@oxy.so/services 14.18.1 → 14.19.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.
Files changed (62) hide show
  1. package/lib/commonjs/ui/components/AccountLanguageBoundary.js +4 -2
  2. package/lib/commonjs/ui/components/AccountLanguageBoundary.js.map +1 -1
  3. package/lib/commonjs/ui/components/LanguageBridge.js +63 -22
  4. package/lib/commonjs/ui/components/LanguageBridge.js.map +1 -1
  5. package/lib/commonjs/ui/context/OxyHostedContext.js +18 -2
  6. package/lib/commonjs/ui/context/OxyHostedContext.js.map +1 -1
  7. package/lib/commonjs/ui/hooks/queryClient.js +20 -1
  8. package/lib/commonjs/ui/hooks/queryClient.js.map +1 -1
  9. package/lib/commonjs/ui/hooks/useLanguageManagement.js +40 -11
  10. package/lib/commonjs/ui/hooks/useLanguageManagement.js.map +1 -1
  11. package/lib/commonjs/ui/session/hostSession.js +14 -2
  12. package/lib/commonjs/ui/session/hostSession.js.map +1 -1
  13. package/lib/commonjs/ui/utils/apiErrorMessage.js +2 -2
  14. package/lib/commonjs/ui/utils/apiErrorMessage.js.map +1 -1
  15. package/lib/module/ui/components/AccountLanguageBoundary.js +4 -2
  16. package/lib/module/ui/components/AccountLanguageBoundary.js.map +1 -1
  17. package/lib/module/ui/components/LanguageBridge.js +64 -23
  18. package/lib/module/ui/components/LanguageBridge.js.map +1 -1
  19. package/lib/module/ui/context/OxyHostedContext.js +18 -2
  20. package/lib/module/ui/context/OxyHostedContext.js.map +1 -1
  21. package/lib/module/ui/hooks/queryClient.js +20 -2
  22. package/lib/module/ui/hooks/queryClient.js.map +1 -1
  23. package/lib/module/ui/hooks/useLanguageManagement.js +40 -11
  24. package/lib/module/ui/hooks/useLanguageManagement.js.map +1 -1
  25. package/lib/module/ui/session/hostSession.js +14 -2
  26. package/lib/module/ui/session/hostSession.js.map +1 -1
  27. package/lib/module/ui/utils/apiErrorMessage.js +3 -3
  28. package/lib/module/ui/utils/apiErrorMessage.js.map +1 -1
  29. package/lib/typescript/commonjs/ui/components/AccountLanguageBoundary.d.ts.map +1 -1
  30. package/lib/typescript/commonjs/ui/components/LanguageBridge.d.ts.map +1 -1
  31. package/lib/typescript/commonjs/ui/context/OxyHostedContext.d.ts +2 -1
  32. package/lib/typescript/commonjs/ui/context/OxyHostedContext.d.ts.map +1 -1
  33. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts +11 -6
  34. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts.map +1 -1
  35. package/lib/typescript/commonjs/ui/hooks/queryClient.d.ts +5 -0
  36. package/lib/typescript/commonjs/ui/hooks/queryClient.d.ts.map +1 -1
  37. package/lib/typescript/commonjs/ui/hooks/useLanguageManagement.d.ts +11 -1
  38. package/lib/typescript/commonjs/ui/hooks/useLanguageManagement.d.ts.map +1 -1
  39. package/lib/typescript/commonjs/ui/session/hostSession.d.ts.map +1 -1
  40. package/lib/typescript/commonjs/ui/utils/apiErrorMessage.d.ts.map +1 -1
  41. package/lib/typescript/module/ui/components/AccountLanguageBoundary.d.ts.map +1 -1
  42. package/lib/typescript/module/ui/components/LanguageBridge.d.ts.map +1 -1
  43. package/lib/typescript/module/ui/context/OxyHostedContext.d.ts +2 -1
  44. package/lib/typescript/module/ui/context/OxyHostedContext.d.ts.map +1 -1
  45. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts +11 -6
  46. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts.map +1 -1
  47. package/lib/typescript/module/ui/hooks/queryClient.d.ts +5 -0
  48. package/lib/typescript/module/ui/hooks/queryClient.d.ts.map +1 -1
  49. package/lib/typescript/module/ui/hooks/useLanguageManagement.d.ts +11 -1
  50. package/lib/typescript/module/ui/hooks/useLanguageManagement.d.ts.map +1 -1
  51. package/lib/typescript/module/ui/session/hostSession.d.ts.map +1 -1
  52. package/lib/typescript/module/ui/utils/apiErrorMessage.d.ts.map +1 -1
  53. package/package.json +3 -3
  54. package/src/ui/components/AccountLanguageBoundary.tsx +3 -1
  55. package/src/ui/components/LanguageBridge.tsx +75 -23
  56. package/src/ui/components/__tests__/LanguageBridge.test.tsx +55 -0
  57. package/src/ui/context/OxyHostedContext.tsx +28 -2
  58. package/src/ui/context/oxyContextTypes.ts +11 -6
  59. package/src/ui/hooks/queryClient.ts +20 -2
  60. package/src/ui/hooks/useLanguageManagement.ts +47 -12
  61. package/src/ui/session/hostSession.ts +18 -2
  62. package/src/ui/utils/apiErrorMessage.ts +9 -4
@@ -12,6 +12,13 @@ export interface UseLanguageManagementOptions {
12
12
  * `null` the device locale (or a locally-chosen guest override) is used.
13
13
  */
14
14
  user: User | null;
15
+ /**
16
+ * The platform's preferred languages, primary first, where the platform names
17
+ * them (a session host's `preferredLanguages`, ADR 0058 R11). When present
18
+ * they are the app's language, signed in or out, and ready from the first
19
+ * render: neither the account, the guest override nor storage is waited for.
20
+ */
21
+ platformLanguages?: readonly string[] | null;
15
22
  onError?: (error: ApiError) => void;
16
23
  logger?: (message: string, error?: unknown) => void;
17
24
  }
@@ -67,9 +74,12 @@ export declare function setPrimaryLocale(languages: readonly string[], locale: s
67
74
  * follow the account's language automatically.
68
75
  * - Signed out → a locally-chosen guest override if one exists, otherwise the
69
76
  * device locale.
77
+ * - On a platform that names its preferred languages (ADR 0058 R11) → those,
78
+ * signed in or out, from the first render, as a Mac app follows the
79
+ * system's preferred languages.
70
80
  *
71
81
  * The only external system this hook synchronizes with is local storage (the
72
82
  * guest override), which is loaded once on mount.
73
83
  */
74
- export declare const useLanguageManagement: ({ storage, languageKey, entryUrl, entryLinkReady, legacyLanguageKeys, user, onError, logger, }: UseLanguageManagementOptions) => UseLanguageManagementResult;
84
+ export declare const useLanguageManagement: ({ storage, languageKey, entryUrl, entryLinkReady, legacyLanguageKeys, user, platformLanguages, onError, logger, }: UseLanguageManagementOptions) => UseLanguageManagementResult;
75
85
  //# sourceMappingURL=useLanguageManagement.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLanguageManagement.d.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QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;CAC/C;AA0CD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,eAAe,CA6BtE;AAED,yFAAyF;AACzF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAkBpF;AAoBD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAgW1E"}
@@ -1 +1 @@
1
- {"version":3,"file":"apiErrorMessage.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/apiErrorMessage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAkB,CAAC;AAElD,yEAAyE;AACzE,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,4EAA4E;AAC5E,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAG5D;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAIlD,CAAC;AAEH,yFAAyF;AACzF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAIxD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAiDxF;AAED,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMvD"}
1
+ {"version":3,"file":"apiErrorMessage.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/apiErrorMessage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAkB,CAAC;AAElD,yEAAyE;AACzE,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,4EAA4E;AAC5E,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAG5D;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAIlD,CAAC;AAEH,yFAAyF;AACzF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAGxD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAiDxF;AAED,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMvD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxy.so/services",
3
- "version": "14.18.1",
3
+ "version": "14.19.1",
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",
@@ -183,7 +183,7 @@
183
183
  "devDependencies": {
184
184
  "@expo/app-integrity": "~58.0.2",
185
185
  "@expo/vector-icons": "^15.1.1",
186
- "@oxy.so/core": "7.46.0",
186
+ "@oxy.so/core": "7.48.0",
187
187
  "@react-native-async-storage/async-storage": "^3.1.1",
188
188
  "@react-native-community/netinfo": "^12.0.1",
189
189
  "@react-native/babel-preset": "^0.88.1",
@@ -236,7 +236,7 @@
236
236
  "@expo/app-integrity": ">=0.1.10 <59.0.0",
237
237
  "@expo/vector-icons": "^15.0.3",
238
238
  "@oxy.so/bloom": ">=17.15.0",
239
- "@oxy.so/core": "^7.46.0",
239
+ "@oxy.so/core": "^7.47.0",
240
240
  "@react-native-async-storage/async-storage": ">=2.0.0 <4.0.0",
241
241
  "@react-native-community/netinfo": ">=11.4.1 <13.0.0",
242
242
  "@tanstack/query-async-storage-persister": "^5.101",
@@ -13,12 +13,14 @@ export function AccountLanguageBoundary({
13
13
  language?: OxyLanguageConfig;
14
14
  children: ReactNode;
15
15
  }) {
16
- const { canUsePrivateApi, user, currentLanguage } = useOxy();
16
+ const { canUsePrivateApi, user, currentLanguage, isAccountLanguageKnown } = useOxy();
17
17
  const profile = useCurrentUser({ enabled: canUsePrivateApi });
18
18
  // The query mirrors its result into the account runtime in an effect. Wait for
19
19
  // that projection as well as the request, so the bridge never publishes the
20
20
  // compact session's fallback locale in the frame before its real preference.
21
+ // A session host that names the language (ADR 0058 R10, R11) is never waited on.
21
22
  const accountReady =
23
+ isAccountLanguageKnown ||
22
24
  !user ||
23
25
  !canUsePrivateApi ||
24
26
  profile.fetchStatus === 'paused' ||
@@ -1,8 +1,46 @@
1
- import { useEffect, useRef, useState, type ReactNode } from 'react';
1
+ import { useLayoutEffect, useRef, useState, type ReactNode } from 'react';
2
2
  import { coerceToSupportedLocale } from '@oxy.so/core';
3
3
  import { useOxy } from '../context/oxyRuntimeContext';
4
4
  import type { OxyLanguageConfig } from '../types/navigation';
5
5
 
6
+ function isPromiseLike(value: unknown): value is PromiseLike<unknown> {
7
+ return (
8
+ (typeof value === 'object' || typeof value === 'function') &&
9
+ value !== null &&
10
+ typeof (value as { then?: unknown }).then === 'function'
11
+ );
12
+ }
13
+
14
+ /**
15
+ * Tell the app `locale`, and its fallback when that fails. Returns a promise
16
+ * only when the app's `onChange` returned one; a synchronous `onChange` (an
17
+ * in-memory locale store) is applied before this returns.
18
+ */
19
+ function applyLocale(config: OxyLanguageConfig, locale: string): Promise<void> | undefined {
20
+ const fallback = (error: unknown): Promise<void> | undefined => {
21
+ config.onError?.(error, locale);
22
+ if (locale === config.fallbackLocale) return undefined;
23
+ try {
24
+ const result = config.onChange(config.fallbackLocale);
25
+ if (!isPromiseLike(result)) return undefined;
26
+ return Promise.resolve(result).then(
27
+ () => undefined,
28
+ (fallbackError) => config.onError?.(fallbackError, config.fallbackLocale),
29
+ );
30
+ } catch (fallbackError) {
31
+ config.onError?.(fallbackError, config.fallbackLocale);
32
+ return undefined;
33
+ }
34
+ };
35
+ try {
36
+ const result = config.onChange(locale);
37
+ if (!isPromiseLike(result)) return undefined;
38
+ return Promise.resolve(result).then(() => undefined, fallback);
39
+ } catch (error) {
40
+ return fallback(error);
41
+ }
42
+ }
43
+
6
44
  /** The SDK resolves the entry/account locale before exposing translated app content. */
7
45
  export function LanguageBridge({
8
46
  config,
@@ -14,39 +52,53 @@ export function LanguageBridge({
14
52
  children: ReactNode;
15
53
  }) {
16
54
  const { currentLanguage, isLanguageReady, isAuthResolved, isAccountLanguageKnown } = useOxy();
17
- // On a session host whose snapshot names the account's languages, the
18
- // language is known before the account is published with its token.
55
+ // On a session host that names the language (the platform's, or the
56
+ // account's in its snapshot), it is known before the account is published.
19
57
  const isAccountResolved = isAuthResolved || isAccountLanguageKnown;
20
58
  const resolvedLocale = config
21
59
  ? coerceToSupportedLocale(currentLanguage, config.supportedLocales, config.fallbackLocale)
22
60
  : currentLanguage;
23
61
  const configRef = useRef(config);
24
62
  configRef.current = config;
25
- const pendingChange = useRef(Promise.resolve());
63
+ // The change still being applied, if any: a later locale waits for it, so a
64
+ // slow earlier catalog never lands after a later one.
65
+ const pendingChange = useRef<Promise<void> | null>(null);
26
66
  const [prepared, setPrepared] = useState(false);
27
67
 
28
- useEffect(() => {
68
+ // A layout effect: when the language is known at mount and the app applies
69
+ // it synchronously, the app's own content is in the same commit as the
70
+ // bridge, so its first frame is the app rather than an empty window.
71
+ useLayoutEffect(() => {
29
72
  if (!isLanguageReady || !isAccountResolved || !accountReady) return;
30
73
  let active = true;
31
- // A slow earlier catalog must finish before a later locale is committed.
74
+ const settle = (change: Promise<void>): void => {
75
+ // A failure is the app's `onError`'s to report; the app is shown either way.
76
+ const tracked = change
77
+ .catch(() => undefined)
78
+ .then(() => {
79
+ if (active) setPrepared(true);
80
+ });
81
+ pendingChange.current = tracked;
82
+ void tracked.finally(() => {
83
+ if (pendingChange.current === tracked) pendingChange.current = null;
84
+ });
85
+ };
86
+ const current = configRef.current;
87
+ if (!current) {
88
+ setPrepared(true);
89
+ } else if (pendingChange.current) {
90
+ settle(
91
+ pendingChange.current.then(async () => {
92
+ const latest = configRef.current;
93
+ if (active && latest) await applyLocale(latest, resolvedLocale);
94
+ }),
95
+ );
96
+ } else {
97
+ const change = applyLocale(current, resolvedLocale);
98
+ if (change) settle(change);
99
+ else setPrepared(true);
100
+ }
32
101
  // Children stay mounted after boot: changing language never destroys route state.
33
- pendingChange.current = pendingChange.current.then(async () => {
34
- if (!active) return;
35
- const current = configRef.current;
36
- try {
37
- await current?.onChange(resolvedLocale);
38
- } catch (error) {
39
- current?.onError?.(error, resolvedLocale);
40
- if (current && resolvedLocale !== current.fallbackLocale) {
41
- try {
42
- await current.onChange(current.fallbackLocale);
43
- } catch (fallbackError) {
44
- current.onError?.(fallbackError, current.fallbackLocale);
45
- }
46
- }
47
- }
48
- if (active) setPrepared(true);
49
- });
50
102
  return () => {
51
103
  active = false;
52
104
  };
@@ -126,3 +126,58 @@ it('paints before the session resolves when a session host already named the acc
126
126
  await waitFor(() => expect(screen.getByText('App')).toBeTruthy());
127
127
  expect(onChange.mock.calls).toEqual([['es-ES']]);
128
128
  });
129
+
130
+ it('shows the app in the same commit when the language is known at mount and applied synchronously', () => {
131
+ mockAuthResolved = false;
132
+ mockAccountLanguageKnown = true;
133
+ mockCurrentLanguage = 'es-ES';
134
+ const applied: string[] = [];
135
+ function Page() {
136
+ applied.push(`rendered after ${applied.join(',')}`);
137
+ return <span>App</span>;
138
+ }
139
+ const onChange = jest.fn((locale: string) => {
140
+ applied.push(locale);
141
+ });
142
+ const screen = render(
143
+ <LanguageBridge config={{ supportedLocales: HOST_CATALOG, fallbackLocale: 'en-US', onChange }}>
144
+ <Page />
145
+ </LanguageBridge>,
146
+ );
147
+ // No promise turn: the app is there as soon as the first render is committed.
148
+ expect(screen.getByText('App')).toBeTruthy();
149
+ expect(applied[0]).toBe('es-ES');
150
+ expect(applied[1]).toBe('rendered after es-ES');
151
+ });
152
+
153
+ it('applies a later locale only after a slow earlier catalog finished', async () => {
154
+ mockCurrentLanguage = 'es-ES';
155
+ let finishSpanish: (() => void) | undefined;
156
+ const order: string[] = [];
157
+ const onChange = jest.fn((locale: string) => {
158
+ order.push(`start ${locale}`);
159
+ if (locale !== 'es-ES') return undefined;
160
+ return new Promise<void>((resolve) => {
161
+ finishSpanish = () => {
162
+ order.push('end es-ES');
163
+ resolve();
164
+ };
165
+ });
166
+ });
167
+ const config = { supportedLocales: HOST_CATALOG, fallbackLocale: 'en-US', onChange };
168
+ const screen = render(
169
+ <LanguageBridge config={config}>
170
+ <span>App</span>
171
+ </LanguageBridge>,
172
+ );
173
+ mockCurrentLanguage = 'fr-FR';
174
+ screen.rerender(
175
+ <LanguageBridge config={config}>
176
+ <span>App</span>
177
+ </LanguageBridge>,
178
+ );
179
+ expect(order).toEqual(['start es-ES']);
180
+ await act(async () => finishSpanish?.());
181
+ await waitFor(() => expect(screen.getByText('App')).toBeTruthy());
182
+ expect(order).toEqual(['start es-ES', 'end es-ES', 'start fr-FR']);
183
+ });
@@ -9,7 +9,8 @@
9
9
  *
10
10
  * - WIRED: the token (`session/hostSession.ts`), the account from the host's
11
11
  * snapshot, every API namespace, `createLinkedClient`, the user socket
12
- * (bearer only, `user:<id>`), the account cache, the language.
12
+ * (bearer only, `user:<id>`), the account cache, the language (the
13
+ * platform's own where it names it, R11).
13
14
  * - SKIPPED: the auth-state store (nothing persisted), every cold-boot lane,
14
15
  * the OAuth return lane, the identity pin, `SessionClient` and the device
15
16
  * directory, the switcher, `setDeviceCredentialProvider`, the browser bridge,
@@ -126,6 +127,15 @@ function languageAccountOf(host: OxySessionHost): string | null {
126
127
  return snapshot.account?.languages ? JSON.stringify(snapshot.account) : null;
127
128
  }
128
129
 
130
+ /**
131
+ * The platform's preferred languages (R11) as a stable value for
132
+ * `useSyncExternalStore`: JSON, or `null` where the platform names none.
133
+ */
134
+ function platformLanguagesOf(host: OxySessionHost): string | null {
135
+ const languages = readHostSnapshot(host).preferredLanguages;
136
+ return languages ? JSON.stringify(languages) : null;
137
+ }
138
+
129
139
  /**
130
140
  * Which of the platform's screens an `openAccountDialog(view)` asks for: its
131
141
  * sign-in when signed out; while signed in, every view of the dialog — the
@@ -343,7 +353,22 @@ export const OxyHostedRuntimeProvider: React.FC<OxyHostedRuntimeProviderProps> =
343
353
  if (!languageAccount) return null;
344
354
  return userFromHostAccount(JSON.parse(languageAccount) as OxyHostAccount, null);
345
355
  }, [languageAccount, user]);
346
- const isAccountLanguageKnown = languageAccount !== null;
356
+ // The platform's own languages (R11), where it names them, are the app's: the
357
+ // account's are not consulted, and nothing waits for the session.
358
+ const readPlatformLanguages = useCallback(
359
+ () => (host ? platformLanguagesOf(host) : null),
360
+ [host],
361
+ );
362
+ const platformLanguagesJson = useSyncExternalStore(
363
+ subscribeHost,
364
+ readPlatformLanguages,
365
+ readPlatformLanguages,
366
+ );
367
+ const platformLanguages = useMemo<string[] | null>(
368
+ () => (platformLanguagesJson ? (JSON.parse(platformLanguagesJson) as string[]) : null),
369
+ [platformLanguagesJson],
370
+ );
371
+ const isAccountLanguageKnown = platformLanguages !== null || languageAccount !== null;
347
372
 
348
373
  const entryLink = useEntryLink({
349
374
  storage,
@@ -367,6 +392,7 @@ export const OxyHostedRuntimeProvider: React.FC<OxyHostedRuntimeProviderProps> =
367
392
  entryLinkReady: entryLink.ready,
368
393
  legacyLanguageKeys,
369
394
  user: languageUser,
395
+ platformLanguages,
370
396
  onError,
371
397
  logger,
372
398
  });
@@ -97,15 +97,20 @@ export interface OxyContextState {
97
97
  /** How web third-party sign-in reaches the IdP (see `OxyProviderProps.webAuthMode`). */
98
98
  webAuthMode: WebAuthMode;
99
99
  error: string | null;
100
- /** Active UI locale (`language-REGION`): the account's primary locale when signed in, else the guest/device locale. */
100
+ /**
101
+ * Active UI locale (`language-REGION`): the platform's preferred language where
102
+ * a session host names it (ADR 0058 R11), else the account's primary locale
103
+ * when signed in, else the guest/device locale.
104
+ */
101
105
  currentLanguage: string;
102
106
  isLanguageReady: boolean;
103
107
  /**
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.
108
+ * Whether the app's language is known without the session: on a session host
109
+ * (ADR 0058) that names the platform's preferred languages (R11), or whose
110
+ * snapshot carries the account's languages (R10) or says nobody is signed in,
111
+ * from the first render. The language bridge then waits for neither the token
112
+ * nor a profile read (ADR 0022). Always `false` where this SDK holds the
113
+ * session itself.
109
114
  */
110
115
  isAccountLanguageKnown: boolean;
111
116
  campaignAttribution?: CampaignAttribution;
@@ -23,7 +23,7 @@
23
23
 
24
24
  import { QueryClient, onlineManager, type Query } from '@tanstack/react-query';
25
25
  import type { PersistedClient } from '@tanstack/react-query-persist-client';
26
- import { isDev } from '@oxy.so/core';
26
+ import { isDev, retryAfterSecondsOf } from '@oxy.so/core';
27
27
  import type { StorageInterface } from '../utils/storageHelpers';
28
28
  import { accountQueryOwnership, type AccountQueriesConfig } from './accountQueryPersistence';
29
29
  import {
@@ -37,6 +37,8 @@ const QUERY_CACHE_KEY = 'oxy_query_cache_v3';
37
37
  const QUERY_CACHE_MAX_AGE = 30 * 24 * 60 * 60 * 1000; // 30 days
38
38
  const QUERY_PERSIST_THROTTLE_MS = 1_000;
39
39
  const MAX_QUERY_RETRIES = 2;
40
+ /** The longest a query waits, silently, for a refusal's `Retry-After`; a longer wait is the person's to see. */
41
+ const MAX_RETRY_AFTER_MS = 30_000;
40
42
 
41
43
  function statusOf(error: unknown): number | null {
42
44
  if (!error || typeof error !== 'object') return null;
@@ -46,10 +48,26 @@ function statusOf(error: unknown): number | null {
46
48
  return typeof value === 'number' ? value : null;
47
49
  }
48
50
 
51
+ /** The wait a refusal asked for (`Retry-After`), in ms; 0 when it named none. */
52
+ function retryAfterMs(error: unknown): number {
53
+ return (retryAfterSecondsOf(error) ?? 0) * 1000;
54
+ }
55
+
56
+ /**
57
+ * How long to wait before the next attempt: what the refusal asked for
58
+ * (`Retry-After` of a 429) when it named a wait, else exponential backoff.
59
+ */
60
+ export function queryRetryDelay(attemptIndex: number, error: unknown): number {
61
+ return retryAfterMs(error) || Math.min(1000 * 2 ** attemptIndex, 30_000);
62
+ }
63
+
49
64
  /** Retry only failures that another attempt can plausibly change. */
50
65
  export function shouldRetryQuery(failureCount: number, error: unknown): boolean {
51
66
  if (failureCount >= MAX_QUERY_RETRIES) return false;
52
67
  const status = statusOf(error);
68
+ // A refusal that asks for a longer wait than we hold a query for: retrying
69
+ // sooner is refused again and spends the budget, so it fails now instead.
70
+ if (retryAfterMs(error) > MAX_RETRY_AFTER_MS) return false;
53
71
  if (status === null) return true; // transport error without an HTTP response
54
72
  return status === 408 || status === 425 || status === 429 || status >= 500;
55
73
  }
@@ -80,7 +98,7 @@ export const createQueryClient = (): QueryClient => {
80
98
  // Keep unused data in cache for 30 minutes
81
99
  gcTime: 30 * 60 * 1000,
82
100
  retry: shouldRetryQuery,
83
- retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 30000),
101
+ retryDelay: queryRetryDelay,
84
102
  // Refetch on reconnect so stale data is refreshed once online again.
85
103
  refetchOnReconnect: true,
86
104
  // Don't refetch on window focus (better for mobile)
@@ -27,6 +27,13 @@ export interface UseLanguageManagementOptions {
27
27
  * `null` the device locale (or a locally-chosen guest override) is used.
28
28
  */
29
29
  user: User | null;
30
+ /**
31
+ * The platform's preferred languages, primary first, where the platform names
32
+ * them (a session host's `preferredLanguages`, ADR 0058 R11). When present
33
+ * they are the app's language, signed in or out, and ready from the first
34
+ * render: neither the account, the guest override nor storage is waited for.
35
+ */
36
+ platformLanguages?: readonly string[] | null;
30
37
  onError?: (error: ApiError) => void;
31
38
  logger?: (message: string, error?: unknown) => void;
32
39
  }
@@ -91,6 +98,21 @@ export function setPrimaryLocale(languages: readonly string[], locale: string):
91
98
  return [canonical, ...languages.filter((entry) => entry !== canonical)];
92
99
  }
93
100
 
101
+ /**
102
+ * The first of `candidates` that resolves to a supported catalog locale, either
103
+ * exactly or by base-language match (`fr-BE` → `fr-FR`), or `undefined`.
104
+ */
105
+ function firstSupportedLocale(candidates: readonly string[]): string | undefined {
106
+ for (const candidate of candidates) {
107
+ const exact = normalizeLocale(candidate);
108
+ if (exact) return exact;
109
+ const base = getBaseLanguage(candidate);
110
+ const byBase = SUPPORTED_LANGUAGES.find((entry) => entry.language === base);
111
+ if (byBase) return byBase.code;
112
+ }
113
+ return undefined;
114
+ }
115
+
94
116
  /**
95
117
  * Resolve the device/browser locale, mapped to a supported catalog locale.
96
118
  *
@@ -123,15 +145,7 @@ function resolveDeviceLocale(): string {
123
145
  // navigator-provided candidates (or the fallback locale below).
124
146
  }
125
147
 
126
- for (const candidate of candidates) {
127
- const exact = normalizeLocale(candidate);
128
- if (exact) return exact;
129
- const base = getBaseLanguage(candidate);
130
- const byBase = SUPPORTED_LANGUAGES.find((entry) => entry.language === base);
131
- if (byBase) return byBase.code;
132
- }
133
-
134
- return FALLBACK_LOCALE;
148
+ return firstSupportedLocale(candidates) ?? FALLBACK_LOCALE;
135
149
  }
136
150
 
137
151
  /**
@@ -143,6 +157,9 @@ function resolveDeviceLocale(): string {
143
157
  * follow the account's language automatically.
144
158
  * - Signed out → a locally-chosen guest override if one exists, otherwise the
145
159
  * device locale.
160
+ * - On a platform that names its preferred languages (ADR 0058 R11) → those,
161
+ * signed in or out, from the first render, as a Mac app follows the
162
+ * system's preferred languages.
146
163
  *
147
164
  * The only external system this hook synchronizes with is local storage (the
148
165
  * guest override), which is loaded once on mount.
@@ -154,6 +171,7 @@ export const useLanguageManagement = ({
154
171
  entryLinkReady = true,
155
172
  legacyLanguageKeys,
156
173
  user,
174
+ platformLanguages = null,
157
175
  onError,
158
176
  logger,
159
177
  }: UseLanguageManagementOptions): UseLanguageManagementResult => {
@@ -279,19 +297,36 @@ export const useLanguageManagement = ({
279
297
 
280
298
  const setLanguage = useCallback((locale: string) => setLanguages([locale]), [setLanguages]);
281
299
 
300
+ // The platform's languages as supported locales, primary first; `null` where
301
+ // the platform names none. Keyed by value: a new snapshot of the same
302
+ // languages changes nothing.
303
+ const platformKey = platformLanguages ? JSON.stringify(platformLanguages) : null;
304
+ const platform = useMemo<string[] | null>(() => {
305
+ if (platformKey === null) return null;
306
+ const tags: string[] = JSON.parse(platformKey);
307
+ const supported = tags.flatMap((tag) => firstSupportedLocale([tag]) ?? []);
308
+ return supported.length ? [...new Set(supported)] : [FALLBACK_LOCALE];
309
+ }, [platformKey]);
310
+
282
311
  const languages = useMemo<string[]>(() => {
312
+ if (platform) {
313
+ return platform;
314
+ }
283
315
  if (user) {
284
316
  return getUserLanguages(user);
285
317
  }
286
318
  return guestLanguages;
287
- }, [user, guestLanguages]);
319
+ }, [platform, user, guestLanguages]);
288
320
 
289
321
  const currentLanguage = useMemo<string>(() => {
322
+ if (platform) {
323
+ return platform[0] ?? FALLBACK_LOCALE;
324
+ }
290
325
  if (user) {
291
326
  return getPrimaryLanguage(user) ?? FALLBACK_LOCALE;
292
327
  }
293
328
  return guestLanguages[0] ?? deviceLanguage;
294
- }, [user, guestLanguages, deviceLanguage]);
329
+ }, [platform, user, guestLanguages, deviceLanguage]);
295
330
 
296
331
  const metadata = useMemo(() => getLanguageMetadata(currentLanguage), [currentLanguage]);
297
332
  const languageName = useMemo(() => getLanguageName(currentLanguage), [currentLanguage]);
@@ -302,7 +337,7 @@ export const useLanguageManagement = ({
302
337
 
303
338
  return {
304
339
  currentLanguage,
305
- isLanguageReady,
340
+ isLanguageReady: platform !== null || isLanguageReady,
306
341
  languages,
307
342
  metadata,
308
343
  languageName,
@@ -107,6 +107,15 @@ function validAccount(account: unknown): OxyHostAccount | null {
107
107
  };
108
108
  }
109
109
 
110
+ /** The platform's preferred languages (R11): the non-empty tags, or none at all. */
111
+ function validPreferredLanguages(languages: unknown): { preferredLanguages?: string[] } {
112
+ if (!Array.isArray(languages)) return {};
113
+ const kept = languages.filter(
114
+ (language): language is string => typeof language === 'string' && language !== '',
115
+ );
116
+ return kept.length > 0 ? { preferredLanguages: kept } : {};
117
+ }
118
+
110
119
  /**
111
120
  * The host's snapshot, checked. A host that throws or answers something that is
112
121
  * not a snapshot is `unavailable` — signed out, never a reason to sign in here.
@@ -124,13 +133,20 @@ export function readHostSnapshot(host: OxySessionHost): OxyHostSnapshot {
124
133
  return UNAVAILABLE;
125
134
  }
126
135
  const online = candidate.online === true;
136
+ const preferred = validPreferredLanguages(candidate.preferredLanguages);
127
137
  if (candidate.status === 'signed_in') {
128
138
  const account = validAccount(candidate.account);
129
139
  if (!account) return UNAVAILABLE;
130
- return { status: 'signed_in', revision: candidate.revision, account, online };
140
+ return { status: 'signed_in', revision: candidate.revision, account, online, ...preferred };
131
141
  }
132
142
  if (candidate.status === 'signed_out' || candidate.status === 'unavailable') {
133
- return { status: candidate.status, revision: candidate.revision, account: null, online };
143
+ return {
144
+ status: candidate.status,
145
+ revision: candidate.revision,
146
+ account: null,
147
+ online,
148
+ ...preferred,
149
+ };
134
150
  }
135
151
  return UNAVAILABLE;
136
152
  }
@@ -7,7 +7,13 @@
7
7
  */
8
8
 
9
9
  import { EMAIL_VERIFICATION_ERROR_CODES, SIGN_IN_ERROR_CODES } from '@oxy.so/contracts/client';
10
- import { ErrorCodes, getErrorStatus, isRateLimitError, isServerError } from '@oxy.so/core';
10
+ import {
11
+ ErrorCodes,
12
+ getErrorStatus,
13
+ isRateLimitError,
14
+ isServerError,
15
+ retryAfterSecondsOf,
16
+ } from '@oxy.so/core';
11
17
  import type { Translate } from '../hooks/useI18n';
12
18
 
13
19
  /** How long a screen waits after a 429 that names no wait of its own. */
@@ -32,9 +38,8 @@ export const OFFLINE_ERROR_CODES: ReadonlySet<string> = new Set([
32
38
 
33
39
  /** How long to wait after a 429, from the API's `retryAfterSeconds` when it sent one. */
34
40
  export function retryAfterSeconds(error: unknown): number {
35
- const seconds = (error as { details?: { retryAfterSeconds?: unknown } } | undefined)?.details
36
- ?.retryAfterSeconds;
37
- return typeof seconds === 'number' && seconds > 0 ? Math.ceil(seconds) : RATE_LIMIT_SECONDS;
41
+ const seconds = retryAfterSecondsOf(error);
42
+ return seconds === undefined ? RATE_LIMIT_SECONDS : Math.ceil(seconds);
38
43
  }
39
44
 
40
45
  /**