@scalemule/nextjs 0.1.61 → 0.1.63

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/dist/audio.css +857 -0
  2. package/dist/audio.d.mts +334 -0
  3. package/dist/audio.d.ts +334 -0
  4. package/dist/audio.js +2178 -0
  5. package/dist/audio.mjs +2156 -0
  6. package/dist/client.d.mts +240 -0
  7. package/dist/client.d.ts +240 -0
  8. package/dist/client.js +938 -0
  9. package/dist/client.mjs +935 -0
  10. package/dist/index-CEi5Nd4L.d.mts +980 -0
  11. package/dist/index-CEi5Nd4L.d.ts +980 -0
  12. package/dist/index.d.mts +1354 -0
  13. package/dist/index.d.ts +1354 -0
  14. package/dist/index.js +6070 -0
  15. package/dist/index.mjs +6006 -0
  16. package/dist/ledvery-CxPzZpxP.d.mts +44 -0
  17. package/dist/ledvery-CxPzZpxP.d.ts +44 -0
  18. package/dist/listening-hub.global.js +1 -0
  19. package/dist/server/auth.d.mts +43 -0
  20. package/dist/server/auth.d.ts +43 -0
  21. package/dist/server/auth.js +2015 -0
  22. package/dist/server/auth.mjs +2009 -0
  23. package/dist/server/index.d.mts +1303 -0
  24. package/dist/server/index.d.ts +1303 -0
  25. package/dist/server/index.js +3660 -0
  26. package/dist/server/index.mjs +3581 -0
  27. package/dist/server/ledvery.d.mts +1 -0
  28. package/dist/server/ledvery.d.ts +1 -0
  29. package/dist/server/ledvery.js +336 -0
  30. package/dist/server/ledvery.mjs +333 -0
  31. package/dist/server/webhook-handler.d.mts +4 -0
  32. package/dist/server/webhook-handler.d.ts +4 -0
  33. package/dist/server/webhook-handler.js +60 -0
  34. package/dist/server/webhook-handler.mjs +58 -0
  35. package/dist/testing.d.mts +109 -0
  36. package/dist/testing.d.ts +109 -0
  37. package/dist/testing.js +144 -0
  38. package/dist/testing.mjs +138 -0
  39. package/dist/webhook-handler-CJm0sIZG.d.mts +856 -0
  40. package/dist/webhook-handler-CnQe9hm5.d.ts +856 -0
  41. package/package.json +2 -2
@@ -0,0 +1,334 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { CSSProperties, ReactNode } from 'react';
3
+
4
+ interface AudioPlayerSource {
5
+ url: string | null;
6
+ duration_ms?: number | null;
7
+ expires_at?: string | null;
8
+ waveform_peaks?: number[] | null;
9
+ ai_generated?: boolean;
10
+ /** Whether narration word timings exist for this recording. */
11
+ has_word_timings?: boolean;
12
+ }
13
+ /**
14
+ * Follow-along highlighting for article narration. When set (and the
15
+ * recording has word timings), the player shows a highlight toggle —
16
+ * off by default; the reader's choice persists per browser. Enabled,
17
+ * the word and sentence being read are painted via the CSS Custom
18
+ * Highlight API on the element `targetId`, and the page scrolls along
19
+ * gently. `timingsUrl` is fetched lazily on first enable and must
20
+ * return the timings JSON (raw or in a {timings}/{data:{timings}}
21
+ * envelope).
22
+ */
23
+ interface AudioPlayerNarration {
24
+ timingsUrl: string;
25
+ targetId: string;
26
+ }
27
+ type AudioPlayerVariant = 'waveform' | 'compact' | 'inline';
28
+ interface AudioPlayerProps {
29
+ audio: AudioPlayerSource;
30
+ /** Stable article/record identity, including the tenant if needed. Changing it resets playback. */
31
+ audioKey?: string;
32
+ variant?: AudioPlayerVariant;
33
+ label?: string;
34
+ className?: string;
35
+ style?: CSSProperties;
36
+ narration?: AudioPlayerNarration;
37
+ /**
38
+ * Defaults to none so a list does not download every recording.
39
+ * A player that does not already know its length uses metadata anyway,
40
+ * so the clock can show before play.
41
+ */
42
+ preload?: 'none' | 'metadata';
43
+ /** Called at most once automatically per play attempt. Honor signal to cancel network work. */
44
+ onRefresh?: (signal: AbortSignal) => Promise<AudioPlayerSource>;
45
+ /**
46
+ * @deprecated No-op. Players never show a manual Refresh control: expired
47
+ * URLs are refreshed silently through `onRefresh`. Kept so existing callers
48
+ * still compile.
49
+ */
50
+ showRefreshButton?: boolean;
51
+ onPlaybackError?: () => void;
52
+ /** Shared with the existing ScaleMule blog player. Set null to disable persistence. */
53
+ playbackRateStorageKey?: string | null;
54
+ exclusivePlayback?: boolean;
55
+ }
56
+ /** Three layouts, one playback controller. No provider, credentials, polling, or Next.js runtime imports. */
57
+ declare function AudioPlayer(props: AudioPlayerProps): react_jsx_runtime.JSX.Element | null;
58
+
59
+ /**
60
+ * Follow-along narration highlighting.
61
+ *
62
+ * The platform's TTS pipeline stores word timings with every narration
63
+ * it synthesizes: `{version: 1, duration_ms, words}` where each word is
64
+ * `[text, start_ms, end_ms, sentence_index]` over the narration script
65
+ * (the article's markdown rendered to plain text). The article body a
66
+ * site renders is HTML from that same markdown, so the two word
67
+ * sequences correspond nearly one-to-one; this module aligns them and
68
+ * paints the spoken word and sentence as boxes in an overlay layer
69
+ * behind the text — the article's own DOM is never rewritten.
70
+ *
71
+ * Everything degrades to nothing: no layout APIs (SSR), missing
72
+ * timings, or a body that no longer matches the narration simply means
73
+ * no highlight.
74
+ */
75
+ interface NarrationTimings {
76
+ version: number;
77
+ duration_ms?: number;
78
+ /** [text, start_ms, end_ms, sentence_index] */
79
+ words: [string, number, number, number][];
80
+ }
81
+ declare const WORD_HIGHLIGHT = "sm-narration-word";
82
+ declare const SENTENCE_HIGHLIGHT = "sm-narration-sentence";
83
+ declare function narrationHighlightSupported(): boolean;
84
+ /**
85
+ * Owns the live highlight for one narration player. Build once per
86
+ * (timings, article body) pair; drive with `update(currentTimeMs)`.
87
+ *
88
+ * Paints into an overlay layer behind the article text (positioned boxes
89
+ * computed from the words' line rectangles) rather than the CSS Custom
90
+ * Highlight API: WebKit leaves stale ::highlight paint behind while the
91
+ * page scrolls, and per-word highlight ranges render as ragged, gapped
92
+ * boxes. Colors come from --sm-narration-sentence / --sm-narration-word
93
+ * on the article body (or any ancestor).
94
+ */
95
+ declare class NarrationHighlighter {
96
+ private words;
97
+ private ranges;
98
+ private sentenceWords;
99
+ private currentWord;
100
+ private currentSentence;
101
+ private follow;
102
+ private detachUserScroll;
103
+ private reducedMotion;
104
+ private root;
105
+ private layer;
106
+ private sentenceLayer;
107
+ private wordLayer;
108
+ private restoreRootStyle;
109
+ private resizeObserver;
110
+ private onWindowResize;
111
+ constructor(root: Element, timings: NarrationTimings);
112
+ /** Fraction of narration words found in the article body. A low
113
+ * ratio means the body diverged from the script; callers may prefer
114
+ * to hide the toggle below ~0.5. */
115
+ matchRatio(): number;
116
+ private attachUserScroll;
117
+ /** Re-engage auto-scroll (the reader pressed the toggle or sought). */
118
+ resumeFollowing(): void;
119
+ /** Lazily creates the overlay layer behind the article text. */
120
+ private ensureLayer;
121
+ /** Line boxes for the given word indexes, in layer coordinates. */
122
+ private boxesFor;
123
+ private paint;
124
+ /** Re-lays out the current highlight (after resize / reflow). */
125
+ private repaint;
126
+ update(timeMs: number): void;
127
+ private scrollTo;
128
+ clear(): void;
129
+ destroy(): void;
130
+ }
131
+ /** Parse a fetched timings payload; accepts the raw timings object or
132
+ * common envelopes ({timings}, {data:{timings}}). */
133
+ declare function parseTimingsPayload(body: unknown): NarrationTimings | null;
134
+
135
+ /** Article identity is publication-scoped. Media URLs never enter queue checkpoints/messages. */
136
+ interface NetworkAudioTrack {
137
+ id: string;
138
+ publicationId: string;
139
+ title: string;
140
+ publicationName?: string;
141
+ articleUrl: string;
142
+ /** Stable canonical story URL/ID shared by syndicated editions. */
143
+ storyId?: string;
144
+ /** An editorial revision, never a routine database updated_at value. */
145
+ revision?: string;
146
+ durationSeconds?: number;
147
+ section?: string;
148
+ publishedAt?: string;
149
+ automatic?: boolean;
150
+ }
151
+ interface ListeningRecord {
152
+ track: NetworkAudioTrack;
153
+ position: number;
154
+ duration: number;
155
+ ranges: [number, number][];
156
+ updatedAt: number;
157
+ completedAt?: number;
158
+ skippedAt?: number;
159
+ }
160
+ interface NetworkAudioSnapshot {
161
+ queue: readonly NetworkAudioTrack[];
162
+ index: number;
163
+ position: number;
164
+ duration: number;
165
+ rate: number;
166
+ volume: number;
167
+ status: 'idle' | 'loading' | 'playing' | 'paused' | 'error';
168
+ error: string | null;
169
+ history?: readonly ListeningRecord[];
170
+ autoplayNext?: boolean;
171
+ allowRepeats?: boolean;
172
+ hidden?: boolean;
173
+ historyClearedAt?: number;
174
+ settingsUpdatedAt?: number;
175
+ sessionMinutes?: number;
176
+ }
177
+ type ResolveNetworkAudio = (track: NetworkAudioTrack, signal: AbortSignal) => Promise<AudioPlayerSource>;
178
+ /** One audio element per persistent layout. Safe to construct during SSR; attach on mount. */
179
+ declare class NetworkAudioController {
180
+ private resolve;
181
+ private snapshot;
182
+ private listeners;
183
+ private audio;
184
+ private cleanup;
185
+ private request;
186
+ private generation;
187
+ private intent;
188
+ private source;
189
+ private refreshed;
190
+ private resumePosition;
191
+ mergeListeningMemory(memory: {
192
+ rate: number;
193
+ autoplayNext: boolean;
194
+ allowRepeats: boolean;
195
+ settingsUpdatedAt: number;
196
+ historyClearedAt: number;
197
+ history: ListeningRecord[];
198
+ }): void;
199
+ private candidates;
200
+ constructor(resolve: ResolveNetworkAudio);
201
+ setResolver(resolve: ResolveNetworkAudio): void;
202
+ getSnapshot: () => NetworkAudioSnapshot;
203
+ subscribe: (listener: () => void) => () => void;
204
+ private patch;
205
+ attach(audio: HTMLAudioElement): void;
206
+ detach(): void;
207
+ enqueue(track: NetworkAudioTrack): number;
208
+ playTrack(track: NetworkAudioTrack): void;
209
+ select(index: number): void;
210
+ remove(index: number): void;
211
+ private cancel;
212
+ pause(): void;
213
+ clear(): void;
214
+ close(): void;
215
+ setAutoplay(value: boolean): void;
216
+ setRepeats(value: boolean): void;
217
+ forgetHistory(): void;
218
+ restart(): void;
219
+ skip(): void;
220
+ private remember;
221
+ private finish;
222
+ setRecommendations(tracks: NetworkAudioTrack[]): void;
223
+ /** Manual selections retain their order; recommendations are bounded and never replace them. */
224
+ catchUp(minutes?: number): void;
225
+ seek(position: number): void;
226
+ setRate(rate: number): void;
227
+ setVolume(volume: number): void;
228
+ restore(snapshot: NetworkAudioSnapshot): void;
229
+ play(): Promise<void>;
230
+ private load;
231
+ private start;
232
+ private recover;
233
+ private fail;
234
+ }
235
+
236
+ type NetworkAudioCommand = {
237
+ action: 'play' | 'pause' | 'clear' | 'close' | 'skip' | 'restart' | 'forgetHistory';
238
+ } | {
239
+ action: 'autoplay' | 'repeats';
240
+ value: boolean;
241
+ } | {
242
+ action: 'catchUp';
243
+ value: number;
244
+ } | {
245
+ action: 'select' | 'remove' | 'seek' | 'rate' | 'volume';
246
+ value: number;
247
+ } | {
248
+ action: 'enqueue' | 'playTrack';
249
+ track: NetworkAudioTrack;
250
+ };
251
+ interface NetworkPlayerConnection {
252
+ /** Fully qualified, dedicated player route; never the article route. */
253
+ playerUrl: string;
254
+ /** Same namespace on all participating publications. */
255
+ networkId: string;
256
+ }
257
+ interface NetworkPlayerHostOptions {
258
+ networkId: string;
259
+ /** Exact trusted reader origins; never '*'. Also bounds incoming article URLs. */
260
+ allowedOrigins: readonly string[];
261
+ }
262
+
263
+ interface ListeningPersistence {
264
+ /** Network and reader scope. Change this on account changes. */
265
+ storageKey: string;
266
+ networkId: string;
267
+ /** New player windows adopt the opener queue instead of restoring an older host queue. */
268
+ restoreQueue?: boolean;
269
+ hubUrl?: string;
270
+ allowedOrigins: readonly string[];
271
+ }
272
+
273
+ interface NetworkAudioProviderProps {
274
+ children: ReactNode;
275
+ /** Resolve through your reader-authorized server route, including publication identity. */
276
+ resolveAudio: ResolveNetworkAudio;
277
+ /** Reader pages: enables the opt-in separate player window and remote bottom bar. */
278
+ connection?: NetworkPlayerConnection;
279
+ /** Dedicated player route: allows only these reader origins to control its audio. */
280
+ host?: NetworkPlayerHostOptions;
281
+ /** Optional sessionStorage checkpoint. Scope by application/network and user; honor consent. Restores paused. */
282
+ checkpointStorageKey?: string;
283
+ persistence?: ListeningPersistence;
284
+ loadRecommendations?: (signal: AbortSignal) => Promise<NetworkAudioTrack[]>;
285
+ }
286
+ interface NetworkAudioContextValue {
287
+ snapshot: NetworkAudioSnapshot;
288
+ remote: boolean;
289
+ hosted: boolean;
290
+ notice: string | null;
291
+ command: (command: NetworkAudioCommand) => void;
292
+ openNetworkPlayer?: () => void;
293
+ highlightAvailable: boolean;
294
+ highlightEnabled: boolean;
295
+ setHighlightEnabled: (enabled: boolean) => void;
296
+ catchUp?: (minutes: number) => Promise<void>;
297
+ recommendationsLoading: boolean;
298
+ }
299
+ /** Mount once in a persistent root layout, outside route keys/templates. */
300
+ declare function NetworkAudioProvider({ children, resolveAudio, connection, host, checkpointStorageKey, persistence, loadRecommendations }: NetworkAudioProviderProps): react_jsx_runtime.JSX.Element;
301
+ declare function useNetworkAudio(): NetworkAudioContextValue;
302
+ /** Attach in the article component. Unmount/hidden tab clears only highlighting, never playback. */
303
+ declare function useArticleNarration(track: NetworkAudioTrack, narration?: AudioPlayerNarration): {
304
+ highlightAvailable: boolean;
305
+ highlightEnabled: boolean;
306
+ setHighlightEnabled: (enabled: boolean) => void;
307
+ matching: boolean;
308
+ };
309
+ interface ArticleAudioControlsProps {
310
+ track: NetworkAudioTrack;
311
+ narration?: AudioPlayerNarration;
312
+ /** Recording length shown before playback; resolved media supplies the live duration. */
313
+ durationMs?: number | null;
314
+ className?: string;
315
+ }
316
+ declare function ArticleAudioControls({ track, narration, durationMs, className }: ArticleAudioControlsProps): react_jsx_runtime.JSX.Element;
317
+ interface NetworkAudioPlayerProps {
318
+ networkName?: string;
319
+ /** Render an actual ad or sponsor creative here. The expanded slot is labeled Advertisement. */
320
+ advertisement?: ReactNode;
321
+ className?: string;
322
+ style?: CSSProperties;
323
+ /** Use false on the dedicated player page; readers default to a fixed bottom bar with a measured spacer. */
324
+ fixed?: boolean;
325
+ /** Supply your router's Link for same-site navigation. The host always opens articles separately. */
326
+ renderArticleLink?: (track: NetworkAudioTrack) => ReactNode;
327
+ }
328
+ declare function NetworkAudioPlayer({ networkName, advertisement, className, style, fixed, renderArticleLink }: NetworkAudioPlayerProps): react_jsx_runtime.JSX.Element | null;
329
+ /** Shared, compact library: available even when the player is hidden or the queue is empty. */
330
+ declare function ListeningLibrary({ open }: {
331
+ open?: boolean;
332
+ }): react_jsx_runtime.JSX.Element;
333
+
334
+ export { ArticleAudioControls, type ArticleAudioControlsProps, AudioPlayer, type AudioPlayerNarration, type AudioPlayerProps, type AudioPlayerSource, type AudioPlayerVariant, ListeningLibrary, type ListeningPersistence, NarrationHighlighter, type NarrationTimings, type NetworkAudioCommand, type NetworkAudioContextValue, NetworkAudioController, NetworkAudioPlayer, type NetworkAudioPlayerProps, NetworkAudioProvider, type NetworkAudioProviderProps, type NetworkAudioSnapshot, type NetworkAudioTrack, type NetworkPlayerConnection, type NetworkPlayerHostOptions, type ResolveNetworkAudio, SENTENCE_HIGHLIGHT, WORD_HIGHLIGHT, narrationHighlightSupported, parseTimingsPayload, useArticleNarration, useNetworkAudio };
@@ -0,0 +1,334 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { CSSProperties, ReactNode } from 'react';
3
+
4
+ interface AudioPlayerSource {
5
+ url: string | null;
6
+ duration_ms?: number | null;
7
+ expires_at?: string | null;
8
+ waveform_peaks?: number[] | null;
9
+ ai_generated?: boolean;
10
+ /** Whether narration word timings exist for this recording. */
11
+ has_word_timings?: boolean;
12
+ }
13
+ /**
14
+ * Follow-along highlighting for article narration. When set (and the
15
+ * recording has word timings), the player shows a highlight toggle —
16
+ * off by default; the reader's choice persists per browser. Enabled,
17
+ * the word and sentence being read are painted via the CSS Custom
18
+ * Highlight API on the element `targetId`, and the page scrolls along
19
+ * gently. `timingsUrl` is fetched lazily on first enable and must
20
+ * return the timings JSON (raw or in a {timings}/{data:{timings}}
21
+ * envelope).
22
+ */
23
+ interface AudioPlayerNarration {
24
+ timingsUrl: string;
25
+ targetId: string;
26
+ }
27
+ type AudioPlayerVariant = 'waveform' | 'compact' | 'inline';
28
+ interface AudioPlayerProps {
29
+ audio: AudioPlayerSource;
30
+ /** Stable article/record identity, including the tenant if needed. Changing it resets playback. */
31
+ audioKey?: string;
32
+ variant?: AudioPlayerVariant;
33
+ label?: string;
34
+ className?: string;
35
+ style?: CSSProperties;
36
+ narration?: AudioPlayerNarration;
37
+ /**
38
+ * Defaults to none so a list does not download every recording.
39
+ * A player that does not already know its length uses metadata anyway,
40
+ * so the clock can show before play.
41
+ */
42
+ preload?: 'none' | 'metadata';
43
+ /** Called at most once automatically per play attempt. Honor signal to cancel network work. */
44
+ onRefresh?: (signal: AbortSignal) => Promise<AudioPlayerSource>;
45
+ /**
46
+ * @deprecated No-op. Players never show a manual Refresh control: expired
47
+ * URLs are refreshed silently through `onRefresh`. Kept so existing callers
48
+ * still compile.
49
+ */
50
+ showRefreshButton?: boolean;
51
+ onPlaybackError?: () => void;
52
+ /** Shared with the existing ScaleMule blog player. Set null to disable persistence. */
53
+ playbackRateStorageKey?: string | null;
54
+ exclusivePlayback?: boolean;
55
+ }
56
+ /** Three layouts, one playback controller. No provider, credentials, polling, or Next.js runtime imports. */
57
+ declare function AudioPlayer(props: AudioPlayerProps): react_jsx_runtime.JSX.Element | null;
58
+
59
+ /**
60
+ * Follow-along narration highlighting.
61
+ *
62
+ * The platform's TTS pipeline stores word timings with every narration
63
+ * it synthesizes: `{version: 1, duration_ms, words}` where each word is
64
+ * `[text, start_ms, end_ms, sentence_index]` over the narration script
65
+ * (the article's markdown rendered to plain text). The article body a
66
+ * site renders is HTML from that same markdown, so the two word
67
+ * sequences correspond nearly one-to-one; this module aligns them and
68
+ * paints the spoken word and sentence as boxes in an overlay layer
69
+ * behind the text — the article's own DOM is never rewritten.
70
+ *
71
+ * Everything degrades to nothing: no layout APIs (SSR), missing
72
+ * timings, or a body that no longer matches the narration simply means
73
+ * no highlight.
74
+ */
75
+ interface NarrationTimings {
76
+ version: number;
77
+ duration_ms?: number;
78
+ /** [text, start_ms, end_ms, sentence_index] */
79
+ words: [string, number, number, number][];
80
+ }
81
+ declare const WORD_HIGHLIGHT = "sm-narration-word";
82
+ declare const SENTENCE_HIGHLIGHT = "sm-narration-sentence";
83
+ declare function narrationHighlightSupported(): boolean;
84
+ /**
85
+ * Owns the live highlight for one narration player. Build once per
86
+ * (timings, article body) pair; drive with `update(currentTimeMs)`.
87
+ *
88
+ * Paints into an overlay layer behind the article text (positioned boxes
89
+ * computed from the words' line rectangles) rather than the CSS Custom
90
+ * Highlight API: WebKit leaves stale ::highlight paint behind while the
91
+ * page scrolls, and per-word highlight ranges render as ragged, gapped
92
+ * boxes. Colors come from --sm-narration-sentence / --sm-narration-word
93
+ * on the article body (or any ancestor).
94
+ */
95
+ declare class NarrationHighlighter {
96
+ private words;
97
+ private ranges;
98
+ private sentenceWords;
99
+ private currentWord;
100
+ private currentSentence;
101
+ private follow;
102
+ private detachUserScroll;
103
+ private reducedMotion;
104
+ private root;
105
+ private layer;
106
+ private sentenceLayer;
107
+ private wordLayer;
108
+ private restoreRootStyle;
109
+ private resizeObserver;
110
+ private onWindowResize;
111
+ constructor(root: Element, timings: NarrationTimings);
112
+ /** Fraction of narration words found in the article body. A low
113
+ * ratio means the body diverged from the script; callers may prefer
114
+ * to hide the toggle below ~0.5. */
115
+ matchRatio(): number;
116
+ private attachUserScroll;
117
+ /** Re-engage auto-scroll (the reader pressed the toggle or sought). */
118
+ resumeFollowing(): void;
119
+ /** Lazily creates the overlay layer behind the article text. */
120
+ private ensureLayer;
121
+ /** Line boxes for the given word indexes, in layer coordinates. */
122
+ private boxesFor;
123
+ private paint;
124
+ /** Re-lays out the current highlight (after resize / reflow). */
125
+ private repaint;
126
+ update(timeMs: number): void;
127
+ private scrollTo;
128
+ clear(): void;
129
+ destroy(): void;
130
+ }
131
+ /** Parse a fetched timings payload; accepts the raw timings object or
132
+ * common envelopes ({timings}, {data:{timings}}). */
133
+ declare function parseTimingsPayload(body: unknown): NarrationTimings | null;
134
+
135
+ /** Article identity is publication-scoped. Media URLs never enter queue checkpoints/messages. */
136
+ interface NetworkAudioTrack {
137
+ id: string;
138
+ publicationId: string;
139
+ title: string;
140
+ publicationName?: string;
141
+ articleUrl: string;
142
+ /** Stable canonical story URL/ID shared by syndicated editions. */
143
+ storyId?: string;
144
+ /** An editorial revision, never a routine database updated_at value. */
145
+ revision?: string;
146
+ durationSeconds?: number;
147
+ section?: string;
148
+ publishedAt?: string;
149
+ automatic?: boolean;
150
+ }
151
+ interface ListeningRecord {
152
+ track: NetworkAudioTrack;
153
+ position: number;
154
+ duration: number;
155
+ ranges: [number, number][];
156
+ updatedAt: number;
157
+ completedAt?: number;
158
+ skippedAt?: number;
159
+ }
160
+ interface NetworkAudioSnapshot {
161
+ queue: readonly NetworkAudioTrack[];
162
+ index: number;
163
+ position: number;
164
+ duration: number;
165
+ rate: number;
166
+ volume: number;
167
+ status: 'idle' | 'loading' | 'playing' | 'paused' | 'error';
168
+ error: string | null;
169
+ history?: readonly ListeningRecord[];
170
+ autoplayNext?: boolean;
171
+ allowRepeats?: boolean;
172
+ hidden?: boolean;
173
+ historyClearedAt?: number;
174
+ settingsUpdatedAt?: number;
175
+ sessionMinutes?: number;
176
+ }
177
+ type ResolveNetworkAudio = (track: NetworkAudioTrack, signal: AbortSignal) => Promise<AudioPlayerSource>;
178
+ /** One audio element per persistent layout. Safe to construct during SSR; attach on mount. */
179
+ declare class NetworkAudioController {
180
+ private resolve;
181
+ private snapshot;
182
+ private listeners;
183
+ private audio;
184
+ private cleanup;
185
+ private request;
186
+ private generation;
187
+ private intent;
188
+ private source;
189
+ private refreshed;
190
+ private resumePosition;
191
+ mergeListeningMemory(memory: {
192
+ rate: number;
193
+ autoplayNext: boolean;
194
+ allowRepeats: boolean;
195
+ settingsUpdatedAt: number;
196
+ historyClearedAt: number;
197
+ history: ListeningRecord[];
198
+ }): void;
199
+ private candidates;
200
+ constructor(resolve: ResolveNetworkAudio);
201
+ setResolver(resolve: ResolveNetworkAudio): void;
202
+ getSnapshot: () => NetworkAudioSnapshot;
203
+ subscribe: (listener: () => void) => () => void;
204
+ private patch;
205
+ attach(audio: HTMLAudioElement): void;
206
+ detach(): void;
207
+ enqueue(track: NetworkAudioTrack): number;
208
+ playTrack(track: NetworkAudioTrack): void;
209
+ select(index: number): void;
210
+ remove(index: number): void;
211
+ private cancel;
212
+ pause(): void;
213
+ clear(): void;
214
+ close(): void;
215
+ setAutoplay(value: boolean): void;
216
+ setRepeats(value: boolean): void;
217
+ forgetHistory(): void;
218
+ restart(): void;
219
+ skip(): void;
220
+ private remember;
221
+ private finish;
222
+ setRecommendations(tracks: NetworkAudioTrack[]): void;
223
+ /** Manual selections retain their order; recommendations are bounded and never replace them. */
224
+ catchUp(minutes?: number): void;
225
+ seek(position: number): void;
226
+ setRate(rate: number): void;
227
+ setVolume(volume: number): void;
228
+ restore(snapshot: NetworkAudioSnapshot): void;
229
+ play(): Promise<void>;
230
+ private load;
231
+ private start;
232
+ private recover;
233
+ private fail;
234
+ }
235
+
236
+ type NetworkAudioCommand = {
237
+ action: 'play' | 'pause' | 'clear' | 'close' | 'skip' | 'restart' | 'forgetHistory';
238
+ } | {
239
+ action: 'autoplay' | 'repeats';
240
+ value: boolean;
241
+ } | {
242
+ action: 'catchUp';
243
+ value: number;
244
+ } | {
245
+ action: 'select' | 'remove' | 'seek' | 'rate' | 'volume';
246
+ value: number;
247
+ } | {
248
+ action: 'enqueue' | 'playTrack';
249
+ track: NetworkAudioTrack;
250
+ };
251
+ interface NetworkPlayerConnection {
252
+ /** Fully qualified, dedicated player route; never the article route. */
253
+ playerUrl: string;
254
+ /** Same namespace on all participating publications. */
255
+ networkId: string;
256
+ }
257
+ interface NetworkPlayerHostOptions {
258
+ networkId: string;
259
+ /** Exact trusted reader origins; never '*'. Also bounds incoming article URLs. */
260
+ allowedOrigins: readonly string[];
261
+ }
262
+
263
+ interface ListeningPersistence {
264
+ /** Network and reader scope. Change this on account changes. */
265
+ storageKey: string;
266
+ networkId: string;
267
+ /** New player windows adopt the opener queue instead of restoring an older host queue. */
268
+ restoreQueue?: boolean;
269
+ hubUrl?: string;
270
+ allowedOrigins: readonly string[];
271
+ }
272
+
273
+ interface NetworkAudioProviderProps {
274
+ children: ReactNode;
275
+ /** Resolve through your reader-authorized server route, including publication identity. */
276
+ resolveAudio: ResolveNetworkAudio;
277
+ /** Reader pages: enables the opt-in separate player window and remote bottom bar. */
278
+ connection?: NetworkPlayerConnection;
279
+ /** Dedicated player route: allows only these reader origins to control its audio. */
280
+ host?: NetworkPlayerHostOptions;
281
+ /** Optional sessionStorage checkpoint. Scope by application/network and user; honor consent. Restores paused. */
282
+ checkpointStorageKey?: string;
283
+ persistence?: ListeningPersistence;
284
+ loadRecommendations?: (signal: AbortSignal) => Promise<NetworkAudioTrack[]>;
285
+ }
286
+ interface NetworkAudioContextValue {
287
+ snapshot: NetworkAudioSnapshot;
288
+ remote: boolean;
289
+ hosted: boolean;
290
+ notice: string | null;
291
+ command: (command: NetworkAudioCommand) => void;
292
+ openNetworkPlayer?: () => void;
293
+ highlightAvailable: boolean;
294
+ highlightEnabled: boolean;
295
+ setHighlightEnabled: (enabled: boolean) => void;
296
+ catchUp?: (minutes: number) => Promise<void>;
297
+ recommendationsLoading: boolean;
298
+ }
299
+ /** Mount once in a persistent root layout, outside route keys/templates. */
300
+ declare function NetworkAudioProvider({ children, resolveAudio, connection, host, checkpointStorageKey, persistence, loadRecommendations }: NetworkAudioProviderProps): react_jsx_runtime.JSX.Element;
301
+ declare function useNetworkAudio(): NetworkAudioContextValue;
302
+ /** Attach in the article component. Unmount/hidden tab clears only highlighting, never playback. */
303
+ declare function useArticleNarration(track: NetworkAudioTrack, narration?: AudioPlayerNarration): {
304
+ highlightAvailable: boolean;
305
+ highlightEnabled: boolean;
306
+ setHighlightEnabled: (enabled: boolean) => void;
307
+ matching: boolean;
308
+ };
309
+ interface ArticleAudioControlsProps {
310
+ track: NetworkAudioTrack;
311
+ narration?: AudioPlayerNarration;
312
+ /** Recording length shown before playback; resolved media supplies the live duration. */
313
+ durationMs?: number | null;
314
+ className?: string;
315
+ }
316
+ declare function ArticleAudioControls({ track, narration, durationMs, className }: ArticleAudioControlsProps): react_jsx_runtime.JSX.Element;
317
+ interface NetworkAudioPlayerProps {
318
+ networkName?: string;
319
+ /** Render an actual ad or sponsor creative here. The expanded slot is labeled Advertisement. */
320
+ advertisement?: ReactNode;
321
+ className?: string;
322
+ style?: CSSProperties;
323
+ /** Use false on the dedicated player page; readers default to a fixed bottom bar with a measured spacer. */
324
+ fixed?: boolean;
325
+ /** Supply your router's Link for same-site navigation. The host always opens articles separately. */
326
+ renderArticleLink?: (track: NetworkAudioTrack) => ReactNode;
327
+ }
328
+ declare function NetworkAudioPlayer({ networkName, advertisement, className, style, fixed, renderArticleLink }: NetworkAudioPlayerProps): react_jsx_runtime.JSX.Element | null;
329
+ /** Shared, compact library: available even when the player is hidden or the queue is empty. */
330
+ declare function ListeningLibrary({ open }: {
331
+ open?: boolean;
332
+ }): react_jsx_runtime.JSX.Element;
333
+
334
+ export { ArticleAudioControls, type ArticleAudioControlsProps, AudioPlayer, type AudioPlayerNarration, type AudioPlayerProps, type AudioPlayerSource, type AudioPlayerVariant, ListeningLibrary, type ListeningPersistence, NarrationHighlighter, type NarrationTimings, type NetworkAudioCommand, type NetworkAudioContextValue, NetworkAudioController, NetworkAudioPlayer, type NetworkAudioPlayerProps, NetworkAudioProvider, type NetworkAudioProviderProps, type NetworkAudioSnapshot, type NetworkAudioTrack, type NetworkPlayerConnection, type NetworkPlayerHostOptions, type ResolveNetworkAudio, SENTENCE_HIGHLIGHT, WORD_HIGHLIGHT, narrationHighlightSupported, parseTimingsPayload, useArticleNarration, useNetworkAudio };