Permission
Reactive Permissions API .
Usage
<script>
import { permission } from "@sveu/browser"
const microphone = permission("microphone")
</script>
<script>
import { permission } from "@sveu/browser"
const microphone = permission("microphone")
</script>
svelte
Example
{}
<script>
import { permission } from "@sveu/browser"
const accelerometer = permission("accelerometer")
const accessibilityEvents = permission("accessibility-events")
const ambientLightSensor = permission("ambient-light-sensor")
const backgroundSync = permission("background-sync")
const camera = permission("camera")
const clipboardRead = permission("clipboard-read")
const clipboardWrite = permission("clipboard-write")
const gyroscope = permission("gyroscope")
const magnetometer = permission("magnetometer")
const microphone = permission("microphone")
const notifications = permission("notifications")
const paymentHandler = permission("payment-handler")
const persistentStorage = permission("persistent-storage")
const push = permission("push")
const speaker = permission("speaker")
const geolocation = permission("geolocation")
$: code = JSON.stringify(
{
accelerometer: $accelerometer,
accessibilityEvents: $accessibilityEvents,
ambientLightSensor: $ambientLightSensor,
backgroundSync: $backgroundSync,
camera: $camera,
clipboardRead: $clipboardRead,
clipboardWrite: $clipboardWrite,
gyroscope: $gyroscope,
magnetometer: $magnetometer,
microphone: $microphone,
notifications: $notifications,
paymentHandler: $paymentHandler,
persistentStorage: $persistentStorage,
push: $push,
speaker: $speaker,
geolocation: $geolocation,
},
null,
2
)
</script>
<pre lang="json">{code}</pre>
<script>
import { permission } from "@sveu/browser"
const accelerometer = permission("accelerometer")
const accessibilityEvents = permission("accessibility-events")
const ambientLightSensor = permission("ambient-light-sensor")
const backgroundSync = permission("background-sync")
const camera = permission("camera")
const clipboardRead = permission("clipboard-read")
const clipboardWrite = permission("clipboard-write")
const gyroscope = permission("gyroscope")
const magnetometer = permission("magnetometer")
const microphone = permission("microphone")
const notifications = permission("notifications")
const paymentHandler = permission("payment-handler")
const persistentStorage = permission("persistent-storage")
const push = permission("push")
const speaker = permission("speaker")
const geolocation = permission("geolocation")
$: code = JSON.stringify(
{
accelerometer: $accelerometer,
accessibilityEvents: $accessibilityEvents,
ambientLightSensor: $ambientLightSensor,
backgroundSync: $backgroundSync,
camera: $camera,
clipboardRead: $clipboardRead,
clipboardWrite: $clipboardWrite,
gyroscope: $gyroscope,
magnetometer: $magnetometer,
microphone: $microphone,
notifications: $notifications,
paymentHandler: $paymentHandler,
persistentStorage: $persistentStorage,
push: $push,
speaker: $speaker,
geolocation: $geolocation,
},
null,
2
)
</script>
<pre lang="json">{code}</pre>
svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Click fold/expand code
API
Arguments
Name | Description | Type | Required |
---|---|---|---|
name | Permission name | string | Yes |
Options
Name | Description | Type |
---|---|---|
controls | Whether to return controls or not. | boolean |
Return
Name | Description | Type |
---|---|---|
state | Permission state | Readable<PermissionState> |
supported | Whether the browser supports the API(only available when controls is true) | Readable<boolean > |
query | Query permission status(only available when controls is true) | () => Promise<PermissionStatus > |