1
1
/* this implementation is original ported from https://github.com/logaretm/vue-use-web by Abdelrahman Awad */
2
2
3
3
import type { Ref } from 'vue-demi'
4
- import { ref } from 'vue-demi'
4
+ import { readonly , ref } from 'vue-demi'
5
5
import { useEventListener } from '../useEventListener'
6
6
import { useSupported } from '../useSupported'
7
7
import type { ConfigurableWindow } from '../_configurable'
@@ -12,43 +12,43 @@ export type NetworkType = 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi
12
12
export type NetworkEffectiveType = 'slow-2g' | '2g' | '3g' | '4g' | undefined
13
13
14
14
export interface NetworkState {
15
- isSupported : Ref < boolean >
15
+ isSupported : Readonly < Ref < boolean > >
16
16
/**
17
17
* If the user is currently connected.
18
18
*/
19
- isOnline : Ref < boolean >
19
+ isOnline : Readonly < Ref < boolean > >
20
20
/**
21
21
* The time since the user was last connected.
22
22
*/
23
- offlineAt : Ref < number | undefined >
23
+ offlineAt : Readonly < Ref < number | undefined > >
24
24
/**
25
25
* At this time, if the user is offline and reconnects
26
26
*/
27
- onlineAt : Ref < number | undefined >
27
+ onlineAt : Readonly < Ref < number | undefined > >
28
28
/**
29
29
* The download speed in Mbps.
30
30
*/
31
- downlink : Ref < number | undefined >
31
+ downlink : Readonly < Ref < number | undefined > >
32
32
/**
33
33
* The max reachable download speed in Mbps.
34
34
*/
35
- downlinkMax : Ref < number | undefined >
35
+ downlinkMax : Readonly < Ref < number | undefined > >
36
36
/**
37
37
* The detected effective speed type.
38
38
*/
39
- effectiveType : Ref < NetworkEffectiveType | undefined >
39
+ effectiveType : Readonly < Ref < NetworkEffectiveType | undefined > >
40
40
/**
41
41
* The estimated effective round-trip time of the current connection.
42
42
*/
43
- rtt : Ref < number | undefined >
43
+ rtt : Readonly < Ref < number | undefined > >
44
44
/**
45
45
* If the user activated data saver mode.
46
46
*/
47
- saveData : Ref < boolean | undefined >
47
+ saveData : Readonly < Ref < boolean | undefined > >
48
48
/**
49
49
* The detected connection/network type.
50
50
*/
51
- type : Ref < NetworkType >
51
+ type : Readonly < Ref < NetworkType > >
52
52
}
53
53
54
54
/**
@@ -110,16 +110,16 @@ export function useNetwork(options: ConfigurableWindow = {}): Readonly<NetworkSt
110
110
updateNetworkInformation ( )
111
111
112
112
return {
113
- isSupported,
114
- isOnline,
115
- saveData,
116
- offlineAt,
117
- onlineAt,
118
- downlink,
119
- downlinkMax,
120
- effectiveType,
121
- rtt,
122
- type,
113
+ isSupported : readonly ( isSupported ) ,
114
+ isOnline : readonly ( isOnline ) ,
115
+ saveData : readonly ( saveData ) ,
116
+ offlineAt : readonly ( offlineAt ) ,
117
+ onlineAt : readonly ( onlineAt ) ,
118
+ downlink : readonly ( downlink ) ,
119
+ downlinkMax : readonly ( downlinkMax ) ,
120
+ effectiveType : readonly ( effectiveType ) ,
121
+ rtt : readonly ( rtt ) ,
122
+ type : readonly ( type ) ,
123
123
}
124
124
}
125
125
0 commit comments