reactive-vscode 0.0.0 → 0.0.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/dist/composables/index.d.ts +0 -1
- package/dist/composables/index.mjs +0 -1
- package/dist/composables/useTreeView.d.ts +3 -4
- package/dist/composables/useTreeView.mjs +10 -2
- package/package.json +5 -5
- package/dist/composables/useTreeViewWithParent.d.ts +0 -12
- package/dist/composables/useTreeViewWithParent.mjs +0 -28
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# reactive-vscode
|
|
2
|
+
|
|
3
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
4
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
5
|
+
[![bundle][bundle-src]][bundle-href]
|
|
6
|
+
[![JSDocs][jsdocs-src]][jsdocs-href]
|
|
7
|
+
[![License][license-src]][license-href]
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
**Develop VSCode extension with Vue 3 Composition API**
|
|
11
|
+
|
|
12
|
+
[**Documentation**](https://kermanx.github.io/reactive-vscode/) | [**Why reactive-vscode**](https://kermanx.github.io/reactive-vscode/guide/why) | [**Implemented Composables**](https://kermanx.github.io/reactive-vscode/functions.html)
|
|
13
|
+
|
|
14
|
+
🚧 _**WIP**, not published yet_ 🚧
|
|
15
|
+
|
|
16
|
+
## License
|
|
17
|
+
|
|
18
|
+
[MIT](./LICENSE) License © 2024-PRESENT [_Kerman](https://github.com/KermanX)
|
|
19
|
+
|
|
20
|
+
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/).
|
|
21
|
+
|
|
22
|
+
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).
|
|
23
|
+
|
|
24
|
+
<!-- Badges -->
|
|
25
|
+
|
|
26
|
+
[npm-version-src]: https://img.shields.io/npm/v/reactive-vscode?style=flat&colorA=080f12&colorB=1fa669
|
|
27
|
+
[npm-version-href]: https://npmjs.com/package/reactive-vscode
|
|
28
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/reactive-vscode?style=flat&colorA=080f12&colorB=1fa669
|
|
29
|
+
[npm-downloads-href]: https://npmjs.com/package/reactive-vscode
|
|
30
|
+
[bundle-src]: https://img.shields.io/bundlephobia/minzip/reactive-vscode?style=flat&colorA=080f12&colorB=1fa669&label=minzip
|
|
31
|
+
[bundle-href]: https://bundlephobia.com/result?p=reactive-vscode
|
|
32
|
+
[license-src]: https://img.shields.io/github/license/KermanX/reactive-vscode.svg?style=flat&colorA=080f12&colorB=1fa669
|
|
33
|
+
[license-href]: https://github.com/KermanX/reactive-vscode/blob/main/LICENSE
|
|
34
|
+
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
|
|
35
|
+
[jsdocs-href]: https://www.jsdocs.io/package/reactive-vscode
|
|
@@ -37,7 +37,6 @@ export * from './useTextEditorSelections';
|
|
|
37
37
|
export * from './useTextEditorViewColumn';
|
|
38
38
|
export * from './useTextEditorVisibleRanges';
|
|
39
39
|
export * from './useTreeView';
|
|
40
|
-
export * from './useTreeViewWithParent';
|
|
41
40
|
export * from './useUri';
|
|
42
41
|
export * from './useViewBadge';
|
|
43
42
|
export * from './useViewTitle';
|
|
@@ -37,7 +37,6 @@ export * from "./useTextEditorSelections.mjs";
|
|
|
37
37
|
export * from "./useTextEditorViewColumn.mjs";
|
|
38
38
|
export * from "./useTextEditorVisibleRanges.mjs";
|
|
39
39
|
export * from "./useTreeView.mjs";
|
|
40
|
-
export * from "./useTreeViewWithParent.mjs";
|
|
41
40
|
export * from "./useUri.mjs";
|
|
42
41
|
export * from "./useViewBadge.mjs";
|
|
43
42
|
export * from "./useViewTitle.mjs";
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import type { ProviderResult, TreeDataProvider, TreeView, TreeViewOptions } from 'vscode';
|
|
2
1
|
import type { MaybeRefOrGetter } from '@vue/runtime-core';
|
|
2
|
+
import type { TreeDataProvider, TreeView, TreeViewOptions } from 'vscode';
|
|
3
3
|
export interface TreeViewNode {
|
|
4
|
-
readonly children?:
|
|
4
|
+
readonly children?: this[];
|
|
5
5
|
}
|
|
6
6
|
export type UseTreeViewOptions<T> = (Omit<TreeViewOptions<T>, 'treeDataProvider'> & Pick<TreeDataProvider<T>, 'getTreeItem' | 'resolveTreeItem'>) | TreeDataProvider<T>['getTreeItem'];
|
|
7
|
-
export type TreeViewWithoutParent<T> = Omit<TreeView<T>, 'reveal'>;
|
|
8
7
|
/**
|
|
9
8
|
* Register a tree view. See `vscode::window.createTreeView`.
|
|
10
9
|
*
|
|
11
10
|
* @category view
|
|
12
11
|
*/
|
|
13
|
-
export declare const useTreeView: <T extends TreeViewNode>(viewId: string, treeData: MaybeRefOrGetter<T[]>, options: UseTreeViewOptions<T>) =>
|
|
12
|
+
export declare const useTreeView: <T extends TreeViewNode>(viewId: string, treeData: MaybeRefOrGetter<T[]>, options: UseTreeViewOptions<T>) => TreeView<T>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EventEmitter, window } from "vscode";
|
|
2
1
|
import { toValue, watch } from "@vue/runtime-core";
|
|
2
|
+
import { EventEmitter, window } from "vscode";
|
|
3
3
|
import { createKeyedComposable } from "../utils/index.mjs";
|
|
4
4
|
import { useDisposable } from "./useDisposable.mjs";
|
|
5
5
|
export const useTreeView = createKeyedComposable(
|
|
@@ -7,6 +7,7 @@ export const useTreeView = createKeyedComposable(
|
|
|
7
7
|
const normalizedOptions = typeof options === "function" ? { getTreeItem: options } : options;
|
|
8
8
|
const changeEventEmitter = new EventEmitter();
|
|
9
9
|
watch(treeData, () => changeEventEmitter.fire());
|
|
10
|
+
const childrenToParentMap = /* @__PURE__ */ new WeakMap();
|
|
10
11
|
return useDisposable(window.createTreeView(viewId, {
|
|
11
12
|
...normalizedOptions,
|
|
12
13
|
treeDataProvider: {
|
|
@@ -16,7 +17,14 @@ export const useTreeView = createKeyedComposable(
|
|
|
16
17
|
return normalizedOptions.getTreeItem(node);
|
|
17
18
|
},
|
|
18
19
|
getChildren(node) {
|
|
19
|
-
|
|
20
|
+
if (node) {
|
|
21
|
+
node.children?.forEach((child) => childrenToParentMap.set(child, node));
|
|
22
|
+
return node.children;
|
|
23
|
+
}
|
|
24
|
+
return toValue(treeData);
|
|
25
|
+
},
|
|
26
|
+
getParent(node) {
|
|
27
|
+
return childrenToParentMap.get(node);
|
|
20
28
|
}
|
|
21
29
|
}
|
|
22
30
|
}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reactive-vscode",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.1-beta.1",
|
|
5
5
|
"description": "Develop VSCode extension with Vue 3 Composition API",
|
|
6
6
|
"author": "_Kerman <kermanx@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"sideEffects": false,
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
26
|
-
"types": "./
|
|
27
|
-
"import": "./
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.mjs"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
-
"main": "./
|
|
31
|
-
"types": "./
|
|
30
|
+
"main": "./dist/index.mjs",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
32
|
"files": [
|
|
33
33
|
"README.md",
|
|
34
34
|
"dist"
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { MaybeRefOrGetter } from '@vue/runtime-core';
|
|
2
|
-
import type { ProviderResult } from 'vscode';
|
|
3
|
-
import type { TreeViewNode, TreeViewWithoutParent, UseTreeViewOptions } from './useTreeView';
|
|
4
|
-
export interface TreeViewNodeWithParent extends TreeViewNode {
|
|
5
|
-
readonly parent?: ProviderResult<this>;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Register a tree view, in which items has a prarent. See `vscode::window.createTreeView`.
|
|
9
|
-
*
|
|
10
|
-
* @category view
|
|
11
|
-
*/
|
|
12
|
-
export declare const useTreeViewWithParent: <T extends TreeViewNodeWithParent>(viewId: string, treeData: MaybeRefOrGetter<T[]>, options: UseTreeViewOptions<T>) => TreeViewWithoutParent<T>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { toValue, watch } from "@vue/runtime-core";
|
|
2
|
-
import { EventEmitter, window } from "vscode";
|
|
3
|
-
import { createKeyedComposable } from "../utils/index.mjs";
|
|
4
|
-
import { useDisposable } from "./useDisposable.mjs";
|
|
5
|
-
export const useTreeViewWithParent = createKeyedComposable(
|
|
6
|
-
(viewId, treeData, options) => {
|
|
7
|
-
const normalizedOptions = typeof options === "function" ? { getTreeItem: options } : options;
|
|
8
|
-
const changeEventEmitter = new EventEmitter();
|
|
9
|
-
watch(treeData, () => changeEventEmitter.fire());
|
|
10
|
-
return useDisposable(window.createTreeView(viewId, {
|
|
11
|
-
...normalizedOptions,
|
|
12
|
-
treeDataProvider: {
|
|
13
|
-
...normalizedOptions,
|
|
14
|
-
onDidChangeTreeData: changeEventEmitter.event,
|
|
15
|
-
getTreeItem(node) {
|
|
16
|
-
return normalizedOptions.getTreeItem(node);
|
|
17
|
-
},
|
|
18
|
-
getChildren(node) {
|
|
19
|
-
return node ? node.children : toValue(treeData);
|
|
20
|
-
},
|
|
21
|
-
getParent(node) {
|
|
22
|
-
return node.parent;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}));
|
|
26
|
-
},
|
|
27
|
-
(viewId) => viewId
|
|
28
|
-
);
|