@reactive-vscode/vueuse 0.2.8 → 0.2.10
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.cjs +222 -152
- package/dist/index.d.ts +73 -36
- package/dist/index.js +223 -153
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { ComputedGetter } from '@reactive-vscode/reactivity';
|
|
2
2
|
import { ComputedRef } from '@reactive-vscode/reactivity';
|
|
3
|
+
import { MaybeRef } from '@reactive-vscode/reactivity';
|
|
4
|
+
import { MaybeRefOrGetter } from '@reactive-vscode/reactivity';
|
|
3
5
|
import { Ref } from '@reactive-vscode/reactivity';
|
|
4
6
|
import { ShallowRef } from '@reactive-vscode/reactivity';
|
|
5
7
|
import { ShallowUnwrapRef as ShallowUnwrapRef_2 } from '@reactive-vscode/reactivity';
|
|
6
8
|
import { ToRef } from '@reactive-vscode/reactivity';
|
|
7
9
|
import { ToRefs } from '@reactive-vscode/reactivity';
|
|
10
|
+
import { toValue as toValue_2 } from '@reactive-vscode/reactivity';
|
|
8
11
|
import { UnwrapNestedRefs } from '@reactive-vscode/reactivity';
|
|
9
12
|
import { UnwrapRef } from '@reactive-vscode/reactivity';
|
|
10
13
|
import * as vue from '@reactive-vscode/reactivity';
|
|
@@ -18,6 +21,8 @@ import { WritableComputedRef } from '@reactive-vscode/reactivity';
|
|
|
18
21
|
export declare interface AfterFetchContext<T = any> {
|
|
19
22
|
response: Response;
|
|
20
23
|
data: T | null;
|
|
24
|
+
context: BeforeFetchContext;
|
|
25
|
+
execute: (throwOnFailed?: boolean) => Promise<any>;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
/**
|
|
@@ -347,6 +352,7 @@ export declare interface EventHook<T = any> {
|
|
|
347
352
|
on: EventHookOn<T>;
|
|
348
353
|
off: EventHookOff<T>;
|
|
349
354
|
trigger: EventHookTrigger<T>;
|
|
355
|
+
clear: () => void;
|
|
350
356
|
}
|
|
351
357
|
|
|
352
358
|
export declare type EventHookOff<T = any> = (fn: Callback<T>) => void;
|
|
@@ -516,16 +522,6 @@ export declare type MapSources<T> = {
|
|
|
516
522
|
[K in keyof T]: T[K] extends WatchSource<infer V> ? V : never;
|
|
517
523
|
};
|
|
518
524
|
|
|
519
|
-
/**
|
|
520
|
-
* Maybe it's a ref, or a plain value.
|
|
521
|
-
*/
|
|
522
|
-
declare type MaybeRef<T = any> = T | Ref<T> | ShallowRef<T> | WritableComputedRef<T>;
|
|
523
|
-
|
|
524
|
-
/**
|
|
525
|
-
* Maybe it's a ref, or a plain value, or a getter function.
|
|
526
|
-
*/
|
|
527
|
-
declare type MaybeRefOrGetter<T = any> = MaybeRef<T> | ComputedRef<T> | (() => T);
|
|
528
|
-
|
|
529
525
|
export declare type MultiWatchSources = (WatchSource<unknown> | object)[];
|
|
530
526
|
|
|
531
527
|
export declare type Mutable<T> = {
|
|
@@ -564,6 +560,9 @@ declare type OnCleanup = (cleanupFn: () => void) => void;
|
|
|
564
560
|
export declare interface OnFetchErrorContext<T = any, E = any> {
|
|
565
561
|
error: E;
|
|
566
562
|
data: T | null;
|
|
563
|
+
response: Response | null;
|
|
564
|
+
context: BeforeFetchContext;
|
|
565
|
+
execute: (throwOnFailed?: boolean) => Promise<any>;
|
|
567
566
|
}
|
|
568
567
|
|
|
569
568
|
export declare interface Pausable {
|
|
@@ -739,7 +738,7 @@ export declare const resolveRef: typeof toRef;
|
|
|
739
738
|
/**
|
|
740
739
|
* @deprecated use `toValue` instead
|
|
741
740
|
*/
|
|
742
|
-
export declare const resolveUnref: typeof
|
|
741
|
+
export declare const resolveUnref: typeof toValue_2;
|
|
743
742
|
|
|
744
743
|
export declare interface Serializer<T> {
|
|
745
744
|
read: (raw: string) => T;
|
|
@@ -879,7 +878,7 @@ export declare interface ThrottleFilterOptions {
|
|
|
879
878
|
rejectOnCancel?: boolean;
|
|
880
879
|
}
|
|
881
880
|
|
|
882
|
-
export declare interface ToDataURLOptions {
|
|
881
|
+
export declare interface ToDataURLOptions extends UseBase64Options {
|
|
883
882
|
/**
|
|
884
883
|
* MIME type
|
|
885
884
|
*/
|
|
@@ -932,8 +931,10 @@ export declare interface ToRefsOptions {
|
|
|
932
931
|
|
|
933
932
|
/**
|
|
934
933
|
* Get the value of value/ref/getter.
|
|
934
|
+
*
|
|
935
|
+
* @deprecated use `toValue` from `vue` instead
|
|
935
936
|
*/
|
|
936
|
-
export declare
|
|
937
|
+
export declare const toValue: typeof toValue_2;
|
|
937
938
|
|
|
938
939
|
declare interface Transform<L, R> {
|
|
939
940
|
ltr: (left: L) => R;
|
|
@@ -1020,9 +1021,19 @@ export declare interface UntilValueInstance<T, Not extends boolean = false> exte
|
|
|
1020
1021
|
|
|
1021
1022
|
export declare type UrlParams = Record<string, string[] | string>;
|
|
1022
1023
|
|
|
1023
|
-
export declare function useArrayDifference<T>(list: MaybeRefOrGetter<T[]>, values: MaybeRefOrGetter<T[]>, key?: keyof T): ComputedRef<T[]>;
|
|
1024
|
+
export declare function useArrayDifference<T>(list: MaybeRefOrGetter<T[]>, values: MaybeRefOrGetter<T[]>, key?: keyof T, options?: UseArrayDifferenceOptions): ComputedRef<T[]>;
|
|
1024
1025
|
|
|
1025
|
-
export declare function useArrayDifference<T>(list: MaybeRefOrGetter<T[]>, values: MaybeRefOrGetter<T[]>, compareFn?: (value: T, othVal: T) => boolean): ComputedRef<T[]>;
|
|
1026
|
+
export declare function useArrayDifference<T>(list: MaybeRefOrGetter<T[]>, values: MaybeRefOrGetter<T[]>, compareFn?: (value: T, othVal: T) => boolean, options?: UseArrayDifferenceOptions): ComputedRef<T[]>;
|
|
1027
|
+
|
|
1028
|
+
declare interface UseArrayDifferenceOptions {
|
|
1029
|
+
/**
|
|
1030
|
+
* Returns asymmetric difference
|
|
1031
|
+
*
|
|
1032
|
+
* @see https://en.wikipedia.org/wiki/Symmetric_difference
|
|
1033
|
+
* @default false
|
|
1034
|
+
*/
|
|
1035
|
+
symmetric?: boolean;
|
|
1036
|
+
}
|
|
1026
1037
|
|
|
1027
1038
|
/**
|
|
1028
1039
|
* Reactive `Array.every`
|
|
@@ -1223,7 +1234,7 @@ export declare type UseAsyncQueueTask<T> = (...args: any[]) => T | Promise<T>;
|
|
|
1223
1234
|
* @param initialState The initial state, used until the first evaluation finishes
|
|
1224
1235
|
* @param options
|
|
1225
1236
|
*/
|
|
1226
|
-
export declare function useAsyncState<Data, Params extends any[] = [], Shallow extends boolean = true>(promise: Promise<Data> | ((...args: Params) => Promise<Data>), initialState: Data, options?: UseAsyncStateOptions<Shallow, Data>): UseAsyncStateReturn<Data, Params, Shallow>;
|
|
1237
|
+
export declare function useAsyncState<Data, Params extends any[] = any[], Shallow extends boolean = true>(promise: Promise<Data> | ((...args: Params) => Promise<Data>), initialState: Data, options?: UseAsyncStateOptions<Shallow, Data>): UseAsyncStateReturn<Data, Params, Shallow>;
|
|
1227
1238
|
|
|
1228
1239
|
export declare interface UseAsyncStateOptions<Shallow extends boolean, D = any> {
|
|
1229
1240
|
/**
|
|
@@ -1285,11 +1296,11 @@ export declare interface UseAsyncStateReturnBase<Data, Params extends any[], Sha
|
|
|
1285
1296
|
execute: (delay?: number, ...args: Params) => Promise<Data>;
|
|
1286
1297
|
}
|
|
1287
1298
|
|
|
1288
|
-
export declare function useBase64(target: MaybeRefOrGetter<string
|
|
1299
|
+
export declare function useBase64(target: MaybeRefOrGetter<string>, options?: UseBase64Options): UseBase64Return;
|
|
1289
1300
|
|
|
1290
|
-
export declare function useBase64(target: MaybeRefOrGetter<Blob
|
|
1301
|
+
export declare function useBase64(target: MaybeRefOrGetter<Blob>, options?: UseBase64Options): UseBase64Return;
|
|
1291
1302
|
|
|
1292
|
-
export declare function useBase64(target: MaybeRefOrGetter<ArrayBuffer
|
|
1303
|
+
export declare function useBase64(target: MaybeRefOrGetter<ArrayBuffer>, options?: UseBase64Options): UseBase64Return;
|
|
1293
1304
|
|
|
1294
1305
|
export declare function useBase64(target: MaybeRefOrGetter<HTMLCanvasElement>, options?: ToDataURLOptions): UseBase64Return;
|
|
1295
1306
|
|
|
@@ -1303,8 +1314,17 @@ export declare function useBase64<T extends Set<unknown>>(target: MaybeRefOrGett
|
|
|
1303
1314
|
|
|
1304
1315
|
export declare function useBase64<T>(target: MaybeRefOrGetter<T[]>, options?: UseBase64ObjectOptions<T[]>): UseBase64Return;
|
|
1305
1316
|
|
|
1306
|
-
export declare interface UseBase64ObjectOptions<T> {
|
|
1307
|
-
serializer
|
|
1317
|
+
export declare interface UseBase64ObjectOptions<T> extends UseBase64Options {
|
|
1318
|
+
serializer?: (v: T) => string;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
declare interface UseBase64Options {
|
|
1322
|
+
/**
|
|
1323
|
+
* Output as Data URL format
|
|
1324
|
+
*
|
|
1325
|
+
* @default true
|
|
1326
|
+
*/
|
|
1327
|
+
dataUrl?: boolean;
|
|
1308
1328
|
}
|
|
1309
1329
|
|
|
1310
1330
|
export declare interface UseBase64Return {
|
|
@@ -1331,7 +1351,7 @@ export declare interface UseBroadcastChannelOptions extends ConfigurableWindow {
|
|
|
1331
1351
|
}
|
|
1332
1352
|
|
|
1333
1353
|
export declare interface UseBroadcastChannelReturn<D, P> {
|
|
1334
|
-
isSupported:
|
|
1354
|
+
isSupported: ComputedRef<boolean>;
|
|
1335
1355
|
channel: Ref<BroadcastChannel | undefined>;
|
|
1336
1356
|
data: Ref<D>;
|
|
1337
1357
|
post: (data: P) => void;
|
|
@@ -1399,6 +1419,10 @@ export declare interface UseClonedReturn<T> {
|
|
|
1399
1419
|
* Cloned ref
|
|
1400
1420
|
*/
|
|
1401
1421
|
cloned: Ref<T>;
|
|
1422
|
+
/**
|
|
1423
|
+
* Ref indicates whether the cloned data is modified
|
|
1424
|
+
*/
|
|
1425
|
+
isModified: Ref<boolean>;
|
|
1402
1426
|
/**
|
|
1403
1427
|
* Sync cloned data with source manually
|
|
1404
1428
|
*/
|
|
@@ -1597,11 +1621,7 @@ export declare interface UseFetchOptions {
|
|
|
1597
1621
|
* Will run immediately after the fetch request is returned.
|
|
1598
1622
|
* Runs after any 4xx and 5xx response
|
|
1599
1623
|
*/
|
|
1600
|
-
onFetchError?: (ctx:
|
|
1601
|
-
data: any;
|
|
1602
|
-
response: Response | null;
|
|
1603
|
-
error: any;
|
|
1604
|
-
}) => Promise<Partial<OnFetchErrorContext>> | Partial<OnFetchErrorContext>;
|
|
1624
|
+
onFetchError?: (ctx: OnFetchErrorContext) => Promise<Partial<OnFetchErrorContext>> | Partial<OnFetchErrorContext>;
|
|
1605
1625
|
}
|
|
1606
1626
|
|
|
1607
1627
|
export declare interface UseFetchReturn<T> {
|
|
@@ -1839,11 +1859,11 @@ export declare interface UseManualRefHistoryReturn<Raw, Serialized> {
|
|
|
1839
1859
|
/**
|
|
1840
1860
|
* A ref representing if undo is possible (non empty undoStack)
|
|
1841
1861
|
*/
|
|
1842
|
-
canUndo:
|
|
1862
|
+
canUndo: ComputedRef<boolean>;
|
|
1843
1863
|
/**
|
|
1844
1864
|
* A ref representing if redo is possible (non empty redoStack)
|
|
1845
1865
|
*/
|
|
1846
|
-
canRedo:
|
|
1866
|
+
canRedo: ComputedRef<boolean>;
|
|
1847
1867
|
/**
|
|
1848
1868
|
* Undo changes
|
|
1849
1869
|
*/
|
|
@@ -2135,7 +2155,7 @@ export declare interface UseStepperReturn<StepName, Steps, Step> {
|
|
|
2135
2155
|
}
|
|
2136
2156
|
|
|
2137
2157
|
declare function useTextareaAutosize(options?: UseTextareaAutosizeOptions): {
|
|
2138
|
-
textarea: vue.Ref<HTMLTextAreaElement, HTMLTextAreaElement>;
|
|
2158
|
+
textarea: vue.Ref<HTMLTextAreaElement | undefined, HTMLTextAreaElement | undefined>;
|
|
2139
2159
|
input: vue.Ref<string, string>;
|
|
2140
2160
|
triggerResize: () => void;
|
|
2141
2161
|
};
|
|
@@ -2144,7 +2164,7 @@ export declare interface UseTextareaAutosizeOptions {
|
|
|
2144
2164
|
/** Textarea element to autosize. */
|
|
2145
2165
|
element?: MaybeRef<HTMLTextAreaElement | undefined>;
|
|
2146
2166
|
/** Textarea content. */
|
|
2147
|
-
input?: MaybeRef<string
|
|
2167
|
+
input?: MaybeRef<string>;
|
|
2148
2168
|
/** Watch sources that should trigger a textarea resize. */
|
|
2149
2169
|
watch?: WatchSource | Array<WatchSource>;
|
|
2150
2170
|
/** Function called when the textarea size changes. */
|
|
@@ -2283,7 +2303,7 @@ export declare interface UseTimeoutOptions<Controls extends boolean> extends Use
|
|
|
2283
2303
|
callback?: Fn;
|
|
2284
2304
|
}
|
|
2285
2305
|
|
|
2286
|
-
export declare function useTimeoutPoll(fn: () => Awaitable<void>, interval: MaybeRefOrGetter<number>,
|
|
2306
|
+
export declare function useTimeoutPoll(fn: () => Awaitable<void>, interval: MaybeRefOrGetter<number>, options?: UseTimeoutFnOptions): Pausable;
|
|
2287
2307
|
|
|
2288
2308
|
/**
|
|
2289
2309
|
* Reactive current timestamp.
|
|
@@ -2348,9 +2368,11 @@ export declare interface UseToNumberOptions {
|
|
|
2348
2368
|
/**
|
|
2349
2369
|
* Method to use to convert the value to a number.
|
|
2350
2370
|
*
|
|
2371
|
+
* Or a custom function for the conversion.
|
|
2372
|
+
*
|
|
2351
2373
|
* @default 'parseFloat'
|
|
2352
2374
|
*/
|
|
2353
|
-
method?: 'parseFloat' | 'parseInt';
|
|
2375
|
+
method?: 'parseFloat' | 'parseInt' | ((value: string | number) => number);
|
|
2354
2376
|
/**
|
|
2355
2377
|
* The base in mathematical numeral systems passed to `parseInt`.
|
|
2356
2378
|
* Only works with `method: 'parseInt'`
|
|
@@ -2399,6 +2421,13 @@ export declare interface UseUrlSearchParamsOptions<T> extends ConfigurableWindow
|
|
|
2399
2421
|
* @default true
|
|
2400
2422
|
*/
|
|
2401
2423
|
write?: boolean;
|
|
2424
|
+
/**
|
|
2425
|
+
* Write mode for `window.history` when `write` is enabled
|
|
2426
|
+
* - `replace`: replace the current history entry
|
|
2427
|
+
* - `push`: push a new history entry
|
|
2428
|
+
* @default 'replace'
|
|
2429
|
+
*/
|
|
2430
|
+
writeMode?: 'replace' | 'push';
|
|
2402
2431
|
}
|
|
2403
2432
|
|
|
2404
2433
|
/**
|
|
@@ -2425,11 +2454,11 @@ export declare interface UseWebSocketOptions {
|
|
|
2425
2454
|
*
|
|
2426
2455
|
* @default 'ping'
|
|
2427
2456
|
*/
|
|
2428
|
-
message?:
|
|
2457
|
+
message?: MaybeRefOrGetter<WebSocketHeartbeatMessage>;
|
|
2429
2458
|
/**
|
|
2430
2459
|
* Response message for the heartbeat, if undefined the message will be used
|
|
2431
2460
|
*/
|
|
2432
|
-
responseMessage?:
|
|
2461
|
+
responseMessage?: MaybeRefOrGetter<WebSocketHeartbeatMessage>;
|
|
2433
2462
|
/**
|
|
2434
2463
|
* Interval, in milliseconds
|
|
2435
2464
|
*
|
|
@@ -2469,11 +2498,17 @@ export declare interface UseWebSocketOptions {
|
|
|
2469
2498
|
onFailed?: Fn;
|
|
2470
2499
|
};
|
|
2471
2500
|
/**
|
|
2472
|
-
*
|
|
2501
|
+
* Immediately open the connection when calling this composable
|
|
2473
2502
|
*
|
|
2474
2503
|
* @default true
|
|
2475
2504
|
*/
|
|
2476
2505
|
immediate?: boolean;
|
|
2506
|
+
/**
|
|
2507
|
+
* Automatically connect to the websocket when URL changes
|
|
2508
|
+
*
|
|
2509
|
+
* @default true
|
|
2510
|
+
*/
|
|
2511
|
+
autoConnect?: boolean;
|
|
2477
2512
|
/**
|
|
2478
2513
|
* Automatically close a connection
|
|
2479
2514
|
*
|
|
@@ -2672,6 +2707,8 @@ export declare function watchWithFilter<T extends object, Immediate extends Read
|
|
|
2672
2707
|
declare interface WatchWithFilterOptions<Immediate> extends WatchOptions<Immediate>, ConfigurableEventFilter {
|
|
2673
2708
|
}
|
|
2674
2709
|
|
|
2710
|
+
declare type WebSocketHeartbeatMessage = string | ArrayBuffer | Blob;
|
|
2711
|
+
|
|
2675
2712
|
export declare type WebSocketStatus = 'OPEN' | 'CONNECTING' | 'CLOSED';
|
|
2676
2713
|
|
|
2677
2714
|
export declare type WebWorkerStatus = 'PENDING' | 'SUCCESS' | 'RUNNING' | 'ERROR' | 'TIMEOUT_EXPIRED';
|