@hadoku/prefs-client 1.1.10 → 1.1.11
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/README.md +8 -1
- package/dist/avatar.d.ts +16 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -147,9 +147,16 @@ const byUser = await resolveAvatars(
|
|
|
147
147
|
{ serviceKey: process.env.SERVICE_KEY! },
|
|
148
148
|
userIds
|
|
149
149
|
);
|
|
150
|
-
// every requested id is present; unknown users resolve to { source: 'sprite' }
|
|
150
|
+
// every requested id is present; unknown users resolve to { source: 'sprite', name: null }
|
|
151
|
+
byUser[id].name; // their live display name, or null for an unknown or closed account
|
|
151
152
|
```
|
|
152
153
|
|
|
154
|
+
**Names come from here too.** A server stores only userIds (IDENTITY_MODEL R12) and names
|
|
155
|
+
people, online or not, when it shows them: `resolveAvatars(...)[id].name`. Never keep a copy.
|
|
156
|
+
prefs-api reads the registry at most once a minute per isolate, so a rename shows within a
|
|
157
|
+
minute and a deleted account stops being named. Over HTTP it is `POST /prefs/api/v1/_avatar/resolve`
|
|
158
|
+
`{ userIds }` with a service-tier `X-User-Key`.
|
|
159
|
+
|
|
153
160
|
Rules for an app that renders avatars:
|
|
154
161
|
|
|
155
162
|
- **`url` → `<img src>`**, nothing else: never fetch it server-side, never proxy it. Set
|
package/dist/avatar.d.ts
CHANGED
|
@@ -93,9 +93,18 @@ interface LinkStart {
|
|
|
93
93
|
interface ResolveRequest {
|
|
94
94
|
userIds: string[];
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* One person as a server shows them: their avatar and their live display name.
|
|
98
|
+
* `name` is null for an unknown id or a closed (deleted, banned) account, so a
|
|
99
|
+
* server that stores only userIds (IDENTITY_MODEL R12) names people at display
|
|
100
|
+
* time and never keeps a copy.
|
|
101
|
+
*/
|
|
102
|
+
interface ResolvedPerson extends ResolvedAvatar {
|
|
103
|
+
name: string | null;
|
|
104
|
+
}
|
|
96
105
|
interface ResolveResponse {
|
|
97
|
-
/** Every requested id is present; an unknown user resolves to `{ source: 'sprite' }`. */
|
|
98
|
-
avatars: Record<string,
|
|
106
|
+
/** Every requested id is present; an unknown user resolves to `{ source: 'sprite', name: null }`. */
|
|
107
|
+
avatars: Record<string, ResolvedPerson>;
|
|
99
108
|
}
|
|
100
109
|
declare const RESOLVE_MAX_IDS = 100;
|
|
101
110
|
/** A watchparty character id, as prefs-api accepts one from the watchparty blob. */
|
|
@@ -156,9 +165,11 @@ interface ResolveAvatarsOptions extends AvatarClientOptions {
|
|
|
156
165
|
serviceKey: string;
|
|
157
166
|
}
|
|
158
167
|
/**
|
|
159
|
-
* Server-side: resolve many users
|
|
168
|
+
* Server-side: resolve many users by userId: each one's avatar and live display
|
|
169
|
+
* `name` (null for an unknown or closed account). Store only the userId and
|
|
170
|
+
* call this when showing people (IDENTITY_MODEL R12). Batches past
|
|
160
171
|
* RESOLVE_MAX_IDS for you. Every requested id is in the result.
|
|
161
172
|
*/
|
|
162
|
-
declare function resolveAvatars(opts: ResolveAvatarsOptions, userIds: readonly string[]): Promise<Record<string,
|
|
173
|
+
declare function resolveAvatars(opts: ResolveAvatarsOptions, userIds: readonly string[]): Promise<Record<string, ResolvedPerson>>;
|
|
163
174
|
|
|
164
|
-
export { AVATAR_SOURCES, type AvatarClient, type AvatarClientOptions, AvatarError, type AvatarSettings, type AvatarSource, type AvatarUpdate, type AvatarUploadLimits, LINK_CALLBACK_PATH, LINK_MESSAGE_TYPE, LINK_POPUP_MARK, LINK_PROVIDERS, type LinkMessage, type LinkProvider, type LinkStart, type LinkedAccountView, RESOLVE_MAX_IDS, type ResolveAvatarsOptions, type ResolveRequest, type ResolveResponse, type ResolvedAvatar, SPRITE_ID_PATTERN, type UploadView, createAvatarClient, resolveAvatars };
|
|
175
|
+
export { AVATAR_SOURCES, type AvatarClient, type AvatarClientOptions, AvatarError, type AvatarSettings, type AvatarSource, type AvatarUpdate, type AvatarUploadLimits, LINK_CALLBACK_PATH, LINK_MESSAGE_TYPE, LINK_POPUP_MARK, LINK_PROVIDERS, type LinkMessage, type LinkProvider, type LinkStart, type LinkedAccountView, RESOLVE_MAX_IDS, type ResolveAvatarsOptions, type ResolveRequest, type ResolveResponse, type ResolvedAvatar, type ResolvedPerson, SPRITE_ID_PATTERN, type UploadView, createAvatarClient, resolveAvatars };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hadoku/prefs-client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"description": "Client SDK for the hadoku unified preferences store. Wraps /prefs/api/v1/* with localStorage caching, debounced writes, Zod-validated reads, and a usePrefs() React hook, plus match history, ratings and leaderboards for every game (./games), and the one resolved avatar per user (./avatar).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|