@oxy.so/services 14.17.0 → 14.18.1
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/assets/assets/fonts/icons/OxyServicesIonicons.ttf +0 -0
- package/lib/commonjs/assets/assets/fonts/icons/OxyServicesMaterialCommunityIcons.ttf +0 -0
- package/lib/commonjs/assets/assets/fonts/icons/manifest.json +5 -4
- package/lib/commonjs/assets/fonts/icons/OxyServicesIonicons.ttf +0 -0
- package/lib/commonjs/assets/fonts/icons/OxyServicesMaterialCommunityIcons.ttf +0 -0
- package/lib/commonjs/assets/fonts/icons/manifest.json +5 -4
- package/lib/commonjs/ui/components/LanguageBridge.js +7 -3
- package/lib/commonjs/ui/components/LanguageBridge.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +1 -0
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/context/OxyHostedContext.js +28 -2
- package/lib/commonjs/ui/context/OxyHostedContext.js.map +1 -1
- package/lib/commonjs/ui/hooks/useSurfaceHeader.js +25 -11
- package/lib/commonjs/ui/hooks/useSurfaceHeader.js.map +1 -1
- package/lib/commonjs/ui/icons/subsetGlyphMaps.js +1 -0
- package/lib/commonjs/ui/icons/subsetGlyphMaps.js.map +1 -1
- package/lib/commonjs/ui/session/hostSession.js +11 -2
- package/lib/commonjs/ui/session/hostSession.js.map +1 -1
- package/lib/module/assets/assets/fonts/icons/OxyServicesIonicons.ttf +0 -0
- package/lib/module/assets/assets/fonts/icons/OxyServicesMaterialCommunityIcons.ttf +0 -0
- package/lib/module/assets/assets/fonts/icons/manifest.json +5 -4
- package/lib/module/assets/fonts/icons/OxyServicesIonicons.ttf +0 -0
- package/lib/module/assets/fonts/icons/OxyServicesMaterialCommunityIcons.ttf +0 -0
- package/lib/module/assets/fonts/icons/manifest.json +5 -4
- package/lib/module/ui/components/LanguageBridge.js +7 -3
- package/lib/module/ui/components/LanguageBridge.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +1 -0
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/context/OxyHostedContext.js +29 -3
- package/lib/module/ui/context/OxyHostedContext.js.map +1 -1
- package/lib/module/ui/hooks/useSurfaceHeader.js +25 -11
- package/lib/module/ui/hooks/useSurfaceHeader.js.map +1 -1
- package/lib/module/ui/icons/subsetGlyphMaps.js +1 -0
- package/lib/module/ui/icons/subsetGlyphMaps.js.map +1 -1
- package/lib/module/ui/session/hostSession.js +11 -2
- package/lib/module/ui/session/hostSession.js.map +1 -1
- package/lib/typescript/commonjs/ui/components/LanguageBridge.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/OxyHostedContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts +8 -0
- package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useSurfaceHeader.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/icons/MaterialCommunityIcons.d.ts +1 -1
- package/lib/typescript/commonjs/ui/icons/MaterialCommunityIcons.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/icons/subsetGlyphMaps.d.ts +1 -0
- package/lib/typescript/commonjs/ui/icons/subsetGlyphMaps.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/session/hostSession.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/LanguageBridge.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/OxyHostedContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/oxyContextTypes.d.ts +8 -0
- package/lib/typescript/module/ui/context/oxyContextTypes.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useSurfaceHeader.d.ts.map +1 -1
- package/lib/typescript/module/ui/icons/MaterialCommunityIcons.d.ts +1 -1
- package/lib/typescript/module/ui/icons/MaterialCommunityIcons.d.ts.map +1 -1
- package/lib/typescript/module/ui/icons/subsetGlyphMaps.d.ts +1 -0
- package/lib/typescript/module/ui/icons/subsetGlyphMaps.d.ts.map +1 -1
- package/lib/typescript/module/ui/session/hostSession.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/assets/fonts/icons/OxyServicesIonicons.ttf +0 -0
- package/src/assets/fonts/icons/OxyServicesMaterialCommunityIcons.ttf +0 -0
- package/src/assets/fonts/icons/manifest.json +5 -4
- package/src/ui/components/LanguageBridge.tsx +6 -3
- package/src/ui/components/__tests__/LanguageBridge.test.tsx +17 -0
- package/src/ui/context/OxyContext.tsx +1 -0
- package/src/ui/context/OxyHostedContext.tsx +43 -3
- package/src/ui/context/oxyContextTypes.ts +8 -0
- package/src/ui/hooks/useSurfaceHeader.ts +50 -15
- package/src/ui/icons/subsetGlyphMaps.ts +1 -0
- package/src/ui/session/hostSession.ts +15 -1
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
} from 'react';
|
|
35
35
|
import { OxyServices, logger as loggerUtil } from '@oxy.so/core';
|
|
36
36
|
import type { AccountNode, CreateAccountInput, User } from '@oxy.so/core';
|
|
37
|
-
import type { OxyHostRequest, OxySessionHost } from '@oxy.so/core/host';
|
|
37
|
+
import type { OxyHostAccount, OxyHostRequest, OxySessionHost } from '@oxy.so/core/host';
|
|
38
38
|
import type { AccountDialogView } from '@oxy.so/core/session';
|
|
39
39
|
import { createUserEventSocket, type UserEventSocket } from '@oxy.so/core/session';
|
|
40
40
|
import { useQueryClient } from '@tanstack/react-query';
|
|
@@ -72,7 +72,13 @@ import {
|
|
|
72
72
|
registerAccountDialogControls,
|
|
73
73
|
notifyAccountDialogVisibility,
|
|
74
74
|
} from '../navigation/accountDialogManager';
|
|
75
|
-
import {
|
|
75
|
+
import {
|
|
76
|
+
createHostSession,
|
|
77
|
+
HostedSessionError,
|
|
78
|
+
readHostSnapshot,
|
|
79
|
+
userFromHostAccount,
|
|
80
|
+
type HostSession,
|
|
81
|
+
} from '../session/hostSession';
|
|
76
82
|
import { AppAssertionProvider } from '../appAssertion/AppAssertionContext';
|
|
77
83
|
import type { LogoutResult, OxyContextState, OxyRuntimeProviderProps } from './oxyContextTypes';
|
|
78
84
|
import {
|
|
@@ -108,6 +114,18 @@ const NO_DEVICE: RuntimeSessionClient = {
|
|
|
108
114
|
};
|
|
109
115
|
const NO_DEVICE_HOST = { setCurrentAccountId: () => undefined };
|
|
110
116
|
|
|
117
|
+
/**
|
|
118
|
+
* What the host's snapshot says of the account's languages, as a stable value
|
|
119
|
+
* for `useSyncExternalStore`: `''` when nobody is signed in (the guest or
|
|
120
|
+
* device language is the answer), the account as JSON when it carries its
|
|
121
|
+
* languages, or `null` while only the account's own profile can tell.
|
|
122
|
+
*/
|
|
123
|
+
function languageAccountOf(host: OxySessionHost): string | null {
|
|
124
|
+
const snapshot = readHostSnapshot(host);
|
|
125
|
+
if (snapshot.status !== 'signed_in') return '';
|
|
126
|
+
return snapshot.account?.languages ? JSON.stringify(snapshot.account) : null;
|
|
127
|
+
}
|
|
128
|
+
|
|
111
129
|
/**
|
|
112
130
|
* Which of the platform's screens an `openAccountDialog(view)` asks for: its
|
|
113
131
|
* sign-in when signed out; while signed in, every view of the dialog — the
|
|
@@ -307,6 +325,26 @@ export const OxyHostedRuntimeProvider: React.FC<OxyHostedRuntimeProviderProps> =
|
|
|
307
325
|
onAuthStateChangeRef.current?.(runtime.getSnapshot().account);
|
|
308
326
|
}, [authResolved, userId, runtime]);
|
|
309
327
|
|
|
328
|
+
// The account's languages as the platform's snapshot gives them (ADR 0022 on a
|
|
329
|
+
// session host): the language is known from the first render, offline too,
|
|
330
|
+
// while the account itself is published only with its token (ADR 0058).
|
|
331
|
+
const subscribeHost = useCallback(
|
|
332
|
+
(listener: () => void) => (host ? host.subscribe(listener) : () => undefined),
|
|
333
|
+
[host],
|
|
334
|
+
);
|
|
335
|
+
const readLanguageAccount = useCallback(() => (host ? languageAccountOf(host) : null), [host]);
|
|
336
|
+
const languageAccount = useSyncExternalStore(
|
|
337
|
+
subscribeHost,
|
|
338
|
+
readLanguageAccount,
|
|
339
|
+
readLanguageAccount,
|
|
340
|
+
);
|
|
341
|
+
const languageUser = useMemo(() => {
|
|
342
|
+
if (user) return user;
|
|
343
|
+
if (!languageAccount) return null;
|
|
344
|
+
return userFromHostAccount(JSON.parse(languageAccount) as OxyHostAccount, null);
|
|
345
|
+
}, [languageAccount, user]);
|
|
346
|
+
const isAccountLanguageKnown = languageAccount !== null;
|
|
347
|
+
|
|
310
348
|
const entryLink = useEntryLink({
|
|
311
349
|
storage,
|
|
312
350
|
storageKey: `${storageKeyPrefix}_campaign_attribution`,
|
|
@@ -328,7 +366,7 @@ export const OxyHostedRuntimeProvider: React.FC<OxyHostedRuntimeProviderProps> =
|
|
|
328
366
|
entryUrl: entryLink.url,
|
|
329
367
|
entryLinkReady: entryLink.ready,
|
|
330
368
|
legacyLanguageKeys,
|
|
331
|
-
user,
|
|
369
|
+
user: languageUser,
|
|
332
370
|
onError,
|
|
333
371
|
logger,
|
|
334
372
|
});
|
|
@@ -524,6 +562,7 @@ export const OxyHostedRuntimeProvider: React.FC<OxyHostedRuntimeProviderProps> =
|
|
|
524
562
|
error,
|
|
525
563
|
currentLanguage,
|
|
526
564
|
isLanguageReady: isLanguageReady && entryLink.campaignReady,
|
|
565
|
+
isAccountLanguageKnown,
|
|
527
566
|
campaignAttribution: entryLink.campaignAttribution,
|
|
528
567
|
currentLanguages,
|
|
529
568
|
currentLanguageMetadata,
|
|
@@ -583,6 +622,7 @@ export const OxyHostedRuntimeProvider: React.FC<OxyHostedRuntimeProviderProps> =
|
|
|
583
622
|
error,
|
|
584
623
|
currentLanguage,
|
|
585
624
|
isLanguageReady,
|
|
625
|
+
isAccountLanguageKnown,
|
|
586
626
|
entryLink.campaignReady,
|
|
587
627
|
entryLink.campaignAttribution,
|
|
588
628
|
currentLanguages,
|
|
@@ -100,6 +100,14 @@ export interface OxyContextState {
|
|
|
100
100
|
/** Active UI locale (`language-REGION`): the account's primary locale when signed in, else the guest/device locale. */
|
|
101
101
|
currentLanguage: string;
|
|
102
102
|
isLanguageReady: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Whether the account's language is known before the session resolves: on a
|
|
105
|
+
* session host (ADR 0058) whose snapshot carries the account's languages, or
|
|
106
|
+
* says nobody is signed in, from the first render. The language bridge then
|
|
107
|
+
* waits for neither the token nor a profile read (ADR 0022). Always `false`
|
|
108
|
+
* where this SDK holds the session itself.
|
|
109
|
+
*/
|
|
110
|
+
isAccountLanguageKnown: boolean;
|
|
103
111
|
campaignAttribution?: CampaignAttribution;
|
|
104
112
|
/** Ordered account locales (primary first) when signed in, or the single guest override when signed out. */
|
|
105
113
|
currentLanguages: string[];
|
|
@@ -65,23 +65,48 @@ function primaryActionEqual(
|
|
|
65
65
|
return a.label === b.label && !!a.disabled === !!b.disabled && !!a.loading === !!b.loading;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
// Bloom's legacy entries use accessibilityLabel; semantic entries use id/label.
|
|
69
|
+
// Read the fixed presentation vocabulary structurally so this adapter also
|
|
70
|
+
// compiles against the supported older Bloom declarations, before that union.
|
|
71
|
+
const ACTION_PRESENTATION_KEYS = [
|
|
72
|
+
'id',
|
|
73
|
+
'label',
|
|
74
|
+
'accessibilityLabel',
|
|
75
|
+
'icon',
|
|
76
|
+
'group',
|
|
77
|
+
'priority',
|
|
78
|
+
'essential',
|
|
79
|
+
'overflow',
|
|
80
|
+
'visible',
|
|
81
|
+
'disabled',
|
|
82
|
+
'busy',
|
|
83
|
+
'selected',
|
|
84
|
+
'labelVisibility',
|
|
85
|
+
] as const;
|
|
86
|
+
function actionPresentationValue(
|
|
87
|
+
action: HeaderAction,
|
|
88
|
+
key: (typeof ACTION_PRESENTATION_KEYS)[number],
|
|
89
|
+
): unknown {
|
|
90
|
+
const value: unknown = Reflect.get(action, key);
|
|
91
|
+
if (key === 'disabled' || key === 'busy' || key === 'essential') return !!value;
|
|
92
|
+
if (key === 'visible') return value !== false;
|
|
93
|
+
if (key === 'priority') return value ?? 0;
|
|
94
|
+
if (key === 'overflow' || key === 'labelVisibility') return value ?? 'auto';
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
|
|
68
98
|
function actionsEqual(a: HeaderAction[] | undefined, b: HeaderAction[] | undefined): boolean {
|
|
69
99
|
if (a === b) return true;
|
|
70
100
|
if (!a || !b || a.length !== b.length) return false;
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return true;
|
|
101
|
+
return a.every((action, index) => {
|
|
102
|
+
const other = b[index];
|
|
103
|
+
return (
|
|
104
|
+
other !== undefined &&
|
|
105
|
+
ACTION_PRESENTATION_KEYS.every(
|
|
106
|
+
(key) => actionPresentationValue(action, key) === actionPresentationValue(other, key),
|
|
107
|
+
)
|
|
108
|
+
);
|
|
109
|
+
});
|
|
85
110
|
}
|
|
86
111
|
|
|
87
112
|
function searchEqual(a: HeaderSearch | undefined, b: HeaderSearch | undefined): boolean {
|
|
@@ -202,7 +227,17 @@ export function useSurfaceHeader(content: SurfaceHeaderContent | null | undefine
|
|
|
202
227
|
? {
|
|
203
228
|
actions: content.actions.map((action, index) => ({
|
|
204
229
|
...action,
|
|
205
|
-
onPress: () =>
|
|
230
|
+
onPress: () => {
|
|
231
|
+
const current = liveContent.current?.actions;
|
|
232
|
+
const id = actionPresentationValue(action, 'id');
|
|
233
|
+
// Semantic commands keep identity when reordered; legacy
|
|
234
|
+
// static lists retain their existing positional dispatch.
|
|
235
|
+
const latest =
|
|
236
|
+
id === undefined
|
|
237
|
+
? current?.[index]
|
|
238
|
+
: current?.find((entry) => actionPresentationValue(entry, 'id') === id);
|
|
239
|
+
latest?.onPress();
|
|
240
|
+
},
|
|
206
241
|
})),
|
|
207
242
|
}
|
|
208
243
|
: {}),
|
|
@@ -97,6 +97,13 @@ function validAccount(account: unknown): OxyHostAccount | null {
|
|
|
97
97
|
...(typeof candidate.avatar === 'string' && candidate.avatar
|
|
98
98
|
? { avatar: candidate.avatar }
|
|
99
99
|
: {}),
|
|
100
|
+
...(Array.isArray(candidate.languages)
|
|
101
|
+
? {
|
|
102
|
+
languages: candidate.languages.filter(
|
|
103
|
+
(language): language is string => typeof language === 'string' && language !== '',
|
|
104
|
+
),
|
|
105
|
+
}
|
|
106
|
+
: {}),
|
|
100
107
|
};
|
|
101
108
|
}
|
|
102
109
|
|
|
@@ -140,6 +147,12 @@ export function userFromHostAccount(account: OxyHostAccount, base: User | null):
|
|
|
140
147
|
publicKey: known?.publicKey ?? '',
|
|
141
148
|
name,
|
|
142
149
|
avatar: account.avatar ?? known?.avatar ?? null,
|
|
150
|
+
// The platform's last read of the languages until the profile is read here,
|
|
151
|
+
// which is the fresher of the two (ADR 0022's only read of the owner's own
|
|
152
|
+
// preferences).
|
|
153
|
+
...(known?.languages === undefined && account.languages
|
|
154
|
+
? { languages: [...account.languages] }
|
|
155
|
+
: {}),
|
|
143
156
|
} as User;
|
|
144
157
|
}
|
|
145
158
|
|
|
@@ -149,7 +162,8 @@ function sameProfile(user: User | null, account: OxyHostAccount): boolean {
|
|
|
149
162
|
user.id === account.id &&
|
|
150
163
|
user.username === account.handle &&
|
|
151
164
|
(account.displayName === undefined || user.name?.displayName === account.displayName) &&
|
|
152
|
-
(account.avatar === undefined || user.avatar === account.avatar)
|
|
165
|
+
(account.avatar === undefined || user.avatar === account.avatar) &&
|
|
166
|
+
(account.languages === undefined || user.languages !== undefined)
|
|
153
167
|
);
|
|
154
168
|
}
|
|
155
169
|
|