@@ -19,8 +19,6 @@ declare interface CachedData<TData = any, TParams = any> {
19
19
20
20
export declare const clearUseRequestCache : ( key ?: string | string [ ] ) => void ;
21
21
22
- export declare function createUseRequest < TData , TParams extends unknown [ ] = unknown [ ] , PluginsOptions extends UseRequestPlugin < TData , TParams > [ ] = UseRequestPlugin < TData , TParams > [ ] > ( service : UseRequestService < TData , TParams > , options ?: UseRequestOptions < TData , TParams , PluginsOptions extends ( infer P ) [ ] ? P extends UseRequestPlugin < TData , TParams , infer R > ? R : any : any > , plugins ?: PluginsOptions ) : useRequestResult < TData , TParams > ;
23
-
24
22
declare interface DebounceOptions {
25
23
/**
26
24
* The number of milliseconds to delay.
@@ -96,13 +94,6 @@ declare class Fetch<TData, TParams extends unknown[] = any> {
96
94
mutate ( data ?: TData | ( ( oldData ?: TData ) => TData | undefined ) ) : void ;
97
95
}
98
96
99
- declare type FetchType < TData , TParams > = Record < string | number , {
100
- data : TData | undefined ;
101
- params : TParams ;
102
- loading : boolean ;
103
- key : string | number ;
104
- } > ;
105
-
106
97
declare interface IFuncUpdater < T > {
107
98
( previousState ?: T ) : T ;
108
99
}
@@ -143,8 +134,8 @@ declare enum ReadyState_2 {
143
134
declare type Resolve = ( value : any ) => void ;
144
135
145
136
declare type Size = {
146
- width : Ref < number > ;
147
- height : Ref < number > ;
137
+ width : Readonly < Ref < number > > ;
138
+ height : Readonly < Ref < number > > ;
148
139
} ;
149
140
150
141
declare type StorageStateResultHasDefaultValue < T > = [
@@ -222,9 +213,9 @@ declare interface UseBooleanActions {
222
213
toggle : ( ) => void ;
223
214
}
224
215
225
- declare type UseBooleanResult = [ Ref < boolean > , UseBooleanActions ] ;
216
+ declare type UseBooleanResult = [ Readonly < Ref < boolean > > , UseBooleanActions ] ;
226
217
227
- export declare function useCookieState ( cookieKey : string , options ?: UseCookieStateOptions ) : readonly [ any , ( newValue : UseCookieStateType | ( ( prevState : UseCookieStateType ) => UseCookieStateType ) , newOptions ?: Cookies . CookieAttributes ) => void ] ;
218
+ export declare function useCookieState ( cookieKey : string , options ?: UseCookieStateOptions ) : readonly [ Readonly < Ref < UseCookieStateType | ( ( ) => UseCookieStateType ) > > , ( newValue : UseCookieStateType | ( ( prevState : UseCookieStateType ) => UseCookieStateType ) , newOptions ?: Cookies . CookieAttributes ) => void ] ;
228
219
229
220
declare interface UseCookieStateOptions extends Cookies . CookieAttributes {
230
221
defaultValue ?: UseCookieStateType | ( ( ) => UseCookieStateType ) ;
@@ -271,7 +262,7 @@ declare interface UseCounterOptions {
271
262
max ?: number ;
272
263
}
273
264
274
- export declare function useDarkMode ( ) : [ ComputedRef < any > , ( value ?: unknown ) => void ] ;
265
+ export declare function useDarkMode ( ) : [ ComputedRef < boolean > , ( value ?: unknown ) => void ] ;
275
266
276
267
export declare function useDebounce < T > ( value : Ref < T > , options ?: DebounceOptions ) : Ref < T > ;
277
268
@@ -414,7 +405,7 @@ declare type UseEventListenerOptions<T extends UseEventListenerTarget = UseEvent
414
405
415
406
declare type UseEventListenerTarget = BasicTarget < HTMLElement | Element | Window | Document > ;
416
407
417
- export declare function useExternal ( path ?: string | Ref < string > , options ?: UseExternalOptions ) : Ref < UseExternalStatus > ;
408
+ export declare function useExternal ( path ?: string | Ref < string > , options ?: UseExternalOptions ) : Readonly < Ref < UseExternalStatus > > ;
418
409
419
410
declare interface UseExternalOptions {
420
411
/**
@@ -440,15 +431,28 @@ export declare function useFetchs<TData, TParams>(service: UseRequestService<TDa
440
431
} , self : {
441
432
fetchKey ?: ( ...args : ParamsType < TParams > ) => string ;
442
433
} ) : {
443
- fetchs : Ref < FetchType < TData , TParams > > ;
434
+ fetchs : Readonly < Ref < {
435
+ readonly [ x : string ] : {
436
+ readonly data : DeepReadonly < TData > | undefined ;
437
+ readonly params : DeepReadonly < TParams > ;
438
+ readonly loading : boolean ;
439
+ readonly key : string | number ;
440
+ } ;
441
+ readonly [ x : number ] : {
442
+ readonly data : DeepReadonly < TData > | undefined ;
443
+ readonly params : DeepReadonly < TParams > ;
444
+ readonly loading : boolean ;
445
+ readonly key : string | number ;
446
+ } ;
447
+ } > > ;
444
448
fetchRun : ( ...args : TParams extends any [ ] ? any [ ] : any ) => void ;
445
449
} ;
446
450
447
451
export declare function useFocusWithin (
448
452
/**
449
453
* DOM element or ref
450
454
*/
451
- target : BasicTarget , options ?: UseFocusWithinOptions ) : Ref < boolean > ;
455
+ target : BasicTarget , options ?: UseFocusWithinOptions ) : Readonly < Ref < boolean > > ;
452
456
453
457
declare interface UseFocusWithinOptions {
454
458
/**
@@ -473,7 +477,7 @@ declare interface UseFocusWithinOptions {
473
477
474
478
export declare function useFormatResult < TData , FData > ( data : TData | Ref < TData > , formatResultCallback : ( data : TData ) => FData ) : ComputedRef < FData > ;
475
479
476
- export declare const useFullscreen : ( target : BasicTarget , options ?: UseFullscreenOptions ) => readonly [ Ref < boolean > , {
480
+ export declare const useFullscreen : ( target : BasicTarget , options ?: UseFullscreenOptions ) => readonly [ Readonly < Ref < boolean > > , {
477
481
readonly enterFullscreen : ( ) => void ;
478
482
readonly exitFullscreen : ( ) => void ;
479
483
readonly toggleFullscreen : ( ) => void ;
@@ -520,9 +524,9 @@ declare type UseInfiniteData = {
520
524
} ;
521
525
522
526
export declare const useInfiniteScroll : < TData extends UseInfiniteData > ( service : UseInfiniteService < TData > , options ?: UseInfiniteScrollOptions < TData > ) => {
523
- data : Ref < TData | undefined > ;
524
- loading : ComputedRef < boolean > ;
525
- loadingMore : Ref < boolean > ;
527
+ data : Readonly < Ref < TData | undefined > > ;
528
+ loading : Readonly < Ref < boolean > > ;
529
+ loadingMore : Readonly < Ref < boolean > > ;
526
530
noMore : ComputedRef < boolean > ;
527
531
loadMore : ( ) => void ;
528
532
loadMoreAsync : ( ) => Promise < TData > | undefined ;
@@ -600,7 +604,7 @@ delay: Ref<number | undefined> | number | undefined, options?: {
600
604
immediate ?: boolean ;
601
605
} ) : void ;
602
606
603
- export declare function useInViewport ( target : BasicTarget , options ?: UseInViewportOptions ) : readonly [ Ref < boolean | undefined > , Ref < number | undefined > ] ;
607
+ export declare function useInViewport ( target : BasicTarget , options ?: UseInViewportOptions ) : readonly [ Readonly < Ref < boolean | undefined > > , Readonly < Ref < number | undefined > > ] ;
604
608
605
609
declare interface UseInViewportOptions {
606
610
/**
@@ -648,7 +652,7 @@ export declare const useLocalStorageState: <T>(key: string | Ref<string>, option
648
652
649
653
export declare function useLockFn < P extends any [ ] , V > ( fn : ( ...args : P ) => Promise < V > ) : ( ...args : P ) => Promise < V | undefined > ;
650
654
651
- export declare function useMap < K , T > ( initialValue ?: UseMapValue < K , T > ) : [ Ref < Map < K , T > > , UseMapActions < K , T > ] ;
655
+ export declare function useMap < K , T > ( initialValue ?: UseMapValue < K , T > ) : [ Readonly < Ref < Map < K , T > > > , UseMapActions < K , T > ] ;
652
656
653
657
declare type UseMapActions < K , T > = {
654
658
/**
@@ -713,22 +717,22 @@ values: {
713
717
*/
714
718
defaultValue : any ) : any ;
715
719
716
- export declare function useMouse ( target ?: BasicTarget ) : Ref < {
717
- screenX : number ;
718
- screenY : number ;
719
- clientX : number ;
720
- clientY : number ;
721
- pageX : number ;
722
- pageY : number ;
723
- elementX : number ;
724
- elementY : number ;
725
- elementH : number ;
726
- elementW : number ;
727
- elementPosX : number ;
728
- elementPosY : number ;
729
- } > ;
730
-
731
- export declare function useNetwork ( ) : UseNetworkState ;
720
+ export declare function useMouse ( target ?: BasicTarget ) : Readonly < Ref < {
721
+ readonly screenX : number ;
722
+ readonly screenY : number ;
723
+ readonly clientX : number ;
724
+ readonly clientY : number ;
725
+ readonly pageX : number ;
726
+ readonly pageY : number ;
727
+ readonly elementX : number ;
728
+ readonly elementY : number ;
729
+ readonly elementH : number ;
730
+ readonly elementW : number ;
731
+ readonly elementPosX : number ;
732
+ readonly elementPosY : number ;
733
+ } > > ;
734
+
735
+ export declare function useNetwork ( ) : Readonly < Ref < UseNetworkState > > ;
732
736
733
737
declare interface UseNetworkState {
734
738
since ?: Date ;
@@ -745,7 +749,7 @@ export declare function usePreview(md: Parameters<typeof createApp> | Ref<string
745
749
container : Ref < Element | undefined > ;
746
750
} ;
747
751
748
- export declare function usePrevious < T > ( state : Ref < T > | ComputedRef < T > , shouldUpdate ?: UsePreviousShouldUpdateFunc < T > ) : Ref < T | undefined > ;
752
+ export declare function usePrevious < T > ( state : Ref < T > | ComputedRef < T > , shouldUpdate ?: UsePreviousShouldUpdateFunc < T > ) : Readonly < Ref < DeepReadonly < T > | undefined > > ;
749
753
750
754
declare type UsePreviousShouldUpdateFunc < T > = ( prev : T | undefined , next : T ) => boolean ;
751
755
@@ -913,7 +917,7 @@ declare type UseRequestOptions<TData, TParams extends unknown[], TPlugin> = {
913
917
[ K in keyof TPlugin ] : TPlugin [ K ] ;
914
918
} ;
915
919
916
- export declare interface UseRequestPlugin < TData , TParams extends unknown [ ] = unknown [ ] , TPlugin = any > {
920
+ declare interface UseRequestPlugin < TData , TParams extends unknown [ ] = unknown [ ] , TPlugin = any > {
917
921
( fetchInstance : Fetch < TData , TParams > , options : UseRequestOptions < TData , TParams , TPlugin > ) : UseRequestPluginReturn < TData , TParams > ;
918
922
onInit ?: ( options : UseRequestOptions < TData , TParams , TPlugin > ) => Partial < UseRequestFetchState < TData , TParams > > ;
919
923
}
@@ -939,19 +943,19 @@ declare interface useRequestResult<TData, TParams extends unknown[]> {
939
943
/**
940
944
* Is the service being executed.
941
945
*/
942
- loading : Ref < boolean > ;
946
+ loading : Readonly < Ref < boolean > > ;
943
947
/**
944
948
* Data returned by service.
945
949
*/
946
- data : Ref < TData | undefined > ;
950
+ data : Readonly < Ref < TData | undefined > > ;
947
951
/**
948
952
* Exception thrown by service.
949
953
*/
950
- error : Ref < Error | undefined > ;
954
+ error : Readonly < Ref < Error | undefined > > ;
951
955
/**
952
956
* params An array of parameters for the service being executed. For example, you triggered `run(1, 2, 3)`, then params is equal to `[1, 2, 3]`.
953
957
*/
954
- params : Ref < TParams | [ ] > ;
958
+ params : Readonly < Ref < TParams | [ ] > > ;
955
959
/**
956
960
* Ignore the current promise response.
957
961
*/
@@ -980,15 +984,15 @@ declare interface useRequestResult<TData, TParams extends unknown[]> {
980
984
981
985
declare type UseRequestService < TData , TParams extends unknown [ ] > = ( ...args : TParams ) => Promise < TData > ;
982
986
983
- export declare function useScroll ( target ?: UseScrollTarget , shouldUpdate ?: UseScrollListenController ) : Ref < Position | undefined > ;
987
+ export declare function useScroll ( target ?: UseScrollTarget , shouldUpdate ?: UseScrollListenController ) : Readonly < Ref < Position | undefined > > ;
984
988
985
989
declare type UseScrollListenController = ( val : Position ) => boolean ;
986
990
987
991
declare type UseScrollTarget = BasicTarget < Element | Document > ;
988
992
989
993
export declare const useSessionStorageState : < T > ( key : string | Ref < string > , options ?: OptionsWithDefaultValue < T > | undefined ) => StorageStateResultHasDefaultValue < T > ;
990
994
991
- export declare function useSet < T = any > ( initialValue ?: T [ ] ) : [ Ref < Set < any > > , UseSetActions < T > ] ;
995
+ export declare function useSet < T = any > ( initialValue ?: T [ ] ) : [ Readonly < Ref < Set < T > > > , UseSetActions < T > ] ;
992
996
993
997
declare interface UseSetActions < T > {
994
998
add : ( value : T ) => void ;
@@ -1009,7 +1013,7 @@ declare type UseSetStateType<S> = S | (() => S) | Ref<S> | (() => Ref<S>);
1009
1013
*
1010
1014
* @param {dom id节点或者 ref句柄 } target
1011
1015
*/
1012
- export declare function useSize ( target : BasicTarget ) : Size | undefined ;
1016
+ export declare function useSize ( target : BasicTarget ) : Size ;
1013
1017
1014
1018
export declare function useThrottle < T > ( value : Ref < T > , options ?: UseThrottleOptions ) : Ref < any > ;
1015
1019
@@ -1053,7 +1057,7 @@ declare type UseSetStateType<S> = S | (() => S) | Ref<S> | (() => Ref<S>);
1053
1057
export declare const useTrackedEffect : ( effect : UseTrackedEffect , deps ?: Ref [ ] ) => void ;
1054
1058
1055
1059
export declare function useUpdate ( ) : {
1056
- update : Ref < { } > ;
1060
+ update : Readonly < Ref < { } > > ;
1057
1061
setUpdate : ( ) => void ;
1058
1062
} ;
1059
1063
@@ -1100,11 +1104,11 @@ declare type UseSetStateType<S> = S | (() => S) | Ref<S> | (() => Ref<S>);
1100
1104
}
1101
1105
1102
1106
declare interface UseWebSocketResult {
1103
- latestMessage : Ref < WebSocketEventMap [ 'message' ] | undefined > ;
1107
+ latestMessage : Readonly < Ref < WebSocketEventMap [ 'message' ] | undefined > > ;
1104
1108
sendMessage ?: WebSocket [ 'send' ] ;
1105
1109
disconnect ?: ( ) => void ;
1106
1110
connect ?: ( ) => void ;
1107
- readyState : Ref < ReadyState_2 > ;
1111
+ readyState : Readonly < Ref < ReadyState_2 > > ;
1108
1112
webSocketIns ?: WebSocket ;
1109
1113
}
1110
1114
0 commit comments