reactive-vscode 0.1.0 → 0.2.0-beta.2

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.d.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  /// <reference types="vscode" />
2
2
 
3
- import { Awaited as Awaited_2 } from '@vue/shared';
4
3
  import { ColorTheme } from 'vscode';
5
4
  import { CommentController } from 'vscode';
6
- import { ComputedRef } from '@vue/reactivity';
5
+ import { ComputedRef } from '@reactive-vscode/reactivity';
6
+ import { ComputedRef as ComputedRef_2 } from '@vue/reactivity';
7
7
  import { ConfigurationScope } from 'vscode';
8
8
  import { ConfigurationTarget } from 'vscode';
9
- import { DebuggerOptions } from '@vue/reactivity';
10
9
  import { DebugSession } from 'vscode';
11
10
  import { DecorationOptions } from 'vscode';
12
11
  import { DecorationRenderOptions } from 'vscode';
@@ -14,22 +13,24 @@ import { Disposable as Disposable_2 } from 'vscode';
14
13
  import { DocumentSelector } from 'vscode';
15
14
  import { EffectScope } from '@vue/reactivity';
16
15
  import { Event as Event_2 } from 'vscode';
16
+ import { EventEmitter } from 'vscode';
17
17
  import { Extension } from 'vscode';
18
18
  import { ExtensionContext } from 'vscode';
19
19
  import { ExtensionTerminalOptions } from 'vscode';
20
20
  import { FoldingRangeProvider } from 'vscode';
21
21
  import { GlobPattern } from 'vscode';
22
22
  import { LogLevel } from 'vscode';
23
- import { MaybeRef } from '@vue/reactivity';
24
- import { MaybeRefOrGetter } from '@vue/reactivity';
23
+ import { MaybeRef } from '@reactive-vscode/reactivity';
24
+ import { MaybeRefOrGetter } from '@reactive-vscode/reactivity';
25
25
  import { NotebookEditor } from 'vscode';
26
26
  import { NotebookRange } from 'vscode';
27
27
  import { OutputChannel } from 'vscode';
28
28
  import { Range } from 'vscode';
29
- import { Ref } from '@vue/reactivity';
29
+ import { Ref } from '@reactive-vscode/reactivity';
30
30
  import { Selection } from 'vscode';
31
31
  import { ShallowReactive } from '@vue/reactivity';
32
32
  import { ShallowRef } from '@vue/reactivity';
33
+ import { ShallowRef as ShallowRef_2 } from '@reactive-vscode/reactivity';
33
34
  import { StatusBarAlignment } from 'vscode';
34
35
  import { StatusBarItem } from 'vscode';
35
36
  import { Task } from 'vscode';
@@ -44,15 +45,18 @@ import { TextEditorDecorationType } from 'vscode';
44
45
  import { TextEditorEdit } from 'vscode';
45
46
  import { TextEditorSelectionChangeKind } from 'vscode';
46
47
  import { TreeDataProvider } from 'vscode';
48
+ import { TreeItem } from 'vscode';
47
49
  import { TreeView } from 'vscode';
48
50
  import { TreeViewOptions } from 'vscode';
49
51
  import { Uri } from 'vscode';
50
52
  import { ViewBadge } from 'vscode';
51
53
  import { ViewColumn } from 'vscode';
54
+ import { WatchSource } from '@reactive-vscode/reactivity';
52
55
  import { WebviewOptions } from 'vscode';
53
56
  import { WebviewView } from 'vscode';
54
57
  import { WorkspaceFolder } from 'vscode';
55
58
  import { WritableComputedRef } from '@vue/reactivity';
59
+ import { WritableComputedRef as WritableComputedRef_2 } from '@reactive-vscode/reactivity';
56
60
 
57
61
  /* Excluded from this release type: activateCbs */
58
62
 
@@ -60,7 +64,7 @@ export declare interface Commands extends Record<string, (...args: any[]) => any
60
64
  'vscode.open': (uri: Uri) => void;
61
65
  }
62
66
 
63
- export declare interface ConfigRef<T> extends ShallowRef<T> {
67
+ export declare interface ConfigRef<T> extends ShallowRef_2<T> {
64
68
  update: (value: T, configurationTarget?: ConfigurationTarget | boolean | null, overrideInLanguage?: boolean) => Promise<void>;
65
69
  }
66
70
 
@@ -92,8 +96,6 @@ export declare function createSingletonComposable<T>(fn: () => T): () => T;
92
96
 
93
97
  /* Excluded from this release type: deactivateCbs */
94
98
 
95
- declare function defaultGetPrefix(type: string): string;
96
-
97
99
  /**
98
100
  * Define configurations of an extension. See `vscode::workspace.getConfiguration`.
99
101
  *
@@ -111,6 +113,40 @@ export declare function defineExtension(setup: () => void): {
111
113
  deactivate: () => void;
112
114
  };
113
115
 
116
+ /**
117
+ * Define a logger which is usable before activation.
118
+ *
119
+ * @category view
120
+ */
121
+ export declare function defineLogger(name: string, options?: UseLoggerOptions): {
122
+ logger: ShallowRef< {
123
+ outputChannel: OutputChannel;
124
+ createLoggerFunc: (type: string) => (...message: any[]) => void;
125
+ info: (...message: any[]) => void;
126
+ warn: (...message: any[]) => void;
127
+ error: (...message: any[]) => void;
128
+ append: (value: string) => void;
129
+ appendLine: (value: string) => void;
130
+ replace: (value: string) => void;
131
+ clear: () => void;
132
+ show: {
133
+ (preserveFocus?: boolean | undefined): void;
134
+ (column?: ViewColumn | undefined, preserveFocus?: boolean | undefined): void;
135
+ };
136
+ hide: () => void;
137
+ } | null>;
138
+ outputChannel: ComputedRef_2<OutputChannel | undefined>;
139
+ info: (...args: any[]) => void | null;
140
+ warn: (...args: any[]) => void | null;
141
+ error: (...args: any[]) => void | null;
142
+ append: (value: string) => void | null;
143
+ appendLine: (value: string) => void | null;
144
+ replace: (value: string) => void | null;
145
+ clear: () => void | null;
146
+ show: (column?: ViewColumn | undefined, preserveFocus?: boolean | undefined) => void | null;
147
+ hide: () => void | null;
148
+ };
149
+
114
150
  /**
115
151
  * Execute a command, with type checking. See `vscode::commands.executeCommand`.
116
152
  *
@@ -122,30 +158,10 @@ export declare const extensionContext: ShallowRef<ExtensionContext | null>;
122
158
 
123
159
  /* Excluded from this release type: extensionScope */
124
160
 
125
- declare type MapSources<T, Immediate> = {
126
- [K in keyof T]: T[K] extends WatchSource<infer V>
127
- ? Immediate extends true
128
- ? V | undefined
129
- : V
130
- : T[K] extends object
131
- ? Immediate extends true
132
- ? T[K] | undefined
133
- : T[K]
134
- : never
135
- }
161
+ export declare function getDefaultLoggerPrefix(type: string): string;
136
162
 
137
163
  export declare type MaybeNullableRefOrGetter<T> = T | Ref<Nullable<T>> | (() => Nullable<T>);
138
164
 
139
- declare type MultiWatchSources = (WatchSource<unknown> | object)[]
140
-
141
- export declare function nextTick<T = void, R = void>(
142
- this: T,
143
- fn?: (this: T) => R,
144
- ): Promise<Awaited_2<R>> {
145
- const p = currentFlushPromise || resolvedPromise
146
- return fn ? p.then(this ? fn.bind(this) : fn) : p
147
- }
148
-
149
165
  export declare type Nullable<T> = T | null | undefined;
150
166
 
151
167
  /**
@@ -157,8 +173,6 @@ export declare function onActivate(fn: OnActivateCb): void;
157
173
 
158
174
  declare type OnActivateCb = (context: ExtensionContext) => void;
159
175
 
160
- declare type OnCleanup = (cleanupFn: () => void) => void
161
-
162
176
  /**
163
177
  * Registers a callback to be called when the extension is deactivated.
164
178
  *
@@ -178,6 +192,7 @@ export declare type TextEditorCommandCallback = (textEditor: TextEditor, edit: T
178
192
 
179
193
  export declare interface TreeViewNode {
180
194
  readonly children?: this[];
195
+ readonly treeItem: TreeItem | Thenable<TreeItem>;
181
196
  }
182
197
 
183
198
  /**
@@ -203,7 +218,7 @@ export declare const useActiveColorTheme: () => ShallowRef<ColorTheme>;
203
218
  /**
204
219
  * @reactive `debug.activeDebugSession`
205
220
  */
206
- export declare const useActiveDebugSession: () => ComputedRef<DebugSession | undefined>;
221
+ export declare const useActiveDebugSession: () => ComputedRef_2<DebugSession | undefined>;
207
222
 
208
223
  /**
209
224
  * Reactively set decorations on the active editor. See `vscode::window.activeTextEditor`.
@@ -233,7 +248,7 @@ export declare const useActiveTextEditor: () => ShallowRef<TextEditor | undefine
233
248
  /**
234
249
  * @reactive `extensions.all`
235
250
  */
236
- export declare const useAllExtensions: () => ComputedRef<readonly Extension<any>[]>;
251
+ export declare const useAllExtensions: () => ComputedRef_2<readonly Extension<any>[]>;
237
252
 
238
253
  /**
239
254
  * Register a command. See `vscode::commands.registerCommand`.
@@ -277,7 +292,7 @@ declare interface UseControlledTerminalReturn {
277
292
  /**
278
293
  * @reactive `env.shell`
279
294
  */
280
- export declare const useDefaultShell: () => ComputedRef<string>;
295
+ export declare const useDefaultShell: () => ComputedRef_2<string>;
281
296
 
282
297
  /**
283
298
  * Dispose the disposable when the current scope is disposed. See `vscode::Disposable`.
@@ -309,16 +324,20 @@ export declare function useEvent<T>(event: Event_2<T>, listeners?: ((e: T) => an
309
324
  * @category utilities
310
325
  * @reactive `EventEmitter`
311
326
  */
312
- export declare function useEventEmitter<T>(listeners?: ((e: T) => any)[]): {
327
+ export declare function useEventEmitter<T>(eventEmitter?: EventEmitter<T>, listeners?: ((e: T) => any)[]): UseEventEmitterReturn<T>;
328
+
329
+ export declare function useEventEmitter<T>(listeners?: ((e: T) => any)[]): UseEventEmitterReturn<T>;
330
+
331
+ declare interface UseEventEmitterReturn<T> {
313
332
  event: Event_2<T>;
314
333
  fire: (data: T) => void;
315
- addListener: Event_2<T>;
316
- };
334
+ addListener: (listener: (e: T) => any) => void;
335
+ }
317
336
 
318
337
  /**
319
338
  * @reactive `tasks.fetchTasks`
320
339
  */
321
- export declare function useFetchTasks(filter?: MaybeRefOrGetter<TaskFilter | undefined>): ComputedRef<Thenable<Task[]>>;
340
+ export declare function useFetchTasks(filter?: MaybeRefOrGetter<TaskFilter | undefined>): ComputedRef_2<Thenable<Task[]>>;
322
341
 
323
342
  /**
324
343
  * @reactive `Uri.file`
@@ -364,12 +383,12 @@ export declare function useFsWatcher(globPattern: GlobPattern, ignoreCreateEvent
364
383
  *
365
384
  * @category window
366
385
  */
367
- export declare const useIsDarkTheme: () => ComputedRef<boolean>;
386
+ export declare const useIsDarkTheme: () => ComputedRef_2<boolean>;
368
387
 
369
388
  /**
370
389
  * @reactive `env.isTelemetryEnabled`
371
390
  */
372
- export declare const useIsTelemetryEnabled: () => ComputedRef<boolean>;
391
+ export declare const useIsTelemetryEnabled: () => ComputedRef_2<boolean>;
373
392
 
374
393
  /**
375
394
  * @reactive `l10n.t`
@@ -383,7 +402,7 @@ export declare function useL10nText(message: MaybeRefOrGetter<string>, args: Rec
383
402
  *
384
403
  * @category view
385
404
  */
386
- export declare function useLogger(name: string, getPrefix?: typeof defaultGetPrefix): {
405
+ export declare function useLogger(name: string, options?: UseLoggerOptions): {
387
406
  outputChannel: OutputChannel;
388
407
  createLoggerFunc: (type: string) => (...message: any[]) => void;
389
408
  info: (...message: any[]) => void;
@@ -400,10 +419,15 @@ export declare function useLogger(name: string, getPrefix?: typeof defaultGetPre
400
419
  hide: () => void;
401
420
  };
402
421
 
422
+ export declare interface UseLoggerOptions {
423
+ outputChannel?: OutputChannel;
424
+ getPrefix?: ((type: string) => string) | null;
425
+ }
426
+
403
427
  /**
404
428
  * @reactive `env.logLevel`
405
429
  */
406
- export declare const useLogLevel: () => ComputedRef<LogLevel>;
430
+ export declare const useLogLevel: () => ComputedRef_2<LogLevel>;
407
431
 
408
432
  /**
409
433
  * @reactive `NotebookEditor.selection`
@@ -421,7 +445,7 @@ export declare function useNotebookEditorSelections(notebookEditor: MaybeNullabl
421
445
  * @reactive `NotebookEditor.visibleRanges`
422
446
  * @category editor
423
447
  */
424
- export declare function useNotebookEditorVisibleRanges(notebookEditor: MaybeNullableRefOrGetter<NotebookEditor>): ComputedRef<readonly NotebookRange[]>;
448
+ export declare function useNotebookEditorVisibleRanges(notebookEditor: MaybeNullableRefOrGetter<NotebookEditor>): ComputedRef_2<readonly NotebookRange[]>;
425
449
 
426
450
  /**
427
451
  * @reactive `window.terminals`
@@ -456,7 +480,7 @@ export declare interface UseStatusBarItemOptions {
456
480
  /**
457
481
  * @reactive `tasks.taskExecutions`
458
482
  */
459
- export declare const useTaskExecutions: () => ComputedRef<readonly TaskExecution[]>;
483
+ export declare const useTaskExecutions: () => ComputedRef_2<readonly TaskExecution[]>;
460
484
 
461
485
  /**
462
486
  * @category terminal
@@ -477,7 +501,7 @@ declare interface UseTerminalReturn extends Omit<Terminal, 'state' | 'dispose'>
477
501
  * @reactive `Terminal.state`
478
502
  * @category terminal
479
503
  */
480
- export declare function useTerminalState(terminal: MaybeNullableRefOrGetter<Terminal>): ComputedRef<TerminalState | undefined>;
504
+ export declare function useTerminalState(terminal: MaybeNullableRefOrGetter<Terminal>): ComputedRef_2<TerminalState | undefined>;
481
505
 
482
506
  /**
483
507
  * Register a text editor command. See `vscode::commands.registerTextEditorCommand`.
@@ -509,25 +533,29 @@ export declare function useTextEditorSelections(textEditor: MaybeNullableRefOrGe
509
533
  * @reactive `TextEditor.viewColumn`
510
534
  * @category editor
511
535
  */
512
- export declare function useTextEditorViewColumn(textEditor: MaybeNullableRefOrGetter<TextEditor>): ComputedRef<ViewColumn | undefined>;
536
+ export declare function useTextEditorViewColumn(textEditor: MaybeNullableRefOrGetter<TextEditor>): ComputedRef_2<ViewColumn | undefined>;
513
537
 
514
538
  /**
515
539
  * @reactive `TextEditor.visibleRanges`
516
540
  * @category editor
517
541
  */
518
- export declare function useTextEditorVisibleRanges(textEditor: MaybeNullableRefOrGetter<TextEditor>): ComputedRef<readonly Range[]>;
542
+ export declare function useTextEditorVisibleRanges(textEditor: MaybeNullableRefOrGetter<TextEditor>): ComputedRef_2<readonly Range[]>;
519
543
 
520
544
  /**
521
545
  * Register a tree view. See `vscode::window.createTreeView`.
522
546
  *
523
547
  * @category view
524
548
  */
525
- export declare const useTreeView: <T extends TreeViewNode>(viewId: string, treeData: MaybeRefOrGetter<T[]>, options: UseTreeViewOptions<T>) => TreeView<T>;
549
+ export declare const useTreeView: <T extends TreeViewNode>(viewId: string, treeData: MaybeRefOrGetter<T[]>, options?: UseTreeViewOptions<T> | undefined) => TreeView<T>;
526
550
 
527
- export declare type UseTreeViewOptions<T> = (Omit<TreeViewOptions<T>, 'treeDataProvider'> & Pick<TreeDataProvider<T>, 'getTreeItem' | 'resolveTreeItem'> & {
551
+ export declare type UseTreeViewOptions<T> = Omit<TreeViewOptions<T>, 'treeDataProvider'> & Pick<TreeDataProvider<T>, 'resolveTreeItem'> & {
528
552
  title?: MaybeRefOrGetter<string | undefined>;
529
553
  badge?: MaybeRefOrGetter<ViewBadge | undefined>;
530
- }) | TreeDataProvider<T>['getTreeItem'];
554
+ /**
555
+ * Additional watch source to trigger a change event. Useful when `treeItem` is a promise.
556
+ */
557
+ watchSource?: WatchSource<any>;
558
+ };
531
559
 
532
560
  /**
533
561
  * @reactive `Uri`
@@ -586,7 +614,7 @@ export declare const useVisibleTextEditors: () => ShallowRef<readonly TextEditor
586
614
 
587
615
  export declare function useVscodeContext<T>(name: string, value: ComputedRef<T> | (() => T), shouldUpdate?: MaybeRefOrGetter<boolean>): ComputedRef<T>;
588
616
 
589
- export declare function useVscodeContext<T>(name: string, value: WritableComputedRef<T>, shouldUpdate?: MaybeRefOrGetter<boolean>): WritableComputedRef<T>;
617
+ export declare function useVscodeContext<T>(name: string, value: WritableComputedRef_2<T>, shouldUpdate?: MaybeRefOrGetter<boolean>): WritableComputedRef_2<T>;
590
618
 
591
619
  export declare function useVscodeContext<T>(name: string, value: MaybeRef<T>, shouldUpdate?: MaybeRefOrGetter<boolean>): Ref<T>;
592
620
 
@@ -595,33 +623,25 @@ export declare function useVscodeContext<T>(name: string, value: MaybeRef<T>, sh
595
623
  *
596
624
  * @category view
597
625
  */
598
- export declare const useWebviewView: (viewId: string, html: MaybeRefOrGetter<string>, options?: ({
599
- readonly webviewOptions?: {
600
- readonly retainContextWhenHidden?: boolean | undefined;
601
- } | undefined;
602
- } & {
603
- onDidReceiveMessage?: ((message: any) => void) | undefined;
604
- webviewOptions?: MaybeRefOrGetter<WebviewOptions> | undefined;
605
- title?: MaybeRefOrGetter<string | undefined>;
606
- badge?: MaybeRefOrGetter<ViewBadge | undefined>;
607
- }) | undefined) => {
626
+ export declare const useWebviewView: (viewId: string, html: MaybeRefOrGetter<string>, options?: WebviewRegisterOptions | undefined) => {
608
627
  view: ShallowRef<WebviewView | undefined>;
609
628
  context: ShallowRef<unknown>;
610
629
  postMessage: (message: any) => Thenable<boolean> | undefined;
630
+ forceRefresh: () => void;
611
631
  };
612
632
 
613
633
  /**
614
634
  * @reactive `window.state`
615
635
  */
616
636
  export declare const useWindowState: () => {
617
- focused: ComputedRef<boolean>;
618
- active: ComputedRef<boolean>;
637
+ focused: ComputedRef_2<boolean>;
638
+ active: ComputedRef_2<boolean>;
619
639
  };
620
640
 
621
641
  /**
622
642
  * @reactive `workspace.workspaceFolders`
623
643
  */
624
- export declare const useWorkspaceFolders: () => ComputedRef<readonly WorkspaceFolder[] | undefined>;
644
+ export declare const useWorkspaceFolders: () => ComputedRef_2<readonly WorkspaceFolder[] | undefined>;
625
645
 
626
646
  declare type ViewWithBadge = Pick<TreeView<unknown> | WebviewView, 'badge'>;
627
647
 
@@ -629,95 +649,15 @@ declare type ViewWithTitle = Pick<TreeView<unknown> | WebviewView, 'title'>;
629
649
 
630
650
  declare type ViewWithVisibility = Pick<TreeView<unknown> | WebviewView, 'visible' | 'onDidChangeVisibility'>;
631
651
 
632
- export declare function watch<T, Immediate extends Readonly<boolean> = false>(
633
- source: WatchSource<T>,
634
- cb: WatchCallback<T, Immediate extends true ? T | undefined : T>,
635
- options?: WatchOptions<Immediate>,
636
- ): WatchStopHandle
637
-
638
- export declare function watch<
639
- T extends MultiWatchSources,
640
- Immediate extends Readonly<boolean> = false,
641
- >(
642
- sources: [...T],
643
- cb: WatchCallback<MapSources<T, false>, MapSources<T, Immediate>>,
644
- options?: WatchOptions<Immediate>,
645
- ): WatchStopHandle
646
-
647
- export declare function watch<
648
- T extends Readonly<MultiWatchSources>,
649
- Immediate extends Readonly<boolean> = false,
650
- >(
651
- source: T,
652
- cb: WatchCallback<MapSources<T, false>, MapSources<T, Immediate>>,
653
- options?: WatchOptions<Immediate>,
654
- ): WatchStopHandle
655
-
656
- export declare function watch<
657
- T extends object,
658
- Immediate extends Readonly<boolean> = false,
659
- >(
660
- source: T,
661
- cb: WatchCallback<T, Immediate extends true ? T | undefined : T>,
662
- options?: WatchOptions<Immediate>,
663
- ): WatchStopHandle
664
-
665
- export declare function watch<T = any, Immediate extends Readonly<boolean> = false>(
666
- source: T | WatchSource<T>,
667
- cb: any,
668
- options?: WatchOptions<Immediate>,
669
- ): WatchStopHandle {
670
- if (__DEV__ && !isFunction(cb)) {
671
- warn(
672
- `\`watch(fn, options?)\` signature has been moved to a separate API. ` +
673
- `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
674
- `supports \`watch(source, cb, options?) signature.`,
675
- )
676
- }
677
- return doWatch(source as any, cb, options)
678
- }
679
-
680
- export declare type WatchCallback<V = any, OV = any> = (
681
- value: V,
682
- oldValue: OV,
683
- onCleanup: OnCleanup,
684
- ) => any
685
-
686
- export declare type WatchEffect = (onCleanup: OnCleanup) => void
687
-
688
- export declare function watchEffect(
689
- effect: WatchEffect,
690
- options?: WatchOptionsBase,
691
- ): WatchStopHandle {
692
- return doWatch(effect, null, options)
693
- }
694
-
695
- export declare interface WatchOptions<Immediate = boolean> extends WatchOptionsBase {
696
- immediate?: Immediate
697
- deep?: boolean
698
- once?: boolean
699
- }
700
-
701
- export declare interface WatchOptionsBase extends DebuggerOptions {
702
- flush?: 'pre' | 'post' | 'sync'
703
- }
704
-
705
- export declare type WatchSource<T = any> = Ref<T> | ComputedRef<T> | (() => T)
706
-
707
- export declare type WatchStopHandle = () => void
708
-
709
- export declare function watchSyncEffect(
710
- effect: WatchEffect,
711
- options?: DebuggerOptions,
712
- ) {
713
- return doWatch(
714
- effect,
715
- null,
716
- __DEV__ ? extend({}, options as any, { flush: 'sync' }) : { flush: 'sync' },
717
- )
652
+ declare interface WebviewRegisterOptions {
653
+ retainContextWhenHidden?: boolean;
654
+ onDidReceiveMessage?: (message: any) => void;
655
+ webviewOptions?: MaybeRefOrGetter<WebviewOptions>;
656
+ title?: MaybeRefOrGetter<string | undefined>;
657
+ badge?: MaybeRefOrGetter<ViewBadge | undefined>;
718
658
  }
719
659
 
720
660
 
721
- export * from "@vue/reactivity";
661
+ export * from "@reactive-vscode/reactivity";
722
662
 
723
663
  export { }