@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.
- package/LICENSE +1 -1
- package/README.md +43 -3
- package/dist/waveform-sounds-no-autoinit.esm.js +607 -178
- package/dist/waveform-sounds-render.esm.js +79 -15
- package/dist/waveform-sounds.css +136 -79
- package/dist/waveform-sounds.esm.js +611 -181
- package/dist/waveform-sounds.js +608 -181
- package/dist/waveform-sounds.min.css +1 -1
- package/dist/waveform-sounds.min.js +3 -3
- package/package.json +36 -33
- package/src/css/waveform-sounds.css +136 -79
- package/src/js/core/WaveformSounds.ts +1366 -0
- package/src/js/core/element.ts +208 -0
- package/src/js/core/engine.ts +107 -0
- package/src/js/core/{options.js → options.ts} +28 -28
- package/src/js/data/{bpm.js → bpm.ts} +27 -17
- package/src/js/data/{navigation.js → navigation.ts} +31 -18
- package/src/js/data/{sounds.js → sounds.ts} +97 -66
- package/src/js/data/url-state.ts +130 -0
- package/src/js/dom/colors.ts +86 -0
- package/src/js/dom/{draw.js → draw.ts} +16 -17
- package/src/js/dom/{menus.js → menus.ts} +70 -55
- package/src/js/dom/{rows.js → rows.ts} +15 -17
- package/src/js/entry.ts +60 -0
- package/src/js/{index.js → index.ts} +7 -3
- package/src/js/render/{html.js → html.ts} +16 -12
- package/src/js/render/{icons.js → icons.ts} +3 -4
- package/src/js/render/{markup.js → markup.ts} +114 -64
- package/src/js/render/options.ts +118 -0
- package/src/js/render/{strings.js → strings.ts} +18 -16
- package/src/js/{render-entry.js → render-entry.ts} +2 -1
- package/src/js/shared/{utils.js → utils.ts} +24 -24
- package/{index.d.ts → src/js/types.ts} +40 -88
- package/types/core/WaveformSounds.d.ts +175 -0
- package/types/core/WaveformSounds.d.ts.map +1 -0
- package/types/core/element.d.ts +84 -0
- package/types/core/element.d.ts.map +1 -0
- package/types/core/engine.d.ts +72 -0
- package/types/core/engine.d.ts.map +1 -0
- package/types/core/options.d.ts +71 -0
- package/types/core/options.d.ts.map +1 -0
- package/types/data/bpm.d.ts +80 -0
- package/types/data/bpm.d.ts.map +1 -0
- package/types/data/navigation.d.ts +62 -0
- package/types/data/navigation.d.ts.map +1 -0
- package/types/data/sounds.d.ts +168 -0
- package/types/data/sounds.d.ts.map +1 -0
- package/types/data/url-state.d.ts +109 -0
- package/types/data/url-state.d.ts.map +1 -0
- package/types/dom/colors.d.ts +48 -0
- package/types/dom/colors.d.ts.map +1 -0
- package/types/dom/draw.d.ts +72 -0
- package/types/dom/draw.d.ts.map +1 -0
- package/types/dom/menus.d.ts +75 -0
- package/types/dom/menus.d.ts.map +1 -0
- package/types/dom/rows.d.ts +39 -0
- package/types/dom/rows.d.ts.map +1 -0
- package/types/entry.d.ts +28 -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 +37 -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 +141 -0
- package/types/render/markup.d.ts.map +1 -0
- package/types/render/options.d.ts +69 -0
- package/types/render/options.d.ts.map +1 -0
- package/types/render/strings.d.ts +43 -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 +280 -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 -2159
- package/dist/waveform-sounds-render.cjs +0 -614
- package/dist/waveform-sounds.cjs +0 -2181
- package/no-autoinit.d.ts +0 -2
- package/render.d.ts +0 -5
- package/src/js/core/WaveformSounds.js +0 -993
- package/src/js/core/engine.js +0 -57
- package/src/js/data/url-state.js +0 -106
- package/src/js/dom/colors.js +0 -59
- package/src/js/entry.js +0 -25
- package/src/js/render/options.js +0 -90
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The BPM range control's arithmetic: between the two slider handles and the
|
|
3
|
+
* filter, and the label its menu button shows. Pure, so the server renderer
|
|
4
|
+
* and the runtime agree.
|
|
5
|
+
*
|
|
6
|
+
* A handle resting at an END of the pack's range is "no limit on that side",
|
|
7
|
+
* not a limit at that value: sounds with no BPM are hidden by any BPM filter,
|
|
8
|
+
* so a slider left wide open must not filter at all.
|
|
9
|
+
*
|
|
10
|
+
* @module bpm
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* The range the slider spans: the pack's BPMs widened to whole numbers
|
|
14
|
+
* (the handles step by 1, so a pack whose fastest loop is 128.5 BPM needs
|
|
15
|
+
* an end at 129, or the top handle could never reach it). A pack of whole
|
|
16
|
+
* BPMs is unchanged.
|
|
17
|
+
*
|
|
18
|
+
* @param range - The pack's BPM range (`facets().bpm`).
|
|
19
|
+
* @returns The slider's ends, or null when the pack has no BPMs.
|
|
20
|
+
*/
|
|
21
|
+
export declare function bpmExtent(range: {
|
|
22
|
+
min: number;
|
|
23
|
+
max: number;
|
|
24
|
+
} | null | undefined): {
|
|
25
|
+
min: number;
|
|
26
|
+
max: number;
|
|
27
|
+
} | null;
|
|
28
|
+
/**
|
|
29
|
+
* The filter for a pair of handle positions.
|
|
30
|
+
*
|
|
31
|
+
* @param lo - The lower handle.
|
|
32
|
+
* @param hi - The upper handle.
|
|
33
|
+
* @param extent - The slider's range ({@link bpmExtent}).
|
|
34
|
+
* @returns `''` for an open end.
|
|
35
|
+
*/
|
|
36
|
+
export declare function bpmFilterFromRange(lo: number, hi: number, extent: {
|
|
37
|
+
min: number;
|
|
38
|
+
max: number;
|
|
39
|
+
}): {
|
|
40
|
+
bpmMin: string;
|
|
41
|
+
bpmMax: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Where the handles sit for a filter: an open end at the pack's own end, a
|
|
45
|
+
* set one at its value (clamped into the pack's range, so a link with
|
|
46
|
+
* `?bpm=60-300` still shows sensible handles).
|
|
47
|
+
*
|
|
48
|
+
* @param filter
|
|
49
|
+
* @param extent
|
|
50
|
+
*/
|
|
51
|
+
export declare function bpmRangeFromFilter(filter: {
|
|
52
|
+
bpmMin?: string | number;
|
|
53
|
+
bpmMax?: string | number;
|
|
54
|
+
}, extent: {
|
|
55
|
+
min: number;
|
|
56
|
+
max: number;
|
|
57
|
+
}): {
|
|
58
|
+
lo: number;
|
|
59
|
+
hi: number;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* A handle's position along the track, 0..1.
|
|
63
|
+
*
|
|
64
|
+
* @param value
|
|
65
|
+
* @param extent
|
|
66
|
+
*/
|
|
67
|
+
export declare function bpmFraction(value: number, extent: {
|
|
68
|
+
min: number;
|
|
69
|
+
max: number;
|
|
70
|
+
}): number;
|
|
71
|
+
/**
|
|
72
|
+
* Is a BPM limit set on either side?
|
|
73
|
+
*
|
|
74
|
+
* @param filter
|
|
75
|
+
*/
|
|
76
|
+
export declare function hasBpmFilter(filter: {
|
|
77
|
+
bpmMin?: string | number;
|
|
78
|
+
bpmMax?: string | number;
|
|
79
|
+
}): boolean;
|
|
80
|
+
//# sourceMappingURL=bpm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bpm.d.ts","sourceRoot":"","sources":["../../src/js/data/bpm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,GAAG,IAAI,GAAG,SAAS,GAAG;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,GAAG,IAAI,CAEjH;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,GAAG;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,CAM/H;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,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,GAAG;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAC,CAQzJ;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,GAAG,MAAM,CAGrF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE;IAAC,MAAM,CAAC,EAAE,MAAM,GAAC,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAC,MAAM,CAAA;CAAC,GAAG,OAAO,CAE9F"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Moving through the list: which row a key lands on, how far an arrow
|
|
3
|
+
* seeks, and which rows the current page shows. Pure — the runtime maps
|
|
4
|
+
* the results onto rows and the engine.
|
|
5
|
+
*
|
|
6
|
+
* @module navigation
|
|
7
|
+
*/
|
|
8
|
+
/** How far ←/→ seek, as a fraction of the sound. */
|
|
9
|
+
export declare const SEEK_STEP = 0.1;
|
|
10
|
+
/**
|
|
11
|
+
* Where a navigation key moves from position `at` in a list of `count`
|
|
12
|
+
* visible rows.
|
|
13
|
+
*
|
|
14
|
+
* @param key - `KeyboardEvent.key`.
|
|
15
|
+
* @param at - The focused row's position among the visible rows.
|
|
16
|
+
* @param count - How many rows are visible.
|
|
17
|
+
* @returns The new position; `'search'` for ↑ on
|
|
18
|
+
* the first row (back to the search field); null when the key isn't a
|
|
19
|
+
* move or there is nowhere to go.
|
|
20
|
+
*/
|
|
21
|
+
export declare function rowTarget(key: string, at: number, count: number): number | 'search' | null;
|
|
22
|
+
/**
|
|
23
|
+
* The position an ←/→ press seeks to. Stops just short of the end, so a
|
|
24
|
+
* held → can't end the sound by accident.
|
|
25
|
+
*
|
|
26
|
+
* @param progress - Current position, 0..1.
|
|
27
|
+
* @param key - `'ArrowRight'` or `'ArrowLeft'`.
|
|
28
|
+
* @returns The new position, or null for any other key.
|
|
29
|
+
*/
|
|
30
|
+
export declare function seekTarget(progress: number, key: string): number | null;
|
|
31
|
+
/** Where End seeks on a slider: just short of the end, so it can't end
|
|
32
|
+
* the sound (and with it auto-advance) by accident. */
|
|
33
|
+
export declare const SEEK_END = 0.999;
|
|
34
|
+
/**
|
|
35
|
+
* The position Home / End seek to on a row's seek slider (the ARIA slider
|
|
36
|
+
* pattern: they go to the minimum / maximum, not to the first / last row).
|
|
37
|
+
*
|
|
38
|
+
* @param key - `KeyboardEvent.key`.
|
|
39
|
+
* @returns 0 for Home, {@link SEEK_END} for End, else null.
|
|
40
|
+
*/
|
|
41
|
+
export declare function sliderEdgeTarget(key: string): number | null;
|
|
42
|
+
/**
|
|
43
|
+
* Which of the matching sounds the current page shows, and how many more
|
|
44
|
+
* "Show more" would reveal.
|
|
45
|
+
*
|
|
46
|
+
* @template T
|
|
47
|
+
* @param shown - The sounds that match, in display order.
|
|
48
|
+
* @param limit - How many to show (Infinity for all).
|
|
49
|
+
*/
|
|
50
|
+
export declare function pageWindow<T>(shown: T[], limit: number): {
|
|
51
|
+
visible: Set<T>;
|
|
52
|
+
remaining: number;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The page limit that reveals position `pos` (used when playing past the
|
|
56
|
+
* end of the current page, e.g. by `next()` or auto-advance).
|
|
57
|
+
*
|
|
58
|
+
* @param limit - The current limit.
|
|
59
|
+
* @param pos - The position that must be visible.
|
|
60
|
+
*/
|
|
61
|
+
export declare function limitToReveal(limit: number, pos: number): number;
|
|
62
|
+
//# sourceMappingURL=navigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/js/data/navigation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,oDAAoD;AACpD,eAAO,MAAM,SAAS,MAAM,CAAC;AAE7B;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,IAAI,CAS1F;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGvE;AAED;wDACwD;AACxD,eAAO,MAAM,QAAQ,QAAQ,CAAC;AAE9B;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE3D;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG;IAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAC,CAG7F;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhE"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { Sound, SoundInput, SoundsFilter, SoundsManifest, SoundsSort } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Pure data helpers: no DOM, no window. Shared by the browser runtime and
|
|
4
|
+
* the server renderer (`@arraypress/waveform-sounds/render`), so a wrapper
|
|
5
|
+
* that renders the list on the server produces exactly what the client
|
|
6
|
+
* would.
|
|
7
|
+
*
|
|
8
|
+
* @module data
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Peaks travel as an 8-bit hex string, two characters per bar ("00"–"ff").
|
|
12
|
+
* A sound browser draws ~48–64 bars per row, so that is ~100 characters a
|
|
13
|
+
* sound: 300 sounds is ~30 KB in a manifest or in row attributes, against
|
|
14
|
+
* ~3x that as a JSON number array.
|
|
15
|
+
*
|
|
16
|
+
* @param peaks - Values 0..1.
|
|
17
|
+
* @returns Hex string.
|
|
18
|
+
*/
|
|
19
|
+
export declare function encodePeaks(peaks: number[]): string;
|
|
20
|
+
/**
|
|
21
|
+
* Decode peaks from any accepted form into numbers 0..1.
|
|
22
|
+
*
|
|
23
|
+
* Accepts the hex string from {@link encodePeaks}, the player's compact
|
|
24
|
+
* `wp1:` string (`"wp1:"` + base64url of one byte per peak, what the 2.0
|
|
25
|
+
* core and waveform-gen write), an array of 0..1 numbers, or an array of
|
|
26
|
+
* integers on a larger scale (e.g. 0..100 or 0..255) together with that
|
|
27
|
+
* `scale`. Server markup still writes hex.
|
|
28
|
+
*
|
|
29
|
+
* @param value
|
|
30
|
+
* @param scale - The maximum of an integer array.
|
|
31
|
+
* @returns Peaks, or null when there are none.
|
|
32
|
+
*/
|
|
33
|
+
export declare function decodePeaks(value: string | number[] | null | undefined, scale?: number): number[] | null;
|
|
34
|
+
/**
|
|
35
|
+
* Normalise a musical key to a short canonical form: root, accidental
|
|
36
|
+
* (`#` or `b`), and `m` for minor. "F minor", "Fmin", "f m" → "Fm";
|
|
37
|
+
* "C# Major", "C♯" → "C#". Anything unparseable comes back trimmed, as
|
|
38
|
+
* given, so an unusual label still displays.
|
|
39
|
+
*
|
|
40
|
+
* @param key
|
|
41
|
+
* @returns Canonical key, or '' for none.
|
|
42
|
+
*/
|
|
43
|
+
export declare function normalizeKey(key: string | null | undefined): string;
|
|
44
|
+
/**
|
|
45
|
+
* Format seconds as m:ss (whole seconds, rounded down like a player's
|
|
46
|
+
* clock), or as tenths under a second.
|
|
47
|
+
*
|
|
48
|
+
* A one-shot (a kick, a hat) is often shorter than a second, and m:ss would
|
|
49
|
+
* round it to "0:00", which reads as a missing length.
|
|
50
|
+
*
|
|
51
|
+
* @param seconds
|
|
52
|
+
* @returns e.g. "0:08", "0.4s", or '' when unknown.
|
|
53
|
+
*/
|
|
54
|
+
export declare function formatDuration(seconds: number | null | undefined): string;
|
|
55
|
+
/**
|
|
56
|
+
* A playback position as a clock: whole seconds, rounded down like a
|
|
57
|
+
* player's ("0:12", "1:05:09" past an hour).
|
|
58
|
+
*
|
|
59
|
+
* @param seconds
|
|
60
|
+
* @returns e.g. "0:12"; "0:00" for anything unusable.
|
|
61
|
+
*/
|
|
62
|
+
export declare function formatClock(seconds: number): string;
|
|
63
|
+
/**
|
|
64
|
+
* Parse a duration given as seconds (8.02) or as "m:ss" / "h:mm:ss".
|
|
65
|
+
* @param value
|
|
66
|
+
*/
|
|
67
|
+
export declare function parseDuration(value: number | string | null | undefined): number | null;
|
|
68
|
+
/**
|
|
69
|
+
* The title a file name implies: extension and separators dropped,
|
|
70
|
+
* leading pack prefixes kept (they are often the label's code).
|
|
71
|
+
* "NW_Bass_Loop_04_128_Fmin.wav" → "NW Bass Loop 04 128 Fmin".
|
|
72
|
+
* @param url
|
|
73
|
+
*/
|
|
74
|
+
export declare function titleFromUrl(url: string): string;
|
|
75
|
+
/**
|
|
76
|
+
* Normalise one sound into the shape the runtime and renderer use.
|
|
77
|
+
*
|
|
78
|
+
* @param input - A sound: `{url, title?, type?, bpm?, key?,
|
|
79
|
+
* duration?, tags?, peaks?, waveform?, download?, loop?, id?}`.
|
|
80
|
+
* @param index - Its position (used for a fallback id).
|
|
81
|
+
* @param peakScale - Scale of an integer `peaks` array.
|
|
82
|
+
* @returns The sound, or null if it has
|
|
83
|
+
* no url.
|
|
84
|
+
*/
|
|
85
|
+
export declare function normalizeSound(input: Record<string, any>, index: number, peakScale?: number): Sound | null;
|
|
86
|
+
/**
|
|
87
|
+
* The values of the loops-or-one-shots filter. A sound is a loop only when
|
|
88
|
+
* it says so (`loop: true`); everything else is a one-shot.
|
|
89
|
+
*/
|
|
90
|
+
export declare const LOOP_FILTERS: string[];
|
|
91
|
+
/**
|
|
92
|
+
* Is this a loop? Only an explicit yes counts: `true`, or `"true"` / `"1"`
|
|
93
|
+
* as an attribute or a CSV-ish manifest writes it. Unset is a one-shot.
|
|
94
|
+
*
|
|
95
|
+
* @param value
|
|
96
|
+
*/
|
|
97
|
+
export declare function isLoop(value: unknown): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Read a sounds manifest. Accepts `{version, peakScale?, sounds: [...]}`
|
|
100
|
+
* (what `waveform-gen --manifest` writes) or a bare array of sounds.
|
|
101
|
+
* Sounds without a url are dropped.
|
|
102
|
+
*
|
|
103
|
+
* @param manifest
|
|
104
|
+
*/
|
|
105
|
+
export declare function parseManifest(manifest: SoundsManifest | SoundInput[]): Sound[];
|
|
106
|
+
/**
|
|
107
|
+
* Normalise a list of sounds, dropping invalid ones and de-duplicating ids
|
|
108
|
+
* (a repeated id would make two rows answer to one play() call).
|
|
109
|
+
* @param list
|
|
110
|
+
* @param peakScale
|
|
111
|
+
*/
|
|
112
|
+
export declare function normalizeSounds(list: SoundInput[], peakScale?: number): Sound[];
|
|
113
|
+
/**
|
|
114
|
+
* What the filter controls offer, derived from the sounds: each type with
|
|
115
|
+
* its count (in first-seen order), each key (in musical order), the BPM
|
|
116
|
+
* range, and how many are loops and one-shots. A control with nothing to
|
|
117
|
+
* offer is not rendered.
|
|
118
|
+
*
|
|
119
|
+
* @param sounds
|
|
120
|
+
*/
|
|
121
|
+
export declare function facets(sounds: Sound[]): {
|
|
122
|
+
types: {
|
|
123
|
+
name: string;
|
|
124
|
+
count: number;
|
|
125
|
+
}[];
|
|
126
|
+
keys: string[];
|
|
127
|
+
bpm: {
|
|
128
|
+
min: number;
|
|
129
|
+
max: number;
|
|
130
|
+
} | null;
|
|
131
|
+
hasDuration: boolean;
|
|
132
|
+
loops: number;
|
|
133
|
+
oneShots: number;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Does a sound match the filter? Every set criterion must hold. `loop` is
|
|
137
|
+
* `'loop'` (loops only), `'one-shot'` (everything else) or empty (both).
|
|
138
|
+
*
|
|
139
|
+
* `query` matches the title, type, key and tags with
|
|
140
|
+
* `@arraypress/text`'s `matchesAll`: every word, in any order, forgiving
|
|
141
|
+
* one typo in words of four letters or more ("drun" finds drum loops). A
|
|
142
|
+
* number in the query also matches the BPM exactly, so "bass 128" finds
|
|
143
|
+
* 128 BPM bass loops.
|
|
144
|
+
*
|
|
145
|
+
* @param sound
|
|
146
|
+
* @param filter
|
|
147
|
+
*/
|
|
148
|
+
export declare function matches(sound: Sound, filter?: Partial<SoundsFilter>): boolean;
|
|
149
|
+
/** The sort orders the toolbar offers. */
|
|
150
|
+
export declare const SORTS: SoundsSort[];
|
|
151
|
+
/**
|
|
152
|
+
* The configured sort orders the data can use (no BPM sort without BPMs),
|
|
153
|
+
* in the configured order. Shared by the renderer and the runtime, so the
|
|
154
|
+
* menu and the starting order always agree.
|
|
155
|
+
*
|
|
156
|
+
* @param sorts - The configured orders.
|
|
157
|
+
* @param f - The sounds' facets.
|
|
158
|
+
*/
|
|
159
|
+
export declare function availableSorts(sorts: string[], f: ReturnType<typeof facets>): string[];
|
|
160
|
+
/**
|
|
161
|
+
* Sort sounds (returns a new array; `default` keeps the given order).
|
|
162
|
+
* Missing values sort last in every order.
|
|
163
|
+
*
|
|
164
|
+
* @param sounds
|
|
165
|
+
* @param by
|
|
166
|
+
*/
|
|
167
|
+
export declare function sortSounds(sounds: Sound[], by?: SoundsSort): Sound[];
|
|
168
|
+
//# sourceMappingURL=sounds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sounds.d.ts","sourceRoot":"","sources":["../../src/js/data/sounds.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAC,MAAM,aAAa,CAAC;AAE7F;;;;;;;GAOG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAQnD;AAwBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,GAAE,MAAU,GAAG,MAAM,EAAE,GAAG,IAAI,CAa3G;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CASnE;AAcD;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAWzE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAInD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAStF;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKhD;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,GAAE,MAAU,GAAG,KAAK,GAAG,IAAI,CAsB7G;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,UAAuB,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE9C;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,cAAc,GAAG,UAAU,EAAE,GAAG,KAAK,EAAE,CAI9E;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,SAAS,GAAE,MAAU,GAAG,KAAK,EAAE,CAalF;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG;IAAC,KAAK,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,GAAG,EAAE;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAC,GAAC,IAAI,CAAC;IAAC,WAAW,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAmB7L;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,GAAE,OAAO,CAAC,YAAY,CAAM,GAAG,OAAO,CAsBjF;AAED,0CAA0C;AAC1C,eAAO,MAAM,KAAK,EAAE,UAAU,EAAmD,CAAC;AAWlF;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,GAAG,MAAM,EAAE,CAEtF;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,GAAE,UAAsB,GAAG,KAAK,EAAE,CAW/E"}
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
*/
|
|
19
|
+
export declare function urlKeys(urlState: boolean | string | null | undefined): {
|
|
20
|
+
q: string;
|
|
21
|
+
type: string;
|
|
22
|
+
key: string;
|
|
23
|
+
bpm: string;
|
|
24
|
+
loop: string;
|
|
25
|
+
sort: string;
|
|
26
|
+
} | null;
|
|
27
|
+
/**
|
|
28
|
+
* A BPM range parameter: "120-130", "120-", "-130", or with decimals
|
|
29
|
+
* ("128.5-130", what `setFilter({bpmMin: 128.5})` writes). Reversed ends
|
|
30
|
+
* are put in order.
|
|
31
|
+
*
|
|
32
|
+
* @param value
|
|
33
|
+
* @returns null if malformed.
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseBpmRange(value: string | null | undefined): {
|
|
36
|
+
bpmMin: string;
|
|
37
|
+
bpmMax: string;
|
|
38
|
+
} | null;
|
|
39
|
+
/**
|
|
40
|
+
* Keep only the limits that fall inside the pack's BPM range: a link made
|
|
41
|
+
* for another pack (`?bpm=200-` on one topping out at 174) must not empty
|
|
42
|
+
* the list, and a limit beyond an end is no limit at all.
|
|
43
|
+
*
|
|
44
|
+
* @param range - From {@link parseBpmRange}.
|
|
45
|
+
* @param extent - The slider's range; null when the pack has no BPMs
|
|
46
|
+
* (then any BPM filter would hide everything, so none is kept).
|
|
47
|
+
* @returns The usable limits, or null when none is left.
|
|
48
|
+
*/
|
|
49
|
+
export declare function bpmRangeWithin(range: {
|
|
50
|
+
bpmMin: string;
|
|
51
|
+
bpmMax: string;
|
|
52
|
+
}, extent: {
|
|
53
|
+
min: number;
|
|
54
|
+
max: number;
|
|
55
|
+
} | null): {
|
|
56
|
+
bpmMin: string;
|
|
57
|
+
bpmMax: string;
|
|
58
|
+
} | null;
|
|
59
|
+
/**
|
|
60
|
+
* The inverse of {@link parseBpmRange}; '' when neither end is set.
|
|
61
|
+
*
|
|
62
|
+
* @param min
|
|
63
|
+
* @param max
|
|
64
|
+
*/
|
|
65
|
+
export declare function formatBpmRange(min: string | number | null | undefined, max: string | number | null | undefined): string;
|
|
66
|
+
/**
|
|
67
|
+
* Read the filter and sort from a query string. Values the list can't use
|
|
68
|
+
* (a type it doesn't have, a key no sound is in, a BPM limit outside its
|
|
69
|
+
* range, a loops filter on a list that isn't a mix of loops and one-shots,
|
|
70
|
+
* a sort it doesn't offer)
|
|
71
|
+
* are ignored, never applied: a stale link shows the whole list, not an
|
|
72
|
+
* empty one.
|
|
73
|
+
*
|
|
74
|
+
* @param search - `location.search`.
|
|
75
|
+
* @param keys
|
|
76
|
+
* @param available - From `facets()`, with `bpm` as the slider's range
|
|
77
|
+
* (`bpmExtent()`).
|
|
78
|
+
* @param sorts - The sort orders offered.
|
|
79
|
+
* @returns A filter patch, and the sort (or null).
|
|
80
|
+
*/
|
|
81
|
+
export declare function readUrlState(search: string, keys: ReturnType<typeof urlKeys>, available: {
|
|
82
|
+
types: {
|
|
83
|
+
name: string;
|
|
84
|
+
}[];
|
|
85
|
+
keys: string[];
|
|
86
|
+
loops?: number;
|
|
87
|
+
oneShots?: number;
|
|
88
|
+
bpm?: {
|
|
89
|
+
min: number;
|
|
90
|
+
max: number;
|
|
91
|
+
} | null;
|
|
92
|
+
}, sorts: string[]): {
|
|
93
|
+
filter: Partial<SoundsFilter>;
|
|
94
|
+
sort: string | null;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* The URL with the filter written in. Empty values (and the starting sort)
|
|
98
|
+
* are removed rather than written empty; every other parameter and the
|
|
99
|
+
* hash are kept.
|
|
100
|
+
*
|
|
101
|
+
* @param href - `location.href`.
|
|
102
|
+
* @param keys
|
|
103
|
+
* @param filter
|
|
104
|
+
* @param sort
|
|
105
|
+
* @param defaultSort - The starting order (not written).
|
|
106
|
+
* @returns The new href (equal to `href` when nothing changed).
|
|
107
|
+
*/
|
|
108
|
+
export declare function writeUrlState(href: string, keys: ReturnType<typeof urlKeys>, filter: SoundsFilter, sort: string, defaultSort: string): string;
|
|
109
|
+
//# 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;;;;;;GAMG;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;;;;;;;GAOG;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,CAKvG;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,EAAE,MAAM,EAAE;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,GAAG,IAAI,GAAG;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,GAAG,IAAI,CAK1J;AAED;;;;;GAKG;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;;;;;;;;;;;;;;GAcG;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,CAAC;IAAC,GAAG,CAAC,EAAE;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAC,GAAG,IAAI,CAAA;CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG;IAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,GAAC,IAAI,CAAA;CAAC,CAmBpR;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,48 @@
|
|
|
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
|
+
* Is the page in forced colours (Windows High Contrast)? Then the canvas
|
|
28
|
+
* must draw in system colours too.
|
|
29
|
+
*/
|
|
30
|
+
export declare function forcedColors(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Every element above `el`, nearest first, crossing shadow-root boundaries
|
|
33
|
+
* (the elements whose class, style or theme attribute can change what the
|
|
34
|
+
* list inherits).
|
|
35
|
+
*
|
|
36
|
+
* @param el
|
|
37
|
+
*/
|
|
38
|
+
export declare function ancestorsOf(el: Element): Element[];
|
|
39
|
+
/**
|
|
40
|
+
* Resolve any CSS colour (a `var()`, `color-mix()`, `currentColor`) to a
|
|
41
|
+
* concrete value, as it would compute inside `container`.
|
|
42
|
+
*
|
|
43
|
+
* @param container
|
|
44
|
+
* @param value - A CSS colour expression.
|
|
45
|
+
* @returns The computed colour.
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveCssColor(container: Element, value: string): string;
|
|
48
|
+
//# 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;;;GAGG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAMtC;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,EAAE,CAIlD;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAUzE"}
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
*/
|
|
42
|
+
export declare function barRects(peaks: number[], width: number, height: number, o: {
|
|
43
|
+
style: 'mirror' | 'bars';
|
|
44
|
+
barWidth: number;
|
|
45
|
+
barGap: number;
|
|
46
|
+
}): {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
w: number;
|
|
50
|
+
h: number;
|
|
51
|
+
}[];
|
|
52
|
+
/**
|
|
53
|
+
* Draw a row waveform: every bar in the waveform colour, then the same
|
|
54
|
+
* bars again in the progress colour, CLIPPED at the playhead. The played
|
|
55
|
+
* part grows by the pixel — through the middle of a bar — rather than a
|
|
56
|
+
* whole bar at a time, which on a short clip stepped visibly (an 8-second
|
|
57
|
+
* loop across ~120 bars moved in ~15 jumps a second however fast it was
|
|
58
|
+
* redrawn).
|
|
59
|
+
*
|
|
60
|
+
* @param canvas
|
|
61
|
+
* @param peaks - 0..1. Null draws a flat placeholder line.
|
|
62
|
+
* @param progress - 0..1 played.
|
|
63
|
+
* @param o
|
|
64
|
+
*/
|
|
65
|
+
export declare function drawRowWaveform(canvas: HTMLCanvasElement, peaks: number[] | null, progress: number, o: {
|
|
66
|
+
style: 'mirror' | 'bars';
|
|
67
|
+
color: string;
|
|
68
|
+
progressColor: string;
|
|
69
|
+
barWidth: number;
|
|
70
|
+
barGap: number;
|
|
71
|
+
}): void;
|
|
72
|
+
//# 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;;;;;;;;;;;;GAYG;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,75 @@
|
|
|
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
|
+
*/
|
|
24
|
+
export declare function optionMatches(label: string, query: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Move an index by `delta`, clamped to `0..length-1`.
|
|
27
|
+
*
|
|
28
|
+
* @param current - -1 when nothing is active.
|
|
29
|
+
* @param delta
|
|
30
|
+
* @param length
|
|
31
|
+
*/
|
|
32
|
+
export declare function stepIndex(current: number, delta: number, length: number): number;
|
|
33
|
+
/**
|
|
34
|
+
* Every dropdown inside one list, with one shared "which is open" state.
|
|
35
|
+
*/
|
|
36
|
+
export declare class Menus {
|
|
37
|
+
/** Each menu's root element, by its `data-ws-menu` name. */
|
|
38
|
+
menus: Record<string, HTMLElement>;
|
|
39
|
+
/** The open menu's root element, if any. */
|
|
40
|
+
openMenu: HTMLElement | null;
|
|
41
|
+
/**
|
|
42
|
+
* @param {HTMLElement} container - The list's root element.
|
|
43
|
+
* @param {Object} opts
|
|
44
|
+
* @param {(name: string, value: string) => void} opts.onPick - A value was chosen.
|
|
45
|
+
* @param {AbortSignal} opts.signal - Removes every listener on abort.
|
|
46
|
+
*/
|
|
47
|
+
constructor(container: HTMLElement, { onPick, signal }: {
|
|
48
|
+
onPick: (name: string, value: string) => void;
|
|
49
|
+
signal: AbortSignal;
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Open a menu (closing any other), with the selected option active and
|
|
53
|
+
* focus in its search field or list. Flips to open over the end edge
|
|
54
|
+
* when it would overflow the list.
|
|
55
|
+
*
|
|
56
|
+
* @param menu
|
|
57
|
+
*/
|
|
58
|
+
open(menu: HTMLElement): void;
|
|
59
|
+
/**
|
|
60
|
+
* Close the open menu, if any.
|
|
61
|
+
*
|
|
62
|
+
* @param focusButton - Return focus to its button (after a
|
|
63
|
+
* pick or Esc; not after a click elsewhere).
|
|
64
|
+
*/
|
|
65
|
+
close(focusButton: boolean): void;
|
|
66
|
+
/**
|
|
67
|
+
* Show `value` as a menu's choice (button text + `aria-selected`). Used
|
|
68
|
+
* after a pick and when the filter is changed from code.
|
|
69
|
+
*
|
|
70
|
+
* @param name - 'type' | 'key' | 'sort'.
|
|
71
|
+
* @param value
|
|
72
|
+
*/
|
|
73
|
+
setValue(name: string, value: string): void;
|
|
74
|
+
}
|
|
75
|
+
//# 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;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAGnE;AAED;;;;;;GAMG;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"}
|