reactive-vscode 0.2.6-beta.1 → 0.2.6

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.
Files changed (3) hide show
  1. package/README.md +108 -108
  2. package/dist/index.cjs +1 -0
  3. package/package.json +10 -9
package/README.md CHANGED
@@ -1,108 +1,108 @@
1
- # reactive-vscode
2
-
3
- [![npm version][npm-version-src]][npm-version-href]
4
- [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
- [![License][license-src]][license-href]
6
-
7
- <img src="./docs/public/header.png" width="60%" />
8
-
9
- **Develop VSCode extension with Vue Reactivity API**
10
-
11
- - [**Documentation**](https://kermanx.github.io/reactive-vscode/)
12
- - [**Why reactive-vscode**](https://kermanx.github.io/reactive-vscode/guide/why)
13
- - [**All Functions**](https://kermanx.github.io/reactive-vscode/functions/)
14
- - [**Examples**](https://kermanx.github.io/reactive-vscode/examples/)
15
-
16
- ### Project Status
17
-
18
- Currently, most of the VSCode APIs are covered, and this project has been used in:
19
-
20
- - [Slidev for VSCode <sub><sub>![downloads](https://img.shields.io/visual-studio-marketplace/d/antfu.slidev.svg)</sub></sub>](https://github.com/slidevjs/slidev/tree/main/packages/vscode)
21
- - [Iconify IntelliSense <sub><sub>![downloads](https://img.shields.io/visual-studio-marketplace/d/antfu.iconify.svg)</sub></sub>](https://github.com/antfu/vscode-iconify)
22
-
23
- The [documentation](https://kermanx.github.io/reactive-vscode/) is complete, and the [VueUse integration](https://kermanx.github.io/reactive-vscode/guide/vueuse.html) is also available.
24
-
25
- However, the project is still in beta and may have minor API changes. If you encounter any problems, please feel free to [open an issue](https://github.com/KermanX/reactive-vscode/issues/new).
26
-
27
- ### Counter Example
28
-
29
- ```ts
30
- import { defineExtension, ref, useCommands, useStatusBarItem } from 'reactive-vscode'
31
- import { StatusBarAlignment } from 'vscode'
32
-
33
- export = defineExtension(() => {
34
- const counter = ref(0)
35
-
36
- useStatusBarItem({
37
- alignment: StatusBarAlignment.Right,
38
- priority: 100,
39
- text: () => `$(megaphone) Hello*${counter.value}`,
40
- })
41
-
42
- useCommands({
43
- 'extension.sayHello': () => counter.value++,
44
- 'extension.sayGoodbye': () => counter.value--,
45
- })
46
- })
47
- ```
48
-
49
- <details>
50
- <summary> Implementation with original VSCode API </summary>
51
-
52
- ```ts
53
- import type { ExtensionContext } from 'vscode'
54
- import { StatusBarAlignment, commands, window } from 'vscode'
55
-
56
- export function activate(extensionContext: ExtensionContext) {
57
- let counter = 0
58
-
59
- const item = window.createStatusBarItem(StatusBarAlignment.Right, 100)
60
-
61
- function updateStatusBar() {
62
- item.text = `$(megaphone) Hello*${counter}`
63
- item.show()
64
- }
65
-
66
- updateStatusBar()
67
-
68
- extensionContext.subscriptions.push(
69
- commands.registerCommand('extension.sayHello', () => {
70
- counter++
71
- updateStatusBar()
72
- }),
73
- commands.registerCommand('extension.sayGoodbye', () => {
74
- counter--
75
- updateStatusBar()
76
- }),
77
- )
78
- }
79
- ```
80
-
81
- </details>
82
-
83
- [More examples](https://kermanx.github.io/reactive-vscode/examples/).
84
-
85
- ### License
86
-
87
- [MIT](./LICENSE) License © 2024-PRESENT [_Kerman](https://github.com/KermanX)
88
-
89
- Source code in [the `./packages/reactivity` directory](https://github.com/KermanX/reactive-vscode/blob/main/packages/core/src/reactivity) is ported from [`@vue/runtime-core`](https://github.com/vuejs/core/blob/main/packages/runtime-core). Licensed under a [MIT License](https://github.com/vueuse/vueuse/blob/main/LICENSE).
90
-
91
- Source code in [the `./packages/mock` directory](https://github.com/KermanX/reactive-vscode/blob/main/packages/core/src/mock) references the implementation of [`VSCode`](https://github.com/microsoft/vscode). Licensed under a [MIT License](https://github.com/microsoft/vscode/blob/main/LICENSE.txt).
92
-
93
- The logo <img src="https://kermanx.github.io/reactive-vscode/logo.svg" width="14"> is modified from [Vue Reactity Artworks](https://github.com/vue-reactivity/art). Licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-nc-sa/4.0/).
94
-
95
- Part of the docs website is ported from [VueUse](https://github.com/vueuse/vueuse). Licensed under a [MIT License](https://github.com/vueuse/vueuse/blob/main/LICENSE).
96
-
97
- <!-- Badges -->
98
-
99
- [npm-version-src]: https://img.shields.io/npm/v/reactive-vscode?style=flat&colorA=080f12&colorB=1fa669
100
- [npm-version-href]: https://npmjs.com/package/reactive-vscode
101
- [npm-downloads-src]: https://img.shields.io/npm/dm/reactive-vscode?style=flat&colorA=080f12&colorB=1fa669
102
- [npm-downloads-href]: https://npmjs.com/package/reactive-vscode
103
- [bundle-src]: https://img.shields.io/bundlephobia/minzip/reactive-vscode?style=flat&colorA=080f12&colorB=1fa669&label=minzip
104
- [bundle-href]: https://bundlephobia.com/result?p=reactive-vscode
105
- [license-src]: https://img.shields.io/github/license/KermanX/reactive-vscode.svg?style=flat&colorA=080f12&colorB=1fa669
106
- [license-href]: https://github.com/KermanX/reactive-vscode/blob/main/LICENSE
107
- [jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
108
- [jsdocs-href]: https://www.jsdocs.io/package/reactive-vscode
1
+ # reactive-vscode
2
+
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
+ [![License][license-src]][license-href]
6
+
7
+ <img src="./docs/public/header.png" width="60%" />
8
+
9
+ **Develop VSCode extension with Vue Reactivity API**
10
+
11
+ - [**Documentation**](https://kermanx.github.io/reactive-vscode/)
12
+ - [**Why reactive-vscode**](https://kermanx.github.io/reactive-vscode/guide/why)
13
+ - [**All Functions**](https://kermanx.github.io/reactive-vscode/functions/)
14
+ - [**Examples**](https://kermanx.github.io/reactive-vscode/examples/)
15
+
16
+ ### Project Status
17
+
18
+ Currently, most of the VSCode APIs are covered, and this project has been used in:
19
+
20
+ - [Slidev for VSCode <sub><sub>![downloads](https://img.shields.io/visual-studio-marketplace/d/antfu.slidev.svg)</sub></sub>](https://github.com/slidevjs/slidev/tree/main/packages/vscode)
21
+ - [Iconify IntelliSense <sub><sub>![downloads](https://img.shields.io/visual-studio-marketplace/d/antfu.iconify.svg)</sub></sub>](https://github.com/antfu/vscode-iconify)
22
+
23
+ The [documentation](https://kermanx.github.io/reactive-vscode/) is complete, and the [VueUse integration](https://kermanx.github.io/reactive-vscode/guide/vueuse.html) is also available.
24
+
25
+ However, the project is still in beta and may have minor API changes. If you encounter any problems, please feel free to [open an issue](https://github.com/KermanX/reactive-vscode/issues/new).
26
+
27
+ ### Counter Example
28
+
29
+ ```ts
30
+ import { defineExtension, ref, useCommands, useStatusBarItem } from 'reactive-vscode'
31
+ import { StatusBarAlignment } from 'vscode'
32
+
33
+ export = defineExtension(() => {
34
+ const counter = ref(0)
35
+
36
+ useStatusBarItem({
37
+ alignment: StatusBarAlignment.Right,
38
+ priority: 100,
39
+ text: () => `$(megaphone) Hello*${counter.value}`,
40
+ })
41
+
42
+ useCommands({
43
+ 'extension.sayHello': () => counter.value++,
44
+ 'extension.sayGoodbye': () => counter.value--,
45
+ })
46
+ })
47
+ ```
48
+
49
+ <details>
50
+ <summary> Implementation with original VSCode API </summary>
51
+
52
+ ```ts
53
+ import type { ExtensionContext } from 'vscode'
54
+ import { commands, StatusBarAlignment, window } from 'vscode'
55
+
56
+ export function activate(extensionContext: ExtensionContext) {
57
+ let counter = 0
58
+
59
+ const item = window.createStatusBarItem(StatusBarAlignment.Right, 100)
60
+
61
+ function updateStatusBar() {
62
+ item.text = `$(megaphone) Hello*${counter}`
63
+ item.show()
64
+ }
65
+
66
+ updateStatusBar()
67
+
68
+ extensionContext.subscriptions.push(
69
+ commands.registerCommand('extension.sayHello', () => {
70
+ counter++
71
+ updateStatusBar()
72
+ }),
73
+ commands.registerCommand('extension.sayGoodbye', () => {
74
+ counter--
75
+ updateStatusBar()
76
+ }),
77
+ )
78
+ }
79
+ ```
80
+
81
+ </details>
82
+
83
+ [More examples](https://kermanx.github.io/reactive-vscode/examples/).
84
+
85
+ ### License
86
+
87
+ [MIT](./LICENSE) License © 2024-PRESENT [_Kerman](https://github.com/KermanX)
88
+
89
+ Source code in [the `./packages/reactivity` directory](https://github.com/KermanX/reactive-vscode/blob/main/packages/core/src/reactivity) is ported from [`@vue/runtime-core`](https://github.com/vuejs/core/blob/main/packages/runtime-core). Licensed under a [MIT License](https://github.com/vueuse/vueuse/blob/main/LICENSE).
90
+
91
+ Source code in [the `./packages/mock` directory](https://github.com/KermanX/reactive-vscode/blob/main/packages/core/src/mock) references the implementation of [`VSCode`](https://github.com/microsoft/vscode). Licensed under a [MIT License](https://github.com/microsoft/vscode/blob/main/LICENSE.txt).
92
+
93
+ The logo <img src="https://kermanx.github.io/reactive-vscode/logo.svg" width="14"> is modified from [Vue Reactity Artworks](https://github.com/vue-reactivity/art). Licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-nc-sa/4.0/).
94
+
95
+ Part of the docs website is ported from [VueUse](https://github.com/vueuse/vueuse). Licensed under a [MIT License](https://github.com/vueuse/vueuse/blob/main/LICENSE).
96
+
97
+ <!-- Badges -->
98
+
99
+ [npm-version-src]: https://img.shields.io/npm/v/reactive-vscode?style=flat&colorA=080f12&colorB=1fa669
100
+ [npm-version-href]: https://npmjs.com/package/reactive-vscode
101
+ [npm-downloads-src]: https://img.shields.io/npm/dm/reactive-vscode?style=flat&colorA=080f12&colorB=1fa669
102
+ [npm-downloads-href]: https://npmjs.com/package/reactive-vscode
103
+ [bundle-src]: https://img.shields.io/bundlephobia/minzip/reactive-vscode?style=flat&colorA=080f12&colorB=1fa669&label=minzip
104
+ [bundle-href]: https://bundlephobia.com/result?p=reactive-vscode
105
+ [license-src]: https://img.shields.io/github/license/KermanX/reactive-vscode.svg?style=flat&colorA=080f12&colorB=1fa669
106
+ [license-href]: https://github.com/KermanX/reactive-vscode/blob/main/LICENSE
107
+ [jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
108
+ [jsdocs-href]: https://www.jsdocs.io/package/reactive-vscode
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@reactive-vscode/reactivity"),s=require("vscode");function y(e){return n.getCurrentScope()?(n.onScopeDispose(e),!0):!1}function p(e,t){const a=new Map;return(...o)=>{const i=t(...o);let c=a.get(i);return c?c.refCount++:(c={data:e(...o),refCount:1},a.set(i,c)),y(()=>{--c.refCount===0&&a.delete(i)}),c.data}}function v(e){let t;return()=>t??(t=e())}const E=[];function B(e){E.push(e)}const C=n.shallowRef(null),T=n.effectScope();function H(e){return{activate:t=>(C.value=t,T.run(()=>(S.map(a=>a(t)),e()))),deactivate:()=>{E.map(t=>t()),T.stop()}}}const S=[];function x(e){C.value?e(C.value):S.push(e)}function A(e,t,a){const o=!e,i=s.workspace.getConfiguration(o?void 0:e,a);function c(l,d){const w=n.shallowRef(d),h=n.computed({get:()=>w.value,set:f=>{w.value=f,i.update(l,f)}});return h.update=async(f,g,m)=>{await i.update(l,f,g,m),h.value=f},h.set=f=>{w.value=f},h}const u=Object.fromEntries(Object.keys(t).map(l=>[l,c(l,i.get(l))]));return x(()=>{r(s.workspace.onDidChangeConfiguration(o?l=>{const d=s.workspace.getConfiguration();for(const w in t)l.affectsConfiguration(w)&&u[w].set(d.get(w))}:l=>{if(!l.affectsConfiguration(e))return;const d=s.workspace.getConfiguration(e);for(const w in t)l.affectsConfiguration(`${e}.${w}`)&&u[w].set(d.get(w))}))}),u}function K(e,t,a){const o=A(e,t,a);return n.reactive({...o,$update(i,c,u,l){return o[i].update(c,u,l)},$set(i,c){return o[i].set(c)}})}function q(e,t){const a=n.shallowRef(null),o=[],i=c=>(...u)=>a.value?a.value[c](...u):(o.push([c,u]),null);return x(()=>{a.value=N(e,t);for(const[c,u]of o)a.value[c](...u)}),{logger:a,outputChannel:n.computed(()=>{var c;return(c=a.value)==null?void 0:c.outputChannel}),info:i("info"),warn:i("warn"),error:i("error"),append:i("append"),appendLine:i("appendLine"),replace:i("replace"),clear:i("clear"),show:i("show"),hide:i("hide")}}function Q(e,...t){return s.commands.executeCommand(e,...t)}function U(e,t=!1){const a=C.value;if(!a&&!t)throw new Error("Cannot get absolute path because the extension is not activated yet");return a==null?void 0:a.asAbsolutePath(e)}function z(e,t=!1){return n.computed(()=>U(n.toValue(e),t))}function r(e){return(n.getCurrentScope()??T).cleanups.push(e.dispose.bind(e)),e}const I=v(()=>{const e=n.shallowRef(s.window.activeColorTheme);return r(s.window.onDidChangeActiveColorTheme(t=>{e.value=t})),e}),Y=v(()=>{const e=n.shallowRef(s.debug.activeDebugSession);return r(s.debug.onDidChangeActiveDebugSession(t=>{e.value=t})),n.computed(()=>e.value)}),O=v(()=>{const e=n.shallowRef(s.window.activeTextEditor);return r(s.window.onDidChangeActiveTextEditor(t=>{e.value=t})),e});function P(e){var a;const t=n.shallowRef((a=n.toValue(e))==null?void 0:a.getText());return n.watchEffect(()=>{var o;t.value=(o=n.toValue(e))==null?void 0:o.getText()}),r(s.workspace.onDidChangeTextDocument(o=>{o.document===n.toValue(e)&&(t.value=o.document.getText())})),t}function W(e,t,a,o={}){const{updateOn:i=["effect","documentChanged"]}=o,c="key"in t?t:r(s.window.createTextEditorDecorationType(t)),u=async()=>{const d=n.toValue(e);d&&d.setDecorations(c,typeof a=="function"?await a(d):n.toValue(a))},l=i.includes("documentChanged")?P(()=>{var d;return(d=n.toValue(e))==null?void 0:d.document}):null;return i.includes("effect")?n.watchEffect(async()=>{l==null||l.value,await u()}):l&&n.watch(l,u),{update:u}}function G(e,t){const a=O();W(a,e,t)}const J=v(()=>{const e=n.shallowRef(s.window.activeNotebookEditor);return r(s.window.onDidChangeActiveNotebookEditor(t=>{e.value=t})),e}),X=v(()=>{const e=n.shallowRef(s.window.activeTerminal);return r(s.window.onDidChangeActiveTerminal(t=>{e.value=t})),e}),Z=v(()=>{const e=n.shallowRef(s.extensions.all);return r(s.extensions.onDidChange(()=>{e.value=s.extensions.all})),n.computed(()=>e.value)});function F(e,t){r(s.commands.registerCommand(e,t))}function _(e){for(const[t,a]of Object.entries(e))a&&F(t,a)}function ee(e,t){return r(s.comments.createCommentController(e,t))}function R(e){var a;const t=n.shallowRef((a=n.toValue(e))==null?void 0:a.state);return n.watch(e,()=>{var o;t.value=(o=n.toValue(e))==null?void 0:o.state}),r(s.window.onDidChangeTerminalState(o=>{o===n.toValue(e)&&(t.value=o.state)})),n.computed(()=>t.value)}function te(...e){const t=n.ref(null);function a(){return!!t.value&&t.value.exitStatus==null}function o(){return a()?t.value:t.value=s.window.createTerminal(...e)}function i(l){o().sendText(l)}function c(){o().show()}function u(){a()&&(t.value.sendText(""),t.value.dispose(),t.value=null)}return n.onScopeDispose(u),{terminal:t,getIsActive:a,show:c,sendText:i,close:u,state:R(t)}}const ne=v(()=>{const e=n.shallowRef(s.env.shell);return r(s.env.onDidChangeShell(t=>{e.value=t})),n.computed(()=>e.value)});function b(e,t){const a=(o,i,c)=>{r(e(o,i,c))};return t==null||t.forEach(o=>a(o)),a}function V(e,t=[]){const a=Array.isArray(e)?e:t??[],o=r(Array.isArray(e)||e==null?new s.EventEmitter:e),i=b(o.event,a);for(const c of a)i(c);return{event:o.event,fire:o.fire.bind(o),addListener:i}}async function ae(e){const t=C.value.secrets,a=n.ref(await t.get(e));return a.set=async o=>{a.value=o,await t.store(e,o)},a.remove=async()=>{a.value=void 0,await t.delete(e)},r(t.onDidChange(async o=>{o.key===e&&(a.value=await t.get(e))})),n.watch(a,o=>{o===void 0?t.delete(e):t.store(e,o)}),a}function oe(e){return n.computed(()=>s.tasks.fetchTasks(n.toValue(e)))}function ie(e){return n.computed(()=>s.Uri.file(n.toValue(e)))}function se(e,t){const a=new s.EventEmitter,o=n.shallowRef();n.watchEffect(()=>{o.value&&a.fire(),o.value=n.toValue(t)}),r(s.languages.registerFoldingRangeProvider(e,{onDidChangeFoldingRanges:a.event,provideFoldingRanges(i,c,u){var l;return(l=o.value)==null?void 0:l.call(o,i,c,u)}}))}function ue(e,t,a,o){const i=n.shallowReactive(new Map),c=V(),u=V(),l=V(),d=n.computed(()=>{const f=n.toValue(e);return Array.isArray(f)?f:f instanceof Set?Array.from(f):[f]});function w(){const f=d.value;for(const[g,m]of i)f.includes(g)||(m.dispose(),i.delete(g));for(const g of f)if(!i.has(g)){const m=s.workspace.createFileSystemWatcher(g,n.toValue(t)||!1,n.toValue(a)||!1,n.toValue(o)||!1);m.onDidCreate(c.fire),m.onDidChange(u.fire),m.onDidDelete(l.fire),i.set(g,m)}}function h(){for(const f of i.values())f.dispose();i.clear()}return w(),n.watch(d,w),n.watch(()=>[n.toValue(t),n.toValue(a),n.toValue(o)],()=>{h(),w()}),n.onScopeDispose(h),{watchers:i,onDidCreate:c.event,onDidChange:u.event,onDidDelete:l.event}}const ce=v(()=>{const e=I();return n.computed(()=>e.value.kind===s.ColorThemeKind.Dark||e.value.kind===s.ColorThemeKind.HighContrast)}),re=v(()=>{const e=n.shallowRef(s.env.isTelemetryEnabled);return r(s.env.onDidChangeTelemetryEnabled(t=>{e.value=t})),n.computed(()=>e.value)});function le(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)))}function L(e,t){return r(s.window.createOutputChannel(e,t))}function de(e){const t=new Date,a=String(t.getFullYear()).padStart(4,"0"),o=String(t.getMonth()+1).padStart(2,"0"),i=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"),d=String(t.getMilliseconds()).padStart(3,"0");return`${a}-${o}-${i} ${c}:${u}:${l}.${d} [${e}] `}function N(e,t={}){const a=t.outputChannel??L(e),o=i=>(...c)=>{var u;a.appendLine((((u=t.getPrefix)==null?void 0:u.call(t,i))??"")+c.join(" "))};return{outputChannel:a,createLoggerFunc:o,info:o("INFO"),warn:o("WARN"),error:o("ERROR"),append:a.append.bind(a),appendLine:a.appendLine.bind(a),replace:a.replace.bind(a),clear:a.clear.bind(a),show:a.show.bind(a),hide:a.hide.bind(a)}}const fe=v(()=>{const e=n.shallowRef(s.env.logLevel);return r(s.env.onDidChangeLogLevel(t=>{e.value=t})),n.computed(()=>e.value)});function M(e){var a;const t=n.shallowRef(((a=n.toValue(e))==null?void 0:a.selections)??[]);return n.watch(e,()=>{var o;t.value=((o=n.toValue(e))==null?void 0:o.selections)??[]}),r(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 we(e){const t=M(e);return n.computed({get(){return t.value[0]},set(a){t.value=t.value.toSpliced(0,1,a)}})}function ve(e){var a;const t=n.shallowRef(((a=n.toValue(e))==null?void 0:a.visibleRanges)??[]);return n.watch(e,()=>{var o;t.value=((o=n.toValue(e))==null?void 0:o.visibleRanges)??[]}),r(s.window.onDidChangeNotebookEditorVisibleRanges(o=>{o.notebookEditor===n.toValue(e)&&(t.value=o.visibleRanges)})),n.computed(()=>t.value)}const he=v(()=>{const e=n.shallowRef(s.window.terminals);function t(){e.value=s.window.terminals}return r(s.window.onDidOpenTerminal(t)),r(s.window.onDidCloseTerminal(t)),e});function ge(e={}){const t=r(s.window.createQuickPick()),a=b(t.onDidChangeActive),o=b(t.onDidChangeSelection),i=b(t.onDidAccept),c=b(t.onDidHide),u=b(t.onDidTriggerButton),l=b(t.onDidChangeValue);["items","buttons","title","step","totalSteps","enabled","busy","ignoreFocusOut","placeholder","canSelectMany","matchOnDescription","matchOnDetail","keepScrollPosition"].forEach(f=>{e[f]&&n.watchEffect(()=>t[f]=n.toValue(e[f]))}),e.value&&(t.value=e.value);const d=n.shallowRef(t.value);l(f=>d.value=f),e.activeItems&&(t.activeItems=e.activeItems);const w=n.shallowRef(t.activeItems);a(f=>w.value=f),e.selectedItems&&(t.selectedItems=e.selectedItems);const h=n.shallowRef(t.selectedItems);return o(f=>h.value=f),{...t,onDidChangeActive:a,onDidChangeSelection:o,onDidAccept:i,onDidHide:c,onDidTriggerButton:u,onDidChangeValue:l,value:d,activeItems:w,selectedItems:h}}function me(e){const t=r(e.id?s.window.createStatusBarItem(e.id,e.alignment,e.priority):s.window.createStatusBarItem(e.alignment,e.priority));function a(o){const i=e[o];i!=null&&n.watchEffect(()=>t[o]=n.toValue(i))}return["name","text","tooltip","color","backgroundColor","command","accessibilityInformation"].forEach(a),t}const be=v(()=>{const e=n.shallowRef(s.tasks.taskExecutions);function t(){e.value=s.tasks.taskExecutions}return r(s.tasks.onDidStartTask(t)),r(s.tasks.onDidEndTask(t)),n.computed(()=>e.value)});function Ce(...e){const t=r(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:R(t)}}function $(e,t){r(s.commands.registerTextEditorCommand(e,t))}function Ve(e){for(const[t,a]of Object.entries(e))$(t,a)}function j(e,t){var o;const a=n.shallowRef(((o=n.toValue(e))==null?void 0:o.selections)??[]);return n.watch(e,()=>{var i;a.value=((i=n.toValue(e))==null?void 0:i.selections)??[]}),r(s.window.onDidChangeTextEditorSelection(i=>{const c=n.toValue(e),u=n.toValue(t);i.textEditor===c&&(!u||u.includes(i.kind))&&(a.value=i.selections)})),n.computed({get(){return a.value},set(i){a.value=i;const c=n.toValue(e);c&&(c.selections=i)}})}function Te(e,t){const a=j(e,t);return n.computed({get(){return a.value[0]},set(o){a.value=a.value.toSpliced(0,1,o)}})}function De(e){var a;const t=n.shallowRef((a=n.toValue(e))==null?void 0:a.viewColumn);return n.watch(e,()=>{var o;t.value=(o=n.toValue(e))==null?void 0:o.viewColumn}),r(s.window.onDidChangeTextEditorViewColumn(o=>{o.textEditor===n.toValue(e)&&(t.value=o.viewColumn)})),n.computed(()=>t.value)}function pe(e){var a;const t=n.shallowRef(((a=n.toValue(e))==null?void 0:a.visibleRanges)??[]);return n.watch(e,()=>{var o;t.value=((o=n.toValue(e))==null?void 0:o.visibleRanges)??[]}),r(s.window.onDidChangeTextEditorVisibleRanges(o=>{o.textEditor===n.toValue(e)&&(t.value=o.visibleRanges)})),n.computed(()=>t.value)}function k(e,t){n.watchEffect(()=>{const a=n.toValue(e);a&&(a.badge=n.toValue(t))})}function D(e,t){n.watchEffect(()=>{const a=n.toValue(e);a&&(a.title=n.toValue(t))})}const Ee=p((e,t,a)=>{const o=V();n.watch(t,()=>o.fire()),a!=null&&a.watchSource&&n.watch(a.watchSource,()=>o.fire());const i=new WeakMap,c=r(s.window.createTreeView(e,{...a,treeDataProvider:{...a,onDidChangeTreeData:o.event,getTreeItem(u){return u.treeItem},getChildren(u){var l;return u?((l=u.children)==null||l.forEach(d=>i.set(d,u)),u.children):n.toValue(t)},getParent(u){return i.get(u)}}}));return a!=null&&a.title&&D(c,a.title),a!=null&&a.badge&&k(c,a.badge),c},e=>e);function Se(e){var o;const t=n.ref((o=n.toValue(e))==null?void 0:o.visible);function a(){var i;t.value=(i=n.toValue(e))==null?void 0:i.visible}return n.watchEffect(i=>{const c=n.toValue(e);if(c){const u=c.onDidChangeVisibility(a);i(()=>u.dispose())}}),n.watchEffect(a),n.computed(()=>!!t.value)}const xe=v(()=>{const e=n.shallowRef(s.window.visibleNotebookEditors);return r(s.window.onDidChangeVisibleNotebookEditors(t=>{e.value=t})),e}),Re=v(()=>{const e=n.shallowRef(s.window.visibleTextEditors);return r(s.window.onDidChangeVisibleTextEditors(t=>{e.value=t})),e});function ke(e,t,a=!0){const o=n.isRef(t)?t:typeof t=="function"?n.computed(t):n.ref(t);return n.watchEffect(()=>{n.toValue(a)&&s.commands.executeCommand("setContext",e,o.value)}),o}function ye(e,t,a,o,i){const c=n.shallowRef(),u=r(s.window.createWebviewPanel(e,n.toValue(t),o,{enableFindWidget:i==null?void 0:i.enableFindWidget,retainContextWhenHidden:i==null?void 0:i.retainContextWhenHidden,...n.toValue(i==null?void 0:i.webviewOptions)}));i!=null&&i.onDidReceiveMessage&&u.webview.onDidReceiveMessage(i.onDidReceiveMessage);const l=n.ref(0);function d(){l.value++}if(n.watchEffect(()=>{u.webview.html=`${n.toValue(a)}<!--${l.value}-->`}),i!=null&&i.webviewOptions){const g=i.webviewOptions;n.watchEffect(()=>{u.webview.options=n.toValue(g)})}D(u,t);function w(g){return u.webview.postMessage(g)}const h=n.ref(u.active),f=n.ref(u.visible);return r(u.onDidChangeViewState(()=>{h.value=u.active,f.value=u.visible})),{panel:u,context:c,active:h,visible:f,postMessage:w,forceRefresh:d}}const Ae=p((e,t,a)=>{const o=n.shallowRef(),i=n.shallowRef();r(s.window.registerWebviewViewProvider(e,{resolveWebviewView(d,w){o.value=d,i.value=w,a!=null&&a.onDidReceiveMessage&&d.webview.onDidReceiveMessage(a.onDidReceiveMessage)}},{webviewOptions:{retainContextWhenHidden:a==null?void 0:a.retainContextWhenHidden}}));const c=n.ref(0);function u(){c.value++}if(n.watchEffect(()=>{o.value&&(o.value.webview.html=`${n.toValue(t)}<!--${c.value}-->`)}),a!=null&&a.webviewOptions){const d=a.webviewOptions;n.watchEffect(()=>{o.value&&(o.value.webview.options=n.toValue(d))})}a!=null&&a.title&&D(o,a.title),a!=null&&a.badge&&k(o,a.badge);function l(d){var w;return(w=o.value)==null?void 0:w.webview.postMessage(d)}return{view:o,context:i,postMessage:l,forceRefresh:u}},e=>e),Ie=v(()=>{const e=n.shallowRef(s.window.state);return r(s.window.onDidChangeWindowState(t=>{e.value=t})),{focused:n.computed(()=>e.value.focused),active:n.computed(()=>e.value.active)}}),Oe=v(()=>{const e=n.shallowRef(s.workspace.workspaceFolders);return r(s.workspace.onDidChangeWorkspaceFolders(()=>{e.value=s.workspace.workspaceFolders})),n.computed(()=>e.value)});exports.activateCbs=S;exports.createKeyedComposable=p;exports.createSingletonComposable=v;exports.deactivateCbs=E;exports.defineConfigObject=K;exports.defineConfigs=A;exports.defineExtension=H;exports.defineLogger=q;exports.executeCommand=Q;exports.extensionContext=C;exports.extensionScope=T;exports.getDefaultLoggerPrefix=de;exports.onActivate=x;exports.onDeactivate=B;exports.tryOnScopeDispose=y;exports.useAbsolutePath=z;exports.useActiveColorTheme=I;exports.useActiveDebugSession=Y;exports.useActiveEditorDecorations=G;exports.useActiveNotebookEditor=J;exports.useActiveTerminal=X;exports.useActiveTextEditor=O;exports.useAllExtensions=Z;exports.useCommand=F;exports.useCommands=_;exports.useCommentController=ee;exports.useControlledTerminal=te;exports.useDefaultShell=ne;exports.useDisposable=r;exports.useDocumentText=P;exports.useEditorDecorations=W;exports.useEvent=b;exports.useEventEmitter=V;exports.useExtensionSecret=ae;exports.useFetchTasks=oe;exports.useFileUri=ie;exports.useFoldingRangeProvider=se;exports.useFsWatcher=ue;exports.useIsDarkTheme=ce;exports.useIsTelemetryEnabled=re;exports.useL10nText=le;exports.useLogLevel=fe;exports.useLogger=N;exports.useNotebookEditorSelection=we;exports.useNotebookEditorSelections=M;exports.useNotebookEditorVisibleRanges=ve;exports.useOpenedTerminals=he;exports.useOutputChannel=L;exports.useQuickPick=ge;exports.useStatusBarItem=me;exports.useTaskExecutions=be;exports.useTerminal=Ce;exports.useTerminalState=R;exports.useTextEditorCommand=$;exports.useTextEditorCommands=Ve;exports.useTextEditorSelection=Te;exports.useTextEditorSelections=j;exports.useTextEditorViewColumn=De;exports.useTextEditorVisibleRanges=pe;exports.useTreeView=Ee;exports.useViewBadge=k;exports.useViewTitle=D;exports.useViewVisibility=Se;exports.useVisibleNotebookEditors=xe;exports.useVisibleTextEditors=Re;exports.useVscodeContext=ke;exports.useWebviewPanel=ye;exports.useWebviewView=Ae;exports.useWindowState=Ie;exports.useWorkspaceFolders=Oe;Object.keys(n).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>n[e]})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "reactive-vscode",
3
3
  "type": "module",
4
- "version": "0.2.6-beta.1",
4
+ "version": "0.2.6",
5
5
  "description": "Develop VSCode extension with Vue Reactivity API",
6
6
  "author": "_Kerman <kermanx@qq.com>",
7
7
  "license": "MIT",
@@ -24,10 +24,11 @@
24
24
  "exports": {
25
25
  ".": {
26
26
  "types": "./dist/index.d.ts",
27
- "import": "./dist/index.js"
27
+ "import": "./dist/index.js",
28
+ "require": "./dist/index.cjs"
28
29
  }
29
30
  },
30
- "main": "./dist/index.js",
31
+ "main": "./dist/index.cjs",
31
32
  "types": "./dist/index.d.ts",
32
33
  "files": [
33
34
  "README.md",
@@ -37,14 +38,14 @@
37
38
  "@types/vscode": "^1.89.0"
38
39
  },
39
40
  "dependencies": {
40
- "@reactive-vscode/reactivity": "0.2.6-beta.1"
41
+ "@reactive-vscode/reactivity": "0.2.6"
41
42
  },
42
43
  "devDependencies": {
43
- "@types/node": "^20.16.10",
44
- "@types/vscode": "^1.93.0",
45
- "typescript": "^5.6.2",
46
- "vite": "^5.4.8",
47
- "vite-plugin-dts": "^4.2.1"
44
+ "@types/node": "^20.17.0",
45
+ "@types/vscode": "^1.94.0",
46
+ "typescript": "^5.6.3",
47
+ "vite": "^5.4.10",
48
+ "vite-plugin-dts": "^4.3.0"
48
49
  },
49
50
  "scripts": {
50
51
  "typecheck": "tsc --noEmit",