@arraypress/waveform-sounds 0.3.0 → 2.0.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.
- package/LICENSE +1 -1
- package/README.md +19 -1
- package/dist/waveform-sounds-no-autoinit.esm.js +145 -98
- package/dist/waveform-sounds-render.esm.js +25 -11
- package/dist/waveform-sounds.css +66 -78
- package/dist/waveform-sounds.esm.js +146 -99
- package/dist/waveform-sounds.js +147 -99
- package/dist/waveform-sounds.min.css +1 -1
- package/dist/waveform-sounds.min.js +1 -1
- package/package.json +36 -33
- package/src/css/waveform-sounds.css +66 -78
- package/src/js/core/{WaveformSounds.js → WaveformSounds.ts} +328 -189
- package/src/js/core/engine.ts +101 -0
- package/src/js/core/{options.js → options.ts} +33 -28
- package/src/js/data/{bpm.js → bpm.ts} +17 -17
- package/src/js/data/{navigation.js → navigation.ts} +17 -17
- package/src/js/data/{sounds.js → sounds.ts} +67 -63
- package/src/js/data/{url-state.js → url-state.ts} +27 -26
- package/src/js/dom/{colors.js → colors.ts} +12 -12
- package/src/js/dom/{draw.js → draw.ts} +17 -17
- package/src/js/dom/{menus.js → menus.ts} +72 -55
- package/src/js/dom/{rows.js → rows.ts} +18 -17
- package/src/js/{entry.js → entry.ts} +25 -0
- package/src/js/render/{html.js → html.ts} +18 -12
- package/src/js/render/{icons.js → icons.ts} +4 -4
- package/src/js/render/{markup.js → markup.ts} +82 -60
- package/src/js/render/{options.js → options.ts} +26 -20
- package/src/js/render/{strings.js → strings.ts} +17 -16
- package/src/js/{render-entry.js → render-entry.ts} +1 -0
- package/src/js/shared/{utils.js → utils.ts} +22 -22
- package/{index.d.ts → src/js/types.ts} +12 -87
- package/types/core/WaveformSounds.d.ts +145 -0
- package/types/core/WaveformSounds.d.ts.map +1 -0
- package/types/core/engine.d.ts +67 -0
- package/types/core/engine.d.ts.map +1 -0
- package/types/core/options.d.ts +76 -0
- package/types/core/options.d.ts.map +1 -0
- package/types/data/bpm.d.ts +67 -0
- package/types/data/bpm.d.ts.map +1 -0
- package/types/data/navigation.d.ts +53 -0
- package/types/data/navigation.d.ts.map +1 -0
- package/types/data/sounds.d.ts +167 -0
- package/types/data/sounds.d.ts.map +1 -0
- package/types/data/url-state.d.ts +83 -0
- package/types/data/url-state.d.ts.map +1 -0
- package/types/dom/colors.d.ts +35 -0
- package/types/dom/colors.d.ts.map +1 -0
- package/types/dom/draw.d.ts +73 -0
- package/types/dom/draw.d.ts.map +1 -0
- package/types/dom/menus.d.ts +77 -0
- package/types/dom/menus.d.ts.map +1 -0
- package/types/dom/rows.d.ts +42 -0
- package/types/dom/rows.d.ts.map +1 -0
- package/types/entry.d.ts +22 -0
- package/types/entry.d.ts.map +1 -0
- package/types/index.d.ts +16 -0
- package/types/index.d.ts.map +1 -0
- package/types/render/html.d.ts +39 -0
- package/types/render/html.d.ts.map +1 -0
- package/types/render/icons.d.ts +17 -0
- package/types/render/icons.d.ts.map +1 -0
- package/types/render/markup.d.ts +132 -0
- package/types/render/markup.d.ts.map +1 -0
- package/types/render/options.d.ts +56 -0
- package/types/render/options.d.ts.map +1 -0
- package/types/render/strings.d.ts +46 -0
- package/types/render/strings.d.ts.map +1 -0
- package/types/render-entry.d.ts +8 -0
- package/types/render-entry.d.ts.map +1 -0
- package/types/shared/utils.d.ts +57 -0
- package/types/shared/utils.d.ts.map +1 -0
- package/types/types.d.ts +254 -0
- package/types/types.d.ts.map +1 -0
- package/types/vendor/arraypress-text.d.ts +250 -0
- package/dist/waveform-sounds-no-autoinit.cjs +0 -2136
- package/dist/waveform-sounds-render.cjs +0 -614
- package/dist/waveform-sounds.cjs +0 -2158
- package/no-autoinit.d.ts +0 -2
- package/render.d.ts +0 -5
- package/src/js/core/engine.js +0 -57
- /package/src/js/{index.js → index.ts} +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filters in the address (`urlState`): which query parameters hold them,
|
|
3
|
+
* reading them into a filter, and writing a filter back into a URL. Pure:
|
|
4
|
+
* the runtime passes `location.search` / `location.href` in and calls
|
|
5
|
+
* `history.replaceState` with what comes out.
|
|
6
|
+
*
|
|
7
|
+
* ?q=bass&type=Bass+loops&key=Fm&bpm=120-130&loop=one-shot&sort=bpm
|
|
8
|
+
*
|
|
9
|
+
* @module url-state
|
|
10
|
+
*/
|
|
11
|
+
import type { SoundsFilter } from '../types.js';
|
|
12
|
+
/**
|
|
13
|
+
* The parameter names, or null when urlState is off. A string urlState
|
|
14
|
+
* prefixes them (`'pack'` → `pack-q`, `pack-type`, …) so two lists on one
|
|
15
|
+
* page don't share a filter.
|
|
16
|
+
*
|
|
17
|
+
* @param urlState
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export declare function urlKeys(urlState: boolean | string | null | undefined): {
|
|
21
|
+
q: string;
|
|
22
|
+
type: string;
|
|
23
|
+
key: string;
|
|
24
|
+
bpm: string;
|
|
25
|
+
loop: string;
|
|
26
|
+
sort: string;
|
|
27
|
+
} | null;
|
|
28
|
+
/**
|
|
29
|
+
* A BPM range parameter: "120-130", "120-" or "-130".
|
|
30
|
+
*
|
|
31
|
+
* @param value
|
|
32
|
+
* @returns null if malformed.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseBpmRange(value: string | null | undefined): {
|
|
35
|
+
bpmMin: string;
|
|
36
|
+
bpmMax: string;
|
|
37
|
+
} | null;
|
|
38
|
+
/**
|
|
39
|
+
* The inverse of {@link parseBpmRange}; '' when neither end is set.
|
|
40
|
+
*
|
|
41
|
+
* @param min
|
|
42
|
+
* @param max
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
export declare function formatBpmRange(min: string | number | null | undefined, max: string | number | null | undefined): string;
|
|
46
|
+
/**
|
|
47
|
+
* Read the filter and sort from a query string. Values the list can't use
|
|
48
|
+
* (a type it doesn't have, a key no sound is in, a loops filter on a list
|
|
49
|
+
* that isn't a mix of loops and one-shots, a sort it doesn't offer)
|
|
50
|
+
* are ignored, never applied: a stale link shows the whole list, not an
|
|
51
|
+
* empty one.
|
|
52
|
+
*
|
|
53
|
+
* @param search - `location.search`.
|
|
54
|
+
* @param keys
|
|
55
|
+
* @param available - From `facets()`.
|
|
56
|
+
* @param sorts - The sort orders offered.
|
|
57
|
+
* @returns A filter patch, and the sort (or null).
|
|
58
|
+
*/
|
|
59
|
+
export declare function readUrlState(search: string, keys: ReturnType<typeof urlKeys>, available: {
|
|
60
|
+
types: {
|
|
61
|
+
name: string;
|
|
62
|
+
}[];
|
|
63
|
+
keys: string[];
|
|
64
|
+
loops?: number;
|
|
65
|
+
oneShots?: number;
|
|
66
|
+
}, sorts: string[]): {
|
|
67
|
+
filter: Partial<SoundsFilter>;
|
|
68
|
+
sort: string | null;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* The URL with the filter written in. Empty values (and the starting sort)
|
|
72
|
+
* are removed rather than written empty; every other parameter and the
|
|
73
|
+
* hash are kept.
|
|
74
|
+
*
|
|
75
|
+
* @param href - `location.href`.
|
|
76
|
+
* @param keys
|
|
77
|
+
* @param filter
|
|
78
|
+
* @param sort
|
|
79
|
+
* @param defaultSort - The starting order (not written).
|
|
80
|
+
* @returns The new href (equal to `href` when nothing changed).
|
|
81
|
+
*/
|
|
82
|
+
export declare function writeUrlState(href: string, keys: ReturnType<typeof urlKeys>, filter: SoundsFilter, sort: string, defaultSort: string): string;
|
|
83
|
+
//# sourceMappingURL=url-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-state.d.ts","sourceRoot":"","sources":["../../src/js/data/url-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAC,YAAY,EAAmB,MAAM,aAAa,CAAC;AAEhE;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GAAG,IAAI,CAI7J;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,GAAG,IAAI,CAGvG;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAGvH;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,SAAS,EAAE;IAAC,KAAK,EAAE;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG;IAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,GAAC,IAAI,CAAA;CAAC,CAiB3O;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAW7I"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Colours the CSS can't hand the runtime directly: the canvas needs real
|
|
3
|
+
* colour values (it can't read `var()` or `color-mix()`), and the inverted
|
|
4
|
+
* "on" states need the page surface behind the list.
|
|
5
|
+
*
|
|
6
|
+
* @module colors
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The alpha of a computed colour string: `rgba(0, 0, 0, 0)`,
|
|
10
|
+
* `rgb(1 2 3 / 50%)`, `oklab(… / 0.9)`, `transparent`. Opaque when no alpha
|
|
11
|
+
* is written.
|
|
12
|
+
*
|
|
13
|
+
* @param color
|
|
14
|
+
* @returns 0..1.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseAlpha(color: string | null | undefined): number;
|
|
17
|
+
/**
|
|
18
|
+
* The first (near-)opaque background at or above an element — the page
|
|
19
|
+
* surface the list sits on. Crosses shadow-root boundaries.
|
|
20
|
+
*
|
|
21
|
+
* @param el
|
|
22
|
+
* @param minAlpha - How opaque counts as "the surface".
|
|
23
|
+
* @returns A computed colour, or `#fff` when nothing is painted.
|
|
24
|
+
*/
|
|
25
|
+
export declare function pageSurface(el: Element, minAlpha?: number): string;
|
|
26
|
+
/**
|
|
27
|
+
* Resolve any CSS colour (a `var()`, `color-mix()`, `currentColor`) to a
|
|
28
|
+
* concrete value, as it would compute inside `container`.
|
|
29
|
+
*
|
|
30
|
+
* @param container
|
|
31
|
+
* @param value - A CSS colour expression.
|
|
32
|
+
* @returns The computed colour.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveCssColor(container: Element, value: string): string;
|
|
35
|
+
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/js/dom/colors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAQnE;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,OAAO,EAAE,QAAQ,GAAE,MAAa,GAAG,MAAM,CAMxE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAQzE"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The row waveform: a small canvas of mirrored bars (or plain bars) drawn
|
|
3
|
+
* from low-resolution peaks, with the played part in the progress colour.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately NOT a WaveformPlayer per row. A pack can have 300 sounds;
|
|
6
|
+
* 300 players would be 300 resize observers, theme watchers and option
|
|
7
|
+
* pipelines for what is, until one is played, a static picture. One engine
|
|
8
|
+
* player does the audio; these are pictures with a progress fill.
|
|
9
|
+
*
|
|
10
|
+
* @module draw
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Size a canvas to its box at the device pixel ratio. Returns the CSS size,
|
|
14
|
+
* or null when the canvas has no box (hidden row, jsdom).
|
|
15
|
+
* @param canvas
|
|
16
|
+
*/
|
|
17
|
+
export declare function fitCanvas(canvas: HTMLCanvasElement): {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
dpr: number;
|
|
21
|
+
} | null;
|
|
22
|
+
/**
|
|
23
|
+
* Resample peaks to `count` bars (max of each bucket, so transients
|
|
24
|
+
* survive the downsample).
|
|
25
|
+
* @param peaks
|
|
26
|
+
* @param count
|
|
27
|
+
*/
|
|
28
|
+
export declare function resample(peaks: number[], count: number): any[];
|
|
29
|
+
/**
|
|
30
|
+
* The rectangles of a row waveform, in CSS pixels. Pure: the geometry is
|
|
31
|
+
* separate from the canvas so it can be tested (and reused for both
|
|
32
|
+
* passes of {@link drawRowWaveform}).
|
|
33
|
+
*
|
|
34
|
+
* Bars are normalised to the loudest one, so a quiet one-shot isn't a
|
|
35
|
+
* flat line, and never shorter than 4% of the height.
|
|
36
|
+
*
|
|
37
|
+
* @param peaks - 0..1.
|
|
38
|
+
* @param width - Canvas width (CSS px).
|
|
39
|
+
* @param height - Canvas height (CSS px).
|
|
40
|
+
* @param o
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
export declare function barRects(peaks: number[], width: number, height: number, o: {
|
|
44
|
+
style: 'mirror' | 'bars';
|
|
45
|
+
barWidth: number;
|
|
46
|
+
barGap: number;
|
|
47
|
+
}): {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
w: number;
|
|
51
|
+
h: number;
|
|
52
|
+
}[];
|
|
53
|
+
/**
|
|
54
|
+
* Draw a row waveform: every bar in the waveform colour, then the same
|
|
55
|
+
* bars again in the progress colour, CLIPPED at the playhead. The played
|
|
56
|
+
* part grows by the pixel — through the middle of a bar — rather than a
|
|
57
|
+
* whole bar at a time, which on a short clip stepped visibly (an 8-second
|
|
58
|
+
* loop across ~120 bars moved in ~15 jumps a second however fast it was
|
|
59
|
+
* redrawn).
|
|
60
|
+
*
|
|
61
|
+
* @param canvas
|
|
62
|
+
* @param peaks - 0..1. Null draws a flat placeholder line.
|
|
63
|
+
* @param progress - 0..1 played.
|
|
64
|
+
* @param o
|
|
65
|
+
*/
|
|
66
|
+
export declare function drawRowWaveform(canvas: HTMLCanvasElement, peaks: number[] | null, progress: number, o: {
|
|
67
|
+
style: 'mirror' | 'bars';
|
|
68
|
+
color: string;
|
|
69
|
+
progressColor: string;
|
|
70
|
+
barWidth: number;
|
|
71
|
+
barGap: number;
|
|
72
|
+
}): void;
|
|
73
|
+
//# sourceMappingURL=draw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draw.d.ts","sourceRoot":"","sources":["../../src/js/dom/draw.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,iBAAiB;;;;SAQlD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,SAatD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE;IAAC,KAAK,EAAE,QAAQ,GAAC,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,GAAG;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAC,EAAE,CActL;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,EAAE;IAAC,KAAK,EAAE,QAAQ,GAAC,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,QA6BvM"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dropdowns (type / key / sort): a button and a popup listbox, with a
|
|
3
|
+
* search field when it has many options. Follows the WAI-ARIA
|
|
4
|
+
* combobox/listbox pattern: focus stays in the search field (or the list),
|
|
5
|
+
* the active option is `aria-activedescendant`, ↑/↓ move, Enter picks,
|
|
6
|
+
* Esc closes and returns focus to the button.
|
|
7
|
+
*
|
|
8
|
+
* A menu without a listbox is a PANEL (the BPM range): a button and a popup
|
|
9
|
+
* dialog of its own controls. It shares the opening, closing, outside-press
|
|
10
|
+
* and Esc handling; what's inside it reports its own changes.
|
|
11
|
+
*
|
|
12
|
+
* The markup comes from `renderMenu()` (server or client); this module
|
|
13
|
+
* only adds behaviour.
|
|
14
|
+
*
|
|
15
|
+
* @module menus
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Does an option's label match what's typed in a menu's search field?
|
|
19
|
+
* Case- and accent-insensitive substring.
|
|
20
|
+
*
|
|
21
|
+
* @param label
|
|
22
|
+
* @param query
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
export declare function optionMatches(label: string, query: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Move an index by `delta`, clamped to `0..length-1`.
|
|
28
|
+
*
|
|
29
|
+
* @param current - -1 when nothing is active.
|
|
30
|
+
* @param delta
|
|
31
|
+
* @param length
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
export declare function stepIndex(current: number, delta: number, length: number): number;
|
|
35
|
+
/**
|
|
36
|
+
* Every dropdown inside one list, with one shared "which is open" state.
|
|
37
|
+
*/
|
|
38
|
+
export declare class Menus {
|
|
39
|
+
/** Each menu's root element, by its `data-ws-menu` name. */
|
|
40
|
+
menus: Record<string, HTMLElement>;
|
|
41
|
+
/** The open menu's root element, if any. */
|
|
42
|
+
openMenu: HTMLElement | null;
|
|
43
|
+
/**
|
|
44
|
+
* @param {HTMLElement} container - The list's root element.
|
|
45
|
+
* @param {Object} opts
|
|
46
|
+
* @param {(name: string, value: string) => void} opts.onPick - A value was chosen.
|
|
47
|
+
* @param {AbortSignal} opts.signal - Removes every listener on abort.
|
|
48
|
+
*/
|
|
49
|
+
constructor(container: HTMLElement, { onPick, signal }: {
|
|
50
|
+
onPick: (name: string, value: string) => void;
|
|
51
|
+
signal: AbortSignal;
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* Open a menu (closing any other), with the selected option active and
|
|
55
|
+
* focus in its search field or list. Flips to open over the end edge
|
|
56
|
+
* when it would overflow the list.
|
|
57
|
+
*
|
|
58
|
+
* @param menu
|
|
59
|
+
*/
|
|
60
|
+
open(menu: HTMLElement): void;
|
|
61
|
+
/**
|
|
62
|
+
* Close the open menu, if any.
|
|
63
|
+
*
|
|
64
|
+
* @param focusButton - Return focus to its button (after a
|
|
65
|
+
* pick or Esc; not after a click elsewhere).
|
|
66
|
+
*/
|
|
67
|
+
close(focusButton: boolean): void;
|
|
68
|
+
/**
|
|
69
|
+
* Show `value` as a menu's choice (button text + `aria-selected`). Used
|
|
70
|
+
* after a pick and when the filter is changed from code.
|
|
71
|
+
*
|
|
72
|
+
* @param name - 'type' | 'key' | 'sort'.
|
|
73
|
+
* @param value
|
|
74
|
+
*/
|
|
75
|
+
setValue(name: string, value: string): void;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=menus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menus.d.ts","sourceRoot":"","sources":["../../src/js/dom/menus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAGnE;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEhF;AA8BD;;GAEG;AACH,qBAAa,KAAK;IAGd,4DAA4D;IACpD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC3C,4CAA4C;IACpC,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;IAErC;;;;;OAKG;IACH,YAAY,SAAS,EAAE,WAAW,EAAE,EAAC,MAAM,EAAE,MAAM,EAAC,EAAE;QAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;QAAC,MAAM,EAAE,WAAW,CAAA;KAAC,EAQzH;IA0CD;;;;;;OAMG;IACH,IAAI,CAAC,IAAI,EAAE,WAAW,QAWrB;IAED;;;;;OAKG;IACH,KAAK,CAAC,WAAW,EAAE,OAAO,QAQzB;IAED;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAYnC;CAqEJ"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export declare function readRows(list: HTMLElement): Sound[];
|
|
18
|
+
/**
|
|
19
|
+
* The row elements, indexed by the sound each one shows (whatever order
|
|
20
|
+
* they're displayed in).
|
|
21
|
+
*
|
|
22
|
+
* @param list
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
export declare function indexRows(list: HTMLElement): HTMLElement[];
|
|
26
|
+
/**
|
|
27
|
+
* The rows currently visible (not hidden by the filter or the page), in
|
|
28
|
+
* display order.
|
|
29
|
+
*
|
|
30
|
+
* @param list
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
export declare function visibleRows(list: HTMLElement): HTMLElement[];
|
|
34
|
+
/**
|
|
35
|
+
* Put the rows in the given order. Every row moves (hidden ones too), so
|
|
36
|
+
* clearing a filter keeps the order.
|
|
37
|
+
*
|
|
38
|
+
* @param list
|
|
39
|
+
* @param rows - In the order to show them.
|
|
40
|
+
*/
|
|
41
|
+
export declare function orderRows(list: HTMLElement, rows: HTMLElement[]): void;
|
|
42
|
+
//# 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;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,KAAK,EAAE,CAenD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW,EAAE,CAI1D;AAED;;;;;;GAMG;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"}
|
package/types/entry.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @arraypress/waveform-sounds — public surface, without the import-time
|
|
3
|
+
* auto-init scan (`index.js` adds that). Anything new belongs here.
|
|
4
|
+
*
|
|
5
|
+
* @module entry
|
|
6
|
+
*/
|
|
7
|
+
import { WaveformSounds, DEFAULT_OPTIONS } from './core/WaveformSounds.js';
|
|
8
|
+
import { encodePeaks, decodePeaks, normalizeKey, normalizeSounds, parseManifest, facets, matches, sortSounds, formatDuration } from './data/sounds.js';
|
|
9
|
+
import { renderSounds, renderSoundsElement, DEFAULT_STRINGS } from './render/markup.js';
|
|
10
|
+
import type { WaveformSoundsEventMap } from './types.js';
|
|
11
|
+
declare global {
|
|
12
|
+
interface Window {
|
|
13
|
+
/** The script-tag global, set when the bundle loads in a browser. */
|
|
14
|
+
WaveformSounds: typeof WaveformSounds;
|
|
15
|
+
}
|
|
16
|
+
interface HTMLElementEventMap extends WaveformSoundsEventMap {
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export default WaveformSounds;
|
|
20
|
+
export { WaveformSounds, DEFAULT_OPTIONS, DEFAULT_STRINGS, encodePeaks, decodePeaks, normalizeKey, normalizeSounds, parseManifest, facets, matches, sortSounds, formatDuration, renderSounds, renderSoundsElement, };
|
|
21
|
+
export type { SoundInput, Sound, SoundsManifest, SoundsFilter, SoundsLoopFilter, SoundsSort, SoundsLayout, SoundsFilterControl, SoundsColumn, WaveformSoundsStrings, WaveformSoundsOptions, WaveformSoundsEventMap, } from './types.js';
|
|
22
|
+
//# sourceMappingURL=entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/js/entry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAC,cAAc,EAAE,eAAe,EAAC,MAAM,0BAA0B,CAAC;AACzE,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,EAAC,MAAM,oBAAoB,CAAC;AACtF,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;CAClE;eASc,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,GACpC,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,GACzB,MAAM,YAAY,CAAC"}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @arraypress/waveform-sounds
|
|
3
|
+
* A searchable, filterable list of sounds for WaveformPlayer.
|
|
4
|
+
*
|
|
5
|
+
* Importing this entry initialises every `[data-waveform-sounds]` element
|
|
6
|
+
* 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,cAAc,MAAM,YAAY,CAAC;AAExC,cAAc,YAAY,CAAC;eACZ,cAAc"}
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare function text(value: unknown): string;
|
|
23
|
+
/**
|
|
24
|
+
* Serialise attributes, in the order given.
|
|
25
|
+
*
|
|
26
|
+
* @param map
|
|
27
|
+
* @returns e.g. ` class="ws-row" hidden` (leading space included).
|
|
28
|
+
*/
|
|
29
|
+
export declare function attrs(map?: HtmlAttrs): string;
|
|
30
|
+
/**
|
|
31
|
+
* Build an element.
|
|
32
|
+
*
|
|
33
|
+
* @param tag
|
|
34
|
+
* @param attributes
|
|
35
|
+
* @param children - HTML strings; falsy ones and nested arrays are flattened away.
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
export declare function h(tag: string, attributes?: HtmlAttrs, ...children: HtmlChild[]): string;
|
|
39
|
+
//# 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;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE3C;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,GAAG,GAAE,SAAc,GAAG,MAAM,CAOjD;AAED;;;;;;;GAOG;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;AAcH,eAAO,MAAM,KAAK;IACd,IAAI;IACJ,KAAK;IACL,MAAM;IACN,OAAO;IACP,KAAK;IACL,QAAQ;IACR,IAAI;CACP,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
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 { RENDER_DEFAULTS, 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, 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
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
export declare function toolbarPlan(f: ReturnType<typeof facets>, o: ReturnType<typeof resolveRenderOptions>): {
|
|
47
|
+
types: 'chips' | 'menu' | null;
|
|
48
|
+
key: boolean;
|
|
49
|
+
bpm: boolean;
|
|
50
|
+
loops: boolean;
|
|
51
|
+
sorts: string[];
|
|
52
|
+
search: boolean;
|
|
53
|
+
loop: boolean;
|
|
54
|
+
count: boolean;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Does the Loop toggle start on? An explicit `loop` option decides; left
|
|
58
|
+
* unset, it's on exactly when the list marks loops (only those repeat, so
|
|
59
|
+
* a one-shot still plays once).
|
|
60
|
+
*
|
|
61
|
+
* @param loop - The `loop` option.
|
|
62
|
+
* @param f - The sounds' facets.
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
export declare function loopsByDefault(loop: boolean | null | undefined, f: {
|
|
66
|
+
loops: number;
|
|
67
|
+
}): boolean;
|
|
68
|
+
/** A dropdown's content ({@link renderMenu}). */
|
|
69
|
+
export interface MenuSpec {
|
|
70
|
+
id: string;
|
|
71
|
+
label: string;
|
|
72
|
+
prefix?: string;
|
|
73
|
+
value: string;
|
|
74
|
+
options: {
|
|
75
|
+
value: string;
|
|
76
|
+
label: string;
|
|
77
|
+
count?: number;
|
|
78
|
+
}[];
|
|
79
|
+
searchFrom: number;
|
|
80
|
+
placeholder?: string;
|
|
81
|
+
noMatches: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A dropdown: a button and a popup listbox, with a search field when it
|
|
85
|
+
* has more than `searchFrom` options. The runtime (`menus.js`) opens,
|
|
86
|
+
* filters and navigates it; without JS the button still shows the value.
|
|
87
|
+
*
|
|
88
|
+
* @param name - 'type' | 'key' | 'sort' (the runtime routes by it).
|
|
89
|
+
* @param m
|
|
90
|
+
* @param m.id - Id prefix for this list.
|
|
91
|
+
* @param m.label - Accessible name ("Type").
|
|
92
|
+
* @param [m.prefix] - Visible lead-in ("Sort by"); otherwise the label is screen-reader only.
|
|
93
|
+
* @param m.value - The selected value.
|
|
94
|
+
* @param m.options
|
|
95
|
+
* @param m.searchFrom - Options above which a search field is added.
|
|
96
|
+
* @param [m.placeholder] - The search field's placeholder (no field without one).
|
|
97
|
+
* @param m.noMatches - Shown when the search matches nothing.
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
export declare function renderMenu(name: string, m: MenuSpec): string;
|
|
101
|
+
/**
|
|
102
|
+
* One row. `index` is the sound's position in the ORIGINAL list: the
|
|
103
|
+
* runtime maps rows back to sounds through it, whatever order they are
|
|
104
|
+
* sorted into. Every field is also written as a `data-*` attribute, so the
|
|
105
|
+
* runtime can rebuild the sounds from server markup.
|
|
106
|
+
*
|
|
107
|
+
* @param sound - Normalised.
|
|
108
|
+
* @param index
|
|
109
|
+
* @param o
|
|
110
|
+
* @param hidden - Past the first page.
|
|
111
|
+
* @returns
|
|
112
|
+
*/
|
|
113
|
+
export declare function renderRow(sound: Sound, index: number, o: ReturnType<typeof resolveRenderOptions>, hidden?: boolean): string;
|
|
114
|
+
/**
|
|
115
|
+
* The whole component's inner markup.
|
|
116
|
+
*
|
|
117
|
+
* @param sounds - Sounds (normalised or raw; normalised here).
|
|
118
|
+
* @param options - Render options (see `WaveformSoundsOptions`).
|
|
119
|
+
* @returns HTML for the inside of `[data-waveform-sounds]`.
|
|
120
|
+
*/
|
|
121
|
+
export declare function renderSounds(sounds: SoundInput[], options?: WaveformSoundsOptions): string;
|
|
122
|
+
/**
|
|
123
|
+
* The full element, for callers who want one string: the wrapper div with
|
|
124
|
+
* its `data-waveform-sounds` marker, its `data-player` and the inner markup.
|
|
125
|
+
*
|
|
126
|
+
* @param sounds
|
|
127
|
+
* @param options
|
|
128
|
+
* @param className - Extra classes for the wrapper.
|
|
129
|
+
* @returns
|
|
130
|
+
*/
|
|
131
|
+
export declare function renderSoundsElement(sounds: SoundInput[], options?: WaveformSoundsOptions, className?: string): string;
|
|
132
|
+
//# sourceMappingURL=markup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markup.d.ts","sourceRoot":"","sources":["../../src/js/render/markup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAC,cAAc,EAAe,MAAM,EAAkC,MAAM,mBAAmB,CAAC;AAGvG,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAC,MAAM,cAAc,CAAC;AACnE,OAAO,EAAW,SAAS,EAAE,eAAe,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAC;AAEzF,OAAO,KAAK,EAAC,KAAK,EAAE,UAAU,EAAc,qBAAqB,EAAwB,MAAM,aAAa,CAAC;AAE7G,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,oBAAoB,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,EAAC,CAAC;AAE7G;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,EAAE,GAAG,MAAM,CAGtD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,GAAG;IAAC,KAAK,EAAE,OAAO,GAAC,MAAM,GAAC,IAAI,CAAC;IAAC,GAAG,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAC,CAa/O;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,EAAE,CAAC,EAAE;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,GAAG,OAAO,CAE5F;AAWD,iDAAiD;AACjD,MAAM,WAAW,QAAQ;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACrB;AAaD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,GAAG,MAAM,CA+B5D;AAiHD;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,EAAE,MAAM,GAAE,OAAe,GAAG,MAAM,CAoClI;AAqBD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,OAAO,GAAE,qBAA0B,GAAG,MAAM,CAS9F;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,OAAO,GAAE,qBAA0B,EAAE,SAAS,GAAE,MAAW,GAAG,MAAM,CAI7H"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The options that shape the markup — the 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
|
+
* The object without its `undefined` entries (so spreading it can't erase
|
|
24
|
+
* a default).
|
|
25
|
+
*
|
|
26
|
+
* @param obj
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
export declare function defined(obj: Record<string, any> | null | undefined): Record<string, any>;
|
|
30
|
+
/**
|
|
31
|
+
* The entries of `values` that are allowed, in the caller's order; the
|
|
32
|
+
* fallback when `values` isn't a list.
|
|
33
|
+
*
|
|
34
|
+
* @param values
|
|
35
|
+
* @param allowed
|
|
36
|
+
* @param fallback
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
export declare function allowedList<T extends string>(values: unknown, allowed: T[], fallback: T[]): T[];
|
|
40
|
+
/**
|
|
41
|
+
* A whole number ≥ 0, or the fallback.
|
|
42
|
+
*
|
|
43
|
+
* @param value
|
|
44
|
+
* @param fallback
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
export declare function wholeNumber(value: unknown, fallback: number): number;
|
|
48
|
+
/**
|
|
49
|
+
* The render options, defaulted and validated: unknown filters, sorts and
|
|
50
|
+
* columns are dropped, counts are whole numbers, `strings` is complete.
|
|
51
|
+
*
|
|
52
|
+
* @param options
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveRenderOptions(options?: WaveformSoundsOptions): RenderOptions;
|
|
56
|
+
//# 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,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAIxF;AAED;;;;;;;;GAQG;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;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGpE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B,GAAG,aAAa,CAavF"}
|