@hadoku/ui-shell 0.1.265 → 0.1.266

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/sound/mix.js CHANGED
@@ -13,6 +13,7 @@
13
13
  * repeating; a `reversed` role plays its target's cell backwards; an empty
14
14
  * cell falls back down its `fallback` chain.
15
15
  */
16
+ import { pickNotLast } from '@wolffm/platform-wire/random';
16
17
  let ambientRegistry = { roles: new Map(), fallback: {}, reversed: {} };
17
18
  /** The registry a bare `createMixPlanner()` builds against, for a call site that leans on its default. The game sets this once, with its real roles, before such a call; new code prefers `createSound`. */
18
19
  export function configureSoundRoles(registry) {
@@ -34,14 +35,6 @@ export const DEFAULT_MIX = {
34
35
  opponent: 0.6,
35
36
  collapseMs: 80,
36
37
  };
37
- /** Pick one file at random, never the same one twice in a row — unless there is only one to pick. */
38
- function pickRandom(files, last, rng) {
39
- if (files.length === 0)
40
- return null;
41
- const options = files.length > 1 && last !== null ? files.filter((f) => f !== last) : files;
42
- const i = Math.floor(rng() * options.length);
43
- return options[Math.min(i, options.length - 1)] ?? null;
44
- }
45
38
  function cueTakesOf(registry, cells) {
46
39
  const isMusic = (cell) => registry.roles.get(cell.slice(0, cell.indexOf('|')))?.bus === 'music';
47
40
  return [...new Set(Object.entries(cells).flatMap(([cell, files]) => (isMusic(cell) ? [] : files)))].sort();
@@ -88,7 +81,7 @@ function buildPlanner(registry, rng) {
88
81
  result.skipped.push({ cell: layer.cell, reason: 'collapsed' });
89
82
  continue;
90
83
  }
91
- const file = pickRandom(cells[layer.cell] ?? [], lastPick.get(layer.cell) ?? null, rng);
84
+ const file = pickNotLast(cells[layer.cell] ?? [], lastPick.get(layer.cell) ?? null, rng);
92
85
  if (file === null) {
93
86
  result.skipped.push({ cell: layer.cell, reason: 'empty' });
94
87
  continue;
@@ -11,23 +11,7 @@
11
11
  * it out; within a rank, unplaced before placed, edited before the take it
12
12
  * was made from; a fallback pool pads a thin choice to `minChoices`.
13
13
  */
14
- /** A seeded shuffle (mulberry32 + Fisher-Yates): the same seed, the same order. */
15
- function shuffled(items, seed) {
16
- let a = seed >>> 0;
17
- const rand = () => {
18
- a = (a + 0x6d2b79f5) >>> 0;
19
- let t = a;
20
- t = Math.imul(t ^ (t >>> 15), t | 1);
21
- t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
22
- return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
23
- };
24
- const out = [...items];
25
- for (let i = out.length - 1; i > 0; i--) {
26
- const j = Math.floor(rand() * (i + 1));
27
- [out[i], out[j]] = [out[j], out[i]];
28
- }
29
- return out;
30
- }
14
+ import { mulberry32, shuffle } from '@wolffm/platform-wire/random';
31
15
  const folderOf = (file) => file.slice(0, file.indexOf('/'));
32
16
  /** Build one queue against the game's own catalog and ranking. Pure mechanics otherwise: no cell grammar, no role or folder names. */
33
17
  export function createSoundQueue(config) {
@@ -71,7 +55,7 @@ export function createSoundQueue(config) {
71
55
  }
72
56
  function queueOrder(cells, skipped, seed, takes) {
73
57
  const items = takes === undefined ? emptyCells(cells) : queueCells(cells, takes);
74
- const all = seed === undefined ? items : shuffled(items, seed);
58
+ const all = seed === undefined ? items : shuffle(items, mulberry32(seed));
75
59
  const later = new Set(skipped);
76
60
  const back = skipped.map((c) => all.find((i) => i.cell === c)).filter((i) => i !== undefined);
77
61
  return [...all.filter((i) => !later.has(i.cell)), ...back];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/ui-shell",
3
- "version": "0.1.265",
4
- "gitHead": "8b28f20837041731519c303b5c9aff80deed9780",
3
+ "version": "0.1.266",
4
+ "gitHead": "33e217cc0042251707965b5aaac76997909d9fdf",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "The parts of a game's UI any game keeps: chrome, trim, room shell, embed mount, theme and settings frame, UI scale, usage counting, the sound mixer, motion and generic components. One appId parameterizes its storage keys, events and chat prefix. MIT; imports only react, react-dom, platform-wire and @wolffm/*.",
@@ -72,7 +72,7 @@
72
72
  "react-dom": "^19.2.8"
73
73
  },
74
74
  "dependencies": {
75
- "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.265",
75
+ "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.266",
76
76
  "@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.4",
77
77
  "@wolffm/themes": "npm:@hadoku/themes@^5.14.22",
78
78
  "zod": "^4.6.7"