@oxy.so/services 12.6.0 → 12.7.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/useAccountColor.js +56 -0
- package/lib/commonjs/ui/hooks/useAccountColor.js.map +1 -0
- package/lib/module/ui/client.js +1 -0
- package/lib/module/ui/client.js.map +1 -1
- package/lib/module/ui/hooks/useAccountColor.js +51 -0
- package/lib/module/ui/hooks/useAccountColor.js.map +1 -0
- package/lib/typescript/commonjs/ui/client.d.ts +1 -0
- package/lib/typescript/commonjs/ui/client.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useAccountColor.d.ts +25 -0
- package/lib/typescript/commonjs/ui/hooks/useAccountColor.d.ts.map +1 -0
- package/lib/typescript/module/ui/client.d.ts +1 -0
- package/lib/typescript/module/ui/client.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useAccountColor.d.ts +25 -0
- package/lib/typescript/module/ui/hooks/useAccountColor.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/ui/client.ts +1 -0
- package/src/ui/hooks/useAccountColor.ts +52 -0
|
@@ -207,6 +207,12 @@ Object.defineProperty(exports, "queryKeys", {
|
|
|
207
207
|
return _queryKeys.queryKeys;
|
|
208
208
|
}
|
|
209
209
|
});
|
|
210
|
+
Object.defineProperty(exports, "resolveAccountColor", {
|
|
211
|
+
enumerable: true,
|
|
212
|
+
get: function () {
|
|
213
|
+
return _useAccountColor.resolveAccountColor;
|
|
214
|
+
}
|
|
215
|
+
});
|
|
210
216
|
Object.defineProperty(exports, "resolveFollowPrimaryAction", {
|
|
211
217
|
enumerable: true,
|
|
212
218
|
get: function () {
|
|
@@ -231,6 +237,12 @@ Object.defineProperty(exports, "upsertCachedUsers", {
|
|
|
231
237
|
return _userCache.upsertCachedUsers;
|
|
232
238
|
}
|
|
233
239
|
});
|
|
240
|
+
Object.defineProperty(exports, "useAccountColor", {
|
|
241
|
+
enumerable: true,
|
|
242
|
+
get: function () {
|
|
243
|
+
return _useAccountColor.useAccountColor;
|
|
244
|
+
}
|
|
245
|
+
});
|
|
234
246
|
Object.defineProperty(exports, "useAppAssertion", {
|
|
235
247
|
enumerable: true,
|
|
236
248
|
get: function () {
|
|
@@ -394,6 +406,7 @@ var _PeableButton = _interopRequireDefault(require("./components/PeableButton.js
|
|
|
394
406
|
var _OxyPayButton = _interopRequireDefault(require("./components/OxyPayButton.js"));
|
|
395
407
|
var _OxyContext = require("./context/OxyContext.js");
|
|
396
408
|
var _useAuth = require("./hooks/useAuth.js");
|
|
409
|
+
var _useAccountColor = require("./hooks/useAccountColor.js");
|
|
397
410
|
var _AppAssertionContext = require("./appAssertion/AppAssertionContext.js");
|
|
398
411
|
var _productAnalytics = require("./analytics/productAnalytics.js");
|
|
399
412
|
var _useFollow = require("./hooks/useFollow.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["require","_OxyProvider","_interopRequireDefault","_OxySignInButton","_OxyAuthPrompt","_LogoIcon","_LogoText","_FollowButton","_FollowTargetButton","_ProfileButton","_PeableButton","_OxyPayButton","_OxyContext","_useAuth","_AppAssertionContext","_productAnalytics","_useFollow","_useFollowTarget","_useSupervision","_useAccountQueries","_useStorage","_useOxyEvent","_useAccountMutations","_useFileDownloadUrl","_useMutationStatus","_useOnlineStatus","_useDisplayCurrency","_useDisplayPrice","_DisplayCurrencySelector","_followRules","_queryKeys","_userCache","_authStore","_errorHandlers","e","__esModule","default"],"sourceRoot":"../../../src","sources":["ui/client.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["require","_OxyProvider","_interopRequireDefault","_OxySignInButton","_OxyAuthPrompt","_LogoIcon","_LogoText","_FollowButton","_FollowTargetButton","_ProfileButton","_PeableButton","_OxyPayButton","_OxyContext","_useAuth","_useAccountColor","_AppAssertionContext","_productAnalytics","_useFollow","_useFollowTarget","_useSupervision","_useAccountQueries","_useStorage","_useOxyEvent","_useAccountMutations","_useFileDownloadUrl","_useMutationStatus","_useOnlineStatus","_useDisplayCurrency","_useDisplayPrice","_DisplayCurrencySelector","_followRules","_queryKeys","_userCache","_authStore","_errorHandlers","e","__esModule","default"],"sourceRoot":"../../../src","sources":["ui/client.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeAA,OAAA;AAGA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,cAAA,GAAAF,sBAAA,CAAAF,OAAA;AAEA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAL,sBAAA,CAAAF,OAAA;AAMA,IAAAQ,mBAAA,GAAAR,OAAA;AAGA,IAAAS,cAAA,GAAAP,sBAAA,CAAAF,OAAA;AAEA,IAAAU,aAAA,GAAAR,sBAAA,CAAAF,OAAA;AAGA,IAAAW,aAAA,GAAAT,sBAAA,CAAAF,OAAA;AAKA,IAAAY,WAAA,GAAAZ,OAAA;AAGA,IAAAa,QAAA,GAAAb,OAAA;AACA,IAAAc,gBAAA,GAAAd,OAAA;AAGA,IAAAe,oBAAA,GAAAf,OAAA;AAOA,IAAAgB,iBAAA,GAAAhB,OAAA;AAEA,IAAAiB,UAAA,GAAAjB,OAAA;AACA,IAAAkB,gBAAA,GAAAlB,OAAA;AACA,IAAAmB,eAAA,GAAAnB,OAAA;AAEA,IAAAoB,kBAAA,GAAApB,OAAA;AAOA,IAAAqB,WAAA,GAAArB,OAAA;AAGA,IAAAsB,YAAA,GAAAtB,OAAA;AAKA,IAAAuB,oBAAA,GAAAvB,OAAA;AAKA,IAAAwB,mBAAA,GAAAxB,OAAA;AACA,IAAAyB,kBAAA,GAAAzB,OAAA;AAEA,IAAA0B,gBAAA,GAAA1B,OAAA;AACA,IAAA2B,mBAAA,GAAA3B,OAAA;AACA,IAAA4B,gBAAA,GAAA5B,OAAA;AACA,IAAA6B,wBAAA,GAAA7B,OAAA;AAOA,IAAA8B,YAAA,GAAA9B,OAAA;AAQA,IAAA+B,UAAA,GAAA/B,OAAA;AAaA,IAAAgC,UAAA,GAAAhC,OAAA;AAcA,IAAAiC,UAAA,GAAAjC,OAAA;AAGA,IAAAkC,cAAA,GAAAlC,OAAA;AAK+B,SAAAE,uBAAAiC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.resolveAccountColor = resolveAccountColor;
|
|
7
|
+
exports.useAccountColor = useAccountColor;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _theme = require("@oxy.so/bloom/theme");
|
|
10
|
+
var _useAuth = require("./useAuth.js");
|
|
11
|
+
/**
|
|
12
|
+
* useAccountColor
|
|
13
|
+
*
|
|
14
|
+
* The account's colour is one value that every Oxy app wears: `users.color`, a
|
|
15
|
+
* Bloom preset NAME the API only stores after its entitlement check (`oxy` and
|
|
16
|
+
* `faircoin` belong to the account with that handle, `mono` to an active
|
|
17
|
+
* benefit). This hook is the single place an app turns that stored name into its
|
|
18
|
+
* Bloom theme, so two apps cannot disagree about which field wins.
|
|
19
|
+
*
|
|
20
|
+
* The portable `themePreference.colorPreset` is the fallback for an account that
|
|
21
|
+
* has no `color` yet. Mode (light/dark) is deliberately out of scope: whether to
|
|
22
|
+
* follow the account's mode is each app's own choice, the colour is not.
|
|
23
|
+
*
|
|
24
|
+
* An app with a stricter rule of its own (a plan the SDK cannot see) passes
|
|
25
|
+
* `canUse`; a name it refuses is simply not applied, so the app keeps its own
|
|
26
|
+
* default instead of a colour the viewer is not entitled to.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
function isAppColorName(value) {
|
|
30
|
+
return typeof value === 'string' && Object.prototype.hasOwnProperty.call(_theme.APP_COLOR_PRESETS, value);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The preset an account wears, or `null` when it has none Bloom knows. */
|
|
34
|
+
function resolveAccountColor(user) {
|
|
35
|
+
const stored = user?.color ?? user?.themePreference?.colorPreset;
|
|
36
|
+
return isAppColorName(stored) ? stored : null;
|
|
37
|
+
}
|
|
38
|
+
function useAccountColor({
|
|
39
|
+
canUse
|
|
40
|
+
} = {}) {
|
|
41
|
+
const {
|
|
42
|
+
isAuthenticated,
|
|
43
|
+
user
|
|
44
|
+
} = (0, _useAuth.useAuth)();
|
|
45
|
+
const {
|
|
46
|
+
colorPreset,
|
|
47
|
+
setColorPreset
|
|
48
|
+
} = (0, _theme.useBloomTheme)();
|
|
49
|
+
const accountColor = resolveAccountColor(user);
|
|
50
|
+
const allowed = accountColor !== null && (canUse?.(accountColor) ?? true);
|
|
51
|
+
(0, _react.useEffect)(() => {
|
|
52
|
+
if (!isAuthenticated || !accountColor || !allowed || accountColor === colorPreset) return;
|
|
53
|
+
setColorPreset(accountColor);
|
|
54
|
+
}, [isAuthenticated, accountColor, allowed, colorPreset, setColorPreset]);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=useAccountColor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_theme","_useAuth","isAppColorName","value","Object","prototype","hasOwnProperty","call","APP_COLOR_PRESETS","resolveAccountColor","user","stored","color","themePreference","colorPreset","useAccountColor","canUse","isAuthenticated","useAuth","setColorPreset","useBloomTheme","accountColor","allowed","useEffect"],"sourceRoot":"../../../../src","sources":["ui/hooks/useAccountColor.ts"],"mappings":";;;;;;;AAkBA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AArBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASG,cAAcA,CAACC,KAAc,EAAyB;EAC7D,OACE,OAAOA,KAAK,KAAK,QAAQ,IAAIC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACC,wBAAiB,EAAEL,KAAK,CAAC;AAE/F;;AAEA;AACO,SAASM,mBAAmBA,CACjCC,IAAgE,EAC3C;EACrB,MAAMC,MAAM,GAAGD,IAAI,EAAEE,KAAK,IAAIF,IAAI,EAAEG,eAAe,EAAEC,WAAW;EAChE,OAAOZ,cAAc,CAACS,MAAM,CAAC,GAAGA,MAAM,GAAG,IAAI;AAC/C;AAEO,SAASI,eAAeA,CAAC;EAC9BC;AAGF,CAAC,GAAG,CAAC,CAAC,EAAQ;EACZ,MAAM;IAAEC,eAAe;IAAEP;EAAK,CAAC,GAAG,IAAAQ,gBAAO,EAAC,CAAC;EAC3C,MAAM;IAAEJ,WAAW;IAAEK;EAAe,CAAC,GAAG,IAAAC,oBAAa,EAAC,CAAC;EACvD,MAAMC,YAAY,GAAGZ,mBAAmB,CAACC,IAAI,CAAC;EAC9C,MAAMY,OAAO,GAAGD,YAAY,KAAK,IAAI,KAAKL,MAAM,GAAGK,YAAY,CAAC,IAAI,IAAI,CAAC;EAEzE,IAAAE,gBAAS,EAAC,MAAM;IACd,IAAI,CAACN,eAAe,IAAI,CAACI,YAAY,IAAI,CAACC,OAAO,IAAID,YAAY,KAAKP,WAAW,EAAE;IACnFK,cAAc,CAACE,YAAY,CAAC;EAC9B,CAAC,EAAE,CAACJ,eAAe,EAAEI,YAAY,EAAEC,OAAO,EAAER,WAAW,EAAEK,cAAc,CAAC,CAAC;AAC3E","ignoreList":[]}
|
package/lib/module/ui/client.js
CHANGED
|
@@ -36,6 +36,7 @@ export { useOxy, useOptionalOxy, OxyProviderMissingError } from "./context/OxyCo
|
|
|
36
36
|
|
|
37
37
|
// Hooks
|
|
38
38
|
export { useAuth } from "./hooks/useAuth.js";
|
|
39
|
+
export { useAccountColor, resolveAccountColor } from "./hooks/useAccountColor.js";
|
|
39
40
|
// This app's Oxy-signed assertion of which app it is (ADR 0045), for an SDK
|
|
40
41
|
// that attaches it to its own requests without pulling in the account screens.
|
|
41
42
|
export { useAppAssertion, AppAssertionProviderMissingError } from "./appAssertion/AppAssertionContext.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","OxyProvider","OxySignInButton","OxyAuthPrompt","LogoIcon","LogoText","FollowButton","FollowTargetButton","ProfileButton","PeableButton","OxyPayButton","useOxy","useOptionalOxy","OxyProviderMissingError","useAuth","useAppAssertion","AppAssertionProviderMissingError","createDeferredProductAnalytics","useFollow","useFollowerCounts","useSeedFollowStatuses","useFollowTarget","useSupervision","supervisionQueryKeys","useUserProfile","useUserProfiles","useCurrentUser","useUserById","useUserByUsername","useStorage","useOxyEvent","useUpdateProfile","useUploadAvatar","useUploadFile","useFileDownloadUrl","useMutationStatus","useOnlineStatus","useDisplayCurrency","useDisplayPrice","DisplayCurrencySelector","buildFollowMenuItems","resolveFollowPrimaryAction","FOLLOW_ACTION_LEAVES_ACTIVE","queryKeys","invalidateAccountQueries","invalidateUserQueries","invalidateSessionQueries","invalidateDeviceQueries","invalidatePrivacyQueries","invalidateSecurityQueries","invalidateStorageQueries","invalidatePaymentsQueries","invalidateConnectedAppsQueries","invalidateAuthMethodsQueries","upsertCachedUser","upsertCachedUsers","CLEARABLE_USER_FIELDS","clearedFieldsFromProfileUpdate","clearedFieldsFromAccountUpdate","useAuthStore","handleAuthError","isInvalidSessionError","isTimeoutOrNetworkError","extractErrorMessage"],"sourceRoot":"../../../src","sources":["ui/client.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO,wBAAqB;;AAE5B;AACA,SAASA,OAAO,IAAIC,WAAW,QAAQ,6BAA0B;AACjE,SAASD,OAAO,IAAIE,eAAe,QAAQ,iCAA8B;AACzE,SAASF,OAAO,IAAIG,aAAa,QAAQ,+BAA4B;AAErE,SAASC,QAAQ,QAAQ,+BAA4B;AACrD,SAASC,QAAQ,QAAQ,+BAA4B;AACrD,SAASL,OAAO,IAAIM,YAAY,QAAQ,8BAA2B;AAMnE,SAASC,kBAAkB,QAAQ,oCAAiC;AAGpE,SAASP,OAAO,IAAIQ,aAAa,QAAQ,+BAA4B;AAErE,SAASR,OAAO,IAAIS,YAAY,QAAQ,8BAA2B;AAEnE;AACA,SAAST,OAAO,IAAIU,YAAY,QAAQ,8BAA2B;AACnE;;AAGA;AACA,SAASC,MAAM,EAAEC,cAAc,EAAEC,uBAAuB,QAAQ,yBAAsB;;AAEtF;AACA,SAASC,OAAO,QAAQ,oBAAiB;AACzC;AACA;AACA,SACEC,eAAe,EACfC,gCAAgC,QAC3B,uCAAoC;AAI3C,SAASC,8BAA8B,QAAQ,iCAA8B;AAE7E,SAASC,SAAS,EAAEC,iBAAiB,EAAEC,qBAAqB,QAAQ,sBAAmB;AACvF,SAASC,eAAe,QAAQ,4BAAyB;AACzD,SAASC,cAAc,EAAEC,oBAAoB,QAAQ,mCAAgC;AAErF,SACEC,cAAc,EACdC,eAAe,EACfC,cAAc,EACdC,WAAW,EACXC,iBAAiB,QACZ,sCAAmC;AAC1C,SAASC,UAAU,QAAQ,uBAAoB;AAC/C;AACA;AACA,SAASC,WAAW,QAAQ,wBAAqB;AACjD;AACA;AACA;AACA;AACA,SACEC,gBAAgB,EAChBC,eAAe,EACfC,aAAa,QACR,0CAAuC;AAC9C,SAASC,kBAAkB,QAAQ,+BAA4B;AAC/D,SAASC,iBAAiB,QAAQ,8BAA2B;AAE7D,SAASC,eAAe,QAAQ,4BAAyB;AACzD,SAASC,kBAAkB,QAAQ,+BAA4B;AAC/D,SAASC,eAAe,QAAQ,4BAAyB;AACzD,SAASC,uBAAuB,QAAQ,yCAAsC;AAG9E;AACA;;AAEA;AACA,SACEC,oBAAoB,EACpBC,0BAA0B,EAC1BC,2BAA2B,QACtB,6BAA0B;AAGjC;AACA,SACEC,SAAS,EACTC,wBAAwB,EACxBC,qBAAqB,EACrBC,wBAAwB,EACxBC,uBAAuB,EACvBC,wBAAwB,EACxBC,yBAAyB,EACzBC,wBAAwB,EACxBC,yBAAyB,EACzBC,8BAA8B,EAC9BC,4BAA4B,QACvB,8BAA2B;AAClC,SACEC,gBAAgB,EAChBC,iBAAiB,EACjBC,qBAAqB,EACrBC,8BAA8B,EAC9BC,8BAA8B,QACzB,8BAA2B;AAOlC;AACA,SAASC,YAAY,QAAQ,uBAAoB;;AAEjD;AACA,SACEC,eAAe,EACfC,qBAAqB,EACrBC,uBAAuB,EACvBC,mBAAmB,QACd,0BAAuB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["default","OxyProvider","OxySignInButton","OxyAuthPrompt","LogoIcon","LogoText","FollowButton","FollowTargetButton","ProfileButton","PeableButton","OxyPayButton","useOxy","useOptionalOxy","OxyProviderMissingError","useAuth","useAccountColor","resolveAccountColor","useAppAssertion","AppAssertionProviderMissingError","createDeferredProductAnalytics","useFollow","useFollowerCounts","useSeedFollowStatuses","useFollowTarget","useSupervision","supervisionQueryKeys","useUserProfile","useUserProfiles","useCurrentUser","useUserById","useUserByUsername","useStorage","useOxyEvent","useUpdateProfile","useUploadAvatar","useUploadFile","useFileDownloadUrl","useMutationStatus","useOnlineStatus","useDisplayCurrency","useDisplayPrice","DisplayCurrencySelector","buildFollowMenuItems","resolveFollowPrimaryAction","FOLLOW_ACTION_LEAVES_ACTIVE","queryKeys","invalidateAccountQueries","invalidateUserQueries","invalidateSessionQueries","invalidateDeviceQueries","invalidatePrivacyQueries","invalidateSecurityQueries","invalidateStorageQueries","invalidatePaymentsQueries","invalidateConnectedAppsQueries","invalidateAuthMethodsQueries","upsertCachedUser","upsertCachedUsers","CLEARABLE_USER_FIELDS","clearedFieldsFromProfileUpdate","clearedFieldsFromAccountUpdate","useAuthStore","handleAuthError","isInvalidSessionError","isTimeoutOrNetworkError","extractErrorMessage"],"sourceRoot":"../../../src","sources":["ui/client.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO,wBAAqB;;AAE5B;AACA,SAASA,OAAO,IAAIC,WAAW,QAAQ,6BAA0B;AACjE,SAASD,OAAO,IAAIE,eAAe,QAAQ,iCAA8B;AACzE,SAASF,OAAO,IAAIG,aAAa,QAAQ,+BAA4B;AAErE,SAASC,QAAQ,QAAQ,+BAA4B;AACrD,SAASC,QAAQ,QAAQ,+BAA4B;AACrD,SAASL,OAAO,IAAIM,YAAY,QAAQ,8BAA2B;AAMnE,SAASC,kBAAkB,QAAQ,oCAAiC;AAGpE,SAASP,OAAO,IAAIQ,aAAa,QAAQ,+BAA4B;AAErE,SAASR,OAAO,IAAIS,YAAY,QAAQ,8BAA2B;AAEnE;AACA,SAAST,OAAO,IAAIU,YAAY,QAAQ,8BAA2B;AACnE;;AAGA;AACA,SAASC,MAAM,EAAEC,cAAc,EAAEC,uBAAuB,QAAQ,yBAAsB;;AAEtF;AACA,SAASC,OAAO,QAAQ,oBAAiB;AACzC,SAASC,eAAe,EAAEC,mBAAmB,QAAQ,4BAAyB;AA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,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* useAccountColor
|
|
5
|
+
*
|
|
6
|
+
* The account's colour is one value that every Oxy app wears: `users.color`, a
|
|
7
|
+
* Bloom preset NAME the API only stores after its entitlement check (`oxy` and
|
|
8
|
+
* `faircoin` belong to the account with that handle, `mono` to an active
|
|
9
|
+
* benefit). This hook is the single place an app turns that stored name into its
|
|
10
|
+
* Bloom theme, so two apps cannot disagree about which field wins.
|
|
11
|
+
*
|
|
12
|
+
* The portable `themePreference.colorPreset` is the fallback for an account that
|
|
13
|
+
* has no `color` yet. Mode (light/dark) is deliberately out of scope: whether to
|
|
14
|
+
* follow the account's mode is each app's own choice, the colour is not.
|
|
15
|
+
*
|
|
16
|
+
* An app with a stricter rule of its own (a plan the SDK cannot see) passes
|
|
17
|
+
* `canUse`; a name it refuses is simply not applied, so the app keeps its own
|
|
18
|
+
* default instead of a colour the viewer is not entitled to.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { useEffect } from 'react';
|
|
22
|
+
import { APP_COLOR_PRESETS, useBloomTheme } from '@oxy.so/bloom/theme';
|
|
23
|
+
import { useAuth } from "./useAuth.js";
|
|
24
|
+
function isAppColorName(value) {
|
|
25
|
+
return typeof value === 'string' && Object.prototype.hasOwnProperty.call(APP_COLOR_PRESETS, value);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The preset an account wears, or `null` when it has none Bloom knows. */
|
|
29
|
+
export function resolveAccountColor(user) {
|
|
30
|
+
const stored = user?.color ?? user?.themePreference?.colorPreset;
|
|
31
|
+
return isAppColorName(stored) ? stored : null;
|
|
32
|
+
}
|
|
33
|
+
export function useAccountColor({
|
|
34
|
+
canUse
|
|
35
|
+
} = {}) {
|
|
36
|
+
const {
|
|
37
|
+
isAuthenticated,
|
|
38
|
+
user
|
|
39
|
+
} = useAuth();
|
|
40
|
+
const {
|
|
41
|
+
colorPreset,
|
|
42
|
+
setColorPreset
|
|
43
|
+
} = useBloomTheme();
|
|
44
|
+
const accountColor = resolveAccountColor(user);
|
|
45
|
+
const allowed = accountColor !== null && (canUse?.(accountColor) ?? true);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!isAuthenticated || !accountColor || !allowed || accountColor === colorPreset) return;
|
|
48
|
+
setColorPreset(accountColor);
|
|
49
|
+
}, [isAuthenticated, accountColor, allowed, colorPreset, setColorPreset]);
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=useAccountColor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","APP_COLOR_PRESETS","useBloomTheme","useAuth","isAppColorName","value","Object","prototype","hasOwnProperty","call","resolveAccountColor","user","stored","color","themePreference","colorPreset","useAccountColor","canUse","isAuthenticated","setColorPreset","accountColor","allowed"],"sourceRoot":"../../../../src","sources":["ui/hooks/useAccountColor.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,SAAS,QAAQ,OAAO;AAEjC,SAASC,iBAAiB,EAAEC,aAAa,QAA2B,qBAAqB;AACzF,SAASC,OAAO,QAAQ,cAAW;AAEnC,SAASC,cAAcA,CAACC,KAAc,EAAyB;EAC7D,OACE,OAAOA,KAAK,KAAK,QAAQ,IAAIC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACR,iBAAiB,EAAEI,KAAK,CAAC;AAE/F;;AAEA;AACA,OAAO,SAASK,mBAAmBA,CACjCC,IAAgE,EAC3C;EACrB,MAAMC,MAAM,GAAGD,IAAI,EAAEE,KAAK,IAAIF,IAAI,EAAEG,eAAe,EAAEC,WAAW;EAChE,OAAOX,cAAc,CAACQ,MAAM,CAAC,GAAGA,MAAM,GAAG,IAAI;AAC/C;AAEA,OAAO,SAASI,eAAeA,CAAC;EAC9BC;AAGF,CAAC,GAAG,CAAC,CAAC,EAAQ;EACZ,MAAM;IAAEC,eAAe;IAAEP;EAAK,CAAC,GAAGR,OAAO,CAAC,CAAC;EAC3C,MAAM;IAAEY,WAAW;IAAEI;EAAe,CAAC,GAAGjB,aAAa,CAAC,CAAC;EACvD,MAAMkB,YAAY,GAAGV,mBAAmB,CAACC,IAAI,CAAC;EAC9C,MAAMU,OAAO,GAAGD,YAAY,KAAK,IAAI,KAAKH,MAAM,GAAGG,YAAY,CAAC,IAAI,IAAI,CAAC;EAEzEpB,SAAS,CAAC,MAAM;IACd,IAAI,CAACkB,eAAe,IAAI,CAACE,YAAY,IAAI,CAACC,OAAO,IAAID,YAAY,KAAKL,WAAW,EAAE;IACnFI,cAAc,CAACC,YAAY,CAAC;EAC9B,CAAC,EAAE,CAACF,eAAe,EAAEE,YAAY,EAAEC,OAAO,EAAEN,WAAW,EAAEI,cAAc,CAAC,CAAC;AAC3E","ignoreList":[]}
|
|
@@ -33,6 +33,7 @@ export { default as OxyPayButton } from './components/OxyPayButton';
|
|
|
33
33
|
export type { OxyPayButtonProps } from './components/OxyPayButton';
|
|
34
34
|
export { useOxy, useOptionalOxy, OxyProviderMissingError } from './context/OxyContext';
|
|
35
35
|
export { useAuth } from './hooks/useAuth';
|
|
36
|
+
export { useAccountColor, resolveAccountColor } from './hooks/useAccountColor';
|
|
36
37
|
export { useAppAssertion, AppAssertionProviderMissingError, } from './appAssertion/AppAssertionContext';
|
|
37
38
|
export type { UseAppAssertionResult } from './appAssertion/AppAssertionContext';
|
|
38
39
|
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,M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AAsC,CAAC;AAC/E,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAM9E,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,0BAA0B,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,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useAccountColor
|
|
3
|
+
*
|
|
4
|
+
* The account's colour is one value that every Oxy app wears: `users.color`, a
|
|
5
|
+
* Bloom preset NAME the API only stores after its entitlement check (`oxy` and
|
|
6
|
+
* `faircoin` belong to the account with that handle, `mono` to an active
|
|
7
|
+
* benefit). This hook is the single place an app turns that stored name into its
|
|
8
|
+
* Bloom theme, so two apps cannot disagree about which field wins.
|
|
9
|
+
*
|
|
10
|
+
* The portable `themePreference.colorPreset` is the fallback for an account that
|
|
11
|
+
* has no `color` yet. Mode (light/dark) is deliberately out of scope: whether to
|
|
12
|
+
* follow the account's mode is each app's own choice, the colour is not.
|
|
13
|
+
*
|
|
14
|
+
* An app with a stricter rule of its own (a plan the SDK cannot see) passes
|
|
15
|
+
* `canUse`; a name it refuses is simply not applied, so the app keeps its own
|
|
16
|
+
* default instead of a colour the viewer is not entitled to.
|
|
17
|
+
*/
|
|
18
|
+
import type { User } from '@oxy.so/core';
|
|
19
|
+
import { type AppColorName } from '@oxy.so/bloom/theme';
|
|
20
|
+
/** The preset an account wears, or `null` when it has none Bloom knows. */
|
|
21
|
+
export declare function resolveAccountColor(user: Pick<User, 'color' | 'themePreference'> | null | undefined): AppColorName | null;
|
|
22
|
+
export declare function useAccountColor({ canUse, }?: {
|
|
23
|
+
canUse?: (name: AppColorName) => boolean;
|
|
24
|
+
}): void;
|
|
25
|
+
//# sourceMappingURL=useAccountColor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAccountColor.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useAccountColor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAS1F,2EAA2E;AAC3E,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,iBAAiB,CAAC,GAAG,IAAI,GAAG,SAAS,GAC/D,YAAY,GAAG,IAAI,CAGrB;AAED,wBAAgB,eAAe,CAAC,EAC9B,MAAM,GACP,GAAE;IACD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;CACrC,GAAG,IAAI,CAUZ"}
|
|
@@ -33,6 +33,7 @@ export { default as OxyPayButton } from './components/OxyPayButton.js';
|
|
|
33
33
|
export type { OxyPayButtonProps } from './components/OxyPayButton.js';
|
|
34
34
|
export { useOxy, useOptionalOxy, OxyProviderMissingError } from './context/OxyContext.js';
|
|
35
35
|
export { useAuth } from './hooks/useAuth.js';
|
|
36
|
+
export { useAccountColor, resolveAccountColor } from './hooks/useAccountColor.js';
|
|
36
37
|
export { useAppAssertion, AppAssertionProviderMissingError, } from './appAssertion/AppAssertionContext.js';
|
|
37
38
|
export type { UseAppAssertionResult } from './appAssertion/AppAssertionContext.js';
|
|
38
39
|
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,OAAO,IAAI,aAAa,EAAE,MAAM,+BAA4B,CAAC;AACtE,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA4B,CAAC;AACrE,OAAO,E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eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,0BAAuB,CAAC;AAC/B,YAAY,EAAE,sBAAsB,EAAE,MAAM,0BAAuB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useAccountColor
|
|
3
|
+
*
|
|
4
|
+
* The account's colour is one value that every Oxy app wears: `users.color`, a
|
|
5
|
+
* Bloom preset NAME the API only stores after its entitlement check (`oxy` and
|
|
6
|
+
* `faircoin` belong to the account with that handle, `mono` to an active
|
|
7
|
+
* benefit). This hook is the single place an app turns that stored name into its
|
|
8
|
+
* Bloom theme, so two apps cannot disagree about which field wins.
|
|
9
|
+
*
|
|
10
|
+
* The portable `themePreference.colorPreset` is the fallback for an account that
|
|
11
|
+
* has no `color` yet. Mode (light/dark) is deliberately out of scope: whether to
|
|
12
|
+
* follow the account's mode is each app's own choice, the colour is not.
|
|
13
|
+
*
|
|
14
|
+
* An app with a stricter rule of its own (a plan the SDK cannot see) passes
|
|
15
|
+
* `canUse`; a name it refuses is simply not applied, so the app keeps its own
|
|
16
|
+
* default instead of a colour the viewer is not entitled to.
|
|
17
|
+
*/
|
|
18
|
+
import type { User } from '@oxy.so/core';
|
|
19
|
+
import { type AppColorName } from '@oxy.so/bloom/theme';
|
|
20
|
+
/** The preset an account wears, or `null` when it has none Bloom knows. */
|
|
21
|
+
export declare function resolveAccountColor(user: Pick<User, 'color' | 'themePreference'> | null | undefined): AppColorName | null;
|
|
22
|
+
export declare function useAccountColor({ canUse, }?: {
|
|
23
|
+
canUse?: (name: AppColorName) => boolean;
|
|
24
|
+
}): void;
|
|
25
|
+
//# sourceMappingURL=useAccountColor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAccountColor.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useAccountColor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAS1F,2EAA2E;AAC3E,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,iBAAiB,CAAC,GAAG,IAAI,GAAG,SAAS,GAC/D,YAAY,GAAG,IAAI,CAGrB;AAED,wBAAgB,eAAe,CAAC,EAC9B,MAAM,GACP,GAAE;IACD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;CACrC,GAAG,IAAI,CAUZ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxy.so/services",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.7.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",
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
"prepublishOnly": "node ../../scripts/assert-bun-publish.mjs && bun run typescript && bun run test && bun run build"
|
|
152
152
|
},
|
|
153
153
|
"dependencies": {
|
|
154
|
-
"@oxy.so/contracts": "^5.
|
|
154
|
+
"@oxy.so/contracts": "^5.4.0",
|
|
155
155
|
"color": "^5.0.3",
|
|
156
156
|
"@peable.to/sdk": "0.4.1"
|
|
157
157
|
},
|
|
@@ -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": "6.
|
|
163
|
+
"@oxy.so/core": "6.9.3",
|
|
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",
|
package/src/ui/client.ts
CHANGED
|
@@ -45,6 +45,7 @@ export { useOxy, useOptionalOxy, OxyProviderMissingError } from './context/OxyCo
|
|
|
45
45
|
|
|
46
46
|
// Hooks
|
|
47
47
|
export { useAuth } from './hooks/useAuth';
|
|
48
|
+
export { useAccountColor, resolveAccountColor } from './hooks/useAccountColor';
|
|
48
49
|
// This app's Oxy-signed assertion of which app it is (ADR 0045), for an SDK
|
|
49
50
|
// that attaches it to its own requests without pulling in the account screens.
|
|
50
51
|
export {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useAccountColor
|
|
3
|
+
*
|
|
4
|
+
* The account's colour is one value that every Oxy app wears: `users.color`, a
|
|
5
|
+
* Bloom preset NAME the API only stores after its entitlement check (`oxy` and
|
|
6
|
+
* `faircoin` belong to the account with that handle, `mono` to an active
|
|
7
|
+
* benefit). This hook is the single place an app turns that stored name into its
|
|
8
|
+
* Bloom theme, so two apps cannot disagree about which field wins.
|
|
9
|
+
*
|
|
10
|
+
* The portable `themePreference.colorPreset` is the fallback for an account that
|
|
11
|
+
* has no `color` yet. Mode (light/dark) is deliberately out of scope: whether to
|
|
12
|
+
* follow the account's mode is each app's own choice, the colour is not.
|
|
13
|
+
*
|
|
14
|
+
* An app with a stricter rule of its own (a plan the SDK cannot see) passes
|
|
15
|
+
* `canUse`; a name it refuses is simply not applied, so the app keeps its own
|
|
16
|
+
* default instead of a colour the viewer is not entitled to.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { useEffect } from 'react';
|
|
20
|
+
import type { User } from '@oxy.so/core';
|
|
21
|
+
import { APP_COLOR_PRESETS, useBloomTheme, type AppColorName } from '@oxy.so/bloom/theme';
|
|
22
|
+
import { useAuth } from './useAuth';
|
|
23
|
+
|
|
24
|
+
function isAppColorName(value: unknown): value is AppColorName {
|
|
25
|
+
return (
|
|
26
|
+
typeof value === 'string' && Object.prototype.hasOwnProperty.call(APP_COLOR_PRESETS, value)
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The preset an account wears, or `null` when it has none Bloom knows. */
|
|
31
|
+
export function resolveAccountColor(
|
|
32
|
+
user: Pick<User, 'color' | 'themePreference'> | null | undefined,
|
|
33
|
+
): AppColorName | null {
|
|
34
|
+
const stored = user?.color ?? user?.themePreference?.colorPreset;
|
|
35
|
+
return isAppColorName(stored) ? stored : null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function useAccountColor({
|
|
39
|
+
canUse,
|
|
40
|
+
}: {
|
|
41
|
+
canUse?: (name: AppColorName) => boolean;
|
|
42
|
+
} = {}): void {
|
|
43
|
+
const { isAuthenticated, user } = useAuth();
|
|
44
|
+
const { colorPreset, setColorPreset } = useBloomTheme();
|
|
45
|
+
const accountColor = resolveAccountColor(user);
|
|
46
|
+
const allowed = accountColor !== null && (canUse?.(accountColor) ?? true);
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (!isAuthenticated || !accountColor || !allowed || accountColor === colorPreset) return;
|
|
50
|
+
setColorPreset(accountColor);
|
|
51
|
+
}, [isAuthenticated, accountColor, allowed, colorPreset, setColorPreset]);
|
|
52
|
+
}
|