reactive-vscode
Advanced tools
Comparing version 0.0.1-beta.5 to 0.0.1-beta.6
@@ -1,3 +0,666 @@ | ||
export * from '@reactive-vscode/reactivity'; | ||
export * from './composables'; | ||
export * from './utils'; | ||
/// <reference types="vscode" /> | ||
import { Awaited as Awaited_2 } from '@vue/shared'; | ||
import { ColorTheme } from 'vscode'; | ||
import { CommentController } from 'vscode'; | ||
import { ComputedRef } from '@vue/reactivity'; | ||
import { ConfigurationScope } from 'vscode'; | ||
import { ConfigurationTarget } from 'vscode'; | ||
import { DebuggerOptions } from '@vue/reactivity'; | ||
import { DebugSession } from 'vscode'; | ||
import { DecorationOptions } from 'vscode'; | ||
import { DecorationRenderOptions } from 'vscode'; | ||
import { Disposable as Disposable_2 } from 'vscode'; | ||
import { DocumentSelector } from 'vscode'; | ||
import { EffectScope } from '@vue/reactivity'; | ||
import { Event as Event_2 } from 'vscode'; | ||
import { Extension } from 'vscode'; | ||
import { ExtensionContext } from 'vscode'; | ||
import { FoldingRangeProvider } from 'vscode'; | ||
import { LogLevel } from 'vscode'; | ||
import { MaybeRefOrGetter } from '@vue/reactivity'; | ||
import { NotebookEditor } from 'vscode'; | ||
import { NotebookRange } from 'vscode'; | ||
import { OutputChannel } from 'vscode'; | ||
import { Range } from 'vscode'; | ||
import { Ref } from '@vue/reactivity'; | ||
import { Selection } from 'vscode'; | ||
import { ShallowReactive } from '@vue/reactivity'; | ||
import { ShallowRef } from '@vue/reactivity'; | ||
import { StatusBarAlignment } from 'vscode'; | ||
import { StatusBarItem } from 'vscode'; | ||
import { Task } from 'vscode'; | ||
import { TaskExecution } from 'vscode'; | ||
import { TaskFilter } from 'vscode'; | ||
import { Terminal } from 'vscode'; | ||
import { TerminalState } from 'vscode'; | ||
import { TextDocument } from 'vscode'; | ||
import { TextEditor } from 'vscode'; | ||
import { TextEditorDecorationType } from 'vscode'; | ||
import { TextEditorEdit } from 'vscode'; | ||
import { TextEditorSelectionChangeKind } from 'vscode'; | ||
import { TreeDataProvider } from 'vscode'; | ||
import { TreeView } from 'vscode'; | ||
import { TreeViewOptions } from 'vscode'; | ||
import { Uri } from 'vscode'; | ||
import { ViewBadge } from 'vscode'; | ||
import { ViewColumn } from 'vscode'; | ||
import { WebviewOptions } from 'vscode'; | ||
import { WebviewView } from 'vscode'; | ||
import { WorkspaceFolder } from 'vscode'; | ||
import { WritableComputedRef } from '@vue/reactivity'; | ||
/* Excluded from this release type: activateCbs */ | ||
export declare interface Commands extends Record<string, (...args: any[]) => any> { | ||
'vscode.open': (uri: Uri) => void; | ||
} | ||
export declare interface ConfigRef<T> extends ShallowRef<T> { | ||
update: (value: T, configurationTarget?: ConfigurationTarget | boolean | null, overrideInLanguage?: boolean) => Promise<void>; | ||
} | ||
export declare interface ConfigType<T> extends ObjectConstructor { | ||
[ConfigTypeSymbol]: T; | ||
} | ||
declare type ConfigTypeOptions = Record<string, ConfigTypeRaw<any>>; | ||
declare type ConfigTypeRaw<T> = ConfigTypeSingle<T> | ConfigTypeSingle<T>[]; | ||
declare type ConfigTypeSingle<T> = string | typeof String | typeof Number | typeof Boolean | typeof Array | typeof Object | null | ConfigType<T>; | ||
declare const ConfigTypeSymbol: unique symbol; | ||
/** | ||
* Creates a composable that caches the result of a function based on a key. | ||
* | ||
* @category utilities | ||
*/ | ||
export declare function createKeyedComposable<P extends unknown[], R, K>(fn: (...args: P) => R, key: NoInfer<(...args: P) => K>): (...args: P) => R; | ||
/** | ||
* Creates a composable that should only be called once. | ||
* | ||
* @category utilities | ||
*/ | ||
export declare function createSingletonComposable<T>(fn: () => T): () => T; | ||
/* Excluded from this release type: deactivateCbs */ | ||
declare function defaultGetPrefix(type: string): string; | ||
/** | ||
* Define configurations of an extension. See `vscode::workspace.getConfiguration`. | ||
* | ||
* @category lifecycle | ||
*/ | ||
export declare function defineConfigs<const C extends ConfigTypeOptions>(section: string, configs: C, scope?: ConfigurationScope | null | undefined): ParseConfigTypeOptions<C>; | ||
/** | ||
* Define a new extension. | ||
* | ||
* @category lifecycle | ||
*/ | ||
export declare function defineExtension(setup: () => void): { | ||
activate: (extCtx: ExtensionContext) => void; | ||
deactivate: () => void; | ||
}; | ||
/** | ||
* Execute a command, with type checking. See `vscode::commands.executeCommand`. | ||
* | ||
* @category commands | ||
*/ | ||
export declare function executeCommand<K extends Extract<keyof Commands, string>>(command: K, ...args: Parameters<Commands[K]>): Thenable<unknown>; | ||
export declare const extensionContext: ShallowRef<ExtensionContext | null>; | ||
/* Excluded from this release type: extensionScope */ | ||
declare type MapSources<T, Immediate> = { | ||
[K in keyof T]: T[K] extends WatchSource<infer V> | ||
? Immediate extends true | ||
? V | undefined | ||
: V | ||
: T[K] extends object | ||
? Immediate extends true | ||
? T[K] | undefined | ||
: T[K] | ||
: never | ||
} | ||
export declare type MaybeNullableRefOrGetter<T> = T | Ref<Nullable<T>> | (() => Nullable<T>); | ||
declare type MultiWatchSources = (WatchSource<unknown> | object)[] | ||
export declare function nextTick<T = void, R = void>( | ||
this: T, | ||
fn?: (this: T) => R, | ||
): Promise<Awaited_2<R>> { | ||
const p = currentFlushPromise || resolvedPromise | ||
return fn ? p.then(this ? fn.bind(this) : fn) : p | ||
} | ||
export declare type Nullable<T> = T | null | undefined; | ||
/** | ||
* Registers a callback to be called after the extension has been activated. | ||
* | ||
* @category lifecycle | ||
*/ | ||
export declare function onActivate(fn: OnActivateCb): void; | ||
declare type OnActivateCb = (context: ExtensionContext) => void; | ||
declare type OnCleanup = (cleanupFn: () => void) => void | ||
/** | ||
* Registers a callback to be called when the extension is deactivated. | ||
* | ||
* @category lifecycle | ||
*/ | ||
export declare function onDeactivate(fn: OnDeactivateCb): void; | ||
declare type OnDeactivateCb = () => void; | ||
declare type ParseConfigType<C extends ConfigTypeRaw<any>> = C extends string ? (C extends 'string' ? string : C extends 'number' ? number : C extends 'boolean' ? boolean : C extends 'null' ? null : C extends 'integer' ? number : C extends 'array' ? any[] : C extends 'object' ? Record<string | number, any> : never) : C extends (infer C1)[] ? (C1 extends ConfigTypeSingle<any> ? ParseConfigType<C1> : never) : C extends ConfigType<infer T> ? T : (C extends typeof String ? string : C extends typeof Number ? number : C extends typeof Boolean ? boolean : C extends typeof Array ? any[] : C extends typeof Object ? Record<string | number, any> : C extends null ? null : never); | ||
declare type ParseConfigTypeOptions<C extends ConfigTypeOptions> = { | ||
[K in keyof C]: ConfigRef<ParseConfigType<C[K]>>; | ||
}; | ||
export declare type TextEditorCommandCallback = (textEditor: TextEditor, edit: TextEditorEdit, ...args: any[]) => void; | ||
export declare interface TreeViewNode { | ||
readonly children?: this[]; | ||
} | ||
/** | ||
* The safe version of `vue::onScopeDispose(https://vuejs.org/api/reactivity-advanced.html#onscopedispose)`. | ||
* | ||
* @category lifecycle | ||
*/ | ||
export declare function tryOnScopeDispose(fn: () => void): boolean; | ||
/** | ||
* @category utilities | ||
* @reactive `ExtensionContext.asAbsolutePath` | ||
*/ | ||
export declare function useAbsolutePath(relativePath: MaybeRefOrGetter<string>, slient: true): ComputedRef<string | undefined>; | ||
export declare function useAbsolutePath(relativePath: MaybeRefOrGetter<string>, slient?: false): ComputedRef<string>; | ||
/** | ||
* @reactive `window.activeColorTheme` | ||
*/ | ||
export declare const useActiveColorTheme: () => ShallowRef<ColorTheme>; | ||
/** | ||
* @reactive `debug.activeDebugSession` | ||
*/ | ||
export declare const useActiveDebugSession: () => ComputedRef<DebugSession | undefined>; | ||
/** | ||
* Reactively set decorations on the active editor. See `vscode::window.activeTextEditor`. | ||
* | ||
* @category editor | ||
*/ | ||
export declare function useActiveEditorDecorations(decorationTypeOrOptions: TextEditorDecorationType | DecorationRenderOptions, rangesOrOptions: MaybeRefOrGetter<readonly Range[] | readonly DecorationOptions[]>): void; | ||
/** | ||
* @reactive `window.activeNotebookEditor` | ||
* @category editor | ||
*/ | ||
export declare const useActiveNotebookEditor: () => ShallowRef<NotebookEditor | undefined>; | ||
/** | ||
* @reactive `window.activeTerminal` | ||
* @category terminal | ||
*/ | ||
export declare const useActiveTerminal: () => ShallowRef<Terminal | undefined>; | ||
/** | ||
* @reactive `window.activeTextEditor` | ||
* @category editor | ||
*/ | ||
export declare const useActiveTextEditor: () => ShallowRef<TextEditor | undefined>; | ||
/** | ||
* @reactive `extensions.all` | ||
*/ | ||
export declare const useAllExtensions: () => ComputedRef<readonly Extension<any>[]>; | ||
/** | ||
* Register a command. See `vscode::commands.registerCommand`. | ||
* | ||
* @category commands | ||
*/ | ||
export declare function useCommand<K extends Extract<keyof Commands, string>>(command: K, callback: Commands[K]): void; | ||
/** | ||
* Register multiple commands. See `vscode::commands.registerCommand`. | ||
* | ||
* @category commands | ||
*/ | ||
export declare function useCommands(commands: Partial<Commands>): void; | ||
/** | ||
* @reactive `comments.createCommentController` | ||
*/ | ||
export declare function useCommentController(id: string, label: string): CommentController; | ||
/** | ||
* @reactive `env.shell` | ||
*/ | ||
export declare const useDefaultShell: () => ComputedRef<string>; | ||
/** | ||
* Dispose the disposable when the current scope is disposed. See `vscode::Disposable`. | ||
* | ||
* @category lifecycle | ||
*/ | ||
export declare function useDisposable<T extends Disposable_2>(disposable: T): T; | ||
/** | ||
* @reactive `TextDocument.getText` | ||
* @category document | ||
*/ | ||
export declare function useDocumentText(doc: MaybeRefOrGetter<TextDocument | undefined>): ShallowRef<string | undefined>; | ||
/** | ||
* Reactively set decorations on the given editor. See `vscode::TextEditor.setDecorations`. | ||
* | ||
* @category editor | ||
*/ | ||
export declare function useEditorDecorations(editor: MaybeRefOrGetter<Nullable<TextEditor>>, decorationTypeOrOptions: TextEditorDecorationType | DecorationRenderOptions, rangesOrOptions: MaybeRefOrGetter<readonly Range[] | readonly DecorationOptions[]>): void; | ||
/** | ||
* @category utilities | ||
* @reactive `Event` | ||
*/ | ||
export declare function useEvent<T>(event: Event_2<T>, listeners?: ((e: T) => any)[]): Event_2<T>; | ||
/** | ||
* @category utilities | ||
* @reactive `EventEmitter` | ||
*/ | ||
export declare function useEventEmitter<T>(listeners?: ((e: T) => any)[]): { | ||
event: Event_2<T>; | ||
fire: (data: T) => void; | ||
addListener: Event_2<T>; | ||
}; | ||
/** | ||
* @reactive `tasks.fetchTasks` | ||
*/ | ||
export declare function useFetchTasks(filter?: MaybeRefOrGetter<TaskFilter | undefined>): ComputedRef<Thenable<Task[]>>; | ||
/** | ||
* @reactive `Uri.file` | ||
* @category utilities | ||
*/ | ||
export declare function useFileUri(path: MaybeRefOrGetter<string>): ShallowReactive< { | ||
readonly scheme: string; | ||
readonly authority: string; | ||
readonly path: string; | ||
readonly query: string; | ||
readonly fragment: string; | ||
readonly fsPath: string; | ||
with(change: { | ||
scheme?: string | undefined; | ||
authority?: string | undefined; | ||
path?: string | undefined; | ||
query?: string | undefined; | ||
fragment?: string | undefined; | ||
}): Uri; | ||
toString(): string; | ||
toJSON(): any; | ||
}>; | ||
/** | ||
* @reactive `languages.registerFoldingRangeProvider` | ||
*/ | ||
export declare function useFoldingRangeProvider(selector: DocumentSelector, provideFoldingRanges: MaybeRefOrGetter<FoldingRangeProvider['provideFoldingRanges']>): void; | ||
/** | ||
* Determines if the current color theme is dark. See `vscode::ColorTheme.kind`. | ||
* | ||
* @category window | ||
*/ | ||
export declare const useIsDarkTheme: () => ComputedRef<boolean>; | ||
/** | ||
* @reactive `env.isTelemetryEnabled` | ||
*/ | ||
export declare const useIsTelemetryEnabled: () => ComputedRef<boolean>; | ||
/** | ||
* @reactive `l10n.t` | ||
*/ | ||
export declare function useL10nText(message: MaybeRefOrGetter<string>, ...args: Array<MaybeRefOrGetter<string | number | boolean>>): ComputedRef<string>; | ||
export declare function useL10nText(message: MaybeRefOrGetter<string>, args: Record<string, any>): ComputedRef<string>; | ||
/** | ||
* Creates a logger that writes to the output channel. | ||
* | ||
* @category view | ||
*/ | ||
export declare function useLogger(name: string, getPrefix?: typeof defaultGetPrefix): { | ||
outputChannel: OutputChannel; | ||
createLoggerFunc: (type: string) => (...message: any[]) => void; | ||
info: (...message: any[]) => void; | ||
warn: (...message: any[]) => void; | ||
error: (...message: any[]) => void; | ||
append: (value: string) => void; | ||
appendLine: (value: string) => void; | ||
replace: (value: string) => void; | ||
clear: () => void; | ||
show: { | ||
(preserveFocus?: boolean | undefined): void; | ||
(column?: ViewColumn | undefined, preserveFocus?: boolean | undefined): void; | ||
}; | ||
hide: () => void; | ||
}; | ||
/** | ||
* @reactive `env.logLevel` | ||
*/ | ||
export declare const useLogLevel: () => ComputedRef<LogLevel>; | ||
/** | ||
* @reactive `NotebookEditor.selection` | ||
* @category editor | ||
*/ | ||
export declare function useNotebookEditorSelection(notebookEditor: MaybeNullableRefOrGetter<NotebookEditor>): WritableComputedRef<NotebookRange>; | ||
/** | ||
* @reactive `NotebookEditor.selections` | ||
* @category editor | ||
*/ | ||
export declare function useNotebookEditorSelections(notebookEditor: MaybeNullableRefOrGetter<NotebookEditor>): WritableComputedRef<readonly NotebookRange[]>; | ||
/** | ||
* @reactive `NotebookEditor.visibleRanges` | ||
* @category editor | ||
*/ | ||
export declare function useNotebookEditorVisibleRanges(notebookEditor: MaybeNullableRefOrGetter<NotebookEditor>): ComputedRef<readonly NotebookRange[]>; | ||
/** | ||
* @reactive `window.terminals` | ||
* @category terminal | ||
*/ | ||
export declare const useOpenedTerminals: () => ShallowRef<readonly Terminal[]>; | ||
/** | ||
* @reactive `window.createOutputChannel` | ||
* @category view | ||
*/ | ||
export declare function useOutputChannel(name: string, languageId?: string): OutputChannel; | ||
/** | ||
* @reactive `window.createStatusBarItem` | ||
*/ | ||
export declare function useStatusBarItem(options: UseStatusBarItemOptions): StatusBarItem; | ||
export declare interface UseStatusBarItemOptions { | ||
id?: string; | ||
alignment?: StatusBarAlignment; | ||
priority?: number; | ||
name?: MaybeRefOrGetter<StatusBarItem['name']>; | ||
text?: MaybeRefOrGetter<StatusBarItem['text']>; | ||
tooltip?: MaybeRefOrGetter<StatusBarItem['tooltip']>; | ||
color?: MaybeRefOrGetter<StatusBarItem['color']>; | ||
backgroundColor?: MaybeRefOrGetter<StatusBarItem['backgroundColor']>; | ||
command?: MaybeRefOrGetter<StatusBarItem['command']>; | ||
accessibilityInformation?: MaybeRefOrGetter<StatusBarItem['accessibilityInformation']>; | ||
} | ||
/** | ||
* @reactive `tasks.taskExecutions` | ||
*/ | ||
export declare const useTaskExecutions: () => ComputedRef<readonly TaskExecution[]>; | ||
/** | ||
* @reactive `Terminal.state` | ||
* @category terminal | ||
*/ | ||
export declare const useTerminalState: (terminal: Terminal) => ComputedRef<TerminalState>; | ||
/** | ||
* Register a text editor command. See `vscode::commands.registerTextEditorCommand`. | ||
* | ||
* @category commands | ||
*/ | ||
export declare function useTextEditorCommand(command: string, callback: TextEditorCommandCallback): void; | ||
/** | ||
* Register multiple text editor commands. See `vscode::commands.registerTextEditorCommand`. | ||
* | ||
* @category commands | ||
*/ | ||
export declare function useTextEditorCommands(commands: Record<string, TextEditorCommandCallback>): void; | ||
/** | ||
* @reactive `TextEditor.selection` | ||
* @category editor | ||
*/ | ||
export declare function useTextEditorSelection(textEditor: MaybeNullableRefOrGetter<TextEditor>, acceptKind?: MaybeRefOrGetter<(TextEditorSelectionChangeKind | undefined)[]>): WritableComputedRef<Selection>; | ||
/** | ||
* @reactive `TextEditor.selections` | ||
* @category editor | ||
*/ | ||
export declare function useTextEditorSelections(textEditor: MaybeNullableRefOrGetter<TextEditor>, acceptKind?: MaybeRefOrGetter<(TextEditorSelectionChangeKind | undefined)[]>): WritableComputedRef<readonly Selection[]>; | ||
/** | ||
* @reactive `TextEditor.viewColumn` | ||
* @category editor | ||
*/ | ||
export declare function useTextEditorViewColumn(textEditor: MaybeNullableRefOrGetter<TextEditor>): ComputedRef<ViewColumn | undefined>; | ||
/** | ||
* @reactive `TextEditor.visibleRanges` | ||
* @category editor | ||
*/ | ||
export declare function useTextEditorVisibleRanges(textEditor: MaybeNullableRefOrGetter<TextEditor>): ComputedRef<readonly Range[]>; | ||
/** | ||
* Register a tree view. See `vscode::window.createTreeView`. | ||
* | ||
* @category view | ||
*/ | ||
export declare const useTreeView: <T extends TreeViewNode>(viewId: string, treeData: MaybeRefOrGetter<T[]>, options: UseTreeViewOptions<T>) => TreeView<T>; | ||
export declare type UseTreeViewOptions<T> = (Omit<TreeViewOptions<T>, 'treeDataProvider'> & Pick<TreeDataProvider<T>, 'getTreeItem' | 'resolveTreeItem'>) | TreeDataProvider<T>['getTreeItem']; | ||
/** | ||
* @reactive `Uri` | ||
* @category utilities | ||
*/ | ||
export declare function useUri(uri: MaybeRefOrGetter<Uri>): ShallowReactive< { | ||
readonly scheme: string; | ||
readonly authority: string; | ||
readonly path: string; | ||
readonly query: string; | ||
readonly fragment: string; | ||
readonly fsPath: string; | ||
with(change: { | ||
scheme?: string | undefined; | ||
authority?: string | undefined; | ||
path?: string | undefined; | ||
query?: string | undefined; | ||
fragment?: string | undefined; | ||
}): Uri; | ||
toString(): string; | ||
toJSON(): any; | ||
}>; | ||
/** | ||
* Reactively set the badge of a view (`vscode::TreeView` or `vscode::WebviewView`). | ||
* | ||
* @category view | ||
*/ | ||
export declare function useViewBadge(view: MaybeRefOrGetter<Nullable<ViewWithBadge>>, title: MaybeRefOrGetter<ViewBadge | undefined>): void; | ||
/** | ||
* Reactively set the title of a view (`vscode::TreeView` or `vscode::WebviewView`). | ||
* | ||
* @category view | ||
*/ | ||
export declare function useViewTitle(view: MaybeRefOrGetter<Nullable<ViewWithTitle>>, title: MaybeRefOrGetter<string | undefined>): void; | ||
/** | ||
* Reactively get the visibility of a view (`vscode::TreeView` or `vscode::WebviewView`). | ||
* | ||
* @category view | ||
*/ | ||
export declare function useViewVisibility(view: MaybeNullableRefOrGetter<ViewWithVisibility>): ComputedRef<boolean>; | ||
/** | ||
* @reactive `window.visibleNotebookEditors` | ||
* @category editor | ||
*/ | ||
export declare const useVisibleNotebookEditors: () => ShallowRef<readonly NotebookEditor[]>; | ||
/** | ||
* @reactive `window.visibleTextEditors` | ||
* @category editor | ||
*/ | ||
export declare const useVisibleTextEditors: () => ShallowRef<readonly TextEditor[]>; | ||
export declare function useVscodeContext<T>(name: string, value: ComputedRef<T> | (() => T), shouldUpdate?: MaybeRefOrGetter<boolean>): ComputedRef<T>; | ||
export declare function useVscodeContext<T>(name: string, value: WritableComputedRef<T>, shouldUpdate?: MaybeRefOrGetter<boolean>): WritableComputedRef<T>; | ||
export declare function useVscodeContext<T>(name: string, value: Ref<T>, shouldUpdate?: MaybeRefOrGetter<boolean>): Ref<T>; | ||
/** | ||
* Register a webview view. See `vscode::window.registerWebviewViewProvider`. | ||
* | ||
* @category view | ||
*/ | ||
export declare const useWebviewView: (viewId: string, html: MaybeRefOrGetter<string>, webviewOptions?: MaybeRefOrGetter<WebviewOptions> | undefined, registerOptions?: ({ | ||
readonly webviewOptions?: { | ||
readonly retainContextWhenHidden?: boolean | undefined; | ||
} | undefined; | ||
} & { | ||
onDidReceiveMessage?: ((message: any) => void) | undefined; | ||
}) | undefined) => { | ||
view: ShallowRef<WebviewView | undefined>; | ||
context: ShallowRef<unknown>; | ||
postMessage: (message: any) => Thenable<boolean> | undefined; | ||
}; | ||
/** | ||
* @reactive `window.state` | ||
*/ | ||
export declare const useWindowState: () => { | ||
focused: ComputedRef<boolean>; | ||
active: ComputedRef<boolean>; | ||
}; | ||
/** | ||
* @reactive `workspace.workspaceFolders` | ||
*/ | ||
export declare const useWorkspaceFolders: () => ComputedRef<readonly WorkspaceFolder[] | undefined>; | ||
declare type ViewWithBadge = Pick<TreeView<unknown> | WebviewView, 'badge'>; | ||
declare type ViewWithTitle = Pick<TreeView<unknown> | WebviewView, 'title'>; | ||
declare type ViewWithVisibility = Pick<TreeView<unknown> | WebviewView, 'visible' | 'onDidChangeVisibility'>; | ||
export declare function watch<T, Immediate extends Readonly<boolean> = false>( | ||
source: WatchSource<T>, | ||
cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, | ||
options?: WatchOptions<Immediate>, | ||
): WatchStopHandle | ||
export declare function watch< | ||
T extends MultiWatchSources, | ||
Immediate extends Readonly<boolean> = false, | ||
>( | ||
sources: [...T], | ||
cb: WatchCallback<MapSources<T, false>, MapSources<T, Immediate>>, | ||
options?: WatchOptions<Immediate>, | ||
): WatchStopHandle | ||
export declare function watch< | ||
T extends Readonly<MultiWatchSources>, | ||
Immediate extends Readonly<boolean> = false, | ||
>( | ||
source: T, | ||
cb: WatchCallback<MapSources<T, false>, MapSources<T, Immediate>>, | ||
options?: WatchOptions<Immediate>, | ||
): WatchStopHandle | ||
export declare function watch< | ||
T extends object, | ||
Immediate extends Readonly<boolean> = false, | ||
>( | ||
source: T, | ||
cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, | ||
options?: WatchOptions<Immediate>, | ||
): WatchStopHandle | ||
export declare function watch<T = any, Immediate extends Readonly<boolean> = false>( | ||
source: T | WatchSource<T>, | ||
cb: any, | ||
options?: WatchOptions<Immediate>, | ||
): WatchStopHandle { | ||
if (__DEV__ && !isFunction(cb)) { | ||
warn( | ||
`\`watch(fn, options?)\` signature has been moved to a separate API. ` + | ||
`Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` + | ||
`supports \`watch(source, cb, options?) signature.`, | ||
) | ||
} | ||
return doWatch(source as any, cb, options) | ||
} | ||
export declare type WatchCallback<V = any, OV = any> = ( | ||
value: V, | ||
oldValue: OV, | ||
onCleanup: OnCleanup, | ||
) => any | ||
export declare type WatchEffect = (onCleanup: OnCleanup) => void | ||
export declare function watchEffect( | ||
effect: WatchEffect, | ||
options?: WatchOptionsBase, | ||
): WatchStopHandle { | ||
return doWatch(effect, null, options) | ||
} | ||
export declare interface WatchOptions<Immediate = boolean> extends WatchOptionsBase { | ||
immediate?: Immediate | ||
deep?: boolean | ||
once?: boolean | ||
} | ||
export declare interface WatchOptionsBase extends DebuggerOptions { | ||
flush?: 'pre' | 'post' | 'sync' | ||
} | ||
export declare type WatchSource<T = any> = Ref<T> | ComputedRef<T> | (() => T) | ||
export declare type WatchStopHandle = () => void | ||
export declare function watchSyncEffect( | ||
effect: WatchEffect, | ||
options?: DebuggerOptions, | ||
) { | ||
return doWatch( | ||
effect, | ||
null, | ||
__DEV__ ? extend({}, options as any, { flush: 'sync' }) : { flush: 'sync' }, | ||
) | ||
} | ||
export * from "@vue/reactivity"; | ||
export { } |
{ | ||
"name": "reactive-vscode", | ||
"type": "module", | ||
"version": "0.0.1-beta.5", | ||
"version": "0.0.1-beta.6", | ||
"description": "Develop VSCode extension with Vue Reactivity API", | ||
@@ -47,3 +47,3 @@ "author": "_Kerman <kermanx@qq.com>", | ||
"vite-plugin-dts": "^3.9.1", | ||
"@reactive-vscode/reactivity": "0.0.1-beta.5" | ||
"@reactive-vscode/reactivity": "0.0.1-beta.6" | ||
}, | ||
@@ -50,0 +50,0 @@ "scripts": { |
@@ -16,3 +16,3 @@ # reactive-vscode | ||
Source code in [the `./packages/core/src/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). | ||
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). | ||
@@ -19,0 +19,0 @@ 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/). |
@@ -0,0 +0,0 @@ { |
71974
6
2251