@symbiote-native/brightness 0.1.0 → 0.3.0
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/README.md +57 -25
- package/build/angular/index.d.ts +1 -1
- package/build/angular/index.js +1 -1
- package/build/angular/services/permissions.service/index.d.ts +4 -0
- package/build/angular/services/permissions.service/index.js +19 -2
- package/build/core/brightness.js +1 -1
- package/build/react/hooks/use-permissions/index.d.ts +2 -1
- package/build/react/hooks/use-permissions/index.js +17 -4
- package/build/react/index.d.ts +1 -1
- package/build/react/index.js +1 -1
- package/build/solid/index.d.ts +2 -0
- package/build/solid/index.js +7 -0
- package/build/solid/primitives/create-permissions.d.ts +8 -0
- package/build/solid/primitives/create-permissions.js +55 -0
- package/build/svelte/index.d.ts +2 -0
- package/build/svelte/index.js +6 -0
- package/build/svelte/runes/use-permissions.svelte.d.ts +7 -0
- package/build/svelte/runes/use-permissions.svelte.js +55 -0
- package/build/vue/composables/use-permissions/index.d.ts +1 -0
- package/build/vue/composables/use-permissions/index.js +12 -2
- package/build/vue/index.d.ts +1 -1
- package/build/vue/index.js +1 -1
- package/build-ngc/angular/index.d.ts +1 -1
- package/build-ngc/angular/index.js +1 -1
- package/build-ngc/angular/index.js.map +1 -1
- package/build-ngc/angular/services/permissions.service/index.d.ts +4 -0
- package/build-ngc/angular/services/permissions.service/index.js +23 -5
- package/build-ngc/angular/services/permissions.service/index.js.map +1 -1
- package/build-ngc/core/brightness.js +1 -1
- package/build-ngc/core/brightness.js.map +1 -1
- package/build-ngc/core/native-module.js.map +1 -1
- package/package.json +42 -14
- package/src/angular/index.ts +1 -20
- package/src/angular/services/permissions.service/index.ts +22 -2
- package/src/core/brightness.ts +41 -11
- package/src/core/native-module.ts +5 -1
- package/src/react/hooks/use-permissions/index.ts +20 -4
- package/src/react/index.ts +1 -20
- package/src/solid/index.ts +7 -0
- package/src/solid/primitives/create-permissions.ts +69 -0
- package/src/svelte/index.ts +7 -0
- package/src/svelte/runes/use-permissions.svelte.ts +69 -0
- package/src/svelte/svelte-ambient.d.ts +6 -0
- package/src/vue/composables/use-permissions/index.ts +13 -2
- package/src/vue/index.ts +1 -20
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Pulls in svelte's ambient global declarations ($state/$effect/...) for this package's tsc
|
|
2
|
+
// program. adapters/svelte gets these for free because render.ts does a real value import from
|
|
3
|
+
// 'svelte' (any file in a program importing a module loads its ambient globals for the whole
|
|
4
|
+
// program); this package has no such import, so a triple-slash reference does the same job
|
|
5
|
+
// explicitly rather than relying on an incidental side-effect.
|
|
6
|
+
/// <reference types="svelte" />
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
// current permission status on mount (mirrors use-battery-level's onMounted/onUnmounted style,
|
|
3
3
|
// but there is no ongoing subscription to tear down here, just a one-shot get), then exposes
|
|
4
4
|
// get/request as imperative callbacks.
|
|
5
|
+
//
|
|
6
|
+
// The mount fetch has nobody to reject to, so its failure lands in the `error` ref instead of
|
|
7
|
+
// escaping as an unhandled rejection: a null status with a non-null error is how a consumer tells
|
|
8
|
+
// "the fetch failed" from "not fetched yet". get()/request() still reject to their direct caller —
|
|
9
|
+
// only the automatic call is made safe.
|
|
5
10
|
import { onMounted, ref, type Ref } from '@vue/runtime-core';
|
|
6
11
|
import {
|
|
7
12
|
getPermissionsAsync,
|
|
@@ -11,26 +16,32 @@ import {
|
|
|
11
16
|
|
|
12
17
|
export function usePermissions(): {
|
|
13
18
|
status: Ref<PermissionResponse | null>;
|
|
19
|
+
error: Ref<Error | null>;
|
|
14
20
|
request: () => Promise<PermissionResponse>;
|
|
15
21
|
get: () => Promise<PermissionResponse>;
|
|
16
22
|
} {
|
|
17
23
|
const status = ref<PermissionResponse | null>(null);
|
|
24
|
+
const error = ref<Error | null>(null);
|
|
18
25
|
|
|
19
26
|
const get = async () => {
|
|
20
27
|
const response = await getPermissionsAsync();
|
|
21
28
|
status.value = response;
|
|
29
|
+
error.value = null;
|
|
22
30
|
return response;
|
|
23
31
|
};
|
|
24
32
|
|
|
25
33
|
const request = async () => {
|
|
26
34
|
const response = await requestPermissionsAsync();
|
|
27
35
|
status.value = response;
|
|
36
|
+
error.value = null;
|
|
28
37
|
return response;
|
|
29
38
|
};
|
|
30
39
|
|
|
31
40
|
onMounted(() => {
|
|
32
|
-
|
|
41
|
+
get().catch((cause: unknown) => {
|
|
42
|
+
error.value = cause instanceof Error ? cause : new Error(String(cause));
|
|
43
|
+
});
|
|
33
44
|
});
|
|
34
45
|
|
|
35
|
-
return { status, request, get };
|
|
46
|
+
return { status, error, request, get };
|
|
36
47
|
}
|
package/src/vue/index.ts
CHANGED
|
@@ -4,23 +4,4 @@
|
|
|
4
4
|
// adapters/vue/src/composables (never `hooks/`, that's React's term).
|
|
5
5
|
|
|
6
6
|
export { usePermissions } from './composables/use-permissions';
|
|
7
|
-
export
|
|
8
|
-
isAvailableAsync,
|
|
9
|
-
getBrightnessAsync,
|
|
10
|
-
setBrightnessAsync,
|
|
11
|
-
getSystemBrightnessAsync,
|
|
12
|
-
setSystemBrightnessAsync,
|
|
13
|
-
restoreSystemBrightnessAsync,
|
|
14
|
-
isUsingSystemBrightnessAsync,
|
|
15
|
-
getSystemBrightnessModeAsync,
|
|
16
|
-
setSystemBrightnessModeAsync,
|
|
17
|
-
getPermissionsAsync,
|
|
18
|
-
requestPermissionsAsync,
|
|
19
|
-
addBrightnessListener,
|
|
20
|
-
BrightnessMode,
|
|
21
|
-
PermissionStatus,
|
|
22
|
-
type BrightnessEvent,
|
|
23
|
-
type PermissionExpiration,
|
|
24
|
-
type PermissionResponse,
|
|
25
|
-
type EventSubscription,
|
|
26
|
-
} from '../core';
|
|
7
|
+
export * from '../core';
|