@hadoku/prefs-client 1.1.14 → 1.1.15

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/dist/avatar.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as AvatarCosmetics, C as CosmeticsView, L as LoadoutUpdate } from './cosmetics-contract-CfWEWT9I.js';
2
- export { a as CosmeticSlot, b as Loadout, P as Placement } from './cosmetics-contract-CfWEWT9I.js';
1
+ import { A as AvatarCosmetics, C as CosmeticsView, L as LoadoutUpdate } from './cosmetics-contract-CzRH-ZG0.js';
2
+ export { a as CosmeticSlot, b as Loadout, P as Placement } from './cosmetics-contract-CzRH-ZG0.js';
3
3
 
4
4
  /**
5
5
  * Avatars — the wire contract, shared by prefs-api and the client.
@@ -132,6 +132,14 @@ interface AvatarCosmetics {
132
132
  message?: string;
133
133
  placement?: Placement;
134
134
  }
135
+ /**
136
+ * What someone wears, as an app relays it over its own wire (a room's presence),
137
+ * made safe to render: known, shown items in their own slots only, and the
138
+ * placement refitted to the allowed area. Ownership was decided by prefs-api,
139
+ * which only ever serves what a person owns; this guards the shape, not the
140
+ * inventory. Undefined when nothing valid is worn.
141
+ */
142
+ declare function cleanWorn(raw: unknown): AvatarCosmetics | undefined;
135
143
  /** In AvatarSettings: what the owner has earned and what they wear. */
136
144
  interface CosmeticsView {
137
145
  /** What the person can wear: free items and the earned ones granted, in catalogue order. */
@@ -171,4 +179,4 @@ interface CosmeticGrantList {
171
179
  }[];
172
180
  }
173
181
 
174
- export { type AvatarCosmetics as A, type Box as B, type CosmeticsView as C, EARNED_COSMETICS as E, type LoadoutUpdate as L, type OverlayArt as O, type Placement as P, type CosmeticSlot as a, type Loadout as b, COSMETICS as c, COSMETICS_BY_ID as d, COSMETIC_ID_PATTERN as e, COSMETIC_SLOTS as f, type CosmeticGrantList as g, type CosmeticGrantRequest as h, type CosmeticItem as i, PLACEMENT_DEFAULT as j, PLACEMENT_LIMITS as k, PLACEMENT_ZONE as l, cleanLoadout as m, emptyLoadout as n, fitPlacement as o, overlayBounds as p, ownedFrom as q, wornCosmetics as w };
182
+ export { type AvatarCosmetics as A, type Box as B, type CosmeticsView as C, EARNED_COSMETICS as E, type LoadoutUpdate as L, type OverlayArt as O, type Placement as P, type CosmeticSlot as a, type Loadout as b, COSMETICS as c, COSMETICS_BY_ID as d, COSMETIC_ID_PATTERN as e, COSMETIC_SLOTS as f, type CosmeticGrantList as g, type CosmeticGrantRequest as h, type CosmeticItem as i, PLACEMENT_DEFAULT as j, PLACEMENT_LIMITS as k, PLACEMENT_ZONE as l, cleanLoadout as m, cleanWorn as n, emptyLoadout as o, fitPlacement as p, overlayBounds as q, ownedFrom as r, wornCosmetics as w };
@@ -1,5 +1,5 @@
1
- import { A as AvatarCosmetics, P as Placement } from './cosmetics-contract-CfWEWT9I.js';
2
- export { B as Box, c as COSMETICS, d as COSMETICS_BY_ID, e as COSMETIC_ID_PATTERN, f as COSMETIC_SLOTS, g as CosmeticGrantList, h as CosmeticGrantRequest, i as CosmeticItem, a as CosmeticSlot, C as CosmeticsView, E as EARNED_COSMETICS, b as Loadout, L as LoadoutUpdate, O as OverlayArt, j as PLACEMENT_DEFAULT, k as PLACEMENT_LIMITS, l as PLACEMENT_ZONE, m as cleanLoadout, n as emptyLoadout, o as fitPlacement, p as overlayBounds, q as ownedFrom, w as wornCosmetics } from './cosmetics-contract-CfWEWT9I.js';
1
+ import { A as AvatarCosmetics, P as Placement } from './cosmetics-contract-CzRH-ZG0.js';
2
+ export { B as Box, c as COSMETICS, d as COSMETICS_BY_ID, e as COSMETIC_ID_PATTERN, f as COSMETIC_SLOTS, g as CosmeticGrantList, h as CosmeticGrantRequest, i as CosmeticItem, a as CosmeticSlot, C as CosmeticsView, E as EARNED_COSMETICS, b as Loadout, L as LoadoutUpdate, O as OverlayArt, j as PLACEMENT_DEFAULT, k as PLACEMENT_LIMITS, l as PLACEMENT_ZONE, m as cleanLoadout, n as cleanWorn, o as emptyLoadout, p as fitPlacement, q as overlayBounds, r as ownedFrom, w as wornCosmetics } from './cosmetics-contract-CzRH-ZG0.js';
3
3
 
4
4
  /**
5
5
  * Avatar cosmetics — the renderer every app uses, so a name, an avatar and a
package/dist/cosmetics.js CHANGED
@@ -179,6 +179,21 @@ function emptyLoadout() {
179
179
  placement: {}
180
180
  };
181
181
  }
182
+ function cleanWorn(raw) {
183
+ if (!raw || typeof raw !== "object") return void 0;
184
+ const src = raw;
185
+ const worn = {};
186
+ for (const slot of COSMETIC_SLOTS) {
187
+ const id = src[slot];
188
+ const it = typeof id === "string" ? COSMETICS_BY_ID.get(id) : void 0;
189
+ if (it && !it.hidden && it.slot === slot) worn[slot] = it.id;
190
+ }
191
+ const art = worn.overlay ? COSMETICS_BY_ID.get(worn.overlay)?.art : void 0;
192
+ if (art && src.placement && typeof src.placement === "object") {
193
+ worn.placement = fitPlacement(art, src.placement);
194
+ }
195
+ return Object.keys(worn).length ? worn : void 0;
196
+ }
182
197
  function cleanLoadout(raw, owned) {
183
198
  const out = emptyLoadout();
184
199
  const src = raw && typeof raw === "object" ? raw : {};
@@ -510,6 +525,7 @@ export {
510
525
  PLACEMENT_ZONE,
511
526
  avatarHtml,
512
527
  cleanLoadout,
528
+ cleanWorn,
513
529
  colourStyle,
514
530
  cosmeticsCss,
515
531
  decorHtml,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/prefs-client",
3
- "version": "1.1.14",
4
- "gitHead": "f2f471f8417ec144486c7cf530f87a632e0653b6",
3
+ "version": "1.1.15",
4
+ "gitHead": "bdf1c74cc458107cf5cb7a427fbfc319cb5f5b95",
5
5
  "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), the one resolved avatar per user (./avatar), and the avatar cosmetics renderer (./cosmetics).",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",