@uvalib/web-components 1.11.1 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +192 -54
  3. package/dist/base.css +56 -2
  4. package/dist/components/uvalib-audio/UvalibAudio.d.ts +186 -0
  5. package/dist/components/uvalib-audio/UvalibAudio.js +1154 -0
  6. package/dist/components/uvalib-audio/UvalibAudio.js.map +1 -0
  7. package/dist/components/uvalib-audio/uvalib-audio.d.ts +1 -0
  8. package/dist/components/uvalib-audio/uvalib-audio.js +4 -0
  9. package/dist/components/uvalib-audio/uvalib-audio.js.map +1 -0
  10. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +25 -5
  11. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +62 -9
  12. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
  13. package/dist/custom-elements.json +8486 -7187
  14. package/dist/edition-epub.css +511 -0
  15. package/dist/edition-print.css +51 -0
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.js +1 -0
  18. package/dist/index.js.map +1 -1
  19. package/dist/styles/base.js +55 -1
  20. package/dist/styles/base.js.map +1 -1
  21. package/dist/styles/edition.d.ts +6 -0
  22. package/dist/styles/edition.js +20 -0
  23. package/dist/styles/edition.js.map +1 -1
  24. package/dist-cdn/base.css +56 -2
  25. package/dist-cdn/chunks/{base-DtkA4Pgg.js → base-D_oPO5cX.js} +56 -2
  26. package/dist-cdn/chunks/{base-DtkA4Pgg.js.map → base-D_oPO5cX.js.map} +1 -1
  27. package/dist-cdn/custom-elements.json +8486 -7187
  28. package/dist-cdn/edition-epub.css +511 -0
  29. package/dist-cdn/edition-print.css +51 -0
  30. package/dist-cdn/manifest.json +6 -3
  31. package/dist-cdn/site-page.js +1 -1
  32. package/dist-cdn/site-style.js +1 -1
  33. package/dist-cdn/skills/uvalib-web-components/SKILL.md +35 -4
  34. package/dist-cdn/skills/uvalib-web-components/reference/components.md +53 -1
  35. package/dist-cdn/uvalib-audio.js +747 -0
  36. package/dist-cdn/uvalib-audio.js.map +1 -0
  37. package/dist-cdn/uvalib-pagefind-search.js +70 -44
  38. package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
  39. package/package.json +7 -1
  40. package/skills/uvalib-web-components/SKILL.md +35 -4
  41. package/skills/uvalib-web-components/reference/components.md +53 -1
@@ -0,0 +1,186 @@
1
+ import { nothing, type PropertyValues } from 'lit';
2
+ import { UvalibElement } from '../../base/UvalibElement.js';
3
+ /** The playback speeds offered, slowest first. */
4
+ export declare const SPEEDS: readonly [0.75, 1, 1.25, 1.5, 1.75, 2];
5
+ /** Back and Forward, in seconds: the podcast convention (a missed phrase back, a skip ahead). */
6
+ export declare const SKIP: {
7
+ readonly back: 15;
8
+ readonly forward: 30;
9
+ };
10
+ /**
11
+ * How long (ms) to wait before announcing (a burst of skips is announced once, where it
12
+ * ends), saving the position while playing, and reporting a speed change to analytics.
13
+ * Tests may shorten them.
14
+ */
15
+ export declare const audioTiming: {
16
+ announce: number;
17
+ save: number;
18
+ speed: number;
19
+ };
20
+ /** `12:31`, `1:02:03` or `751` (seconds) to seconds; undefined when unreadable. */
21
+ export declare function parseDuration(text: string | null | undefined): number | undefined;
22
+ /** 754 → `12:34`, 3723 → `1:02:03`. */
23
+ export declare function clock(seconds: number): string;
24
+ /** 750 → `12 minutes 30 seconds`, 3600 → `1 hour`, 0 → `0 seconds`. */
25
+ export declare function spoken(seconds: number): string;
26
+ /**
27
+ * A size as written (`312 MB`), or a number of bytes made readable in decimal units, as
28
+ * operating systems show file sizes: `312000000` → `312 MB`, `1500000` → `1.5 MB`.
29
+ */
30
+ export declare function formatSize(value: string | null | undefined): string;
31
+ /**
32
+ * A long recording played by chapter: an audiobook, an oral history's sessions. One player
33
+ * for the whole list, so starting a chapter stops the one playing.
34
+ *
35
+ * Give the chapters as a list of links to their files, so the page works before (and
36
+ * without) the script: `<ol><li><a href="ch1.mp3" data-duration="12:31">Chapter 1. Down the
37
+ * Rabbit-Hole</a></li>…</ol>`. The first link in each item is the chapter (its text is the
38
+ * title; inline markup such as `<i>` or `lang` is kept); `data-duration` (`12:31`, `1:02:03` or
39
+ * seconds) is shown beside it and gives the slider its length before the file loads. Other
40
+ * links in the item (the chapter's text, a transcript) are kept as links after it.
41
+ * `data-download` on the `<li>` adds a Download link for that chapter (its own file, or the
42
+ * URL given), with `data-size` (bytes or text) after it.
43
+ *
44
+ * Upgraded, each chapter is a real button (“Play Chapter 1. Down the Rabbit-Hole”, its
45
+ * visible text), with its duration; the current chapter gets `aria-current="true"` and says
46
+ * “Now playing” or “Paused” in text, beside an orange bar. Above the list, a player for the
47
+ * current chapter: what is playing (as text, not a live region), Back 15 s, Play/Pause,
48
+ * Forward 30 s, a position slider (a native range, read as “12 minutes 30 seconds of 41
49
+ * minutes”), the elapsed and total time, and a native Speed select (0.75× to 2×). One
50
+ * `<audio preload="none">` plays everything: nothing loads until the visitor presses Play,
51
+ * and nothing ever plays without a press.
52
+ *
53
+ * `continuous` plays the next chapter when one ends. The position is remembered per page in
54
+ * localStorage (the page's path, plus `storage-key` when a page has more than one
55
+ * recording): on the next visit a “Resume “Chapter 4” at 12:30” button offers to carry on,
56
+ * never playing by itself. Saved on pause, every few seconds while playing, and when the page
57
+ * is left; cleared when the last chapter ends. `no-resume` turns it off. Without storage it
58
+ * simply forgets.
59
+ *
60
+ * Chapter changes, pauses, speed changes and skips are announced politely in one status
61
+ * (a burst of skips once, where it ends); the time is never announced as it runs. A chapter
62
+ * that fails to load says so in text, with a direct link to its file. `download-href` adds a
63
+ * link to the whole recording (an M4B audiobook), with `download-label` and `download-size`
64
+ * (bytes, shown as “312 MB”, or text). Where the browser has the Media Session API, the
65
+ * system's media keys and lock screen show the chapter and can play, pause, seek and change
66
+ * chapter.
67
+ *
68
+ * Before it upgrades, `base.css` holds the player's height above the list and gives each
69
+ * item the height of its upgraded row, so the list does not move.
70
+ *
71
+ * @tagname uvalib-audio
72
+ * @fires uvalib-analytics-event - For `<site-analytics>`, on the visitor's actions only, never titles or URLs: `['uvalib-audio', 'play', 'chapter <N>', N]` the first time each chapter plays in a page view (N is its place in the list), `['uvalib-audio', 'complete', 'chapter <N>', N]` when it plays to its end, `['uvalib-audio', 'speed', '<speed>', speed]` once the visitor settles on a speed, `['uvalib-audio', 'resume', 'chapter <N>', N]`, and `['uvalib-audio', 'download', 'recording' | 'chapter <N>']`. Bubbles and is composed.
73
+ * @csspart player - The player box above the list.
74
+ * @csspart now - The line saying what is playing (or the Resume button).
75
+ * @csspart controls - The player's buttons, slider, time and speed.
76
+ * @csspart download - The whole recording's download line.
77
+ * @csspart list - The list of chapters.
78
+ * @csspart chapter - Each chapter's row.
79
+ * @cssprop --uva-color-text - Dark-mode role token: text (else `--uva-grey-darkest`).
80
+ * @cssprop --uva-color-text-muted - Dark-mode role token: durations (else #4b5563).
81
+ * @cssprop --uva-color-link - Dark-mode role token: links and the outline buttons (else `--uva-brand-blue`).
82
+ * @cssprop --uva-color-button-bg - Dark-mode role token: Play/Pause and the slider (else `--uva-blue-alt`).
83
+ * @cssprop --uva-color-button-text - Dark-mode role token: Play/Pause text (else #fff).
84
+ * @cssprop --uva-color-surface-raised - Dark-mode role token: the player's and the controls' background (else #fff).
85
+ * @cssprop --uva-color-table-border - Dark-mode role token: the player's border and the rules between chapters (else #dadada).
86
+ * @cssprop --uva-color-accent-bg - Dark-mode role token: the “Now playing” marker (else `--uva-brand-blue`).
87
+ * @cssprop --uva-color-on-accent - Dark-mode role token: the marker's text (else #fff).
88
+ * @cssprop --uva-color-current - Dark-mode role token: the current chapter's bar (else `--uva-brand-orange`).
89
+ * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).
90
+ */
91
+ export declare class UvalibAudio extends UvalibElement {
92
+ static styles: import("lit").CSSResult[];
93
+ /** The player's accessible name, such as the book's title (default “Player”). */
94
+ label: string;
95
+ /** Play the next chapter when one ends. */
96
+ continuous: boolean;
97
+ /** Don't remember the position (nothing is read from or written to localStorage). */
98
+ noResume: boolean;
99
+ /** Added to the page's path to name what is remembered, for a page with several recordings. */
100
+ storageKey: string;
101
+ /** The whole recording to download (an M4B audiobook with chapters, an MP3). */
102
+ downloadHref: string;
103
+ /** The download link's text. */
104
+ downloadLabel: string;
105
+ /** The download's size: bytes (shown as “312 MB”) or text. */
106
+ downloadSize: string;
107
+ private chapters;
108
+ /** The current chapter's index, or -1 before any. */
109
+ private currentIndex;
110
+ private isPlaying;
111
+ private finished;
112
+ /** Whole seconds into the current chapter. */
113
+ private time;
114
+ private speed;
115
+ private resume?;
116
+ private failed;
117
+ /** Durations read from the files once loaded, by index. */
118
+ private loaded;
119
+ private announcement;
120
+ private readonly uid;
121
+ private readonly source;
122
+ private sourceKey;
123
+ private restored;
124
+ /** The chapter whose file is in the audio element, or -1. */
125
+ private srcIndex;
126
+ /** A position to seek to once the current file's metadata is in. */
127
+ private pendingTime?;
128
+ private played;
129
+ private completed;
130
+ private lastSave;
131
+ private announceTimer?;
132
+ private clearTimer?;
133
+ private speedTimer?;
134
+ private reportedSpeed;
135
+ private warned;
136
+ constructor();
137
+ /** The current chapter's index (0-based), or -1 before any is chosen. */
138
+ get current(): number;
139
+ /** Whether a chapter is playing. */
140
+ get playing(): boolean;
141
+ protected createRenderRoot(): HTMLElement | DocumentFragment;
142
+ connectedCallback(): void;
143
+ disconnectedCallback(): void;
144
+ private warnOnce;
145
+ private read;
146
+ private get storeKey();
147
+ private readSaved;
148
+ private write;
149
+ /** Save the current chapter and position (nothing before the visitor has played one). */
150
+ private save;
151
+ protected willUpdate(changed: PropertyValues): void;
152
+ private get audio();
153
+ private durationOf;
154
+ /** Play chapter `index` (0-based; default the current one, else the first) from where it was. */
155
+ play(index?: number, at?: number): Promise<void>;
156
+ /** Pause the chapter playing. */
157
+ pause(): void;
158
+ private toggle;
159
+ private seek;
160
+ private currentPosition;
161
+ /** Before any chapter is current, the controls act on the one Resume offers, else the first. */
162
+ private adoptResume;
163
+ private skip;
164
+ private onSeekInput;
165
+ private onSpeed;
166
+ private flushSpeed;
167
+ private onResume;
168
+ private fail;
169
+ private onPlay;
170
+ private onPause;
171
+ private onTime;
172
+ private onMeta;
173
+ private onEnded;
174
+ private onError;
175
+ private claimMediaSession;
176
+ private setPlaybackState;
177
+ private releaseMediaSession;
178
+ private announce;
179
+ private onDownload;
180
+ private sizeText;
181
+ private renderNow;
182
+ private renderPlayer;
183
+ private renderDownload;
184
+ private renderChapter;
185
+ protected render(): typeof nothing | import("lit").TemplateResult<1>;
186
+ }