@hadoku/rooms-protocol 0.45.114 → 0.45.115

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/avatars.d.ts CHANGED
@@ -5,8 +5,10 @@
5
5
  * board, bomberman's arena), so the list of ids is room protocol, not any one
6
6
  * app's content. Ids are generic archetypes, never a character's name: the art
7
7
  * is fan art of third-party characters, and the names stay out of every repo.
8
- * Portraits live on watchparty's media as `square_<id>.png`; colours, grouping
9
- * and art revisions are each app's presentation and stay with the app.
8
+ * Portraits live on watchparty's media as `square_<id>.png`, and every app
9
+ * draws them, so their URL is room protocol too: `avatarPortraitPath`, with the
10
+ * art revisions it carries. Colours and grouping are each app's presentation
11
+ * and stay with the app.
10
12
  *
11
13
  * Append a new character, never insert one: apps draw the cast in this order
12
14
  * (watchparty's picker, its colour table) and their tables are checked
@@ -14,6 +16,21 @@
14
16
  */
15
17
  export declare const AVATAR_POOL: readonly ["sage", "herald", "cleric", "knight", "mage", "brawler", "wanderer", "rogue", "gunner", "chief", "walker", "operative", "idol", "recluse", "phantom", "harlequin", "doll", "imp", "apprentice", "prodigy", "dreamer", "sunny", "mentor"];
16
18
  export type AvatarId = (typeof AVATAR_POOL)[number];
19
+ /**
20
+ * A portrait's revision, for art redrawn in place: bump it when
21
+ * `media/sprites/square_<id>.png` is replaced. The sprites are served immutable
22
+ * for a year, so without a new URL a browser that has seen the old image keeps
23
+ * showing it. An id not listed is revision 1, never redrawn.
24
+ */
25
+ export declare const AVATAR_ART_REV: Readonly<Partial<Record<AvatarId, number>>>;
26
+ /**
27
+ * A character's portrait, as a path under watchparty's server root:
28
+ * `/media/sprites/square_<id>.png`, with `?v=<rev>` once its art has been
29
+ * redrawn (`AVATAR_ART_REV`), so the year-long cache cannot keep the old art.
30
+ * Untouched portraits keep their bare URL and stay cached. Each app prefixes
31
+ * the origin it reaches watchparty's media on.
32
+ */
33
+ export declare function avatarPortraitPath(id: string): string;
17
34
  /** Narrow an arbitrary string (it arrives off the wire) to a pool id. */
18
35
  export declare function isAvatarId(id: string | null | undefined): id is AvatarId;
19
36
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"avatars.d.ts","sourceRoot":"","sources":["../src/avatars.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,oPAKd,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpD,yEAAyE;AACzE,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,EAAE,IAAI,QAAQ,CAExE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,QAAQ,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EACzC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,EACzB,IAAI,GAAE,SAAS,MAAM,EAAgB,EACrC,IAAI,GAAE,MAAM,MAAoB,GAC/B,MAAM,GAAG,SAAS,CAMpB"}
1
+ {"version":3,"file":"avatars.d.ts","sourceRoot":"","sources":["../src/avatars.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,oPAKd,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAGtE,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED,yEAAyE;AACzE,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,EAAE,IAAI,QAAQ,CAExE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,QAAQ,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EACzC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,EACzB,IAAI,GAAE,SAAS,MAAM,EAAgB,EACrC,IAAI,GAAE,MAAM,MAAoB,GAC/B,MAAM,GAAG,SAAS,CAMpB"}
package/dist/avatars.js CHANGED
@@ -5,8 +5,10 @@
5
5
  * board, bomberman's arena), so the list of ids is room protocol, not any one
6
6
  * app's content. Ids are generic archetypes, never a character's name: the art
7
7
  * is fan art of third-party characters, and the names stay out of every repo.
8
- * Portraits live on watchparty's media as `square_<id>.png`; colours, grouping
9
- * and art revisions are each app's presentation and stay with the app.
8
+ * Portraits live on watchparty's media as `square_<id>.png`, and every app
9
+ * draws them, so their URL is room protocol too: `avatarPortraitPath`, with the
10
+ * art revisions it carries. Colours and grouping are each app's presentation
11
+ * and stay with the app.
10
12
  *
11
13
  * Append a new character, never insert one: apps draw the cast in this order
12
14
  * (watchparty's picker, its colour table) and their tables are checked
@@ -18,6 +20,27 @@ export const AVATAR_POOL = [
18
20
  'idol', 'recluse', 'phantom', 'harlequin', 'doll', 'imp',
19
21
  'apprentice', 'prodigy', 'dreamer', 'sunny', 'mentor',
20
22
  ];
23
+ /**
24
+ * A portrait's revision, for art redrawn in place: bump it when
25
+ * `media/sprites/square_<id>.png` is replaced. The sprites are served immutable
26
+ * for a year, so without a new URL a browser that has seen the old image keeps
27
+ * showing it. An id not listed is revision 1, never redrawn.
28
+ */
29
+ export const AVATAR_ART_REV = {
30
+ walker: 2,
31
+ doll: 2,
32
+ };
33
+ /**
34
+ * A character's portrait, as a path under watchparty's server root:
35
+ * `/media/sprites/square_<id>.png`, with `?v=<rev>` once its art has been
36
+ * redrawn (`AVATAR_ART_REV`), so the year-long cache cannot keep the old art.
37
+ * Untouched portraits keep their bare URL and stay cached. Each app prefixes
38
+ * the origin it reaches watchparty's media on.
39
+ */
40
+ export function avatarPortraitPath(id) {
41
+ const rev = AVATAR_ART_REV[id] ?? 1;
42
+ return `/media/sprites/square_${encodeURIComponent(id)}.png${rev > 1 ? `?v=${rev}` : ''}`;
43
+ }
21
44
  /** Narrow an arbitrary string (it arrives off the wire) to a pool id. */
22
45
  export function isAvatarId(id) {
23
46
  return !!id && AVATAR_POOL.includes(id);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/rooms-protocol",
3
- "version": "0.45.114",
4
- "gitHead": "684f61a93b2c357723cf4c91d793e5e0a71ed089",
3
+ "version": "0.45.115",
4
+ "gitHead": "64bb98a4b284ededee071c8d1be12853d0f02d60",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "Room, identity and seating protocol — the wire contract shared by rooms-server and rooms-client.",