@arraypress/waveform-sounds 0.3.1 → 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 +121 -97
- package/dist/waveform-sounds-render.esm.js +24 -10
- package/dist/waveform-sounds.css +62 -76
- package/dist/waveform-sounds.esm.js +122 -98
- package/dist/waveform-sounds.js +123 -98
- 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 +62 -76
- package/src/js/core/{WaveformSounds.js → WaveformSounds.ts} +301 -191
- 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} +62 -61
- 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 -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/engine.js +0 -57
- /package/src/js/{index.js → index.ts} +0 -0
package/no-autoinit.d.ts
DELETED
package/render.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** DOM-free server renderer: `@arraypress/waveform-sounds/render`. */
|
|
2
|
-
/** Escape a string for HTML text or a double-quoted attribute value. */
|
|
3
|
-
export declare function escapeHtml(value: unknown): string;
|
|
4
|
-
export {renderSounds, renderSoundsElement, DEFAULT_STRINGS, normalizeSounds, parseManifest, encodePeaks, decodePeaks, normalizeKey, facets, formatDuration} from './index.js';
|
|
5
|
-
export type {SoundInput, Sound, SoundsManifest, WaveformSoundsOptions, WaveformSoundsStrings} from './index.js';
|
package/src/js/core/engine.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The audio engine: ONE `WaveformPlayer` (self mode) that every sound in
|
|
3
|
-
* the list plays through. These helpers decide how it's configured and
|
|
4
|
-
* what it's given per sound; `WaveformSounds.js` owns its lifecycle.
|
|
5
|
-
*
|
|
6
|
-
* @module engine
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/** The engine's own callbacks, which the list must always receive. */
|
|
10
|
-
const CALLBACKS = ['onLoad', 'onPlay', 'onPause', 'onEnd', 'onTimeUpdate', 'onError'];
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The engine player's options. The site's `playerOptions` override the
|
|
14
|
-
* defaults, except two things the list depends on:
|
|
15
|
-
* - `audioMode` is always `'self'` (the list owns its audio);
|
|
16
|
-
* - the six callbacks always reach the list — a site's own callback of
|
|
17
|
-
* the same name runs as well, after it, with the same arguments.
|
|
18
|
-
*
|
|
19
|
-
* @param {Object|null|undefined} user - The site's `playerOptions`.
|
|
20
|
-
* @param {'inline'|'strip'} layout - Strip shows the engine, so it's taller.
|
|
21
|
-
* @param {Record<string, Function>} handlers - The list's callbacks, keyed by
|
|
22
|
-
* option name (`onPlay`, …).
|
|
23
|
-
* @returns {Object} Options for `new WaveformPlayer(el, options)`.
|
|
24
|
-
*/
|
|
25
|
-
export function engineOptions(user, layout, handlers) {
|
|
26
|
-
const site = user || {};
|
|
27
|
-
const strip = layout === 'strip';
|
|
28
|
-
const options = {
|
|
29
|
-
height: strip ? 48 : 32,
|
|
30
|
-
waveformStyle: strip ? 'mirror' : 'bars',
|
|
31
|
-
preload: 'metadata',
|
|
32
|
-
singlePlay: true,
|
|
33
|
-
...site,
|
|
34
|
-
audioMode: 'self',
|
|
35
|
-
};
|
|
36
|
-
for (const name of CALLBACKS) {
|
|
37
|
-
options[name] = (...args) => {
|
|
38
|
-
handlers[name]?.(...args);
|
|
39
|
-
if (typeof site[name] === 'function') site[name](...args);
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return options;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* The waveform data to hand the engine for a sound: in the strip a
|
|
47
|
-
* full-resolution sidecar when there is one, otherwise the row's peaks.
|
|
48
|
-
* Supplied peaks also stop a hidden engine from downloading and decoding
|
|
49
|
-
* the whole file just to draw it.
|
|
50
|
-
*
|
|
51
|
-
* @param {{peaks: number[]|null, waveform: string|null}} sound
|
|
52
|
-
* @param {'inline'|'strip'} layout
|
|
53
|
-
* @returns {number[]|string|null}
|
|
54
|
-
*/
|
|
55
|
-
export function enginePeaks(sound, layout) {
|
|
56
|
-
return (layout === 'strip' && sound.waveform) || sound.peaks || null;
|
|
57
|
-
}
|
|
File without changes
|