@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
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The public data, option and event types of WaveformSounds. Moved here from
|
|
3
|
+
* the hand-written index.d.ts so the source uses the same definitions the
|
|
4
|
+
* published types are generated from.
|
|
3
5
|
*
|
|
4
6
|
* The four `waveform-sounds-*` wrappers derive their prop types from
|
|
5
|
-
* `WaveformSoundsOptions` here. Add or rename an option in `
|
|
7
|
+
* `WaveformSoundsOptions` here. Add or rename an option in `core/options.ts`
|
|
6
8
|
* (`DEFAULT_OPTIONS`) and in this file in the same change.
|
|
9
|
+
*
|
|
10
|
+
* @module types
|
|
7
11
|
*/
|
|
8
12
|
|
|
13
|
+
import type {WaveformSounds} from './core/WaveformSounds.js';
|
|
14
|
+
|
|
9
15
|
/** One sound, as given (a manifest entry, a `sounds` item). */
|
|
10
16
|
export interface SoundInput {
|
|
11
17
|
/** Audio URL. Required. */
|
|
@@ -37,8 +43,9 @@ export interface SoundInput {
|
|
|
37
43
|
/** A loop (`true`) rather than a one-shot (the default). Loops get a
|
|
38
44
|
* loop icon beside their name, the "Loops / One-shots" filter appears
|
|
39
45
|
* once a list has both, and with any sound marked the Loop toggle
|
|
40
|
-
* repeats only loops.
|
|
41
|
-
|
|
46
|
+
* repeats only loops. As data writes it, `'true'` / `'1'` / `1` also
|
|
47
|
+
* mean a loop; anything else is a one-shot. */
|
|
48
|
+
loop?: boolean | 'true' | 'false' | '1' | '0' | 1 | 0;
|
|
42
49
|
/** Stable id for `play('id')`. Defaults to `sound-<n>`, 1-based
|
|
43
50
|
* (`sound-1` is the first sound). */
|
|
44
51
|
id?: string;
|
|
@@ -123,6 +130,9 @@ export interface WaveformSoundsStrings {
|
|
|
123
130
|
play: string;
|
|
124
131
|
pause: string;
|
|
125
132
|
seek: string;
|
|
133
|
+
/** The playing row's seek slider, read out: `{time}`, `{duration}`
|
|
134
|
+
* ("0:12 of 0:30"). Since 2.1.0. */
|
|
135
|
+
seekValue: string;
|
|
126
136
|
download: string;
|
|
127
137
|
count: string;
|
|
128
138
|
countOne: string;
|
|
@@ -131,6 +141,13 @@ export interface WaveformSoundsStrings {
|
|
|
131
141
|
empty: string;
|
|
132
142
|
clear: string;
|
|
133
143
|
nowPlaying: string;
|
|
144
|
+
/** Announced when a sound fails to load or play. Since 2.1.0. */
|
|
145
|
+
playError: string;
|
|
146
|
+
/** Shown in place of the list when it can't be built (the manifest
|
|
147
|
+
* fails to load or isn't a manifest). Since 2.1.0. */
|
|
148
|
+
loadError: string;
|
|
149
|
+
/** The empty state of a list with no sounds at all. Since 2.1.0. */
|
|
150
|
+
noSounds: string;
|
|
134
151
|
}
|
|
135
152
|
|
|
136
153
|
export interface WaveformSoundsOptions {
|
|
@@ -201,7 +218,10 @@ export interface WaveformSoundsOptions {
|
|
|
201
218
|
arrowAudition?: boolean;
|
|
202
219
|
/** Options for the engine `WaveformPlayer` (colours, height, … — and its
|
|
203
220
|
* callbacks, which are called alongside the list's own). `audioMode` is
|
|
204
|
-
* always `'self'
|
|
221
|
+
* always `'self'`; `loop` and `showLoop` are always off (the list's Loop
|
|
222
|
+
* toggle owns looping); `duration`, `downloadUrl` and `downloadName` are
|
|
223
|
+
* ignored (each sound brings its own). As markup: `data-player-options`
|
|
224
|
+
* (JSON). */
|
|
205
225
|
playerOptions?: Record<string, unknown> | null;
|
|
206
226
|
/** The `WaveformPlayer` class, for ESM setups without the global. */
|
|
207
227
|
playerClass?: unknown;
|
|
@@ -217,7 +237,10 @@ export interface WaveformSoundsOptions {
|
|
|
217
237
|
onError?: ((error: unknown, instance: WaveformSounds) => void) | null;
|
|
218
238
|
}
|
|
219
239
|
|
|
220
|
-
/** `detail` of the `waveformsounds:*` DOM events
|
|
240
|
+
/** `detail` of the `waveformsounds:*` DOM events. All bubble and are
|
|
241
|
+
* composed (they leave a shadow root); merged into `HTMLElementEventMap`,
|
|
242
|
+
* `DocumentEventMap` and `WindowEventMap`, so `addEventListener` on an
|
|
243
|
+
* element, `document` or `window` is typed. */
|
|
221
244
|
export interface WaveformSoundsEventMap {
|
|
222
245
|
'waveformsounds:ready': CustomEvent<{sounds: number; instance: WaveformSounds}>;
|
|
223
246
|
'waveformsounds:play': CustomEvent<{sound: Sound; index: number; instance: WaveformSounds}>;
|
|
@@ -227,86 +250,15 @@ export interface WaveformSoundsEventMap {
|
|
|
227
250
|
'waveformsounds:error': CustomEvent<{error: unknown; sound?: Sound; index?: number; instance: WaveformSounds}>;
|
|
228
251
|
}
|
|
229
252
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
readonly ready: Promise<void>;
|
|
242
|
-
readonly sounds: Sound[];
|
|
243
|
-
readonly filter: SoundsFilter;
|
|
244
|
-
readonly sortBy: SoundsSort;
|
|
245
|
-
readonly playing: boolean;
|
|
246
|
-
/** The engine `WaveformPlayer`, created on first play. */
|
|
247
|
-
readonly engine: unknown;
|
|
248
|
-
/** The sounds passing the filter, in sort order. */
|
|
249
|
-
readonly visible: Sound[];
|
|
250
|
-
/** The current (playing or paused) sound. */
|
|
251
|
-
readonly current: Sound | null;
|
|
252
|
-
|
|
253
|
-
play(target?: number | string | Sound, opts?: {at?: number}): void;
|
|
254
|
-
pause(): void;
|
|
255
|
-
toggle(target?: number | string | Sound): void;
|
|
256
|
-
next(): void;
|
|
257
|
-
previous(): void;
|
|
258
|
-
setLoop(on: boolean): void;
|
|
259
|
-
setFilter(patch: Partial<SoundsFilter>): void;
|
|
260
|
-
clearFilters(): void;
|
|
261
|
-
setSort(by: SoundsSort): void;
|
|
262
|
-
showMore(): void;
|
|
263
|
-
/** Tear down listeners, observers and the engine. Markup the instance
|
|
264
|
-
* rendered is restored; ADOPTED server markup is left as it is (rows may
|
|
265
|
-
* be re-sorted/hidden) — re-render it before building a new instance. */
|
|
266
|
-
destroy(): void;
|
|
267
|
-
|
|
268
|
-
static instances: Map<Element, WaveformSounds>;
|
|
269
|
-
static init(root?: ParentNode): WaveformSounds[];
|
|
270
|
-
static getInstance(el: Element | string): WaveformSounds | null;
|
|
271
|
-
/** Destroy instances whose element has left the document. */
|
|
272
|
-
static prune(): void;
|
|
273
|
-
static DEFAULT_OPTIONS: WaveformSoundsOptions;
|
|
274
|
-
static DEFAULT_STRINGS: WaveformSoundsStrings;
|
|
275
|
-
static utils: {
|
|
276
|
-
encodePeaks: typeof encodePeaks;
|
|
277
|
-
decodePeaks: typeof decodePeaks;
|
|
278
|
-
normalizeKey: typeof normalizeKey;
|
|
279
|
-
normalizeSounds: typeof normalizeSounds;
|
|
280
|
-
parseManifest: typeof parseManifest;
|
|
281
|
-
facets: typeof facets;
|
|
282
|
-
matches: typeof matches;
|
|
283
|
-
sortSounds: typeof sortSounds;
|
|
284
|
-
formatDuration: typeof formatDuration;
|
|
285
|
-
renderSounds: typeof renderSounds;
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
export declare const DEFAULT_OPTIONS: WaveformSoundsOptions;
|
|
290
|
-
export declare const DEFAULT_STRINGS: WaveformSoundsStrings;
|
|
291
|
-
export declare function encodePeaks(peaks: number[]): string;
|
|
292
|
-
export declare function decodePeaks(value: string | number[] | null | undefined, scale?: number): number[] | null;
|
|
293
|
-
export declare function normalizeKey(key: string | null | undefined): string;
|
|
294
|
-
export declare function normalizeSounds(list: SoundInput[], peakScale?: number): Sound[];
|
|
295
|
-
export declare function parseManifest(manifest: SoundsManifest | SoundInput[]): Sound[];
|
|
296
|
-
export declare function facets(sounds: Sound[]): {types: {name: string; count: number}[]; keys: string[]; bpm: {min: number; max: number} | null; hasDuration: boolean; loops: number; oneShots: number};
|
|
297
|
-
export declare function matches(sound: Sound, filter?: Partial<SoundsFilter>): boolean;
|
|
298
|
-
export declare function sortSounds(sounds: Sound[], by?: SoundsSort): Sound[];
|
|
299
|
-
export declare function formatDuration(seconds: number | null | undefined): string;
|
|
300
|
-
/** The component's inner markup, for server rendering (also exported, DOM-free, from `@arraypress/waveform-sounds/render`). */
|
|
301
|
-
export declare function renderSounds(sounds: SoundInput[], options?: WaveformSoundsOptions): string;
|
|
302
|
-
/** The whole element (wrapper div included). */
|
|
303
|
-
export declare function renderSoundsElement(sounds: SoundInput[], options?: WaveformSoundsOptions, className?: string): string;
|
|
304
|
-
|
|
305
|
-
export default WaveformSounds;
|
|
306
|
-
|
|
307
|
-
declare global {
|
|
308
|
-
interface Window {
|
|
309
|
-
WaveformSounds: typeof WaveformSounds;
|
|
310
|
-
}
|
|
311
|
-
interface HTMLElementEventMap extends WaveformSoundsEventMap {}
|
|
253
|
+
/** The plain events a {@link WaveformSounds} dispatches on itself — it is an
|
|
254
|
+
* `EventTarget`, so `list.addEventListener('play', …)` works and is typed.
|
|
255
|
+
* Each mirrors a `waveformsounds:*` container event (whose `detail`
|
|
256
|
+
* carries the data); the matching `on*` callback still runs. Since 2.1.0. */
|
|
257
|
+
export interface WaveformSoundsInstanceEventMap {
|
|
258
|
+
ready: Event;
|
|
259
|
+
play: Event;
|
|
260
|
+
pause: Event;
|
|
261
|
+
end: Event;
|
|
262
|
+
filter: Event;
|
|
263
|
+
error: Event;
|
|
312
264
|
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WaveformSounds — a searchable, filterable list of sounds for showcasing
|
|
3
|
+
* the previews inside a sample pack, preset bank or sound library.
|
|
4
|
+
*
|
|
5
|
+
* One `WaveformPlayer` (self mode) is the audio engine for the whole list:
|
|
6
|
+
* every sound plays through it, so it brings the player's seeking (incl.
|
|
7
|
+
* hosts that ignore byte ranges), error handling, Media Session card and
|
|
8
|
+
* hand-off with every other player on the page. The rows are light: a
|
|
9
|
+
* button, some text and, in the `inline` layout, a small canvas drawn from
|
|
10
|
+
* low-resolution peaks only when it scrolls into view. 300 sounds is 300
|
|
11
|
+
* rows, not 300 players.
|
|
12
|
+
*
|
|
13
|
+
* Layouts (`player`):
|
|
14
|
+
* - `'inline'` (default): every row has a mini waveform; the playing row
|
|
15
|
+
* fills with progress and is click-to-seek. The engine is hidden.
|
|
16
|
+
* - `'strip'`: plain rows; the engine is shown docked under the list as a
|
|
17
|
+
* full player for the current sound.
|
|
18
|
+
*
|
|
19
|
+
* This class orchestrates; the pieces live by layer:
|
|
20
|
+
* - `core/` — this class, the engine's configuration, the option surface
|
|
21
|
+
* - `data/` — pure logic: sounds, filtering, the address, navigation
|
|
22
|
+
* - `render/` — server-safe markup (also the `/render` entry)
|
|
23
|
+
* - `dom/` — browser-only behaviour: dropdowns, rows, canvas, colours
|
|
24
|
+
* - `shared/` — small helpers
|
|
25
|
+
*
|
|
26
|
+
* @module core
|
|
27
|
+
*/
|
|
28
|
+
import { facets, formatDuration, matches, normalizeSounds, parseManifest, sortSounds } from '../data/sounds.js';
|
|
29
|
+
import { DEFAULT_OPTIONS } from './options.js';
|
|
30
|
+
import { renderSounds } from '../render/markup.js';
|
|
31
|
+
import type { decodePeaks, encodePeaks, normalizeKey } from '../data/sounds.js';
|
|
32
|
+
import type { WaveformPlayer } from '@arraypress/waveform-player';
|
|
33
|
+
import type { Sound, SoundsFilter, SoundsSort, WaveformSoundsInstanceEventMap, WaveformSoundsOptions, WaveformSoundsStrings } from '../types.js';
|
|
34
|
+
export { DEFAULT_OPTIONS };
|
|
35
|
+
/**
|
|
36
|
+
* Typed listeners for the events a list dispatches on itself (see
|
|
37
|
+
* {@link WaveformSoundsInstanceEventMap}). Types only: merged into the class
|
|
38
|
+
* below, it emits nothing.
|
|
39
|
+
*/
|
|
40
|
+
export interface WaveformSounds {
|
|
41
|
+
addEventListener<K extends keyof WaveformSoundsInstanceEventMap>(type: K, listener: (this: WaveformSounds, ev: WaveformSoundsInstanceEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
42
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void;
|
|
43
|
+
removeEventListener<K extends keyof WaveformSoundsInstanceEventMap>(type: K, listener: (this: WaveformSounds, ev: WaveformSoundsInstanceEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
44
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* An `EventTarget`, like the core's player: each moment is dispatched on the
|
|
48
|
+
* instance as a plain event (`ready`, `play`, `pause`, `end`, `filter`,
|
|
49
|
+
* `error`), and on the container as a bubbling, composed
|
|
50
|
+
* `waveformsounds:<name>` CustomEvent carrying the details.
|
|
51
|
+
*/
|
|
52
|
+
export declare class WaveformSounds extends EventTarget {
|
|
53
|
+
/** Every live instance, by its element. */
|
|
54
|
+
static instances: Map<Element, WaveformSounds>;
|
|
55
|
+
/** The pure helpers, for `<script>` users (attached in `entry.ts`). */
|
|
56
|
+
static utils: {
|
|
57
|
+
encodePeaks: typeof encodePeaks;
|
|
58
|
+
decodePeaks: typeof decodePeaks;
|
|
59
|
+
normalizeKey: typeof normalizeKey;
|
|
60
|
+
normalizeSounds: typeof normalizeSounds;
|
|
61
|
+
parseManifest: typeof parseManifest;
|
|
62
|
+
facets: typeof facets;
|
|
63
|
+
matches: typeof matches;
|
|
64
|
+
sortSounds: typeof sortSounds;
|
|
65
|
+
formatDuration: typeof formatDuration;
|
|
66
|
+
renderSounds: typeof renderSounds;
|
|
67
|
+
};
|
|
68
|
+
/** Register the `<waveform-sounds>` element (default tag name
|
|
69
|
+
* `waveform-sounds`). The default entry does this on import; this
|
|
70
|
+
* reaches it from a `<script>` page that opted out of auto-init.
|
|
71
|
+
* Attached in `entry.ts`. Since 2.1.0. */
|
|
72
|
+
static defineElement: (name?: string) => CustomElementConstructor | undefined;
|
|
73
|
+
/** Every option with its default (attached in `entry.ts`). */
|
|
74
|
+
static DEFAULT_OPTIONS: WaveformSoundsOptions;
|
|
75
|
+
/** The English UI strings (attached in `entry.ts`). */
|
|
76
|
+
static DEFAULT_STRINGS: WaveformSoundsStrings;
|
|
77
|
+
readonly container: HTMLElement;
|
|
78
|
+
readonly options: Required<WaveformSoundsOptions>;
|
|
79
|
+
/** Resolves once the list is built (after a manifest fetch, if any).
|
|
80
|
+
* The build always happens after the constructor returns, so listeners
|
|
81
|
+
* attached straight after `new WaveformSounds()` see `ready`. It never
|
|
82
|
+
* rejects: a failed build (e.g. the manifest 404s) resolves it too and
|
|
83
|
+
* is reported through `onError` / `waveformsounds:error`. Calls made
|
|
84
|
+
* before it resolves are honoured: `setFilter`/`setSort` show in the
|
|
85
|
+
* controls once built, and `play()` waits for the list. */
|
|
86
|
+
readonly ready: Promise<void>;
|
|
87
|
+
readonly sounds: Sound[];
|
|
88
|
+
readonly filter: SoundsFilter;
|
|
89
|
+
readonly sortBy: SoundsSort;
|
|
90
|
+
readonly playing: boolean;
|
|
91
|
+
/** The engine `WaveformPlayer`: built when the list is ready if the
|
|
92
|
+
* player is on the page (else on first play), null before and after. */
|
|
93
|
+
readonly engine: WaveformPlayer | null;
|
|
94
|
+
/**
|
|
95
|
+
* @param {HTMLElement|string} container - The element (or a selector).
|
|
96
|
+
* @param {WaveformSoundsOptions} [options]
|
|
97
|
+
*/
|
|
98
|
+
constructor(container: HTMLElement | string, options?: WaveformSoundsOptions);
|
|
99
|
+
/** The sounds that pass the filter, in the current sort order. */
|
|
100
|
+
get visible(): Sound[];
|
|
101
|
+
/**
|
|
102
|
+
* Change the filter (merged into the current one) and re-apply. Back to
|
|
103
|
+
* the first page.
|
|
104
|
+
*
|
|
105
|
+
* @param patch
|
|
106
|
+
*/
|
|
107
|
+
setFilter(patch: Partial<SoundsFilter>): void;
|
|
108
|
+
/** Reset every filter (the sort stays). */
|
|
109
|
+
clearFilters(): void;
|
|
110
|
+
/** @param by */
|
|
111
|
+
setSort(by: SoundsSort): void;
|
|
112
|
+
/** Reveal the next page of results. */
|
|
113
|
+
showMore(): void;
|
|
114
|
+
/**
|
|
115
|
+
* Play a sound (by index, id or sound object), or resume the current
|
|
116
|
+
* one. Before the list is built the call waits for it.
|
|
117
|
+
*
|
|
118
|
+
* @param target
|
|
119
|
+
* @param opts - `at`: start position 0..1.
|
|
120
|
+
*/
|
|
121
|
+
play(target?: number | string | Sound, opts?: {
|
|
122
|
+
at?: number;
|
|
123
|
+
}): void;
|
|
124
|
+
/** Pause the current sound. */
|
|
125
|
+
pause(): void;
|
|
126
|
+
/**
|
|
127
|
+
* The current sound plays/pauses; another sound starts.
|
|
128
|
+
* @param target
|
|
129
|
+
*/
|
|
130
|
+
toggle(target?: number | string | Sound): void;
|
|
131
|
+
/** Play the next visible sound (no wrap at the end). */
|
|
132
|
+
next(): void;
|
|
133
|
+
/** Play the previous visible sound. */
|
|
134
|
+
previous(): void;
|
|
135
|
+
/**
|
|
136
|
+
* Loop the current sound (auditioning a loop is the common case). When
|
|
137
|
+
* the list marks its loops (`loop: true` on any sound), only those
|
|
138
|
+
* repeat: a one-shot always plays once.
|
|
139
|
+
* @param on
|
|
140
|
+
*/
|
|
141
|
+
setLoop(on: boolean): void;
|
|
142
|
+
/** The sound playing (or paused) now, or null. */
|
|
143
|
+
get current(): Sound | null;
|
|
144
|
+
/**
|
|
145
|
+
* Tear down: listeners, observers, timers and the engine. Markup this
|
|
146
|
+
* instance rendered is restored to what the container held before.
|
|
147
|
+
* ADOPTED (server-rendered) markup is left as it is now — rows may be
|
|
148
|
+
* re-sorted, hidden or marked current — unless `restore` is set: then it
|
|
149
|
+
* is put back exactly as the server sent it, ready for a new instance
|
|
150
|
+
* (what a framework re-mounting the same markup wants).
|
|
151
|
+
*
|
|
152
|
+
* @param options
|
|
153
|
+
* @param options.restore - Put adopted server markup back as it was.
|
|
154
|
+
* Default false. Since 2.1.0.
|
|
155
|
+
*/
|
|
156
|
+
destroy(options?: {
|
|
157
|
+
restore?: boolean;
|
|
158
|
+
}): void;
|
|
159
|
+
/**
|
|
160
|
+
* Initialise every `[data-waveform-sounds]` under `root` that isn't yet.
|
|
161
|
+
*
|
|
162
|
+
* @param root
|
|
163
|
+
* @returns The new instances.
|
|
164
|
+
*/
|
|
165
|
+
static init(root?: ParentNode): WaveformSounds[];
|
|
166
|
+
/**
|
|
167
|
+
* The instance on an element (or selector), if any.
|
|
168
|
+
* @param el
|
|
169
|
+
*/
|
|
170
|
+
static getInstance(el: Element | string): WaveformSounds | null;
|
|
171
|
+
/** Destroy instances whose element has left the document (after a
|
|
172
|
+
* client-side navigation). */
|
|
173
|
+
static prune(): void;
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=WaveformSounds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WaveformSounds.d.ts","sourceRoot":"","sources":["../../src/js/core/WaveformSounds.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `<waveform-sounds>` custom element, modelled on the core's
|
|
3
|
+
* `<waveform-player>`.
|
|
4
|
+
*
|
|
5
|
+
* A light-DOM wrapper: the element itself is the list's container, so the
|
|
6
|
+
* stylesheet applies as it does to `[data-waveform-sounds]`, server-rendered
|
|
7
|
+
* markup inside it (`renderSounds()` output) is ADOPTED exactly as it is
|
|
8
|
+
* there, and `waveformsounds:*` events bubble from the tag. Configured by
|
|
9
|
+
* attributes — every `data-*` option the list reads, with or without the
|
|
10
|
+
* `data-` prefix (`manifest`, `page-size`, `player`, …), the unprefixed form
|
|
11
|
+
* winning.
|
|
12
|
+
*
|
|
13
|
+
* The default entry registers it (behind the same opt-out as the scan);
|
|
14
|
+
* `/no-autoinit` exports {@link defineWaveformSoundsElement}, and
|
|
15
|
+
* `WaveformSounds.defineElement()` reaches it from a `<script>` page.
|
|
16
|
+
*
|
|
17
|
+
* @module element
|
|
18
|
+
*/
|
|
19
|
+
import { WaveformSounds } from './WaveformSounds.js';
|
|
20
|
+
declare global {
|
|
21
|
+
interface HTMLElementTagNameMap {
|
|
22
|
+
'waveform-sounds': WaveformSoundsElement;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Every `data-*` key `readDataOptions` reads, as its `dataset` name. The
|
|
27
|
+
* element accepts each as `data-<kebab>` and as plain `<kebab>`.
|
|
28
|
+
* `test/runtime/element.test.js` fails if this list and `readDataOptions`
|
|
29
|
+
* drift apart.
|
|
30
|
+
*/
|
|
31
|
+
export declare const ELEMENT_OPTION_KEYS: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Read the element's options: each key from its plain attribute, else its
|
|
34
|
+
* `data-` one, through the same `readDataOptions` the `data-*` contract uses
|
|
35
|
+
* (so a bare boolean attribute — `<waveform-sounds auto-advance>` — is true,
|
|
36
|
+
* as `data-auto-advance` is).
|
|
37
|
+
*
|
|
38
|
+
* @param el
|
|
39
|
+
* @returns Sparse options.
|
|
40
|
+
*/
|
|
41
|
+
export declare function readElementOptions(el: Element): Record<string, any>;
|
|
42
|
+
declare const Base: typeof HTMLElement;
|
|
43
|
+
/**
|
|
44
|
+
* `<waveform-sounds manifest="/previews/sounds.json" page-size="20">`.
|
|
45
|
+
*
|
|
46
|
+
* - `connectedCallback` builds the list in the element (adopting
|
|
47
|
+
* server-rendered markup inside it); `disconnectedCallback` destroys it —
|
|
48
|
+
* putting adopted markup back as the server sent it — unless the element
|
|
49
|
+
* is put back before the current task ends (a move keeps the list, and
|
|
50
|
+
* its playback).
|
|
51
|
+
* - Changing an option attribute (either form) rebuilds the list once per
|
|
52
|
+
* task, from the sounds it holds (or from the new `manifest`).
|
|
53
|
+
* - {@link WaveformSoundsElement.sounds} is the `WaveformSounds` instance.
|
|
54
|
+
*/
|
|
55
|
+
export declare class WaveformSoundsElement extends Base {
|
|
56
|
+
/** The list inside this element, or `null` while disconnected. */
|
|
57
|
+
sounds: WaveformSounds | null;
|
|
58
|
+
/** Every option attribute, plain and `data-` prefixed. */
|
|
59
|
+
static get observedAttributes(): string[];
|
|
60
|
+
/** Build the list (or keep it, after a move). */
|
|
61
|
+
connectedCallback(): void;
|
|
62
|
+
/** Destroy the list, unless the element comes straight back (a move). */
|
|
63
|
+
disconnectedCallback(): void;
|
|
64
|
+
/**
|
|
65
|
+
* An option attribute changed: rebuild once the task's changes are in.
|
|
66
|
+
*
|
|
67
|
+
* @param name
|
|
68
|
+
* @param previous
|
|
69
|
+
* @param value
|
|
70
|
+
*/
|
|
71
|
+
attributeChangedCallback(name: string, previous: string | null, value: string | null): void;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Register the `<waveform-sounds>` element (or the same element under
|
|
75
|
+
* another name). The default entry does this on import; `/no-autoinit`
|
|
76
|
+
* leaves it to you (`WaveformSounds.defineElement()` from a `<script>` page).
|
|
77
|
+
* A name that is already defined is left alone.
|
|
78
|
+
*
|
|
79
|
+
* @param name - Tag name; must contain a hyphen.
|
|
80
|
+
* @returns The registered constructor, or `undefined` outside a browser.
|
|
81
|
+
*/
|
|
82
|
+
export declare function defineWaveformSoundsElement(name?: string): CustomElementConstructor | undefined;
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=element.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../src/js/core/element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAKnD,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,iBAAiB,EAAE,qBAAqB,CAAC;KAC5C;CACJ;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,UAI/B,CAAC;AASF;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAQnE;AAKD,QAAA,MAAM,IAAI,EAAoE,OAAO,WAAW,CAAC;AAEjG;;;;;;;;;;;GAWG;AACH,qBAAa,qBAAsB,SAAQ,IAAI;IAC3C,kEAAkE;IAC1D,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAItC,0DAA0D;IAC1D,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,iDAAiD;IACjD,iBAAiB,IAAI,IAAI,CAOxB;IAED,yEAAyE;IACzE,oBAAoB,IAAI,IAAI,CAM3B;IAED;;;;;;OAMG;IACH,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAe1F;CAkDJ;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,GAAE,MAA0B,GAAG,wBAAwB,GAAG,SAAS,CASlH"}
|
|
@@ -0,0 +1,72 @@
|
|
|
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 player's options. The site's `playerOptions` override the
|
|
10
|
+
* defaults, except what the list depends on:
|
|
11
|
+
* - `audioMode` is always `'self'` (the list owns its audio);
|
|
12
|
+
* - `loop` and `showLoop` are always off: the list owns looping (its Loop
|
|
13
|
+
* toggle, which repeats only the sounds marked as loops). The player's
|
|
14
|
+
* own loop would stop `ended`, so `autoAdvance` and the row state would
|
|
15
|
+
* stall, and its toggle would loop one-shots behind the list's back;
|
|
16
|
+
* - the per-track options (`duration`, `downloadUrl`, `downloadName`) are
|
|
17
|
+
* dropped: each sound's come with it (see {@link engineTrack});
|
|
18
|
+
* - the six callbacks always reach the list — a site's own callback of
|
|
19
|
+
* the same name runs as well, after it, with the same arguments.
|
|
20
|
+
*
|
|
21
|
+
* @param user - The site's `playerOptions`.
|
|
22
|
+
* @param layout - Strip shows the engine, so it's taller.
|
|
23
|
+
* @param handlers - The list's callbacks, keyed by
|
|
24
|
+
* option name (`onPlay`, …).
|
|
25
|
+
* @returns Options for `new WaveformPlayer(el, options)`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function engineOptions(user: Record<string, any> | null | undefined, layout: 'inline' | 'strip', handlers: Record<string, (...args: any[]) => void>): Record<string, any>;
|
|
28
|
+
/**
|
|
29
|
+
* The waveform data to hand the engine for a sound: in the strip a
|
|
30
|
+
* full-resolution sidecar when there is one, otherwise the row's peaks.
|
|
31
|
+
* Supplied peaks also stop a hidden engine from downloading and decoding
|
|
32
|
+
* the whole file just to draw it.
|
|
33
|
+
*
|
|
34
|
+
* @param sound
|
|
35
|
+
* @param layout
|
|
36
|
+
*/
|
|
37
|
+
export declare function enginePeaks(sound: {
|
|
38
|
+
peaks: number[] | null;
|
|
39
|
+
waveform: string | null;
|
|
40
|
+
}, layout: 'inline' | 'strip'): number[] | string | null;
|
|
41
|
+
/** What `loadTrack()` is given for one sound (see {@link engineTrack}). */
|
|
42
|
+
export interface EngineTrack {
|
|
43
|
+
waveform: number[] | string | null;
|
|
44
|
+
autoplay: boolean;
|
|
45
|
+
duration?: number;
|
|
46
|
+
downloadUrl?: string;
|
|
47
|
+
preload?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The `loadTrack()` options for a sound: its peaks (see {@link enginePeaks}),
|
|
51
|
+
* its known length — so the player shows the right total, places a seek and
|
|
52
|
+
* fills the Media Session scrubber before the audio's metadata arrives,
|
|
53
|
+
* which with `preload: 'none'` is only once it plays — and its download
|
|
54
|
+
* link, so a `showDownload` engine offers what the row offers.
|
|
55
|
+
*
|
|
56
|
+
* `preload` is given every time because the core keeps the last one: the
|
|
57
|
+
* strip CUES its first sound with `'none'` (it shows the title, length and
|
|
58
|
+
* peaks from the data, and fetches nothing until it plays), and the next
|
|
59
|
+
* sound played must get the engine's own preload back.
|
|
60
|
+
*
|
|
61
|
+
* @param sound
|
|
62
|
+
* @param layout
|
|
63
|
+
* @param autoplay - Start once loaded (false: cue only).
|
|
64
|
+
* @param preload - The media element's `preload` for this sound.
|
|
65
|
+
*/
|
|
66
|
+
export declare function engineTrack(sound: {
|
|
67
|
+
peaks: number[] | null;
|
|
68
|
+
waveform: string | null;
|
|
69
|
+
duration: number | null;
|
|
70
|
+
download: string | null;
|
|
71
|
+
}, layout: 'inline' | 'strip', autoplay: boolean, preload?: string): EngineTrack;
|
|
72
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/js/core/engine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAaH;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAqB/K;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE;IAAC,KAAK,EAAE,MAAM,EAAE,GAAC,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAC,IAAI,CAAA;CAAC,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAEtI;AAED,2EAA2E;AAC3E,MAAM,WAAW,WAAW;IACxB,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE;IAAC,KAAK,EAAE,MAAM,EAAE,GAAC,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAC,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAC,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAC,IAAI,CAAA;CAAC,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAM5M"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The runtime's option surface: every option with its default, the
|
|
3
|
+
* `data-*` form a container (or a server-rendering wrapper) uses, and the
|
|
4
|
+
* merge that resolves them. The options that shape the markup are defined
|
|
5
|
+
* with the renderer (`render/options.ts`) and included here. `types.ts`
|
|
6
|
+
* documents each option; the wrappers' drift guards compare their
|
|
7
|
+
* forwarding against `WaveformSoundsOptions` (in the generated
|
|
8
|
+
* `types/types.d.ts`).
|
|
9
|
+
*
|
|
10
|
+
* Precedence, as across the waveform family: data-* > constructor > default.
|
|
11
|
+
*
|
|
12
|
+
* @module options
|
|
13
|
+
*/
|
|
14
|
+
import { RENDER_DEFAULTS } from '../render/options.js';
|
|
15
|
+
import type { WaveformSoundsOptions } from '../types.js';
|
|
16
|
+
export { RENDER_DEFAULTS };
|
|
17
|
+
/** Every option, with its default. */
|
|
18
|
+
export declare const DEFAULT_OPTIONS: WaveformSoundsOptions;
|
|
19
|
+
/**
|
|
20
|
+
* A boolean attribute: present-and-empty or "true" → true, "false" → false.
|
|
21
|
+
*
|
|
22
|
+
* @param value
|
|
23
|
+
* @returns undefined for anything else (not set).
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseBool(value: string | undefined): boolean | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* A comma list attribute ("type, key" → ['type', 'key']). An empty string
|
|
28
|
+
* is an empty list (e.g. `data-sorts=""` = no sort menu).
|
|
29
|
+
*
|
|
30
|
+
* @param value
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseList(value: string | undefined): string[] | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* A number attribute; an empty string is "not set".
|
|
35
|
+
*
|
|
36
|
+
* @param value
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseNumber(value: string | undefined): number | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* `data-url-state`: "true"/empty → true, "false" → false, anything else is
|
|
41
|
+
* the parameter prefix.
|
|
42
|
+
*
|
|
43
|
+
* @param value
|
|
44
|
+
*/
|
|
45
|
+
export declare function parseUrlState(value: string | undefined): boolean | string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* A JSON attribute (`data-strings`, `data-player-options`). Invalid JSON is
|
|
48
|
+
* reported and ignored, never thrown: a typo in markup must not take the
|
|
49
|
+
* whole list down.
|
|
50
|
+
*
|
|
51
|
+
* @param value
|
|
52
|
+
* @param name - The attribute name, for the warning.
|
|
53
|
+
*/
|
|
54
|
+
export declare function parseJson(value: string | undefined, name: string): Record<string, any> | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The options set on a container as `data-*` attributes (kebab-case:
|
|
57
|
+
* `data-page-size` → `pageSize`). Attributes that are absent (or unusable)
|
|
58
|
+
* are left out, so they never override a constructor option.
|
|
59
|
+
*
|
|
60
|
+
* @param el
|
|
61
|
+
* @returns The options found.
|
|
62
|
+
*/
|
|
63
|
+
export declare function readDataOptions(el: HTMLElement): Record<string, any>;
|
|
64
|
+
/**
|
|
65
|
+
* Merge option sources: later ones win, and null/undefined never
|
|
66
|
+
* overwrite (an unset prop must not erase a default).
|
|
67
|
+
*
|
|
68
|
+
* @param sources
|
|
69
|
+
*/
|
|
70
|
+
export declare function mergeOptions(...sources: (Record<string, any> | null | undefined)[]): Record<string, any>;
|
|
71
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/js/core/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAC,eAAe,EAAC,CAAC;AAEzB,sCAAsC;AACtC,eAAO,MAAM,eAAe,EAAE,qBAyB7B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAIxE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,GAAG,SAAS,CAGzE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEzE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAIrF;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAQlG;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CA6BpE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,OAAO,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAOxG"}
|