@dawcore/components 0.0.24 → 0.0.25

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
 
@@ -831,6 +846,20 @@ declare class ClipPointerHandler {
831
846
  private _reset;
832
847
  }
833
848
 
849
+ /**
850
+ * Time display formats for <daw-time-display> / <daw-time-format> and the
851
+ * editor's `time-format` attribute. The three formats come from the
852
+ * web-components-migration spec ("Element Registry": hh:mm:ss.sss | hh:mm:ss
853
+ * | seconds). parseDisplayTime exists for the selection inputs (#463).
854
+ */
855
+ type TimeDisplayFormat = 'hh:mm:ss.sss' | 'hh:mm:ss' | 'seconds';
856
+ declare const TIME_DISPLAY_FORMATS: readonly TimeDisplayFormat[];
857
+ declare function isTimeDisplayFormat(value: unknown): value is TimeDisplayFormat;
858
+ /** Format seconds for display. Non-finite or negative input renders as 0. */
859
+ declare function formatDisplayTime(seconds: number, format: TimeDisplayFormat): string;
860
+ /** Parse a formatted time string back to seconds. Lenient: returns 0 for empty/unparseable input; does not validate segment ranges. */
861
+ declare function parseDisplayTime(value: string, format: TimeDisplayFormat): number;
862
+
834
863
  interface DawSelectionDetail {
835
864
  start: number;
836
865
  end: number;
@@ -838,6 +867,13 @@ interface DawSelectionDetail {
838
867
  interface DawSeekDetail {
839
868
  time: number;
840
869
  }
870
+ interface DawTimeUpdateDetail {
871
+ /** Current playback time in seconds (latency-compensated while playing). */
872
+ time: number;
873
+ }
874
+ interface DawTimeFormatChangeDetail {
875
+ format: TimeDisplayFormat;
876
+ }
841
877
  interface DawTrackSelectDetail {
842
878
  trackId: string;
843
879
  }
@@ -978,6 +1014,8 @@ interface DawEffectErrorDetail {
978
1014
  interface DawEventMap {
979
1015
  'daw-selection': CustomEvent<DawSelectionDetail>;
980
1016
  'daw-seek': CustomEvent<DawSeekDetail>;
1017
+ 'daw-timeupdate': CustomEvent<DawTimeUpdateDetail>;
1018
+ 'daw-time-format-change': CustomEvent<DawTimeFormatChangeDetail>;
981
1019
  'daw-track-select': CustomEvent<DawTrackSelectDetail>;
982
1020
  'daw-track-connected': CustomEvent<DawTrackConnectedDetail>;
983
1021
  'daw-track-update': CustomEvent<DawTrackIdDetail>;
@@ -1082,6 +1120,16 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1082
1120
  get samplesPerPixel(): number;
1083
1121
  set samplesPerPixel(value: number);
1084
1122
  private _samplesPerPixel;
1123
+ private _timeFormat;
1124
+ /**
1125
+ * Time display format used by <daw-time-display> and (future, #463) the
1126
+ * selection inputs. Lives on the editor — the target element owns the
1127
+ * state, the transport controls reflect it (native-form style).
1128
+ */
1129
+ get timeFormat(): TimeDisplayFormat;
1130
+ set timeFormat(value: TimeDisplayFormat);
1131
+ /** Set the time display format. Sugar over the `timeFormat` property. */
1132
+ setTimeFormat(format: TimeDisplayFormat): void;
1085
1133
  waveHeight: number;
1086
1134
  timescale: boolean;
1087
1135
  mono: boolean;
@@ -1251,6 +1299,14 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1251
1299
  private _audioResume;
1252
1300
  eagerResume?: string;
1253
1301
  private _recordingController;
1302
+ private _playbackAnimation;
1303
+ /**
1304
+ * True while a seek-while-playing stop+play transition is in flight.
1305
+ * Suppresses the transient settle dispatch from the engine 'stop' handler
1306
+ * (which would otherwise leak a backward-jumping daw-timeupdate at the
1307
+ * play-start position). Non-private: pointer-handler's seek path sets it.
1308
+ */
1309
+ _inSeekTransition: boolean;
1254
1310
  private _spectrogramController;
1255
1311
  private _clipPointer;
1256
1312
  get _clipHandler(): ClipPointerHandler | null;
@@ -1476,6 +1532,10 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1476
1532
  splitAtPlayhead(): boolean;
1477
1533
  recordingStream: MediaStream | null;
1478
1534
  get currentTime(): number;
1535
+ /** Read-only: whether playback is running (HTMLMediaElement-adjacent). */
1536
+ get isPlaying(): boolean;
1537
+ /** Read-only: total content duration in seconds. */
1538
+ get duration(): number;
1479
1539
  get isRecording(): boolean;
1480
1540
  get isRecordingPaused(): boolean;
1481
1541
  pauseRecording(): void;
@@ -1497,6 +1557,8 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1497
1557
  createMediaStreamSource(stream: MediaStream): MediaStreamAudioSourceNode;
1498
1558
  startRecording(stream?: MediaStream, options?: RecordingOptions): Promise<void>;
1499
1559
  private _renderRecordingPreview;
1560
+ /** Convert playback seconds to a timeline pixel offset for the active mode. */
1561
+ private _timeToPixels;
1500
1562
  _startPlayhead(): void;
1501
1563
  _stopPlayhead(): void;
1502
1564
  private _getPlayhead;
@@ -1526,6 +1588,7 @@ declare global {
1526
1588
  }
1527
1589
 
1528
1590
  declare class DawRecordButtonElement extends DawTransportButton {
1591
+ protected static requiredTargetMethods: readonly string[];
1529
1592
  private _isRecording;
1530
1593
  private _targetRef;
1531
1594
  private _onStart;
@@ -1638,6 +1701,69 @@ declare global {
1638
1701
  }
1639
1702
  }
1640
1703
 
1704
+ /**
1705
+ * Formatted playback time readout for <daw-transport>.
1706
+ *
1707
+ * Subscribes to bubbled `daw-timeupdate` / `daw-time-format-change` events at
1708
+ * the document level and filters by its transport target — works with any
1709
+ * target that dispatches them (<daw-editor> today, <daw-player> later) and
1710
+ * tolerates targets that upgrade after this element connects.
1711
+ *
1712
+ * Accessibility (spec): role="status", aria-live="off" — not announced every
1713
+ * frame; screen reader users query on demand.
1714
+ */
1715
+ declare class DawTimeDisplayElement extends LitElement {
1716
+ /** Null until the first successful target sync or daw-timeupdate. */
1717
+ private _time;
1718
+ private _format;
1719
+ static styles: lit.CSSResult;
1720
+ private get target();
1721
+ private _onTimeUpdate;
1722
+ private _onFormatChange;
1723
+ connectedCallback(): void;
1724
+ disconnectedCallback(): void;
1725
+ private _syncFromTarget;
1726
+ render(): lit.TemplateResult<1>;
1727
+ }
1728
+ declare global {
1729
+ interface HTMLElementTagNameMap {
1730
+ 'daw-time-display': DawTimeDisplayElement;
1731
+ }
1732
+ }
1733
+
1734
+ /**
1735
+ * Time format select for <daw-transport>. Sets the format ON the target
1736
+ * (`target.setTimeFormat(...)`) — the target owns the state (native-form
1737
+ * style), and every display/input syncs via the bubbled
1738
+ * `daw-time-format-change` event. Renders disabled when the target doesn't
1739
+ * implement setTimeFormat (duck-typed capability detection, #474).
1740
+ */
1741
+ declare class DawTimeFormatElement extends LitElement {
1742
+ private _format;
1743
+ static styles: lit.CSSResult;
1744
+ private get target();
1745
+ /**
1746
+ * False when the target doesn't implement setTimeFormat. An undetermined
1747
+ * target (missing, or a not-yet-upgraded custom element) gets the benefit
1748
+ * of the doubt and stays enabled — interaction-time resolution warns if
1749
+ * it's still unusable.
1750
+ */
1751
+ private get _targetSupported();
1752
+ private _onFormatChange;
1753
+ private _onPointerEnter;
1754
+ private _onPointerDown;
1755
+ connectedCallback(): void;
1756
+ disconnectedCallback(): void;
1757
+ protected updated(): void;
1758
+ private _onSelectChange;
1759
+ render(): lit.TemplateResult<1>;
1760
+ }
1761
+ declare global {
1762
+ interface HTMLElementTagNameMap {
1763
+ 'daw-time-format': DawTimeFormatElement;
1764
+ }
1765
+ }
1766
+
1641
1767
  interface SpectrogramControllerHost extends ReactiveControllerHost {
1642
1768
  dispatchEvent(event: Event): boolean;
1643
1769
  }
@@ -1701,6 +1827,78 @@ declare class AudioResumeController implements ReactiveController {
1701
1827
  private _removeListeners;
1702
1828
  }
1703
1829
 
1830
+ interface PlayheadLike {
1831
+ setPosition(px: number): void;
1832
+ }
1833
+ interface PlaybackAnimationOptions {
1834
+ /** Convert playback seconds to a timeline pixel offset. */
1835
+ timeToPixels: (time: number) => number;
1836
+ /** Resolve the playhead element (re-queried per call — templates may recreate it). */
1837
+ getPlayhead: () => PlayheadLike | null;
1838
+ }
1839
+ /**
1840
+ * The single editor-owned playback animation loop (mirror of the React
1841
+ * `usePlaybackAnimation` pattern). Each frame reads the latency-compensated
1842
+ * playback time ONCE, positions the playhead, and dispatches `daw-timeupdate`
1843
+ * from the host element. External consumers hook into the same loop by
1844
+ * listening for `daw-timeupdate` — never add a second RAF loop for
1845
+ * playback-time concerns.
1846
+ *
1847
+ * `timeToPixels` and `getPlayhead` are injected once at construction — they
1848
+ * are stable per host, and threading them through every `start`/`stop` call
1849
+ * invited desync between the two call sites.
1850
+ *
1851
+ * HTMLMediaElement-adjacent: `stop()` dispatches one final event so idle
1852
+ * displays settle on the exact commanded position (media elements fire
1853
+ * `timeupdate` on pause and seek too). Pass `{ dispatch: false }` for
1854
+ * transitional stops (stop+play seeks) whose settle position must not leak
1855
+ * to consumers.
1856
+ */
1857
+ declare class PlaybackAnimationController {
1858
+ private _animation;
1859
+ private _host;
1860
+ private _options;
1861
+ private _running;
1862
+ private _lastDispatchedTime;
1863
+ constructor(host: ReactiveControllerHost & HTMLElement, options: PlaybackAnimationOptions);
1864
+ start(getTime: () => number): void;
1865
+ stop(finalTime: number, opts?: {
1866
+ dispatch?: boolean;
1867
+ }): void;
1868
+ private _dispatchTimeUpdate;
1869
+ }
1870
+
1871
+ /**
1872
+ * Transport target resolution + duck-typed capability detection.
1873
+ *
1874
+ * Transport controls never instanceof-check their target — they probe for the
1875
+ * methods they need (`typeof target[m] === 'function'`). This is what lets the
1876
+ * same controls drive <daw-editor>, the future <daw-player> (#454), or any
1877
+ * conforming element, and lets editor-only controls render disabled against a
1878
+ * player (#474, spec "Transport Compatibility").
1879
+ */
1880
+ /**
1881
+ * Resolve the target of the closest <daw-transport for="..."> ancestor.
1882
+ * Walks light-DOM ancestors only (`closest` does not cross shadow boundaries).
1883
+ */
1884
+ declare function resolveTransportTarget(el: Element): HTMLElement | null;
1885
+ /** True when target exists and every named method is a function on it. */
1886
+ declare function targetSupports(target: unknown, methods: readonly string[]): boolean;
1887
+ /**
1888
+ * One-time console warning for a transport control.
1889
+ * Dedup is per element per message — distinct messages on the same element
1890
+ * each warn once, while repeats of the same message stay silent. A
1891
+ * missing-target warn and an unsupported-target warn no longer suppress each
1892
+ * other.
1893
+ */
1894
+ declare function warnOnce(element: Element, message: string): void;
1895
+ /**
1896
+ * One-time console warning explaining why a control is disabled.
1897
+ * Delegates to {@link warnOnce} — an element that already triggered a
1898
+ * missing-target warn will not warn again here.
1899
+ */
1900
+ declare function warnUnsupportedOnce(element: Element, methods: readonly string[]): void;
1901
+
1704
1902
  /** Narrow engine contract for pointer interactions. */
1705
1903
  interface PointerEngineContract {
1706
1904
  setSelection(start: number, end: number): void;
@@ -1743,4 +1941,4 @@ declare function registerEffect(type: string, definition: EffectDefinition): voi
1743
1941
  declare function getEffectDefinitions(): Map<string, EffectDefinition>;
1744
1942
  declare function createEffectInstance(type: string, audioContext: BaseAudioContext, params?: Record<string, number>): CreatedEffect;
1745
1943
 
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 };
1944
+ 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
 
@@ -831,6 +846,20 @@ declare class ClipPointerHandler {
831
846
  private _reset;
832
847
  }
833
848
 
849
+ /**
850
+ * Time display formats for <daw-time-display> / <daw-time-format> and the
851
+ * editor's `time-format` attribute. The three formats come from the
852
+ * web-components-migration spec ("Element Registry": hh:mm:ss.sss | hh:mm:ss
853
+ * | seconds). parseDisplayTime exists for the selection inputs (#463).
854
+ */
855
+ type TimeDisplayFormat = 'hh:mm:ss.sss' | 'hh:mm:ss' | 'seconds';
856
+ declare const TIME_DISPLAY_FORMATS: readonly TimeDisplayFormat[];
857
+ declare function isTimeDisplayFormat(value: unknown): value is TimeDisplayFormat;
858
+ /** Format seconds for display. Non-finite or negative input renders as 0. */
859
+ declare function formatDisplayTime(seconds: number, format: TimeDisplayFormat): string;
860
+ /** Parse a formatted time string back to seconds. Lenient: returns 0 for empty/unparseable input; does not validate segment ranges. */
861
+ declare function parseDisplayTime(value: string, format: TimeDisplayFormat): number;
862
+
834
863
  interface DawSelectionDetail {
835
864
  start: number;
836
865
  end: number;
@@ -838,6 +867,13 @@ interface DawSelectionDetail {
838
867
  interface DawSeekDetail {
839
868
  time: number;
840
869
  }
870
+ interface DawTimeUpdateDetail {
871
+ /** Current playback time in seconds (latency-compensated while playing). */
872
+ time: number;
873
+ }
874
+ interface DawTimeFormatChangeDetail {
875
+ format: TimeDisplayFormat;
876
+ }
841
877
  interface DawTrackSelectDetail {
842
878
  trackId: string;
843
879
  }
@@ -978,6 +1014,8 @@ interface DawEffectErrorDetail {
978
1014
  interface DawEventMap {
979
1015
  'daw-selection': CustomEvent<DawSelectionDetail>;
980
1016
  'daw-seek': CustomEvent<DawSeekDetail>;
1017
+ 'daw-timeupdate': CustomEvent<DawTimeUpdateDetail>;
1018
+ 'daw-time-format-change': CustomEvent<DawTimeFormatChangeDetail>;
981
1019
  'daw-track-select': CustomEvent<DawTrackSelectDetail>;
982
1020
  'daw-track-connected': CustomEvent<DawTrackConnectedDetail>;
983
1021
  'daw-track-update': CustomEvent<DawTrackIdDetail>;
@@ -1082,6 +1120,16 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1082
1120
  get samplesPerPixel(): number;
1083
1121
  set samplesPerPixel(value: number);
1084
1122
  private _samplesPerPixel;
1123
+ private _timeFormat;
1124
+ /**
1125
+ * Time display format used by <daw-time-display> and (future, #463) the
1126
+ * selection inputs. Lives on the editor — the target element owns the
1127
+ * state, the transport controls reflect it (native-form style).
1128
+ */
1129
+ get timeFormat(): TimeDisplayFormat;
1130
+ set timeFormat(value: TimeDisplayFormat);
1131
+ /** Set the time display format. Sugar over the `timeFormat` property. */
1132
+ setTimeFormat(format: TimeDisplayFormat): void;
1085
1133
  waveHeight: number;
1086
1134
  timescale: boolean;
1087
1135
  mono: boolean;
@@ -1251,6 +1299,14 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1251
1299
  private _audioResume;
1252
1300
  eagerResume?: string;
1253
1301
  private _recordingController;
1302
+ private _playbackAnimation;
1303
+ /**
1304
+ * True while a seek-while-playing stop+play transition is in flight.
1305
+ * Suppresses the transient settle dispatch from the engine 'stop' handler
1306
+ * (which would otherwise leak a backward-jumping daw-timeupdate at the
1307
+ * play-start position). Non-private: pointer-handler's seek path sets it.
1308
+ */
1309
+ _inSeekTransition: boolean;
1254
1310
  private _spectrogramController;
1255
1311
  private _clipPointer;
1256
1312
  get _clipHandler(): ClipPointerHandler | null;
@@ -1476,6 +1532,10 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1476
1532
  splitAtPlayhead(): boolean;
1477
1533
  recordingStream: MediaStream | null;
1478
1534
  get currentTime(): number;
1535
+ /** Read-only: whether playback is running (HTMLMediaElement-adjacent). */
1536
+ get isPlaying(): boolean;
1537
+ /** Read-only: total content duration in seconds. */
1538
+ get duration(): number;
1479
1539
  get isRecording(): boolean;
1480
1540
  get isRecordingPaused(): boolean;
1481
1541
  pauseRecording(): void;
@@ -1497,6 +1557,8 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1497
1557
  createMediaStreamSource(stream: MediaStream): MediaStreamAudioSourceNode;
1498
1558
  startRecording(stream?: MediaStream, options?: RecordingOptions): Promise<void>;
1499
1559
  private _renderRecordingPreview;
1560
+ /** Convert playback seconds to a timeline pixel offset for the active mode. */
1561
+ private _timeToPixels;
1500
1562
  _startPlayhead(): void;
1501
1563
  _stopPlayhead(): void;
1502
1564
  private _getPlayhead;
@@ -1526,6 +1588,7 @@ declare global {
1526
1588
  }
1527
1589
 
1528
1590
  declare class DawRecordButtonElement extends DawTransportButton {
1591
+ protected static requiredTargetMethods: readonly string[];
1529
1592
  private _isRecording;
1530
1593
  private _targetRef;
1531
1594
  private _onStart;
@@ -1638,6 +1701,69 @@ declare global {
1638
1701
  }
1639
1702
  }
1640
1703
 
1704
+ /**
1705
+ * Formatted playback time readout for <daw-transport>.
1706
+ *
1707
+ * Subscribes to bubbled `daw-timeupdate` / `daw-time-format-change` events at
1708
+ * the document level and filters by its transport target — works with any
1709
+ * target that dispatches them (<daw-editor> today, <daw-player> later) and
1710
+ * tolerates targets that upgrade after this element connects.
1711
+ *
1712
+ * Accessibility (spec): role="status", aria-live="off" — not announced every
1713
+ * frame; screen reader users query on demand.
1714
+ */
1715
+ declare class DawTimeDisplayElement extends LitElement {
1716
+ /** Null until the first successful target sync or daw-timeupdate. */
1717
+ private _time;
1718
+ private _format;
1719
+ static styles: lit.CSSResult;
1720
+ private get target();
1721
+ private _onTimeUpdate;
1722
+ private _onFormatChange;
1723
+ connectedCallback(): void;
1724
+ disconnectedCallback(): void;
1725
+ private _syncFromTarget;
1726
+ render(): lit.TemplateResult<1>;
1727
+ }
1728
+ declare global {
1729
+ interface HTMLElementTagNameMap {
1730
+ 'daw-time-display': DawTimeDisplayElement;
1731
+ }
1732
+ }
1733
+
1734
+ /**
1735
+ * Time format select for <daw-transport>. Sets the format ON the target
1736
+ * (`target.setTimeFormat(...)`) — the target owns the state (native-form
1737
+ * style), and every display/input syncs via the bubbled
1738
+ * `daw-time-format-change` event. Renders disabled when the target doesn't
1739
+ * implement setTimeFormat (duck-typed capability detection, #474).
1740
+ */
1741
+ declare class DawTimeFormatElement extends LitElement {
1742
+ private _format;
1743
+ static styles: lit.CSSResult;
1744
+ private get target();
1745
+ /**
1746
+ * False when the target doesn't implement setTimeFormat. An undetermined
1747
+ * target (missing, or a not-yet-upgraded custom element) gets the benefit
1748
+ * of the doubt and stays enabled — interaction-time resolution warns if
1749
+ * it's still unusable.
1750
+ */
1751
+ private get _targetSupported();
1752
+ private _onFormatChange;
1753
+ private _onPointerEnter;
1754
+ private _onPointerDown;
1755
+ connectedCallback(): void;
1756
+ disconnectedCallback(): void;
1757
+ protected updated(): void;
1758
+ private _onSelectChange;
1759
+ render(): lit.TemplateResult<1>;
1760
+ }
1761
+ declare global {
1762
+ interface HTMLElementTagNameMap {
1763
+ 'daw-time-format': DawTimeFormatElement;
1764
+ }
1765
+ }
1766
+
1641
1767
  interface SpectrogramControllerHost extends ReactiveControllerHost {
1642
1768
  dispatchEvent(event: Event): boolean;
1643
1769
  }
@@ -1701,6 +1827,78 @@ declare class AudioResumeController implements ReactiveController {
1701
1827
  private _removeListeners;
1702
1828
  }
1703
1829
 
1830
+ interface PlayheadLike {
1831
+ setPosition(px: number): void;
1832
+ }
1833
+ interface PlaybackAnimationOptions {
1834
+ /** Convert playback seconds to a timeline pixel offset. */
1835
+ timeToPixels: (time: number) => number;
1836
+ /** Resolve the playhead element (re-queried per call — templates may recreate it). */
1837
+ getPlayhead: () => PlayheadLike | null;
1838
+ }
1839
+ /**
1840
+ * The single editor-owned playback animation loop (mirror of the React
1841
+ * `usePlaybackAnimation` pattern). Each frame reads the latency-compensated
1842
+ * playback time ONCE, positions the playhead, and dispatches `daw-timeupdate`
1843
+ * from the host element. External consumers hook into the same loop by
1844
+ * listening for `daw-timeupdate` — never add a second RAF loop for
1845
+ * playback-time concerns.
1846
+ *
1847
+ * `timeToPixels` and `getPlayhead` are injected once at construction — they
1848
+ * are stable per host, and threading them through every `start`/`stop` call
1849
+ * invited desync between the two call sites.
1850
+ *
1851
+ * HTMLMediaElement-adjacent: `stop()` dispatches one final event so idle
1852
+ * displays settle on the exact commanded position (media elements fire
1853
+ * `timeupdate` on pause and seek too). Pass `{ dispatch: false }` for
1854
+ * transitional stops (stop+play seeks) whose settle position must not leak
1855
+ * to consumers.
1856
+ */
1857
+ declare class PlaybackAnimationController {
1858
+ private _animation;
1859
+ private _host;
1860
+ private _options;
1861
+ private _running;
1862
+ private _lastDispatchedTime;
1863
+ constructor(host: ReactiveControllerHost & HTMLElement, options: PlaybackAnimationOptions);
1864
+ start(getTime: () => number): void;
1865
+ stop(finalTime: number, opts?: {
1866
+ dispatch?: boolean;
1867
+ }): void;
1868
+ private _dispatchTimeUpdate;
1869
+ }
1870
+
1871
+ /**
1872
+ * Transport target resolution + duck-typed capability detection.
1873
+ *
1874
+ * Transport controls never instanceof-check their target — they probe for the
1875
+ * methods they need (`typeof target[m] === 'function'`). This is what lets the
1876
+ * same controls drive <daw-editor>, the future <daw-player> (#454), or any
1877
+ * conforming element, and lets editor-only controls render disabled against a
1878
+ * player (#474, spec "Transport Compatibility").
1879
+ */
1880
+ /**
1881
+ * Resolve the target of the closest <daw-transport for="..."> ancestor.
1882
+ * Walks light-DOM ancestors only (`closest` does not cross shadow boundaries).
1883
+ */
1884
+ declare function resolveTransportTarget(el: Element): HTMLElement | null;
1885
+ /** True when target exists and every named method is a function on it. */
1886
+ declare function targetSupports(target: unknown, methods: readonly string[]): boolean;
1887
+ /**
1888
+ * One-time console warning for a transport control.
1889
+ * Dedup is per element per message — distinct messages on the same element
1890
+ * each warn once, while repeats of the same message stay silent. A
1891
+ * missing-target warn and an unsupported-target warn no longer suppress each
1892
+ * other.
1893
+ */
1894
+ declare function warnOnce(element: Element, message: string): void;
1895
+ /**
1896
+ * One-time console warning explaining why a control is disabled.
1897
+ * Delegates to {@link warnOnce} — an element that already triggered a
1898
+ * missing-target warn will not warn again here.
1899
+ */
1900
+ declare function warnUnsupportedOnce(element: Element, methods: readonly string[]): void;
1901
+
1704
1902
  /** Narrow engine contract for pointer interactions. */
1705
1903
  interface PointerEngineContract {
1706
1904
  setSelection(start: number, end: number): void;
@@ -1743,4 +1941,4 @@ declare function registerEffect(type: string, definition: EffectDefinition): voi
1743
1941
  declare function getEffectDefinitions(): Map<string, EffectDefinition>;
1744
1942
  declare function createEffectInstance(type: string, audioContext: BaseAudioContext, params?: Record<string, number>): CreatedEffect;
1745
1943
 
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 };
1944
+ 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 };