@yuriai/web 0.3.1 → 0.3.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-BwB9S5gR.js → AgentAvatar-B4_d0rQt.js} +1 -1
- package/dist/assets/{AssistantConversationSurface-BQJZ0RY8.js → AssistantConversationSurface-BlrOfc3x.js} +3 -3
- package/dist/assets/{AssistantSessionCard-CSpwjbEO.js → AssistantSessionCard-B7cmrLAe.js} +2 -2
- package/dist/assets/{AssistantUnreadBadge-DJQUBf7P.js → AssistantUnreadBadge-DzxFnL8M.js} +1 -1
- package/dist/assets/{AssistantView-BNYeCdPt.js → AssistantView-TODFoL2I.js} +1 -1
- package/dist/assets/{DiagramView-4xy78PeY.js → DiagramView-x3sdXc97.js} +1 -1
- package/dist/assets/{FadeInOnReveal-BSm_Y5N-.js → FadeInOnReveal-C5qpH3TY.js} +1 -1
- package/dist/assets/{GuiPluginPage-Zn-NJGcV.js → GuiPluginPage-D5ajS2AA.js} +1 -1
- package/dist/assets/{GuiPluginSurface-BzbqxS7y.js → GuiPluginSurface-bwXAUscV.js} +1 -1
- package/dist/assets/{GuiPluginWindow-DACvDqJe.js → GuiPluginWindow-SsWHnc4g.js} +1 -1
- package/dist/assets/{Icon-CbRhi6Fu.js → Icon-DBOSvb4U.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-DoSf5jCj.js → ImageLoadingPlaceholder-CrJp1f5y.js} +1 -1
- package/dist/assets/{LoadingImage-2mWVVnaP.js → LoadingImage-zXRrm9H9.js} +1 -1
- package/dist/assets/MarkdownRenderer-eeOXke_U.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-Bs4elVH3.js → MarkdownRendererImpl-BeJCqK7P.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-rHAAvqOj.js → MarkstreamRendererImpl-DOYwdhQ_.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-l_n1taf1.js → MobileDetailNavigation-DVbLG15P.js} +1 -1
- package/dist/assets/{MobileResizableSheet-eCQDQAYS.js → MobileResizableSheet-WTfrQdK8.js} +1 -1
- package/dist/assets/{MobileShareBridge-DGb2HExd.js → MobileShareBridge-CgVEGvAL.js} +1 -1
- package/dist/assets/{MobileSurface-lAYRO5L7.js → MobileSurface-BL4nGTY5.js} +1 -1
- package/dist/assets/{MultiRunWindow-BzkslOOz.js → MultiRunWindow-CMBcfCOh.js} +1 -1
- package/dist/assets/{OnboardingScreen-YNlP1MQe.js → OnboardingScreen-DLMYQLFn.js} +1 -1
- package/dist/assets/{OverlayScrollbar-CTdoPf6E.js → OverlayScrollbar-CwmXL6W2.js} +1 -1
- package/dist/assets/{RemoteAssistantSessionCard-B1Pavyxf.js → RemoteAssistantSessionCard-vCSOg3_8.js} +1 -1
- package/dist/assets/{SettingsView-Bl2kgume.js → SettingsView-DeS2ph7b.js} +1 -1
- package/dist/assets/{SettingsWindow-IUQlRvAB.js → SettingsWindow-CBh8oudq.js} +1 -1
- package/dist/assets/{SetupTourDialog-CPBnXSzq.js → SetupTourDialog-C6SfskP3.js} +1 -1
- package/dist/assets/{TerminalView-9qSzxiHi.js → TerminalView-CJDYSJWP.js} +1 -1
- package/dist/assets/{ToolOutputDialog-CmhQV6kW.js → ToolOutputDialog-DF8dWVTm.js} +1 -1
- package/dist/assets/{VoiceSettings-CfYrDKgr.js → VoiceSettings-C-W8KWvQ.js} +1 -1
- package/dist/assets/{capgoAdapter-BEKE5h5I.js → capgoAdapter-vPx0i-Ad.js} +1 -1
- package/dist/assets/{checkbox-gVpQUiVY.js → checkbox-QxG9Mpbu.js} +1 -1
- package/dist/assets/{collapsible-DCBnoRLL.js → collapsible-BvteRbPh.js} +1 -1
- package/dist/assets/{context-menu-w28HFXdm.js → context-menu-BYPUMFAX.js} +1 -1
- package/dist/assets/{diagram-DGTlsED0.js → diagram-D6B_k7M5.js} +1 -1
- package/dist/assets/{dialog-wyG1j1ZY.js → dialog-BfjbsTOP.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-YTaXrwGt.js → fileMentionTouchSelection-DiKjZQEm.js} +1 -1
- package/dist/assets/{gitApi-Bxuv7iZR.js → gitApi-CtJXK0WM.js} +1 -1
- package/dist/assets/host-Bx9gj-ju.js +1 -0
- package/dist/assets/{input-Bv6SbhDB.js → input-C16jIASm.js} +1 -1
- package/dist/assets/{insertionBoundaries-CIvMb0MT.js → insertionBoundaries-62IwW9Ka.js} +1 -1
- package/dist/assets/{main-DrYyJLms.js → main-CAyhodbD.js} +4 -4
- package/dist/assets/{main-wQ79inDK.js → main-DZedJhQx.js} +2 -2
- package/dist/assets/{markdownHeightCache-D2mAXH8W.js → markdownHeightCache-CDcoG7oI.js} +1 -1
- package/dist/assets/{mcpQueries-CUIUymwN.js → mcpQueries-CQjcxaDQ.js} +1 -1
- package/dist/assets/{miniChat-BTPvGmaS.js → miniChat-DFXcicxI.js} +2 -2
- package/dist/assets/{mobile-DtTmIm4s.js → mobile-CKNvVIUj.js} +2 -2
- package/dist/assets/{mobileBackNavigation-DwKmPsU6.js → mobileBackNavigation-BPncsZvR.js} +1 -1
- package/dist/assets/{mobileConnections-BaVOE5PX.js → mobileConnections-BBNhczt8.js} +2 -2
- package/dist/assets/{multirun-Di_vmRR_.js → multirun-B5DvrZRF.js} +1 -1
- package/dist/assets/{native-config-B3D9Nv0p.js → native-config-1ijMxxRj.js} +1 -1
- package/dist/assets/{navigation-lAkZZJTN.js → navigation-guYHqUd5.js} +1 -1
- package/dist/assets/{openRemoteProjectSession-APe4n1gm.js → openRemoteProjectSession-Dvg3pCz-.js} +1 -1
- package/dist/assets/{projectMeta--OgVpG4Z.js → projectMeta-BOcz1XpN.js} +1 -1
- package/dist/assets/{pwa-B6o6xxPS.js → pwa-D4vcI8VD.js} +1 -1
- package/dist/assets/{queue-abort-optimistic-DYFaJQrY.js → queue-abort-optimistic-BuYzwR0N.js} +1 -1
- package/dist/assets/{react-DVXKhubI.js → react-DEouUmkV.js} +1 -1
- package/dist/assets/{readiness-Di6b1RDu.js → readiness-CzHlOvNr.js} +2 -2
- package/dist/assets/{reference-history-DO4BO4M5.js → reference-history-Dyzfrmw-.js} +1 -1
- package/dist/assets/{remoteSessionReference-CabFQNo2.js → remoteSessionReference-CqNXv4Qg.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-BkHYTNcZ.js → renderElectronMiniChatApp-S8GzGGR7.js} +2 -2
- package/dist/assets/{renderMobileApp-tKRbh1UN.js → renderMobileApp-Bbs497wM.js} +4 -4
- package/dist/assets/{runtimeConfig-Ez0YVcLS.js → runtimeConfig-oElsA8Cz.js} +1 -1
- package/dist/assets/runtimeEndpointReset-DT9dHdmQ.js +151 -0
- package/dist/assets/{select-CrwouN4e.js → select-DpKqX1V6.js} +1 -1
- package/dist/assets/{sessionLookup-BpilZd_w.js → sessionLookup-BHJgGHf0.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-Ijc1-z3K.js → sortable-tabs-strip-a2sshnFf.js} +1 -1
- package/dist/assets/{speechSettingsQueries-cV1mK7RB.js → speechSettingsQueries-DKesZuQ3.js} +1 -1
- package/dist/assets/{textarea-BPhvk5Vd.js → textarea-DPrUh2E_.js} +1 -1
- package/dist/assets/{tooltip-BQ1xVNC6.js → tooltip-JO7-ziD9.js} +1 -1
- package/dist/assets/types-CxdhW05G.js +2 -0
- package/dist/assets/{useAppFontEffects-PZ3Y-JIL.js → useAppFontEffects-DhmTAaeq.js} +5 -5
- package/dist/assets/{useDesktopWindowControlsLayout-Z6PBzcuL.js → useDesktopWindowControlsLayout-C3Bhl4tF.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-DWiz5-Xa.js → useEffectiveDirectory-DsQiUzq0.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-D2FLOd1l.js → useMobileNavigationStore-2N3dS8vX.js} +4 -4
- package/dist/assets/{usePluginsStore-pd_Lgl6m.js → usePluginsStore-nTVPoJCl.js} +1 -1
- package/dist/assets/{useProjectRuntimeAPIs-Me0Uy2tM.js → useProjectRuntimeAPIs-CHhK626l.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-eJaQ-Vpw.js → useStreamingTextThrottle-CNJGj-_8.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +1 -1
- package/package.json +1 -1
- package/server/lib/gui-customization/skill/references/work-status.md +4 -2
- package/dist/assets/MarkdownRenderer-BHK_Ba71.js +0 -2
- package/dist/assets/host-D9EDWNmx.js +0 -1
- package/dist/assets/runtimeEndpointReset-C105_37x.js +0 -151
- package/dist/assets/types-CO7YCNVq.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,n as t}from"./runtime-switch-BMjl5Y5W.js";import{n}from"./runtime-fetch-DKZOpfzo.js";import{a as r,i,r as a}from"./vendor-zustand-Cwko4FG1.js";import{o,ot as s,s as c}from"./vendor-base-ui-z2M4boRm.js";import{t as l}from"./safeStorage-DTOhKN0V.js";import{n as u}from"./client-1Fk5IbQR.js";import{n as d}from"./vendor-react-P8wFrkcT.js";import{s as f}from"./vendor-tanstack-react-query-B-KblYBV.js";import{E as p,J as m,K as h,q as g,z as _}from"./runtime-file-resource-CuLP3xp7.js";import{t as v}from"./i18n-qHllte6P.js";import{In as y,Rn as b,Va as x,za as S}from"./useMobileNavigationStore-D2FLOd1l.js";var C=d(),w=s();function ee(e){let t=(0,C.c)(17),{checked:n,onChange:r,disabled:i,ariaLabel:a,className:s}=e,l=i!==void 0&&i,{t:u}=v(),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=b(`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,w.jsxs)(c,{value:e,nativeButton:!0,render:(0,w.jsx)(y,{variant:`ghost`,size:`xs`}),className:`yuri-settings-switch-option`,children:[n===e&&(0,w.jsx)(`span`,{"aria-hidden":!0,className:`yuri-segmented-selected-pill yuri-settings-switch-pill`}),(0,w.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,w.jsx)(o,{value:n,onValueChange:d,disabled:l,"aria-label":a,"aria-orientation":`horizontal`,"data-slot":`settings-switch`,className:f,onClick:E,onKeyDown:T,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 T(e){return e.stopPropagation()}function E(e){return e.stopPropagation()}function D(e){let t=(0,C.c)(10),{children:n,actions:r,className:i}=e,a;t[0]===i?a=t[1]:(a=b(`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,w.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,w.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,w.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 O(e){let t=(0,C.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=b(`yuri-settings-group`,c),t[0]=c,t[1]=f);let p;t[2]!==r||t[3]!==n||t[4]!==d?(p=r?(0,w.jsx)(D,{className:`py-0`,actions:r,children:n?(0,w.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null}):n?(0,w.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=b(`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,w.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,w.jsx)(`p`,{className:`yuri-settings-group-description text-muted-foreground`,children:a}):null,t[13]=a,t[14]=g);let _;return t[15]!==s||t[16]!==f||t[17]!==p||t[18]!==h||t[19]!==g?(_=(0,w.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]=_):_=t[20],_}function te(e){let t=(0,C.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,w.jsx)(k,{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,w.jsx)(O,{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 k(e){let t=(0,C.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=b(`yuri-settings-group-row yuri-settings-split-row`,s),t[0]=s,t[1]=u);let d;t[2]===c?d=t[3]:(d=b(`yuri-settings-split-row-copy`,c),t[2]=c,t[3]=d);let f;t[4]===n?f=t[5]:(f=n?(0,w.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,w.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,w.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=b(`yuri-settings-split-row-control`,l),t[12]=l,t[13]=h);let g;t[14]!==r||t[15]!==h?(g=(0,w.jsx)(`div`,{"data-settings-value":``,className:h,children:r}),t[14]=r,t[15]=h,t[16]=g):g=t[16];let _;t[17]===a?_=t[18]:(_=a?(0,w.jsx)(`div`,{"data-slot":`settings-row-footer`,className:`col-span-full min-w-0`,children:a}):null,t[17]=a,t[18]=_);let v;return t[19]!==o||t[20]!==u||t[21]!==m||t[22]!==g||t[23]!==_?(v=(0,w.jsxs)(`div`,{"data-settings-item":o,className:u,children:[m,g,_]}),t[19]=o,t[20]=u,t[21]=m,t[22]=g,t[23]=_,t[24]=v):v=t[24],v}function ne(e){let t=(0,C.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=re,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=b(`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,_=u||void 0,v,y;t[7]===f?(v=t[8],y=t[9]):(v=e=>{p(e.target)||f()},y=e=>{p(e.target)||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),f())},t[7]=f,t[8]=v,t[9]=y);let x;t[10]===i?x=t[11]:(x=(0,w.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i}),t[10]=i,t[11]=x);let S;t[12]===o?S=t[13]:(S=o?(0,w.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o}):null,t[12]=o,t[13]=S);let T;t[14]!==S||t[15]!==x?(T=(0,w.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[x,S]}),t[14]=S,t[15]=x,t[16]=T):T=t[16];let E;t[17]!==a||t[18]!==n||t[19]!==u||t[20]!==r?(E=(0,w.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,w.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]!==_||t[29]!==v||t[30]!==y?(D=(0,w.jsxs)(`div`,{"data-settings-item":s,className:h,role:`button`,tabIndex:g,"aria-pressed":n,"aria-disabled":_,onClick:v,onKeyDown:y,children:[T,E]}),t[22]=n,t[23]=s,t[24]=T,t[25]=E,t[26]=h,t[27]=g,t[28]=_,t[29]=v,t[30]=y,t[31]=D):D=t[31],D}function re(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}var A=e=>{let t=e?.trim();return t?{location:{directory:t}}:void 0},ie=()=>{let e=u.getSdkClient().plugin;if(!e?.list||!e.check||!e.update)throw Error(`OpenCode plugin status is not available`);return e},ae=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)}`)}},oe=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)}`)},se=e=>({source:ae(e.source),state:oe(e.state)}),ce=e=>{if(!Array.isArray(e))throw Error(`OpenCode plugin status payload is invalid`);return e.map(e=>se(e))};async function j(e,t){return ce((await ie().list(A(e),t?{signal:t}:void 0))?.data)}async function le(e,t,n){let r=t.trim();if(!r)throw Error(`plugin.update requires a target`);await ie().update({...A(e),targets:[r]},n?{signal:n}:void 0)}function ue(e){return e instanceof Error&&e.message.trim()?e.message:typeof e==`string`&&e.trim()?e:`plugin operation failed`}var de=1500,M=e=>e?.trim()||null,N=(t,n=e())=>m.plugins.list(t,n),P=(t,n,r=!1,i=e())=>m.plugins.registry(t,n,r,i),F=(t,n=e())=>m.plugins.runtime(t,n),I=0,L=()=>(I+=1,I),R=(e,t,n)=>e.getQueryData(F(t,n)),z=(t=S(),n=e(),r)=>{let i=r?t??r.location.directory:M(t),a=_(r);return{queryKey:a.key(N(i,n)),queryFn:async({signal:e})=>{let t=await a.fetch(_e(`/api/config/plugins`,i),{headers:U(i),signal:e});if(!t.ok)throw Error(`Failed to load plugins`);let n=await t.json();return a.assertCurrent(e),{entries:n.entries??[],files:n.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 ye(c)){let a=ve(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}},fe=(t=S(),n=e(),r)=>{let i=r?t??r.location.directory:M(t),a=_(r);return{queryKey:a.key(F(i,n)),queryFn:async({signal:e})=>{if(r){let t=await r.sdk().plugin.list({location:{directory:i??r.location.directory}},{signal:e});if(a.assertCurrent(e),!Array.isArray(t.data))throw Error(`Failed to load remote plugin runtime`);return t.data.map(e=>({source:e.source.type===`package`?{kind:`package`,target:e.source.target,version:e.source.version??null,outdated:e.source.outdated===!0,updating:e.source.updating===!0}:e.source.type===`local`?{kind:`local`,path:e.source.path}:{kind:`builtin`},state:e.state.status===`failed`?{kind:`failed`,error:e.state.error,ref:e.state.ref??null}:{kind:`active`}}))}let t=L(),o=await j(i,e);if(t!==I){let e=R(g,i,n);if(e)return e;throw Error(`Stale plugin runtime read`)}return o},staleTime:5e3,retry:!1}},pe=e=>{let t=(0,C.c)(11),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=p(),a=x(be),o;t[2]!==a||t[3]!==i?.entry.location.directory?(o=i?.entry.location.directory??M(a)??M(u.getDirectory()),t[2]=a,t[3]=i?.entry.location.directory,t[4]=o):o=t[4];let s=i?.entry,c;t[5]!==o||t[6]!==s?(c=z(o,void 0,s),t[5]=o,t[6]=s,t[7]=c):c=t[7];let l;return t[8]!==r.enabled||t[9]!==c?(l={...c,enabled:r.enabled},t[8]=r.enabled,t[9]=c,t[10]=l):l=t[10],f(l)},me=(e,t)=>{let n=(0,C.c)(6),r=t!==void 0&&t,i=x(xe),a;n[0]!==i||n[1]!==r||n[2]!==e?(a=B(M(i)??M(u.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,C.c)(2),t=x(Se),n;return e[0]===t?n=e[1]:(n=M(t)??M(u.getDirectory()),e[0]=t,e[1]=n),n},he=e=>{let t=(0,C.c)(8),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=p(),a=V(),o=i?.entry.location.directory??a,s=i?.entry,c;t[2]!==o||t[3]!==s?(c=fe(o,void 0,s),t[2]=o,t[3]=s,t[4]=c):c=t[4];let l;return t[5]!==r.enabled||t[6]!==c?(l={...c,enabled:r.enabled},t[5]=r.enabled,t[6]=c,t[7]=l):l=t[7],f(l)},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:[]}},ge=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 _e(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function ve(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 ye(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>de){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 be(e){return e.getActiveProject?.()?.path??null}function xe(e){return e.getActiveProject?.()?.path??null}function Se(e){return e.getActiveProject?.()?.path??null}var W=()=>{try{let e=x.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=u.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[PluginsStore] Error resolving config directory:`,e)}return null},Ce=5e3,we=`__default__`,G=new Map,K=new Map,Te=1500,q=e=>e?.trim()||we,Ee=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<Ce)return!0;let p=K.get(l);if(!n?.force&&p)return p;let m=(async()=>{r({isLoading:!0});try{let e=n?.force?await H(g,a,o):await g.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,m);try{return await m}finally{K.delete(l)}},loadRegistryInfo:async e=>{let t=Oe(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 ke(t)){let t=await n(De(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(Ae(e))}));return t.ok&&i().loadRegistryInfo({specs:[e.spec],force:!0}),t},updateEntry:async(t,r)=>{let a=(g.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(Ae(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:l(),partialize:e=>({selectedId:e.selectedId})}),{name:`plugins-store`}));function Y(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function De(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 Oe(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}function ke(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>Te?(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 Ae(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};Ee(o);let l=await H(g,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,pe as c,te as d,O as f,ee as g,D as h,ge as i,ue as l,ne as m,B as n,me as o,k as p,z as r,he as s,J as t,le as u};
|
|
1
|
+
import{i as e,n as t}from"./runtime-switch-BMjl5Y5W.js";import{n}from"./runtime-fetch-DKZOpfzo.js";import{a as r,i,r as a}from"./vendor-zustand-Cwko4FG1.js";import{o,ot as s,s as c}from"./vendor-base-ui-z2M4boRm.js";import{t as l}from"./safeStorage-DTOhKN0V.js";import{n as u}from"./client-1Fk5IbQR.js";import{n as d}from"./vendor-react-P8wFrkcT.js";import{s as f}from"./vendor-tanstack-react-query-B-KblYBV.js";import{E as p,J as m,K as h,q as g,z as _}from"./runtime-file-resource-CuLP3xp7.js";import{t as v}from"./i18n-qHllte6P.js";import{In as y,Rn as b,Va as x,za as S}from"./useMobileNavigationStore-2N3dS8vX.js";var C=d(),w=s();function ee(e){let t=(0,C.c)(17),{checked:n,onChange:r,disabled:i,ariaLabel:a,className:s}=e,l=i!==void 0&&i,{t:u}=v(),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=b(`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,w.jsxs)(c,{value:e,nativeButton:!0,render:(0,w.jsx)(y,{variant:`ghost`,size:`xs`}),className:`yuri-settings-switch-option`,children:[n===e&&(0,w.jsx)(`span`,{"aria-hidden":!0,className:`yuri-segmented-selected-pill yuri-settings-switch-pill`}),(0,w.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,w.jsx)(o,{value:n,onValueChange:d,disabled:l,"aria-label":a,"aria-orientation":`horizontal`,"data-slot":`settings-switch`,className:f,onClick:E,onKeyDown:T,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 T(e){return e.stopPropagation()}function E(e){return e.stopPropagation()}function D(e){let t=(0,C.c)(10),{children:n,actions:r,className:i}=e,a;t[0]===i?a=t[1]:(a=b(`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,w.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,w.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,w.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 O(e){let t=(0,C.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=b(`yuri-settings-group`,c),t[0]=c,t[1]=f);let p;t[2]!==r||t[3]!==n||t[4]!==d?(p=r?(0,w.jsx)(D,{className:`py-0`,actions:r,children:n?(0,w.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null}):n?(0,w.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=b(`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,w.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,w.jsx)(`p`,{className:`yuri-settings-group-description text-muted-foreground`,children:a}):null,t[13]=a,t[14]=g);let _;return t[15]!==s||t[16]!==f||t[17]!==p||t[18]!==h||t[19]!==g?(_=(0,w.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]=_):_=t[20],_}function te(e){let t=(0,C.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,w.jsx)(k,{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,w.jsx)(O,{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 k(e){let t=(0,C.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=b(`yuri-settings-group-row yuri-settings-split-row`,s),t[0]=s,t[1]=u);let d;t[2]===c?d=t[3]:(d=b(`yuri-settings-split-row-copy`,c),t[2]=c,t[3]=d);let f;t[4]===n?f=t[5]:(f=n?(0,w.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,w.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,w.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=b(`yuri-settings-split-row-control`,l),t[12]=l,t[13]=h);let g;t[14]!==r||t[15]!==h?(g=(0,w.jsx)(`div`,{"data-settings-value":``,className:h,children:r}),t[14]=r,t[15]=h,t[16]=g):g=t[16];let _;t[17]===a?_=t[18]:(_=a?(0,w.jsx)(`div`,{"data-slot":`settings-row-footer`,className:`col-span-full min-w-0`,children:a}):null,t[17]=a,t[18]=_);let v;return t[19]!==o||t[20]!==u||t[21]!==m||t[22]!==g||t[23]!==_?(v=(0,w.jsxs)(`div`,{"data-settings-item":o,className:u,children:[m,g,_]}),t[19]=o,t[20]=u,t[21]=m,t[22]=g,t[23]=_,t[24]=v):v=t[24],v}function ne(e){let t=(0,C.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=re,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=b(`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,_=u||void 0,v,y;t[7]===f?(v=t[8],y=t[9]):(v=e=>{p(e.target)||f()},y=e=>{p(e.target)||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),f())},t[7]=f,t[8]=v,t[9]=y);let x;t[10]===i?x=t[11]:(x=(0,w.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i}),t[10]=i,t[11]=x);let S;t[12]===o?S=t[13]:(S=o?(0,w.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o}):null,t[12]=o,t[13]=S);let T;t[14]!==S||t[15]!==x?(T=(0,w.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[x,S]}),t[14]=S,t[15]=x,t[16]=T):T=t[16];let E;t[17]!==a||t[18]!==n||t[19]!==u||t[20]!==r?(E=(0,w.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,w.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]!==_||t[29]!==v||t[30]!==y?(D=(0,w.jsxs)(`div`,{"data-settings-item":s,className:h,role:`button`,tabIndex:g,"aria-pressed":n,"aria-disabled":_,onClick:v,onKeyDown:y,children:[T,E]}),t[22]=n,t[23]=s,t[24]=T,t[25]=E,t[26]=h,t[27]=g,t[28]=_,t[29]=v,t[30]=y,t[31]=D):D=t[31],D}function re(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}var A=e=>{let t=e?.trim();return t?{location:{directory:t}}:void 0},ie=()=>{let e=u.getSdkClient().plugin;if(!e?.list||!e.check||!e.update)throw Error(`OpenCode plugin status is not available`);return e},ae=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)}`)}},oe=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)}`)},se=e=>({source:ae(e.source),state:oe(e.state)}),ce=e=>{if(!Array.isArray(e))throw Error(`OpenCode plugin status payload is invalid`);return e.map(e=>se(e))};async function j(e,t){return ce((await ie().list(A(e),t?{signal:t}:void 0))?.data)}async function le(e,t,n){let r=t.trim();if(!r)throw Error(`plugin.update requires a target`);await ie().update({...A(e),targets:[r]},n?{signal:n}:void 0)}function ue(e){return e instanceof Error&&e.message.trim()?e.message:typeof e==`string`&&e.trim()?e:`plugin operation failed`}var de=1500,M=e=>e?.trim()||null,N=(t,n=e())=>m.plugins.list(t,n),P=(t,n,r=!1,i=e())=>m.plugins.registry(t,n,r,i),F=(t,n=e())=>m.plugins.runtime(t,n),I=0,L=()=>(I+=1,I),R=(e,t,n)=>e.getQueryData(F(t,n)),z=(t=S(),n=e(),r)=>{let i=r?t??r.location.directory:M(t),a=_(r);return{queryKey:a.key(N(i,n)),queryFn:async({signal:e})=>{let t=await a.fetch(_e(`/api/config/plugins`,i),{headers:U(i),signal:e});if(!t.ok)throw Error(`Failed to load plugins`);let n=await t.json();return a.assertCurrent(e),{entries:n.entries??[],files:n.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 ye(c)){let a=ve(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}},fe=(t=S(),n=e(),r)=>{let i=r?t??r.location.directory:M(t),a=_(r);return{queryKey:a.key(F(i,n)),queryFn:async({signal:e})=>{if(r){let t=await r.sdk().plugin.list({location:{directory:i??r.location.directory}},{signal:e});if(a.assertCurrent(e),!Array.isArray(t.data))throw Error(`Failed to load remote plugin runtime`);return t.data.map(e=>({source:e.source.type===`package`?{kind:`package`,target:e.source.target,version:e.source.version??null,outdated:e.source.outdated===!0,updating:e.source.updating===!0}:e.source.type===`local`?{kind:`local`,path:e.source.path}:{kind:`builtin`},state:e.state.status===`failed`?{kind:`failed`,error:e.state.error,ref:e.state.ref??null}:{kind:`active`}}))}let t=L(),o=await j(i,e);if(t!==I){let e=R(g,i,n);if(e)return e;throw Error(`Stale plugin runtime read`)}return o},staleTime:5e3,retry:!1}},pe=e=>{let t=(0,C.c)(11),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=p(),a=x(be),o;t[2]!==a||t[3]!==i?.entry.location.directory?(o=i?.entry.location.directory??M(a)??M(u.getDirectory()),t[2]=a,t[3]=i?.entry.location.directory,t[4]=o):o=t[4];let s=i?.entry,c;t[5]!==o||t[6]!==s?(c=z(o,void 0,s),t[5]=o,t[6]=s,t[7]=c):c=t[7];let l;return t[8]!==r.enabled||t[9]!==c?(l={...c,enabled:r.enabled},t[8]=r.enabled,t[9]=c,t[10]=l):l=t[10],f(l)},me=(e,t)=>{let n=(0,C.c)(6),r=t!==void 0&&t,i=x(xe),a;n[0]!==i||n[1]!==r||n[2]!==e?(a=B(M(i)??M(u.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,C.c)(2),t=x(Se),n;return e[0]===t?n=e[1]:(n=M(t)??M(u.getDirectory()),e[0]=t,e[1]=n),n},he=e=>{let t=(0,C.c)(8),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=p(),a=V(),o=i?.entry.location.directory??a,s=i?.entry,c;t[2]!==o||t[3]!==s?(c=fe(o,void 0,s),t[2]=o,t[3]=s,t[4]=c):c=t[4];let l;return t[5]!==r.enabled||t[6]!==c?(l={...c,enabled:r.enabled},t[5]=r.enabled,t[6]=c,t[7]=l):l=t[7],f(l)},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:[]}},ge=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 _e(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function ve(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 ye(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>de){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 be(e){return e.getActiveProject?.()?.path??null}function xe(e){return e.getActiveProject?.()?.path??null}function Se(e){return e.getActiveProject?.()?.path??null}var W=()=>{try{let e=x.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=u.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[PluginsStore] Error resolving config directory:`,e)}return null},Ce=5e3,we=`__default__`,G=new Map,K=new Map,Te=1500,q=e=>e?.trim()||we,Ee=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<Ce)return!0;let p=K.get(l);if(!n?.force&&p)return p;let m=(async()=>{r({isLoading:!0});try{let e=n?.force?await H(g,a,o):await g.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,m);try{return await m}finally{K.delete(l)}},loadRegistryInfo:async e=>{let t=Oe(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 ke(t)){let t=await n(De(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(Ae(e))}));return t.ok&&i().loadRegistryInfo({specs:[e.spec],force:!0}),t},updateEntry:async(t,r)=>{let a=(g.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(Ae(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:l(),partialize:e=>({selectedId:e.selectedId})}),{name:`plugins-store`}));function Y(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function De(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 Oe(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}function ke(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>Te?(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 Ae(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};Ee(o);let l=await H(g,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,pe as c,te as d,O as f,ee as g,D as h,ge as i,ue as l,ne as m,B as n,me as o,k as p,z as r,he as s,J as t,le as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{st as t}from"./vendor-base-ui-z2M4boRm.js";import{E as n,R as r,V as i}from"./runtime-file-resource-CuLP3xp7.js";import{r as a}from"./terminalApi-Cq0vjFe1.js";import{$n as o}from"./useMobileNavigationStore-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{st as t}from"./vendor-base-ui-z2M4boRm.js";import{E as n,R as r,V as i}from"./runtime-file-resource-CuLP3xp7.js";import{r as a}from"./terminalApi-Cq0vjFe1.js";import{$n as o}from"./useMobileNavigationStore-2N3dS8vX.js";import{n as s}from"./useEffectiveDirectory-DsQiUzq0.js";var c=e(t(),1);function l(){return s()}function u(){let e=i(),t=n(),s=t?.entry.location.hostId?t.entry:void 0,l=(0,c.useMemo)(()=>{if(!s)return null;let e,t=!1,n=()=>{if(t)throw new DOMException(`Project terminal owner ended`,`AbortError`);return e??=a(s)};return{files:r(s),git:o(s),terminal:{createSession:e=>n().createTerminalSession(e),restartSession:(e,t)=>n().restartTerminalSession(e,t),connect:(e,t,r)=>({close:n().connectTerminalStream(e,t.onEvent,t.onError,{maxRetries:r?.retry?.maxRetries,initialRetryDelay:r?.retry?.initialDelayMs,maxRetryDelay:r?.retry?.maxDelayMs,connectionTimeout:r?.connectionTimeoutMs})}),sendInput:(e,t)=>n().sendTerminalInput(e,t),resize:async({sessionId:e,cols:t,rows:r})=>{await n().resizeTerminal(e,t,r)},close:e=>n().closeTerminal(e)},activate:()=>{t=!1},dispose:()=>{t=!0,e?.dispose(),e=void 0}}},[s]);return(0,c.useEffect)(()=>(l?.activate(),()=>l?.dispose()),[l]),(0,c.useMemo)(()=>l?{...e,files:l.files,git:l.git,terminal:l.terminal,github:void 0,editor:void 0,projectScope:s}:{...e,projectScope:void 0},[e,l,s])}export{u as n,l as t};
|
package/dist/assets/{useStreamingTextThrottle-eJaQ-Vpw.js → useStreamingTextThrottle-CNJGj-_8.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./platform-wF65ZFgV.js";import{st as n}from"./vendor-base-ui-z2M4boRm.js";import{r}from"./FadeInOnReveal-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./platform-wF65ZFgV.js";import{st as n}from"./vendor-base-ui-z2M4boRm.js";import{r}from"./FadeInOnReveal-C5qpH3TY.js";var i=e(n(),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:n,throttleMs:s=r(t()).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 t=p.current;t.pendingText=e;let r=f.current,i=n&&r.length>e.length?r:e;if(!n){o(t),t.lastEmitAt=Date.now(),u(i);return}let c=Date.now(),l=a(t.lastEmitAt,c,s);if(l<=0){o(t),t.lastEmitAt=c,u(i);return}return o(t),t.timer=setTimeout(()=>{t.timer=null,t.lastEmitAt=Date.now(),u(e=>n&&e.length>t.pendingText.length?e:t.pendingText)},l),()=>{o(t)}},[n,e,s]),i.useEffect(()=>{let e=p.current;return()=>{o(e)}},[]),l};export{s as t};
|
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-DZedJhQx.js"></script>
|
|
575
575
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-P2Xu9kJm.js">
|
|
576
576
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
577
577
|
<link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js">
|
|
@@ -608,12 +608,12 @@
|
|
|
608
608
|
<link rel="modulepreload" crossorigin href="/assets/gitApiHttp-B0FJaIhU.js">
|
|
609
609
|
<link rel="modulepreload" crossorigin href="/assets/terminalApi-Cq0vjFe1.js">
|
|
610
610
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-download-D11Nnedg.js">
|
|
611
|
-
<link rel="modulepreload" crossorigin href="/assets/types-
|
|
612
|
-
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-
|
|
613
|
-
<link rel="modulepreload" crossorigin href="/assets/native-config-
|
|
611
|
+
<link rel="modulepreload" crossorigin href="/assets/types-CxdhW05G.js">
|
|
612
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-vPx0i-Ad.js">
|
|
613
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-1ijMxxRj.js">
|
|
614
614
|
<link rel="modulepreload" crossorigin href="/assets/runtime-ead7P81A.js">
|
|
615
615
|
<link rel="modulepreload" crossorigin href="/assets/bootstrap-eLlfzqAI.js">
|
|
616
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
616
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-oElsA8Cz.js">
|
|
617
617
|
<link rel="stylesheet" crossorigin href="/assets/src-INJJ62RE.css">
|
|
618
618
|
</head>
|
|
619
619
|
<body class="h-full bg-background text-foreground">
|
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-DFXcicxI.js"></script>
|
|
81
81
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-P2Xu9kJm.js">
|
|
82
82
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
83
83
|
<link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js">
|
|
@@ -114,12 +114,12 @@
|
|
|
114
114
|
<link rel="modulepreload" crossorigin href="/assets/gitApiHttp-B0FJaIhU.js">
|
|
115
115
|
<link rel="modulepreload" crossorigin href="/assets/terminalApi-Cq0vjFe1.js">
|
|
116
116
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-download-D11Nnedg.js">
|
|
117
|
-
<link rel="modulepreload" crossorigin href="/assets/types-
|
|
118
|
-
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-
|
|
119
|
-
<link rel="modulepreload" crossorigin href="/assets/native-config-
|
|
117
|
+
<link rel="modulepreload" crossorigin href="/assets/types-CxdhW05G.js">
|
|
118
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-vPx0i-Ad.js">
|
|
119
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-1ijMxxRj.js">
|
|
120
120
|
<link rel="modulepreload" crossorigin href="/assets/runtime-ead7P81A.js">
|
|
121
121
|
<link rel="modulepreload" crossorigin href="/assets/bootstrap-eLlfzqAI.js">
|
|
122
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
122
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-oElsA8Cz.js">
|
|
123
123
|
<link rel="stylesheet" crossorigin href="/assets/src-INJJ62RE.css">
|
|
124
124
|
</head>
|
|
125
125
|
<body class="h-full bg-background text-foreground">
|
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-CKNvVIUj.js"></script>
|
|
68
68
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-P2Xu9kJm.js">
|
|
69
69
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
70
70
|
<link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js">
|
package/package.json
CHANGED
|
@@ -26,7 +26,7 @@ Web desktop and Electron render the widgets in both inline and popup modes, incl
|
|
|
26
26
|
| --- | --- |
|
|
27
27
|
| `session` | Official `MountedSession` reference for **this displayed conversation**, or `undefined` before a draft has a session/directory. Yuri supports `id`, `key`, `directory`, `server`, `tab`, `pending`, `visit`, `location` on this reference; unsupported SDK members reject as elsewhere. |
|
|
28
28
|
| `directory` | Actual displayed working directory, or `null` while unresolved. Never replaced with another selected project's directory. |
|
|
29
|
-
| `runtimeId` |
|
|
29
|
+
| `runtimeId` | Opaque execution scope identity; Remote Projects include Hub/Host/Location and the captured authorization revision. Not a URL or durable cross-transport key. |
|
|
30
30
|
| `project` | Reactive `{ id?: string, name: string, directory: string } \| null`. Same project/worktree resolution as the built-in rows; a directory fallback can have no project ID. |
|
|
31
31
|
| `worktree` | Reactive `{ name: string, directory: string } \| null`. Explicit attached/discovered worktree, when known. |
|
|
32
32
|
| `git` | Reactive read-only summary described below, shared with the built-in Git rows. |
|
|
@@ -51,9 +51,11 @@ interface GitSummary {
|
|
|
51
51
|
|
|
52
52
|
Theme, locale, plugin options and authenticated client remain on `usePlugin()` / setup `ctx`. `ctx.sessions.current()` still describes the window's primary selection; use the injected session for widget-scoped requests. Existing navigation APIs retain their support boundaries: for example, file navigation for an explicitly different session can be rejected. Do not silently retarget it to the primary conversation.
|
|
53
53
|
|
|
54
|
+
Remote Projects use the current window's GUI inventory and options, not remote GUI code. Their injected `session.id`/`directory` are raw remote values; `session.key` and `session.server.id` are scoped identities, and `session.location` includes Hub/Host and the authenticated instance ID when known. The remote reference is read-only: `session.server.client` is explicitly unsupported, while `ctx.client` and screen/file still belong to the window. Widgets querying their own external service can use their configured endpoint plus the injected session ID. No remote SDK, filesystem or native capability is added by mounting the widget.
|
|
55
|
+
|
|
54
56
|
## Lifecycle and updates
|
|
55
57
|
|
|
56
|
-
Changing project/Git metadata or placement updates the existing Solid view; unrelated session/layout/stream updates do not rebuild the widget catalog or remount its DOM. Changing the displayed session ID, directory or
|
|
58
|
+
Changing project/Git metadata or placement updates the existing Solid view; unrelated session/layout/stream updates do not rebuild the widget catalog or remount its DOM. Changing the displayed session ID, directory, host or captured authorization scope creates a new mount and aborts the previous one. Multiple visible instances have independent props and signals.
|
|
57
59
|
|
|
58
60
|
Use `onCleanup` for listeners and timers, or bind DOM listeners/requests to `props.signal`. Ignore completed asynchronous work after that signal aborts. Registration and rendering exceptions use the existing plugin failure path: affected content disappears, diagnostics remain in plugin settings, and unrelated plugins stay usable. Arbitrary plugin JavaScript still runs on the window's main thread; keep expensive work out of setup/render and stop view-owned work on cleanup.
|
|
59
61
|
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkstreamRendererImpl-rHAAvqOj.js","assets/rolldown-runtime-hePW80VL.js","assets/platform-wF65ZFgV.js","assets/runtime-auth-mjIpsk3N.js","assets/runtime-switch-BMjl5Y5W.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-z2M4boRm.js","assets/vendor-react-P8wFrkcT.js","assets/runtime-file-resource-CuLP3xp7.js","assets/runtime-fetch-DKZOpfzo.js","assets/reasoning-projection-client-BEhVknv9.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/vendor-tanstack-react-query-B-KblYBV.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-Dyjw5sZR.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-Cfmg-aDQ.js","assets/vendor-zustand-Cwko4FG1.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/safeStorage-DTOhKN0V.js","assets/useMobileHtmlPreviewStore-EOAzZiAy.js","assets/vendor-markstream-react-TwEpkgfP.js","assets/vendor-markstream-core-Cm34iPLL.js","assets/vendor-floating-ui-dom-BHhLtF5l.js","assets/vendor-floating-ui-core-Co1I1lFV.js","assets/useMobileNavigationStore-D2FLOd1l.js","assets/gitApiHttp-B0FJaIhU.js","assets/client-1Fk5IbQR.js","assets/vendor-opencode-client-BM2r1f0o.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-9fjmgafL.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-B5HgJenP.js","assets/i18n-qHllte6P.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-BOD3jjMl.js","assets/tour-CMXP3Kif.js","assets/useAssistantUIStore-jOKVcBK8.js","assets/input-store-CsY-uaSj.js","assets/remoteProjectQueries-Dfms-cCx.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useThemeSystem-C57Z9mV2.js","assets/vendor-framer-motion-CF9BQLta.js","assets/tooltip-BQ1xVNC6.js","assets/useEffectiveDirectory-DWiz5-Xa.js","assets/image-loading-DBqnxgDH.js","assets/image-loading-DA9JEHD8.css","assets/LoadingImage-2mWVVnaP.js","assets/ImageLoadingPlaceholder-DoSf5jCj.js","assets/FadeInOnReveal-BSm_Y5N-.js","assets/markdownHeightCache-D2mAXH8W.js","assets/dualLimitLru-D8Sphgua.js","assets/useStreamingTextThrottle-eJaQ-Vpw.js","assets/MarkdownRendererImpl-Bs4elVH3.js","assets/vendor-katex-DNVSTX6g.js","assets/themes-BgDJcxRc.js","assets/vendor-marked-S3gCOYp1.js","assets/markdownTheme-DFDWa8Gh.js","assets/vendor-pierre-diffs-tqo4Z3TC.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/markdown-worker-oBGEB9Eg.js","assets/vendor-morphdom-BbKiNDAu.js","assets/vendor-dompurify-CeJNOzik.js","assets/vendor-pele-C1WTNWUm.js","assets/vendor-remend-C3cXc-tf.js","assets/fileReferenceActions-cYqdsXFz.js","assets/toolHelpers-iEHVHQ9p.js","assets/fileReferenceParser-1HHDBUum.js","assets/MarkstreamRendererImpl-C6aiJnjl.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t}from"./vendor-zustand-Cwko4FG1.js";import{ot as n,st as r}from"./vendor-base-ui-z2M4boRm.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as i}from"./vendor-react-P8wFrkcT.js";import{o as a}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{Rn as o}from"./useMobileNavigationStore-D2FLOd1l.js";import{t as s}from"./useEffectiveDirectory-DWiz5-Xa.js";import{i as c,n as l,t as u}from"./markdownHeightCache-D2mAXH8W.js";var d=e(r(),1),f=i(),p=(e,t)=>{try{let n=t??(typeof localStorage>`u`?null:localStorage);return!n||n.getItem(e)!==`0`}catch{return!0}},m=(e,t)=>{try{typeof localStorage<`u`&&localStorage.setItem(e,t?`1`:`0`)}catch{}},h=`yuri:markstream-react`,g=e=>p(h,e),_=t(e=>({markstreamReactEnabled:g(),setMarkstreamReactEnabled:t=>{m(h,t),e({markstreamReactEnabled:t})}})),v=null,y=()=>(v??=a(()=>import(`./MarkstreamRendererImpl-rHAAvqOj.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85])).catch(e=>{throw v=null,e}),v),b=()=>{y().catch(()=>void 0)},x=null,S=()=>(x??=a(()=>import(`./MarkdownRendererImpl-Bs4elVH3.js`).then(e=>e.n),__vite__mapDeps([62,1,4,3,2,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,63,38,39,40,41,42,30,31,32,33,34,35,36,37,43,44,45,46,47,48,49,60,50,64,53,54,55,58,59,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84])).catch(e=>{throw x=null,e}),x),C=()=>{S().catch(()=>void 0),g()&&b()},w=`yuri:chunk-import-reload`,T=250,E=3e4,D=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function O(e){if(e instanceof Error)return`${e.name}\n${e.message}\n${e.stack??``}`;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function k(e){let t=O(e);return D.some(e=>e.test(t))}function A(e){return`0.3.1:${O(e).slice(0,500)}`}function j(e){if(typeof window>`u`)return;let t=Date.now(),n=A(e),r=null;try{let e=window.sessionStorage.getItem(w);if(e)try{r=JSON.parse(e)}catch{r=null}}catch{return}let i=typeof r?.timestamp==`number`?r.timestamp:0;if(!(r?.signature===n&&t-i<E)){try{window.sessionStorage.setItem(w,JSON.stringify({signature:n,timestamp:t}))}catch{return}console.error(`[refresh-debug] chunk-import-reload`,{error:O(e).slice(0,1e3)}),window.setTimeout(()=>{window.location.reload()},0)}}async function M(e,t={}){let n=t.retries??1,r;for(let t=0;t<=n;t+=1)try{return await e()}catch(e){if(r=e,!k(e)||t>=n)break;await new Promise(e=>setTimeout(e,T*(t+1)))}throw k(r)&&j(r),r}var N=e=>(0,d.lazy)(()=>M(e)),P=(e,t)=>!!t?.toLowerCase().startsWith(`video/`)||/^data:video\//i.test(e)||/\.(?:mp4|m4v|webm|mov|ogv|ogg)(?:[?#]|$)/i.test(e),F=class extends d.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.warn(`[markstream-react] falling back to the current Markdown renderer`,e)}render(){return this.state.hasError?this.props.fallback:this.props.children}},I=d.createContext(!0),L=()=>d.useContext(I),R=n(),z=N(()=>S().then(e=>({default:e.MarkdownRenderer}))),B=N(()=>y().then(e=>({default:e.MarkstreamRenderer}))),V=N(()=>S().then(e=>({default:e.SimpleMarkdownRenderer}))),H=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,U=e=>{let t=(0,f.c)(15),n=_(K),r=typeof e.content==`string`?e.content:``,i=typeof e.variant==`string`?e.variant:`assistant`,a;t[0]!==r||t[1]!==n||t[2]!==e.reserveMeasuredHeight||t[3]!==i?(a=e.reserveMeasuredHeight?l(u(r,n?`markstream:${i}`:i)):void 0,t[0]=r,t[1]=n,t[2]=e.reserveMeasuredHeight,t[3]=i,t[4]=a):a=t[4];let s=a,d;t[5]!==e.className||t[6]!==e.variant?(d=o(`relative break-words w-full min-w-0`,H(e.variant),typeof e.className==`string`?e.className:void 0),t[5]=e.className,t[6]=e.variant,t[7]=d):d=t[7];let p;t[8]!==r||t[9]!==e.animated||t[10]!==s?(p=(0,R.jsx)(c,{animated:e.animated,content:r,reservedHeight:s}),t[8]=r,t[9]=e.animated,t[10]=s,t[11]=p):p=t[11];let m;return t[12]!==d||t[13]!==p?(m=(0,R.jsx)(`div`,{className:d,"aria-busy":`true`,"data-markdown-hydration":`deferred`,"data-markdown-ready":`false`,children:p}),t[12]=d,t[13]=p,t[14]=m):m=t[14],m},W=e=>{let t=(0,f.c)(13),n=L(),r=_(q);if(!n&&e.isStreaming!==!0){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1,reserveMeasuredHeight:!0}),t[0]=e,t[1]=n),n}let i;t[2]===e?i=t[3]:(i=(0,R.jsx)(d.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(z,{...e})}),t[2]=e,t[3]=i);let a=i,o;t[4]!==a||t[5]!==r||t[6]!==e?(o=r?(0,R.jsx)(F,{fallback:a,children:(0,R.jsx)(d.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(B,{...e})})}):a,t[4]=a,t[5]=r,t[6]=e,t[7]=o):o=t[7];let c=o,l;t[8]===e?l=t[9]:(l=t=>{if(!e.onShowPopup||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let n=t.target instanceof Element?t.target.closest(`a[href]`):null,r=n?.getAttribute(`href`);if(!r||!P(r))return;t.preventDefault(),t.stopPropagation();let i=n?.textContent?.trim()||r.split(/[/?#]/).filter(Boolean).pop()||r;e.onShowPopup({open:!0,title:i,content:``,video:{url:r,filename:i,directory:s()??``}})},t[8]=e,t[9]=l);let u;return t[10]!==c||t[11]!==l?(u=(0,R.jsx)(`div`,{className:`contents`,onClickCapture:l,children:c}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u},G=e=>{let t=(0,f.c)(4);if(!L()){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,R.jsx)(d.Suspense,{fallback:(0,R.jsx)(U,{...e}),children:(0,R.jsx)(V,{...e})}),t[2]=e,t[3]=n),n};function K(e){return e.markstreamReactEnabled}function q(e){return e.markstreamReactEnabled}export{N as a,P as i,G as n,C as o,I as r,W as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{f as e,n as t}from"./platform-wF65ZFgV.js";import{C as n,D as r,I as i,L as a,M as o,O as s,P as c,S as l,T as u,_ as d,a as f,b as p,c as m,j as h,n as g,o as _,r as v,s as y,t as ee,v as b,w as x,y as S}from"./vendor-opencode-client-BM2r1f0o.js";import{a as te}from"./vendor-tanstack-query-core-BSjXNgF_.js";import{b as ne,v as C}from"./runtime-file-resource-CuLP3xp7.js";import{o as w}from"./path-utils-jGozTg9d.js";import{a as T,n as re}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{Dt as ie,ht as ae,mt as oe,y as se}from"./vendor-effect-X1Hqc7ba.js";import{t as E}from"./native-errors-06if6eu-.js";import{a as ce,i as le,n as ue,o as de,r as fe,s as D}from"./appearance-DFsI3pnP.js";import{i as pe,o as me}from"./fileReferenceParser-1HHDBUum.js";import{a as he,r as O}from"./pages-CYkE04ml.js";import{n as ge,t as _e}from"./vendor-solid-js-BBVUd3Hw.js";import{a as ve,c as ye,d as be,f as k,g as A,h as j,i as M,l as N,m as xe,n as Se,o as P,p as F,r as Ce,s as we,t as Te,u as Ee}from"./vendor-opencode-plugin-ZhpPgHCL.js";var I={"@opencode/plugin/gui":P,"@opencode/plugin/gui/main":P,"@opencode/plugin/gui/file":ve,"@opencode/plugin/gui/review":M,"@opencode/plugin/gui/browser":Ce,"@opencode/plugin/rpc":Te,"@opencode/schema/rpc":Se,"@opencode/client":v,"@opencode/client/effect":g,"@opencode/client/solid":ee,effect:se,"solid-js":c,"solid-js/web":ge,"solid-js/store":y},De=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 Oe(){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 ke(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(I,e))return I[e];if(e===`electron`||e.startsWith(`node:`)||De.has(e))return Oe();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 E(`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 E(`GUI_PLUGIN_UNSUPPORTED`,`OS-restricted plugins require the native GUI host`);if(!Array.isArray(i.os)||!i.os.includes(t))throw new E(`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)||!ie(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(t){let n=t;if(/^file:/i.test(n)){let e=new URL(n);n=`${e.hostname&&e.hostname!==`localhost`?`//${e.hostname}`:``}${decodeURIComponent(e.pathname)}`,/^\/[a-z]:\//i.test(n)&&(n=n.slice(1))}let r=e(n)??``;return r===`.`?``:r}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,Ae=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=s();return this.ended||n&&this.endedOwners.has(n)?Promise.resolve():(this.acquireApiLease(e),this.sync(e,t?.force))},unwatch:e=>this.releaseApiLease(s(),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 n=this.resolve(e),i=r();if(!i||this.ended)return n;let a=`${t}:${n}`,s=this.subscriptions.get(a);s||(s={revision:u(0),listeners:new Set},this.subscriptions.set(a,s));let c=s;return c.listeners.has(i)||(c.listeners.add(i),o(i,()=>h(()=>{c.listeners.delete(i),!c.listeners.size&&this.subscriptions.get(a)===c&&this.subscriptions.delete(a)}))),c.revision[0](),n}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),d(()=>{this.changed(e,`file`),n?.notFound===!0!=(t.notFound===!0)&&this.changed(e,`missing`)}))}acquireApiLease(e){let t=s();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),h(()=>{`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),d(()=>{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=C(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 te(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(m(e)),je=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=oe(a.schema),l=ae(a.schema),d=c(l(W(a.initial)));if(JSON.stringify(l(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]=u(f),g=e=>{r();let t=JSON.stringify(l(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]=f(W(t.initial)),c=[o,e=>{r();let t=W(m(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(_(t))}];return this.memory.set(i,[o,e=>{let t=W(m(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(_(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()}};function Me(e){if(typeof e!=`string`||e.length>2097152)return;let t=e.trim();if(t)try{if(t.startsWith(`<`))return D(t);if(!/^data:/i.test(t))return t;let e=/^data:image\/(svg\+xml|png|jpeg|gif|webp|avif|x-icon|vnd\.microsoft\.icon)(?:;charset=utf-8)?(;base64)?,([\s\S]+)$/i.exec(t);if(!e)return;let[,n,r,i]=e;if(r&&!/^[A-Za-z0-9+/]+={0,2}$/.test(i))return;if(n.toLowerCase()===`svg+xml`){let e=r?new TextDecoder(`utf-8`,{fatal:!0}).decode(Uint8Array.from(atob(i),e=>e.charCodeAt(0))):decodeURIComponent(i);return D(e)}return!r||!atob(i).length?void 0:`data:image/${n.toLowerCase()};base64,${i}`}catch{return}}var G=e=>e===`yuri.exportPDF`||e===`yuri.exportLongImage`,Ne=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]=u(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:A(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 Pe(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 E(`GUI_PLUGIN_UNSUPPORTED`,`GUI toast is unavailable`);if(!i||typeof i!=`object`)throw new E(`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 E(`GUI_PLUGIN_INVALID_INPUT`,`Invalid toast options`);if(u!==void 0||d!==void 0)throw new E(`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 Fe=T(`YuriMedia`);async function Ie(e){let n=/\.html?$/i.test(e.name)?`text/html`:`text/plain`,r=new Blob([e.content],{type:n});if(t()){if(!re.isPluginAvailable(`YuriMedia`))throw new E(`GUI_PLUGIN_UNSUPPORTED`,`Native file saving is unavailable`);if(r.size>33554432)throw new E(`GUI_PLUGIN_INVALID_INPUT`,`File exceeds maximum size`);let t=await new Promise((e,t)=>{let n=new FileReader;n.onload=()=>{if(typeof n.result!=`string`){t(Error(`Failed to encode file`));return}e(n.result.slice(n.result.indexOf(`,`)+1))},n.onerror=()=>t(n.error??Error(`Failed to encode file`)),n.readAsDataURL(r)});return!(await Fe.saveFile({dataBase64:t,mimeType:n,filename:e.name})).cancelled}let i=URL.createObjectURL(r),a=document.createElement(`a`);try{return a.href=i,a.download=e.name,document.body.append(a),a.click(),!0}finally{a.remove(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}}var K=p();function Le(e){return{version:1,register(t){let n=a(K);if(!n||n.plugin!==e||n.signal.aborted||e.aborted)throw Error(`Preview actions require the owning mounted panel`);let r=new AbortController,i=AbortSignal.any([e,n.signal,r.signal]),o,s=()=>{i.removeEventListener(`abort`,s),r.abort(),o?.remove()};h(s),i.addEventListener(`abort`,s,{once:!0});try{o=t.render({element:t.element,signal:i,async snapshot(e={}){let r=AbortSignal.any([i,...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 a=await t.capture({...e,signal:r});if(r.throwIfAborted(),!n.content.contains(t.element))throw Error(`Preview capture region was replaced`);return a}}),i.throwIfAborted(),n.target.append(o)}catch(e){throw s(),e}return s}}}var Re=`yuri.work-status`;function q(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 J=e=>e&&Object.freeze({...e});function Y(e,t,n){let r=new AbortController,[i,a]=u(!0),[o,s]=u(J(e.project),{equals:q}),[c,l]=u(J(e.worktree),{equals:q}),[f,p]=u(Object.freeze({...e.git}),{equals:q}),[m,h]=u(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||d(()=>{s(J(e.project)),l(J(e.worktree)),p(Object.freeze({...e.git})),h(e.placement)})},dispose(){r.signal.aborted||(a(!1),r.abort())}}}var ze=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)i(e)}}},X=e=>{throw new E(`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 Be(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 Ve=class{options;fileIcons=new de;appearanceCatalog=new le;workStatus=new ze;instances=new Map;listeners=new Set;panelMounts=new Set;fileViews=new Map;changes=u(0);views=u(0);session=u();currentPage=u();mobilePageNetworkReady=u(!1);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 Ne(e.viewExport),this.appearance=u({locale:e.locale,mode:e.mode,narrow:e.narrow}),this.storage=new je(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 Ae(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)}setMobilePageNetworkReady(e){this.mobilePageNetworkReady[1](!this.ended&&e)}install(e,t,r){if(this.options.mobileNetworkRequired&&!this.mobilePageNetworkReady[0]()&&!this.ended)throw new E(`GUI_PLUGIN_UNAVAILABLE`,`Mobile plugin Relay is not ready`);let a=this.instances.get(e);if(this.ended||a?.status===`active`&&a.revision===t.revision&&a.native?.active!==!1){r?.dispose();return}a&&(this.instances.delete(e),this.release(a));let c={id:e,native:r,revision:t.revision,controller:new AbortController,status:`active`,cleanups:new Set,contributions:new Set,iconChanges:u(0),appearanceChanges:u(0),workStatusChanges:u(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 a=ke(t.code,r?.activation.os);x(e=>{c.dispose=e,c.root=s(),b(()=>S(j.Provider,{value:c.context=this.context(c,a,t.options),get children(){c.owner=s();let e=i(()=>a.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||o(c.owner,()=>n(()=>{if(c.iconChanges[0](),!c.controller.signal.aborted)try{let e=[...c.contributions].filter(e=>e.registry===ce).map(e=>e.read()).filter(e=>e!==void 0);this.fileIcons.replace(c.id,e),c.iconError!==void 0&&i(()=>{c.iconError=void 0,this.publish()})}catch(e){i(()=>{this.fileIcons.remove(c.id),c.iconError=e instanceof Error?e.message:String(e),this.publish()})}})),c.controller.signal.aborted||o(c.owner,()=>n(()=>{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(ue),c.native?.activation.capabilities?.dockIcon===!0)}catch(e){i(()=>this.fail(c,e))}})),c.controller.signal.aborted||o(c.owner,()=>n(()=>{if(c.workStatusChanges[0](),!c.controller.signal.aborted)try{let e=[...c.contributions].filter(e=>e.registry===Re).map(e=>e.read()).filter(e=>e!==void 0);this.workStatus.replace(c.id,c.revision,e)}catch(e){i(()=>this.fail(c,e))}})),c.controller.signal.aborted||o(c.owner,()=>n(()=>{this.changes[0](),this.session[0](),this.appearance[0]();try{this.derive(c)}catch(e){i(()=>this.fail(c,e))}i(()=>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 E&&(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,d(()=>{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||a(F)?.ended?(r(),r):(e.cleanups.add(r),s()&&h(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,t,r){let o=this.storage.forPlugin(e.id,e.controller.signal),c=Object.fromEntries(Object.entries(t.stores??{}).map(([e,t])=>[e,t.scope===`global`?o.store(e,{...t,scope:`global`}):n=>o.store(e,{...t,scope:{session:n}})])),u=(e,n)=>{let r=this.appearance[0]().locale;return(t.i18n?.[r]?.[e]??t.i18n?.[r.split(`-`)[0]]?.[e]??t.i18n?.en?.[e]??e).replace(/\{\{(\w+)\}\}/g,(e,t)=>String(n?.[t]??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(N).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=Le(e.controller.signal),p=A(()=>e.controller.signal.aborted?{status:`inactive`,reason:`disabled`}:{status:`active`,generation:1,value:f}),m={open:t=>e.controller.signal.aborted||this.appearance[0]().narrow&&!this.mobilePageNetworkReady[0]()||!e.pages.some(e=>e.id===t)?!1:this.options.openPage?.(O(e.id,t))??!1,current:()=>{let t=this.currentPage[0]();return e.pages.find(n=>O(e.id,n.id)===t)?.id}},g=A(()=>e.controller.signal.aborted||!this.options.openPage||this.appearance[0]().narrow&&!this.mobilePageNetworkReady[0]()?{status:`inactive`,reason:`disabled`}:{status:`active`,generation:1,value:m});return Z(`ctx`,{id:e.id,options:r,signal:e.controller.signal,client:this.options.client,storage:o,stores:c,toast:Pe(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:(t,r)=>{if(e.controller.signal.aborted||a(F)?.ended)return()=>{};if([`server`,`composer-pill`,`slot`,`file.viewer`,`menubar-item`].includes(t.id)&&X(`registry.${t.id}`),e.contributions.size>=256)throw Error(`GUI contribution limit exceeded`);let o=()=>{},c,u=x(i=>{o=i,c=s();let a=()=>typeof r==`function`?r():r,u;if(t.id===`yuri.file-icon`){let e=l(()=>{try{return{ok:!0,value:a()}}catch(e){return{ok:!1,error:e}}});u=()=>{let t=e();if(!t.ok)throw t.error;return t.value}}else u=l(a);if(t.id===`style`){let t=document.createElement(`style`);t.dataset.yuriPluginStyle=e.id,document.head.append(t),h(()=>t.remove()),n(()=>{let e=u();t.textContent=e===void 0?``:String(e)})}return{registry:t.id,read:u}},s()??e.owner);e.contributions.add(u);let d=()=>{t.id===`yuri.file-icon`&&e.iconChanges[1](e=>e+1)},f=()=>{(t.id===`yuri.theme`||t.id===`yuri.branding`)&&e.appearanceChanges[1](e=>e+1)},p=()=>{t.id===`yuri.work-status`&&e.workStatusChanges[1](e=>e+1)};return i(d),i(f),i(p),i(()=>this.changed()),this.own(e,()=>{$(c,t=>{e.error??=String(t)}),o(),e.contributions.delete(u),i(d),i(f),i(p),i(()=>this.changed())})},list:e=>this.list(e),provide:(t,n)=>{if(e.controller.signal.aborted||a(F)?.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 E(`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 E(`GUI_PLUGIN_UNSUPPORTED`)}:()=>Promise.reject(new E(`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:Ie},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=>i(()=>{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=u({status:`inactive`,reason:`disabled`});n={live:[A(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=[],r=[],a=[],o=[],s=[],c=this.session[0]();for(let i of e.contributions){if([`yuri.file-icon`,`yuri.theme`,`yuri.branding`,`yuri.work-status`].includes(i.registry))continue;let l=i.read();if(l!==void 0){if(i.registry===`yuri.page`){let e=he(l);if(s.some(t=>t.id===e.id))throw Error(`Duplicate yuri.page id`);s.push(e)}else if(i.registry===we.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(i.registry===k.id){let t=l;o.push({key:JSON.stringify([e.id,t.id]),pluginId:e.id,label:t.label,title:t.title,icon:Me(t.icon),busy:t.busy,pressed:t.pressed,actionable:!!t.run,run:t.run})}else if(i.registry===Ee.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(i.registry===be.id){let e=l;(e.page||e.section)&&X(`SettingsPage host sections`),e.title,r.push(e)}else if(i.registry===N.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=r,e.menus=a,i(()=>this.views[1](e=>e+1))}publish(){let e=i(this.session[0]),t=e?this.layouts.get(e.key):void 0,n=[...this.instances.values()],r=n.filter(e=>e.status===`active`),a=r.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(r.flatMap(e=>e.commands.filter(e=>!e.hidden))),panels:Q(a),titlebarItems:Q(r.flatMap(e=>e.titlebarItems.map(({run:e,...t})=>t))),pages:Q(r.flatMap(e=>e.pages.map(t=>({key:O(e.id,t.id),pluginId:e.id,title:t.title,icon:t.icon})))),settings:Q(r.flatMap(e=>e.settings.map(t=>({key:`${e.id}:${t.id}`,pluginId:e.id,title:t.title})))),menuItems:Q(r.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=o(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===ye.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(e,t){if(this.ended)return!1;let n=me(t.href);if(!n||!pe(n.path))return this.openLink(t);let r=this.session[0]();if(!r||t.session&&(t.session.key!==r.key||t.session.server.id!==r.server.id))return!1;if(!this.options.focusFile)return this.openLink(t);let i=w(t.base??r.directory,n.path),a=n.line===void 0?``:`:${n.line}${n.column===void 0?``:`:${n.column}`}`;return this.invoke(e,()=>this.options.focusFile(i+a,r.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?l(()=>{let e=r();return{tab:e,fields:Object.getPrototypeOf(e)===Object.prototype?Object.getOwnPropertyDescriptors(e):void 0}},void 0,{equals:Be}):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,t,r){let a=this.panel(e);if(!a)return()=>{};let o=new AbortController,s=()=>{let s=l(()=>{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});n(()=>{let e=s();e&&(h(e.model.watch(e.file)),e.model.sync(e.file).catch(()=>{}))});let c=()=>i(()=>a.panel.render(this.props(e,!0)));return S(K.Provider,{value:r?{plugin:a.plugin.controller.signal,signal:o.signal,content:t,target:r}:void 0,get children(){return c()}})},c=this.mount(a.plugin,t,()=>S(xe.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(),c()};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&&!this.mobilePageNetworkReady[0]())throw new E(`GUI_PLUGIN_UNAVAILABLE`,`Mobile page Relay is not ready`);for(let n of this.instances.values()){let r=n.pages.find(t=>O(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=Y(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 r=()=>{},a,o=t=>{queueMicrotask(()=>this.fail(e,t))};try{r=_e(()=>S(j.Provider,{value:e.context,get children(){return a=s(),b(()=>i(n),o)}}),t)}catch(t){this.fail(e,t)}return this.own(e,()=>{$(a,t=>{e.error??=String(t)}),r(),t.replaceChildren()})}};export{Ve as GuiPluginHost};
|