reactive-vscode 0.2.0-beta.6 → 0.2.0-beta.8

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 CHANGED
@@ -12,6 +12,17 @@
12
12
  - [**Why reactive-vscode**](https://kermanx.github.io/reactive-vscode/guide/why)
13
13
  - [**All Functions**](https://kermanx.github.io/reactive-vscode/functions/)
14
14
 
15
+ ### Project Status
16
+
17
+ Currently, most of the VSCode APIs are covered, and this project has been used in:
18
+
19
+ - [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)
20
+ - [Iconify IntelliSense <sub><sub>![downloads](https://img.shields.io/visual-studio-marketplace/d/antfu.iconify.svg)</sub></sub>](https://github.com/antfu/vscode-iconify)
21
+
22
+ 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.
23
+
24
+ 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).
25
+
15
26
  ### Counter Example
16
27
 
17
28
  ```ts
@@ -70,12 +81,14 @@ export function activate(extensionContext: ExtensionContext) {
70
81
 
71
82
  [More examples](https://kermanx.github.io/reactive-vscode/examples/).
72
83
 
73
- ## License
84
+ ### License
74
85
 
75
86
  [MIT](./LICENSE) License © 2024-PRESENT [_Kerman](https://github.com/KermanX)
76
87
 
77
88
  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).
78
89
 
90
+ 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).
91
+
79
92
  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/).
80
93
 
81
94
  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).
package/dist/index.d.ts CHANGED
@@ -16,6 +16,7 @@ import { EventEmitter } from 'vscode';
16
16
  import { Extension } from 'vscode';
17
17
  import { ExtensionContext } from 'vscode';
18
18
  import { ExtensionTerminalOptions } from 'vscode';
19
+ import { FileSystemWatcher } from 'vscode';
19
20
  import { FoldingRangeProvider } from 'vscode';
20
21
  import { GlobPattern } from 'vscode';
21
22
  import { LogLevel } from 'vscode';
@@ -24,6 +25,9 @@ import { MaybeRefOrGetter } from '@reactive-vscode/reactivity';
24
25
  import { NotebookEditor } from 'vscode';
25
26
  import { NotebookRange } from 'vscode';
26
27
  import { OutputChannel } from 'vscode';
28
+ import { QuickInputButton } from 'vscode';
29
+ import { QuickPickItem } from 'vscode';
30
+ import { QuickPickItemButtonEvent } from 'vscode';
27
31
  import { Range } from 'vscode';
28
32
  import { Ref } from '@reactive-vscode/reactivity';
29
33
  import { Selection } from 'vscode';
@@ -46,6 +50,7 @@ import { TreeDataProvider } from 'vscode';
46
50
  import { TreeItem } from 'vscode';
47
51
  import { TreeView } from 'vscode';
48
52
  import { TreeViewOptions } from 'vscode';
53
+ import { UnwrapNestedRefs } from '@reactive-vscode/reactivity';
49
54
  import { Uri } from 'vscode';
50
55
  import { ViewBadge } from 'vscode';
51
56
  import { ViewColumn } from 'vscode';
@@ -61,7 +66,7 @@ export declare interface Commands extends Record<string, (...args: any[]) => any
61
66
  'vscode.open': (uri: Uri) => void;
62
67
  }
63
68
 
64
- export declare type ConfigObject<C extends object> = ShallowReactive<C & {
69
+ export declare type ConfigObject<C extends object> = UnwrapNestedRefs<C> & {
65
70
  /**
66
71
  * Write the configuration value to the workspace.
67
72
  *
@@ -72,7 +77,7 @@ export declare type ConfigObject<C extends object> = ShallowReactive<C & {
72
77
  * Set the value without updating the workspace.
73
78
  */
74
79
  $set: (key: keyof C, value: C[keyof C]) => void;
75
- }>;
80
+ };
76
81
 
77
82
  export declare interface ConfigRef<T> extends WritableComputedRef<T> {
78
83
  /**
@@ -222,6 +227,80 @@ export declare type ParseConfigTypeOptions<C extends ConfigTypeOptions> = {
222
227
  -readonly [K in keyof C]: ParseConfigType<C[K]>;
223
228
  };
224
229
 
230
+ export declare interface QuickPickOptions<T extends QuickPickItem> {
231
+ /**
232
+ * Items to pick from. This can be read and updated by the extension.
233
+ */
234
+ items?: MaybeRefOrGetter<readonly T[]>;
235
+ /**
236
+ * Buttons for actions in the UI.
237
+ */
238
+ buttons?: MaybeRefOrGetter<readonly QuickInputButton[]>;
239
+ /**
240
+ * An optional title.
241
+ */
242
+ title?: MaybeRefOrGetter<string | undefined>;
243
+ /**
244
+ * An optional current step count.
245
+ */
246
+ step?: MaybeRefOrGetter<number | undefined>;
247
+ /**
248
+ * An optional total step count.
249
+ */
250
+ totalSteps?: MaybeRefOrGetter<number | undefined>;
251
+ /**
252
+ * If the UI should allow for user input. Defaults to true.
253
+ *
254
+ * Change this to false, e.g., while validating user input or
255
+ * loading data for the next step in user input.
256
+ */
257
+ enabled?: MaybeRefOrGetter<boolean>;
258
+ /**
259
+ * If the UI should show a progress indicator. Defaults to false.
260
+ *
261
+ * Change this to true, e.g., while loading more data or validating
262
+ * user input.
263
+ */
264
+ busy?: MaybeRefOrGetter<boolean>;
265
+ /**
266
+ * If the UI should stay open even when loosing UI focus. Defaults to false.
267
+ * This setting is ignored on iPad and is always false.
268
+ */
269
+ ignoreFocusOut?: MaybeRefOrGetter<boolean>;
270
+ /**
271
+ * Optional placeholder shown in the filter textbox when no filter has been entered.
272
+ */
273
+ placeholder?: MaybeRefOrGetter<string | undefined>;
274
+ /**
275
+ * If multiple items can be selected at the same time. Defaults to false.
276
+ */
277
+ canSelectMany?: MaybeRefOrGetter<boolean>;
278
+ /**
279
+ * If the filter text should also be matched against the description of the items. Defaults to false.
280
+ */
281
+ matchOnDescription?: MaybeRefOrGetter<boolean>;
282
+ /**
283
+ * If the filter text should also be matched against the detail of the items. Defaults to false.
284
+ */
285
+ matchOnDetail?: MaybeRefOrGetter<boolean>;
286
+ /**
287
+ * An optional flag to maintain the scroll position of the quick pick when the quick pick items are updated. Defaults to false.
288
+ */
289
+ keepScrollPosition?: MaybeRefOrGetter<boolean>;
290
+ /**
291
+ * Initial value of the filter text.
292
+ */
293
+ value?: string;
294
+ /**
295
+ * Initial active items. This can be read and updated by the extension.
296
+ */
297
+ activeItems?: readonly T[];
298
+ /**
299
+ * Initial selected items. This can be read and updated by the extension.
300
+ */
301
+ selectedItems?: readonly T[];
302
+ }
303
+
225
304
  export declare type TextEditorCommandCallback = (textEditor: TextEditor, edit: TextEditorEdit, ...args: any[]) => void;
226
305
 
227
306
  declare type ToConfigRefs<C extends object> = {
@@ -285,6 +364,7 @@ export declare const useActiveTextEditor: () => ShallowRef<TextEditor | undefine
285
364
 
286
365
  /**
287
366
  * @reactive `extensions.all`
367
+ * @category extension
288
368
  */
289
369
  export declare const useAllExtensions: () => ComputedRef<readonly Extension<any>[]>;
290
370
 
@@ -356,7 +436,7 @@ export declare function useEditorDecorations(editor: MaybeRefOrGetter<Nullable<T
356
436
  * @category utilities
357
437
  * @reactive `Event`
358
438
  */
359
- export declare function useEvent<T>(event: Event_2<T>, listeners?: ((e: T) => any)[]): Event_2<T>;
439
+ export declare function useEvent<T>(event: Event_2<T>, listeners?: ((e: T) => any)[]): (listener: (e: T) => any, thisArgs?: any, disposables?: Disposable_2[]) => void;
360
440
 
361
441
  /**
362
442
  * @category utilities
@@ -372,6 +452,17 @@ declare interface UseEventEmitterReturn<T> {
372
452
  addListener: (listener: (e: T) => any) => void;
373
453
  }
374
454
 
455
+ /**
456
+ * Get a reactive secret value from the extension's secrets.
457
+ *
458
+ * @reactive `ExtensionContext.secrets`
459
+ * @category extension
460
+ */
461
+ export declare function useExtensionSecret(key: string): Promise<Ref<string | undefined> & {
462
+ set: (newValue: string) => Promise<void>;
463
+ remove: () => Promise<void>;
464
+ }>;
465
+
375
466
  /**
376
467
  * @reactive `tasks.fetchTasks`
377
468
  */
@@ -404,17 +495,17 @@ toJSON(): any;
404
495
  */
405
496
  export declare function useFoldingRangeProvider(selector: DocumentSelector, provideFoldingRanges: MaybeRefOrGetter<FoldingRangeProvider['provideFoldingRanges']>): void;
406
497
 
498
+ export declare interface UseFSWatcher {
499
+ readonly watchers: ShallowReactive<Map<GlobPattern, FileSystemWatcher>>;
500
+ readonly onDidCreate: Event_2<Uri>;
501
+ readonly onDidChange: Event_2<Uri>;
502
+ readonly onDidDelete: Event_2<Uri>;
503
+ }
504
+
407
505
  /**
408
506
  * @reactive `workspace.createFileSystemWatcher`
409
507
  */
410
- export declare function useFsWatcher(globPattern: GlobPattern, ignoreCreateEvents?: boolean | undefined, ignoreChangeEvents?: boolean | undefined, ignoreDeleteEvents?: boolean | undefined): {
411
- onDidCreate: Event_2<Uri>;
412
- onDidChange: Event_2<Uri>;
413
- onDidDelete: Event_2<Uri>;
414
- ignoreCreateEvents: boolean;
415
- ignoreChangeEvents: boolean;
416
- ignoreDeleteEvents: boolean;
417
- };
508
+ export declare function useFsWatcher(globPattern: MaybeRefOrGetter<GlobPattern | GlobPattern[]>, ignoreCreateEvents?: MaybeNullableRefOrGetter<boolean>, ignoreChangeEvents?: MaybeNullableRefOrGetter<boolean>, ignoreDeleteEvents?: MaybeNullableRefOrGetter<boolean>): UseFSWatcher;
418
509
 
419
510
  /**
420
511
  * Determines if the current color theme is dark. See `vscode::ColorTheme.kind`.
@@ -497,6 +588,40 @@ export declare const useOpenedTerminals: () => ShallowRef<readonly Terminal[]>;
497
588
  */
498
589
  export declare function useOutputChannel(name: string, languageId?: string): OutputChannel;
499
590
 
591
+ /**
592
+ * Creates a customizable quick pick UI.
593
+ *
594
+ * @reactive `window.createQuickPick`
595
+ */
596
+ export declare function useQuickPick<T extends QuickPickItem>(options?: QuickPickOptions<T>): {
597
+ onDidChangeActive: (listener: (e: readonly T[]) => any, thisArgs?: any, disposables?: Disposable_2[] | undefined) => void;
598
+ onDidChangeSelection: (listener: (e: readonly T[]) => any, thisArgs?: any, disposables?: Disposable_2[] | undefined) => void;
599
+ onDidAccept: (listener: (e: void) => any, thisArgs?: any, disposables?: Disposable_2[] | undefined) => void;
600
+ onDidHide: (listener: (e: void) => any, thisArgs?: any, disposables?: Disposable_2[] | undefined) => void;
601
+ onDidTriggerButton: (listener: (e: QuickInputButton) => any, thisArgs?: any, disposables?: Disposable_2[] | undefined) => void;
602
+ onDidChangeValue: (listener: (e: string) => any, thisArgs?: any, disposables?: Disposable_2[] | undefined) => void;
603
+ value: ShallowRef<string>;
604
+ activeItems: ShallowRef<readonly T[]>;
605
+ selectedItems: ShallowRef<readonly T[]>;
606
+ placeholder: string | undefined;
607
+ buttons: readonly QuickInputButton[];
608
+ onDidTriggerItemButton: Event_2<QuickPickItemButtonEvent<T>>;
609
+ items: readonly T[];
610
+ canSelectMany: boolean;
611
+ matchOnDescription: boolean;
612
+ matchOnDetail: boolean;
613
+ keepScrollPosition?: boolean | undefined;
614
+ title: string | undefined;
615
+ step: number | undefined;
616
+ totalSteps: number | undefined;
617
+ enabled: boolean;
618
+ busy: boolean;
619
+ ignoreFocusOut: boolean;
620
+ show(): void;
621
+ hide(): void;
622
+ dispose(): void;
623
+ };
624
+
500
625
  /**
501
626
  * @reactive `window.createStatusBarItem`
502
627
  */