@oxy.so/services 13.2.0 → 13.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/lib/commonjs/ui/client.js +13 -0
- package/lib/commonjs/ui/client.js.map +1 -1
- package/lib/commonjs/ui/hooks/useAccountTheme.js +182 -0
- package/lib/commonjs/ui/hooks/useAccountTheme.js.map +1 -0
- package/lib/commonjs/ui/hooks/useFileDownloadUrl.js +64 -44
- package/lib/commonjs/ui/hooks/useFileDownloadUrl.js.map +1 -1
- package/lib/module/ui/client.js +1 -0
- package/lib/module/ui/client.js.map +1 -1
- package/lib/module/ui/hooks/useAccountTheme.js +178 -0
- package/lib/module/ui/hooks/useAccountTheme.js.map +1 -0
- package/lib/module/ui/hooks/useFileDownloadUrl.js +64 -44
- package/lib/module/ui/hooks/useFileDownloadUrl.js.map +1 -1
- package/lib/typescript/commonjs/ui/client.d.ts +2 -0
- package/lib/typescript/commonjs/ui/client.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useAccountTheme.d.ts +47 -0
- package/lib/typescript/commonjs/ui/hooks/useAccountTheme.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/useFileDownloadUrl.d.ts +10 -4
- package/lib/typescript/commonjs/ui/hooks/useFileDownloadUrl.d.ts.map +1 -1
- package/lib/typescript/module/ui/client.d.ts +2 -0
- package/lib/typescript/module/ui/client.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useAccountTheme.d.ts +47 -0
- package/lib/typescript/module/ui/hooks/useAccountTheme.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/useFileDownloadUrl.d.ts +10 -4
- package/lib/typescript/module/ui/hooks/useFileDownloadUrl.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/ui/client.ts +2 -0
- package/src/ui/hooks/useAccountTheme.ts +177 -0
- package/src/ui/hooks/useFileDownloadUrl.ts +59 -49
|
@@ -1,63 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { useEffect, useState } from 'react';
|
|
4
|
+
import { useOptionalOxy } from "../context/oxyRuntimeContext.js";
|
|
5
|
+
function isAbsoluteUrl(ref) {
|
|
6
|
+
return ref.startsWith('http://') || ref.startsWith('https://');
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
/**
|
|
5
|
-
*
|
|
10
|
+
* Resolve a file's download URL for the current caller.
|
|
11
|
+
*
|
|
12
|
+
* A URL `assets.url` already resolved is answered in the FIRST render from
|
|
13
|
+
* core's identity-scoped cache (`assets.cachedUrl`): no request, no loading
|
|
14
|
+
* frame. Only a miss resolves asynchronously, through `assets.url`, which
|
|
15
|
+
* returns a scoped media-token stream URL for a private asset. There is no
|
|
16
|
+
* public-CDN fallback: `assets.publicUrl` 404s for private uploads. A
|
|
17
|
+
* reference that is already an absolute `http(s)` URL is returned unchanged.
|
|
6
18
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* `getFileDownloadUrl` is public-CDN-only and 404s for private uploads.
|
|
19
|
+
* For a synchronous, render-only answer (an image resolver, a list row) use
|
|
20
|
+
* `oxyServices.assets.renderUrl`, which reads the same cache.
|
|
10
21
|
*/
|
|
11
22
|
export const useFileDownloadUrl = (oxyServices, fileId, options) => {
|
|
12
|
-
const [url, setUrl] = useState(null);
|
|
13
|
-
const [loading, setLoading] = useState(false);
|
|
14
|
-
const [error, setError] = useState(null);
|
|
15
23
|
const variant = options?.variant;
|
|
16
24
|
const expiresIn = options?.expiresIn;
|
|
25
|
+
// A resolved URL can carry the viewer's scoped media token, so the viewer is
|
|
26
|
+
// part of what was asked: an account switch never shows the previous one's.
|
|
27
|
+
const viewerId = useOptionalOxy()?.user?.id ?? '';
|
|
28
|
+
const request = fileId ? `${viewerId}|${fileId}|${variant ?? ''}|${expiresIn ?? ''}` : null;
|
|
29
|
+
const immediate = !fileId ? null : isAbsoluteUrl(fileId) ? fileId : oxyServices?.assets.cachedUrl(fileId, variant, expiresIn) ?? null;
|
|
30
|
+
const needsResolve = !!fileId && !!oxyServices && immediate === null;
|
|
31
|
+
const [settled, setSettled] = useState(null);
|
|
17
32
|
useEffect(() => {
|
|
18
|
-
if (!fileId)
|
|
19
|
-
setUrl(null);
|
|
20
|
-
setLoading(false);
|
|
21
|
-
setError(null);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (!oxyServices) {
|
|
25
|
-
setUrl(null);
|
|
26
|
-
setLoading(false);
|
|
27
|
-
setError(new Error('OxyServices instance not configured for useFileDownloadUrl'));
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
33
|
+
if (!needsResolve || !fileId || !oxyServices || !request) return;
|
|
30
34
|
let cancelled = false;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
setError(err instanceof Error ? err : new Error(String(err)));
|
|
45
|
-
}
|
|
46
|
-
} finally {
|
|
47
|
-
if (!cancelled) {
|
|
48
|
-
setLoading(false);
|
|
49
|
-
}
|
|
35
|
+
oxyServices.assets.url(fileId, variant, expiresIn).then(url => {
|
|
36
|
+
if (!cancelled) setSettled({
|
|
37
|
+
request,
|
|
38
|
+
url: url || null,
|
|
39
|
+
error: null
|
|
40
|
+
});
|
|
41
|
+
}, err => {
|
|
42
|
+
if (!cancelled) {
|
|
43
|
+
setSettled({
|
|
44
|
+
request,
|
|
45
|
+
url: null,
|
|
46
|
+
error: err instanceof Error ? err : new Error(String(err))
|
|
47
|
+
});
|
|
50
48
|
}
|
|
51
|
-
};
|
|
52
|
-
load();
|
|
49
|
+
});
|
|
53
50
|
return () => {
|
|
54
51
|
cancelled = true;
|
|
55
52
|
};
|
|
56
|
-
}, [fileId, oxyServices, variant, expiresIn]);
|
|
53
|
+
}, [needsResolve, fileId, oxyServices, variant, expiresIn, request]);
|
|
54
|
+
if (!fileId) return {
|
|
55
|
+
url: null,
|
|
56
|
+
loading: false,
|
|
57
|
+
error: null
|
|
58
|
+
};
|
|
59
|
+
if (immediate !== null) return {
|
|
60
|
+
url: immediate,
|
|
61
|
+
loading: false,
|
|
62
|
+
error: null
|
|
63
|
+
};
|
|
64
|
+
if (!oxyServices) {
|
|
65
|
+
return {
|
|
66
|
+
url: null,
|
|
67
|
+
loading: false,
|
|
68
|
+
error: new Error('OxyServices instance not configured for useFileDownloadUrl')
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
// A result settled for another file, variant or expiry is never shown.
|
|
72
|
+
if (settled?.request !== request) return {
|
|
73
|
+
url: null,
|
|
74
|
+
loading: true,
|
|
75
|
+
error: null
|
|
76
|
+
};
|
|
57
77
|
return {
|
|
58
|
-
url,
|
|
59
|
-
loading,
|
|
60
|
-
error
|
|
78
|
+
url: settled.url,
|
|
79
|
+
loading: false,
|
|
80
|
+
error: settled.error
|
|
61
81
|
};
|
|
62
82
|
};
|
|
63
83
|
//# sourceMappingURL=useFileDownloadUrl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useState","useFileDownloadUrl","oxyServices","fileId","options","
|
|
1
|
+
{"version":3,"names":["useEffect","useState","useOptionalOxy","isAbsoluteUrl","ref","startsWith","useFileDownloadUrl","oxyServices","fileId","options","variant","expiresIn","viewerId","user","id","request","immediate","assets","cachedUrl","needsResolve","settled","setSettled","cancelled","url","then","error","err","Error","String","loading"],"sourceRoot":"../../../../src","sources":["ui/hooks/useFileDownloadUrl.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,SAASC,cAAc,QAAQ,iCAA8B;AAmB7D,SAASC,aAAaA,CAACC,GAAW,EAAW;EAC3C,OAAOA,GAAG,CAACC,UAAU,CAAC,SAAS,CAAC,IAAID,GAAG,CAACC,UAAU,CAAC,UAAU,CAAC;AAChE;;AAEA;AACA;AACA;AACA;AACA;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AI,CAACJ,SAAS,EAAE;QACdD,UAAU,CAAC;UACTN,OAAO;UACPQ,GAAG,EAAE,IAAI;UACTE,KAAK,EAAEC,GAAG,YAAYC,KAAK,GAAGD,GAAG,GAAG,IAAIC,KAAK,CAACC,MAAM,CAACF,GAAG,CAAC;QAC3D,CAAC,CAAC;MACJ;IACF,CACF,CAAC;IACD,OAAO,MAAM;MACXJ,SAAS,GAAG,IAAI;IAClB,CAAC;EACH,CAAC,EAAE,CAACH,YAAY,EAAEX,MAAM,EAAED,WAAW,EAAEG,OAAO,EAAEC,SAAS,EAAEI,OAAO,CAAC,CAAC;EAEpE,IAAI,CAACP,MAAM,EAAE,OAAO;IAAEe,GAAG,EAAE,IAAI;IAAEM,OAAO,EAAE,KAAK;IAAEJ,KAAK,EAAE;EAAK,CAAC;EAC9D,IAAIT,SAAS,KAAK,IAAI,EAAE,OAAO;IAAEO,GAAG,EAAEP,SAAS;IAAEa,OAAO,EAAE,KAAK;IAAEJ,KAAK,EAAE;EAAK,CAAC;EAC9E,IAAI,CAAClB,WAAW,EAAE;IAChB,OAAO;MACLgB,GAAG,EAAE,IAAI;MACTM,OAAO,EAAE,KAAK;MACdJ,KAAK,EAAE,IAAIE,KAAK,CAAC,4DAA4D;IAC/E,CAAC;EACH;EACA;EACA,IAAIP,OAAO,EAAEL,OAAO,KAAKA,OAAO,EAAE,OAAO;IAAEQ,GAAG,EAAE,IAAI;IAAEM,OAAO,EAAE,IAAI;IAAEJ,KAAK,EAAE;EAAK,CAAC;EAClF,OAAO;IAAEF,GAAG,EAAEH,OAAO,CAACG,GAAG;IAAEM,OAAO,EAAE,KAAK;IAAEJ,KAAK,EAAEL,OAAO,CAACK;EAAM,CAAC;AACnE,CAAC","ignoreList":[]}
|
|
@@ -36,6 +36,8 @@ export type { OxyPayButtonProps } from './components/OxyPayButton';
|
|
|
36
36
|
export { useOxy, useOptionalOxy, OxyProviderMissingError } from './context/OxyContext';
|
|
37
37
|
export { useAuth } from './hooks/useAuth';
|
|
38
38
|
export { useAccountColor, useAccountColorSave, resolveAccountColor, entitledAccountColors, } from './hooks/useAccountColor';
|
|
39
|
+
export { useAccountTheme, useAccountThemeControls } from './hooks/useAccountTheme';
|
|
40
|
+
export type { AccountThemeControls, ThemeSource } from './hooks/useAccountTheme';
|
|
39
41
|
export { useAppAssertion, AppAssertionProviderMissingError, } from './appAssertion/AppAssertionContext';
|
|
40
42
|
export type { UseAppAssertionResult } from './appAssertion/AppAssertionContext';
|
|
41
43
|
export type { AppAssertionSnapshot, AppAssertionStatus } from './appAssertion/appAssertionManager';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/ui/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,qBAAqB,CAAC;AAG7B,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACtE,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,YAAY,EACV,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,YAAY,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC/E,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,YAA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,CAAC;AAClC,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/E,OAAO,EACL,SAAS,EACT,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,8BAA8B,EAC9B,4BAA4B,GAC7B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,8BAA8B,EAC9B,8BAA8B,GAC/B,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useAccountTheme / useAccountThemeControls
|
|
3
|
+
*
|
|
4
|
+
* The Oxy account carries a portable theme (`user.themePreference`: a mode and
|
|
5
|
+
* a colour preset) that every Oxy app can wear. The COLOUR is the account
|
|
6
|
+
* colour and always applies (`useAccountColor`). Whether an app also follows
|
|
7
|
+
* the account's MODE is the viewer's choice per device: the theme SOURCE.
|
|
8
|
+
*
|
|
9
|
+
* - `account` (the default): the account's mode is applied to Bloom, and a mode
|
|
10
|
+
* chosen here is written back to the account for the other Oxy apps.
|
|
11
|
+
* - `app`: the mode stays on this device; nothing is written to the account.
|
|
12
|
+
*
|
|
13
|
+
* The source is a local preference, never sent anywhere. On web it is read
|
|
14
|
+
* synchronously, so the first paint already knows it; on native it resolves
|
|
15
|
+
* from AsyncStorage right after mount. Bloom's own persistence still paints the
|
|
16
|
+
* last theme instantly on cold boot, so the account theme lands without a flash
|
|
17
|
+
* once the session resolves.
|
|
18
|
+
*/
|
|
19
|
+
import { type AppColorName, type ThemeMode } from '@oxy.so/bloom/theme';
|
|
20
|
+
/** Where the app's theme MODE comes from on this device. */
|
|
21
|
+
export type ThemeSource = 'app' | 'account';
|
|
22
|
+
/**
|
|
23
|
+
* Apply the account theme to Bloom: the colour always (through
|
|
24
|
+
* `useAccountColor`, which `canUse` can narrow), the mode while this device's
|
|
25
|
+
* source is `account`. Mount ONCE, inside `OxyProvider` and Bloom's theme
|
|
26
|
+
* provider.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useAccountTheme({ canUse, }?: {
|
|
29
|
+
canUse?: (name: AppColorName) => boolean;
|
|
30
|
+
}): void;
|
|
31
|
+
export interface AccountThemeControls {
|
|
32
|
+
/** The effective source: `app` whenever no session can reach the account. */
|
|
33
|
+
source: ThemeSource;
|
|
34
|
+
/** Switch this device's source; enabling `account` seeds an account with no theme yet. */
|
|
35
|
+
changeThemeSource: (source: ThemeSource) => void;
|
|
36
|
+
/** Change the mode now; on the `account` source, also write it to the account. */
|
|
37
|
+
changeThemeMode: (mode: ThemeMode) => Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Source-aware theme mode changes for a settings screen. Bloom changes at once;
|
|
41
|
+
* on the `account` source the account's portable theme follows. Without a
|
|
42
|
+
* usable session the effective source is `app`, so changes stay local, and the
|
|
43
|
+
* stored choice applies again once signed in. The colour is chosen with
|
|
44
|
+
* `useAccountColorSave`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function useAccountThemeControls(): AccountThemeControls;
|
|
47
|
+
//# sourceMappingURL=useAccountTheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAccountTheme.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useAccountTheme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,OAAO,EAAiB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAMvF,4DAA4D;AAC5D,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,SAAS,CAAC;AA4D5C;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,EAC9B,MAAM,GACP,GAAE;IACD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;CACrC,GAAG,IAAI,CAiBZ;AAED,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,MAAM,EAAE,WAAW,CAAC;IACpB,0FAA0F;IAC1F,iBAAiB,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IACjD,kFAAkF;IAClF,eAAe,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,IAAI,oBAAoB,CA0C9D"}
|
|
@@ -9,11 +9,17 @@ export interface UseFileDownloadUrlResult {
|
|
|
9
9
|
error: Error | null;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Resolve a file's download URL for the current caller.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* A URL `assets.url` already resolved is answered in the FIRST render from
|
|
15
|
+
* core's identity-scoped cache (`assets.cachedUrl`): no request, no loading
|
|
16
|
+
* frame. Only a miss resolves asynchronously, through `assets.url`, which
|
|
17
|
+
* returns a scoped media-token stream URL for a private asset. There is no
|
|
18
|
+
* public-CDN fallback: `assets.publicUrl` 404s for private uploads. A
|
|
19
|
+
* reference that is already an absolute `http(s)` URL is returned unchanged.
|
|
20
|
+
*
|
|
21
|
+
* For a synchronous, render-only answer (an image resolver, a list row) use
|
|
22
|
+
* `oxyServices.assets.renderUrl`, which reads the same cache.
|
|
17
23
|
*/
|
|
18
24
|
export declare const useFileDownloadUrl: (oxyServices: OxyServices | null | undefined, fileId: string | null | undefined, options?: UseFileDownloadUrlOptions) => UseFileDownloadUrlResult;
|
|
19
25
|
//# sourceMappingURL=useFileDownloadUrl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFileDownloadUrl.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useFileDownloadUrl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"useFileDownloadUrl.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useFileDownloadUrl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAYD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,GAC7B,aAAa,WAAW,GAAG,IAAI,GAAG,SAAS,EAC3C,QAAQ,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,UAAU,yBAAyB,KAClC,wBAkDF,CAAC"}
|
|
@@ -36,6 +36,8 @@ export type { OxyPayButtonProps } from './components/OxyPayButton.js';
|
|
|
36
36
|
export { useOxy, useOptionalOxy, OxyProviderMissingError } from './context/OxyContext.js';
|
|
37
37
|
export { useAuth } from './hooks/useAuth.js';
|
|
38
38
|
export { useAccountColor, useAccountColorSave, resolveAccountColor, entitledAccountColors, } from './hooks/useAccountColor.js';
|
|
39
|
+
export { useAccountTheme, useAccountThemeControls } from './hooks/useAccountTheme.js';
|
|
40
|
+
export type { AccountThemeControls, ThemeSource } from './hooks/useAccountTheme.js';
|
|
39
41
|
export { useAppAssertion, AppAssertionProviderMissingError, } from './appAssertion/AppAssertionContext.js';
|
|
40
42
|
export type { UseAppAssertionResult } from './appAssertion/AppAssertionContext.js';
|
|
41
43
|
export type { AppAssertionSnapshot, AppAssertionStatus } from './appAssertion/appAssertionManager.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/ui/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,wBAAqB,CAAC;AAG7B,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,6BAA0B,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,iCAA8B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,+BAA4B,CAAC;AACtE,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA4B,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA4B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA4B,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,8BAA2B,CAAC;AACpE,YAAY,EACV,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,8BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAiC,CAAC;AACrE,YAAY,EAAE,uBAAuB,EAAE,MAAM,oCAAiC,CAAC;AAC/E,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,8BAA2B,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA2B,CAAC;AAClE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAsB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,+BAA4B,CAAC;AACtE,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA4B,CAAC;AACrE,OAAO,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,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,8BAA8B,EAC9B,4BAA4B,GAC7B,MAAM,8BAA2B,CAAC;AACnC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,8BAA8B,EAC9B,8BAA8B,GAC/B,MAAM,8BAA2B,CAAC;AACnC,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,8BAA2B,CAAC;AAGnC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAoB,CAAC;AAGlD,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,0BAAuB,CAAC;AAC/B,YAAY,EAAE,sBAAsB,EAAE,MAAM,0BAAuB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useAccountTheme / useAccountThemeControls
|
|
3
|
+
*
|
|
4
|
+
* The Oxy account carries a portable theme (`user.themePreference`: a mode and
|
|
5
|
+
* a colour preset) that every Oxy app can wear. The COLOUR is the account
|
|
6
|
+
* colour and always applies (`useAccountColor`). Whether an app also follows
|
|
7
|
+
* the account's MODE is the viewer's choice per device: the theme SOURCE.
|
|
8
|
+
*
|
|
9
|
+
* - `account` (the default): the account's mode is applied to Bloom, and a mode
|
|
10
|
+
* chosen here is written back to the account for the other Oxy apps.
|
|
11
|
+
* - `app`: the mode stays on this device; nothing is written to the account.
|
|
12
|
+
*
|
|
13
|
+
* The source is a local preference, never sent anywhere. On web it is read
|
|
14
|
+
* synchronously, so the first paint already knows it; on native it resolves
|
|
15
|
+
* from AsyncStorage right after mount. Bloom's own persistence still paints the
|
|
16
|
+
* last theme instantly on cold boot, so the account theme lands without a flash
|
|
17
|
+
* once the session resolves.
|
|
18
|
+
*/
|
|
19
|
+
import { type AppColorName, type ThemeMode } from '@oxy.so/bloom/theme';
|
|
20
|
+
/** Where the app's theme MODE comes from on this device. */
|
|
21
|
+
export type ThemeSource = 'app' | 'account';
|
|
22
|
+
/**
|
|
23
|
+
* Apply the account theme to Bloom: the colour always (through
|
|
24
|
+
* `useAccountColor`, which `canUse` can narrow), the mode while this device's
|
|
25
|
+
* source is `account`. Mount ONCE, inside `OxyProvider` and Bloom's theme
|
|
26
|
+
* provider.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useAccountTheme({ canUse, }?: {
|
|
29
|
+
canUse?: (name: AppColorName) => boolean;
|
|
30
|
+
}): void;
|
|
31
|
+
export interface AccountThemeControls {
|
|
32
|
+
/** The effective source: `app` whenever no session can reach the account. */
|
|
33
|
+
source: ThemeSource;
|
|
34
|
+
/** Switch this device's source; enabling `account` seeds an account with no theme yet. */
|
|
35
|
+
changeThemeSource: (source: ThemeSource) => void;
|
|
36
|
+
/** Change the mode now; on the `account` source, also write it to the account. */
|
|
37
|
+
changeThemeMode: (mode: ThemeMode) => Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Source-aware theme mode changes for a settings screen. Bloom changes at once;
|
|
41
|
+
* on the `account` source the account's portable theme follows. Without a
|
|
42
|
+
* usable session the effective source is `app`, so changes stay local, and the
|
|
43
|
+
* stored choice applies again once signed in. The colour is chosen with
|
|
44
|
+
* `useAccountColorSave`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function useAccountThemeControls(): AccountThemeControls;
|
|
47
|
+
//# sourceMappingURL=useAccountTheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAccountTheme.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useAccountTheme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,OAAO,EAAiB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAMvF,4DAA4D;AAC5D,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,SAAS,CAAC;AA4D5C;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,EAC9B,MAAM,GACP,GAAE;IACD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;CACrC,GAAG,IAAI,CAiBZ;AAED,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,MAAM,EAAE,WAAW,CAAC;IACpB,0FAA0F;IAC1F,iBAAiB,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IACjD,kFAAkF;IAClF,eAAe,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,IAAI,oBAAoB,CA0C9D"}
|
|
@@ -9,11 +9,17 @@ export interface UseFileDownloadUrlResult {
|
|
|
9
9
|
error: Error | null;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Resolve a file's download URL for the current caller.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* A URL `assets.url` already resolved is answered in the FIRST render from
|
|
15
|
+
* core's identity-scoped cache (`assets.cachedUrl`): no request, no loading
|
|
16
|
+
* frame. Only a miss resolves asynchronously, through `assets.url`, which
|
|
17
|
+
* returns a scoped media-token stream URL for a private asset. There is no
|
|
18
|
+
* public-CDN fallback: `assets.publicUrl` 404s for private uploads. A
|
|
19
|
+
* reference that is already an absolute `http(s)` URL is returned unchanged.
|
|
20
|
+
*
|
|
21
|
+
* For a synchronous, render-only answer (an image resolver, a list row) use
|
|
22
|
+
* `oxyServices.assets.renderUrl`, which reads the same cache.
|
|
17
23
|
*/
|
|
18
24
|
export declare const useFileDownloadUrl: (oxyServices: OxyServices | null | undefined, fileId: string | null | undefined, options?: UseFileDownloadUrlOptions) => UseFileDownloadUrlResult;
|
|
19
25
|
//# sourceMappingURL=useFileDownloadUrl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFileDownloadUrl.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useFileDownloadUrl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"useFileDownloadUrl.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useFileDownloadUrl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAYD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,GAC7B,aAAa,WAAW,GAAG,IAAI,GAAG,SAAS,EAC3C,QAAQ,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,UAAU,yBAAyB,KAClC,wBAkDF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxy.so/services",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.3.0",
|
|
4
4
|
"description": "OxyHQ Expo/React Native SDK — UI components, screens, and native features",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
"@commitlint/config-conventional": "^21.2.0",
|
|
161
161
|
"@expo/app-integrity": "~58.0.2",
|
|
162
162
|
"@expo/vector-icons": "^15.0.3",
|
|
163
|
-
"@oxy.so/core": "7.
|
|
163
|
+
"@oxy.so/core": "7.2.0",
|
|
164
164
|
"@react-native-async-storage/async-storage": "^2.0.0",
|
|
165
165
|
"@react-native-community/netinfo": "^12.0.1",
|
|
166
166
|
"@react-native/babel-preset": "^0.88.0",
|
|
@@ -209,13 +209,13 @@
|
|
|
209
209
|
"expo-video": "~58.0.12"
|
|
210
210
|
},
|
|
211
211
|
"//@oxy.so/bloom": "Bloom 11.1.0 adds the shared grouped sections, usage card, subscription plans, frame appearance and overlay navigation APIs used by this SDK. First-party Bloom peers remain open above this tested minimum.",
|
|
212
|
-
"//@oxy.so/core": "Core 6.16.0 supplies `requireServerVerdict` and `onHolderRejected`, with which the cold boot checks a session it painted from the cache; 6.13.0 supplies the `accounts.settings.*` strings (picture, categories) the account settings speak in every language; 6.12.0 supplies `fileManagement.contentLost` and the `lost` file status a lost file is listed with; 6.11.0 supplies the `follow.errors.*` strings the follow error codes are worded with; 6.4.0 the `follow.*` strings the follow buttons read for every verb and language; 6.1.0 the `oxy.auth.email.{startChange,change,remove}` and `oxy.auth.password.remove` the sign-in & security panels call. Keep one Core instance per app; raise this floor with the root catalogue when new runtime APIs are required.",
|
|
212
|
+
"//@oxy.so/core": "Core 7.2.0 supplies `assets.cachedUrl`, with which `useFileDownloadUrl` answers an already-resolved URL in its first render; 6.16.0 supplies `requireServerVerdict` and `onHolderRejected`, with which the cold boot checks a session it painted from the cache; 6.13.0 supplies the `accounts.settings.*` strings (picture, categories) the account settings speak in every language; 6.12.0 supplies `fileManagement.contentLost` and the `lost` file status a lost file is listed with; 6.11.0 supplies the `follow.errors.*` strings the follow error codes are worded with; 6.4.0 the `follow.*` strings the follow buttons read for every verb and language; 6.1.0 the `oxy.auth.email.{startChange,change,remove}` and `oxy.auth.password.remove` the sign-in & security panels call. Keep one Core instance per app; raise this floor with the root catalogue when new runtime APIs are required.",
|
|
213
213
|
"//react-native": "React Native 0.81 to 0.88, React 19.1+ and Expo SDK 54 to 58. The floors are the Expo SDK 54 stack (react-native 0.81.6, react 19.1.4, react-native-web 0.21.4, expo 54.0.38 and the module versions its bundledNativeModules.json pins), which compat/expo-54 installs as an external consumer and checks on every CI run (`bun check.mjs`): every peer here admits that stack, services' published src typechecks against its types, and <OxyProvider> mounts and settles its cold boot on iOS (React Native 0.81), web (react-native-web 0.21) and react-native-macos 0.81 with the native modules macOS lacks absent. Astro, Oxy's browser, runs react-native-macos 0.81 (0.83 is its latest release), which is why the floor is not 0.85. The SDK 56 floors these replaced were the versions current when the ranges were first written, not measurements.",
|
|
214
214
|
"peerDependencies": {
|
|
215
215
|
"@expo/app-integrity": ">=0.1.10 <59.0.0",
|
|
216
216
|
"@expo/vector-icons": "^15.0.3",
|
|
217
217
|
"@oxy.so/bloom": ">=11.1.0",
|
|
218
|
-
"@oxy.so/core": "^7.
|
|
218
|
+
"@oxy.so/core": "^7.2.0",
|
|
219
219
|
"@react-native-async-storage/async-storage": "^2.0.0",
|
|
220
220
|
"@react-native-community/netinfo": ">=11.4.1 <13.0.0",
|
|
221
221
|
"@tanstack/query-async-storage-persister": "^5.101",
|
package/src/ui/client.ts
CHANGED
|
@@ -53,6 +53,8 @@ export {
|
|
|
53
53
|
resolveAccountColor,
|
|
54
54
|
entitledAccountColors,
|
|
55
55
|
} from './hooks/useAccountColor';
|
|
56
|
+
export { useAccountTheme, useAccountThemeControls } from './hooks/useAccountTheme';
|
|
57
|
+
export type { AccountThemeControls, ThemeSource } from './hooks/useAccountTheme';
|
|
56
58
|
// This app's Oxy-signed assertion of which app it is (ADR 0045), for an SDK
|
|
57
59
|
// that attaches it to its own requests without pulling in the account screens.
|
|
58
60
|
export {
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useAccountTheme / useAccountThemeControls
|
|
3
|
+
*
|
|
4
|
+
* The Oxy account carries a portable theme (`user.themePreference`: a mode and
|
|
5
|
+
* a colour preset) that every Oxy app can wear. The COLOUR is the account
|
|
6
|
+
* colour and always applies (`useAccountColor`). Whether an app also follows
|
|
7
|
+
* the account's MODE is the viewer's choice per device: the theme SOURCE.
|
|
8
|
+
*
|
|
9
|
+
* - `account` (the default): the account's mode is applied to Bloom, and a mode
|
|
10
|
+
* chosen here is written back to the account for the other Oxy apps.
|
|
11
|
+
* - `app`: the mode stays on this device; nothing is written to the account.
|
|
12
|
+
*
|
|
13
|
+
* The source is a local preference, never sent anywhere. On web it is read
|
|
14
|
+
* synchronously, so the first paint already knows it; on native it resolves
|
|
15
|
+
* from AsyncStorage right after mount. Bloom's own persistence still paints the
|
|
16
|
+
* last theme instantly on cold boot, so the account theme lands without a flash
|
|
17
|
+
* once the session resolves.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { useCallback, useEffect } from 'react';
|
|
21
|
+
import { create } from 'zustand';
|
|
22
|
+
import { logger, type User } from '@oxy.so/core';
|
|
23
|
+
import { useBloomTheme, type AppColorName, type ThemeMode } from '@oxy.so/bloom/theme';
|
|
24
|
+
import { createPlatformStorage, isReactNative } from '../utils/storageHelpers';
|
|
25
|
+
import { resolveAccountColor, useAccountColor } from './useAccountColor';
|
|
26
|
+
import { useAuth } from './useAuth';
|
|
27
|
+
import { useUpdateProfile } from './mutations/useAccountMutations';
|
|
28
|
+
|
|
29
|
+
/** Where the app's theme MODE comes from on this device. */
|
|
30
|
+
export type ThemeSource = 'app' | 'account';
|
|
31
|
+
|
|
32
|
+
type PortableThemeMode = NonNullable<User['themePreference']>['mode'];
|
|
33
|
+
|
|
34
|
+
const THEME_SOURCE_KEY = 'oxy.theme.source';
|
|
35
|
+
|
|
36
|
+
function normalizeSource(stored: string | null | undefined): ThemeSource {
|
|
37
|
+
return stored === 'app' ? 'app' : 'account';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Bloom's richer mode set onto the portable subset the account stores
|
|
42
|
+
* (`adaptive` has no cross-app meaning, so it is `system`).
|
|
43
|
+
*/
|
|
44
|
+
function toPortableMode(mode: ThemeMode): PortableThemeMode {
|
|
45
|
+
return mode === 'light' || mode === 'dark' ? mode : 'system';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Web reads `localStorage` synchronously; native resolves in `hydrate`. */
|
|
49
|
+
function readInitialSource(): { source: ThemeSource; hydrated: boolean } {
|
|
50
|
+
if (isReactNative() || typeof window === 'undefined') {
|
|
51
|
+
return { source: 'account', hydrated: false };
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
return {
|
|
55
|
+
source: normalizeSource(window.localStorage?.getItem(THEME_SOURCE_KEY)),
|
|
56
|
+
hydrated: true,
|
|
57
|
+
};
|
|
58
|
+
} catch {
|
|
59
|
+
// A sandboxed document's storage getter throws: no stored choice.
|
|
60
|
+
return { source: 'account', hydrated: true };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface ThemeSourceState {
|
|
65
|
+
source: ThemeSource;
|
|
66
|
+
/** True once the stored source is known (at once on web). */
|
|
67
|
+
hydrated: boolean;
|
|
68
|
+
setSource: (source: ThemeSource) => void;
|
|
69
|
+
hydrate: () => Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const useThemeSourceStore = create<ThemeSourceState>((set, get) => ({
|
|
73
|
+
...readInitialSource(),
|
|
74
|
+
setSource(source) {
|
|
75
|
+
set({ source, hydrated: true });
|
|
76
|
+
void createPlatformStorage()
|
|
77
|
+
.then((storage) => storage.setItem(THEME_SOURCE_KEY, source))
|
|
78
|
+
.catch(() => undefined);
|
|
79
|
+
},
|
|
80
|
+
async hydrate() {
|
|
81
|
+
if (get().hydrated) return;
|
|
82
|
+
const stored = await createPlatformStorage()
|
|
83
|
+
.then((storage) => storage.getItem(THEME_SOURCE_KEY))
|
|
84
|
+
.catch(() => null);
|
|
85
|
+
// A choice made while storage was being read wins over the stored one.
|
|
86
|
+
if (!get().hydrated) set({ source: normalizeSource(stored), hydrated: true });
|
|
87
|
+
},
|
|
88
|
+
}));
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Apply the account theme to Bloom: the colour always (through
|
|
92
|
+
* `useAccountColor`, which `canUse` can narrow), the mode while this device's
|
|
93
|
+
* source is `account`. Mount ONCE, inside `OxyProvider` and Bloom's theme
|
|
94
|
+
* provider.
|
|
95
|
+
*/
|
|
96
|
+
export function useAccountTheme({
|
|
97
|
+
canUse,
|
|
98
|
+
}: {
|
|
99
|
+
canUse?: (name: AppColorName) => boolean;
|
|
100
|
+
} = {}): void {
|
|
101
|
+
const { isAuthenticated, user } = useAuth();
|
|
102
|
+
const source = useThemeSourceStore((state) => state.source);
|
|
103
|
+
const hydrated = useThemeSourceStore((state) => state.hydrated);
|
|
104
|
+
const hydrate = useThemeSourceStore((state) => state.hydrate);
|
|
105
|
+
const { setMode } = useBloomTheme();
|
|
106
|
+
useAccountColor({ canUse });
|
|
107
|
+
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
void hydrate();
|
|
110
|
+
}, [hydrate]);
|
|
111
|
+
|
|
112
|
+
const accountMode = user?.themePreference?.mode;
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (!hydrated || !isAuthenticated || source !== 'account' || !accountMode) return;
|
|
115
|
+
setMode(accountMode);
|
|
116
|
+
}, [hydrated, isAuthenticated, source, accountMode, setMode]);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface AccountThemeControls {
|
|
120
|
+
/** The effective source: `app` whenever no session can reach the account. */
|
|
121
|
+
source: ThemeSource;
|
|
122
|
+
/** Switch this device's source; enabling `account` seeds an account with no theme yet. */
|
|
123
|
+
changeThemeSource: (source: ThemeSource) => void;
|
|
124
|
+
/** Change the mode now; on the `account` source, also write it to the account. */
|
|
125
|
+
changeThemeMode: (mode: ThemeMode) => Promise<void>;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Source-aware theme mode changes for a settings screen. Bloom changes at once;
|
|
130
|
+
* on the `account` source the account's portable theme follows. Without a
|
|
131
|
+
* usable session the effective source is `app`, so changes stay local, and the
|
|
132
|
+
* stored choice applies again once signed in. The colour is chosen with
|
|
133
|
+
* `useAccountColorSave`.
|
|
134
|
+
*/
|
|
135
|
+
export function useAccountThemeControls(): AccountThemeControls {
|
|
136
|
+
const { user, canUsePrivateApi } = useAuth();
|
|
137
|
+
const { mode, colorPreset, setMode } = useBloomTheme();
|
|
138
|
+
const { mutateAsync } = useUpdateProfile();
|
|
139
|
+
const storedSource = useThemeSourceStore((state) => state.source);
|
|
140
|
+
const setSource = useThemeSourceStore((state) => state.setSource);
|
|
141
|
+
const source: ThemeSource = canUsePrivateApi ? storedSource : 'app';
|
|
142
|
+
|
|
143
|
+
const persist = useCallback(
|
|
144
|
+
async (next: { mode: ThemeMode; colorPreset: AppColorName }) => {
|
|
145
|
+
await mutateAsync({
|
|
146
|
+
themePreference: { mode: toPortableMode(next.mode), colorPreset: next.colorPreset },
|
|
147
|
+
});
|
|
148
|
+
},
|
|
149
|
+
[mutateAsync],
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
const changeThemeMode = useCallback(
|
|
153
|
+
async (nextMode: ThemeMode) => {
|
|
154
|
+
setMode(nextMode);
|
|
155
|
+
if (source === 'account') await persist({ mode: nextMode, colorPreset });
|
|
156
|
+
},
|
|
157
|
+
[setMode, source, persist, colorPreset],
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
const accountTheme = user?.themePreference;
|
|
161
|
+
const hasAccountTheme =
|
|
162
|
+
!!accountTheme && resolveAccountColor({ themePreference: accountTheme }) !== null;
|
|
163
|
+
const changeThemeSource = useCallback(
|
|
164
|
+
(nextSource: ThemeSource) => {
|
|
165
|
+
setSource(nextSource);
|
|
166
|
+
// An existing account theme is applied by `useAccountTheme`; only an
|
|
167
|
+
// account without one is seeded, from what the viewer sees now.
|
|
168
|
+
if (nextSource !== 'account' || !canUsePrivateApi || hasAccountTheme) return;
|
|
169
|
+
persist({ mode, colorPreset }).catch((error: unknown) => {
|
|
170
|
+
logger.error('Failed to seed the account theme', error);
|
|
171
|
+
});
|
|
172
|
+
},
|
|
173
|
+
[setSource, canUsePrivateApi, hasAccountTheme, persist, mode, colorPreset],
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
return { source, changeThemeSource, changeThemeMode };
|
|
177
|
+
}
|