@symbiote-native/tracking-transparency 3.0.2 → 3.1.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.
Files changed (62) hide show
  1. package/README.md +78 -73
  2. package/build/angular/index.d.ts +1 -1
  3. package/build/angular/index.js +2 -3
  4. package/build/angular/tracking-permissions.service.d.ts +5 -0
  5. package/build/angular/{services/permissions.service/index.js → tracking-permissions.service.js} +13 -48
  6. package/build/core/tracking-permission-api.d.ts +5 -0
  7. package/build/core/tracking-permission-api.js +7 -0
  8. package/build/react/index.d.ts +1 -1
  9. package/build/react/index.js +2 -5
  10. package/build/react/use-tracking-permissions.d.ts +8 -0
  11. package/build/react/use-tracking-permissions.js +4 -0
  12. package/build/solid/index.d.ts +1 -1
  13. package/build/solid/index.js +2 -6
  14. package/build/solid/use-tracking-permissions.d.ts +9 -0
  15. package/build/solid/use-tracking-permissions.js +4 -0
  16. package/build/svelte/index.d.ts +1 -1
  17. package/build/svelte/index.js +2 -5
  18. package/build/svelte/use-tracking-permissions.svelte.d.ts +8 -0
  19. package/build/svelte/use-tracking-permissions.svelte.js +4 -0
  20. package/build/vue/index.d.ts +1 -1
  21. package/build/vue/index.js +2 -5
  22. package/build/vue/use-tracking-permissions.d.ts +9 -0
  23. package/build/vue/use-tracking-permissions.js +4 -0
  24. package/build-ngc/angular/index.d.ts +1 -1
  25. package/build-ngc/angular/index.js +2 -3
  26. package/build-ngc/angular/index.js.map +1 -1
  27. package/build-ngc/angular/tracking-permissions.service.d.ts +8 -0
  28. package/build-ngc/angular/tracking-permissions.service.js +17 -0
  29. package/build-ngc/angular/tracking-permissions.service.js.map +1 -0
  30. package/build-ngc/core/tracking-permission-api.d.ts +5 -0
  31. package/build-ngc/core/tracking-permission-api.js +8 -0
  32. package/build-ngc/core/tracking-permission-api.js.map +1 -0
  33. package/package.json +15 -15
  34. package/src/angular/index.ts +2 -3
  35. package/src/angular/tracking-permissions.service.ts +16 -0
  36. package/src/core/tracking-permission-api.ts +12 -0
  37. package/src/react/index.ts +5 -6
  38. package/src/react/use-tracking-permissions.ts +16 -0
  39. package/src/solid/index.ts +5 -7
  40. package/src/solid/use-tracking-permissions.ts +17 -0
  41. package/src/svelte/index.ts +5 -6
  42. package/src/svelte/svelte-compile.test-helper.ts +6 -0
  43. package/src/svelte/use-tracking-permissions.svelte.ts +16 -0
  44. package/src/vue/index.ts +5 -6
  45. package/src/vue/use-tracking-permissions.ts +17 -0
  46. package/build/angular/services/permissions.service/index.d.ts +0 -12
  47. package/build/react/hooks/use-permissions/index.d.ts +0 -7
  48. package/build/react/hooks/use-permissions/index.js +0 -43
  49. package/build/solid/primitives/create-permissions.d.ts +0 -8
  50. package/build/solid/primitives/create-permissions.js +0 -41
  51. package/build/svelte/runes/use-permissions.svelte.d.ts +0 -7
  52. package/build/svelte/runes/use-permissions.svelte.js +0 -49
  53. package/build/vue/composables/use-permissions/index.d.ts +0 -8
  54. package/build/vue/composables/use-permissions/index.js +0 -33
  55. package/build-ngc/angular/services/permissions.service/index.d.ts +0 -15
  56. package/build-ngc/angular/services/permissions.service/index.js +0 -55
  57. package/build-ngc/angular/services/permissions.service/index.js.map +0 -1
  58. package/src/angular/services/permissions.service/index.ts +0 -57
  59. package/src/react/hooks/use-permissions/index.ts +0 -57
  60. package/src/solid/primitives/create-permissions.ts +0 -56
  61. package/src/svelte/runes/use-permissions.svelte.ts +0 -63
  62. package/src/vue/composables/use-permissions/index.ts +0 -47
@@ -1,57 +0,0 @@
1
- // React lifecycle wiring over the framework-agnostic core (core/tracking-transparency.ts) —
2
- // auto-fetches the current permission status on mount, then exposes get/request as imperative
3
- // callbacks. Mirrors the shape @symbiote-native/cellular's own usePermissions ships in parallel,
4
- // so both stay byte-for-byte consistent.
5
- //
6
- // The mount fetch has nobody to reject to, so its failure lands in the 4th tuple slot (`error`)
7
- // instead of escaping as an unhandled rejection: a null status with a non-null error is how a
8
- // consumer tells "the fetch failed" from "not fetched yet". get()/request() still reject to their
9
- // direct caller — only the automatic call is made safe.
10
- import { useCallback, useEffect, useRef, useState } from 'react';
11
- import {
12
- getTrackingPermissionsAsync,
13
- requestTrackingPermissionsAsync,
14
- type PermissionResponse,
15
- } from '../../../core';
16
-
17
- export function usePermissions(): [
18
- PermissionResponse | null,
19
- () => Promise<PermissionResponse>,
20
- () => Promise<PermissionResponse>,
21
- Error | null,
22
- ] {
23
- const isMounted = useRef(true);
24
- const [status, setStatus] = useState<PermissionResponse | null>(null);
25
- const [error, setError] = useState<Error | null>(null);
26
-
27
- const getPermission = useCallback(async () => {
28
- const response = await getTrackingPermissionsAsync();
29
- if (isMounted.current) {
30
- setStatus(response);
31
- setError(null);
32
- }
33
- return response;
34
- }, []);
35
-
36
- const requestPermission = useCallback(async () => {
37
- const response = await requestTrackingPermissionsAsync();
38
- if (isMounted.current) {
39
- setStatus(response);
40
- setError(null);
41
- }
42
- return response;
43
- }, []);
44
-
45
- useEffect(() => {
46
- isMounted.current = true;
47
- getPermission().catch((cause: unknown) => {
48
- if (isMounted.current)
49
- setError(cause instanceof Error ? cause : new Error(String(cause)));
50
- });
51
- return () => {
52
- isMounted.current = false;
53
- };
54
- }, [getPermission]);
55
-
56
- return [status, requestPermission, getPermission, error];
57
- }
@@ -1,56 +0,0 @@
1
- // createPermissions — the Solid twin of React's `usePermissions` hook, Vue's composable and
2
- // Svelte's rune, over the framework-agnostic core (core/tracking-transparency.ts). Auto-fetches
3
- // the current permission status, then exposes get/request as imperative callbacks.
4
- //
5
- // `primitives/` and `create*`, never `hooks/`+`use*`: Solid's ecosystem calls a composable
6
- // reactive function a PRIMITIVE and reserves `use*` for consuming something that already exists.
7
- // Full rationale in adapters/solid/src/primitives/create-color-scheme.ts.
8
- //
9
- // Returns ACCESSORS, never snapshots: a Solid component body runs ONCE, so returned values would
10
- // pin the caller to the null pre-fetch state forever.
11
- //
12
- // The auto-fetch fires from the primitive body rather than a mount effect — the shape
13
- // `createResource` uses, and the reason this primitive needs no lifecycle hook at all. Its failure
14
- // lands in `error` instead of escaping as an unhandled rejection: a null status with a non-null
15
- // error is how a consumer tells "the fetch failed" from "not fetched yet". get()/request() still
16
- // reject to their direct caller — only the automatic call is made safe.
17
- //
18
- // No isMounted guard around the late write, unlike React's hook: once the owning root is disposed
19
- // nothing is subscribed to these signals any more, so a resolution arriving afterwards is inert.
20
-
21
- import { createSignal, type Accessor } from 'solid-js';
22
- import {
23
- getTrackingPermissionsAsync,
24
- requestTrackingPermissionsAsync,
25
- type PermissionResponse,
26
- } from '../../core';
27
-
28
- export function createPermissions(): {
29
- status: Accessor<PermissionResponse | null>;
30
- error: Accessor<Error | null>;
31
- request: () => Promise<PermissionResponse>;
32
- get: () => Promise<PermissionResponse>;
33
- } {
34
- const [status, setStatus] = createSignal<PermissionResponse | null>(null);
35
- const [error, setError] = createSignal<Error | null>(null);
36
-
37
- const get = async (): Promise<PermissionResponse> => {
38
- const response = await getTrackingPermissionsAsync();
39
- setStatus(response);
40
- setError(null);
41
- return response;
42
- };
43
-
44
- const request = async (): Promise<PermissionResponse> => {
45
- const response = await requestTrackingPermissionsAsync();
46
- setStatus(response);
47
- setError(null);
48
- return response;
49
- };
50
-
51
- get().catch((cause: unknown) => {
52
- setError(cause instanceof Error ? cause : new Error(String(cause)));
53
- });
54
-
55
- return { status, error, request, get };
56
- }
@@ -1,63 +0,0 @@
1
- // Svelte lifecycle wiring over the framework-agnostic core (core/tracking-transparency.ts) —
2
- // auto-fetches the current permission status on mount, then exposes get/request as imperative
3
- // callbacks. Just a one-shot get with no ongoing subscription, so `$effect` needs no cleanup.
4
- //
5
- // `.svelte.ts` (not `.ts`): runes ($state/$effect) only work in files with this extension
6
- // outside an actual `.svelte` component. `status` is returned as a getter, NOT a bare
7
- // `$state`: Svelte 5 reactivity is lexically scoped to the declaring module and doesn't
8
- // survive being returned as a raw value from a plain function — mirrors how Vue's `Ref`
9
- // needs `.value` to unwrap.
10
- //
11
- // The mount fetch has nobody to reject to, so its failure lands in `error` (a second boxed getter,
12
- // same reason as `status`) instead of escaping as an unhandled rejection: a null status with a
13
- // non-null error is how a consumer tells "the fetch failed" from "not fetched yet".
14
- // get()/request() still reject to their direct caller — only the automatic call is made safe.
15
- import {
16
- getTrackingPermissionsAsync,
17
- requestTrackingPermissionsAsync,
18
- type PermissionResponse,
19
- } from '../../core';
20
-
21
- export function usePermissions(): {
22
- readonly status: PermissionResponse | null;
23
- readonly error: Error | null;
24
- request: () => Promise<PermissionResponse>;
25
- get: () => Promise<PermissionResponse>;
26
- } {
27
- let status = $state<PermissionResponse | null>(null);
28
- let error = $state<Error | null>(null);
29
-
30
- const get = async (): Promise<PermissionResponse> => {
31
- const response = await getTrackingPermissionsAsync();
32
- status = response;
33
- error = null;
34
- return response;
35
- };
36
-
37
- const request = async (): Promise<PermissionResponse> => {
38
- const response = await requestTrackingPermissionsAsync();
39
- status = response;
40
- error = null;
41
- return response;
42
- };
43
-
44
- $effect(() => {
45
- // `get` is a plain closure, not reactive state, so the effect has an empty dependency set and
46
- // runs exactly once on mount — the twin of Vue's onMounted. The catch runs after the effect
47
- // has settled, so writing `error` there adds no dependency and does not re-arm it.
48
- get().catch((cause: unknown) => {
49
- error = cause instanceof Error ? cause : new Error(String(cause));
50
- });
51
- });
52
-
53
- return {
54
- get status(): PermissionResponse | null {
55
- return status;
56
- },
57
- get error(): Error | null {
58
- return error;
59
- },
60
- request,
61
- get,
62
- };
63
- }
@@ -1,47 +0,0 @@
1
- // Vue lifecycle wiring over the framework-agnostic core (core/tracking-transparency.ts) —
2
- // auto-fetches the current permission status on mount (mirrors use-battery-level's
3
- // onMounted/onUnmounted style, but there is no ongoing subscription to tear down here, just a
4
- // one-shot get), then exposes 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.
10
- import { onMounted, ref, type Ref } from '@vue/runtime-core';
11
- import {
12
- getTrackingPermissionsAsync,
13
- requestTrackingPermissionsAsync,
14
- type PermissionResponse,
15
- } from '../../../core';
16
-
17
- export function usePermissions(): {
18
- status: Ref<PermissionResponse | null>;
19
- error: Ref<Error | null>;
20
- request: () => Promise<PermissionResponse>;
21
- get: () => Promise<PermissionResponse>;
22
- } {
23
- const status = ref<PermissionResponse | null>(null);
24
- const error = ref<Error | null>(null);
25
-
26
- const get = async () => {
27
- const response = await getTrackingPermissionsAsync();
28
- status.value = response;
29
- error.value = null;
30
- return response;
31
- };
32
-
33
- const request = async () => {
34
- const response = await requestTrackingPermissionsAsync();
35
- status.value = response;
36
- error.value = null;
37
- return response;
38
- };
39
-
40
- onMounted(() => {
41
- get().catch((cause: unknown) => {
42
- error.value = cause instanceof Error ? cause : new Error(String(cause));
43
- });
44
- });
45
-
46
- return { status, error, request, get };
47
- }