reactive-vscode 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@reactive-vscode/reactivity"),i=require("vscode");function L(e){return n.getCurrentScope()?(n.onScopeDispose(e),!0):!1}function D(e,t){const o=new Map;return(...a)=>{const s=t(...a);let c=o.get(s);return c?c.refCount++:(c={data:e(...a),refCount:1},o.set(s,c)),L(()=>{--c.refCount===0&&o.delete(s)}),c.data}}function g(e){let t=!1,o;return()=>(t||(o=n.effectScope(!0).run(e),t=!0),o)}const S=[];function G(e){S.push(e)}const b=n.shallowRef(null),T=n.effectScope();function J(e){return{activate:t=>(b.value=t,T.run(()=>(k.map(o=>o(t)),e(t)))),deactivate:()=>{S.map(t=>t()),T.stop()}}}const k=[];function y(e){b.value?e(b.value):k.push(e)}function M(e,t,o){const a=!e,s=i.workspace.getConfiguration(a?void 0:e,o);function c(l,f){const d=n.shallowRef(f),w=n.computed({get:()=>d.value,set:v=>{d.value=v,s.update(l,v)}});return w.update=async(v,h,m)=>{await s.update(l,v,h,m),w.value=v},w.set=v=>{d.value=v},w}const u=Object.fromEntries(Object.keys(t).map(l=>[l,c(l,s.get(l))]));return y(()=>{r(i.workspace.onDidChangeConfiguration(a?l=>{const f=i.workspace.getConfiguration();for(const d in t)l.affectsConfiguration(d)&&u[d].set(f.get(d))}:l=>{if(!l.affectsConfiguration(e))return;const f=i.workspace.getConfiguration(e);for(const d in t)l.affectsConfiguration(`${e}.${d}`)&&u[d].set(f.get(d))}))}),u}function X(e,t,o){const a=M(e,t,o),s={},c=n.shallowReactive({$update(u,l,f,d){return a[u].update(l,f,d)},$set(u,l){return a[u].set(l)}});for(const u in t){const l=u.split(".");let f="",d=s,w=c;for(const h of l.slice(0,-1)){f=f?`${f}.${h}`:h;const m=d=d[h]||={};if(w[h])w=w[h];else{const I=n.shallowReactive({});Object.defineProperty(w,h,{enumerable:!0,get(){return I},set(Y){function W(x,R,F){if(x)for(const V in x)W(x[V],R?`${R}.${V}`:V,F?.[V]);else a[R].value=F}W(m,f,Y)}}),w=I}}const v=l[l.length-1];d[v]=null,Object.defineProperty(w,v,{enumerable:!0,get(){return a[u].value},set(h){a[u].value=h}})}return c}function Z(e,t){const o=n.shallowRef(null),a=[],s=c=>(...u)=>o.value?o.value[c](...u):(a.push([c,u]),null);return y(()=>{o.value=q(e,t);for(const[c,u]of a)o.value[c](...u)}),{logger:o,outputChannel:n.computed(()=>o.value?.outputChannel),info:s("info"),warn:s("warn"),error:s("error"),append:s("append"),appendLine:s("appendLine"),replace:s("replace"),clear:s("clear"),show:s("show"),hide:s("hide")}}function _(e,...t){return i.commands.executeCommand(e,...t)}function ee(e,t=!1){const o=b.value;if(!o&&!t)throw new Error("Cannot get absolute path because the extension is not activated yet");return o?.asAbsolutePath(e)}function te(e,t=!1){return n.computed(()=>ee(n.toValue(e),t))}function r(e){return(n.getCurrentScope()??T).cleanups.push(e.dispose.bind(e)),e}const N=g(()=>{const e=n.shallowRef(i.window.activeColorTheme);return r(i.window.onDidChangeActiveColorTheme(t=>{e.value=t})),e}),ne=g(()=>{const e=n.shallowRef(i.debug.activeDebugSession);return r(i.debug.onDidChangeActiveDebugSession(t=>{e.value=t})),n.computed(()=>e.value)}),$=g(()=>{const e=n.shallowRef(i.window.activeTextEditor);return r(i.window.onDidChangeActiveTextEditor(t=>{e.value=t})),e});function j(e){const t=n.shallowRef(n.toValue(e)?.getText());return n.watchEffect(()=>{t.value=n.toValue(e)?.getText()}),r(i.workspace.onDidChangeTextDocument(o=>{o.document===n.toValue(e)&&(t.value=o.document.getText())})),t}function H(e,t,o,a={}){const{updateOn:s=["effect","documentChanged"]}=a;let c;const u=n.computed(()=>{c?.dispose(),c=void 0;const d=n.toValue(t);if("key"in d)return d;const w=i.window.createTextEditorDecorationType(d);return c=r(w),w}),l=async()=>{const d=n.toValue(e);d&&d.setDecorations(u.value,typeof o=="function"?await o(d):n.toValue(o))},f=s.includes("documentChanged")?j(()=>n.toValue(e)?.document):null;return s.includes("effect")?n.watchEffect(async()=>{f?.value,await l()}):f&&n.watch(f,l),{update:l}}function oe(e,t,o={}){const a=$();return H(a,e,t,o)}const ae=g(()=>{const e=n.shallowRef(i.window.activeNotebookEditor);return r(i.window.onDidChangeActiveNotebookEditor(t=>{e.value=t})),e}),ie=g(()=>{const e=n.shallowRef(i.window.activeTerminal);return r(i.window.onDidChangeActiveTerminal(t=>{e.value=t})),e}),se=g(()=>{const e=n.shallowRef(i.extensions.all);return r(i.extensions.onDidChange(()=>{e.value=i.extensions.all})),n.computed(()=>e.value)});function p(e,t){const o=(a,s,c)=>{r(e(a,s,c))};return t?.forEach(a=>o(a)),o}function O(e,t,o){for(const a of o){const s=t[a];s!==void 0&&n.watchEffect(()=>{e[a]=n.toValue(s)})}}const ue=D((e,t,o={})=>{const a=r(i.chat.createChatParticipant(e,n.unref(t)));return O(a,o,["iconPath"]),o.followupProvider!==void 0&&n.watchEffect(()=>{a.followupProvider=n.unref(o.followupProvider)}),n.watchEffect(()=>{a.requestHandler=n.unref(t)}),{onDidReceiveFeedback:p(a.onDidReceiveFeedback)}},e=>e);function B(e,t){r(i.commands.registerCommand(e,t))}function ce(e){for(const[t,o]of Object.entries(e))o&&B(t,o)}function re(e,t){return r(i.comments.createCommentController(e,t))}function P(e){const t=n.shallowRef(n.toValue(e)?.state);return n.watch(e,()=>{t.value=n.toValue(e)?.state}),r(i.window.onDidChangeTerminalState(o=>{o===n.toValue(e)&&(t.value=o.state)})),n.computed(()=>t.value)}function le(...e){const t=n.ref(null);function o(){return!!t.value&&t.value.exitStatus==null}function a(){return o()?t.value:t.value=i.window.createTerminal(...e)}function s(l){a().sendText(l)}function c(){a().show()}function u(){o()&&(t.value.sendText(""),t.value.dispose(),t.value=null)}return n.onScopeDispose(u),{terminal:t,getIsActive:o,show:c,sendText:s,close:u,state:P(t)}}const de=g(()=>{const e=n.shallowRef(i.env.shell);return r(i.env.onDidChangeShell(t=>{e.value=t})),n.computed(()=>e.value)});function C(e,t=[]){const o=Array.isArray(e)?e:t??[],a=r(Array.isArray(e)||e==null?new i.EventEmitter:e),s=p(a.event,o);for(const c of o)s(c);return{event:a.event,fire:a.fire.bind(a),addListener:s}}async function fe(e){const t=b.value.secrets,o=n.ref(await t.get(e));return o.set=async a=>{o.value=a,await t.store(e,a)},o.remove=async()=>{o.value=void 0,await t.delete(e)},r(t.onDidChange(async a=>{a.key===e&&(o.value=await t.get(e))})),n.watch(o,a=>{a===void 0?t.delete(e):t.store(e,a)}),o}function ve(e){return n.computed(()=>i.tasks.fetchTasks(n.toValue(e)))}function we(e){return n.computed(()=>i.Uri.file(n.toValue(e)))}function he(e,t){const o=new i.EventEmitter,a=n.shallowRef();n.watchEffect(()=>{a.value&&o.fire(),a.value=n.toValue(t)}),r(i.languages.registerFoldingRangeProvider(e,{onDidChangeFoldingRanges:o.event,provideFoldingRanges(s,c,u){return a.value?.(s,c,u)}}))}function ge(e,t,o,a){const s=n.shallowReactive(new Map),c=C(),u=C(),l=C(),f=n.computed(()=>{const v=n.toValue(e);return Array.isArray(v)?v:v instanceof Set?Array.from(v):[v]});function d(){const v=f.value;for(const[h,m]of s)v.includes(h)||(m.dispose(),s.delete(h));for(const h of v)if(!s.has(h)){const m=i.workspace.createFileSystemWatcher(h,n.toValue(t)||!1,n.toValue(o)||!1,n.toValue(a)||!1);m.onDidCreate(c.fire),m.onDidChange(u.fire),m.onDidDelete(l.fire),s.set(h,m)}}function w(){for(const v of s.values())v.dispose();s.clear()}return d(),n.watch(f,d),n.watch(()=>[n.toValue(t),n.toValue(o),n.toValue(a)],()=>{w(),d()}),n.onScopeDispose(w),{watchers:s,onDidCreate:c.event,onDidChange:u.event,onDidDelete:l.event}}const me=g(()=>{const e=N();return n.computed(()=>e.value.kind===i.ColorThemeKind.Dark||e.value.kind===i.ColorThemeKind.HighContrast)}),pe=g(()=>{const e=n.shallowRef(i.env.isTelemetryEnabled);return r(i.env.onDidChangeTelemetryEnabled(t=>{e.value=t})),n.computed(()=>e.value)});function be(e,...t){return n.computed(()=>typeof t[0]=="object"?i.l10n.t(n.toValue(e),n.toRaw(t[0])):i.l10n.t(n.toValue(e),...t.map(n.toValue)))}const Ce=g(()=>{const e=n.shallowRef(i.lm.tools);return r(i.lm.onDidChangeChatModels(()=>{e.value=i.lm.tools})),n.computed(()=>e.value)});function K(e,t){return r(i.window.createOutputChannel(e,t))}function Ve(e){const t=new Date,o=String(t.getFullYear()).padStart(4,"0"),a=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),c=String(t.getHours()).padStart(2,"0"),u=String(t.getMinutes()).padStart(2,"0"),l=String(t.getSeconds()).padStart(2,"0"),f=String(t.getMilliseconds()).padStart(3,"0");return`${o}-${a}-${s} ${c}:${u}:${l}.${f} [${e}] `}function q(e,t={}){const o=t.outputChannel??K(e,{log:!0}),a=s=>(...c)=>{o.appendLine((t.getPrefix?.(s)??"")+c.join(" "))};return{outputChannel:o,createLoggerFunc:a,info:a("INFO"),warn:a("WARN"),error:a("ERROR"),append:o.append.bind(o),appendLine:o.appendLine.bind(o),replace:o.replace.bind(o),clear:o.clear.bind(o),show:o.show.bind(o),hide:o.hide.bind(o)}}const Te=g(()=>{const e=n.shallowRef(i.env.logLevel);return r(i.env.onDidChangeLogLevel(t=>{e.value=t})),n.computed(()=>e.value)});function Q(e){const t=n.shallowRef(n.toValue(e)?.selections??[]);return n.watch(e,()=>{t.value=n.toValue(e)?.selections??[]}),r(i.window.onDidChangeNotebookEditorSelection(o=>{o.notebookEditor===n.toValue(e)&&(t.value=o.selections)})),n.computed({get(){return t.value},set(o){t.value=o;const a=n.toValue(e);a&&(a.selections=o)}})}function De(e){const t=Q(e);return n.computed({get(){return t.value[0]},set(o){t.value=t.value.toSpliced(0,1,o)}})}function Ee(e){const t=n.shallowRef(n.toValue(e)?.visibleRanges??[]);return n.watch(e,()=>{t.value=n.toValue(e)?.visibleRanges??[]}),r(i.window.onDidChangeNotebookEditorVisibleRanges(o=>{o.notebookEditor===n.toValue(e)&&(t.value=o.visibleRanges)})),n.computed(()=>t.value)}const xe=g(()=>{const e=n.shallowRef(i.window.terminals);function t(){e.value=i.window.terminals}return r(i.window.onDidOpenTerminal(t)),r(i.window.onDidCloseTerminal(t)),e});function Re(e={}){const t=r(i.window.createQuickPick()),o=p(t.onDidChangeActive),a=p(t.onDidChangeSelection),s=p(t.onDidAccept),c=p(t.onDidHide),u=p(t.onDidTriggerButton),l=p(t.onDidChangeValue);["items","buttons","title","step","totalSteps","enabled","busy","ignoreFocusOut","placeholder","canSelectMany","matchOnDescription","matchOnDetail","keepScrollPosition"].forEach(v=>{e[v]&&n.watchEffect(()=>t[v]=n.toValue(e[v]))}),e.value&&(t.value=e.value);const f=n.shallowRef(t.value);l(v=>f.value=v),e.activeItems&&(t.activeItems=e.activeItems);const d=n.shallowRef(t.activeItems);o(v=>d.value=v),e.selectedItems&&(t.selectedItems=e.selectedItems);const w=n.shallowRef(t.selectedItems);return a(v=>w.value=v),{...t,onDidChangeActive:o,onDidChangeSelection:a,onDidAccept:s,onDidHide:c,onDidTriggerButton:u,onDidChangeValue:l,value:f,activeItems:d,selectedItems:w}}function Se(e){const t=r(e.id?i.window.createStatusBarItem(e.id,e.alignment,e.priority):i.window.createStatusBarItem(e.alignment,e.priority));return O(t,e,["name","text","tooltip","color","backgroundColor","command","accessibilityInformation"]),e.visible!=null?n.watchEffect(()=>{n.toValue(e.visible)?t.show():t.hide()}):t.show(),t}const ke=g(()=>{const e=n.shallowRef(i.tasks.taskExecutions);function t(){e.value=i.tasks.taskExecutions}return r(i.tasks.onDidStartTask(t)),r(i.tasks.onDidEndTask(t)),n.computed(()=>e.value)});function ye(...e){const t=r(i.window.createTerminal(...e));return{terminal:t,get name(){return t.name},get processId(){return t.processId},get creationOptions(){return t.creationOptions},get exitStatus(){return t.exitStatus},get shellIntegration(){return t.shellIntegration},sendText:t.sendText.bind(t),show:t.show.bind(t),hide:t.hide.bind(t),state:P(t)}}function U(e,t){r(i.commands.registerTextEditorCommand(e,t))}function Oe(e){for(const[t,o]of Object.entries(e))U(t,o)}function z(e,t){const o=n.shallowRef(n.toValue(e)?.selections??[]);return n.watch(e,()=>{o.value=n.toValue(e)?.selections??[]}),r(i.window.onDidChangeTextEditorSelection(a=>{const s=n.toValue(e),c=n.toValue(t);a.textEditor===s&&(!c||c.includes(a.kind))&&(o.value=a.selections)})),n.computed({get(){return o.value},set(a){o.value=a;const s=n.toValue(e);s&&(s.selections=a)}})}function Pe(e,t){const o=z(e,t);return n.computed({get(){return o.value[0]},set(a){o.value=o.value.toSpliced(0,1,a)}})}function Ae(e){const t=n.shallowRef(n.toValue(e)?.viewColumn);return n.watch(e,()=>{t.value=n.toValue(e)?.viewColumn}),r(i.window.onDidChangeTextEditorViewColumn(o=>{o.textEditor===n.toValue(e)&&(t.value=o.viewColumn)})),n.computed(()=>t.value)}function Ie(e){const t=n.shallowRef(n.toValue(e)?.visibleRanges??[]);return n.watch(e,()=>{t.value=n.toValue(e)?.visibleRanges??[]}),r(i.window.onDidChangeTextEditorVisibleRanges(o=>{o.textEditor===n.toValue(e)&&(t.value=o.visibleRanges)})),n.computed(()=>t.value)}function A(e,t){n.watchEffect(()=>{const o=n.toValue(e);o&&(o.badge=n.toValue(t))})}function E(e,t){n.watchEffect(()=>{const o=n.toValue(e);o&&(o.title=n.toValue(t))})}const We=D((e,t,o)=>{const a=C();n.watch(t,()=>a.fire()),o?.watchSource&&n.watch(o.watchSource,()=>a.fire());const s=new WeakMap,c=r(i.window.createTreeView(e,{...o,treeDataProvider:{...o,onDidChangeTreeData:a.event,getTreeItem(u){return u.treeItem},async getChildren(u){if(u){const l=await u.children;return l?.forEach(f=>s.set(f,u)),l}return n.toValue(t)},getParent(u){return s.get(u)}}}));return o?.title&&E(c,o.title),o?.badge&&A(c,o.badge),c},e=>e);function Fe(e){const t=n.ref(n.toValue(e)?.visible);function o(){t.value=n.toValue(e)?.visible}return n.watchEffect(a=>{const s=n.toValue(e);if(s){const c=s.onDidChangeVisibility(o);a(()=>c.dispose())}}),n.watchEffect(o),n.computed(()=>!!t.value)}const Le=g(()=>{const e=n.shallowRef(i.window.visibleNotebookEditors);return r(i.window.onDidChangeVisibleNotebookEditors(t=>{e.value=t})),e}),Me=g(()=>{const e=n.shallowRef(i.window.visibleTextEditors);return r(i.window.onDidChangeVisibleTextEditors(t=>{e.value=t})),e});function Ne(e,t,o=!0){const a=n.isRef(t)?t:typeof t=="function"?n.computed(t):n.ref(t);return n.watchEffect(()=>{n.toValue(o)&&i.commands.executeCommand("setContext",e,a.value)}),a}function $e(e,t,o,a,s){const c=n.shallowRef(),u=r(i.window.createWebviewPanel(e,n.toValue(t),a,{enableFindWidget:s?.enableFindWidget,retainContextWhenHidden:s?.retainContextWhenHidden,...n.toValue(s?.webviewOptions)}));s?.onDidReceiveMessage&&u.webview.onDidReceiveMessage(s.onDidReceiveMessage);const l=n.ref(0);function f(){l.value++}if(n.watchEffect(()=>{u.webview.html=`${n.toValue(o)}<!--${l.value}-->`}),s?.webviewOptions){const h=s.webviewOptions;n.watchEffect(()=>{u.webview.options=n.toValue(h)})}E(u,t);function d(h){return u.webview.postMessage(h)}const w=n.ref(u.active),v=n.ref(u.visible);return r(u.onDidChangeViewState(()=>{w.value=u.active,v.value=u.visible})),{panel:u,context:c,active:w,visible:v,postMessage:d,forceRefresh:f}}const je=D((e,t,o)=>{const a=n.shallowRef(),s=n.shallowRef();r(i.window.registerWebviewViewProvider(e,{resolveWebviewView(f,d){a.value=f,s.value=d,o?.onDidReceiveMessage&&f.webview.onDidReceiveMessage(o.onDidReceiveMessage)}},{webviewOptions:{retainContextWhenHidden:o?.retainContextWhenHidden}}));const c=n.ref(0);function u(){c.value++}if(n.watchEffect(()=>{a.value&&(a.value.webview.html=`${n.toValue(t)}<!--${c.value}-->`)}),o?.webviewOptions){const f=o.webviewOptions;n.watchEffect(()=>{a.value&&(a.value.webview.options=n.toValue(f))})}o?.title&&E(a,o.title),o?.badge&&A(a,o.badge);function l(f){return a.value?.webview.postMessage(f)}return{view:a,context:s,postMessage:l,forceRefresh:u}},e=>e),He=g(()=>{const e=n.shallowRef(i.window.state);return r(i.window.onDidChangeWindowState(t=>{e.value=t})),{focused:n.computed(()=>e.value.focused),active:n.computed(()=>e.value.active)}}),Be=g(()=>{const e=n.shallowRef(i.workspace.workspaceFolders);return r(i.workspace.onDidChangeWorkspaceFolders(()=>{e.value=i.workspace.workspaceFolders})),n.computed(()=>e.value)});exports.activateCbs=k;exports.createKeyedComposable=D;exports.createSingletonComposable=g;exports.deactivateCbs=S;exports.defineConfigObject=X;exports.defineConfigs=M;exports.defineExtension=J;exports.defineLogger=Z;exports.executeCommand=_;exports.extensionContext=b;exports.extensionScope=T;exports.getDefaultLoggerPrefix=Ve;exports.onActivate=y;exports.onDeactivate=G;exports.tryOnScopeDispose=L;exports.useAbsolutePath=te;exports.useActiveColorTheme=N;exports.useActiveDebugSession=ne;exports.useActiveEditorDecorations=oe;exports.useActiveNotebookEditor=ae;exports.useActiveTerminal=ie;exports.useActiveTextEditor=$;exports.useAllExtensions=se;exports.useChatParticipant=ue;exports.useCommand=B;exports.useCommands=ce;exports.useCommentController=re;exports.useControlledTerminal=le;exports.useDefaultShell=de;exports.useDisposable=r;exports.useDocumentText=j;exports.useEditorDecorations=H;exports.useEvent=p;exports.useEventEmitter=C;exports.useExtensionSecret=fe;exports.useFetchTasks=ve;exports.useFileUri=we;exports.useFoldingRangeProvider=he;exports.useFsWatcher=ge;exports.useIsDarkTheme=me;exports.useIsTelemetryEnabled=pe;exports.useL10nText=be;exports.useLmTools=Ce;exports.useLogLevel=Te;exports.useLogger=q;exports.useNotebookEditorSelection=De;exports.useNotebookEditorSelections=Q;exports.useNotebookEditorVisibleRanges=Ee;exports.useOpenedTerminals=xe;exports.useOutputChannel=K;exports.useQuickPick=Re;exports.useReactiveOptions=O;exports.useStatusBarItem=Se;exports.useTaskExecutions=ke;exports.useTerminal=ye;exports.useTerminalState=P;exports.useTextEditorCommand=U;exports.useTextEditorCommands=Oe;exports.useTextEditorSelection=Pe;exports.useTextEditorSelections=z;exports.useTextEditorViewColumn=Ae;exports.useTextEditorVisibleRanges=Ie;exports.useTreeView=We;exports.useViewBadge=A;exports.useViewTitle=E;exports.useViewVisibility=Fe;exports.useVisibleNotebookEditors=Le;exports.useVisibleTextEditors=Me;exports.useVscodeContext=Ne;exports.useWebviewPanel=$e;exports.useWebviewView=je;exports.useWindowState=He;exports.useWorkspaceFolders=Be;Object.keys(n).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>n[e]})});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@reactive-vscode/reactivity"),s=require("vscode");function L(e){return n.getCurrentScope()?(n.onScopeDispose(e),!0):!1}function D(e,t){const o=new Map;return(...i)=>{const a=t(...i);let r=o.get(a);return r?r.refCount++:(r={data:e(...i),refCount:1},o.set(a,r)),L(()=>{--r.refCount===0&&o.delete(a)}),r.data}}const R=[];function M(e){R.push(e)}function g(e){let t=!1,o=!1,i;return()=>{if(!o){if(t)throw new Error("Cannot call a singleton composable recursively.");try{t=!0;const a=n.effectScope(!0);M(()=>a.stop()),i=a.run(e),o=!0}finally{t=!1}}return i}}const b=n.shallowRef(null),T=n.effectScope();function J(e){return{activate:t=>(b.value=t,T.run(()=>(k.map(o=>o(t)),e(t)))),deactivate:()=>{R.map(t=>t()),T.stop()}}}const k=[];function y(e){b.value?e(b.value):k.push(e)}function $(e,t,o){const i=!e,a=s.workspace.getConfiguration(i?void 0:e,o);function r(l,f){const d=n.shallowRef(f),w=n.computed({get:()=>d.value,set:v=>{d.value=v,a.update(l,v)}});return w.update=async(v,h,m)=>{await a.update(l,v,h,m),d.value=v},w.set=v=>{d.value=v},w}const u=Object.fromEntries(Object.keys(t).map(l=>[l,r(l,a.get(l))]));return y(()=>{c(s.workspace.onDidChangeConfiguration(i?l=>{const f=s.workspace.getConfiguration();for(const d in t)l.affectsConfiguration(d)&&u[d].set(f.get(d))}:l=>{if(!l.affectsConfiguration(e))return;const f=s.workspace.getConfiguration(e);for(const d in t)l.affectsConfiguration(`${e}.${d}`)&&u[d].set(f.get(d))}))}),u}function X(e,t,o){const i=$(e,t,o),a={},r=n.shallowReactive({$update(u,l,f,d){return i[u].update(l,f,d)},$set(u,l){return i[u].set(l)}});for(const u in t){const l=u.split(".");let f="",d=a,w=r;for(const h of l.slice(0,-1)){f=f?`${f}.${h}`:h;const m=d=d[h]||={};if(w[h])w=w[h];else{const I=n.shallowReactive({});Object.defineProperty(w,h,{enumerable:!0,get(){return I},set(G){function W(x,S,F){if(x)for(const V in x)W(x[V],S?`${S}.${V}`:V,F?.[V]);else i[S].value=F}W(m,f,G)}}),w=I}}const v=l[l.length-1];d[v]=null,Object.defineProperty(w,v,{enumerable:!0,get(){return i[u].value},set(h){i[u].value=h}})}return r}function Z(e,t){const o=n.shallowRef(null),i=[],a=r=>(...u)=>o.value?o.value[r](...u):(i.push([r,u]),null);return y(()=>{o.value=Q(e,t);for(const[r,u]of i)o.value[r](...u)}),{logger:o,outputChannel:n.computed(()=>o.value?.outputChannel),info:a("info"),warn:a("warn"),error:a("error"),append:a("append"),appendLine:a("appendLine"),replace:a("replace"),clear:a("clear"),show:a("show"),hide:a("hide")}}const _=g;function ee(e,...t){return s.commands.executeCommand(e,...t)}function te(e,t=!1){const o=b.value;if(!o&&!t)throw new Error("Cannot get absolute path because the extension is not activated yet");return o?.asAbsolutePath(e)}function ne(e,t=!1){return n.computed(()=>te(n.toValue(e),t))}function c(e){return(n.getCurrentScope()??T).cleanups.push(e.dispose.bind(e)),e}const N=g(()=>{const e=n.shallowRef(s.window.activeColorTheme);return c(s.window.onDidChangeActiveColorTheme(t=>{e.value=t})),e}),oe=g(()=>{const e=n.shallowRef(s.debug.activeDebugSession);return c(s.debug.onDidChangeActiveDebugSession(t=>{e.value=t})),n.computed(()=>e.value)}),j=g(()=>{const e=n.shallowRef(s.window.activeTextEditor);return c(s.window.onDidChangeActiveTextEditor(t=>{e.value=t})),e});function H(e){const t=n.shallowRef(n.toValue(e)?.getText());return n.watchEffect(()=>{t.value=n.toValue(e)?.getText()}),c(s.workspace.onDidChangeTextDocument(o=>{o.document===n.toValue(e)&&(t.value=o.document.getText())})),t}function B(e,t,o,i={}){const{updateOn:a=["effect","documentChanged"]}=i;let r;const u=n.computed(()=>{r?.dispose(),r=void 0;const d=n.toValue(t);if("key"in d)return d;const w=s.window.createTextEditorDecorationType(d);return r=c(w),w}),l=async()=>{const d=n.toValue(e);d&&d.setDecorations(u.value,typeof o=="function"?await o(d):n.toValue(o))},f=a.includes("documentChanged")?H(()=>n.toValue(e)?.document):null;return a.includes("effect")?n.watchEffect(async()=>{f?.value,await l()}):f&&n.watch(f,l),{update:l}}function ie(e,t,o={}){const i=j();return B(i,e,t,o)}const ae=g(()=>{const e=n.shallowRef(s.window.activeNotebookEditor);return c(s.window.onDidChangeActiveNotebookEditor(t=>{e.value=t})),e}),se=g(()=>{const e=n.shallowRef(s.window.activeTerminal);return c(s.window.onDidChangeActiveTerminal(t=>{e.value=t})),e}),ue=g(()=>{const e=n.shallowRef(s.extensions.all);return c(s.extensions.onDidChange(()=>{e.value=s.extensions.all})),n.computed(()=>e.value)});function p(e,t){const o=(i,a,r)=>{c(e(i,a,r))};return t?.forEach(i=>o(i)),o}function P(e,t,o){for(const i of o){const a=t[i];a!==void 0&&n.watchEffect(()=>{e[i]=n.toValue(a)})}}const re=D((e,t,o={})=>{const i=c(s.chat.createChatParticipant(e,n.unref(t)));return P(i,o,["iconPath"]),o.followupProvider!==void 0&&n.watchEffect(()=>{i.followupProvider=n.unref(o.followupProvider)}),n.watchEffect(()=>{i.requestHandler=n.unref(t)}),{onDidReceiveFeedback:p(i.onDidReceiveFeedback)}},e=>e);function K(e,t){c(s.commands.registerCommand(e,t))}function ce(e){for(const[t,o]of Object.entries(e))o&&K(t,o)}function le(e,t){return c(s.comments.createCommentController(e,t))}function O(e){const t=n.shallowRef(n.toValue(e)?.state);return n.watch(e,()=>{t.value=n.toValue(e)?.state}),c(s.window.onDidChangeTerminalState(o=>{o===n.toValue(e)&&(t.value=o.state)})),n.computed(()=>t.value)}function de(...e){const t=n.ref(null);function o(){return!!t.value&&t.value.exitStatus==null}function i(){return o()?t.value:t.value=s.window.createTerminal(...e)}function a(l){i().sendText(l)}function r(){i().show()}function u(){o()&&(t.value.sendText(""),t.value.dispose(),t.value=null)}return n.onScopeDispose(u),{terminal:t,getIsActive:o,show:r,sendText:a,close:u,state:O(t)}}const fe=g(()=>{const e=n.shallowRef(s.env.shell);return c(s.env.onDidChangeShell(t=>{e.value=t})),n.computed(()=>e.value)});function C(e,t=[]){const o=Array.isArray(e)?e:t??[],i=c(Array.isArray(e)||e==null?new s.EventEmitter:e),a=p(i.event,o);for(const r of o)a(r);return{event:i.event,fire:i.fire.bind(i),addListener:a}}async function ve(e){const t=b.value.secrets,o=n.ref(await t.get(e));return o.set=async i=>{o.value=i,await t.store(e,i)},o.remove=async()=>{o.value=void 0,await t.delete(e)},c(t.onDidChange(async i=>{i.key===e&&(o.value=await t.get(e))})),n.watch(o,i=>{i===void 0?t.delete(e):t.store(e,i)}),o}function we(e){return n.computed(()=>s.tasks.fetchTasks(n.toValue(e)))}function he(e){return n.computed(()=>s.Uri.file(n.toValue(e)))}function ge(e,t){const o=new s.EventEmitter,i=n.shallowRef();n.watchEffect(()=>{i.value&&o.fire(),i.value=n.toValue(t)}),c(s.languages.registerFoldingRangeProvider(e,{onDidChangeFoldingRanges:o.event,provideFoldingRanges(a,r,u){return i.value?.(a,r,u)}}))}function me(e,t,o,i){const a=n.shallowReactive(new Map),r=C(),u=C(),l=C(),f=n.computed(()=>{const v=n.toValue(e);return Array.isArray(v)?v:v instanceof Set?Array.from(v):[v]});function d(){const v=f.value;for(const[h,m]of a)v.includes(h)||(m.dispose(),a.delete(h));for(const h of v)if(!a.has(h)){const m=s.workspace.createFileSystemWatcher(h,n.toValue(t)||!1,n.toValue(o)||!1,n.toValue(i)||!1);m.onDidCreate(r.fire),m.onDidChange(u.fire),m.onDidDelete(l.fire),a.set(h,m)}}function w(){for(const v of a.values())v.dispose();a.clear()}return d(),n.watch(f,d),n.watch(()=>[n.toValue(t),n.toValue(o),n.toValue(i)],()=>{w(),d()}),n.onScopeDispose(w),{watchers:a,onDidCreate:r.event,onDidChange:u.event,onDidDelete:l.event}}const pe=g(()=>{const e=N();return n.computed(()=>e.value.kind===s.ColorThemeKind.Dark||e.value.kind===s.ColorThemeKind.HighContrast)}),be=g(()=>{const e=n.shallowRef(s.env.isTelemetryEnabled);return c(s.env.onDidChangeTelemetryEnabled(t=>{e.value=t})),n.computed(()=>e.value)});function Ce(e,...t){return n.computed(()=>typeof t[0]=="object"?s.l10n.t(n.toValue(e),n.toRaw(t[0])):s.l10n.t(n.toValue(e),...t.map(n.toValue)))}const Ve=g(()=>{const e=n.shallowRef(s.lm.tools);return c(s.lm.onDidChangeChatModels(()=>{e.value=s.lm.tools})),n.computed(()=>e.value)});function q(e,t){return c(s.window.createOutputChannel(e,t))}function Te(e){const t=new Date,o=String(t.getFullYear()).padStart(4,"0"),i=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0"),r=String(t.getHours()).padStart(2,"0"),u=String(t.getMinutes()).padStart(2,"0"),l=String(t.getSeconds()).padStart(2,"0"),f=String(t.getMilliseconds()).padStart(3,"0");return`${o}-${i}-${a} ${r}:${u}:${l}.${f} [${e}] `}function Q(e,t={}){const o=t.outputChannel??q(e,{log:!0}),i=t.toConsole??["error","warn"],a=r=>(...u)=>{o.appendLine((t.getPrefix?.(r)??"")+u.join(" ")),i.includes(r)&&console[r](...u)};return{outputChannel:o,createLoggerFunc:a,info:a("info"),warn:a("warn"),error:a("error"),append:o.append.bind(o),appendLine:o.appendLine.bind(o),replace:o.replace.bind(o),clear:o.clear.bind(o),show:o.show.bind(o),hide:o.hide.bind(o)}}const De=g(()=>{const e=n.shallowRef(s.env.logLevel);return c(s.env.onDidChangeLogLevel(t=>{e.value=t})),n.computed(()=>e.value)});function U(e){const t=n.shallowRef(n.toValue(e)?.selections??[]);return n.watch(e,()=>{t.value=n.toValue(e)?.selections??[]}),c(s.window.onDidChangeNotebookEditorSelection(o=>{o.notebookEditor===n.toValue(e)&&(t.value=o.selections)})),n.computed({get(){return t.value},set(o){t.value=o;const i=n.toValue(e);i&&(i.selections=o)}})}function Ee(e){const t=U(e);return n.computed({get(){return t.value[0]},set(o){t.value=t.value.toSpliced(0,1,o)}})}function xe(e){const t=n.shallowRef(n.toValue(e)?.visibleRanges??[]);return n.watch(e,()=>{t.value=n.toValue(e)?.visibleRanges??[]}),c(s.window.onDidChangeNotebookEditorVisibleRanges(o=>{o.notebookEditor===n.toValue(e)&&(t.value=o.visibleRanges)})),n.computed(()=>t.value)}const Se=g(()=>{const e=n.shallowRef(s.window.terminals);function t(){e.value=s.window.terminals}return c(s.window.onDidOpenTerminal(t)),c(s.window.onDidCloseTerminal(t)),e});function Re(e={}){const t=c(s.window.createQuickPick()),o=p(t.onDidChangeActive),i=p(t.onDidChangeSelection),a=p(t.onDidAccept),r=p(t.onDidHide),u=p(t.onDidTriggerButton),l=p(t.onDidChangeValue);["items","buttons","title","step","totalSteps","enabled","busy","ignoreFocusOut","placeholder","canSelectMany","matchOnDescription","matchOnDetail","keepScrollPosition"].forEach(v=>{e[v]&&n.watchEffect(()=>t[v]=n.toValue(e[v]))}),e.value&&(t.value=e.value);const f=n.shallowRef(t.value);l(v=>f.value=v),e.activeItems&&(t.activeItems=e.activeItems);const d=n.shallowRef(t.activeItems);o(v=>d.value=v),e.selectedItems&&(t.selectedItems=e.selectedItems);const w=n.shallowRef(t.selectedItems);return i(v=>w.value=v),{...t,onDidChangeActive:o,onDidChangeSelection:i,onDidAccept:a,onDidHide:r,onDidTriggerButton:u,onDidChangeValue:l,value:f,activeItems:d,selectedItems:w}}function ke(e){const t=c(e.id?s.window.createStatusBarItem(e.id,e.alignment,e.priority):s.window.createStatusBarItem(e.alignment,e.priority));return P(t,e,["name","text","tooltip","color","backgroundColor","command","accessibilityInformation"]),e.visible!=null?n.watchEffect(()=>{n.toValue(e.visible)?t.show():t.hide()}):t.show(),t}const ye=g(()=>{const e=n.shallowRef(s.tasks.taskExecutions);function t(){e.value=s.tasks.taskExecutions}return c(s.tasks.onDidStartTask(t)),c(s.tasks.onDidEndTask(t)),n.computed(()=>e.value)});function Pe(...e){const t=c(s.window.createTerminal(...e));return{terminal:t,get name(){return t.name},get processId(){return t.processId},get creationOptions(){return t.creationOptions},get exitStatus(){return t.exitStatus},get shellIntegration(){return t.shellIntegration},sendText:t.sendText.bind(t),show:t.show.bind(t),hide:t.hide.bind(t),state:O(t)}}function z(e,t){c(s.commands.registerTextEditorCommand(e,t))}function Oe(e){for(const[t,o]of Object.entries(e))z(t,o)}function Y(e,t){const o=n.shallowRef(n.toValue(e)?.selections??[]);return n.watch(e,()=>{o.value=n.toValue(e)?.selections??[]}),c(s.window.onDidChangeTextEditorSelection(i=>{const a=n.toValue(e),r=n.toValue(t);i.textEditor===a&&(!r||r.includes(i.kind))&&(o.value=i.selections)})),n.computed({get(){return o.value},set(i){o.value=i;const a=n.toValue(e);a&&(a.selections=i)}})}function Ae(e,t){const o=Y(e,t);return n.computed({get(){return o.value[0]},set(i){o.value=o.value.toSpliced(0,1,i)}})}function Ie(e){const t=n.shallowRef(n.toValue(e)?.viewColumn);return n.watch(e,()=>{t.value=n.toValue(e)?.viewColumn}),c(s.window.onDidChangeTextEditorViewColumn(o=>{o.textEditor===n.toValue(e)&&(t.value=o.viewColumn)})),n.computed(()=>t.value)}function We(e){const t=n.shallowRef(n.toValue(e)?.visibleRanges??[]);return n.watch(e,()=>{t.value=n.toValue(e)?.visibleRanges??[]}),c(s.window.onDidChangeTextEditorVisibleRanges(o=>{o.textEditor===n.toValue(e)&&(t.value=o.visibleRanges)})),n.computed(()=>t.value)}function A(e,t){n.watchEffect(()=>{const o=n.toValue(e);o&&(o.badge=n.toValue(t))})}function E(e,t){n.watchEffect(()=>{const o=n.toValue(e);o&&(o.title=n.toValue(t))})}const Fe=D((e,t,o)=>{const i=C();n.watch(t,()=>i.fire()),o?.watchSource&&n.watch(o.watchSource,()=>i.fire());const a=new WeakMap,r=c(s.window.createTreeView(e,{...o,treeDataProvider:{...o,onDidChangeTreeData:i.event,getTreeItem(u){return u.treeItem},async getChildren(u){if(u){const l=await u.children;return l?.forEach(f=>a.set(f,u)),l}return n.toValue(t)},getParent(u){return a.get(u)}}}));return o?.title&&E(r,o.title),o?.badge&&A(r,o.badge),r},e=>e);function Le(e){const t=n.ref(n.toValue(e)?.visible);function o(){t.value=n.toValue(e)?.visible}return n.watchEffect(i=>{const a=n.toValue(e);if(a){const r=a.onDidChangeVisibility(o);i(()=>r.dispose())}}),n.watchEffect(o),n.computed(()=>!!t.value)}const Me=g(()=>{const e=n.shallowRef(s.window.visibleNotebookEditors);return c(s.window.onDidChangeVisibleNotebookEditors(t=>{e.value=t})),e}),$e=g(()=>{const e=n.shallowRef(s.window.visibleTextEditors);return c(s.window.onDidChangeVisibleTextEditors(t=>{e.value=t})),e});function Ne(e,t,o=!0){const i=n.isRef(t)?t:typeof t=="function"?n.computed(t):n.ref(t);return n.watchEffect(()=>{n.toValue(o)&&s.commands.executeCommand("setContext",e,i.value)}),i}function je(e,t,o,i,a){const r=n.shallowRef(),u=c(s.window.createWebviewPanel(e,n.toValue(t),i,{enableFindWidget:a?.enableFindWidget,retainContextWhenHidden:a?.retainContextWhenHidden,...n.toValue(a?.webviewOptions)}));a?.onDidReceiveMessage&&u.webview.onDidReceiveMessage(a.onDidReceiveMessage);const l=n.ref(0);function f(){l.value++}if(n.watchEffect(()=>{u.webview.html=`${n.toValue(o)}<!--${l.value}-->`}),a?.webviewOptions){const h=a.webviewOptions;n.watchEffect(()=>{u.webview.options=n.toValue(h)})}E(u,t);function d(h){return u.webview.postMessage(h)}const w=n.ref(u.active),v=n.ref(u.visible);return c(u.onDidChangeViewState(()=>{w.value=u.active,v.value=u.visible})),{panel:u,context:r,active:w,visible:v,postMessage:d,forceRefresh:f}}const He=D((e,t,o)=>{const i=n.shallowRef(),a=n.shallowRef();c(s.window.registerWebviewViewProvider(e,{resolveWebviewView(f,d){i.value=f,a.value=d,o?.onDidReceiveMessage&&f.webview.onDidReceiveMessage(o.onDidReceiveMessage)}},{webviewOptions:{retainContextWhenHidden:o?.retainContextWhenHidden}}));const r=n.ref(0);function u(){r.value++}if(n.watchEffect(()=>{i.value&&(i.value.webview.html=`${n.toValue(t)}<!--${r.value}-->`)}),o?.webviewOptions){const f=o.webviewOptions;n.watchEffect(()=>{i.value&&(i.value.webview.options=n.toValue(f))})}o?.title&&E(i,o.title),o?.badge&&A(i,o.badge);function l(f){return i.value?.webview.postMessage(f)}return{view:i,context:a,postMessage:l,forceRefresh:u}},e=>e),Be=g(()=>{const e=n.shallowRef(s.window.state);return c(s.window.onDidChangeWindowState(t=>{e.value=t})),{focused:n.computed(()=>e.value.focused),active:n.computed(()=>e.value.active)}}),Ke=g(()=>{const e=n.shallowRef(s.workspace.workspaceFolders);return c(s.workspace.onDidChangeWorkspaceFolders(()=>{e.value=s.workspace.workspaceFolders})),n.computed(()=>e.value)});exports.activateCbs=k;exports.createKeyedComposable=D;exports.createSingletonComposable=g;exports.deactivateCbs=R;exports.defineConfigObject=X;exports.defineConfigs=$;exports.defineExtension=J;exports.defineLogger=Z;exports.defineService=_;exports.executeCommand=ee;exports.extensionContext=b;exports.extensionScope=T;exports.getDefaultLoggerPrefix=Te;exports.onActivate=y;exports.onDeactivate=M;exports.tryOnScopeDispose=L;exports.useAbsolutePath=ne;exports.useActiveColorTheme=N;exports.useActiveDebugSession=oe;exports.useActiveEditorDecorations=ie;exports.useActiveNotebookEditor=ae;exports.useActiveTerminal=se;exports.useActiveTextEditor=j;exports.useAllExtensions=ue;exports.useChatParticipant=re;exports.useCommand=K;exports.useCommands=ce;exports.useCommentController=le;exports.useControlledTerminal=de;exports.useDefaultShell=fe;exports.useDisposable=c;exports.useDocumentText=H;exports.useEditorDecorations=B;exports.useEvent=p;exports.useEventEmitter=C;exports.useExtensionSecret=ve;exports.useFetchTasks=we;exports.useFileUri=he;exports.useFoldingRangeProvider=ge;exports.useFsWatcher=me;exports.useIsDarkTheme=pe;exports.useIsTelemetryEnabled=be;exports.useL10nText=Ce;exports.useLmTools=Ve;exports.useLogLevel=De;exports.useLogger=Q;exports.useNotebookEditorSelection=Ee;exports.useNotebookEditorSelections=U;exports.useNotebookEditorVisibleRanges=xe;exports.useOpenedTerminals=Se;exports.useOutputChannel=q;exports.useQuickPick=Re;exports.useReactiveOptions=P;exports.useStatusBarItem=ke;exports.useTaskExecutions=ye;exports.useTerminal=Pe;exports.useTerminalState=O;exports.useTextEditorCommand=z;exports.useTextEditorCommands=Oe;exports.useTextEditorSelection=Ae;exports.useTextEditorSelections=Y;exports.useTextEditorViewColumn=Ie;exports.useTextEditorVisibleRanges=We;exports.useTreeView=Fe;exports.useViewBadge=A;exports.useViewTitle=E;exports.useViewVisibility=Le;exports.useVisibleNotebookEditors=Me;exports.useVisibleTextEditors=$e;exports.useVscodeContext=Ne;exports.useWebviewPanel=je;exports.useWebviewView=He;exports.useWindowState=Be;exports.useWorkspaceFolders=Ke;Object.keys(n).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>n[e]})});
package/dist/index.d.ts CHANGED
@@ -87,7 +87,7 @@ export declare type ConfigObject<C extends object> = UnwrapNestedRefs<C> & {
87
87
  *
88
88
  * @see https://code.visualstudio.com/api/references/vscode-api#WorkspaceConfiguration.update
89
89
  */
90
- $update: (key: keyof C, value: C[keyof C], configurationTarget?: Nullable<ConfigurationTarget>, overrideInLanguage?: boolean) => Promise<void>;
90
+ $update: (key: keyof C, value: C[keyof C], configurationTarget?: ConfigurationTarget | boolean | null, overrideInLanguage?: boolean) => Promise<void>;
91
91
  /**
92
92
  * Set the value without updating the workspace.
93
93
  */
@@ -129,7 +129,7 @@ export declare function createKeyedComposable<P extends unknown[], R, K>(fn: (..
129
129
  /**
130
130
  * Creates a composable that should only be called once.
131
131
  *
132
- * @category utilities
132
+ * @category lifecycle
133
133
  */
134
134
  export declare function createSingletonComposable<T>(fn: () => T): () => T;
135
135
 
@@ -175,7 +175,7 @@ export declare function defineExtension<T>(setup: (context: ExtensionContext) =>
175
175
  export declare function defineLogger(name: string, options?: UseLoggerOptions): {
176
176
  logger: ShallowRef< {
177
177
  outputChannel: OutputChannel;
178
- createLoggerFunc: (type: string) => (...message: any[]) => void;
178
+ createLoggerFunc: (type: "info" | "warn" | "error") => (...message: any[]) => void;
179
179
  info: (...message: any[]) => void;
180
180
  warn: (...message: any[]) => void;
181
181
  error: (...message: any[]) => void;
@@ -190,7 +190,7 @@ export declare function defineLogger(name: string, options?: UseLoggerOptions):
190
190
  hide: () => void;
191
191
  } | null, {
192
192
  outputChannel: OutputChannel;
193
- createLoggerFunc: (type: string) => (...message: any[]) => void;
193
+ createLoggerFunc: (type: "info" | "warn" | "error") => (...message: any[]) => void;
194
194
  info: (...message: any[]) => void;
195
195
  warn: (...message: any[]) => void;
196
196
  error: (...message: any[]) => void;
@@ -216,6 +216,13 @@ export declare function defineLogger(name: string, options?: UseLoggerOptions):
216
216
  hide: () => void | null;
217
217
  };
218
218
 
219
+ /**
220
+ * Define a service that should only be instantiated once.
221
+ *
222
+ * @category lifecycle
223
+ */
224
+ export declare const defineService: typeof createSingletonComposable;
225
+
219
226
  /**
220
227
  * Execute a command, with type checking. See `vscode::commands.executeCommand`.
221
228
  *
@@ -229,6 +236,8 @@ export declare const extensionContext: ShallowRef<ExtensionContext | null, Exten
229
236
 
230
237
  export declare function getDefaultLoggerPrefix(type: string): string;
231
238
 
239
+ declare type LoggingType = 'info' | 'warn' | 'error';
240
+
232
241
  export declare type MaybeNullableRefOrGetter<T> = T | Ref<Nullable<T>> | (() => Nullable<T>);
233
242
 
234
243
  export declare type Nullable<T> = T | null | undefined;
@@ -579,7 +588,7 @@ export declare const useLmTools: () => ComputedRef<readonly LanguageModelToolInf
579
588
  */
580
589
  export declare function useLogger(name: string, options?: UseLoggerOptions): {
581
590
  outputChannel: OutputChannel;
582
- createLoggerFunc: (type: string) => (...message: any[]) => void;
591
+ createLoggerFunc: (type: LoggingType) => (...message: any[]) => void;
583
592
  info: (...message: any[]) => void;
584
593
  warn: (...message: any[]) => void;
585
594
  error: (...message: any[]) => void;
@@ -596,7 +605,11 @@ export declare function useLogger(name: string, options?: UseLoggerOptions): {
596
605
 
597
606
  export declare interface UseLoggerOptions {
598
607
  outputChannel?: OutputChannel;
599
- getPrefix?: ((type: string) => string) | null;
608
+ getPrefix?: ((type: LoggingType) => string) | null;
609
+ /**
610
+ * @default ['error', 'warn']
611
+ */
612
+ toConsole?: LoggingType[];
600
613
  }
601
614
 
602
615
  /**
@@ -672,6 +685,10 @@ export declare function useQuickPick<T extends QuickPickItem>(options?: QuickPic
672
685
  dispose(): void;
673
686
  };
674
687
 
688
+ /**
689
+ * Set multiple reactive options on a target object.
690
+ * @category utilities
691
+ */
675
692
  export declare function useReactiveOptions<T extends object>(target: T, options: {
676
693
  [K in keyof T]?: MaybeRefOrGetter<T[K]>;
677
694
  }, keys: (keyof T)[]): void;
package/dist/index.js CHANGED
@@ -1,34 +1,47 @@
1
- import { getCurrentScope as U, onScopeDispose as L, effectScope as Y, shallowRef as g, computed as h, shallowReactive as $, toValue as a, watchEffect as b, watch as C, unref as I, ref as S, toRaw as ie, isRef as oe } from "@reactive-vscode/reactivity";
1
+ import { getCurrentScope as U, onScopeDispose as L, effectScope as Y, shallowRef as g, computed as h, shallowReactive as $, toValue as a, watchEffect as w, watch as C, unref as I, ref as S, toRaw as oe, isRef as ie } from "@reactive-vscode/reactivity";
2
2
  export * from "@reactive-vscode/reactivity";
3
- import { workspace as T, commands as P, window as v, debug as q, extensions as W, chat as ae, comments as se, env as E, EventEmitter as G, tasks as k, Uri as re, languages as ce, ColorThemeKind as z, l10n as Q, lm as F } from "vscode";
3
+ import { workspace as T, commands as V, window as v, debug as q, extensions as W, chat as ae, comments as se, env as E, EventEmitter as G, tasks as y, Uri as re, languages as ce, ColorThemeKind as z, l10n as Q, lm as F } from "vscode";
4
4
  function ue(e) {
5
5
  return U() ? (L(e), !0) : !1;
6
6
  }
7
7
  function N(e, t) {
8
8
  const n = /* @__PURE__ */ new Map();
9
- return (...i) => {
10
- const o = t(...i);
11
- let r = n.get(o);
9
+ return (...o) => {
10
+ const i = t(...o);
11
+ let r = n.get(i);
12
12
  return r ? r.refCount++ : (r = {
13
- data: e(...i),
13
+ data: e(...o),
14
14
  refCount: 1
15
- }, n.set(o, r)), ue(() => {
16
- --r.refCount === 0 && n.delete(o);
15
+ }, n.set(i, r)), ue(() => {
16
+ --r.refCount === 0 && n.delete(i);
17
17
  }), r.data;
18
18
  };
19
19
  }
20
- function w(e) {
21
- let t = !1, n;
22
- return () => (t || (n = Y(!0).run(e), t = !0), n);
23
- }
24
20
  const J = [];
25
- function Se(e) {
21
+ function le(e) {
26
22
  J.push(e);
27
23
  }
28
- const y = g(null), M = Y();
24
+ function b(e) {
25
+ let t = !1, n = !1, o;
26
+ return () => {
27
+ if (!n) {
28
+ if (t)
29
+ throw new Error("Cannot call a singleton composable recursively.");
30
+ try {
31
+ t = !0;
32
+ const i = Y(!0);
33
+ le(() => i.stop()), o = i.run(e), n = !0;
34
+ } finally {
35
+ t = !1;
36
+ }
37
+ }
38
+ return o;
39
+ };
40
+ }
41
+ const k = g(null), M = Y();
29
42
  function Ee(e) {
30
43
  return {
31
- activate: (t) => (y.value = t, M.run(() => (X.map((n) => n(t)), e(t)))),
44
+ activate: (t) => (k.value = t, M.run(() => (X.map((n) => n(t)), e(t)))),
32
45
  deactivate: () => {
33
46
  J.map((t) => t()), M.stop();
34
47
  }
@@ -36,29 +49,29 @@ function Ee(e) {
36
49
  }
37
50
  const X = [];
38
51
  function Z(e) {
39
- y.value ? e(y.value) : X.push(e);
52
+ k.value ? e(k.value) : X.push(e);
40
53
  }
41
- function le(e, t, n) {
42
- const i = !e, o = T.getConfiguration(i ? void 0 : e, n);
54
+ function de(e, t, n) {
55
+ const o = !e, i = T.getConfiguration(o ? void 0 : e, n);
43
56
  function r(u, d) {
44
57
  const l = g(d), m = h({
45
58
  get: () => l.value,
46
59
  set: (f) => {
47
- l.value = f, o.update(u, f);
60
+ l.value = f, i.update(u, f);
48
61
  }
49
62
  });
50
63
  return m.update = async (f, p, D) => {
51
- await o.update(u, f, p, D), m.value = f;
64
+ await i.update(u, f, p, D), l.value = f;
52
65
  }, m.set = (f) => {
53
66
  l.value = f;
54
67
  }, m;
55
68
  }
56
69
  const s = Object.fromEntries(
57
- Object.keys(t).map((u) => [u, r(u, o.get(u))])
70
+ Object.keys(t).map((u) => [u, r(u, i.get(u))])
58
71
  );
59
72
  return Z(() => {
60
73
  c(T.onDidChangeConfiguration(
61
- i ? (u) => {
74
+ o ? (u) => {
62
75
  const d = T.getConfiguration();
63
76
  for (const l in t)
64
77
  u.affectsConfiguration(l) && s[l].set(d.get(l));
@@ -72,18 +85,18 @@ function le(e, t, n) {
72
85
  ));
73
86
  }), s;
74
87
  }
75
- function ke(e, t, n) {
76
- const i = le(e, t, n), o = {}, r = $({
88
+ function ye(e, t, n) {
89
+ const o = de(e, t, n), i = {}, r = $({
77
90
  $update(s, u, d, l) {
78
- return i[s].update(u, d, l);
91
+ return o[s].update(u, d, l);
79
92
  },
80
93
  $set(s, u) {
81
- return i[s].set(u);
94
+ return o[s].set(u);
82
95
  }
83
96
  });
84
97
  for (const s in t) {
85
98
  const u = s.split(".");
86
- let d = "", l = o, m = r;
99
+ let d = "", l = i, m = r;
87
100
  for (const p of u.slice(0, -1)) {
88
101
  d = d ? `${d}.${p}` : p;
89
102
  const D = l = l[p] ||= {};
@@ -97,12 +110,12 @@ function ke(e, t, n) {
97
110
  return H;
98
111
  },
99
112
  set(ne) {
100
- function B(V, A, K) {
101
- if (V)
102
- for (const R in V)
103
- B(V[R], A ? `${A}.${R}` : R, K?.[R]);
113
+ function B(A, O, K) {
114
+ if (A)
115
+ for (const R in A)
116
+ B(A[R], O ? `${O}.${R}` : R, K?.[R]);
104
117
  else
105
- i[A].value = K;
118
+ o[O].value = K;
106
119
  }
107
120
  B(D, d, ne);
108
121
  }
@@ -113,78 +126,79 @@ function ke(e, t, n) {
113
126
  l[f] = null, Object.defineProperty(m, f, {
114
127
  enumerable: !0,
115
128
  get() {
116
- return i[s].value;
129
+ return o[s].value;
117
130
  },
118
131
  set(p) {
119
- i[s].value = p;
132
+ o[s].value = p;
120
133
  }
121
134
  });
122
135
  }
123
136
  return r;
124
137
  }
125
- function ye(e, t) {
126
- const n = g(null), i = [], o = (r) => (...s) => n.value ? n.value[r](...s) : (i.push([r, s]), null);
138
+ function ke(e, t) {
139
+ const n = g(null), o = [], i = (r) => (...s) => n.value ? n.value[r](...s) : (o.push([r, s]), null);
127
140
  return Z(() => {
128
- n.value = be(e, t);
129
- for (const [r, s] of i)
141
+ n.value = we(e, t);
142
+ for (const [r, s] of o)
130
143
  n.value[r](...s);
131
144
  }), {
132
145
  logger: n,
133
146
  outputChannel: h(() => n.value?.outputChannel),
134
- info: o("info"),
135
- warn: o("warn"),
136
- error: o("error"),
137
- append: o("append"),
138
- appendLine: o("appendLine"),
139
- replace: o("replace"),
140
- clear: o("clear"),
141
- show: o("show"),
142
- hide: o("hide")
147
+ info: i("info"),
148
+ warn: i("warn"),
149
+ error: i("error"),
150
+ append: i("append"),
151
+ appendLine: i("appendLine"),
152
+ replace: i("replace"),
153
+ clear: i("clear"),
154
+ show: i("show"),
155
+ hide: i("hide")
143
156
  };
144
157
  }
145
- function Re(e, ...t) {
146
- return P.executeCommand(e, ...t);
158
+ const Re = b;
159
+ function Pe(e, ...t) {
160
+ return V.executeCommand(e, ...t);
147
161
  }
148
- function de(e, t = !1) {
149
- const n = y.value;
162
+ function fe(e, t = !1) {
163
+ const n = k.value;
150
164
  if (!n && !t)
151
165
  throw new Error("Cannot get absolute path because the extension is not activated yet");
152
166
  return n?.asAbsolutePath(e);
153
167
  }
154
- function Oe(e, t = !1) {
155
- return h(() => de(a(e), t));
168
+ function Ve(e, t = !1) {
169
+ return h(() => fe(a(e), t));
156
170
  }
157
171
  function c(e) {
158
172
  return (U() ?? M).cleanups.push(e.dispose.bind(e)), e;
159
173
  }
160
- const fe = w(() => {
174
+ const ve = b(() => {
161
175
  const e = g(v.activeColorTheme);
162
176
  return c(v.onDidChangeActiveColorTheme((t) => {
163
177
  e.value = t;
164
178
  })), e;
165
- }), Pe = w(() => {
179
+ }), Ae = b(() => {
166
180
  const e = g(q.activeDebugSession);
167
181
  return c(q.onDidChangeActiveDebugSession((t) => {
168
182
  e.value = t;
169
183
  })), h(() => e.value);
170
- }), ve = w(() => {
184
+ }), ge = b(() => {
171
185
  const e = g(v.activeTextEditor);
172
186
  return c(v.onDidChangeActiveTextEditor((t) => {
173
187
  e.value = t;
174
188
  })), e;
175
189
  });
176
- function ge(e) {
190
+ function he(e) {
177
191
  const t = g(a(e)?.getText());
178
- return b(() => {
192
+ return w(() => {
179
193
  t.value = a(e)?.getText();
180
194
  }), c(T.onDidChangeTextDocument((n) => {
181
195
  n.document === a(e) && (t.value = n.document.getText());
182
196
  })), t;
183
197
  }
184
- function he(e, t, n, i = {}) {
198
+ function me(e, t, n, o = {}) {
185
199
  const {
186
- updateOn: o = ["effect", "documentChanged"]
187
- } = i;
200
+ updateOn: i = ["effect", "documentChanged"]
201
+ } = o;
188
202
  let r;
189
203
  const s = h(
190
204
  () => {
@@ -201,8 +215,8 @@ function he(e, t, n, i = {}) {
201
215
  s.value,
202
216
  typeof n == "function" ? await n(l) : a(n)
203
217
  );
204
- }, d = o.includes("documentChanged") ? ge(() => a(e)?.document) : null;
205
- return o.includes("effect") ? b(async () => {
218
+ }, d = i.includes("documentChanged") ? he(() => a(e)?.document) : null;
219
+ return i.includes("effect") ? w(async () => {
206
220
  d?.value, await u();
207
221
  }) : d && C(d, u), {
208
222
  /**
@@ -211,60 +225,60 @@ function he(e, t, n, i = {}) {
211
225
  update: u
212
226
  };
213
227
  }
214
- function Ve(e, t, n = {}) {
215
- const i = ve();
216
- return he(i, e, t, n);
228
+ function Oe(e, t, n = {}) {
229
+ const o = ge();
230
+ return me(o, e, t, n);
217
231
  }
218
- const Ae = w(() => {
232
+ const Ie = b(() => {
219
233
  const e = g(v.activeNotebookEditor);
220
234
  return c(v.onDidChangeActiveNotebookEditor((t) => {
221
235
  e.value = t;
222
236
  })), e;
223
- }), Ie = w(() => {
237
+ }), We = b(() => {
224
238
  const e = g(v.activeTerminal);
225
239
  return c(v.onDidChangeActiveTerminal((t) => {
226
240
  e.value = t;
227
241
  })), e;
228
- }), We = w(() => {
242
+ }), Fe = b(() => {
229
243
  const e = g(W.all);
230
244
  return c(W.onDidChange(() => {
231
245
  e.value = W.all;
232
246
  })), h(() => e.value);
233
247
  });
234
248
  function x(e, t) {
235
- const n = (i, o, r) => {
236
- c(e(i, o, r));
249
+ const n = (o, i, r) => {
250
+ c(e(o, i, r));
237
251
  };
238
- return t?.forEach((i) => n(i)), n;
252
+ return t?.forEach((o) => n(o)), n;
239
253
  }
240
254
  function _(e, t, n) {
241
- for (const i of n) {
242
- const o = t[i];
243
- o !== void 0 && b(() => {
244
- e[i] = a(o);
255
+ for (const o of n) {
256
+ const i = t[o];
257
+ i !== void 0 && w(() => {
258
+ e[o] = a(i);
245
259
  });
246
260
  }
247
261
  }
248
- const Fe = N((e, t, n = {}) => {
249
- const i = c(ae.createChatParticipant(e, I(t)));
250
- return _(i, n, [
262
+ const $e = N((e, t, n = {}) => {
263
+ const o = c(ae.createChatParticipant(e, I(t)));
264
+ return _(o, n, [
251
265
  "iconPath"
252
- ]), n.followupProvider !== void 0 && b(() => {
253
- i.followupProvider = I(n.followupProvider);
254
- }), b(() => {
255
- i.requestHandler = I(t);
266
+ ]), n.followupProvider !== void 0 && w(() => {
267
+ o.followupProvider = I(n.followupProvider);
268
+ }), w(() => {
269
+ o.requestHandler = I(t);
256
270
  }), {
257
- onDidReceiveFeedback: x(i.onDidReceiveFeedback)
271
+ onDidReceiveFeedback: x(o.onDidReceiveFeedback)
258
272
  };
259
273
  }, (e) => e);
260
- function me(e, t) {
261
- c(P.registerCommand(e, t));
274
+ function pe(e, t) {
275
+ c(V.registerCommand(e, t));
262
276
  }
263
- function $e(e) {
277
+ function Me(e) {
264
278
  for (const [t, n] of Object.entries(e))
265
- n && me(t, n);
279
+ n && pe(t, n);
266
280
  }
267
- function Me(e, t) {
281
+ function Le(e, t) {
268
282
  return c(se.createCommentController(e, t));
269
283
  }
270
284
  function ee(e) {
@@ -275,19 +289,19 @@ function ee(e) {
275
289
  n === a(e) && (t.value = n.state);
276
290
  })), h(() => t.value);
277
291
  }
278
- function Le(...e) {
292
+ function Ne(...e) {
279
293
  const t = S(null);
280
294
  function n() {
281
295
  return !!t.value && t.value.exitStatus == null;
282
296
  }
283
- function i() {
297
+ function o() {
284
298
  return n() ? t.value : t.value = v.createTerminal(...e);
285
299
  }
286
- function o(u) {
287
- i().sendText(u);
300
+ function i(u) {
301
+ o().sendText(u);
288
302
  }
289
303
  function r() {
290
- i().show();
304
+ o().show();
291
305
  }
292
306
  function s() {
293
307
  n() && (t.value.sendText(""), t.value.dispose(), t.value = null);
@@ -296,135 +310,135 @@ function Le(...e) {
296
310
  terminal: t,
297
311
  getIsActive: n,
298
312
  show: r,
299
- sendText: o,
313
+ sendText: i,
300
314
  close: s,
301
315
  state: ee(t)
302
316
  };
303
317
  }
304
- const Ne = w(() => {
318
+ const je = b(() => {
305
319
  const e = g(E.shell);
306
320
  return c(E.onDidChangeShell((t) => {
307
321
  e.value = t;
308
322
  })), h(() => e.value);
309
323
  });
310
- function O(e, t = []) {
311
- const n = Array.isArray(e) ? e : t ?? [], i = c(Array.isArray(e) || e == null ? new G() : e), o = x(i.event, n);
324
+ function P(e, t = []) {
325
+ const n = Array.isArray(e) ? e : t ?? [], o = c(Array.isArray(e) || e == null ? new G() : e), i = x(o.event, n);
312
326
  for (const r of n)
313
- o(r);
327
+ i(r);
314
328
  return {
315
- event: i.event,
316
- fire: i.fire.bind(i),
317
- addListener: o
329
+ event: o.event,
330
+ fire: o.fire.bind(o),
331
+ addListener: i
318
332
  };
319
333
  }
320
- async function je(e) {
321
- const t = y.value.secrets, n = S(await t.get(e));
322
- return n.set = async (i) => {
323
- n.value = i, await t.store(e, i);
334
+ async function He(e) {
335
+ const t = k.value.secrets, n = S(await t.get(e));
336
+ return n.set = async (o) => {
337
+ n.value = o, await t.store(e, o);
324
338
  }, n.remove = async () => {
325
339
  n.value = void 0, await t.delete(e);
326
- }, c(t.onDidChange(async (i) => {
327
- i.key === e && (n.value = await t.get(e));
328
- })), C(n, (i) => {
329
- i === void 0 ? t.delete(e) : t.store(e, i);
340
+ }, c(t.onDidChange(async (o) => {
341
+ o.key === e && (n.value = await t.get(e));
342
+ })), C(n, (o) => {
343
+ o === void 0 ? t.delete(e) : t.store(e, o);
330
344
  }), n;
331
345
  }
332
- function He(e) {
333
- return h(() => k.fetchTasks(a(e)));
334
- }
335
346
  function Be(e) {
347
+ return h(() => y.fetchTasks(a(e)));
348
+ }
349
+ function Ke(e) {
336
350
  return h(() => re.file(a(e)));
337
351
  }
338
- function Ke(e, t) {
339
- const n = new G(), i = g();
340
- b(() => {
341
- i.value && n.fire(), i.value = a(t);
352
+ function qe(e, t) {
353
+ const n = new G(), o = g();
354
+ w(() => {
355
+ o.value && n.fire(), o.value = a(t);
342
356
  }), c(ce.registerFoldingRangeProvider(
343
357
  e,
344
358
  {
345
359
  onDidChangeFoldingRanges: n.event,
346
- provideFoldingRanges(o, r, s) {
347
- return i.value?.(o, r, s);
360
+ provideFoldingRanges(i, r, s) {
361
+ return o.value?.(i, r, s);
348
362
  }
349
363
  }
350
364
  ));
351
365
  }
352
- function qe(e, t, n, i) {
353
- const o = $(/* @__PURE__ */ new Map()), r = O(), s = O(), u = O(), d = h(() => {
366
+ function ze(e, t, n, o) {
367
+ const i = $(/* @__PURE__ */ new Map()), r = P(), s = P(), u = P(), d = h(() => {
354
368
  const f = a(e);
355
369
  return Array.isArray(f) ? f : f instanceof Set ? Array.from(f) : [f];
356
370
  });
357
371
  function l() {
358
372
  const f = d.value;
359
- for (const [p, D] of o)
360
- f.includes(p) || (D.dispose(), o.delete(p));
373
+ for (const [p, D] of i)
374
+ f.includes(p) || (D.dispose(), i.delete(p));
361
375
  for (const p of f)
362
- if (!o.has(p)) {
376
+ if (!i.has(p)) {
363
377
  const D = T.createFileSystemWatcher(
364
378
  p,
365
379
  a(t) || !1,
366
380
  a(n) || !1,
367
- a(i) || !1
381
+ a(o) || !1
368
382
  );
369
- D.onDidCreate(r.fire), D.onDidChange(s.fire), D.onDidDelete(u.fire), o.set(p, D);
383
+ D.onDidCreate(r.fire), D.onDidChange(s.fire), D.onDidDelete(u.fire), i.set(p, D);
370
384
  }
371
385
  }
372
386
  function m() {
373
- for (const f of o.values())
387
+ for (const f of i.values())
374
388
  f.dispose();
375
- o.clear();
389
+ i.clear();
376
390
  }
377
391
  return l(), C(d, l), C(
378
392
  () => [
379
393
  a(t),
380
394
  a(n),
381
- a(i)
395
+ a(o)
382
396
  ],
383
397
  () => {
384
398
  m(), l();
385
399
  }
386
400
  ), L(m), {
387
- watchers: o,
401
+ watchers: i,
388
402
  onDidCreate: r.event,
389
403
  onDidChange: s.event,
390
404
  onDidDelete: u.event
391
405
  };
392
406
  }
393
- const ze = w(() => {
394
- const e = fe();
407
+ const Qe = b(() => {
408
+ const e = ve();
395
409
  return h(() => e.value.kind === z.Dark || e.value.kind === z.HighContrast);
396
- }), Qe = w(() => {
410
+ }), Ue = b(() => {
397
411
  const e = g(E.isTelemetryEnabled);
398
412
  return c(E.onDidChangeTelemetryEnabled((t) => {
399
413
  e.value = t;
400
414
  })), h(() => e.value);
401
415
  });
402
- function Ue(e, ...t) {
403
- return h(() => typeof t[0] == "object" ? Q.t(a(e), ie(t[0])) : Q.t(a(e), ...t.map(a)));
416
+ function Ye(e, ...t) {
417
+ return h(() => typeof t[0] == "object" ? Q.t(a(e), oe(t[0])) : Q.t(a(e), ...t.map(a)));
404
418
  }
405
- const Ye = w(() => {
419
+ const Ge = b(() => {
406
420
  const e = g(F.tools);
407
421
  return c(F.onDidChangeChatModels(() => {
408
422
  e.value = F.tools;
409
423
  })), h(() => e.value);
410
424
  });
411
- function pe(e, t) {
425
+ function be(e, t) {
412
426
  return c(v.createOutputChannel(e, t));
413
427
  }
414
- function Ge(e) {
415
- const t = /* @__PURE__ */ new Date(), n = String(t.getFullYear()).padStart(4, "0"), i = String(t.getMonth() + 1).padStart(2, "0"), o = String(t.getDate()).padStart(2, "0"), r = String(t.getHours()).padStart(2, "0"), s = String(t.getMinutes()).padStart(2, "0"), u = String(t.getSeconds()).padStart(2, "0"), d = String(t.getMilliseconds()).padStart(3, "0");
416
- return `${n}-${i}-${o} ${r}:${s}:${u}.${d} [${e}] `;
428
+ function Je(e) {
429
+ const t = /* @__PURE__ */ new Date(), n = String(t.getFullYear()).padStart(4, "0"), o = String(t.getMonth() + 1).padStart(2, "0"), i = String(t.getDate()).padStart(2, "0"), r = String(t.getHours()).padStart(2, "0"), s = String(t.getMinutes()).padStart(2, "0"), u = String(t.getSeconds()).padStart(2, "0"), d = String(t.getMilliseconds()).padStart(3, "0");
430
+ return `${n}-${o}-${i} ${r}:${s}:${u}.${d} [${e}] `;
417
431
  }
418
- function be(e, t = {}) {
419
- const n = t.outputChannel ?? pe(e, { log: !0 }), i = (o) => (...r) => {
420
- n.appendLine((t.getPrefix?.(o) ?? "") + r.join(" "));
432
+ function we(e, t = {}) {
433
+ const n = t.outputChannel ?? be(e, { log: !0 }), o = t.toConsole ?? ["error", "warn"], i = (r) => (...s) => {
434
+ n.appendLine((t.getPrefix?.(r) ?? "") + s.join(" ")), o.includes(r) && console[r](...s);
421
435
  };
422
436
  return {
423
437
  outputChannel: n,
424
438
  createLoggerFunc: i,
425
- info: i("INFO"),
426
- warn: i("WARN"),
427
- error: i("ERROR"),
439
+ info: i("info"),
440
+ warn: i("warn"),
441
+ error: i("error"),
428
442
  append: n.append.bind(n),
429
443
  appendLine: n.appendLine.bind(n),
430
444
  replace: n.replace.bind(n),
@@ -433,13 +447,13 @@ function be(e, t = {}) {
433
447
  hide: n.hide.bind(n)
434
448
  };
435
449
  }
436
- const Je = w(() => {
450
+ const Xe = b(() => {
437
451
  const e = g(E.logLevel);
438
452
  return c(E.onDidChangeLogLevel((t) => {
439
453
  e.value = t;
440
454
  })), h(() => e.value);
441
455
  });
442
- function we(e) {
456
+ function Ce(e) {
443
457
  const t = g(a(e)?.selections ?? []);
444
458
  return C(e, () => {
445
459
  t.value = a(e)?.selections ?? [];
@@ -451,13 +465,13 @@ function we(e) {
451
465
  },
452
466
  set(n) {
453
467
  t.value = n;
454
- const i = a(e);
455
- i && (i.selections = n);
468
+ const o = a(e);
469
+ o && (o.selections = n);
456
470
  }
457
471
  });
458
472
  }
459
- function Xe(e) {
460
- const t = we(e);
473
+ function Ze(e) {
474
+ const t = Ce(e);
461
475
  return h({
462
476
  get() {
463
477
  return t.value[0];
@@ -467,7 +481,7 @@ function Xe(e) {
467
481
  }
468
482
  });
469
483
  }
470
- function Ze(e) {
484
+ function _e(e) {
471
485
  const t = g(a(e)?.visibleRanges ?? []);
472
486
  return C(e, () => {
473
487
  t.value = a(e)?.visibleRanges ?? [];
@@ -475,15 +489,15 @@ function Ze(e) {
475
489
  n.notebookEditor === a(e) && (t.value = n.visibleRanges);
476
490
  })), h(() => t.value);
477
491
  }
478
- const _e = w(() => {
492
+ const et = b(() => {
479
493
  const e = g(v.terminals);
480
494
  function t() {
481
495
  e.value = v.terminals;
482
496
  }
483
497
  return c(v.onDidOpenTerminal(t)), c(v.onDidCloseTerminal(t)), e;
484
498
  });
485
- function et(e = {}) {
486
- const t = c(v.createQuickPick()), n = x(t.onDidChangeActive), i = x(t.onDidChangeSelection), o = x(t.onDidAccept), r = x(t.onDidHide), s = x(t.onDidTriggerButton), u = x(t.onDidChangeValue);
499
+ function tt(e = {}) {
500
+ const t = c(v.createQuickPick()), n = x(t.onDidChangeActive), o = x(t.onDidChangeSelection), i = x(t.onDidAccept), r = x(t.onDidHide), s = x(t.onDidTriggerButton), u = x(t.onDidChangeValue);
487
501
  [
488
502
  "items",
489
503
  "buttons",
@@ -499,18 +513,18 @@ function et(e = {}) {
499
513
  "matchOnDetail",
500
514
  "keepScrollPosition"
501
515
  ].forEach((f) => {
502
- e[f] && b(() => t[f] = a(e[f]));
516
+ e[f] && w(() => t[f] = a(e[f]));
503
517
  }), e.value && (t.value = e.value);
504
518
  const d = g(t.value);
505
519
  u((f) => d.value = f), e.activeItems && (t.activeItems = e.activeItems);
506
520
  const l = g(t.activeItems);
507
521
  n((f) => l.value = f), e.selectedItems && (t.selectedItems = e.selectedItems);
508
522
  const m = g(t.selectedItems);
509
- return i((f) => m.value = f), {
523
+ return o((f) => m.value = f), {
510
524
  ...t,
511
525
  onDidChangeActive: n,
512
- onDidChangeSelection: i,
513
- onDidAccept: o,
526
+ onDidChangeSelection: o,
527
+ onDidAccept: i,
514
528
  onDidHide: r,
515
529
  onDidTriggerButton: s,
516
530
  onDidChangeValue: u,
@@ -519,7 +533,7 @@ function et(e = {}) {
519
533
  selectedItems: m
520
534
  };
521
535
  }
522
- function tt(e) {
536
+ function nt(e) {
523
537
  const t = c(e.id ? v.createStatusBarItem(e.id, e.alignment, e.priority) : v.createStatusBarItem(e.alignment, e.priority));
524
538
  return _(t, e, [
525
539
  "name",
@@ -529,16 +543,16 @@ function tt(e) {
529
543
  "backgroundColor",
530
544
  "command",
531
545
  "accessibilityInformation"
532
- ]), e.visible != null ? b(() => {
546
+ ]), e.visible != null ? w(() => {
533
547
  a(e.visible) ? t.show() : t.hide();
534
548
  }) : t.show(), t;
535
549
  }
536
- const nt = w(() => {
537
- const e = g(k.taskExecutions);
550
+ const ot = b(() => {
551
+ const e = g(y.taskExecutions);
538
552
  function t() {
539
- e.value = k.taskExecutions;
553
+ e.value = y.taskExecutions;
540
554
  }
541
- return c(k.onDidStartTask(t)), c(k.onDidEndTask(t)), h(() => e.value);
555
+ return c(y.onDidStartTask(t)), c(y.onDidEndTask(t)), h(() => e.value);
542
556
  });
543
557
  function it(...e) {
544
558
  const t = c(v.createTerminal(...e));
@@ -565,43 +579,43 @@ function it(...e) {
565
579
  state: ee(t)
566
580
  };
567
581
  }
568
- function Ce(e, t) {
569
- c(P.registerTextEditorCommand(e, t));
582
+ function De(e, t) {
583
+ c(V.registerTextEditorCommand(e, t));
570
584
  }
571
- function ot(e) {
585
+ function at(e) {
572
586
  for (const [t, n] of Object.entries(e))
573
- Ce(t, n);
587
+ De(t, n);
574
588
  }
575
- function De(e, t) {
589
+ function Te(e, t) {
576
590
  const n = g(a(e)?.selections ?? []);
577
591
  return C(e, () => {
578
592
  n.value = a(e)?.selections ?? [];
579
- }), c(v.onDidChangeTextEditorSelection((i) => {
580
- const o = a(e), r = a(t);
581
- i.textEditor === o && (!r || r.includes(i.kind)) && (n.value = i.selections);
593
+ }), c(v.onDidChangeTextEditorSelection((o) => {
594
+ const i = a(e), r = a(t);
595
+ o.textEditor === i && (!r || r.includes(o.kind)) && (n.value = o.selections);
582
596
  })), h({
583
597
  get() {
584
598
  return n.value;
585
599
  },
586
- set(i) {
587
- n.value = i;
588
- const o = a(e);
589
- o && (o.selections = i);
600
+ set(o) {
601
+ n.value = o;
602
+ const i = a(e);
603
+ i && (i.selections = o);
590
604
  }
591
605
  });
592
606
  }
593
- function at(e, t) {
594
- const n = De(e, t);
607
+ function st(e, t) {
608
+ const n = Te(e, t);
595
609
  return h({
596
610
  get() {
597
611
  return n.value[0];
598
612
  },
599
- set(i) {
600
- n.value = n.value.toSpliced(0, 1, i);
613
+ set(o) {
614
+ n.value = n.value.toSpliced(0, 1, o);
601
615
  }
602
616
  });
603
617
  }
604
- function st(e) {
618
+ function rt(e) {
605
619
  const t = g(a(e)?.viewColumn);
606
620
  return C(e, () => {
607
621
  t.value = a(e)?.viewColumn;
@@ -609,7 +623,7 @@ function st(e) {
609
623
  n.textEditor === a(e) && (t.value = n.viewColumn);
610
624
  })), h(() => t.value);
611
625
  }
612
- function rt(e) {
626
+ function ct(e) {
613
627
  const t = g(a(e)?.visibleRanges ?? []);
614
628
  return C(e, () => {
615
629
  t.value = a(e)?.visibleRanges ?? [];
@@ -618,38 +632,38 @@ function rt(e) {
618
632
  })), h(() => t.value);
619
633
  }
620
634
  function te(e, t) {
621
- b(() => {
635
+ w(() => {
622
636
  const n = a(e);
623
637
  n && (n.badge = a(t));
624
638
  });
625
639
  }
626
640
  function j(e, t) {
627
- b(() => {
641
+ w(() => {
628
642
  const n = a(e);
629
643
  n && (n.title = a(t));
630
644
  });
631
645
  }
632
- const ct = N(
646
+ const ut = N(
633
647
  (e, t, n) => {
634
- const i = O();
635
- C(t, () => i.fire()), n?.watchSource && C(n.watchSource, () => i.fire());
636
- const o = /* @__PURE__ */ new WeakMap(), r = c(v.createTreeView(e, {
648
+ const o = P();
649
+ C(t, () => o.fire()), n?.watchSource && C(n.watchSource, () => o.fire());
650
+ const i = /* @__PURE__ */ new WeakMap(), r = c(v.createTreeView(e, {
637
651
  ...n,
638
652
  treeDataProvider: {
639
653
  ...n,
640
- onDidChangeTreeData: i.event,
654
+ onDidChangeTreeData: o.event,
641
655
  getTreeItem(s) {
642
656
  return s.treeItem;
643
657
  },
644
658
  async getChildren(s) {
645
659
  if (s) {
646
660
  const u = await s.children;
647
- return u?.forEach((d) => o.set(d, s)), u;
661
+ return u?.forEach((d) => i.set(d, s)), u;
648
662
  }
649
663
  return a(t);
650
664
  },
651
665
  getParent(s) {
652
- return o.get(s);
666
+ return i.get(s);
653
667
  }
654
668
  }
655
669
  }));
@@ -657,57 +671,57 @@ const ct = N(
657
671
  },
658
672
  (e) => e
659
673
  );
660
- function ut(e) {
674
+ function lt(e) {
661
675
  const t = S(a(e)?.visible);
662
676
  function n() {
663
677
  t.value = a(e)?.visible;
664
678
  }
665
- return b((i) => {
666
- const o = a(e);
667
- if (o) {
668
- const r = o.onDidChangeVisibility(n);
669
- i(() => r.dispose());
679
+ return w((o) => {
680
+ const i = a(e);
681
+ if (i) {
682
+ const r = i.onDidChangeVisibility(n);
683
+ o(() => r.dispose());
670
684
  }
671
- }), b(n), h(() => !!t.value);
685
+ }), w(n), h(() => !!t.value);
672
686
  }
673
- const lt = w(() => {
687
+ const dt = b(() => {
674
688
  const e = g(v.visibleNotebookEditors);
675
689
  return c(v.onDidChangeVisibleNotebookEditors((t) => {
676
690
  e.value = t;
677
691
  })), e;
678
- }), dt = w(() => {
692
+ }), ft = b(() => {
679
693
  const e = g(v.visibleTextEditors);
680
694
  return c(v.onDidChangeVisibleTextEditors((t) => {
681
695
  e.value = t;
682
696
  })), e;
683
697
  });
684
- function ft(e, t, n = !0) {
685
- const i = oe(t) ? t : typeof t == "function" ? h(t) : S(t);
686
- return b(() => {
687
- a(n) && P.executeCommand("setContext", e, i.value);
688
- }), i;
698
+ function vt(e, t, n = !0) {
699
+ const o = ie(t) ? t : typeof t == "function" ? h(t) : S(t);
700
+ return w(() => {
701
+ a(n) && V.executeCommand("setContext", e, o.value);
702
+ }), o;
689
703
  }
690
- function vt(e, t, n, i, o) {
704
+ function gt(e, t, n, o, i) {
691
705
  const r = g(), s = c(v.createWebviewPanel(
692
706
  e,
693
707
  a(t),
694
- i,
708
+ o,
695
709
  {
696
- enableFindWidget: o?.enableFindWidget,
697
- retainContextWhenHidden: o?.retainContextWhenHidden,
698
- ...a(o?.webviewOptions)
710
+ enableFindWidget: i?.enableFindWidget,
711
+ retainContextWhenHidden: i?.retainContextWhenHidden,
712
+ ...a(i?.webviewOptions)
699
713
  }
700
714
  ));
701
- o?.onDidReceiveMessage && s.webview.onDidReceiveMessage(o.onDidReceiveMessage);
715
+ i?.onDidReceiveMessage && s.webview.onDidReceiveMessage(i.onDidReceiveMessage);
702
716
  const u = S(0);
703
717
  function d() {
704
718
  u.value++;
705
719
  }
706
- if (b(() => {
720
+ if (w(() => {
707
721
  s.webview.html = `${a(n)}<!--${u.value}-->`;
708
- }), o?.webviewOptions) {
709
- const p = o.webviewOptions;
710
- b(() => {
722
+ }), i?.webviewOptions) {
723
+ const p = i.webviewOptions;
724
+ w(() => {
711
725
  s.webview.options = a(p);
712
726
  });
713
727
  }
@@ -720,14 +734,14 @@ function vt(e, t, n, i, o) {
720
734
  m.value = s.active, f.value = s.visible;
721
735
  })), { panel: s, context: r, active: m, visible: f, postMessage: l, forceRefresh: d };
722
736
  }
723
- const gt = N(
737
+ const ht = N(
724
738
  (e, t, n) => {
725
- const i = g(), o = g();
739
+ const o = g(), i = g();
726
740
  c(v.registerWebviewViewProvider(
727
741
  e,
728
742
  {
729
743
  resolveWebviewView(d, l) {
730
- i.value = d, o.value = l, n?.onDidReceiveMessage && d.webview.onDidReceiveMessage(n.onDidReceiveMessage);
744
+ o.value = d, i.value = l, n?.onDidReceiveMessage && d.webview.onDidReceiveMessage(n.onDidReceiveMessage);
731
745
  }
732
746
  },
733
747
  {
@@ -740,22 +754,22 @@ const gt = N(
740
754
  function s() {
741
755
  r.value++;
742
756
  }
743
- if (b(() => {
744
- i.value && (i.value.webview.html = `${a(t)}<!--${r.value}-->`);
757
+ if (w(() => {
758
+ o.value && (o.value.webview.html = `${a(t)}<!--${r.value}-->`);
745
759
  }), n?.webviewOptions) {
746
760
  const d = n.webviewOptions;
747
- b(() => {
748
- i.value && (i.value.webview.options = a(d));
761
+ w(() => {
762
+ o.value && (o.value.webview.options = a(d));
749
763
  });
750
764
  }
751
- n?.title && j(i, n.title), n?.badge && te(i, n.badge);
765
+ n?.title && j(o, n.title), n?.badge && te(o, n.badge);
752
766
  function u(d) {
753
- return i.value?.webview.postMessage(d);
767
+ return o.value?.webview.postMessage(d);
754
768
  }
755
- return { view: i, context: o, postMessage: u, forceRefresh: s };
769
+ return { view: o, context: i, postMessage: u, forceRefresh: s };
756
770
  },
757
771
  (e) => e
758
- ), ht = w(() => {
772
+ ), mt = b(() => {
759
773
  const e = g(v.state);
760
774
  return c(v.onDidChangeWindowState((t) => {
761
775
  e.value = t;
@@ -763,7 +777,7 @@ const gt = N(
763
777
  focused: h(() => e.value.focused),
764
778
  active: h(() => e.value.active)
765
779
  };
766
- }), mt = w(() => {
780
+ }), pt = b(() => {
767
781
  const e = g(T.workspaceFolders);
768
782
  return c(T.onDidChangeWorkspaceFolders(() => {
769
783
  e.value = T.workspaceFolders;
@@ -772,75 +786,76 @@ const gt = N(
772
786
  export {
773
787
  X as activateCbs,
774
788
  N as createKeyedComposable,
775
- w as createSingletonComposable,
789
+ b as createSingletonComposable,
776
790
  J as deactivateCbs,
777
- ke as defineConfigObject,
778
- le as defineConfigs,
791
+ ye as defineConfigObject,
792
+ de as defineConfigs,
779
793
  Ee as defineExtension,
780
- ye as defineLogger,
781
- Re as executeCommand,
782
- y as extensionContext,
794
+ ke as defineLogger,
795
+ Re as defineService,
796
+ Pe as executeCommand,
797
+ k as extensionContext,
783
798
  M as extensionScope,
784
- Ge as getDefaultLoggerPrefix,
799
+ Je as getDefaultLoggerPrefix,
785
800
  Z as onActivate,
786
- Se as onDeactivate,
801
+ le as onDeactivate,
787
802
  ue as tryOnScopeDispose,
788
- Oe as useAbsolutePath,
789
- fe as useActiveColorTheme,
790
- Pe as useActiveDebugSession,
791
- Ve as useActiveEditorDecorations,
792
- Ae as useActiveNotebookEditor,
793
- Ie as useActiveTerminal,
794
- ve as useActiveTextEditor,
795
- We as useAllExtensions,
796
- Fe as useChatParticipant,
797
- me as useCommand,
798
- $e as useCommands,
799
- Me as useCommentController,
800
- Le as useControlledTerminal,
801
- Ne as useDefaultShell,
803
+ Ve as useAbsolutePath,
804
+ ve as useActiveColorTheme,
805
+ Ae as useActiveDebugSession,
806
+ Oe as useActiveEditorDecorations,
807
+ Ie as useActiveNotebookEditor,
808
+ We as useActiveTerminal,
809
+ ge as useActiveTextEditor,
810
+ Fe as useAllExtensions,
811
+ $e as useChatParticipant,
812
+ pe as useCommand,
813
+ Me as useCommands,
814
+ Le as useCommentController,
815
+ Ne as useControlledTerminal,
816
+ je as useDefaultShell,
802
817
  c as useDisposable,
803
- ge as useDocumentText,
804
- he as useEditorDecorations,
818
+ he as useDocumentText,
819
+ me as useEditorDecorations,
805
820
  x as useEvent,
806
- O as useEventEmitter,
807
- je as useExtensionSecret,
808
- He as useFetchTasks,
809
- Be as useFileUri,
810
- Ke as useFoldingRangeProvider,
811
- qe as useFsWatcher,
812
- ze as useIsDarkTheme,
813
- Qe as useIsTelemetryEnabled,
814
- Ue as useL10nText,
815
- Ye as useLmTools,
816
- Je as useLogLevel,
817
- be as useLogger,
818
- Xe as useNotebookEditorSelection,
819
- we as useNotebookEditorSelections,
820
- Ze as useNotebookEditorVisibleRanges,
821
- _e as useOpenedTerminals,
822
- pe as useOutputChannel,
823
- et as useQuickPick,
821
+ P as useEventEmitter,
822
+ He as useExtensionSecret,
823
+ Be as useFetchTasks,
824
+ Ke as useFileUri,
825
+ qe as useFoldingRangeProvider,
826
+ ze as useFsWatcher,
827
+ Qe as useIsDarkTheme,
828
+ Ue as useIsTelemetryEnabled,
829
+ Ye as useL10nText,
830
+ Ge as useLmTools,
831
+ Xe as useLogLevel,
832
+ we as useLogger,
833
+ Ze as useNotebookEditorSelection,
834
+ Ce as useNotebookEditorSelections,
835
+ _e as useNotebookEditorVisibleRanges,
836
+ et as useOpenedTerminals,
837
+ be as useOutputChannel,
838
+ tt as useQuickPick,
824
839
  _ as useReactiveOptions,
825
- tt as useStatusBarItem,
826
- nt as useTaskExecutions,
840
+ nt as useStatusBarItem,
841
+ ot as useTaskExecutions,
827
842
  it as useTerminal,
828
843
  ee as useTerminalState,
829
- Ce as useTextEditorCommand,
830
- ot as useTextEditorCommands,
831
- at as useTextEditorSelection,
832
- De as useTextEditorSelections,
833
- st as useTextEditorViewColumn,
834
- rt as useTextEditorVisibleRanges,
835
- ct as useTreeView,
844
+ De as useTextEditorCommand,
845
+ at as useTextEditorCommands,
846
+ st as useTextEditorSelection,
847
+ Te as useTextEditorSelections,
848
+ rt as useTextEditorViewColumn,
849
+ ct as useTextEditorVisibleRanges,
850
+ ut as useTreeView,
836
851
  te as useViewBadge,
837
852
  j as useViewTitle,
838
- ut as useViewVisibility,
839
- lt as useVisibleNotebookEditors,
840
- dt as useVisibleTextEditors,
841
- ft as useVscodeContext,
842
- vt as useWebviewPanel,
843
- gt as useWebviewView,
844
- ht as useWindowState,
845
- mt as useWorkspaceFolders
853
+ lt as useViewVisibility,
854
+ dt as useVisibleNotebookEditors,
855
+ ft as useVisibleTextEditors,
856
+ vt as useVscodeContext,
857
+ gt as useWebviewPanel,
858
+ ht as useWebviewView,
859
+ mt as useWindowState,
860
+ pt as useWorkspaceFolders
846
861
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "reactive-vscode",
3
3
  "type": "module",
4
- "version": "0.3.2",
4
+ "version": "0.4.0",
5
5
  "description": "Develop VSCode extension with Vue Reactivity API",
6
6
  "author": "_Kerman <kermanx@qq.com>",
7
7
  "license": "MIT",
@@ -38,13 +38,13 @@
38
38
  "@types/vscode": "^1.101.0"
39
39
  },
40
40
  "dependencies": {
41
- "@reactive-vscode/reactivity": "0.3.2"
41
+ "@reactive-vscode/reactivity": "0.4.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@types/node": "^20.19.13",
45
- "@types/vscode": "^1.103.0",
46
- "typescript": "^5.9.2",
47
- "vite": "^7.1.4",
44
+ "@types/node": "^24.6.2",
45
+ "@types/vscode": "^1.104.0",
46
+ "typescript": "^5.9.3",
47
+ "vite": "^7.1.8",
48
48
  "vite-plugin-dts": "^4.5.4"
49
49
  },
50
50
  "scripts": {