@dawcore/components 0.0.24 → 0.0.26

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.mts CHANGED
@@ -281,17 +281,14 @@ declare global {
281
281
  }
282
282
 
283
283
  declare class DawPlayheadElement extends LitElement {
284
- private _animation;
285
284
  private _line;
286
285
  static styles: lit.CSSResult;
287
286
  render(): lit.TemplateResult<1>;
288
287
  firstUpdated(): void;
289
- startAnimation(getTime: () => number, sampleRate: number, samplesPerPixel: number): void;
290
- stopAnimation(time: number, sampleRate: number, samplesPerPixel: number): void;
291
- startBeatsAnimation(getTime: () => number, bpm: number, ppqn: number, ticksPerPixel: number): void;
292
- stopBeatsAnimation(time: number, bpm: number, ppqn: number, ticksPerPixel: number): void;
293
- startBeatsAnimationWithMap(getTime: () => number, secondsToTicks: (s: number) => number, ticksPerPixel: number): void;
294
- stopBeatsAnimationWithMap(time: number, secondsToTicks: (s: number) => number, ticksPerPixel: number): void;
288
+ /** Position the playhead line at an absolute pixel offset on the timeline.
289
+ * The editor's PlaybackAnimationController drives this each frame — the
290
+ * playhead owns no animation loop or time math of its own. */
291
+ setPosition(px: number): void;
295
292
  }
296
293
  declare global {
297
294
  interface HTMLElementTagNameMap {
@@ -312,10 +309,28 @@ declare global {
312
309
 
313
310
  /**
314
311
  * Base class for transport button elements.
315
- * Finds target daw-editor via closest <daw-transport>.
312
+ * Finds target via closest <daw-transport>. Capability detection is
313
+ * duck-typed (#474): subclasses declare requiredTargetMethods and render
314
+ * `?disabled=${!this.targetSupported}`; targets lacking the methods get a
315
+ * disabled control and a one-time console warning on interaction.
316
316
  */
317
317
  declare class DawTransportButton extends LitElement {
318
+ /** Methods the transport target must implement for this control to be
319
+ * enabled. Empty = works with any target. */
320
+ protected static requiredTargetMethods: readonly string[];
318
321
  protected get target(): any;
322
+ private get _requiredMethods();
323
+ /**
324
+ * False when this control declares requirements its target doesn't meet.
325
+ * An undetermined target (missing, or a not-yet-upgraded custom element)
326
+ * gets the benefit of the doubt and stays enabled — click-time resolution
327
+ * warns if it's still unusable.
328
+ */
329
+ protected get targetSupported(): boolean;
330
+ connectedCallback(): void;
331
+ disconnectedCallback(): void;
332
+ private _onCapabilityPointerEnter;
333
+ private _onCapabilityPointerDown;
319
334
  static styles: lit.CSSResultGroup;
320
335
  }
321
336
 
@@ -630,6 +645,14 @@ interface RecordingOptions {
630
645
  startSample?: number;
631
646
  /** Start playback during recording so user hears existing tracks. */
632
647
  overdub?: boolean;
648
+ /**
649
+ * Latency offset to skip at the start of the recording, in **seconds**.
650
+ * Absolute replacement for the auto-computed `outputLatency`-based value —
651
+ * use this to apply an externally-measured round-trip latency. `0` disables
652
+ * compensation; when omitted, the auto-computed value is used.
653
+ * Negative or non-finite values are treated as 0.
654
+ */
655
+ latencyOffset?: number;
633
656
  }
634
657
  interface RecordingSession {
635
658
  readonly trackId: string;
@@ -831,6 +854,20 @@ declare class ClipPointerHandler {
831
854
  private _reset;
832
855
  }
833
856
 
857
+ /**
858
+ * Time display formats for <daw-time-display> / <daw-time-format> and the
859
+ * editor's `time-format` attribute. The three formats come from the
860
+ * web-components-migration spec ("Element Registry": hh:mm:ss.sss | hh:mm:ss
861
+ * | seconds). parseDisplayTime exists for the selection inputs (#463).
862
+ */
863
+ type TimeDisplayFormat = 'hh:mm:ss.sss' | 'hh:mm:ss' | 'seconds';
864
+ declare const TIME_DISPLAY_FORMATS: readonly TimeDisplayFormat[];
865
+ declare function isTimeDisplayFormat(value: unknown): value is TimeDisplayFormat;
866
+ /** Format seconds for display. Non-finite or negative input renders as 0. */
867
+ declare function formatDisplayTime(seconds: number, format: TimeDisplayFormat): string;
868
+ /** Parse a formatted time string back to seconds. Lenient: returns 0 for empty/unparseable input; does not validate segment ranges. */
869
+ declare function parseDisplayTime(value: string, format: TimeDisplayFormat): number;
870
+
834
871
  interface DawSelectionDetail {
835
872
  start: number;
836
873
  end: number;
@@ -838,6 +875,13 @@ interface DawSelectionDetail {
838
875
  interface DawSeekDetail {
839
876
  time: number;
840
877
  }
878
+ interface DawTimeUpdateDetail {
879
+ /** Current playback time in seconds (latency-compensated while playing). */
880
+ time: number;
881
+ }
882
+ interface DawTimeFormatChangeDetail {
883
+ format: TimeDisplayFormat;
884
+ }
841
885
  interface DawTrackSelectDetail {
842
886
  trackId: string;
843
887
  }
@@ -978,6 +1022,8 @@ interface DawEffectErrorDetail {
978
1022
  interface DawEventMap {
979
1023
  'daw-selection': CustomEvent<DawSelectionDetail>;
980
1024
  'daw-seek': CustomEvent<DawSeekDetail>;
1025
+ 'daw-timeupdate': CustomEvent<DawTimeUpdateDetail>;
1026
+ 'daw-time-format-change': CustomEvent<DawTimeFormatChangeDetail>;
981
1027
  'daw-track-select': CustomEvent<DawTrackSelectDetail>;
982
1028
  'daw-track-connected': CustomEvent<DawTrackConnectedDetail>;
983
1029
  'daw-track-update': CustomEvent<DawTrackIdDetail>;
@@ -1082,6 +1128,16 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1082
1128
  get samplesPerPixel(): number;
1083
1129
  set samplesPerPixel(value: number);
1084
1130
  private _samplesPerPixel;
1131
+ private _timeFormat;
1132
+ /**
1133
+ * Time display format used by <daw-time-display> and (future, #463) the
1134
+ * selection inputs. Lives on the editor — the target element owns the
1135
+ * state, the transport controls reflect it (native-form style).
1136
+ */
1137
+ get timeFormat(): TimeDisplayFormat;
1138
+ set timeFormat(value: TimeDisplayFormat);
1139
+ /** Set the time display format. Sugar over the `timeFormat` property. */
1140
+ setTimeFormat(format: TimeDisplayFormat): void;
1085
1141
  waveHeight: number;
1086
1142
  timescale: boolean;
1087
1143
  mono: boolean;
@@ -1251,6 +1307,14 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1251
1307
  private _audioResume;
1252
1308
  eagerResume?: string;
1253
1309
  private _recordingController;
1310
+ private _playbackAnimation;
1311
+ /**
1312
+ * True while a seek-while-playing stop+play transition is in flight.
1313
+ * Suppresses the transient settle dispatch from the engine 'stop' handler
1314
+ * (which would otherwise leak a backward-jumping daw-timeupdate at the
1315
+ * play-start position). Non-private: pointer-handler's seek path sets it.
1316
+ */
1317
+ _inSeekTransition: boolean;
1254
1318
  private _spectrogramController;
1255
1319
  private _clipPointer;
1256
1320
  get _clipHandler(): ClipPointerHandler | null;
@@ -1476,6 +1540,10 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1476
1540
  splitAtPlayhead(): boolean;
1477
1541
  recordingStream: MediaStream | null;
1478
1542
  get currentTime(): number;
1543
+ /** Read-only: whether playback is running (HTMLMediaElement-adjacent). */
1544
+ get isPlaying(): boolean;
1545
+ /** Read-only: total content duration in seconds. */
1546
+ get duration(): number;
1479
1547
  get isRecording(): boolean;
1480
1548
  get isRecordingPaused(): boolean;
1481
1549
  pauseRecording(): void;
@@ -1497,6 +1565,8 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1497
1565
  createMediaStreamSource(stream: MediaStream): MediaStreamAudioSourceNode;
1498
1566
  startRecording(stream?: MediaStream, options?: RecordingOptions): Promise<void>;
1499
1567
  private _renderRecordingPreview;
1568
+ /** Convert playback seconds to a timeline pixel offset for the active mode. */
1569
+ private _timeToPixels;
1500
1570
  _startPlayhead(): void;
1501
1571
  _stopPlayhead(): void;
1502
1572
  private _getPlayhead;
@@ -1526,6 +1596,7 @@ declare global {
1526
1596
  }
1527
1597
 
1528
1598
  declare class DawRecordButtonElement extends DawTransportButton {
1599
+ protected static requiredTargetMethods: readonly string[];
1529
1600
  private _isRecording;
1530
1601
  private _targetRef;
1531
1602
  private _onStart;
@@ -1638,6 +1709,69 @@ declare global {
1638
1709
  }
1639
1710
  }
1640
1711
 
1712
+ /**
1713
+ * Formatted playback time readout for <daw-transport>.
1714
+ *
1715
+ * Subscribes to bubbled `daw-timeupdate` / `daw-time-format-change` events at
1716
+ * the document level and filters by its transport target — works with any
1717
+ * target that dispatches them (<daw-editor> today, <daw-player> later) and
1718
+ * tolerates targets that upgrade after this element connects.
1719
+ *
1720
+ * Accessibility (spec): role="status", aria-live="off" — not announced every
1721
+ * frame; screen reader users query on demand.
1722
+ */
1723
+ declare class DawTimeDisplayElement extends LitElement {
1724
+ /** Null until the first successful target sync or daw-timeupdate. */
1725
+ private _time;
1726
+ private _format;
1727
+ static styles: lit.CSSResult;
1728
+ private get target();
1729
+ private _onTimeUpdate;
1730
+ private _onFormatChange;
1731
+ connectedCallback(): void;
1732
+ disconnectedCallback(): void;
1733
+ private _syncFromTarget;
1734
+ render(): lit.TemplateResult<1>;
1735
+ }
1736
+ declare global {
1737
+ interface HTMLElementTagNameMap {
1738
+ 'daw-time-display': DawTimeDisplayElement;
1739
+ }
1740
+ }
1741
+
1742
+ /**
1743
+ * Time format select for <daw-transport>. Sets the format ON the target
1744
+ * (`target.setTimeFormat(...)`) — the target owns the state (native-form
1745
+ * style), and every display/input syncs via the bubbled
1746
+ * `daw-time-format-change` event. Renders disabled when the target doesn't
1747
+ * implement setTimeFormat (duck-typed capability detection, #474).
1748
+ */
1749
+ declare class DawTimeFormatElement extends LitElement {
1750
+ private _format;
1751
+ static styles: lit.CSSResult;
1752
+ private get target();
1753
+ /**
1754
+ * False when the target doesn't implement setTimeFormat. An undetermined
1755
+ * target (missing, or a not-yet-upgraded custom element) gets the benefit
1756
+ * of the doubt and stays enabled — interaction-time resolution warns if
1757
+ * it's still unusable.
1758
+ */
1759
+ private get _targetSupported();
1760
+ private _onFormatChange;
1761
+ private _onPointerEnter;
1762
+ private _onPointerDown;
1763
+ connectedCallback(): void;
1764
+ disconnectedCallback(): void;
1765
+ protected updated(): void;
1766
+ private _onSelectChange;
1767
+ render(): lit.TemplateResult<1>;
1768
+ }
1769
+ declare global {
1770
+ interface HTMLElementTagNameMap {
1771
+ 'daw-time-format': DawTimeFormatElement;
1772
+ }
1773
+ }
1774
+
1641
1775
  interface SpectrogramControllerHost extends ReactiveControllerHost {
1642
1776
  dispatchEvent(event: Event): boolean;
1643
1777
  }
@@ -1701,6 +1835,78 @@ declare class AudioResumeController implements ReactiveController {
1701
1835
  private _removeListeners;
1702
1836
  }
1703
1837
 
1838
+ interface PlayheadLike {
1839
+ setPosition(px: number): void;
1840
+ }
1841
+ interface PlaybackAnimationOptions {
1842
+ /** Convert playback seconds to a timeline pixel offset. */
1843
+ timeToPixels: (time: number) => number;
1844
+ /** Resolve the playhead element (re-queried per call — templates may recreate it). */
1845
+ getPlayhead: () => PlayheadLike | null;
1846
+ }
1847
+ /**
1848
+ * The single editor-owned playback animation loop (mirror of the React
1849
+ * `usePlaybackAnimation` pattern). Each frame reads the latency-compensated
1850
+ * playback time ONCE, positions the playhead, and dispatches `daw-timeupdate`
1851
+ * from the host element. External consumers hook into the same loop by
1852
+ * listening for `daw-timeupdate` — never add a second RAF loop for
1853
+ * playback-time concerns.
1854
+ *
1855
+ * `timeToPixels` and `getPlayhead` are injected once at construction — they
1856
+ * are stable per host, and threading them through every `start`/`stop` call
1857
+ * invited desync between the two call sites.
1858
+ *
1859
+ * HTMLMediaElement-adjacent: `stop()` dispatches one final event so idle
1860
+ * displays settle on the exact commanded position (media elements fire
1861
+ * `timeupdate` on pause and seek too). Pass `{ dispatch: false }` for
1862
+ * transitional stops (stop+play seeks) whose settle position must not leak
1863
+ * to consumers.
1864
+ */
1865
+ declare class PlaybackAnimationController {
1866
+ private _animation;
1867
+ private _host;
1868
+ private _options;
1869
+ private _running;
1870
+ private _lastDispatchedTime;
1871
+ constructor(host: ReactiveControllerHost & HTMLElement, options: PlaybackAnimationOptions);
1872
+ start(getTime: () => number): void;
1873
+ stop(finalTime: number, opts?: {
1874
+ dispatch?: boolean;
1875
+ }): void;
1876
+ private _dispatchTimeUpdate;
1877
+ }
1878
+
1879
+ /**
1880
+ * Transport target resolution + duck-typed capability detection.
1881
+ *
1882
+ * Transport controls never instanceof-check their target — they probe for the
1883
+ * methods they need (`typeof target[m] === 'function'`). This is what lets the
1884
+ * same controls drive <daw-editor>, the future <daw-player> (#454), or any
1885
+ * conforming element, and lets editor-only controls render disabled against a
1886
+ * player (#474, spec "Transport Compatibility").
1887
+ */
1888
+ /**
1889
+ * Resolve the target of the closest <daw-transport for="..."> ancestor.
1890
+ * Walks light-DOM ancestors only (`closest` does not cross shadow boundaries).
1891
+ */
1892
+ declare function resolveTransportTarget(el: Element): HTMLElement | null;
1893
+ /** True when target exists and every named method is a function on it. */
1894
+ declare function targetSupports(target: unknown, methods: readonly string[]): boolean;
1895
+ /**
1896
+ * One-time console warning for a transport control.
1897
+ * Dedup is per element per message — distinct messages on the same element
1898
+ * each warn once, while repeats of the same message stay silent. A
1899
+ * missing-target warn and an unsupported-target warn no longer suppress each
1900
+ * other.
1901
+ */
1902
+ declare function warnOnce(element: Element, message: string): void;
1903
+ /**
1904
+ * One-time console warning explaining why a control is disabled.
1905
+ * Delegates to {@link warnOnce} — an element that already triggered a
1906
+ * missing-target warn will not warn again here.
1907
+ */
1908
+ declare function warnUnsupportedOnce(element: Element, methods: readonly string[]): void;
1909
+
1704
1910
  /** Narrow engine contract for pointer interactions. */
1705
1911
  interface PointerEngineContract {
1706
1912
  setSelection(start: number, end: number): void;
@@ -1743,4 +1949,4 @@ declare function registerEffect(type: string, definition: EffectDefinition): voi
1743
1949
  declare function getEffectDefinitions(): Map<string, EffectDefinition>;
1744
1950
  declare function createEffectInstance(type: string, audioContext: BaseAudioContext, params?: Record<string, number>): CreatedEffect;
1745
1951
 
1746
- export { AudioResumeController, type ClipConfig, type ClipDescriptor, type ClipEngineContract, ClipPointerHandler, type ClipPointerHost, type DawClipConnectedDetail, DawClipElement, type DawClipErrorDetail, type DawClipIdDetail, type DawClipMoveDetail, type DawClipSplitDetail, type DawClipTrimDetail, type DawClipUpdateDetail, DawEditorElement, type DawEffectAddDetail, type DawEffectBypassDetail, type DawEffectChangeDetail, type DawEffectErrorDetail, type DawEffectRemoveDetail, type DawEffectReorderDetail, type DawErrorDetail, type DawEvent, type DawEventMap, type DawFilesLoadErrorDetail, DawGridElement, DawKeyboardShortcutsElement, DawPauseButtonElement, DawPianoRollElement, DawPlayButtonElement, DawPlayheadElement, DawRecordButtonElement, type DawRecordingCompleteDetail, type DawRecordingErrorDetail, type DawRecordingStartDetail, DawRulerElement, type DawSeekDetail, type DawSelectionDetail, DawSelectionElement, DawSpectrogramElement, DawStopButtonElement, type DawTrackConnectedDetail, type DawTrackControlDetail, DawTrackControlsElement, DawTrackElement, type DawTrackErrorDetail, type DawTrackIdDetail, type DawTrackRemoveDetail, type DawTrackSelectDetail, DawTransportButton, DawTransportElement, DawWaveformElement, type DomClipDescriptor, type DropClipDescriptor, type EffectDefinition, type EffectInstance, type EffectParamDef, type EffectState, type ExportAudioHost, type ExportOptions, type KeyBinding, type LoadFilesResult, type PlaybackShortcutMap, type PointerEngineContract, RecordingController, type RecordingOptions, type RecordingSession, type SerializedEffectEntry, SpectrogramController, type SplitEngineContract, type SplitHost, type SplittingShortcutMap, type TrackConfig, type TrackDescriptor, type TrackRenderMode, type UndoShortcutMap, type WaveformSegment, createEffectInstance, getEffectDefinitions, isDomClip, registerEffect, splitAtPlayhead };
1952
+ export { AudioResumeController, type ClipConfig, type ClipDescriptor, type ClipEngineContract, ClipPointerHandler, type ClipPointerHost, type DawClipConnectedDetail, DawClipElement, type DawClipErrorDetail, type DawClipIdDetail, type DawClipMoveDetail, type DawClipSplitDetail, type DawClipTrimDetail, type DawClipUpdateDetail, DawEditorElement, type DawEffectAddDetail, type DawEffectBypassDetail, type DawEffectChangeDetail, type DawEffectErrorDetail, type DawEffectRemoveDetail, type DawEffectReorderDetail, type DawErrorDetail, type DawEvent, type DawEventMap, type DawFilesLoadErrorDetail, DawGridElement, DawKeyboardShortcutsElement, DawPauseButtonElement, DawPianoRollElement, DawPlayButtonElement, DawPlayheadElement, DawRecordButtonElement, type DawRecordingCompleteDetail, type DawRecordingErrorDetail, type DawRecordingStartDetail, DawRulerElement, type DawSeekDetail, type DawSelectionDetail, DawSelectionElement, DawSpectrogramElement, DawStopButtonElement, DawTimeDisplayElement, type DawTimeFormatChangeDetail, DawTimeFormatElement, type DawTimeUpdateDetail, type DawTrackConnectedDetail, type DawTrackControlDetail, DawTrackControlsElement, DawTrackElement, type DawTrackErrorDetail, type DawTrackIdDetail, type DawTrackRemoveDetail, type DawTrackSelectDetail, DawTransportButton, DawTransportElement, DawWaveformElement, type DomClipDescriptor, type DropClipDescriptor, type EffectDefinition, type EffectInstance, type EffectParamDef, type EffectState, type ExportAudioHost, type ExportOptions, type KeyBinding, type LoadFilesResult, PlaybackAnimationController, type PlaybackAnimationOptions, type PlaybackShortcutMap, type PlayheadLike, type PointerEngineContract, RecordingController, type RecordingOptions, type RecordingSession, type SerializedEffectEntry, SpectrogramController, type SplitEngineContract, type SplitHost, type SplittingShortcutMap, TIME_DISPLAY_FORMATS, type TimeDisplayFormat, type TrackConfig, type TrackDescriptor, type TrackRenderMode, type UndoShortcutMap, type WaveformSegment, createEffectInstance, formatDisplayTime, getEffectDefinitions, isDomClip, isTimeDisplayFormat, parseDisplayTime, registerEffect, resolveTransportTarget, splitAtPlayhead, targetSupports, warnOnce, warnUnsupportedOnce };
package/dist/index.d.ts CHANGED
@@ -281,17 +281,14 @@ declare global {
281
281
  }
282
282
 
283
283
  declare class DawPlayheadElement extends LitElement {
284
- private _animation;
285
284
  private _line;
286
285
  static styles: lit.CSSResult;
287
286
  render(): lit.TemplateResult<1>;
288
287
  firstUpdated(): void;
289
- startAnimation(getTime: () => number, sampleRate: number, samplesPerPixel: number): void;
290
- stopAnimation(time: number, sampleRate: number, samplesPerPixel: number): void;
291
- startBeatsAnimation(getTime: () => number, bpm: number, ppqn: number, ticksPerPixel: number): void;
292
- stopBeatsAnimation(time: number, bpm: number, ppqn: number, ticksPerPixel: number): void;
293
- startBeatsAnimationWithMap(getTime: () => number, secondsToTicks: (s: number) => number, ticksPerPixel: number): void;
294
- stopBeatsAnimationWithMap(time: number, secondsToTicks: (s: number) => number, ticksPerPixel: number): void;
288
+ /** Position the playhead line at an absolute pixel offset on the timeline.
289
+ * The editor's PlaybackAnimationController drives this each frame — the
290
+ * playhead owns no animation loop or time math of its own. */
291
+ setPosition(px: number): void;
295
292
  }
296
293
  declare global {
297
294
  interface HTMLElementTagNameMap {
@@ -312,10 +309,28 @@ declare global {
312
309
 
313
310
  /**
314
311
  * Base class for transport button elements.
315
- * Finds target daw-editor via closest <daw-transport>.
312
+ * Finds target via closest <daw-transport>. Capability detection is
313
+ * duck-typed (#474): subclasses declare requiredTargetMethods and render
314
+ * `?disabled=${!this.targetSupported}`; targets lacking the methods get a
315
+ * disabled control and a one-time console warning on interaction.
316
316
  */
317
317
  declare class DawTransportButton extends LitElement {
318
+ /** Methods the transport target must implement for this control to be
319
+ * enabled. Empty = works with any target. */
320
+ protected static requiredTargetMethods: readonly string[];
318
321
  protected get target(): any;
322
+ private get _requiredMethods();
323
+ /**
324
+ * False when this control declares requirements its target doesn't meet.
325
+ * An undetermined target (missing, or a not-yet-upgraded custom element)
326
+ * gets the benefit of the doubt and stays enabled — click-time resolution
327
+ * warns if it's still unusable.
328
+ */
329
+ protected get targetSupported(): boolean;
330
+ connectedCallback(): void;
331
+ disconnectedCallback(): void;
332
+ private _onCapabilityPointerEnter;
333
+ private _onCapabilityPointerDown;
319
334
  static styles: lit.CSSResultGroup;
320
335
  }
321
336
 
@@ -630,6 +645,14 @@ interface RecordingOptions {
630
645
  startSample?: number;
631
646
  /** Start playback during recording so user hears existing tracks. */
632
647
  overdub?: boolean;
648
+ /**
649
+ * Latency offset to skip at the start of the recording, in **seconds**.
650
+ * Absolute replacement for the auto-computed `outputLatency`-based value —
651
+ * use this to apply an externally-measured round-trip latency. `0` disables
652
+ * compensation; when omitted, the auto-computed value is used.
653
+ * Negative or non-finite values are treated as 0.
654
+ */
655
+ latencyOffset?: number;
633
656
  }
634
657
  interface RecordingSession {
635
658
  readonly trackId: string;
@@ -831,6 +854,20 @@ declare class ClipPointerHandler {
831
854
  private _reset;
832
855
  }
833
856
 
857
+ /**
858
+ * Time display formats for <daw-time-display> / <daw-time-format> and the
859
+ * editor's `time-format` attribute. The three formats come from the
860
+ * web-components-migration spec ("Element Registry": hh:mm:ss.sss | hh:mm:ss
861
+ * | seconds). parseDisplayTime exists for the selection inputs (#463).
862
+ */
863
+ type TimeDisplayFormat = 'hh:mm:ss.sss' | 'hh:mm:ss' | 'seconds';
864
+ declare const TIME_DISPLAY_FORMATS: readonly TimeDisplayFormat[];
865
+ declare function isTimeDisplayFormat(value: unknown): value is TimeDisplayFormat;
866
+ /** Format seconds for display. Non-finite or negative input renders as 0. */
867
+ declare function formatDisplayTime(seconds: number, format: TimeDisplayFormat): string;
868
+ /** Parse a formatted time string back to seconds. Lenient: returns 0 for empty/unparseable input; does not validate segment ranges. */
869
+ declare function parseDisplayTime(value: string, format: TimeDisplayFormat): number;
870
+
834
871
  interface DawSelectionDetail {
835
872
  start: number;
836
873
  end: number;
@@ -838,6 +875,13 @@ interface DawSelectionDetail {
838
875
  interface DawSeekDetail {
839
876
  time: number;
840
877
  }
878
+ interface DawTimeUpdateDetail {
879
+ /** Current playback time in seconds (latency-compensated while playing). */
880
+ time: number;
881
+ }
882
+ interface DawTimeFormatChangeDetail {
883
+ format: TimeDisplayFormat;
884
+ }
841
885
  interface DawTrackSelectDetail {
842
886
  trackId: string;
843
887
  }
@@ -978,6 +1022,8 @@ interface DawEffectErrorDetail {
978
1022
  interface DawEventMap {
979
1023
  'daw-selection': CustomEvent<DawSelectionDetail>;
980
1024
  'daw-seek': CustomEvent<DawSeekDetail>;
1025
+ 'daw-timeupdate': CustomEvent<DawTimeUpdateDetail>;
1026
+ 'daw-time-format-change': CustomEvent<DawTimeFormatChangeDetail>;
981
1027
  'daw-track-select': CustomEvent<DawTrackSelectDetail>;
982
1028
  'daw-track-connected': CustomEvent<DawTrackConnectedDetail>;
983
1029
  'daw-track-update': CustomEvent<DawTrackIdDetail>;
@@ -1082,6 +1128,16 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1082
1128
  get samplesPerPixel(): number;
1083
1129
  set samplesPerPixel(value: number);
1084
1130
  private _samplesPerPixel;
1131
+ private _timeFormat;
1132
+ /**
1133
+ * Time display format used by <daw-time-display> and (future, #463) the
1134
+ * selection inputs. Lives on the editor — the target element owns the
1135
+ * state, the transport controls reflect it (native-form style).
1136
+ */
1137
+ get timeFormat(): TimeDisplayFormat;
1138
+ set timeFormat(value: TimeDisplayFormat);
1139
+ /** Set the time display format. Sugar over the `timeFormat` property. */
1140
+ setTimeFormat(format: TimeDisplayFormat): void;
1085
1141
  waveHeight: number;
1086
1142
  timescale: boolean;
1087
1143
  mono: boolean;
@@ -1251,6 +1307,14 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1251
1307
  private _audioResume;
1252
1308
  eagerResume?: string;
1253
1309
  private _recordingController;
1310
+ private _playbackAnimation;
1311
+ /**
1312
+ * True while a seek-while-playing stop+play transition is in flight.
1313
+ * Suppresses the transient settle dispatch from the engine 'stop' handler
1314
+ * (which would otherwise leak a backward-jumping daw-timeupdate at the
1315
+ * play-start position). Non-private: pointer-handler's seek path sets it.
1316
+ */
1317
+ _inSeekTransition: boolean;
1254
1318
  private _spectrogramController;
1255
1319
  private _clipPointer;
1256
1320
  get _clipHandler(): ClipPointerHandler | null;
@@ -1476,6 +1540,10 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1476
1540
  splitAtPlayhead(): boolean;
1477
1541
  recordingStream: MediaStream | null;
1478
1542
  get currentTime(): number;
1543
+ /** Read-only: whether playback is running (HTMLMediaElement-adjacent). */
1544
+ get isPlaying(): boolean;
1545
+ /** Read-only: total content duration in seconds. */
1546
+ get duration(): number;
1479
1547
  get isRecording(): boolean;
1480
1548
  get isRecordingPaused(): boolean;
1481
1549
  pauseRecording(): void;
@@ -1497,6 +1565,8 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1497
1565
  createMediaStreamSource(stream: MediaStream): MediaStreamAudioSourceNode;
1498
1566
  startRecording(stream?: MediaStream, options?: RecordingOptions): Promise<void>;
1499
1567
  private _renderRecordingPreview;
1568
+ /** Convert playback seconds to a timeline pixel offset for the active mode. */
1569
+ private _timeToPixels;
1500
1570
  _startPlayhead(): void;
1501
1571
  _stopPlayhead(): void;
1502
1572
  private _getPlayhead;
@@ -1526,6 +1596,7 @@ declare global {
1526
1596
  }
1527
1597
 
1528
1598
  declare class DawRecordButtonElement extends DawTransportButton {
1599
+ protected static requiredTargetMethods: readonly string[];
1529
1600
  private _isRecording;
1530
1601
  private _targetRef;
1531
1602
  private _onStart;
@@ -1638,6 +1709,69 @@ declare global {
1638
1709
  }
1639
1710
  }
1640
1711
 
1712
+ /**
1713
+ * Formatted playback time readout for <daw-transport>.
1714
+ *
1715
+ * Subscribes to bubbled `daw-timeupdate` / `daw-time-format-change` events at
1716
+ * the document level and filters by its transport target — works with any
1717
+ * target that dispatches them (<daw-editor> today, <daw-player> later) and
1718
+ * tolerates targets that upgrade after this element connects.
1719
+ *
1720
+ * Accessibility (spec): role="status", aria-live="off" — not announced every
1721
+ * frame; screen reader users query on demand.
1722
+ */
1723
+ declare class DawTimeDisplayElement extends LitElement {
1724
+ /** Null until the first successful target sync or daw-timeupdate. */
1725
+ private _time;
1726
+ private _format;
1727
+ static styles: lit.CSSResult;
1728
+ private get target();
1729
+ private _onTimeUpdate;
1730
+ private _onFormatChange;
1731
+ connectedCallback(): void;
1732
+ disconnectedCallback(): void;
1733
+ private _syncFromTarget;
1734
+ render(): lit.TemplateResult<1>;
1735
+ }
1736
+ declare global {
1737
+ interface HTMLElementTagNameMap {
1738
+ 'daw-time-display': DawTimeDisplayElement;
1739
+ }
1740
+ }
1741
+
1742
+ /**
1743
+ * Time format select for <daw-transport>. Sets the format ON the target
1744
+ * (`target.setTimeFormat(...)`) — the target owns the state (native-form
1745
+ * style), and every display/input syncs via the bubbled
1746
+ * `daw-time-format-change` event. Renders disabled when the target doesn't
1747
+ * implement setTimeFormat (duck-typed capability detection, #474).
1748
+ */
1749
+ declare class DawTimeFormatElement extends LitElement {
1750
+ private _format;
1751
+ static styles: lit.CSSResult;
1752
+ private get target();
1753
+ /**
1754
+ * False when the target doesn't implement setTimeFormat. An undetermined
1755
+ * target (missing, or a not-yet-upgraded custom element) gets the benefit
1756
+ * of the doubt and stays enabled — interaction-time resolution warns if
1757
+ * it's still unusable.
1758
+ */
1759
+ private get _targetSupported();
1760
+ private _onFormatChange;
1761
+ private _onPointerEnter;
1762
+ private _onPointerDown;
1763
+ connectedCallback(): void;
1764
+ disconnectedCallback(): void;
1765
+ protected updated(): void;
1766
+ private _onSelectChange;
1767
+ render(): lit.TemplateResult<1>;
1768
+ }
1769
+ declare global {
1770
+ interface HTMLElementTagNameMap {
1771
+ 'daw-time-format': DawTimeFormatElement;
1772
+ }
1773
+ }
1774
+
1641
1775
  interface SpectrogramControllerHost extends ReactiveControllerHost {
1642
1776
  dispatchEvent(event: Event): boolean;
1643
1777
  }
@@ -1701,6 +1835,78 @@ declare class AudioResumeController implements ReactiveController {
1701
1835
  private _removeListeners;
1702
1836
  }
1703
1837
 
1838
+ interface PlayheadLike {
1839
+ setPosition(px: number): void;
1840
+ }
1841
+ interface PlaybackAnimationOptions {
1842
+ /** Convert playback seconds to a timeline pixel offset. */
1843
+ timeToPixels: (time: number) => number;
1844
+ /** Resolve the playhead element (re-queried per call — templates may recreate it). */
1845
+ getPlayhead: () => PlayheadLike | null;
1846
+ }
1847
+ /**
1848
+ * The single editor-owned playback animation loop (mirror of the React
1849
+ * `usePlaybackAnimation` pattern). Each frame reads the latency-compensated
1850
+ * playback time ONCE, positions the playhead, and dispatches `daw-timeupdate`
1851
+ * from the host element. External consumers hook into the same loop by
1852
+ * listening for `daw-timeupdate` — never add a second RAF loop for
1853
+ * playback-time concerns.
1854
+ *
1855
+ * `timeToPixels` and `getPlayhead` are injected once at construction — they
1856
+ * are stable per host, and threading them through every `start`/`stop` call
1857
+ * invited desync between the two call sites.
1858
+ *
1859
+ * HTMLMediaElement-adjacent: `stop()` dispatches one final event so idle
1860
+ * displays settle on the exact commanded position (media elements fire
1861
+ * `timeupdate` on pause and seek too). Pass `{ dispatch: false }` for
1862
+ * transitional stops (stop+play seeks) whose settle position must not leak
1863
+ * to consumers.
1864
+ */
1865
+ declare class PlaybackAnimationController {
1866
+ private _animation;
1867
+ private _host;
1868
+ private _options;
1869
+ private _running;
1870
+ private _lastDispatchedTime;
1871
+ constructor(host: ReactiveControllerHost & HTMLElement, options: PlaybackAnimationOptions);
1872
+ start(getTime: () => number): void;
1873
+ stop(finalTime: number, opts?: {
1874
+ dispatch?: boolean;
1875
+ }): void;
1876
+ private _dispatchTimeUpdate;
1877
+ }
1878
+
1879
+ /**
1880
+ * Transport target resolution + duck-typed capability detection.
1881
+ *
1882
+ * Transport controls never instanceof-check their target — they probe for the
1883
+ * methods they need (`typeof target[m] === 'function'`). This is what lets the
1884
+ * same controls drive <daw-editor>, the future <daw-player> (#454), or any
1885
+ * conforming element, and lets editor-only controls render disabled against a
1886
+ * player (#474, spec "Transport Compatibility").
1887
+ */
1888
+ /**
1889
+ * Resolve the target of the closest <daw-transport for="..."> ancestor.
1890
+ * Walks light-DOM ancestors only (`closest` does not cross shadow boundaries).
1891
+ */
1892
+ declare function resolveTransportTarget(el: Element): HTMLElement | null;
1893
+ /** True when target exists and every named method is a function on it. */
1894
+ declare function targetSupports(target: unknown, methods: readonly string[]): boolean;
1895
+ /**
1896
+ * One-time console warning for a transport control.
1897
+ * Dedup is per element per message — distinct messages on the same element
1898
+ * each warn once, while repeats of the same message stay silent. A
1899
+ * missing-target warn and an unsupported-target warn no longer suppress each
1900
+ * other.
1901
+ */
1902
+ declare function warnOnce(element: Element, message: string): void;
1903
+ /**
1904
+ * One-time console warning explaining why a control is disabled.
1905
+ * Delegates to {@link warnOnce} — an element that already triggered a
1906
+ * missing-target warn will not warn again here.
1907
+ */
1908
+ declare function warnUnsupportedOnce(element: Element, methods: readonly string[]): void;
1909
+
1704
1910
  /** Narrow engine contract for pointer interactions. */
1705
1911
  interface PointerEngineContract {
1706
1912
  setSelection(start: number, end: number): void;
@@ -1743,4 +1949,4 @@ declare function registerEffect(type: string, definition: EffectDefinition): voi
1743
1949
  declare function getEffectDefinitions(): Map<string, EffectDefinition>;
1744
1950
  declare function createEffectInstance(type: string, audioContext: BaseAudioContext, params?: Record<string, number>): CreatedEffect;
1745
1951
 
1746
- export { AudioResumeController, type ClipConfig, type ClipDescriptor, type ClipEngineContract, ClipPointerHandler, type ClipPointerHost, type DawClipConnectedDetail, DawClipElement, type DawClipErrorDetail, type DawClipIdDetail, type DawClipMoveDetail, type DawClipSplitDetail, type DawClipTrimDetail, type DawClipUpdateDetail, DawEditorElement, type DawEffectAddDetail, type DawEffectBypassDetail, type DawEffectChangeDetail, type DawEffectErrorDetail, type DawEffectRemoveDetail, type DawEffectReorderDetail, type DawErrorDetail, type DawEvent, type DawEventMap, type DawFilesLoadErrorDetail, DawGridElement, DawKeyboardShortcutsElement, DawPauseButtonElement, DawPianoRollElement, DawPlayButtonElement, DawPlayheadElement, DawRecordButtonElement, type DawRecordingCompleteDetail, type DawRecordingErrorDetail, type DawRecordingStartDetail, DawRulerElement, type DawSeekDetail, type DawSelectionDetail, DawSelectionElement, DawSpectrogramElement, DawStopButtonElement, type DawTrackConnectedDetail, type DawTrackControlDetail, DawTrackControlsElement, DawTrackElement, type DawTrackErrorDetail, type DawTrackIdDetail, type DawTrackRemoveDetail, type DawTrackSelectDetail, DawTransportButton, DawTransportElement, DawWaveformElement, type DomClipDescriptor, type DropClipDescriptor, type EffectDefinition, type EffectInstance, type EffectParamDef, type EffectState, type ExportAudioHost, type ExportOptions, type KeyBinding, type LoadFilesResult, type PlaybackShortcutMap, type PointerEngineContract, RecordingController, type RecordingOptions, type RecordingSession, type SerializedEffectEntry, SpectrogramController, type SplitEngineContract, type SplitHost, type SplittingShortcutMap, type TrackConfig, type TrackDescriptor, type TrackRenderMode, type UndoShortcutMap, type WaveformSegment, createEffectInstance, getEffectDefinitions, isDomClip, registerEffect, splitAtPlayhead };
1952
+ export { AudioResumeController, type ClipConfig, type ClipDescriptor, type ClipEngineContract, ClipPointerHandler, type ClipPointerHost, type DawClipConnectedDetail, DawClipElement, type DawClipErrorDetail, type DawClipIdDetail, type DawClipMoveDetail, type DawClipSplitDetail, type DawClipTrimDetail, type DawClipUpdateDetail, DawEditorElement, type DawEffectAddDetail, type DawEffectBypassDetail, type DawEffectChangeDetail, type DawEffectErrorDetail, type DawEffectRemoveDetail, type DawEffectReorderDetail, type DawErrorDetail, type DawEvent, type DawEventMap, type DawFilesLoadErrorDetail, DawGridElement, DawKeyboardShortcutsElement, DawPauseButtonElement, DawPianoRollElement, DawPlayButtonElement, DawPlayheadElement, DawRecordButtonElement, type DawRecordingCompleteDetail, type DawRecordingErrorDetail, type DawRecordingStartDetail, DawRulerElement, type DawSeekDetail, type DawSelectionDetail, DawSelectionElement, DawSpectrogramElement, DawStopButtonElement, DawTimeDisplayElement, type DawTimeFormatChangeDetail, DawTimeFormatElement, type DawTimeUpdateDetail, type DawTrackConnectedDetail, type DawTrackControlDetail, DawTrackControlsElement, DawTrackElement, type DawTrackErrorDetail, type DawTrackIdDetail, type DawTrackRemoveDetail, type DawTrackSelectDetail, DawTransportButton, DawTransportElement, DawWaveformElement, type DomClipDescriptor, type DropClipDescriptor, type EffectDefinition, type EffectInstance, type EffectParamDef, type EffectState, type ExportAudioHost, type ExportOptions, type KeyBinding, type LoadFilesResult, PlaybackAnimationController, type PlaybackAnimationOptions, type PlaybackShortcutMap, type PlayheadLike, type PointerEngineContract, RecordingController, type RecordingOptions, type RecordingSession, type SerializedEffectEntry, SpectrogramController, type SplitEngineContract, type SplitHost, type SplittingShortcutMap, TIME_DISPLAY_FORMATS, type TimeDisplayFormat, type TrackConfig, type TrackDescriptor, type TrackRenderMode, type UndoShortcutMap, type WaveformSegment, createEffectInstance, formatDisplayTime, getEffectDefinitions, isDomClip, isTimeDisplayFormat, parseDisplayTime, registerEffect, resolveTransportTarget, splitAtPlayhead, targetSupports, warnOnce, warnUnsupportedOnce };