@scalemule/nextjs 0.1.48 → 0.1.49
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/README.md +4 -0
- package/dist/audio.css +229 -0
- package/dist/audio.d.mts +130 -2
- package/dist/audio.d.ts +130 -2
- package/dist/audio.js +782 -2
- package/dist/audio.mjs +784 -1
- package/docs/network-audio.md +218 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
ScaleMule SDK for Next.js applications.
|
|
4
4
|
|
|
5
|
+
For persistent article playback, a bottom player bar, listening queues and an
|
|
6
|
+
opt-in player window that survives navigation across publications, see the
|
|
7
|
+
[network audio integration guide](docs/network-audio.md).
|
|
8
|
+
|
|
5
9
|
Server-side authentication with HTTP-only cookies, CSRF protection, webhook handling, secrets management, and client-side hooks.
|
|
6
10
|
|
|
7
11
|
## Install
|
package/dist/audio.css
CHANGED
|
@@ -224,3 +224,232 @@
|
|
|
224
224
|
flex-basis: 120px;
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
+
|
|
228
|
+
/* src/components/network-audio-player.css */
|
|
229
|
+
.sm-network-player {
|
|
230
|
+
--sm-player-paper: #fff;
|
|
231
|
+
--sm-player-ink: #203b30;
|
|
232
|
+
--sm-player-muted: #52675c;
|
|
233
|
+
--sm-player-line: #d4ddd6;
|
|
234
|
+
--sm-player-accent: #246346;
|
|
235
|
+
--sm-player-soft: #f2f6f3;
|
|
236
|
+
box-sizing: border-box;
|
|
237
|
+
color: var(--sm-player-ink);
|
|
238
|
+
background: var(--sm-player-paper);
|
|
239
|
+
border-top: 2px solid var(--sm-player-accent);
|
|
240
|
+
padding: 16px max(20px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
|
|
241
|
+
font: 400 14px/1.45 var(--font-inter, system-ui), sans-serif;
|
|
242
|
+
color-scheme: light;
|
|
243
|
+
}
|
|
244
|
+
.sm-network-player *,
|
|
245
|
+
.sm-network-article * {
|
|
246
|
+
box-sizing: border-box;
|
|
247
|
+
}
|
|
248
|
+
.sm-network-player--fixed {
|
|
249
|
+
position: fixed;
|
|
250
|
+
z-index: var(--sm-player-z-index, 100);
|
|
251
|
+
inset: auto 0 0;
|
|
252
|
+
box-shadow: 0 -5px 24px #203b3010;
|
|
253
|
+
}
|
|
254
|
+
.sm-network-player button,
|
|
255
|
+
.sm-network-player select,
|
|
256
|
+
.sm-network-article button {
|
|
257
|
+
color: inherit;
|
|
258
|
+
font: inherit;
|
|
259
|
+
border: 1px solid var(--sm-player-line, #d4ddd6);
|
|
260
|
+
background: transparent;
|
|
261
|
+
min-height: 44px;
|
|
262
|
+
border-radius: 6px;
|
|
263
|
+
padding: 8px 12px;
|
|
264
|
+
cursor: pointer;
|
|
265
|
+
touch-action: manipulation;
|
|
266
|
+
}
|
|
267
|
+
.sm-network-player button:disabled,
|
|
268
|
+
.sm-network-article button:disabled {
|
|
269
|
+
opacity: .5;
|
|
270
|
+
cursor: default;
|
|
271
|
+
}
|
|
272
|
+
.sm-network-player :is(button, a, input, select):focus-visible,
|
|
273
|
+
.sm-network-article button:focus-visible {
|
|
274
|
+
outline: 3px solid var(--sm-player-accent, #246346);
|
|
275
|
+
outline-offset: 3px;
|
|
276
|
+
}
|
|
277
|
+
.sm-network-player button:hover:not(:disabled),
|
|
278
|
+
.sm-network-article button:hover:not(:disabled) {
|
|
279
|
+
background: var(--sm-player-soft, #f2f6f3);
|
|
280
|
+
}
|
|
281
|
+
.sm-network-player__row {
|
|
282
|
+
display: flex;
|
|
283
|
+
align-items: center;
|
|
284
|
+
gap: 18px;
|
|
285
|
+
max-width: 1320px;
|
|
286
|
+
margin: auto;
|
|
287
|
+
}
|
|
288
|
+
.sm-network-player .sm-network-player__play {
|
|
289
|
+
width: 48px;
|
|
290
|
+
height: 48px;
|
|
291
|
+
flex: 0 0 48px;
|
|
292
|
+
display: grid;
|
|
293
|
+
place-items: center;
|
|
294
|
+
border-radius: 50%;
|
|
295
|
+
background: var(--sm-player-accent);
|
|
296
|
+
color: white;
|
|
297
|
+
border: none;
|
|
298
|
+
}
|
|
299
|
+
.sm-network-player .sm-network-player__play:hover {
|
|
300
|
+
background: var(--sm-player-ink);
|
|
301
|
+
}
|
|
302
|
+
.sm-network-player__play svg {
|
|
303
|
+
width: 22px;
|
|
304
|
+
height: 22px;
|
|
305
|
+
fill: currentColor;
|
|
306
|
+
}
|
|
307
|
+
.sm-network-player__story {
|
|
308
|
+
min-width: 0;
|
|
309
|
+
flex: 1 1 340px;
|
|
310
|
+
}
|
|
311
|
+
.sm-network-player__story a {
|
|
312
|
+
display: block;
|
|
313
|
+
overflow: hidden;
|
|
314
|
+
text-overflow: ellipsis;
|
|
315
|
+
white-space: nowrap;
|
|
316
|
+
font: 600 19px/1.3 var(--font-editorial, Georgia), serif;
|
|
317
|
+
color: inherit;
|
|
318
|
+
text-decoration: none;
|
|
319
|
+
}
|
|
320
|
+
.sm-network-player__story a:hover {
|
|
321
|
+
text-decoration: underline;
|
|
322
|
+
}
|
|
323
|
+
.sm-network-player__story :is(span, small) {
|
|
324
|
+
color: var(--sm-player-muted);
|
|
325
|
+
font-size: 12px;
|
|
326
|
+
}
|
|
327
|
+
.sm-network-player__timeline {
|
|
328
|
+
flex: 1 1 260px;
|
|
329
|
+
min-width: 160px;
|
|
330
|
+
}
|
|
331
|
+
.sm-network-player input[type=range] {
|
|
332
|
+
accent-color: var(--sm-player-accent);
|
|
333
|
+
cursor: pointer;
|
|
334
|
+
min-height: 24px;
|
|
335
|
+
}
|
|
336
|
+
.sm-network-player__timeline input {
|
|
337
|
+
display: block;
|
|
338
|
+
width: 100%;
|
|
339
|
+
margin: 0;
|
|
340
|
+
}
|
|
341
|
+
.sm-network-player__timeline div {
|
|
342
|
+
display: flex;
|
|
343
|
+
justify-content: space-between;
|
|
344
|
+
color: var(--sm-player-muted);
|
|
345
|
+
font-size: 12px;
|
|
346
|
+
font-variant-numeric: tabular-nums;
|
|
347
|
+
}
|
|
348
|
+
.sm-network-player__details {
|
|
349
|
+
max-height: min(60dvh, 600px);
|
|
350
|
+
overflow: auto;
|
|
351
|
+
max-width: 1320px;
|
|
352
|
+
margin: auto;
|
|
353
|
+
}
|
|
354
|
+
.sm-network-player__tools {
|
|
355
|
+
display: flex;
|
|
356
|
+
flex-wrap: wrap;
|
|
357
|
+
gap: 12px;
|
|
358
|
+
align-items: center;
|
|
359
|
+
padding-block: 20px;
|
|
360
|
+
}
|
|
361
|
+
.sm-network-player__tools label {
|
|
362
|
+
display: flex;
|
|
363
|
+
align-items: center;
|
|
364
|
+
gap: 8px;
|
|
365
|
+
}
|
|
366
|
+
.sm-network-player__tools input {
|
|
367
|
+
width: 100px;
|
|
368
|
+
}
|
|
369
|
+
.sm-network-player__expanded {
|
|
370
|
+
display: grid;
|
|
371
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
372
|
+
gap: 32px;
|
|
373
|
+
border-top: 1px solid var(--sm-player-line);
|
|
374
|
+
padding-top: 16px;
|
|
375
|
+
}
|
|
376
|
+
.sm-network-player h2 {
|
|
377
|
+
font: 600 22px/1.3 var(--font-editorial, Georgia), serif;
|
|
378
|
+
margin: 0 0 12px;
|
|
379
|
+
}
|
|
380
|
+
.sm-network-player ol {
|
|
381
|
+
margin: 0;
|
|
382
|
+
padding: 0;
|
|
383
|
+
list-style: none;
|
|
384
|
+
}
|
|
385
|
+
.sm-network-player li {
|
|
386
|
+
display: flex;
|
|
387
|
+
gap: 12px;
|
|
388
|
+
align-items: center;
|
|
389
|
+
padding: 8px;
|
|
390
|
+
border-bottom: 1px solid var(--sm-player-line);
|
|
391
|
+
}
|
|
392
|
+
.sm-network-player li[aria-current=true] {
|
|
393
|
+
background: var(--sm-player-soft);
|
|
394
|
+
}
|
|
395
|
+
.sm-network-player .sm-network-player__queue-title {
|
|
396
|
+
flex: 1;
|
|
397
|
+
text-align: left;
|
|
398
|
+
border: 0;
|
|
399
|
+
overflow-wrap: anywhere;
|
|
400
|
+
}
|
|
401
|
+
.sm-network-player__queue-title small {
|
|
402
|
+
display: block;
|
|
403
|
+
color: var(--sm-player-muted);
|
|
404
|
+
margin-top: 4px;
|
|
405
|
+
}
|
|
406
|
+
.sm-network-player aside {
|
|
407
|
+
max-width: 320px;
|
|
408
|
+
}
|
|
409
|
+
.sm-network-player aside > span {
|
|
410
|
+
display: block;
|
|
411
|
+
font-size: 11px;
|
|
412
|
+
color: var(--sm-player-muted);
|
|
413
|
+
margin-bottom: 8px;
|
|
414
|
+
}
|
|
415
|
+
.sm-network-player aside img {
|
|
416
|
+
max-width: 100%;
|
|
417
|
+
height: auto;
|
|
418
|
+
}
|
|
419
|
+
.sm-network-player__notice {
|
|
420
|
+
max-width: 1320px;
|
|
421
|
+
margin: 12px auto 0;
|
|
422
|
+
}
|
|
423
|
+
.sm-network-article {
|
|
424
|
+
display: flex;
|
|
425
|
+
flex-wrap: wrap;
|
|
426
|
+
align-items: center;
|
|
427
|
+
gap: 10px;
|
|
428
|
+
}
|
|
429
|
+
.sm-network-article button[aria-pressed=true] {
|
|
430
|
+
background: var(--sm-player-accent, #246346);
|
|
431
|
+
color: white;
|
|
432
|
+
}
|
|
433
|
+
@media (max-width: 700px) {
|
|
434
|
+
.sm-network-player {
|
|
435
|
+
padding-inline: max(12px, env(safe-area-inset-left));
|
|
436
|
+
}
|
|
437
|
+
.sm-network-player__row {
|
|
438
|
+
gap: 10px;
|
|
439
|
+
flex-wrap: wrap;
|
|
440
|
+
}
|
|
441
|
+
.sm-network-player__story {
|
|
442
|
+
flex: 1 1 calc(100% - 60px);
|
|
443
|
+
}
|
|
444
|
+
.sm-network-player__story a {
|
|
445
|
+
font-size: 17px;
|
|
446
|
+
}
|
|
447
|
+
.sm-network-player__timeline {
|
|
448
|
+
flex: 1 1 120px;
|
|
449
|
+
min-width: 100px;
|
|
450
|
+
}
|
|
451
|
+
.sm-network-player__expanded {
|
|
452
|
+
grid-template-columns: minmax(0, 1fr);
|
|
453
|
+
gap: 20px;
|
|
454
|
+
}
|
|
455
|
+
}
|
package/dist/audio.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { CSSProperties } from 'react';
|
|
2
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
interface AudioPlayerSource {
|
|
5
5
|
url: string | null;
|
|
@@ -132,4 +132,132 @@ declare class NarrationHighlighter {
|
|
|
132
132
|
* common envelopes ({timings}, {data:{timings}}). */
|
|
133
133
|
declare function parseTimingsPayload(body: unknown): NarrationTimings | null;
|
|
134
134
|
|
|
135
|
-
|
|
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
|
+
}
|
|
143
|
+
interface NetworkAudioSnapshot {
|
|
144
|
+
queue: readonly NetworkAudioTrack[];
|
|
145
|
+
index: number;
|
|
146
|
+
position: number;
|
|
147
|
+
duration: number;
|
|
148
|
+
rate: number;
|
|
149
|
+
volume: number;
|
|
150
|
+
status: 'idle' | 'loading' | 'playing' | 'paused' | 'error';
|
|
151
|
+
error: string | null;
|
|
152
|
+
}
|
|
153
|
+
type ResolveNetworkAudio = (track: NetworkAudioTrack, signal: AbortSignal) => Promise<AudioPlayerSource>;
|
|
154
|
+
/** One audio element per persistent layout. Safe to construct during SSR; attach on mount. */
|
|
155
|
+
declare class NetworkAudioController {
|
|
156
|
+
private resolve;
|
|
157
|
+
private snapshot;
|
|
158
|
+
private listeners;
|
|
159
|
+
private audio;
|
|
160
|
+
private cleanup;
|
|
161
|
+
private request;
|
|
162
|
+
private generation;
|
|
163
|
+
private intent;
|
|
164
|
+
private source;
|
|
165
|
+
private refreshed;
|
|
166
|
+
private resumePosition;
|
|
167
|
+
constructor(resolve: ResolveNetworkAudio);
|
|
168
|
+
setResolver(resolve: ResolveNetworkAudio): void;
|
|
169
|
+
getSnapshot: () => NetworkAudioSnapshot;
|
|
170
|
+
subscribe: (listener: () => void) => () => void;
|
|
171
|
+
private patch;
|
|
172
|
+
attach(audio: HTMLAudioElement): void;
|
|
173
|
+
detach(): void;
|
|
174
|
+
enqueue(track: NetworkAudioTrack): number;
|
|
175
|
+
playTrack(track: NetworkAudioTrack): void;
|
|
176
|
+
select(index: number): void;
|
|
177
|
+
remove(index: number): void;
|
|
178
|
+
private cancel;
|
|
179
|
+
pause(): void;
|
|
180
|
+
clear(): void;
|
|
181
|
+
seek(position: number): void;
|
|
182
|
+
setRate(rate: number): void;
|
|
183
|
+
setVolume(volume: number): void;
|
|
184
|
+
restore(snapshot: NetworkAudioSnapshot): void;
|
|
185
|
+
play(): Promise<void>;
|
|
186
|
+
private load;
|
|
187
|
+
private start;
|
|
188
|
+
private recover;
|
|
189
|
+
private fail;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
type NetworkAudioCommand = {
|
|
193
|
+
action: 'play' | 'pause' | 'clear';
|
|
194
|
+
} | {
|
|
195
|
+
action: 'select' | 'remove' | 'seek' | 'rate' | 'volume';
|
|
196
|
+
value: number;
|
|
197
|
+
} | {
|
|
198
|
+
action: 'enqueue' | 'playTrack';
|
|
199
|
+
track: NetworkAudioTrack;
|
|
200
|
+
};
|
|
201
|
+
interface NetworkPlayerConnection {
|
|
202
|
+
/** Fully qualified, dedicated player route; never the article route. */
|
|
203
|
+
playerUrl: string;
|
|
204
|
+
/** Same namespace on all participating publications. */
|
|
205
|
+
networkId: string;
|
|
206
|
+
}
|
|
207
|
+
interface NetworkPlayerHostOptions {
|
|
208
|
+
networkId: string;
|
|
209
|
+
/** Exact trusted reader origins; never '*'. Also bounds incoming article URLs. */
|
|
210
|
+
allowedOrigins: readonly string[];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
interface NetworkAudioProviderProps {
|
|
214
|
+
children: ReactNode;
|
|
215
|
+
/** Resolve through your reader-authorized server route, including publication identity. */
|
|
216
|
+
resolveAudio: ResolveNetworkAudio;
|
|
217
|
+
/** Reader pages: enables the opt-in separate player window and remote bottom bar. */
|
|
218
|
+
connection?: NetworkPlayerConnection;
|
|
219
|
+
/** Dedicated player route: allows only these reader origins to control its audio. */
|
|
220
|
+
host?: NetworkPlayerHostOptions;
|
|
221
|
+
/** Optional sessionStorage checkpoint. Scope by application/network and user; honor consent. Restores paused. */
|
|
222
|
+
checkpointStorageKey?: string;
|
|
223
|
+
}
|
|
224
|
+
interface NetworkAudioContextValue {
|
|
225
|
+
snapshot: NetworkAudioSnapshot;
|
|
226
|
+
remote: boolean;
|
|
227
|
+
hosted: boolean;
|
|
228
|
+
notice: string | null;
|
|
229
|
+
command: (command: NetworkAudioCommand) => void;
|
|
230
|
+
openNetworkPlayer?: () => void;
|
|
231
|
+
highlightEnabled: boolean;
|
|
232
|
+
setHighlightEnabled: (enabled: boolean) => void;
|
|
233
|
+
}
|
|
234
|
+
/** Mount once in a persistent root layout, outside route keys/templates. */
|
|
235
|
+
declare function NetworkAudioProvider({ children, resolveAudio, connection, host, checkpointStorageKey }: NetworkAudioProviderProps): react_jsx_runtime.JSX.Element;
|
|
236
|
+
declare function useNetworkAudio(): NetworkAudioContextValue;
|
|
237
|
+
/** Attach in the article component. Unmount/hidden tab clears only highlighting, never playback. */
|
|
238
|
+
declare function useArticleNarration(track: NetworkAudioTrack, narration?: AudioPlayerNarration): {
|
|
239
|
+
highlightAvailable: boolean;
|
|
240
|
+
highlightEnabled: boolean;
|
|
241
|
+
setHighlightEnabled: (enabled: boolean) => void;
|
|
242
|
+
matching: boolean;
|
|
243
|
+
};
|
|
244
|
+
interface ArticleAudioControlsProps {
|
|
245
|
+
track: NetworkAudioTrack;
|
|
246
|
+
narration?: AudioPlayerNarration;
|
|
247
|
+
className?: string;
|
|
248
|
+
}
|
|
249
|
+
declare function ArticleAudioControls({ track, narration, className }: ArticleAudioControlsProps): react_jsx_runtime.JSX.Element;
|
|
250
|
+
interface NetworkAudioPlayerProps {
|
|
251
|
+
networkName?: string;
|
|
252
|
+
/** Render an actual ad or sponsor creative here. The expanded slot is labeled Advertisement. */
|
|
253
|
+
advertisement?: ReactNode;
|
|
254
|
+
className?: string;
|
|
255
|
+
style?: CSSProperties;
|
|
256
|
+
/** Use false on the dedicated player page; readers default to a fixed bottom bar with a measured spacer. */
|
|
257
|
+
fixed?: boolean;
|
|
258
|
+
/** Supply your router's Link for same-site navigation. The host always opens articles separately. */
|
|
259
|
+
renderArticleLink?: (track: NetworkAudioTrack) => ReactNode;
|
|
260
|
+
}
|
|
261
|
+
declare function NetworkAudioPlayer({ networkName, advertisement, className, style, fixed, renderArticleLink }: NetworkAudioPlayerProps): react_jsx_runtime.JSX.Element | null;
|
|
262
|
+
|
|
263
|
+
export { ArticleAudioControls, type ArticleAudioControlsProps, AudioPlayer, type AudioPlayerNarration, type AudioPlayerProps, type AudioPlayerSource, type AudioPlayerVariant, 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 };
|
package/dist/audio.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { CSSProperties } from 'react';
|
|
2
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
interface AudioPlayerSource {
|
|
5
5
|
url: string | null;
|
|
@@ -132,4 +132,132 @@ declare class NarrationHighlighter {
|
|
|
132
132
|
* common envelopes ({timings}, {data:{timings}}). */
|
|
133
133
|
declare function parseTimingsPayload(body: unknown): NarrationTimings | null;
|
|
134
134
|
|
|
135
|
-
|
|
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
|
+
}
|
|
143
|
+
interface NetworkAudioSnapshot {
|
|
144
|
+
queue: readonly NetworkAudioTrack[];
|
|
145
|
+
index: number;
|
|
146
|
+
position: number;
|
|
147
|
+
duration: number;
|
|
148
|
+
rate: number;
|
|
149
|
+
volume: number;
|
|
150
|
+
status: 'idle' | 'loading' | 'playing' | 'paused' | 'error';
|
|
151
|
+
error: string | null;
|
|
152
|
+
}
|
|
153
|
+
type ResolveNetworkAudio = (track: NetworkAudioTrack, signal: AbortSignal) => Promise<AudioPlayerSource>;
|
|
154
|
+
/** One audio element per persistent layout. Safe to construct during SSR; attach on mount. */
|
|
155
|
+
declare class NetworkAudioController {
|
|
156
|
+
private resolve;
|
|
157
|
+
private snapshot;
|
|
158
|
+
private listeners;
|
|
159
|
+
private audio;
|
|
160
|
+
private cleanup;
|
|
161
|
+
private request;
|
|
162
|
+
private generation;
|
|
163
|
+
private intent;
|
|
164
|
+
private source;
|
|
165
|
+
private refreshed;
|
|
166
|
+
private resumePosition;
|
|
167
|
+
constructor(resolve: ResolveNetworkAudio);
|
|
168
|
+
setResolver(resolve: ResolveNetworkAudio): void;
|
|
169
|
+
getSnapshot: () => NetworkAudioSnapshot;
|
|
170
|
+
subscribe: (listener: () => void) => () => void;
|
|
171
|
+
private patch;
|
|
172
|
+
attach(audio: HTMLAudioElement): void;
|
|
173
|
+
detach(): void;
|
|
174
|
+
enqueue(track: NetworkAudioTrack): number;
|
|
175
|
+
playTrack(track: NetworkAudioTrack): void;
|
|
176
|
+
select(index: number): void;
|
|
177
|
+
remove(index: number): void;
|
|
178
|
+
private cancel;
|
|
179
|
+
pause(): void;
|
|
180
|
+
clear(): void;
|
|
181
|
+
seek(position: number): void;
|
|
182
|
+
setRate(rate: number): void;
|
|
183
|
+
setVolume(volume: number): void;
|
|
184
|
+
restore(snapshot: NetworkAudioSnapshot): void;
|
|
185
|
+
play(): Promise<void>;
|
|
186
|
+
private load;
|
|
187
|
+
private start;
|
|
188
|
+
private recover;
|
|
189
|
+
private fail;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
type NetworkAudioCommand = {
|
|
193
|
+
action: 'play' | 'pause' | 'clear';
|
|
194
|
+
} | {
|
|
195
|
+
action: 'select' | 'remove' | 'seek' | 'rate' | 'volume';
|
|
196
|
+
value: number;
|
|
197
|
+
} | {
|
|
198
|
+
action: 'enqueue' | 'playTrack';
|
|
199
|
+
track: NetworkAudioTrack;
|
|
200
|
+
};
|
|
201
|
+
interface NetworkPlayerConnection {
|
|
202
|
+
/** Fully qualified, dedicated player route; never the article route. */
|
|
203
|
+
playerUrl: string;
|
|
204
|
+
/** Same namespace on all participating publications. */
|
|
205
|
+
networkId: string;
|
|
206
|
+
}
|
|
207
|
+
interface NetworkPlayerHostOptions {
|
|
208
|
+
networkId: string;
|
|
209
|
+
/** Exact trusted reader origins; never '*'. Also bounds incoming article URLs. */
|
|
210
|
+
allowedOrigins: readonly string[];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
interface NetworkAudioProviderProps {
|
|
214
|
+
children: ReactNode;
|
|
215
|
+
/** Resolve through your reader-authorized server route, including publication identity. */
|
|
216
|
+
resolveAudio: ResolveNetworkAudio;
|
|
217
|
+
/** Reader pages: enables the opt-in separate player window and remote bottom bar. */
|
|
218
|
+
connection?: NetworkPlayerConnection;
|
|
219
|
+
/** Dedicated player route: allows only these reader origins to control its audio. */
|
|
220
|
+
host?: NetworkPlayerHostOptions;
|
|
221
|
+
/** Optional sessionStorage checkpoint. Scope by application/network and user; honor consent. Restores paused. */
|
|
222
|
+
checkpointStorageKey?: string;
|
|
223
|
+
}
|
|
224
|
+
interface NetworkAudioContextValue {
|
|
225
|
+
snapshot: NetworkAudioSnapshot;
|
|
226
|
+
remote: boolean;
|
|
227
|
+
hosted: boolean;
|
|
228
|
+
notice: string | null;
|
|
229
|
+
command: (command: NetworkAudioCommand) => void;
|
|
230
|
+
openNetworkPlayer?: () => void;
|
|
231
|
+
highlightEnabled: boolean;
|
|
232
|
+
setHighlightEnabled: (enabled: boolean) => void;
|
|
233
|
+
}
|
|
234
|
+
/** Mount once in a persistent root layout, outside route keys/templates. */
|
|
235
|
+
declare function NetworkAudioProvider({ children, resolveAudio, connection, host, checkpointStorageKey }: NetworkAudioProviderProps): react_jsx_runtime.JSX.Element;
|
|
236
|
+
declare function useNetworkAudio(): NetworkAudioContextValue;
|
|
237
|
+
/** Attach in the article component. Unmount/hidden tab clears only highlighting, never playback. */
|
|
238
|
+
declare function useArticleNarration(track: NetworkAudioTrack, narration?: AudioPlayerNarration): {
|
|
239
|
+
highlightAvailable: boolean;
|
|
240
|
+
highlightEnabled: boolean;
|
|
241
|
+
setHighlightEnabled: (enabled: boolean) => void;
|
|
242
|
+
matching: boolean;
|
|
243
|
+
};
|
|
244
|
+
interface ArticleAudioControlsProps {
|
|
245
|
+
track: NetworkAudioTrack;
|
|
246
|
+
narration?: AudioPlayerNarration;
|
|
247
|
+
className?: string;
|
|
248
|
+
}
|
|
249
|
+
declare function ArticleAudioControls({ track, narration, className }: ArticleAudioControlsProps): react_jsx_runtime.JSX.Element;
|
|
250
|
+
interface NetworkAudioPlayerProps {
|
|
251
|
+
networkName?: string;
|
|
252
|
+
/** Render an actual ad or sponsor creative here. The expanded slot is labeled Advertisement. */
|
|
253
|
+
advertisement?: ReactNode;
|
|
254
|
+
className?: string;
|
|
255
|
+
style?: CSSProperties;
|
|
256
|
+
/** Use false on the dedicated player page; readers default to a fixed bottom bar with a measured spacer. */
|
|
257
|
+
fixed?: boolean;
|
|
258
|
+
/** Supply your router's Link for same-site navigation. The host always opens articles separately. */
|
|
259
|
+
renderArticleLink?: (track: NetworkAudioTrack) => ReactNode;
|
|
260
|
+
}
|
|
261
|
+
declare function NetworkAudioPlayer({ networkName, advertisement, className, style, fixed, renderArticleLink }: NetworkAudioPlayerProps): react_jsx_runtime.JSX.Element | null;
|
|
262
|
+
|
|
263
|
+
export { ArticleAudioControls, type ArticleAudioControlsProps, AudioPlayer, type AudioPlayerNarration, type AudioPlayerProps, type AudioPlayerSource, type AudioPlayerVariant, 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 };
|