@arraypress/waveform-sounds 2.0.0 → 2.2.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 (79) hide show
  1. package/README.md +44 -2
  2. package/dist/waveform-sounds-no-autoinit.esm.js +914 -208
  3. package/dist/waveform-sounds-render.esm.js +274 -82
  4. package/dist/waveform-sounds.css +92 -17
  5. package/dist/waveform-sounds.esm.js +917 -210
  6. package/dist/waveform-sounds.js +913 -210
  7. package/dist/waveform-sounds.min.css +1 -1
  8. package/dist/waveform-sounds.min.js +3 -3
  9. package/package.json +1 -1
  10. package/src/css/waveform-sounds.css +92 -17
  11. package/src/js/core/WaveformSounds.ts +540 -120
  12. package/src/js/core/element.ts +208 -0
  13. package/src/js/core/engine.ts +9 -3
  14. package/src/js/core/options.ts +1 -5
  15. package/src/js/data/bpm.ts +14 -4
  16. package/src/js/data/keys.ts +156 -0
  17. package/src/js/data/navigation.ts +51 -11
  18. package/src/js/data/sounds.ts +73 -36
  19. package/src/js/data/url-state.ts +39 -12
  20. package/src/js/dom/colors.ts +28 -1
  21. package/src/js/dom/draw.ts +16 -3
  22. package/src/js/dom/menus.ts +2 -3
  23. package/src/js/dom/rows.ts +38 -15
  24. package/src/js/entry.ts +13 -3
  25. package/src/js/index.ts +7 -3
  26. package/src/js/render/html.ts +0 -2
  27. package/src/js/render/icons.ts +59 -17
  28. package/src/js/render/markup.ts +156 -62
  29. package/src/js/render/options.ts +29 -5
  30. package/src/js/render/strings.ts +57 -4
  31. package/src/js/render-entry.ts +1 -1
  32. package/src/js/shared/utils.ts +4 -4
  33. package/src/js/types.ts +54 -3
  34. package/types/core/WaveformSounds.d.ts +41 -11
  35. package/types/core/WaveformSounds.d.ts.map +1 -1
  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 +8 -3
  39. package/types/core/engine.d.ts.map +1 -1
  40. package/types/core/options.d.ts +0 -5
  41. package/types/core/options.d.ts.map +1 -1
  42. package/types/data/bpm.d.ts +17 -4
  43. package/types/data/bpm.d.ts.map +1 -1
  44. package/types/data/keys.d.ts +88 -0
  45. package/types/data/keys.d.ts.map +1 -0
  46. package/types/data/navigation.d.ts +38 -11
  47. package/types/data/navigation.d.ts.map +1 -1
  48. package/types/data/sounds.d.ts +33 -17
  49. package/types/data/sounds.d.ts.map +1 -1
  50. package/types/data/url-state.d.ts +38 -7
  51. package/types/data/url-state.d.ts.map +1 -1
  52. package/types/dom/colors.d.ts +13 -0
  53. package/types/dom/colors.d.ts.map +1 -1
  54. package/types/dom/draw.d.ts +5 -3
  55. package/types/dom/draw.d.ts.map +1 -1
  56. package/types/dom/menus.d.ts +0 -2
  57. package/types/dom/menus.d.ts.map +1 -1
  58. package/types/dom/rows.d.ts +19 -11
  59. package/types/dom/rows.d.ts.map +1 -1
  60. package/types/entry.d.ts +10 -4
  61. package/types/entry.d.ts.map +1 -1
  62. package/types/index.d.ts +2 -2
  63. package/types/index.d.ts.map +1 -1
  64. package/types/render/html.d.ts +0 -2
  65. package/types/render/html.d.ts.map +1 -1
  66. package/types/render/icons.d.ts +41 -3
  67. package/types/render/icons.d.ts.map +1 -1
  68. package/types/render/markup.d.ts +44 -12
  69. package/types/render/markup.d.ts.map +1 -1
  70. package/types/render/options.d.ts +18 -5
  71. package/types/render/options.d.ts.map +1 -1
  72. package/types/render/strings.d.ts +22 -4
  73. package/types/render/strings.d.ts.map +1 -1
  74. package/types/render-entry.d.ts +1 -1
  75. package/types/render-entry.d.ts.map +1 -1
  76. package/types/shared/utils.d.ts +3 -3
  77. package/types/shared/utils.d.ts.map +1 -1
  78. package/types/types.d.ts +53 -3
  79. package/types/types.d.ts.map +1 -1
package/README.md CHANGED
@@ -29,6 +29,18 @@ import '@arraypress/waveform-sounds/styles.css';
29
29
  <div data-waveform-sounds data-manifest="/sounds.json"></div>
30
30
  ```
31
31
 
32
+ Or as a custom element — every `data-*` option works as an attribute,
33
+ with or without the prefix, and server-rendered markup inside it is
34
+ adopted:
35
+
36
+ ```html
37
+ <waveform-sounds manifest="/sounds.json" page-size="20"></waveform-sounds>
38
+ ```
39
+
40
+ The default import registers it; with `/no-autoinit` (or
41
+ `data-waveform-autoinit="false"`), call `defineWaveformSoundsElement()` —
42
+ `WaveformSounds.defineElement()` from a `<script>` page.
43
+
32
44
  Generate the manifest from a folder of previews (BPM and key are read from
33
45
  file names like `Bass_Loop_04_128_Fmin.wav`; the type is the sub-folder).
34
46
  `--base-url` is the public URL the folder is served at:
@@ -44,6 +56,7 @@ npx @arraypress/waveform-gen ./public/previews/ --recursive \
44
56
 
45
57
  `player` (`'inline'` | `'strip'`), `search`, `filters`, `sorts`,
46
58
  `loopToggle`, `showCount`, `pageSize` (50), `maxTypeChips` (10), `menuSearch` (8), `columns`,
59
+ `mergeEnharmonicKeys` (true),
47
60
  `waveformStyle`, `waveformColor`, `progressColor`, `barWidth`, `barGap`,
48
61
  `loop`, `autoAdvance`, `arrowAudition`, `playerOptions`, `strings`, and the
49
62
  callbacks `onReady` / `onPlay` / `onPause` / `onEnd` / `onFilter` / `onError`.
@@ -90,6 +103,17 @@ A list that marks nothing works as before.
90
103
  `waveform-gen --manifest` sets `loop: true` for files whose folder or name
91
104
  contains the word "loop".
92
105
 
106
+ ## Keys
107
+
108
+ Enharmonic keys are one key: a pack that writes both A#m and Bbm (or C#
109
+ and Db) gets one key-menu entry, a filter on either spelling finds both,
110
+ and `?key=` accepts either. The entry shows the spelling the pack uses
111
+ most; a tie goes to the conventional one (the key signature with the
112
+ fewest accidentals — Db, Eb, F#, Ab, Bb, B major; C#m, Ebm, F#m, G#m, Bbm
113
+ minor). Each row still shows its own key as written.
114
+ `mergeEnharmonicKeys: false` (`data-merge-enharmonic-keys="false"`) keeps
115
+ every spelling apart.
116
+
93
117
  ## Download links
94
118
 
95
119
  Optional, per sound — a free sample, the `.mid` of a MIDI preview. Rows
@@ -129,19 +153,37 @@ before the first play.)
129
153
 
130
154
  | Key | Does |
131
155
  |---|---|
156
+ | Tab | The list is one stop: the focused (else first) row |
132
157
  | ↑ / ↓ | Move between sounds; while one plays, play the next |
133
158
  | ← / → | Seek the playing sound |
159
+ | Home / End | First / last sound; on the playing row's seek slider, its start / end |
134
160
  | Space / Enter | Play / pause |
135
161
  | `/` | Search |
136
162
 
163
+ For a screen reader each row reads as a sentence ("Bass loops, 130 BPM,
164
+ key B minor, 0:07") that also describes its play button, and only the
165
+ playing (or paused) sound's waveform is a seek slider. The words are
166
+ `strings` (`rowBpm`, `rowKey`, `keyMinor`, `noteSharp`, …).
167
+
137
168
  ## Server rendering
138
169
 
139
170
  ```js
140
171
  import {renderSounds} from '@arraypress/waveform-sounds/render';
141
- const html = `<div data-waveform-sounds>${renderSounds(sounds, options)}</div>`;
172
+ const html = `<div class="waveform-sounds waveform-sounds--inline" data-waveform-sounds>${renderSounds(sounds, options)}</div>`;
142
173
  ```
143
174
 
144
- The runtime adopts that markup instead of rebuilding it.
175
+ The runtime adopts that markup instead of rebuilding it. It holds the
176
+ rows the list starts with (the first page; with `pageSize: 0` the first
177
+ 50) and every sound once as JSON; the runtime renders the other rows as
178
+ they are revealed (Show more, a filter, scrolling, ↓). Keep the
179
+ `waveform-sounds` classes on the wrapper (`waveform-sounds--strip` for the
180
+ strip): the stylesheet hangs off them, so without them the list paints
181
+ unstyled until the script runs and then shifts. `renderSoundsElement(sounds,
182
+ options, className)` writes the whole wrapper — the classes, and a `data-*`
183
+ attribute for every render option you set, so the runtime keeps them (pass
184
+ the same options to both, or a `pageSize` the runtime doesn't know is
185
+ re-paged to 50). `pickRenderOptions(props)` picks the options that shape
186
+ the markup out of a component's props.
145
187
 
146
188
  ## Theming
147
189