@dataimago/ui 0.1.0-alpha.35 → 0.1.0-alpha.42

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/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import React__default from 'react';
2
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
4
  import { LogoId, LogoVariant, AnimationId, NavbarLogoId } from '@dataimago/brand';
4
5
 
@@ -351,4 +352,157 @@ interface ThemeScriptProps {
351
352
  */
352
353
  declare function ThemeScript({ nonce }: ThemeScriptProps): react_jsx_runtime.JSX.Element;
353
354
 
354
- export { BrandAnimation, type BrandAnimationProps, Button, type ButtonProps, type ButtonSize, type ButtonVariant, type CopulaLinkProps, CopulaLockup, type CopulaLockupProps, Logo, LogoMonogram, LogoMonogramBg, type LogoMonogramBgProps, type LogoMonogramProps, type LogoProps, LogoWordmark, type LogoWordmarkProps, NavbarLogo, type NavbarLogoProps, type ResolvedTheme, THEME_ATTRIBUTE, THEME_STORAGE_KEY, type ThemePreference, ThemeScript, type ThemeScriptProps, ThemeToggle, type ThemeToggleLabels, type ThemeToggleProps, nextThemePreference, readThemePreference, resolveTheme, setThemePreference, themeInitScript, useResolvedTheme, useThemePreference };
355
+ /** The captions file a video release carries beside its WebVTT fallback. */
356
+ declare const CAPTIONS_SCHEMA = "dataimago.video_captions.v1";
357
+ type CaptionTreatment = 'editorial' | 'frosted' | 'boxed';
358
+ interface CaptionWord {
359
+ /** The word as the script spells it; inline math stays a `$…$` span. */
360
+ text: string;
361
+ /** Spoken start, in the page's time unit: the word tones from inkMute to ink from here. */
362
+ at: number;
363
+ /** The line of the page the word sits on. */
364
+ line: number;
365
+ /** MathML for the word's `$…$` span, rendered by the foundry (Temml) at export. */
366
+ math?: string;
367
+ }
368
+ interface CaptionPage {
369
+ start: number;
370
+ end: number;
371
+ lines: string[];
372
+ words: CaptionWord[];
373
+ }
374
+ interface CaptionTrack {
375
+ schema: typeof CAPTIONS_SCHEMA;
376
+ work: string;
377
+ version: string;
378
+ lang: string;
379
+ style: {
380
+ profile: string;
381
+ treatment: CaptionTreatment;
382
+ /** Font weight of the caption text (400 when boxed). */
383
+ weight: number;
384
+ /** How long a word takes to tone from inkMute to ink, in seconds. */
385
+ toneSeconds: number;
386
+ lineHeight: number;
387
+ /** The profile's colour tokens (`color.palette.<scale>.<step>`); the player maps them to CSS variables. */
388
+ colors?: {
389
+ paper: string;
390
+ ink: string;
391
+ inkMute: string;
392
+ };
393
+ };
394
+ /** The canvas the captions were laid out on, in pixels: scale everything by displayed width ÷ width. */
395
+ frame: {
396
+ width: number;
397
+ height: number;
398
+ fontSize: number;
399
+ safe: {
400
+ top: number;
401
+ right: number;
402
+ bottom: number;
403
+ left: number;
404
+ };
405
+ };
406
+ /** In seconds from the start of the video, in order, never overlapping. */
407
+ pages: CaptionPage[];
408
+ }
409
+ /** The page on screen at time t (start ≤ t < end), if any. Pages must be in order. */
410
+ declare function pageAt<P extends {
411
+ start: number;
412
+ end: number;
413
+ }>(pages: readonly P[], t: number): P | undefined;
414
+ /** How far a word has toned toward ink at time t: 0 before it is spoken, 1 once it has settled. */
415
+ declare function wordTone(at: number, t: number, span: number): number;
416
+ /** The colour for a tone between inkMute (0) and ink (1). */
417
+ declare function toneColor(tone: number, ink: string, inkMute: string): string;
418
+ /** A word's text split around its `$…$` span, or null when it carries no math. */
419
+ declare function splitMath(text: string): {
420
+ before: string;
421
+ tex: string;
422
+ after: string;
423
+ } | null;
424
+ /** A palette token path as a CSS variable (`color.palette.stone.50` → `var(--color-palette-stone-50)`), or null if it is not one. */
425
+ declare function paletteVar(token: string): string | null;
426
+ type CaptionStyle = Record<string, string | number>;
427
+ interface CaptionLook {
428
+ /** The panel around the lines. */
429
+ panel: CaptionStyle;
430
+ /** The text block: family, weight, size, line height. */
431
+ text: CaptionStyle;
432
+ /** Extra lift above the safe area, in pixels, so a panel's soft shadow stays inside it too. */
433
+ lift: number;
434
+ /** Whether words tone from inkMute to ink (boxed captions are one colour). */
435
+ toned: boolean;
436
+ }
437
+ /**
438
+ * The treatment at one size. `scale` multiplies the profile's fixed pixel measures
439
+ * (blur, border, radius on a boxed panel) and is 1 on the foundry's canvas.
440
+ */
441
+ declare function captionLook(treatment: CaptionTreatment, o: {
442
+ size: number;
443
+ scale: number;
444
+ weight: number;
445
+ lineHeight: number;
446
+ family: string;
447
+ ink: string;
448
+ paper: string;
449
+ }): CaptionLook;
450
+
451
+ interface CaptionedVideoProps {
452
+ src: string;
453
+ /** The release's poster frame: required, as the player shows it until the reader presses play (explanatory-video-carve-out, decision 2). */
454
+ poster: string;
455
+ /** The release's captions file (dataimago.video_captions.v1): pages, word timing, MathML. */
456
+ captions: string;
457
+ /** The release's WebVTT captions: the native track, and the text drawn if `captions` fails to load. */
458
+ fallbackCaptions: string;
459
+ /** The release's WebVTT chapters. */
460
+ chapters?: string;
461
+ /** The video's accessible name. */
462
+ title: string;
463
+ /** BCP 47 language of the captions. */
464
+ lang?: string;
465
+ className?: string;
466
+ style?: React__default.CSSProperties;
467
+ }
468
+ /** Where the reader's captions choice is kept (per browser). */
469
+ declare const CAPTIONS_STORAGE_KEY = "dataimago:video-captions";
470
+ /** A captions file the layer can draw; anything else takes the WebVTT fallback. */
471
+ declare function isCaptionTrack(x: unknown): x is CaptionTrack;
472
+ /**
473
+ * A video with the dataimago caption treatment drawn over it: the foundry's fonts,
474
+ * word tone and mathematics, from the release's captions file. The native WebVTT
475
+ * track stays hidden underneath, for assistive technology and as the fallback text.
476
+ * Fullscreen takes the whole player, so the captions come along.
477
+ */
478
+ declare const CaptionedVideo: React__default.FC<CaptionedVideoProps>;
479
+
480
+ interface CaptionLayerProps {
481
+ track: CaptionTrack;
482
+ /** Seconds into the video. */
483
+ time: number;
484
+ /** The video's displayed width in CSS pixels; size and insets scale from the track's canvas. */
485
+ width: number;
486
+ /**
487
+ * Show each page in full ink, as the foundry's reduced-motion render does. Defaults to
488
+ * true, the safe side; pass the reader's `prefers-reduced-motion` (CaptionedVideo does).
489
+ */
490
+ reducedMotion?: boolean;
491
+ /**
492
+ * Keep the captions at least this far above the bottom edge, in CSS pixels (the
493
+ * player's controls). They move up only when their own place would sit lower.
494
+ */
495
+ clearance?: number;
496
+ /** A page to show instead of the track's (the WebVTT fallback, already in full ink). */
497
+ page?: CaptionPage | null;
498
+ }
499
+ /**
500
+ * The captions over a video, in the foundry's treatment, at time `time`. Pure
501
+ * presentation: the caller supplies the clock and the size. The drawn layer is hidden
502
+ * from assistive technology; the current page is also present as visually hidden plain
503
+ * text, not a live region, so a braille or screen-reader user can find it without every
504
+ * line being spoken over the narration.
505
+ */
506
+ declare const CaptionLayer: React__default.FC<CaptionLayerProps>;
507
+
508
+ export { BrandAnimation, type BrandAnimationProps, Button, type ButtonProps, type ButtonSize, type ButtonVariant, CAPTIONS_SCHEMA, CAPTIONS_STORAGE_KEY, CaptionLayer, type CaptionLayerProps, type CaptionLook, type CaptionPage, type CaptionTrack, type CaptionTreatment, type CaptionWord, CaptionedVideo, type CaptionedVideoProps, type CopulaLinkProps, CopulaLockup, type CopulaLockupProps, Logo, LogoMonogram, LogoMonogramBg, type LogoMonogramBgProps, type LogoMonogramProps, type LogoProps, LogoWordmark, type LogoWordmarkProps, NavbarLogo, type NavbarLogoProps, type ResolvedTheme, THEME_ATTRIBUTE, THEME_STORAGE_KEY, type ThemePreference, ThemeScript, type ThemeScriptProps, ThemeToggle, type ThemeToggleLabels, type ThemeToggleProps, captionLook, isCaptionTrack, nextThemePreference, pageAt, paletteVar, readThemePreference, resolveTheme, setThemePreference, splitMath, themeInitScript, toneColor, useResolvedTheme, useThemePreference, wordTone };