@dawcore/components 0.0.34 → 0.0.35

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
@@ -1,11 +1,187 @@
1
1
  import * as lit from 'lit';
2
2
  import { LitElement, PropertyValues, ReactiveController, ReactiveControllerHost } from 'lit';
3
- import { MidiNoteData, RenderMode, SpectrogramConfig, Peaks, Bits, FadeType, PeakData, MeterEntry, SnapTo, ColorMapValue, ClipTrack, KeyboardShortcut } from '@waveform-playlist/core';
3
+ import { AnnotationData, AnnotationShortcutMap, MidiNoteData, RenderMode, SpectrogramConfig, Peaks, Bits, FadeType, PeakData, MeterEntry, SnapTo, ColorMapValue, ClipTrack, KeyboardShortcut } from '@waveform-playlist/core';
4
4
  import WaveformData from 'waveform-data';
5
5
  import { PlayoutAdapter, PlaylistEngine } from '@waveform-playlist/engine';
6
6
  import { MidiLoadOptions, MidiLoadResult } from '@dawcore/midi';
7
7
  import { ClipRegistration, CanvasRegistration, ViewportState } from '@dawcore/spectrogram';
8
8
 
9
+ /**
10
+ * Declarative annotation data element (light DOM). Its `start`/`end`
11
+ * attributes and text content ARE the single source of truth — the editor's
12
+ * annotation lane and <daw-annotation-list> both derive from them.
13
+ */
14
+ declare class DawAnnotationElement extends LitElement {
15
+ /** Start time in seconds. Reflected — attribute writes drive both views. */
16
+ get start(): number;
17
+ set start(value: number);
18
+ private _start;
19
+ /** End time in seconds. Reflected. */
20
+ get end(): number;
21
+ set end(value: number);
22
+ private _end;
23
+ /** Musical start position (ticks). Authoritative when end-tick is also set —
24
+ * start/end seconds become a derived cache the host editor keeps fresh
25
+ * (clip startTick pattern). */
26
+ get startTick(): number | null;
27
+ set startTick(value: number | null);
28
+ private _startTick;
29
+ /** Musical end position (ticks). See startTick. */
30
+ get endTick(): number | null;
31
+ set endTick(value: number | null);
32
+ private _endTick;
33
+ /** Tick-based iff BOTH tick attributes are set (authority rule). */
34
+ get isTickBased(): boolean;
35
+ private _warnedHalfTick;
36
+ private readonly _generatedId;
37
+ /** Stable identity: the id attribute when present, else a generated UUID. */
38
+ get annotationId(): string;
39
+ toAnnotationData(): AnnotationData;
40
+ createRenderRoot(): this;
41
+ connectedCallback(): void;
42
+ private _hasRendered;
43
+ updated(changed: PropertyValues): void;
44
+ }
45
+ declare global {
46
+ interface HTMLElementTagNameMap {
47
+ 'daw-annotation': DawAnnotationElement;
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Declarative annotation track (light DOM). Children are <daw-annotation>
53
+ * elements — their attributes are the single source of truth. This element
54
+ * owns the ephemeral selection state and the programmatic API; the host
55
+ * <daw-editor> renders the timeline lane, <daw-annotation-list> renders the
56
+ * text panel.
57
+ */
58
+ declare class DawAnnotationTrackElement extends LitElement {
59
+ editable: boolean;
60
+ linkEndpoints: boolean;
61
+ continuousPlay: boolean;
62
+ keyboardControls: boolean;
63
+ /** Lane box label mode: 'text' (default) | 'id' (sonnet-style: explicit id
64
+ * attribute, else 1-based position) | 'none' (pure region bars). The list
65
+ * always shows full text — this only affects the timeline lane. */
66
+ boxLabel: 'text' | 'id' | 'none';
67
+ /** Display label for the editor's controls-column lane row (mirrors
68
+ * <daw-track name>). Empty = blank spacer (opt-in, no layout change). */
69
+ name: string;
70
+ private _activeAnnotationId;
71
+ get activeAnnotationId(): string | null;
72
+ set activeAnnotationId(value: string | null);
73
+ /** Child annotation elements, sorted by start time. */
74
+ get annotationElements(): DawAnnotationElement[];
75
+ get annotations(): AnnotationData[];
76
+ selectNext(): void;
77
+ selectPrevious(): void;
78
+ selectFirst(): void;
79
+ selectLast(): void;
80
+ clearSelection(): void;
81
+ /** offset: +1 next / -1 previous; noSelectionIndex: 0 → first, -1 → last. */
82
+ private _selectByOffset;
83
+ playActive(): void;
84
+ moveStartBoundary(deltaMs: number): void;
85
+ moveEndBoundary(deltaMs: number): void;
86
+ private _moveBoundary;
87
+ private _timelineDuration;
88
+ private _activeElement;
89
+ private _hostEditor;
90
+ private _annotationShortcuts;
91
+ private _resolvedShortcuts;
92
+ get annotationShortcuts(): AnnotationShortcutMap | null;
93
+ set annotationShortcuts(value: AnnotationShortcutMap | null);
94
+ private _shortcutEntries;
95
+ private static readonly _boundaryActions;
96
+ private _onKeyDownCapture;
97
+ private _runShortcutAction;
98
+ private _childObserver;
99
+ createRenderRoot(): this;
100
+ connectedCallback(): void;
101
+ disconnectedCallback(): void;
102
+ }
103
+ declare global {
104
+ interface HTMLElementTagNameMap {
105
+ 'daw-annotation-track': DawAnnotationTrackElement;
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Scrollable text panel over a <daw-annotation-track>'s children — the same
111
+ * <daw-annotation> elements the editor lane renders (single source of truth).
112
+ * Linked via the `for` attribute (id of the track element).
113
+ */
114
+ declare class DawAnnotationListElement extends LitElement {
115
+ for: string;
116
+ /** `'time'` (default): m:ss.mmm clock times, unchanged. `'bars'`: B.b – B.b
117
+ * bar.beat ranges resolved via the host editor's meter map — falls back
118
+ * to time display (and warns once) when no `<daw-editor>` ancestor is
119
+ * found via `this.track?.closest('daw-editor')`. */
120
+ timeDisplay: 'time' | 'bars';
121
+ /** Suppress re-render while a row's text is being edited. */
122
+ private _editingId;
123
+ private _activeId;
124
+ /** Playback-following highlight, separate from `_activeId` (selection) so
125
+ * playback never disturbs selection/keyboard editing. Driven by
126
+ * daw-timeupdate, cleared on daw-stop, retained on pause. */
127
+ private _playingId;
128
+ private _observer;
129
+ private _observedTrack;
130
+ private _warnedMissing;
131
+ /** Warn once per resolved `for` target when bars mode can't find a host
132
+ * editor — reset alongside `_warnedMissing` on `for` change so a
133
+ * retargeted list can warn again for its new target. */
134
+ private _warnedNoEditorForBars;
135
+ /** Set around `_cancelEdit`'s `span.blur()` so the resulting synchronous
136
+ * blur event doesn't re-enter `_commitEdit` (cancel already restores the
137
+ * text and clears `_editingId` itself). */
138
+ private _cancelling;
139
+ static styles: lit.CSSResult;
140
+ get track(): DawAnnotationTrackElement | null;
141
+ protected willUpdate(changed: Map<string, unknown>): void;
142
+ connectedCallback(): void;
143
+ disconnectedCallback(): void;
144
+ protected shouldUpdate(): boolean;
145
+ protected updated(): void;
146
+ /**
147
+ * Text content is set imperatively, NOT bound as a Lit expression.
148
+ * contenteditable mutates the span's DOM directly as the user types —
149
+ * that ejects lit-html's ChildPart marker comments for any binding at
150
+ * that position, so a later Lit-driven re-render of the same row throws
151
+ * "ChildPart has no parentNode". Keeping the span's children entirely
152
+ * outside Lit's diffing sidesteps the crash; the (soon-to-commit) edited
153
+ * row is skipped via the _editingId check.
154
+ */
155
+ private _syncRowText;
156
+ /** (Re)attach the MutationObserver when the resolved track changes. */
157
+ private _ensureObserver;
158
+ private _onSelect;
159
+ /**
160
+ * Update only on annotation-boundary crossings, not per animation frame.
161
+ * `shouldUpdate()` suppresses the resulting render while a row is being
162
+ * edited (`_editingId`) — intentional, not bypassed here. A boundary
163
+ * crossed mid-edit is caught up on the NEXT crossing after the edit ends;
164
+ * the highlight is briefly stale in that window, which is acceptable
165
+ * (edits are rare and short-lived relative to playback).
166
+ */
167
+ private _onTimeUpdate;
168
+ private _onStop;
169
+ private _onRowClick;
170
+ /** Formats a row's times span per `timeDisplay`. `'bars'` resolves the
171
+ * host editor once (shared across all rows in a render) and falls back
172
+ * to time display, warning once, when no editor is found. */
173
+ private _formatTimes;
174
+ private _annotationElement;
175
+ private _commitEdit;
176
+ private _cancelEdit;
177
+ render(): lit.TemplateResult<1>;
178
+ }
179
+ declare global {
180
+ interface HTMLElementTagNameMap {
181
+ 'daw-annotation-list': DawAnnotationListElement;
182
+ }
183
+ }
184
+
9
185
  declare class DawClipElement extends LitElement {
10
186
  src: string;
11
187
  peaksSrc: string;
@@ -1137,6 +1313,19 @@ interface DawEffectErrorDetail {
1137
1313
  type?: string;
1138
1314
  message: string;
1139
1315
  }
1316
+ interface DawAnnotationConnectedDetail {
1317
+ annotationId: string;
1318
+ element: HTMLElement;
1319
+ }
1320
+ interface DawAnnotationUpdateDetail {
1321
+ annotationId: string;
1322
+ }
1323
+ interface DawAnnotationSelectDetail {
1324
+ annotation: AnnotationData | null;
1325
+ }
1326
+ interface DawAnnotationTrackConnectedDetail {
1327
+ element: HTMLElement;
1328
+ }
1140
1329
  interface DawEventMap {
1141
1330
  'daw-selection': CustomEvent<DawSelectionDetail>;
1142
1331
  'daw-seek': CustomEvent<DawSeekDetail>;
@@ -1177,6 +1366,10 @@ interface DawEventMap {
1177
1366
  'daw-effect-bypass': CustomEvent<DawEffectBypassDetail>;
1178
1367
  'daw-effect-reorder': CustomEvent<DawEffectReorderDetail>;
1179
1368
  'daw-effect-error': CustomEvent<DawEffectErrorDetail>;
1369
+ 'daw-annotation-connected': CustomEvent<DawAnnotationConnectedDetail>;
1370
+ 'daw-annotation-update': CustomEvent<DawAnnotationUpdateDetail>;
1371
+ 'daw-annotation-select': CustomEvent<DawAnnotationSelectDetail>;
1372
+ 'daw-annotation-track-connected': CustomEvent<DawAnnotationTrackConnectedDetail>;
1180
1373
  }
1181
1374
  type DawEvent<K extends keyof DawEventMap> = DawEventMap[K];
1182
1375
  interface LoadFilesResult {
@@ -1375,12 +1568,13 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1375
1568
  _engineTracks: Map<string, ClipTrack>;
1376
1569
  _peaksData: Map<string, PeakData>;
1377
1570
  _isPlaying: boolean;
1378
- private _duration;
1571
+ _duration: number;
1379
1572
  _selectedTrackId: string | null;
1380
1573
  _dragOver: boolean;
1381
1574
  _selectionStartTime: number;
1382
1575
  _selectionEndTime: number;
1383
1576
  _currentTime: number;
1577
+ _activePlayEndTime: number | null;
1384
1578
  set adapter(value: PlayoutAdapter | null);
1385
1579
  get adapter(): PlayoutAdapter | null;
1386
1580
  private _externalAdapter;
@@ -1482,6 +1676,10 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1482
1676
  private _audioResume;
1483
1677
  eagerResume?: string;
1484
1678
  private _recordingController;
1679
+ private _annotations;
1680
+ /** Last engine BPM seen by the statechange handler — re-derives tick
1681
+ * annotation seconds caches only when it actually changes. */
1682
+ private _lastAnnotationBpm;
1485
1683
  private _playbackAnimation;
1486
1684
  /**
1487
1685
  * True while a seek-while-playing stop+play transition is in flight.
@@ -1490,8 +1688,17 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1490
1688
  * play-start position). Non-private: pointer-handler's seek path sets it.
1491
1689
  */
1492
1690
  _inSeekTransition: boolean;
1691
+ /**
1692
+ * True while `stop()` (the public API) is actively calling `this._engine.stop()`.
1693
+ * Suppresses the engine 'stop' handler's own `daw-stop` dispatch — `stop()`
1694
+ * dispatches its own, and without this guard a consumer-initiated stop would
1695
+ * fire `daw-stop` twice. See the engine 'stop' handler for the counterpart
1696
+ * engine-initiated case this flag does NOT suppress.
1697
+ */
1698
+ private _inConsumerStop;
1493
1699
  private _spectrogramController;
1494
1700
  private _clipPointer;
1701
+ private _annotationDrag;
1495
1702
  get _clipHandler(): ClipPointerHandler | null;
1496
1703
  get engine(): PlaylistEngine | null;
1497
1704
  get renderSamplesPerPixel(): number;
@@ -1513,11 +1720,15 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1513
1720
  * In beats mode, derive samplesPerPixel from ticksPerPixel so that
1514
1721
  * clip positions, waveforms, and the tick-space grid all align.
1515
1722
  */
1516
- private get _renderSpp();
1723
+ get _renderSpp(): number;
1517
1724
  /** Convert seconds to ticks — uses callback if provided, otherwise single-BPM fallback. */
1518
1725
  _secondsToTicks(seconds: number): number;
1519
1726
  /** Convert ticks to seconds — uses callback if provided, otherwise single-BPM fallback. */
1520
1727
  _ticksToSeconds(ticks: number): number;
1728
+ /** Clamp limit for annotation boundary edits. indefinite-playback removes the
1729
+ * end-of-timeline bound — annotations may extend past the audio (DAW-style
1730
+ * unbounded timeline); the shared boundary math treats Infinity as "no end cap". */
1731
+ get _annotationClampDuration(): number;
1521
1732
  private get _totalWidth();
1522
1733
  /** Grid height when no tracks exist — matches scroll area's rendered height. */
1523
1734
  private get _emptyGridHeight();
@@ -1545,6 +1756,8 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1545
1756
  */
1546
1757
  private _lastSpectrogramViewport;
1547
1758
  protected updated(_changed: Map<string, unknown>): void;
1759
+ private _onAnnotationTrackConnected;
1760
+ private _onAnnotationSelect;
1548
1761
  private _onTrackConnected;
1549
1762
  private _onTrackRemoved;
1550
1763
  private _onTrackUpdate;
@@ -1708,7 +1921,11 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1708
1921
  */
1709
1922
  updateClip(trackId: string, clipId: string, partial: Partial<ClipConfig>): void;
1710
1923
  private _buildClipElement;
1711
- play(startTime?: number): Promise<void>;
1924
+ /**
1925
+ * Start playback, optionally seeking to `startTime` first. When `endTime`
1926
+ * is provided, playback stops at that time (selection/annotation playback).
1927
+ */
1928
+ play(startTime?: number, endTime?: number): Promise<void>;
1712
1929
  pause(): void;
1713
1930
  stop(): void;
1714
1931
  /** Toggle between play and pause. */
@@ -2124,6 +2341,12 @@ declare class AudioResumeController implements ReactiveController {
2124
2341
  private _removeListeners;
2125
2342
  }
2126
2343
 
2344
+ /**
2345
+ * Fixed lane height. A TS constant (not a CSS var) because the frozen-panes
2346
+ * controls-column spacer and the beats-grid top offset need it in layout math.
2347
+ */
2348
+ declare const ANNOTATION_LANE_HEIGHT = 32;
2349
+
2127
2350
  interface PlayheadLike {
2128
2351
  setPosition(px: number): void;
2129
2352
  }
@@ -2238,4 +2461,4 @@ declare function registerEffect(type: string, definition: EffectDefinition): voi
2238
2461
  declare function getEffectDefinitions(): Map<string, EffectDefinition>;
2239
2462
  declare function createEffectInstance(type: string, audioContext: BaseAudioContext, params?: Record<string, number>): CreatedEffect;
2240
2463
 
2241
- 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, DawPlayerElement, 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 TrackWithId, type UndoShortcutMap, type WaveformSegment, createEffectInstance, formatDisplayTime, getEffectDefinitions, isDomClip, isTimeDisplayFormat, parseDisplayTime, registerEffect, resolveTransportTarget, splitAtPlayhead, targetSupports, warnOnce, warnUnsupportedOnce };
2464
+ export { ANNOTATION_LANE_HEIGHT, AudioResumeController, type ClipConfig, type ClipDescriptor, type ClipEngineContract, ClipPointerHandler, type ClipPointerHost, type DawAnnotationConnectedDetail, DawAnnotationElement, DawAnnotationListElement, type DawAnnotationSelectDetail, type DawAnnotationTrackConnectedDetail, DawAnnotationTrackElement, type DawAnnotationUpdateDetail, 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, DawPlayerElement, 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 TrackWithId, type UndoShortcutMap, type WaveformSegment, createEffectInstance, formatDisplayTime, getEffectDefinitions, isDomClip, isTimeDisplayFormat, parseDisplayTime, registerEffect, resolveTransportTarget, splitAtPlayhead, targetSupports, warnOnce, warnUnsupportedOnce };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,187 @@
1
1
  import * as lit from 'lit';
2
2
  import { LitElement, PropertyValues, ReactiveController, ReactiveControllerHost } from 'lit';
3
- import { MidiNoteData, RenderMode, SpectrogramConfig, Peaks, Bits, FadeType, PeakData, MeterEntry, SnapTo, ColorMapValue, ClipTrack, KeyboardShortcut } from '@waveform-playlist/core';
3
+ import { AnnotationData, AnnotationShortcutMap, MidiNoteData, RenderMode, SpectrogramConfig, Peaks, Bits, FadeType, PeakData, MeterEntry, SnapTo, ColorMapValue, ClipTrack, KeyboardShortcut } from '@waveform-playlist/core';
4
4
  import WaveformData from 'waveform-data';
5
5
  import { PlayoutAdapter, PlaylistEngine } from '@waveform-playlist/engine';
6
6
  import { MidiLoadOptions, MidiLoadResult } from '@dawcore/midi';
7
7
  import { ClipRegistration, CanvasRegistration, ViewportState } from '@dawcore/spectrogram';
8
8
 
9
+ /**
10
+ * Declarative annotation data element (light DOM). Its `start`/`end`
11
+ * attributes and text content ARE the single source of truth — the editor's
12
+ * annotation lane and <daw-annotation-list> both derive from them.
13
+ */
14
+ declare class DawAnnotationElement extends LitElement {
15
+ /** Start time in seconds. Reflected — attribute writes drive both views. */
16
+ get start(): number;
17
+ set start(value: number);
18
+ private _start;
19
+ /** End time in seconds. Reflected. */
20
+ get end(): number;
21
+ set end(value: number);
22
+ private _end;
23
+ /** Musical start position (ticks). Authoritative when end-tick is also set —
24
+ * start/end seconds become a derived cache the host editor keeps fresh
25
+ * (clip startTick pattern). */
26
+ get startTick(): number | null;
27
+ set startTick(value: number | null);
28
+ private _startTick;
29
+ /** Musical end position (ticks). See startTick. */
30
+ get endTick(): number | null;
31
+ set endTick(value: number | null);
32
+ private _endTick;
33
+ /** Tick-based iff BOTH tick attributes are set (authority rule). */
34
+ get isTickBased(): boolean;
35
+ private _warnedHalfTick;
36
+ private readonly _generatedId;
37
+ /** Stable identity: the id attribute when present, else a generated UUID. */
38
+ get annotationId(): string;
39
+ toAnnotationData(): AnnotationData;
40
+ createRenderRoot(): this;
41
+ connectedCallback(): void;
42
+ private _hasRendered;
43
+ updated(changed: PropertyValues): void;
44
+ }
45
+ declare global {
46
+ interface HTMLElementTagNameMap {
47
+ 'daw-annotation': DawAnnotationElement;
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Declarative annotation track (light DOM). Children are <daw-annotation>
53
+ * elements — their attributes are the single source of truth. This element
54
+ * owns the ephemeral selection state and the programmatic API; the host
55
+ * <daw-editor> renders the timeline lane, <daw-annotation-list> renders the
56
+ * text panel.
57
+ */
58
+ declare class DawAnnotationTrackElement extends LitElement {
59
+ editable: boolean;
60
+ linkEndpoints: boolean;
61
+ continuousPlay: boolean;
62
+ keyboardControls: boolean;
63
+ /** Lane box label mode: 'text' (default) | 'id' (sonnet-style: explicit id
64
+ * attribute, else 1-based position) | 'none' (pure region bars). The list
65
+ * always shows full text — this only affects the timeline lane. */
66
+ boxLabel: 'text' | 'id' | 'none';
67
+ /** Display label for the editor's controls-column lane row (mirrors
68
+ * <daw-track name>). Empty = blank spacer (opt-in, no layout change). */
69
+ name: string;
70
+ private _activeAnnotationId;
71
+ get activeAnnotationId(): string | null;
72
+ set activeAnnotationId(value: string | null);
73
+ /** Child annotation elements, sorted by start time. */
74
+ get annotationElements(): DawAnnotationElement[];
75
+ get annotations(): AnnotationData[];
76
+ selectNext(): void;
77
+ selectPrevious(): void;
78
+ selectFirst(): void;
79
+ selectLast(): void;
80
+ clearSelection(): void;
81
+ /** offset: +1 next / -1 previous; noSelectionIndex: 0 → first, -1 → last. */
82
+ private _selectByOffset;
83
+ playActive(): void;
84
+ moveStartBoundary(deltaMs: number): void;
85
+ moveEndBoundary(deltaMs: number): void;
86
+ private _moveBoundary;
87
+ private _timelineDuration;
88
+ private _activeElement;
89
+ private _hostEditor;
90
+ private _annotationShortcuts;
91
+ private _resolvedShortcuts;
92
+ get annotationShortcuts(): AnnotationShortcutMap | null;
93
+ set annotationShortcuts(value: AnnotationShortcutMap | null);
94
+ private _shortcutEntries;
95
+ private static readonly _boundaryActions;
96
+ private _onKeyDownCapture;
97
+ private _runShortcutAction;
98
+ private _childObserver;
99
+ createRenderRoot(): this;
100
+ connectedCallback(): void;
101
+ disconnectedCallback(): void;
102
+ }
103
+ declare global {
104
+ interface HTMLElementTagNameMap {
105
+ 'daw-annotation-track': DawAnnotationTrackElement;
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Scrollable text panel over a <daw-annotation-track>'s children — the same
111
+ * <daw-annotation> elements the editor lane renders (single source of truth).
112
+ * Linked via the `for` attribute (id of the track element).
113
+ */
114
+ declare class DawAnnotationListElement extends LitElement {
115
+ for: string;
116
+ /** `'time'` (default): m:ss.mmm clock times, unchanged. `'bars'`: B.b – B.b
117
+ * bar.beat ranges resolved via the host editor's meter map — falls back
118
+ * to time display (and warns once) when no `<daw-editor>` ancestor is
119
+ * found via `this.track?.closest('daw-editor')`. */
120
+ timeDisplay: 'time' | 'bars';
121
+ /** Suppress re-render while a row's text is being edited. */
122
+ private _editingId;
123
+ private _activeId;
124
+ /** Playback-following highlight, separate from `_activeId` (selection) so
125
+ * playback never disturbs selection/keyboard editing. Driven by
126
+ * daw-timeupdate, cleared on daw-stop, retained on pause. */
127
+ private _playingId;
128
+ private _observer;
129
+ private _observedTrack;
130
+ private _warnedMissing;
131
+ /** Warn once per resolved `for` target when bars mode can't find a host
132
+ * editor — reset alongside `_warnedMissing` on `for` change so a
133
+ * retargeted list can warn again for its new target. */
134
+ private _warnedNoEditorForBars;
135
+ /** Set around `_cancelEdit`'s `span.blur()` so the resulting synchronous
136
+ * blur event doesn't re-enter `_commitEdit` (cancel already restores the
137
+ * text and clears `_editingId` itself). */
138
+ private _cancelling;
139
+ static styles: lit.CSSResult;
140
+ get track(): DawAnnotationTrackElement | null;
141
+ protected willUpdate(changed: Map<string, unknown>): void;
142
+ connectedCallback(): void;
143
+ disconnectedCallback(): void;
144
+ protected shouldUpdate(): boolean;
145
+ protected updated(): void;
146
+ /**
147
+ * Text content is set imperatively, NOT bound as a Lit expression.
148
+ * contenteditable mutates the span's DOM directly as the user types —
149
+ * that ejects lit-html's ChildPart marker comments for any binding at
150
+ * that position, so a later Lit-driven re-render of the same row throws
151
+ * "ChildPart has no parentNode". Keeping the span's children entirely
152
+ * outside Lit's diffing sidesteps the crash; the (soon-to-commit) edited
153
+ * row is skipped via the _editingId check.
154
+ */
155
+ private _syncRowText;
156
+ /** (Re)attach the MutationObserver when the resolved track changes. */
157
+ private _ensureObserver;
158
+ private _onSelect;
159
+ /**
160
+ * Update only on annotation-boundary crossings, not per animation frame.
161
+ * `shouldUpdate()` suppresses the resulting render while a row is being
162
+ * edited (`_editingId`) — intentional, not bypassed here. A boundary
163
+ * crossed mid-edit is caught up on the NEXT crossing after the edit ends;
164
+ * the highlight is briefly stale in that window, which is acceptable
165
+ * (edits are rare and short-lived relative to playback).
166
+ */
167
+ private _onTimeUpdate;
168
+ private _onStop;
169
+ private _onRowClick;
170
+ /** Formats a row's times span per `timeDisplay`. `'bars'` resolves the
171
+ * host editor once (shared across all rows in a render) and falls back
172
+ * to time display, warning once, when no editor is found. */
173
+ private _formatTimes;
174
+ private _annotationElement;
175
+ private _commitEdit;
176
+ private _cancelEdit;
177
+ render(): lit.TemplateResult<1>;
178
+ }
179
+ declare global {
180
+ interface HTMLElementTagNameMap {
181
+ 'daw-annotation-list': DawAnnotationListElement;
182
+ }
183
+ }
184
+
9
185
  declare class DawClipElement extends LitElement {
10
186
  src: string;
11
187
  peaksSrc: string;
@@ -1137,6 +1313,19 @@ interface DawEffectErrorDetail {
1137
1313
  type?: string;
1138
1314
  message: string;
1139
1315
  }
1316
+ interface DawAnnotationConnectedDetail {
1317
+ annotationId: string;
1318
+ element: HTMLElement;
1319
+ }
1320
+ interface DawAnnotationUpdateDetail {
1321
+ annotationId: string;
1322
+ }
1323
+ interface DawAnnotationSelectDetail {
1324
+ annotation: AnnotationData | null;
1325
+ }
1326
+ interface DawAnnotationTrackConnectedDetail {
1327
+ element: HTMLElement;
1328
+ }
1140
1329
  interface DawEventMap {
1141
1330
  'daw-selection': CustomEvent<DawSelectionDetail>;
1142
1331
  'daw-seek': CustomEvent<DawSeekDetail>;
@@ -1177,6 +1366,10 @@ interface DawEventMap {
1177
1366
  'daw-effect-bypass': CustomEvent<DawEffectBypassDetail>;
1178
1367
  'daw-effect-reorder': CustomEvent<DawEffectReorderDetail>;
1179
1368
  'daw-effect-error': CustomEvent<DawEffectErrorDetail>;
1369
+ 'daw-annotation-connected': CustomEvent<DawAnnotationConnectedDetail>;
1370
+ 'daw-annotation-update': CustomEvent<DawAnnotationUpdateDetail>;
1371
+ 'daw-annotation-select': CustomEvent<DawAnnotationSelectDetail>;
1372
+ 'daw-annotation-track-connected': CustomEvent<DawAnnotationTrackConnectedDetail>;
1180
1373
  }
1181
1374
  type DawEvent<K extends keyof DawEventMap> = DawEventMap[K];
1182
1375
  interface LoadFilesResult {
@@ -1375,12 +1568,13 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1375
1568
  _engineTracks: Map<string, ClipTrack>;
1376
1569
  _peaksData: Map<string, PeakData>;
1377
1570
  _isPlaying: boolean;
1378
- private _duration;
1571
+ _duration: number;
1379
1572
  _selectedTrackId: string | null;
1380
1573
  _dragOver: boolean;
1381
1574
  _selectionStartTime: number;
1382
1575
  _selectionEndTime: number;
1383
1576
  _currentTime: number;
1577
+ _activePlayEndTime: number | null;
1384
1578
  set adapter(value: PlayoutAdapter | null);
1385
1579
  get adapter(): PlayoutAdapter | null;
1386
1580
  private _externalAdapter;
@@ -1482,6 +1676,10 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1482
1676
  private _audioResume;
1483
1677
  eagerResume?: string;
1484
1678
  private _recordingController;
1679
+ private _annotations;
1680
+ /** Last engine BPM seen by the statechange handler — re-derives tick
1681
+ * annotation seconds caches only when it actually changes. */
1682
+ private _lastAnnotationBpm;
1485
1683
  private _playbackAnimation;
1486
1684
  /**
1487
1685
  * True while a seek-while-playing stop+play transition is in flight.
@@ -1490,8 +1688,17 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1490
1688
  * play-start position). Non-private: pointer-handler's seek path sets it.
1491
1689
  */
1492
1690
  _inSeekTransition: boolean;
1691
+ /**
1692
+ * True while `stop()` (the public API) is actively calling `this._engine.stop()`.
1693
+ * Suppresses the engine 'stop' handler's own `daw-stop` dispatch — `stop()`
1694
+ * dispatches its own, and without this guard a consumer-initiated stop would
1695
+ * fire `daw-stop` twice. See the engine 'stop' handler for the counterpart
1696
+ * engine-initiated case this flag does NOT suppress.
1697
+ */
1698
+ private _inConsumerStop;
1493
1699
  private _spectrogramController;
1494
1700
  private _clipPointer;
1701
+ private _annotationDrag;
1495
1702
  get _clipHandler(): ClipPointerHandler | null;
1496
1703
  get engine(): PlaylistEngine | null;
1497
1704
  get renderSamplesPerPixel(): number;
@@ -1513,11 +1720,15 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1513
1720
  * In beats mode, derive samplesPerPixel from ticksPerPixel so that
1514
1721
  * clip positions, waveforms, and the tick-space grid all align.
1515
1722
  */
1516
- private get _renderSpp();
1723
+ get _renderSpp(): number;
1517
1724
  /** Convert seconds to ticks — uses callback if provided, otherwise single-BPM fallback. */
1518
1725
  _secondsToTicks(seconds: number): number;
1519
1726
  /** Convert ticks to seconds — uses callback if provided, otherwise single-BPM fallback. */
1520
1727
  _ticksToSeconds(ticks: number): number;
1728
+ /** Clamp limit for annotation boundary edits. indefinite-playback removes the
1729
+ * end-of-timeline bound — annotations may extend past the audio (DAW-style
1730
+ * unbounded timeline); the shared boundary math treats Infinity as "no end cap". */
1731
+ get _annotationClampDuration(): number;
1521
1732
  private get _totalWidth();
1522
1733
  /** Grid height when no tracks exist — matches scroll area's rendered height. */
1523
1734
  private get _emptyGridHeight();
@@ -1545,6 +1756,8 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1545
1756
  */
1546
1757
  private _lastSpectrogramViewport;
1547
1758
  protected updated(_changed: Map<string, unknown>): void;
1759
+ private _onAnnotationTrackConnected;
1760
+ private _onAnnotationSelect;
1548
1761
  private _onTrackConnected;
1549
1762
  private _onTrackRemoved;
1550
1763
  private _onTrackUpdate;
@@ -1708,7 +1921,11 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1708
1921
  */
1709
1922
  updateClip(trackId: string, clipId: string, partial: Partial<ClipConfig>): void;
1710
1923
  private _buildClipElement;
1711
- play(startTime?: number): Promise<void>;
1924
+ /**
1925
+ * Start playback, optionally seeking to `startTime` first. When `endTime`
1926
+ * is provided, playback stops at that time (selection/annotation playback).
1927
+ */
1928
+ play(startTime?: number, endTime?: number): Promise<void>;
1712
1929
  pause(): void;
1713
1930
  stop(): void;
1714
1931
  /** Toggle between play and pause. */
@@ -2124,6 +2341,12 @@ declare class AudioResumeController implements ReactiveController {
2124
2341
  private _removeListeners;
2125
2342
  }
2126
2343
 
2344
+ /**
2345
+ * Fixed lane height. A TS constant (not a CSS var) because the frozen-panes
2346
+ * controls-column spacer and the beats-grid top offset need it in layout math.
2347
+ */
2348
+ declare const ANNOTATION_LANE_HEIGHT = 32;
2349
+
2127
2350
  interface PlayheadLike {
2128
2351
  setPosition(px: number): void;
2129
2352
  }
@@ -2238,4 +2461,4 @@ declare function registerEffect(type: string, definition: EffectDefinition): voi
2238
2461
  declare function getEffectDefinitions(): Map<string, EffectDefinition>;
2239
2462
  declare function createEffectInstance(type: string, audioContext: BaseAudioContext, params?: Record<string, number>): CreatedEffect;
2240
2463
 
2241
- 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, DawPlayerElement, 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 TrackWithId, type UndoShortcutMap, type WaveformSegment, createEffectInstance, formatDisplayTime, getEffectDefinitions, isDomClip, isTimeDisplayFormat, parseDisplayTime, registerEffect, resolveTransportTarget, splitAtPlayhead, targetSupports, warnOnce, warnUnsupportedOnce };
2464
+ export { ANNOTATION_LANE_HEIGHT, AudioResumeController, type ClipConfig, type ClipDescriptor, type ClipEngineContract, ClipPointerHandler, type ClipPointerHost, type DawAnnotationConnectedDetail, DawAnnotationElement, DawAnnotationListElement, type DawAnnotationSelectDetail, type DawAnnotationTrackConnectedDetail, DawAnnotationTrackElement, type DawAnnotationUpdateDetail, 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, DawPlayerElement, 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 TrackWithId, type UndoShortcutMap, type WaveformSegment, createEffectInstance, formatDisplayTime, getEffectDefinitions, isDomClip, isTimeDisplayFormat, parseDisplayTime, registerEffect, resolveTransportTarget, splitAtPlayhead, targetSupports, warnOnce, warnUnsupportedOnce };