@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.
Files changed (70) 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/LanguageBridge.js +7 -3
  8. package/lib/commonjs/ui/components/LanguageBridge.js.map +1 -1
  9. package/lib/commonjs/ui/context/OxyContext.js +1 -0
  10. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  11. package/lib/commonjs/ui/context/OxyHostedContext.js +28 -2
  12. package/lib/commonjs/ui/context/OxyHostedContext.js.map +1 -1
  13. package/lib/commonjs/ui/hooks/useSurfaceHeader.js +25 -11
  14. package/lib/commonjs/ui/hooks/useSurfaceHeader.js.map +1 -1
  15. package/lib/commonjs/ui/icons/subsetGlyphMaps.js +1 -0
  16. package/lib/commonjs/ui/icons/subsetGlyphMaps.js.map +1 -1
  17. package/lib/commonjs/ui/session/hostSession.js +11 -2
  18. package/lib/commonjs/ui/session/hostSession.js.map +1 -1
  19. package/lib/module/assets/assets/fonts/icons/OxyServicesIonicons.ttf +0 -0
  20. package/lib/module/assets/assets/fonts/icons/OxyServicesMaterialCommunityIcons.ttf +0 -0
  21. package/lib/module/assets/assets/fonts/icons/manifest.json +5 -4
  22. package/lib/module/assets/fonts/icons/OxyServicesIonicons.ttf +0 -0
  23. package/lib/module/assets/fonts/icons/OxyServicesMaterialCommunityIcons.ttf +0 -0
  24. package/lib/module/assets/fonts/icons/manifest.json +5 -4
  25. package/lib/module/ui/components/LanguageBridge.js +7 -3
  26. package/lib/module/ui/components/LanguageBridge.js.map +1 -1
  27. package/lib/module/ui/context/OxyContext.js +1 -0
  28. package/lib/module/ui/context/OxyContext.js.map +1 -1
  29. package/lib/module/ui/context/OxyHostedContext.js +29 -3
  30. package/lib/module/ui/context/OxyHostedContext.js.map +1 -1
  31. package/lib/module/ui/hooks/useSurfaceHeader.js +25 -11
  32. package/lib/module/ui/hooks/useSurfaceHeader.js.map +1 -1
  33. package/lib/module/ui/icons/subsetGlyphMaps.js +1 -0
  34. package/lib/module/ui/icons/subsetGlyphMaps.js.map +1 -1
  35. package/lib/module/ui/session/hostSession.js +11 -2
  36. package/lib/module/ui/session/hostSession.js.map +1 -1
  37. package/lib/typescript/commonjs/ui/components/LanguageBridge.d.ts.map +1 -1
  38. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
  39. package/lib/typescript/commonjs/ui/context/OxyHostedContext.d.ts.map +1 -1
  40. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts +8 -0
  41. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts.map +1 -1
  42. package/lib/typescript/commonjs/ui/hooks/useSurfaceHeader.d.ts.map +1 -1
  43. package/lib/typescript/commonjs/ui/icons/MaterialCommunityIcons.d.ts +1 -1
  44. package/lib/typescript/commonjs/ui/icons/MaterialCommunityIcons.d.ts.map +1 -1
  45. package/lib/typescript/commonjs/ui/icons/subsetGlyphMaps.d.ts +1 -0
  46. package/lib/typescript/commonjs/ui/icons/subsetGlyphMaps.d.ts.map +1 -1
  47. package/lib/typescript/commonjs/ui/session/hostSession.d.ts.map +1 -1
  48. package/lib/typescript/module/ui/components/LanguageBridge.d.ts.map +1 -1
  49. package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
  50. package/lib/typescript/module/ui/context/OxyHostedContext.d.ts.map +1 -1
  51. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts +8 -0
  52. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts.map +1 -1
  53. package/lib/typescript/module/ui/hooks/useSurfaceHeader.d.ts.map +1 -1
  54. package/lib/typescript/module/ui/icons/MaterialCommunityIcons.d.ts +1 -1
  55. package/lib/typescript/module/ui/icons/MaterialCommunityIcons.d.ts.map +1 -1
  56. package/lib/typescript/module/ui/icons/subsetGlyphMaps.d.ts +1 -0
  57. package/lib/typescript/module/ui/icons/subsetGlyphMaps.d.ts.map +1 -1
  58. package/lib/typescript/module/ui/session/hostSession.d.ts.map +1 -1
  59. package/package.json +5 -5
  60. package/src/assets/fonts/icons/OxyServicesIonicons.ttf +0 -0
  61. package/src/assets/fonts/icons/OxyServicesMaterialCommunityIcons.ttf +0 -0
  62. package/src/assets/fonts/icons/manifest.json +5 -4
  63. package/src/ui/components/LanguageBridge.tsx +6 -3
  64. package/src/ui/components/__tests__/LanguageBridge.test.tsx +17 -0
  65. package/src/ui/context/OxyContext.tsx +1 -0
  66. package/src/ui/context/OxyHostedContext.tsx +43 -3
  67. package/src/ui/context/oxyContextTypes.ts +8 -0
  68. package/src/ui/hooks/useSurfaceHeader.ts +50 -15
  69. package/src/ui/icons/subsetGlyphMaps.ts +1 -0
  70. 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 { createHostSession, HostedSessionError, type HostSession } from '../session/hostSession';
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
- 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,
@@ -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