@arraypress/waveform-sounds 0.3.1 → 2.1.0

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 (89) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +43 -3
  3. package/dist/waveform-sounds-no-autoinit.esm.js +607 -178
  4. package/dist/waveform-sounds-render.esm.js +79 -15
  5. package/dist/waveform-sounds.css +136 -79
  6. package/dist/waveform-sounds.esm.js +611 -181
  7. package/dist/waveform-sounds.js +608 -181
  8. package/dist/waveform-sounds.min.css +1 -1
  9. package/dist/waveform-sounds.min.js +3 -3
  10. package/package.json +36 -33
  11. package/src/css/waveform-sounds.css +136 -79
  12. package/src/js/core/WaveformSounds.ts +1366 -0
  13. package/src/js/core/element.ts +208 -0
  14. package/src/js/core/engine.ts +107 -0
  15. package/src/js/core/{options.js → options.ts} +28 -28
  16. package/src/js/data/{bpm.js → bpm.ts} +27 -17
  17. package/src/js/data/{navigation.js → navigation.ts} +31 -18
  18. package/src/js/data/{sounds.js → sounds.ts} +97 -66
  19. package/src/js/data/url-state.ts +130 -0
  20. package/src/js/dom/colors.ts +86 -0
  21. package/src/js/dom/{draw.js → draw.ts} +16 -17
  22. package/src/js/dom/{menus.js → menus.ts} +70 -55
  23. package/src/js/dom/{rows.js → rows.ts} +15 -17
  24. package/src/js/entry.ts +60 -0
  25. package/src/js/{index.js → index.ts} +7 -3
  26. package/src/js/render/{html.js → html.ts} +16 -12
  27. package/src/js/render/{icons.js → icons.ts} +3 -4
  28. package/src/js/render/{markup.js → markup.ts} +114 -64
  29. package/src/js/render/options.ts +118 -0
  30. package/src/js/render/{strings.js → strings.ts} +18 -16
  31. package/src/js/{render-entry.js → render-entry.ts} +2 -1
  32. package/src/js/shared/{utils.js → utils.ts} +24 -24
  33. package/{index.d.ts → src/js/types.ts} +40 -88
  34. package/types/core/WaveformSounds.d.ts +175 -0
  35. package/types/core/WaveformSounds.d.ts.map +1 -0
  36. package/types/core/element.d.ts +84 -0
  37. package/types/core/element.d.ts.map +1 -0
  38. package/types/core/engine.d.ts +72 -0
  39. package/types/core/engine.d.ts.map +1 -0
  40. package/types/core/options.d.ts +71 -0
  41. package/types/core/options.d.ts.map +1 -0
  42. package/types/data/bpm.d.ts +80 -0
  43. package/types/data/bpm.d.ts.map +1 -0
  44. package/types/data/navigation.d.ts +62 -0
  45. package/types/data/navigation.d.ts.map +1 -0
  46. package/types/data/sounds.d.ts +168 -0
  47. package/types/data/sounds.d.ts.map +1 -0
  48. package/types/data/url-state.d.ts +109 -0
  49. package/types/data/url-state.d.ts.map +1 -0
  50. package/types/dom/colors.d.ts +48 -0
  51. package/types/dom/colors.d.ts.map +1 -0
  52. package/types/dom/draw.d.ts +72 -0
  53. package/types/dom/draw.d.ts.map +1 -0
  54. package/types/dom/menus.d.ts +75 -0
  55. package/types/dom/menus.d.ts.map +1 -0
  56. package/types/dom/rows.d.ts +39 -0
  57. package/types/dom/rows.d.ts.map +1 -0
  58. package/types/entry.d.ts +28 -0
  59. package/types/entry.d.ts.map +1 -0
  60. package/types/index.d.ts +16 -0
  61. package/types/index.d.ts.map +1 -0
  62. package/types/render/html.d.ts +37 -0
  63. package/types/render/html.d.ts.map +1 -0
  64. package/types/render/icons.d.ts +17 -0
  65. package/types/render/icons.d.ts.map +1 -0
  66. package/types/render/markup.d.ts +141 -0
  67. package/types/render/markup.d.ts.map +1 -0
  68. package/types/render/options.d.ts +69 -0
  69. package/types/render/options.d.ts.map +1 -0
  70. package/types/render/strings.d.ts +43 -0
  71. package/types/render/strings.d.ts.map +1 -0
  72. package/types/render-entry.d.ts +8 -0
  73. package/types/render-entry.d.ts.map +1 -0
  74. package/types/shared/utils.d.ts +57 -0
  75. package/types/shared/utils.d.ts.map +1 -0
  76. package/types/types.d.ts +280 -0
  77. package/types/types.d.ts.map +1 -0
  78. package/types/vendor/arraypress-text.d.ts +250 -0
  79. package/dist/waveform-sounds-no-autoinit.cjs +0 -2159
  80. package/dist/waveform-sounds-render.cjs +0 -614
  81. package/dist/waveform-sounds.cjs +0 -2181
  82. package/no-autoinit.d.ts +0 -2
  83. package/render.d.ts +0 -5
  84. package/src/js/core/WaveformSounds.js +0 -993
  85. package/src/js/core/engine.js +0 -57
  86. package/src/js/data/url-state.js +0 -106
  87. package/src/js/dom/colors.js +0 -59
  88. package/src/js/entry.js +0 -25
  89. package/src/js/render/options.js +0 -90
@@ -8,10 +8,24 @@ var HTML_ESCAPES = Object.freeze({
8
8
  });
9
9
  function escapeHtml(input) {
10
10
  if (input === null || input === void 0) return "";
11
- return String(input).replace(/[&<>"']/g, (c) => HTML_ESCAPES[c]);
12
- }
11
+ return String(input).replace(/[&<>"']/g, (c) => HTML_ESCAPES[
12
+ /** @type {keyof typeof HTML_ESCAPES} */
13
+ c
14
+ ]);
15
+ }
16
+ var ACCENTS = Object.freeze([
17
+ [768, 879],
18
+ [1425, 1479],
19
+ [1552, 1562],
20
+ [1611, 1631],
21
+ [1648, 1648],
22
+ [6832, 6911],
23
+ [7616, 7679],
24
+ [8400, 8447],
25
+ [65056, 65071]
26
+ ]);
13
27
 
14
- // src/js/data/sounds.js
28
+ // src/js/data/sounds.ts
15
29
  function encodePeaks(peaks) {
16
30
  if (!Array.isArray(peaks)) return "";
17
31
  let out = "";
@@ -21,12 +35,25 @@ function encodePeaks(peaks) {
21
35
  }
22
36
  return out;
23
37
  }
38
+ var COMPACT_PREFIX = "wp1:";
39
+ function decodeCompact(body) {
40
+ if (!body || !/^[\w-]+$/.test(body) || body.length % 4 === 1) return null;
41
+ try {
42
+ const bytes = atob(body.replace(/-/g, "+").replace(/_/g, "/"));
43
+ const out = new Array(bytes.length);
44
+ for (let i = 0; i < bytes.length; i++) out[i] = bytes.charCodeAt(i) / 255;
45
+ return out;
46
+ } catch {
47
+ return null;
48
+ }
49
+ }
24
50
  function decodePeaks(value, scale = 1) {
25
51
  if (value == null || value === "") return null;
26
52
  if (typeof value === "string") {
53
+ if (value.startsWith(COMPACT_PREFIX)) return decodeCompact(value.slice(COMPACT_PREFIX.length));
27
54
  if (!/^[0-9a-f]+$/i.test(value) || value.length % 2) return null;
28
55
  const out2 = new Array(value.length / 2);
29
- for (let i = 0; i < out2.length; i++) out2[i] = parseInt(value.substr(i * 2, 2), 16) / 255;
56
+ for (let i = 0; i < out2.length; i++) out2[i] = parseInt(value.slice(i * 2, i * 2 + 2), 16) / 255;
30
57
  return out2;
31
58
  }
32
59
  if (!Array.isArray(value)) return null;
@@ -65,8 +92,8 @@ function parseDuration(value) {
65
92
  if (typeof value === "number") return Number.isFinite(value) && value >= 0 ? value : null;
66
93
  const str = String(value).trim();
67
94
  if (/^\d+(\.\d+)?$/.test(str)) return Number(str);
95
+ if (!/^\d+(\.\d+)?(:\d+(\.\d+)?)+$/.test(str)) return null;
68
96
  const parts = str.split(":").map(Number);
69
- if (parts.length < 2 || parts.some((n) => !Number.isFinite(n))) return null;
70
97
  return parts.reduce((acc, n) => acc * 60 + n, 0);
71
98
  }
72
99
  function titleFromUrl(url) {
@@ -154,7 +181,7 @@ function availableSorts(sorts, f) {
154
181
  return sorts.filter((sort) => SORT_NEEDS[sort]?.(f));
155
182
  }
156
183
 
157
- // src/js/render/html.js
184
+ // src/js/render/html.ts
158
185
  var VOID = /* @__PURE__ */ new Set(["input", "br", "img"]);
159
186
  function text(value) {
160
187
  return escapeHtml(value ?? "");
@@ -173,7 +200,7 @@ function h(tag, attributes = {}, ...children) {
173
200
  return open + children.flat(Infinity).filter((c) => c != null && c !== false && c !== "").join("") + `</${tag}>`;
174
201
  }
175
202
 
176
- // src/js/render/icons.js
203
+ // src/js/render/icons.ts
177
204
  function icon(path, extraClass = "") {
178
205
  const cls = extraClass ? `ws-icon ${extraClass}` : "ws-icon";
179
206
  return `<svg class="${cls}" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="${path}"/></svg>`;
@@ -188,7 +215,10 @@ var ICONS = {
188
215
  loop: icon("M17 4l3 3-3 3V8H8a3 3 0 0 0-3 3v1H3v-1a5 5 0 0 1 5-5h9V4zM7 20l-3-3 3-3v2h9a3 3 0 0 0 3-3v-1h2v1a5 5 0 0 1-5 5H7v2z")
189
216
  };
190
217
 
191
- // src/js/data/bpm.js
218
+ // src/js/data/bpm.ts
219
+ function bpmExtent(range) {
220
+ return range ? { min: Math.floor(range.min), max: Math.ceil(range.max) } : null;
221
+ }
192
222
  function bpmRangeFromFilter(filter, extent) {
193
223
  const read = (v, fallback) => {
194
224
  const n = Number(v);
@@ -202,7 +232,7 @@ function hasBpmFilter(filter) {
202
232
  return filter.bpmMin != null && filter.bpmMin !== "" || filter.bpmMax != null && filter.bpmMax !== "";
203
233
  }
204
234
 
205
- // src/js/render/strings.js
235
+ // src/js/render/strings.ts
206
236
  var DEFAULT_STRINGS = {
207
237
  search: "Search sounds",
208
238
  searchPlaceholder: "Search sounds\u2026",
@@ -234,6 +264,7 @@ var DEFAULT_STRINGS = {
234
264
  play: "Play {title}",
235
265
  pause: "Pause {title}",
236
266
  seek: "Seek {title}",
267
+ seekValue: "{time} of {duration}",
237
268
  download: "Download {title}",
238
269
  count: "{count} sounds",
239
270
  countOne: "1 sound",
@@ -241,7 +272,10 @@ var DEFAULT_STRINGS = {
241
272
  showMore: "Show {count} more",
242
273
  empty: "No sounds match.",
243
274
  clear: "Clear filters",
244
- nowPlaying: "Playing {title}"
275
+ nowPlaying: "Playing {title}",
276
+ playError: "Could not play {title}",
277
+ loadError: "Could not load the sounds.",
278
+ noSounds: "No sounds."
245
279
  };
246
280
  var SORT_LABEL_KEYS = {
247
281
  default: "sortDefault",
@@ -263,7 +297,7 @@ function countText(shown, total, strings = DEFAULT_STRINGS) {
263
297
  return total === 1 ? strings.countOne : fill(strings.count, { count: total });
264
298
  }
265
299
 
266
- // src/js/render/options.js
300
+ // src/js/render/options.ts
267
301
  var FILTERS = ["type", "key", "bpm", "loop"];
268
302
  var COLUMNS = ["type", "bpm", "key", "duration"];
269
303
  var RENDER_DEFAULTS = {
@@ -278,6 +312,15 @@ var RENDER_DEFAULTS = {
278
312
  columns: [...COLUMNS],
279
313
  maxTypeChips: 10
280
314
  };
315
+ var RENDER_OPTION_KEYS = [...Object.keys(RENDER_DEFAULTS), "idPrefix", "loop", "strings"];
316
+ function pickRenderOptions(options) {
317
+ const out = {};
318
+ for (const key of RENDER_OPTION_KEYS) {
319
+ const value = options?.[key];
320
+ if (value != null) out[key] = value;
321
+ }
322
+ return out;
323
+ }
281
324
  function defined(obj) {
282
325
  const out = {};
283
326
  for (const k in obj ?? {}) if (obj[k] !== void 0) out[k] = obj[k];
@@ -305,14 +348,14 @@ function resolveRenderOptions(options = {}) {
305
348
  };
306
349
  }
307
350
 
308
- // src/js/shared/utils.js
351
+ // src/js/shared/utils.ts
309
352
  function hashString(str) {
310
353
  let hash = 5381;
311
354
  for (const char of str) hash = hash * 33 + char.codePointAt(0) >>> 0;
312
355
  return hash;
313
356
  }
314
357
 
315
- // src/js/render/markup.js
358
+ // src/js/render/markup.ts
316
359
  function idBase(sounds) {
317
360
  const signature = [sounds.length, ...sounds.map((s) => s.url)].join("|");
318
361
  return `ws${hashString(signature).toString(36)}`;
@@ -469,7 +512,7 @@ function renderToolbar(plan, { o, s, f, total, id }) {
469
512
  placeholder: s.findKey,
470
513
  options: [{ value: "", label: s.anyKey }, ...f.keys.map((k) => ({ value: k, label: k }))]
471
514
  }),
472
- plan.bpm && renderBpmMenu({ id, s, range: f.bpm }),
515
+ plan.bpm && renderBpmMenu({ id, s, range: bpmExtent(f.bpm) }),
473
516
  plan.loops && renderLoopFilter(s),
474
517
  plan.sorts.length > 0 && menu("sort", {
475
518
  label: s.sort,
@@ -572,13 +615,33 @@ function renderSounds(sounds, options = {}) {
572
615
  list.map((sound, i) => renderRow(sound, i, o, i >= page))
573
616
  ) + renderFooter(ctx);
574
617
  }
618
+ function renderOptionAttributes(options = {}) {
619
+ const set = pickRenderOptions(options);
620
+ const o = resolveRenderOptions(options);
621
+ const out = {};
622
+ for (const key of RENDER_OPTION_KEYS) {
623
+ if (key === "player" || !(key in set)) continue;
624
+ const name = `data-${key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}`;
625
+ if (key === "strings") {
626
+ const strings = defined(set.strings);
627
+ if (Object.keys(strings).length) out[name] = JSON.stringify(strings);
628
+ } else if (key === "loop" || key === "idPrefix") {
629
+ out[name] = String(set[key]);
630
+ } else {
631
+ const value = o[key];
632
+ out[name] = Array.isArray(value) ? value.join(",") : String(value);
633
+ }
634
+ }
635
+ return out;
636
+ }
575
637
  function renderSoundsElement(sounds, options = {}, className = "") {
576
638
  const o = resolveRenderOptions(options);
577
639
  const cls = ["waveform-sounds", `waveform-sounds--${o.player}`, className].filter(Boolean).join(" ");
578
- return h("div", { class: cls, "data-waveform-sounds": true, "data-player": o.player }, renderSounds(sounds, options));
640
+ return h("div", { class: cls, "data-waveform-sounds": true, "data-player": o.player, ...renderOptionAttributes(options) }, renderSounds(sounds, options));
579
641
  }
580
642
  export {
581
643
  DEFAULT_STRINGS,
644
+ RENDER_OPTION_KEYS,
582
645
  decodePeaks,
583
646
  encodePeaks,
584
647
  escapeHtml,
@@ -587,6 +650,7 @@ export {
587
650
  normalizeKey,
588
651
  normalizeSounds,
589
652
  parseManifest,
653
+ pickRenderOptions,
590
654
  renderSounds,
591
655
  renderSoundsElement
592
656
  };
@@ -15,12 +15,21 @@
15
15
  * canvas can't use CSS, so the runtime resolves them, and re-reads them
16
16
  * when the page theme flips).
17
17
  */
18
+ /* <waveform-sounds>: a block, like the <div data-waveform-sounds> form (a
19
+ * custom element is inline by default), and styled as one from the first
20
+ * paint: the container rules below name the tag as well as the class, so
21
+ * server-rendered markup inside it doesn't shift when it upgrades. Before
22
+ * the script defines it, an EMPTY element (a manifest still to load) holds
23
+ * --ws-element-height, if you set one. */
24
+ waveform-sounds { display: block; }
25
+ waveform-sounds:not(:defined):empty { min-height: var(--ws-element-height, 0); }
26
+
18
27
  /* THE ONE RULE for the inverted states: an element whose background is
19
28
  * `var(--ws-accent)` never sets its own `color` — its CHILDREN take the
20
29
  * ink. `--ws-accent` defaults to `currentColor`, which resolves where it's
21
30
  * used (even registered with @property: Chrome keeps the keyword), so a
22
31
  * button with `color: ink; background: currentColor` paints ink on ink. */
23
- .waveform-sounds {
32
+ :is(.waveform-sounds, waveform-sounds) {
24
33
  --ws-accent: currentColor;
25
34
  /* The ink on an inverted fill: the page surface (set by you, or
26
35
  * measured by the runtime), else the INVERSE of the text colour — right
@@ -43,20 +52,53 @@
43
52
  color: inherit;
44
53
  font: inherit;
45
54
  }
46
- .waveform-sounds *, .waveform-sounds *::before, .waveform-sounds *::after { box-sizing: border-box; }
47
- .waveform-sounds [hidden] { display: none !important; }
55
+ /* The inverse above is relative colour FROM currentColor: Chrome 131,
56
+ * Firefox 133, Safari 18, all newer than the 2.0 floor. Chrome 119–130
57
+ * parse relative colour, but not from currentColor, so the guard names it;
58
+ * Firefox 128–132 parse it but resolve currentColor as black (white ink on
59
+ * a light fill), so they are named too: Firefox (-moz-appearance) without
60
+ * a feature of its 133 (letter-spacing in %). Where it's unusable the ink
61
+ * is the surface the runtime measures. Until it has
62
+ * (a server-rendered first paint, or no script — the runtime sets
63
+ * data-ws-initialized as it measures), there is no ink that is right on
64
+ * every page (the system Canvas is white on a dark page that doesn't declare
65
+ * color-scheme), so a pressed control is a TINT with text-colour ink
66
+ * instead of an inversion: readable on any page. */
67
+ @supports (not (color: rgb(from currentColor r g b))) or ((-moz-appearance: none) and (not (letter-spacing: 1%))) {
68
+ :is(.waveform-sounds, waveform-sounds) { --ws-on-accent: var(--ws-surface, Canvas); }
69
+ :is(.waveform-sounds, waveform-sounds):where(:not([data-ws-initialized])) {
70
+ --ws-accent-fill: color-mix(in srgb, currentColor 22%, transparent);
71
+ --ws-on-accent: currentColor;
72
+ }
73
+ }
74
+ :is(.waveform-sounds, waveform-sounds) *, :is(.waveform-sounds, waveform-sounds) *::before, :is(.waveform-sounds, waveform-sounds) *::after { box-sizing: border-box; }
75
+ :is(.waveform-sounds, waveform-sounds) [hidden] { display: none !important; }
48
76
 
49
77
  .ws-sr {
50
78
  position: absolute !important;
51
79
  width: 1px; height: 1px;
52
80
  margin: -1px; padding: 0;
53
81
  overflow: hidden;
54
- clip: rect(0 0 0 0);
82
+ clip-path: inset(50%);
55
83
  white-space: nowrap;
56
84
  border: 0;
57
85
  }
58
86
  .ws-icon { width: 1em; height: 1em; fill: currentColor; flex: none; }
59
87
 
88
+ /* ── Controls: shared ────────────────────────────────────────────────── */
89
+ /* The pill-shaped controls share one frame... */
90
+ .ws-search, .ws-menu-btn, .ws-seg, .ws-loop, .ws-chip, .ws-clear, .ws-more {
91
+ border: 1px solid var(--ws-border);
92
+ border-radius: var(--ws-control-radius);
93
+ }
94
+ /* ...and every button starts from the text around it. */
95
+ .ws-menu-btn, .ws-bpm-clear, .ws-seg-btn, .ws-loop, .ws-chip, .ws-clear, .ws-more {
96
+ background: none;
97
+ color: inherit;
98
+ font: inherit;
99
+ cursor: pointer;
100
+ }
101
+
60
102
  /* ── Toolbar ─────────────────────────────────────────────────────────── */
61
103
  .ws-toolbar {
62
104
  display: flex;
@@ -73,13 +115,12 @@
73
115
  min-width: 0;
74
116
  height: 2.75rem;
75
117
  padding: 0 1rem;
76
- border: 1px solid var(--ws-border);
77
- border-radius: var(--ws-control-radius);
78
118
  background: var(--ws-field);
79
119
  color: inherit;
80
120
  cursor: text;
81
121
  }
82
- .ws-search:focus-within { border-color: var(--ws-accent); }
122
+ /* The focus ring is the field's frame, not the bare input inside it. */
123
+ .ws-search:focus-within { border-color: var(--ws-accent); outline: 2px solid var(--ws-accent); outline-offset: 2px; }
83
124
  .ws-search-input {
84
125
  flex: 1;
85
126
  min-width: 0;
@@ -88,13 +129,14 @@
88
129
  background: none;
89
130
  color: inherit;
90
131
  font: inherit;
91
- outline: none;
92
132
  }
93
- .ws-search .ws-icon { color: var(--ws-muted); }
94
- .ws-search-input::placeholder { color: var(--ws-muted); }
133
+ .ws-search-input:focus { outline: none; } /* the frame above carries the ring */
134
+ .ws-search .ws-icon, .ws-search-input::placeholder { color: var(--ws-muted); }
135
+ /* WebKit/Blink's clear button, redrawn in the text colour. The mask stays
136
+ * prefixed: unprefixed `mask` is Chrome/Edge 120+. */
95
137
  .ws-search-input::-webkit-search-cancel-button,
96
138
  .ws-menu-search::-webkit-search-cancel-button {
97
- -webkit-appearance: none;
139
+ appearance: none;
98
140
  width: 0.9em;
99
141
  height: 0.9em;
100
142
  background: currentColor;
@@ -103,7 +145,9 @@
103
145
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.4 5 5 6.4 10.6 12 5 17.6 6.4 19l5.6-5.6 5.6 5.6 1.4-1.4-5.6-5.6L19 6.4 17.6 5 12 10.6z'/%3E%3C/svg%3E") center / contain no-repeat;
104
146
  }
105
147
 
148
+ /* The row of menus, the loops filter and the Loop toggle. */
106
149
  .ws-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
150
+
107
151
  /* ── Dropdowns (type / key / sort) ──────────────────────────────────── */
108
152
  .ws-menu { position: relative; }
109
153
  .ws-menu-btn {
@@ -113,18 +157,13 @@
113
157
  height: 2.75rem;
114
158
  max-width: 16rem;
115
159
  padding: 0 0.85rem 0 1rem;
116
- border: 1px solid var(--ws-border);
117
- border-radius: var(--ws-control-radius);
118
160
  background: var(--ws-field);
119
- color: inherit;
120
- font: inherit;
121
161
  font-size: 0.9em;
122
- cursor: pointer;
123
162
  }
124
163
  .ws-menu-btn:hover { background: var(--ws-hover); }
125
164
  .ws-menu-btn[aria-expanded='true'] { border-color: var(--ws-accent); }
126
165
  .ws-menu-prefix { color: var(--ws-muted); }
127
- .ws-menu-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
166
+ .ws-menu-value, .ws-menu-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
128
167
  .ws-menu-chevron { font-size: 1.1em; color: var(--ws-muted); transition: transform 0.15s; }
129
168
  .ws-menu-btn[aria-expanded='true'] .ws-menu-chevron { transform: rotate(180deg); }
130
169
  .ws-menu-pop {
@@ -154,9 +193,9 @@
154
193
  color: inherit;
155
194
  font: inherit;
156
195
  font-size: 0.9em;
157
- outline: none;
158
196
  }
159
197
  .ws-menu-search:focus { border-color: var(--ws-accent); }
198
+ .ws-menu-search:focus-visible { outline: 2px solid var(--ws-accent); outline-offset: 1px; }
160
199
  .ws-menu-list { list-style: none; margin: 0; padding: 0; max-height: 18rem; overflow-y: auto; outline: none; }
161
200
  .ws-menu-option {
162
201
  display: flex;
@@ -172,7 +211,7 @@
172
211
  .ws-menu-check { visibility: hidden; flex: none; }
173
212
  .ws-menu-option[aria-selected='true'] { font-weight: 600; }
174
213
  .ws-menu-option[aria-selected='true'] .ws-menu-check { visibility: visible; }
175
- .ws-menu-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
214
+ .ws-menu-text { flex: 1; min-width: 0; }
176
215
  .ws-menu-count { font-family: var(--ws-mono); font-size: 0.85em; color: var(--ws-muted); }
177
216
  .ws-menu-none { margin: 0; padding: 0.6rem; color: var(--ws-muted); font-size: 0.9em; }
178
217
 
@@ -181,14 +220,20 @@
181
220
  .ws-bpm-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.6rem; }
182
221
  .ws-bpm-readout { font-weight: 600; font-variant-numeric: tabular-nums; }
183
222
  .ws-bpm-clear {
184
- padding: 0;
223
+ /* A 24px target (WCAG 2.5.8) without growing the head. */
224
+ display: inline-flex;
225
+ align-items: center;
226
+ justify-content: center;
227
+ min-width: 24px;
228
+ min-height: 24px;
229
+ margin: -2px -0.3rem -2px 0;
230
+ padding: 0 0.3rem;
185
231
  border: 0;
186
- background: none;
232
+ border-radius: 4px;
187
233
  color: var(--ws-muted);
188
- font: inherit;
189
234
  font-size: 0.85em;
190
- cursor: pointer;
191
235
  }
236
+ .ws-bpm-clear:focus-visible { outline: 2px solid var(--ws-accent); outline-offset: 0; }
192
237
  .ws-bpm-clear:hover { color: inherit; text-decoration: underline; }
193
238
 
194
239
  /* Two native range inputs stacked on one track. The track and the filled
@@ -229,12 +274,13 @@
229
274
  margin: 0;
230
275
  background: none;
231
276
  pointer-events: none;
232
- -webkit-appearance: none;
233
277
  appearance: none;
234
278
  }
235
279
  /* When the handles meet, the lower one goes on top (it's the one that can
236
280
  * still move: left). */
237
281
  .ws-range.is-min-top [data-ws-bpm-min] { z-index: 2; }
282
+ /* The track and thumb pseudo-elements are per engine, each in its own
283
+ * rule: a browser drops a whole selector list over one it doesn't know. */
238
284
  .ws-range-input::-webkit-slider-runnable-track { height: 100%; background: none; }
239
285
  .ws-range-input::-moz-range-track { background: none; }
240
286
  .ws-range-input::-webkit-slider-thumb {
@@ -247,7 +293,6 @@
247
293
  box-shadow: 0 0 0 1px var(--ws-border);
248
294
  cursor: grab;
249
295
  pointer-events: auto;
250
- -webkit-appearance: none;
251
296
  appearance: none;
252
297
  }
253
298
  .ws-range-input::-moz-range-thumb {
@@ -274,50 +319,35 @@
274
319
  font-size: 0.75em;
275
320
  font-variant-numeric: tabular-nums;
276
321
  }
277
- .ws-loop {
278
- display: inline-flex;
279
- align-items: center;
280
- gap: 0.45rem;
281
- height: 2.75rem;
282
- padding: 0 1rem;
283
- border: 1px solid var(--ws-border);
284
- border-radius: var(--ws-control-radius);
285
- background: none;
286
- color: inherit;
287
- font: inherit;
288
- font-size: 0.9em;
289
- cursor: pointer;
290
- }
291
- .ws-loop[aria-pressed='true'] { border-color: var(--ws-accent); background: var(--ws-accent); }
292
- .ws-loop[aria-pressed='true'] > * { color: var(--ws-on-accent); }
293
322
 
294
- /* Loops or one-shots: a segmented control, one button pressed. */
323
+ /* ── Loops or one-shots: a segmented control, one button pressed ─────── */
295
324
  .ws-seg {
296
325
  display: inline-flex;
297
326
  height: 2.75rem;
298
327
  padding: 0.25rem;
299
328
  gap: 0.15rem;
300
- border: 1px solid var(--ws-border);
301
- border-radius: var(--ws-control-radius);
302
329
  }
303
330
  .ws-seg-btn {
304
331
  padding: 0 0.85rem;
305
332
  border: 0;
306
333
  border-radius: var(--ws-control-radius);
307
- background: none;
308
- color: inherit;
309
- font: inherit;
310
334
  font-size: 0.88em;
311
335
  white-space: nowrap;
312
- cursor: pointer;
313
336
  transition: background 0.15s;
314
337
  }
315
338
  .ws-seg-btn:hover { background: var(--ws-hover); }
316
- /* On the accent the CHILD takes the inverted ink: the button itself never
317
- * sets a colour (see the pause icon note at the top). */
318
- .ws-seg-btn[aria-pressed='true'] { background: var(--ws-accent); }
319
- .ws-seg-btn[aria-pressed='true'] > * { color: var(--ws-on-accent); }
320
339
 
340
+ /* ── The Loop toggle ─────────────────────────────────────────────────── */
341
+ .ws-loop {
342
+ display: inline-flex;
343
+ align-items: center;
344
+ gap: 0.45rem;
345
+ height: 2.75rem;
346
+ padding: 0 1rem;
347
+ font-size: 0.9em;
348
+ }
349
+
350
+ /* ── Type chips and the count ────────────────────────────────────────── */
321
351
  .ws-meta { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
322
352
  .ws-types { display: flex; flex-wrap: wrap; gap: 0.4rem; flex: 1 1 auto; min-width: 0; }
323
353
  .ws-chip {
@@ -326,23 +356,27 @@
326
356
  gap: 0.4rem;
327
357
  height: 2.25rem;
328
358
  padding: 0 0.9rem;
329
- border: 1px solid var(--ws-border);
330
- border-radius: var(--ws-control-radius);
331
- background: none;
332
- color: inherit;
333
- font: inherit;
334
359
  font-size: 0.88em;
335
- cursor: pointer;
336
360
  transition: border-color 0.15s, background 0.15s;
337
361
  }
338
362
  .ws-chip:hover { background: var(--ws-hover); }
339
- .ws-chip[aria-pressed='true'] { border-color: var(--ws-accent); background: var(--ws-accent); }
340
- .ws-chip[aria-pressed='true'] > * { color: var(--ws-on-accent); }
341
363
  .ws-chip-count { font-family: var(--ws-mono); font-size: 0.85em; opacity: 0.7; }
364
+ .ws-count { margin: 0 0 0 auto; color: var(--ws-muted); font-size: 0.88em; font-variant-numeric: tabular-nums; }
365
+
366
+ /* ── The pressed controls: the accent fill, inverted ink ─────────────── */
367
+ /* After the hovers, so a pressed control keeps its fill under the pointer.
368
+ * The CHILDREN take the ink, never the button (THE ONE RULE, at the top). */
369
+ /* `--ws-accent-fill` is unset, except for a tint before the runtime has
370
+ * measured the surface in engines without relative colour (top of file). */
371
+ .ws-loop[aria-pressed='true'],
372
+ .ws-chip[aria-pressed='true'] { border-color: var(--ws-accent); background: var(--ws-accent-fill, var(--ws-accent)); }
373
+ .ws-seg-btn[aria-pressed='true'] { background: var(--ws-accent-fill, var(--ws-accent)); }
374
+ .ws-loop[aria-pressed='true'] > *,
375
+ .ws-seg-btn[aria-pressed='true'] > *,
376
+ .ws-chip[aria-pressed='true'] > * { color: var(--ws-on-accent); }
342
377
  /* Full ink on the accent: a dimmed count on a saturated fill fails contrast
343
378
  * (70% measured 4.04:1 on #ff4f24). */
344
379
  .ws-chip[aria-pressed='true'] .ws-chip-count { opacity: 1; }
345
- .ws-count { margin: 0 0 0 auto; color: var(--ws-muted); font-size: 0.88em; font-variant-numeric: tabular-nums; }
346
380
 
347
381
  /* ── Rows ────────────────────────────────────────────────────────────── */
348
382
  .ws-list {
@@ -365,14 +399,17 @@
365
399
  .ws-row.is-current { background: var(--ws-current); }
366
400
  .ws-row.is-error .ws-title { text-decoration: line-through; opacity: 0.6; }
367
401
 
368
- .ws-play {
402
+ /* The play button and the download link: round icon buttons. */
403
+ .ws-play, .ws-download {
369
404
  flex: none;
370
405
  display: grid;
371
406
  place-items: center;
372
407
  width: 2.25rem;
373
408
  height: 2.25rem;
374
- border: 0;
375
409
  border-radius: 999px;
410
+ }
411
+ .ws-play {
412
+ border: 0;
376
413
  background: var(--ws-field);
377
414
  color: inherit;
378
415
  font-size: 0.95rem;
@@ -380,7 +417,7 @@
380
417
  transition: background 0.15s, color 0.15s;
381
418
  }
382
419
  .ws-row:hover .ws-play { background: color-mix(in srgb, currentColor 12%, transparent); }
383
- .ws-row.is-current .ws-play { background: var(--ws-accent); }
420
+ .ws-row.is-current .ws-play { background: var(--ws-accent-fill, var(--ws-accent)); }
384
421
  .ws-row.is-current .ws-play > * { color: var(--ws-on-accent); }
385
422
  .ws-play .ws-icon-pause { display: none; }
386
423
  .ws-row.is-playing .ws-play .ws-icon-play { display: none; }
@@ -419,12 +456,6 @@
419
456
  }
420
457
  .ws-canvas { display: block; width: 100%; height: 100%; }
421
458
  .ws-download {
422
- flex: none;
423
- display: grid;
424
- place-items: center;
425
- width: 2.25rem;
426
- height: 2.25rem;
427
- border-radius: 999px;
428
459
  color: var(--ws-muted);
429
460
  font-size: 1.05rem;
430
461
  text-decoration: none;
@@ -458,18 +489,17 @@
458
489
  .ws-cells > .ws-cell:not(:empty) ~ .ws-cell:not(:empty)::before { content: '·'; margin-right: 0.5rem; opacity: 0.6; }
459
490
  .ws-wave { grid-area: wave; margin-top: 0.35rem; min-width: 0; }
460
491
  .ws-download { grid-area: dl; align-self: start; }
492
+ /* The menus open from the controls row, never wider than it: anchored
493
+ to their own button, a wide panel (the BPM range) near the end of a
494
+ phone-width row hung off the screen's edge. */
495
+ .ws-controls { position: relative; }
496
+ .ws-menu { position: static; }
497
+ .ws-menu-pop { min-width: min(14rem, 100%); max-width: 100%; }
498
+ .ws-bpm-pop { width: min(17rem, 100%); }
461
499
  }
462
500
 
463
501
  /* ── Footer bits ─────────────────────────────────────────────────────── */
464
502
  .ws-empty { margin: 1.5rem 0; color: var(--ws-muted); }
465
- .ws-clear, .ws-more {
466
- border: 1px solid var(--ws-border);
467
- border-radius: var(--ws-control-radius);
468
- background: none;
469
- color: inherit;
470
- font: inherit;
471
- cursor: pointer;
472
- }
473
503
  .ws-clear { margin-left: 0.5rem; padding: 0.35rem 0.85rem; font-size: 0.88em; }
474
504
  .ws-more { display: block; margin: 1.25rem auto 0; padding: 0.7rem 1.4rem; font-size: 0.92em; }
475
505
  .ws-more:hover, .ws-clear:hover { background: var(--ws-hover); }
@@ -500,6 +530,33 @@
500
530
  .ws-menu-option { padding: 0.75rem 0.6rem; }
501
531
  }
502
532
 
533
+ /* Forced colours (Windows High Contrast): the pressed states and the
534
+ * playing row's button are the system Highlight, with their icons in
535
+ * HighlightText (left to the system, the inverted ink vanished into the
536
+ * forced background); the BPM track and thumb are drawn in system colours,
537
+ * and focus is an outline, never only a box-shadow (which is dropped). The
538
+ * canvases follow too: the runtime draws them in CanvasText / Highlight. */
539
+ @media (forced-colors: active) {
540
+ .ws-loop[aria-pressed='true'],
541
+ .ws-chip[aria-pressed='true'],
542
+ .ws-seg-btn[aria-pressed='true'],
543
+ .ws-row.is-current .ws-play {
544
+ forced-color-adjust: none;
545
+ border-color: Highlight;
546
+ background: Highlight;
547
+ color: HighlightText;
548
+ }
549
+ .ws-loop[aria-pressed='true'] > *,
550
+ .ws-seg-btn[aria-pressed='true'] > *,
551
+ .ws-chip[aria-pressed='true'] > *,
552
+ .ws-row.is-current .ws-play > * { color: HighlightText; }
553
+ .ws-range::before, .ws-range::after { forced-color-adjust: none; }
554
+ .ws-range::before { background: GrayText; }
555
+ .ws-range::after { background: Highlight; }
556
+ .ws-range-input:focus-visible { outline: 2px solid Highlight; outline-offset: 2px; }
557
+ .ws-menu-option.is-active { outline: 2px solid Highlight; }
558
+ }
559
+
503
560
  @media (prefers-reduced-motion: reduce) {
504
- .ws-row, .ws-chip, .ws-play { transition: none; }
561
+ .ws-row, .ws-chip, .ws-play, .ws-seg-btn, .ws-download, .ws-menu-chevron { transition: none; }
505
562
  }