@oxy.so/services 14.18.0 → 14.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/lib/commonjs/assets/assets/fonts/icons/OxyServicesIonicons.ttf +0 -0
  2. package/lib/commonjs/assets/assets/fonts/icons/OxyServicesMaterialCommunityIcons.ttf +0 -0
  3. package/lib/commonjs/assets/assets/fonts/icons/manifest.json +5 -4
  4. package/lib/commonjs/assets/fonts/icons/OxyServicesIonicons.ttf +0 -0
  5. package/lib/commonjs/assets/fonts/icons/OxyServicesMaterialCommunityIcons.ttf +0 -0
  6. package/lib/commonjs/assets/fonts/icons/manifest.json +5 -4
  7. package/lib/commonjs/ui/components/AccountLanguageBoundary.js +4 -2
  8. package/lib/commonjs/ui/components/AccountLanguageBoundary.js.map +1 -1
  9. package/lib/commonjs/ui/components/LanguageBridge.js +63 -22
  10. package/lib/commonjs/ui/components/LanguageBridge.js.map +1 -1
  11. package/lib/commonjs/ui/context/OxyHostedContext.js +18 -2
  12. package/lib/commonjs/ui/context/OxyHostedContext.js.map +1 -1
  13. package/lib/commonjs/ui/hooks/useLanguageManagement.js +40 -11
  14. package/lib/commonjs/ui/hooks/useLanguageManagement.js.map +1 -1
  15. package/lib/commonjs/ui/hooks/useSurfaceHeader.js +25 -11
  16. package/lib/commonjs/ui/hooks/useSurfaceHeader.js.map +1 -1
  17. package/lib/commonjs/ui/icons/subsetGlyphMaps.js +1 -0
  18. package/lib/commonjs/ui/icons/subsetGlyphMaps.js.map +1 -1
  19. package/lib/commonjs/ui/session/hostSession.js +14 -2
  20. package/lib/commonjs/ui/session/hostSession.js.map +1 -1
  21. package/lib/module/assets/assets/fonts/icons/OxyServicesIonicons.ttf +0 -0
  22. package/lib/module/assets/assets/fonts/icons/OxyServicesMaterialCommunityIcons.ttf +0 -0
  23. package/lib/module/assets/assets/fonts/icons/manifest.json +5 -4
  24. package/lib/module/assets/fonts/icons/OxyServicesIonicons.ttf +0 -0
  25. package/lib/module/assets/fonts/icons/OxyServicesMaterialCommunityIcons.ttf +0 -0
  26. package/lib/module/assets/fonts/icons/manifest.json +5 -4
  27. package/lib/module/ui/components/AccountLanguageBoundary.js +4 -2
  28. package/lib/module/ui/components/AccountLanguageBoundary.js.map +1 -1
  29. package/lib/module/ui/components/LanguageBridge.js +64 -23
  30. package/lib/module/ui/components/LanguageBridge.js.map +1 -1
  31. package/lib/module/ui/context/OxyHostedContext.js +18 -2
  32. package/lib/module/ui/context/OxyHostedContext.js.map +1 -1
  33. package/lib/module/ui/hooks/useLanguageManagement.js +40 -11
  34. package/lib/module/ui/hooks/useLanguageManagement.js.map +1 -1
  35. package/lib/module/ui/hooks/useSurfaceHeader.js +25 -11
  36. package/lib/module/ui/hooks/useSurfaceHeader.js.map +1 -1
  37. package/lib/module/ui/icons/subsetGlyphMaps.js +1 -0
  38. package/lib/module/ui/icons/subsetGlyphMaps.js.map +1 -1
  39. package/lib/module/ui/session/hostSession.js +14 -2
  40. package/lib/module/ui/session/hostSession.js.map +1 -1
  41. package/lib/typescript/commonjs/ui/components/AccountLanguageBoundary.d.ts.map +1 -1
  42. package/lib/typescript/commonjs/ui/components/LanguageBridge.d.ts.map +1 -1
  43. package/lib/typescript/commonjs/ui/context/OxyHostedContext.d.ts +2 -1
  44. package/lib/typescript/commonjs/ui/context/OxyHostedContext.d.ts.map +1 -1
  45. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts +11 -6
  46. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts.map +1 -1
  47. package/lib/typescript/commonjs/ui/hooks/useLanguageManagement.d.ts +11 -1
  48. package/lib/typescript/commonjs/ui/hooks/useLanguageManagement.d.ts.map +1 -1
  49. package/lib/typescript/commonjs/ui/hooks/useSurfaceHeader.d.ts.map +1 -1
  50. package/lib/typescript/commonjs/ui/icons/MaterialCommunityIcons.d.ts +1 -1
  51. package/lib/typescript/commonjs/ui/icons/MaterialCommunityIcons.d.ts.map +1 -1
  52. package/lib/typescript/commonjs/ui/icons/subsetGlyphMaps.d.ts +1 -0
  53. package/lib/typescript/commonjs/ui/icons/subsetGlyphMaps.d.ts.map +1 -1
  54. package/lib/typescript/commonjs/ui/session/hostSession.d.ts.map +1 -1
  55. package/lib/typescript/module/ui/components/AccountLanguageBoundary.d.ts.map +1 -1
  56. package/lib/typescript/module/ui/components/LanguageBridge.d.ts.map +1 -1
  57. package/lib/typescript/module/ui/context/OxyHostedContext.d.ts +2 -1
  58. package/lib/typescript/module/ui/context/OxyHostedContext.d.ts.map +1 -1
  59. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts +11 -6
  60. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts.map +1 -1
  61. package/lib/typescript/module/ui/hooks/useLanguageManagement.d.ts +11 -1
  62. package/lib/typescript/module/ui/hooks/useLanguageManagement.d.ts.map +1 -1
  63. package/lib/typescript/module/ui/hooks/useSurfaceHeader.d.ts.map +1 -1
  64. package/lib/typescript/module/ui/icons/MaterialCommunityIcons.d.ts +1 -1
  65. package/lib/typescript/module/ui/icons/MaterialCommunityIcons.d.ts.map +1 -1
  66. package/lib/typescript/module/ui/icons/subsetGlyphMaps.d.ts +1 -0
  67. package/lib/typescript/module/ui/icons/subsetGlyphMaps.d.ts.map +1 -1
  68. package/lib/typescript/module/ui/session/hostSession.d.ts.map +1 -1
  69. package/package.json +3 -3
  70. package/src/assets/fonts/icons/OxyServicesIonicons.ttf +0 -0
  71. package/src/assets/fonts/icons/OxyServicesMaterialCommunityIcons.ttf +0 -0
  72. package/src/assets/fonts/icons/manifest.json +5 -4
  73. package/src/ui/components/AccountLanguageBoundary.tsx +3 -1
  74. package/src/ui/components/LanguageBridge.tsx +75 -23
  75. package/src/ui/components/__tests__/LanguageBridge.test.tsx +55 -0
  76. package/src/ui/context/OxyHostedContext.tsx +28 -2
  77. package/src/ui/context/oxyContextTypes.ts +11 -6
  78. package/src/ui/hooks/useLanguageManagement.ts +47 -12
  79. package/src/ui/hooks/useSurfaceHeader.ts +50 -15
  80. package/src/ui/icons/subsetGlyphMaps.ts +1 -0
  81. package/src/ui/session/hostSession.ts +18 -2
@@ -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;
@@ -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,
@@ -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
- for (let i = 0; i < a.length; i += 1) {
72
- const x = a[i];
73
- const y = b[i];
74
- if (!x || !y) return false;
75
- // `icon` is a node (identity); `onPress` is ignored, like `primaryAction`'s.
76
- if (
77
- x.accessibilityLabel !== y.accessibilityLabel ||
78
- !!x.disabled !== !!y.disabled ||
79
- x.icon !== y.icon
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: () => liveContent.current?.actions?.[index]?.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
  : {}),
@@ -243,6 +243,7 @@ export const materialCommunityIconsGlyphMap = {
243
243
  "gift": 986692,
244
244
  "gift-outline": 983713,
245
245
  "grid": 983745,
246
+ "group": 983747,
246
247
  "heart": 983761,
247
248
  "heart-outline": 983765,
248
249
  "help-circle": 983767,
@@ -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
  }