@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
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The rows in the DOM: reading server-rendered rows back into sounds, and
3
+ * finding a row by the sound it shows.
4
+ *
5
+ * @module rows
6
+ */
7
+ import type { Sound } from '../types.js';
8
+ /**
9
+ * Read server-rendered rows back into sounds. Rows are taken in their
10
+ * original order (`data-ws-index`) and renumbered 0..n-1, and a row whose
11
+ * data is unusable (no url) is removed — so a row missing from the markup
12
+ * can't leave a hole that would misalign rows and sounds.
13
+ *
14
+ * @param list - The `[data-ws-list]` element.
15
+ */
16
+ export declare function readRows(list: HTMLElement): Sound[];
17
+ /**
18
+ * The row elements, indexed by the sound each one shows (whatever order
19
+ * they're displayed in).
20
+ *
21
+ * @param list
22
+ */
23
+ export declare function indexRows(list: HTMLElement): HTMLElement[];
24
+ /**
25
+ * The rows currently visible (not hidden by the filter or the page), in
26
+ * display order.
27
+ *
28
+ * @param list
29
+ */
30
+ export declare function visibleRows(list: HTMLElement): HTMLElement[];
31
+ /**
32
+ * Put the rows in the given order. Every row moves (hidden ones too), so
33
+ * clearing a filter keeps the order.
34
+ *
35
+ * @param list
36
+ * @param rows - In the order to show them.
37
+ */
38
+ export declare function orderRows(list: HTMLElement, rows: HTMLElement[]): void;
39
+ //# sourceMappingURL=rows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../src/js/dom/rows.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,aAAa,CAAC;AAKvC;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,KAAK,EAAE,CAenD;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW,EAAE,CAI1D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW,EAAE,CAE5D;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,QAI/D"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @arraypress/waveform-sounds — public surface, without the import-time
3
+ * side effects: the auto-init scan and registering `<waveform-sounds>`
4
+ * (`index.js` adds those). Anything new belongs here.
5
+ *
6
+ * @module entry
7
+ */
8
+ import { WaveformSounds, DEFAULT_OPTIONS } from './core/WaveformSounds.js';
9
+ import { WaveformSoundsElement, defineWaveformSoundsElement } from './core/element.js';
10
+ import { encodePeaks, decodePeaks, normalizeKey, normalizeSounds, parseManifest, facets, matches, sortSounds, formatDuration } from './data/sounds.js';
11
+ import { renderSounds, renderSoundsElement, DEFAULT_STRINGS, RENDER_OPTION_KEYS, pickRenderOptions } from './render/markup.js';
12
+ import type { WaveformSoundsEventMap } from './types.js';
13
+ declare global {
14
+ interface Window {
15
+ /** The script-tag global, set when the bundle loads in a browser. */
16
+ WaveformSounds: typeof WaveformSounds;
17
+ }
18
+ interface HTMLElementEventMap extends WaveformSoundsEventMap {
19
+ }
20
+ interface DocumentEventMap extends WaveformSoundsEventMap {
21
+ }
22
+ interface WindowEventMap extends WaveformSoundsEventMap {
23
+ }
24
+ }
25
+ export default WaveformSounds;
26
+ export { WaveformSounds, DEFAULT_OPTIONS, DEFAULT_STRINGS, encodePeaks, decodePeaks, normalizeKey, normalizeSounds, parseManifest, facets, matches, sortSounds, formatDuration, renderSounds, renderSoundsElement, RENDER_OPTION_KEYS, pickRenderOptions, WaveformSoundsElement, defineWaveformSoundsElement, };
27
+ export type { SoundInput, Sound, SoundsManifest, SoundsFilter, SoundsLoopFilter, SoundsSort, SoundsLayout, SoundsFilterControl, SoundsColumn, WaveformSoundsStrings, WaveformSoundsOptions, WaveformSoundsEventMap, WaveformSoundsInstanceEventMap, } from './types.js';
28
+ //# sourceMappingURL=entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/js/entry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAC,cAAc,EAAE,eAAe,EAAC,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAC,qBAAqB,EAAE,2BAA2B,EAAC,MAAM,mBAAmB,CAAC;AACrF,OAAO,EACH,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EACtH,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AAC7H,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,YAAY,CAAC;AAEvD,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,qEAAqE;QACrE,cAAc,EAAE,OAAO,cAAc,CAAC;KACzC;IACD,UAAU,mBAAoB,SAAQ,sBAAsB;KAAG;IAC/D,UAAU,gBAAiB,SAAQ,sBAAsB;KAAG;IAC5D,UAAU,cAAe,SAAQ,sBAAsB;KAAG;CAC7D;eAac,cAAc;AAC7B,OAAO,EACH,cAAc,EAAE,eAAe,EAAE,eAAe,EAChD,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EACnH,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,iBAAiB,EACxE,qBAAqB,EAAE,2BAA2B,GACrD,CAAC;AAGF,YAAY,EACR,UAAU,EACV,KAAK,EACL,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,8BAA8B,GACjC,MAAM,YAAY,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @arraypress/waveform-sounds
3
+ * A searchable, filterable list of sounds for WaveformPlayer.
4
+ *
5
+ * Importing this entry registers `<waveform-sounds>` and initialises every
6
+ * `[data-waveform-sounds]` element once the DOM is ready. Opt out page-wide with
7
+ * `<html data-waveform-autoinit="false">` (the family's switch), or import
8
+ * `@arraypress/waveform-sounds/no-autoinit`.
9
+ *
10
+ * @author ArrayPress
11
+ * @license MIT
12
+ */
13
+ import WaveformSounds from './entry.js';
14
+ export * from './entry.js';
15
+ export default WaveformSounds;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/js/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,cAA6C,MAAM,YAAY,CAAC;AAEvE,cAAc,YAAY,CAAC;eACZ,cAAc"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * A tiny HTML string builder for the server-safe renderer. Two rules make
3
+ * it safe to use everywhere:
4
+ *
5
+ * - ATTRIBUTE values are always escaped. `true` writes a bare attribute
6
+ * (`hidden`, `download`); `false`, `null` and `undefined` leave it out.
7
+ * ARIA states are strings, so pass `String(bool)` for those.
8
+ * - CHILDREN are HTML. Text goes through {@link text} first.
9
+ *
10
+ * @module html
11
+ */
12
+ /** An element's attributes: `true` writes a bare one, `false`/null/undefined leave it out. */
13
+ export type HtmlAttrs = Record<string, string | number | boolean | null | undefined>;
14
+ /** A child: an HTML string, a falsy one (skipped), or a nested list. */
15
+ export type HtmlChild = string | false | null | undefined | HtmlChild[];
16
+ /**
17
+ * Escape text for use as a child.
18
+ *
19
+ * @param value
20
+ */
21
+ export declare function text(value: unknown): string;
22
+ /**
23
+ * Serialise attributes, in the order given.
24
+ *
25
+ * @param map
26
+ * @returns e.g. ` class="ws-row" hidden` (leading space included).
27
+ */
28
+ export declare function attrs(map?: HtmlAttrs): string;
29
+ /**
30
+ * Build an element.
31
+ *
32
+ * @param tag
33
+ * @param attributes
34
+ * @param children - HTML strings; falsy ones and nested arrays are flattened away.
35
+ */
36
+ export declare function h(tag: string, attributes?: HtmlAttrs, ...children: HtmlChild[]): string;
37
+ //# sourceMappingURL=html.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/js/render/html.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,8FAA8F;AAC9F,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAErF,wEAAwE;AACxE,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,EAAE,CAAC;AAKxE;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE3C;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,GAAG,GAAE,SAAc,GAAG,MAAM,CAOjD;AAED;;;;;;GAMG;AACH,wBAAgB,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,GAAE,SAAc,EAAE,GAAG,QAAQ,EAAE,SAAS,EAAE,GAAG,MAAM,CAI3F"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The list's icons: 24×24 single-path SVGs that take `currentColor`, so
3
+ * they follow whatever colour their control has. Decorative (aria-hidden);
4
+ * every control carries its own label.
5
+ *
6
+ * @module icons
7
+ */
8
+ export declare const ICONS: {
9
+ play: string;
10
+ pause: string;
11
+ search: string;
12
+ chevron: string;
13
+ check: string;
14
+ download: string;
15
+ loop: string;
16
+ };
17
+ //# sourceMappingURL=icons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/js/render/icons.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAaH,eAAO,MAAM,KAAK;IACd,IAAI;IACJ,KAAK;IACL,MAAM;IACN,OAAO;IACP,KAAK;IACL,QAAQ;IACR,IAAI;CACP,CAAC"}
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Server-safe renderer: the component's markup as an HTML string, from the
3
+ * same data helpers the browser uses. No DOM, no window.
4
+ *
5
+ * A wrapper that renders on the server (Astro, SSR React/Vue/Svelte) calls
6
+ * {@link renderSounds} and emits the result inside a
7
+ * `[data-waveform-sounds]` element; the browser runtime then ADOPTS that
8
+ * markup instead of building its own, so the list is there (and readable,
9
+ * and crawlable) before any script runs.
10
+ *
11
+ * The markup is the contract between the two halves: every class and
12
+ * `data-ws-*` attribute here is read by the runtime (`core.js`,
13
+ * `menus.js`, `rows.js`).
14
+ *
15
+ * @module render
16
+ */
17
+ import { escapeHtml } from '../vendor/arraypress-text.js';
18
+ import { availableSorts, facets } from '../data/sounds.js';
19
+ import { pickRenderOptions, RENDER_DEFAULTS, RENDER_OPTION_KEYS, resolveRenderOptions } from './options.js';
20
+ import { countText, DEFAULT_STRINGS, fill } from './strings.js';
21
+ import type { Sound, SoundInput, WaveformSoundsOptions } from '../types.js';
22
+ export { escapeHtml, RENDER_DEFAULTS, RENDER_OPTION_KEYS, pickRenderOptions, resolveRenderOptions, DEFAULT_STRINGS, countText, fill, availableSorts };
23
+ /**
24
+ * A stable id prefix for a list's dropdowns, from its sounds: the same on
25
+ * the server and in the browser. Two lists of the SAME sounds on one page
26
+ * collide, so they need an `idPrefix` each.
27
+ *
28
+ * @param sounds
29
+ * @returns e.g. `ws1x9k2f`.
30
+ */
31
+ export declare function idBase(sounds: {
32
+ url: string;
33
+ }[]): string;
34
+ /**
35
+ * Which controls the toolbar shows. Each appears only when it's enabled
36
+ * AND the data gives it something to do: no type filter for one type, no
37
+ * key menu for one key, no BPM range without a spread of BPMs, no loops
38
+ * filter unless the list has both loops and one-shots, no sort menu with
39
+ * one usable order. Types past `maxTypeChips` become a menu (a
40
+ * pack has a handful; a whole library can have fifty).
41
+ *
42
+ * @param f - The sounds' facets.
43
+ * @param o - Resolved options.
44
+ */
45
+ export declare function toolbarPlan(f: ReturnType<typeof facets>, o: ReturnType<typeof resolveRenderOptions>): {
46
+ types: 'chips' | 'menu' | null;
47
+ key: boolean;
48
+ bpm: boolean;
49
+ loops: boolean;
50
+ sorts: string[];
51
+ search: boolean;
52
+ loop: boolean;
53
+ count: boolean;
54
+ };
55
+ /**
56
+ * Does the Loop toggle start on? An explicit `loop` option decides; left
57
+ * unset, it's on exactly when the list marks loops (only those repeat, so
58
+ * a one-shot still plays once).
59
+ *
60
+ * @param loop - The `loop` option.
61
+ * @param f - The sounds' facets.
62
+ */
63
+ export declare function loopsByDefault(loop: boolean | null | undefined, f: {
64
+ loops: number;
65
+ }): boolean;
66
+ /** A dropdown's content ({@link renderMenu}). */
67
+ export interface MenuSpec {
68
+ id: string;
69
+ label: string;
70
+ prefix?: string;
71
+ value: string;
72
+ options: {
73
+ value: string;
74
+ label: string;
75
+ count?: number;
76
+ }[];
77
+ searchFrom: number;
78
+ placeholder?: string;
79
+ noMatches: string;
80
+ }
81
+ /**
82
+ * A dropdown: a button and a popup listbox, with a search field when it
83
+ * has more than `searchFrom` options. The runtime (`menus.js`) opens,
84
+ * filters and navigates it; without JS the button still shows the value.
85
+ *
86
+ * @param name - 'type' | 'key' | 'sort' (the runtime routes by it).
87
+ * @param m
88
+ * @param m.id - Id prefix for this list.
89
+ * @param m.label - Accessible name ("Type").
90
+ * @param [m.prefix] - Visible lead-in ("Sort by"); otherwise the label is screen-reader only.
91
+ * @param m.value - The selected value.
92
+ * @param m.options
93
+ * @param m.searchFrom - Options above which a search field is added.
94
+ * @param [m.placeholder] - The search field's placeholder (no field without one).
95
+ * @param m.noMatches - Shown when the search matches nothing.
96
+ */
97
+ export declare function renderMenu(name: string, m: MenuSpec): string;
98
+ /**
99
+ * One row. `index` is the sound's position in the ORIGINAL list: the
100
+ * runtime maps rows back to sounds through it, whatever order they are
101
+ * sorted into. Every field is also written as a `data-*` attribute, so the
102
+ * runtime can rebuild the sounds from server markup.
103
+ *
104
+ * @param sound - Normalised.
105
+ * @param index
106
+ * @param o
107
+ * @param hidden - Past the first page.
108
+ */
109
+ export declare function renderRow(sound: Sound, index: number, o: ReturnType<typeof resolveRenderOptions>, hidden?: boolean): string;
110
+ /**
111
+ * The whole component's inner markup.
112
+ *
113
+ * @param sounds - Sounds (normalised or raw; normalised here).
114
+ * @param options - Render options (see `WaveformSoundsOptions`).
115
+ * @returns HTML for the inside of `[data-waveform-sounds]`.
116
+ */
117
+ export declare function renderSounds(sounds: SoundInput[], options?: WaveformSoundsOptions): string;
118
+ /**
119
+ * The `data-*` attributes that carry the render options set in `options` to
120
+ * the runtime (`data-page-size="20"`, `data-filters=""`, `data-strings='{…}'`),
121
+ * in the form `readDataOptions` reads — so the browser keeps what the server
122
+ * drew instead of falling back to the defaults (re-paging 20 rows to 50).
123
+ * Only options that are set are written; `player` is always written by
124
+ * {@link renderSoundsElement}. Since 2.1.0.
125
+ *
126
+ * @param options
127
+ * @returns Attributes, in {@link RENDER_OPTION_KEYS} order.
128
+ */
129
+ export declare function renderOptionAttributes(options?: WaveformSoundsOptions): Record<string, string>;
130
+ /**
131
+ * The full element, for callers who want one string: the wrapper div with
132
+ * its `data-waveform-sounds` marker, its `data-player`, a `data-*` attribute
133
+ * for every other render option set (see {@link renderOptionAttributes}) and
134
+ * the inner markup. The inner markup is exactly {@link renderSounds}'.
135
+ *
136
+ * @param sounds
137
+ * @param options
138
+ * @param className - Extra classes for the wrapper.
139
+ */
140
+ export declare function renderSoundsElement(sounds: SoundInput[], options?: WaveformSoundsOptions, className?: string): string;
141
+ //# sourceMappingURL=markup.d.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renderer's whole input — with
3
+ * their defaults and validation. DOM-free: the server renderer uses it,
4
+ * and the runtime's option surface (`core/options.js`) builds on it.
5
+ *
6
+ * @module render/options
7
+ */
8
+ import type { SoundsColumn, SoundsFilterControl, WaveformSoundsOptions, WaveformSoundsStrings } from '../types.js';
9
+ /** The filter controls a list can offer. */
10
+ export declare const FILTERS: SoundsFilterControl[];
11
+ /** The columns a row can show after its title. */
12
+ export declare const COLUMNS: SoundsColumn[];
13
+ /** The options that shape the markup (the renderer's whole input). */
14
+ export declare const RENDER_DEFAULTS: Required<Pick<WaveformSoundsOptions, 'player' | 'search' | 'filters' | 'sorts' | 'loopToggle' | 'showCount' | 'menuSearch' | 'pageSize' | 'columns' | 'maxTypeChips'>>;
15
+ /** {@link resolveRenderOptions}' result: the render options, complete, plus
16
+ * whatever else the caller passed. */
17
+ export type RenderOptions = typeof RENDER_DEFAULTS & {
18
+ strings: WaveformSoundsStrings;
19
+ idPrefix?: string;
20
+ loop?: boolean | null;
21
+ };
22
+ /**
23
+ * Every option that shapes the server markup: the render defaults, plus
24
+ * `idPrefix` (the dropdowns' ids), `loop` (whether the Loop toggle starts
25
+ * pressed) and `strings`. A wrapper that renders on the server passes
26
+ * exactly these to `renderSounds` — and the same values to the runtime, or
27
+ * the browser re-lays out what the server drew. Since 2.1.0.
28
+ */
29
+ export declare const RENDER_OPTION_KEYS: (keyof WaveformSoundsOptions)[];
30
+ /**
31
+ * The render options set in `options` (those in {@link RENDER_OPTION_KEYS}
32
+ * that aren't null or undefined), for handing a component's options to
33
+ * `renderSounds` on the server. Since 2.1.0.
34
+ *
35
+ * @param options - Any `WaveformSoundsOptions` (or a component's props).
36
+ * @returns Just the render options that are set.
37
+ */
38
+ export declare function pickRenderOptions(options: WaveformSoundsOptions | null | undefined): WaveformSoundsOptions;
39
+ /**
40
+ * The object without its `undefined` entries (so spreading it can't erase
41
+ * a default).
42
+ *
43
+ * @param obj
44
+ */
45
+ export declare function defined(obj: Record<string, any> | null | undefined): Record<string, any>;
46
+ /**
47
+ * The entries of `values` that are allowed, in the caller's order; the
48
+ * fallback when `values` isn't a list.
49
+ *
50
+ * @param values
51
+ * @param allowed
52
+ * @param fallback
53
+ */
54
+ export declare function allowedList<T extends string>(values: unknown, allowed: T[], fallback: T[]): T[];
55
+ /**
56
+ * A whole number ≥ 0, or the fallback.
57
+ *
58
+ * @param value
59
+ * @param fallback
60
+ */
61
+ export declare function wholeNumber(value: unknown, fallback: number): number;
62
+ /**
63
+ * The render options, defaulted and validated: unknown filters, sorts and
64
+ * columns are dropped, counts are whole numbers, `strings` is complete.
65
+ *
66
+ * @param options
67
+ */
68
+ export declare function resolveRenderOptions(options?: WaveformSoundsOptions): RenderOptions;
69
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/js/render/options.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAC,YAAY,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,qBAAqB,EAAC,MAAM,aAAa,CAAC;AAEjH,4CAA4C;AAC5C,eAAO,MAAM,OAAO,EAAE,mBAAmB,EAAmC,CAAC;AAE7E,kDAAkD;AAClD,eAAO,MAAM,OAAO,EAAE,YAAY,EAAuC,CAAC;AAE1E,sEAAsE;AACtE,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,IAAI,CAAC,qBAAqB,EAC7D,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,YAAY,GAAG,WAAW,GAAG,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,cAAc,CAAC,CAWnI,CAAC;AAEF;uCACuC;AACvC,MAAM,MAAM,aAAa,GAAG,OAAO,eAAe,GAAG;IAAC,OAAO,EAAE,qBAAqB,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;CAAC,CAAC;AAEhI;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAuE,CAAC,MAAM,qBAAqB,CAAC,EAAE,CAAC;AAEtI;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,GAAG,SAAS,GAAG,qBAAqB,CAO1G;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAIxF;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAE/F;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGpE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B,GAAG,aAAa,CAavF"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Every word the list shows or announces, so a site can translate it
3
+ * (`strings` option, or `data-strings` JSON). `{title}`, `{count}` and
4
+ * `{total}` are filled in.
5
+ *
6
+ * @module strings
7
+ */
8
+ import type { SoundsSort, WaveformSoundsStrings } from '../types.js';
9
+ /** The English defaults. */
10
+ export declare const DEFAULT_STRINGS: WaveformSoundsStrings;
11
+ /** The label each sort order shows in the Sort menu. */
12
+ export declare const SORT_LABEL_KEYS: Record<SoundsSort, keyof WaveformSoundsStrings>;
13
+ /**
14
+ * Fill `{name}` placeholders; unknown ones are left as written.
15
+ *
16
+ * @param template
17
+ * @param vars
18
+ */
19
+ export declare function fill(template: string, vars?: Record<string, string | number>): string;
20
+ /**
21
+ * The BPM menu's label: "Any BPM", or the range the handles hold
22
+ * ("120–128 BPM"; an open end shows the pack's own end).
23
+ *
24
+ * @param filter
25
+ * @param extent - The pack's BPM range.
26
+ * @param strings
27
+ */
28
+ export declare function bpmLabel(filter: {
29
+ bpmMin?: string | number;
30
+ bpmMax?: string | number;
31
+ }, extent: {
32
+ min: number;
33
+ max: number;
34
+ }, strings?: typeof DEFAULT_STRINGS): string;
35
+ /**
36
+ * The count line: "300 sounds", "1 sound", "12 of 300 sounds".
37
+ *
38
+ * @param shown - Sounds matching the filter.
39
+ * @param total - All sounds.
40
+ * @param strings
41
+ */
42
+ export declare function countText(shown: number, total: number, strings?: typeof DEFAULT_STRINGS): string;
43
+ //# sourceMappingURL=strings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/js/render/strings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAC,UAAU,EAAE,qBAAqB,EAAC,MAAM,aAAa,CAAC;AAEnE,4BAA4B;AAC5B,eAAO,MAAM,eAAe,EAAE,qBA2C7B,CAAC;AAEF,wDAAwD;AACxD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,qBAAqB,CAM3E,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAC,MAAM,CAAM,GAAG,MAAM,CAEvF;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE;IAAC,MAAM,CAAC,EAAE,MAAM,GAAC,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAC,MAAM,CAAA;CAAC,EAAE,MAAM,EAAE;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,EAAE,OAAO,GAAE,OAAO,eAAiC,GAAG,MAAM,CAIhL;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,OAAO,eAAiC,GAAG,MAAM,CAGjH"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `@arraypress/waveform-sounds/render` — the DOM-free half, for server
3
+ * rendering. Importing it never touches `window` or `document`.
4
+ */
5
+ export { renderSounds, renderSoundsElement, DEFAULT_STRINGS, escapeHtml, RENDER_OPTION_KEYS, pickRenderOptions } from './render/markup.js';
6
+ export { normalizeSounds, parseManifest, encodePeaks, decodePeaks, normalizeKey, facets, formatDuration } from './data/sounds.js';
7
+ export type { SoundInput, Sound, SoundsManifest, WaveformSoundsOptions, WaveformSoundsStrings } from './types.js';
8
+ //# sourceMappingURL=render-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-entry.d.ts","sourceRoot":"","sources":["../src/js/render-entry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAC,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AACzI,OAAO,EAAC,eAAe,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChI,YAAY,EAAC,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,qBAAqB,EAAC,MAAM,YAAY,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Small shared helpers with no state. The pure ones run anywhere; the two
3
+ * that take an element only read from it.
4
+ *
5
+ * @module utils
6
+ */
7
+ /** Prefix for every console message and thrown error. */
8
+ export declare const LOG = "[WaveformSounds]";
9
+ /**
10
+ * Clamp a number into a range.
11
+ *
12
+ * @param value
13
+ * @param min
14
+ * @param max
15
+ */
16
+ export declare function clamp(value: number, min?: number, max?: number): number;
17
+ /**
18
+ * Where a pointer sits across a box, as a fraction 0..1 — the seek
19
+ * position of a click on a row waveform.
20
+ *
21
+ * @param clientX - The pointer's x (viewport coordinates).
22
+ * @param rect - The box (getBoundingClientRect()).
23
+ * @returns 0..1; 0 for a box with no width.
24
+ */
25
+ export declare function pointerFraction(clientX: number, rect: {
26
+ left: number;
27
+ width: number;
28
+ }): number;
29
+ /**
30
+ * Is the element a place the user types into? Keyboard shortcuts (`/`)
31
+ * must not fire there.
32
+ *
33
+ * @param el
34
+ */
35
+ export declare function isTyping(el: Element | null | undefined): boolean;
36
+ /**
37
+ * Dispatch a bubbling, composed `waveformsounds:<name>` CustomEvent from an
38
+ * element (composed: it leaves a shadow root, like the core's lifecycle
39
+ * events).
40
+ * Every event the list emits goes through here, so they share one shape:
41
+ * the detail plus the instance that sent it.
42
+ *
43
+ * @param target
44
+ * @param name - Without the prefix (`'play'`).
45
+ * @param detail
46
+ * @returns The event dispatched.
47
+ */
48
+ export declare function emit(target: EventTarget, name: string, detail: Record<string, any>): CustomEvent;
49
+ /**
50
+ * A small, stable string hash (djb2, 32-bit) — for ids that must come out
51
+ * the same on the server and in the browser. Not cryptographic.
52
+ *
53
+ * @param str
54
+ * @returns An unsigned 32-bit integer.
55
+ */
56
+ export declare function hashString(str: string): number;
57
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/js/shared/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yDAAyD;AACzD,eAAO,MAAM,GAAG,qBAAqB,CAAC;AAEtC;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,GAAE,MAAU,EAAE,GAAG,GAAE,MAAU,GAAG,MAAM,CAE7E;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,GAAG,MAAM,CAE5F;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAEhE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,WAAW,CAIhG;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI9C"}