@dawcore/components 0.0.39-next.3 → 0.0.39-next.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,9 +9,9 @@ Framework-agnostic Web Components for multi-track audio editing. Drop `<daw-edit
9
9
  - **Canvas waveforms** — Chunked rendering with virtual scrolling for large timelines
10
10
  - **Drag interactions** — Move clips, trim boundaries, split at playhead
11
11
  - **Keyboard shortcuts** — Play/pause, split, undo/redo via `<daw-keyboard-shortcuts>`
12
- - **Undo/redo** — Full transaction-based undo with Cmd/Ctrl+Z and Cmd/Ctrl+Shift+Z
12
+ - **Undo/redo** — Full transaction-based undo with Cmd/Ctrl+Z and Cmd/Ctrl+Shift+Z; mixer moves are undo steps too (one per slider drag, click, attribute update or `updateTrack` call)
13
13
  - **File drop** — Drag audio files onto the editor to add tracks (enable with the `file-drop` attribute)
14
- - **Recording** — Live mic recording with waveform preview (full clip chrome incl. header while capturing), pause/resume, cancelable clip creation; takes land at the playhead and replace overlapped clip content (punch-in), the recorded-over track is transiently muted during the take, and the end-of-timeline auto-stop is suppressed so takes run past existing audio
14
+ - **Recording** — Live mic recording with waveform preview (full clip chrome incl. header while capturing), pause/resume, cancelable clip creation; takes land at the playhead and replace overlapped clip content (punch-in), the recorded-over track plays muted during the take, and the end-of-timeline auto-stop is suppressed so takes run past existing audio
15
15
  - **Pre-computed peaks** — Instant waveform rendering from `.dat` files before audio decodes
16
16
  - **MIDI tracks** — Declarative or programmatic MIDI clips render as piano-roll. Playback via the Tone.js adapter. See [MIDI Tracks](#midi-tracks).
17
17
  - **MIDI file loading** — `editor.loadMidi(urlOrFile)` parses a `.mid` file into piano-roll tracks via the optional `@dawcore/midi` peer
@@ -394,7 +394,7 @@ A recorded take has no `<daw-clip>` element; its engine clip id is the `clipId`
394
394
 
395
395
  `daw-recording-clip-add` is not guaranteed after every `daw-recording-complete`: it is skipped when you cancel the complete event, when peak generation for the take fails (`daw-error` with `operation: 'recording-peaks'`), and when the track was removed in the meantime.
396
396
 
397
- During a take the editor shows the live preview with full clip chrome (header label from `RecordingOptions.clipName`, default "Recording…"), transiently mutes the recorded track (punch-in replaces whatever the take overlaps, so the doomed material never plays under the overdub — the track's Mute control is untouched and the previous state is restored when the session ends), and suppresses the end-of-timeline auto-stop so the take can run past existing audio.
397
+ During a take the editor shows the live preview with full clip chrome (header label from `RecordingOptions.clipName`, default "Recording…"), mutes the recorded track for the take (punch-in replaces whatever the take overlaps, so the doomed material never plays under the overdub: the track plays muted, its controls and `editor.tracks` show it muted, and an `exportAudio()` during the take leaves it out; the take's mute is not an undo step and does not change the track's own mute, so a mute changed during the take stays after it), and suppresses the end-of-timeline auto-stop so the take can run past existing audio.
398
398
 
399
399
  ## Single-Track Player
400
400
 
@@ -436,10 +436,12 @@ Add `<daw-keyboard-shortcuts>` as a child of `<daw-editor>`:
436
436
 
437
437
  | Attribute | Shortcuts |
438
438
  |-----------|-----------|
439
- | `playback` | Space (play/pause), Enter (stop) |
439
+ | `playback` | Space (play/pause), Escape (stop), 0 (rewind to start) |
440
440
  | `splitting` | S (split at playhead) |
441
441
  | `undo` | Cmd/Ctrl+Z (undo), Cmd/Ctrl+Shift+Z (redo) |
442
442
 
443
+ During a clip move or trim, or a track-reorder drag, undo and redo do nothing (the keys and `editor.undo()` / `redo()`), and Escape only cancels the drag: it does not also stop playback.
444
+
443
445
  Custom shortcuts via JS properties: `playbackShortcuts`, `splittingShortcuts`, `undoShortcuts`, `customShortcuts`.
444
446
 
445
447
  ## CSS Theming
@@ -508,7 +510,7 @@ Methods:
508
510
 
509
511
  ### `<daw-track>`
510
512
 
511
- Declarative track data. Attributes: `src`, `name`, `volume`, `pan`, `muted`, `soloed`, `kind` (`'audio' | 'midi'`, default `'audio'`: what the track holds; set it before the track is added), `render-mode` (`'waveform' | 'spectrogram'`, default `'waveform'`: how an audio track is drawn; a MIDI track is always a piano roll). JS property: `spectrogramConfig` (per-track spectrogram override). Also exposes the per-track effects API (see [Effects](#effects)).
513
+ Declarative track data. Attributes: `src`, `name`, `volume`, `pan`, `muted`, `soloed`, `kind` (`'audio' | 'midi'`, default `'audio'`: what the track holds; set it before the track is added), `render-mode` (`'waveform' | 'spectrogram'`, default `'waveform'`: how an audio track is drawn; a MIDI track is always a piano roll). JS property: `spectrogramConfig` (per-track spectrogram override). Also exposes the per-track effects API (see [Effects](#effects)). Fires `daw-track-update` `{ trackId, changed }` after a property changes (`changed` names them). A `volume`, `pan`, `muted` or `soloed` change after the track has loaded is one undo step per update; while it loads, the change sets the values it enters with. The editor does not write the element back after an Undo: read the restored mix from `editor.tracks`. Every track load clears the undo history (a known limit, #848), so steps made while a track is still loading cannot be undone once it has finished.
512
514
 
513
515
  ### `<daw-clip>`
514
516
 
@@ -524,7 +526,7 @@ Container that resolves target editor. Children: `<daw-play-button>`, `<daw-paus
524
526
 
525
527
  ### `<daw-track-controls>`
526
528
 
527
- Per-track UI for volume, pan, mute, solo. Receives state from editor, dispatches `daw-track-control` and `daw-track-remove` events.
529
+ Per-track UI for volume, pan, mute, solo. Draws the arrangement's mix (so it follows Undo and Redo), dispatches `daw-track-control` and `daw-track-remove` events. One slider drag or key press is one undo step, each Mute or Solo click is one. Keyboard Undo does not fire while a slider has focus.
528
530
 
529
531
  ### `<daw-keyboard-shortcuts>`
530
532
 
package/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@ import * as lit from 'lit';
2
2
  import { LitElement, PropertyValues, ReactiveController, ReactiveControllerHost } from 'lit';
3
3
  import { AnnotationData, AnnotationShortcutMap, MidiNoteData, TrackKind, RenderMode, SpectrogramConfig, Peaks, Bits, FadeType, PeakData, MeterEntry, SnapTo, ColorMapValue, ClipTrack, KeyboardShortcut } from '@waveform-playlist/core';
4
4
  import WaveformData from 'waveform-data';
5
- import { PlayoutAdapter, PlaylistEngine } from '@waveform-playlist/engine';
5
+ import { TrackMixerValues, 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
 
@@ -555,6 +555,14 @@ interface TrackDescriptor {
555
555
  spectrogramConfig?: SpectrogramConfig | null;
556
556
  clips: ClipDescriptor[];
557
557
  }
558
+ /** The mixer fields of a `TrackDescriptor`. */
559
+ type TrackMixFields = 'volume' | 'pan' | 'muted' | 'soloed';
560
+ /**
561
+ * What `<daw-editor>` stores per track (internal, not exported from the
562
+ * package): a `TrackDescriptor` without its mix. The mix is the arrangement's
563
+ * (#843); `editor.tracks` fills the four fields in from it.
564
+ */
565
+ type StoredTrackDescriptor = Omit<TrackDescriptor, TrackMixFields>;
558
566
  /** A `TrackDescriptor` plus its `trackId` — the shape returned by `editor.tracks`
559
567
  * so consumers can map a track's name to the `trackId` the per-track APIs
560
568
  * (`addTrackEffect`, `removeTrack`, `updateTrack`, …) are keyed by. */
@@ -767,19 +775,35 @@ declare class DawTrackControlsElement extends LitElement {
767
775
  volume: number;
768
776
  pan: number;
769
777
  muted: boolean;
778
+ /** A take is recording onto the track: it plays muted, and the M button is disabled. */
779
+ recording: boolean;
770
780
  soloed: boolean;
771
781
  /** Show the reorder grip + move up/down buttons (set by the editor from
772
782
  * its track-reordering attribute). */
773
783
  reorderable: boolean;
774
784
  trackIndex: number;
775
785
  trackCount: number;
786
+ /**
787
+ * One gesture per slider (#843): the `daw-track-control` events of one
788
+ * drag, or of one key press (a held key included), carry the same
789
+ * `gesture` id, and the editor makes them one undo step. Each gesture is
790
+ * attached to its range input while the element is connected.
791
+ */
792
+ private readonly _volumeGesture;
793
+ private readonly _panGesture;
794
+ private _detachGestures;
776
795
  static styles: lit.CSSResult;
796
+ connectedCallback(): void;
797
+ disconnectedCallback(): void;
798
+ private _attachGestures;
799
+ private _detachAllGestures;
777
800
  protected firstUpdated(): void;
778
801
  private _onVolumeInput;
779
802
  private _onPanInput;
780
803
  private _onMuteClick;
781
804
  private _onSoloClick;
782
805
  private _onRemoveClick;
806
+ /** `gesture` for the sliders only: each mute or solo click is a step. */
783
807
  private _dispatchControl;
784
808
  private _dispatchReorder;
785
809
  private _onMoveUp;
@@ -880,9 +904,6 @@ interface RecordingSession {
880
904
  readonly latencySamples: number;
881
905
  /** Display name for the take (preview header + finalized clip name). */
882
906
  readonly clipName?: string;
883
- /** Pre-session mute state of the armed track — restored when the session
884
- * ends. null = mute never engaged (no engine on the host). */
885
- armedPrevMuted: boolean | null;
886
907
  readonly wasOverdub: boolean;
887
908
  /** Stored so it can be removed on stop/cleanup — not just when stream ends. */
888
909
  readonly _onTrackEnded: (() => void) | null;
@@ -921,18 +942,14 @@ interface RecordingHost extends ReactiveControllerHost {
921
942
  readonly shadowRoot: ShadowRoot | null;
922
943
  resolveAudioContextSampleRate(rate: number): void;
923
944
  _addRecordedClip?(trackId: string, buf: AudioBuffer, startSample: number, durSamples: number, offsetSamples?: number, clipName?: string): void;
924
- /** Structural view of the editor's engine for the armed-track transient
925
- * mute (punch-in replaces the overlapped content, so the recorded-over
926
- * track's existing material must not play under the take). Optional —
927
- * hosts without an engine skip the mute. */
945
+ /** Structural view of the editor's engine for the take's mute (#843):
946
+ * punch-in replaces the overlapped content, so the recorded-over track's
947
+ * existing material must not play under the take. The track a take is
948
+ * recording onto plays muted; that mute is outside the undo history and
949
+ * leaves the stored mute alone. Optional — hosts without an engine skip
950
+ * it. */
928
951
  _engine?: {
929
- setTrackMute(trackId: string, muted: boolean): void;
930
- getState(): {
931
- tracks: ReadonlyArray<{
932
- id: string;
933
- muted: boolean;
934
- }>;
935
- };
952
+ setTrackRecording(trackId: string, recording: boolean): void;
936
953
  } | null;
937
954
  play?(startTime?: number): Promise<void>;
938
955
  stop?(): void;
@@ -994,13 +1011,16 @@ declare class RecordingController implements ReactiveController {
994
1011
  private _removeTrackEndedListener;
995
1012
  private _dispatchRecordingError;
996
1013
  /** Shared teardown for finalize paths that end without a take (no data
997
- * captured / too short after latency compensation): restore the armed-track
998
- * mute, drop the session, and notify via daw-recording-error so record
999
- * buttons reset their state. */
1014
+ * captured / too short after latency compensation): clear the take's mute, drop
1015
+ * the session, and notify via daw-recording-error so record buttons reset
1016
+ * their state. */
1000
1017
  private _abandonFinalize;
1001
- /** Restore the armed track's pre-session mute state (idempotent — safe to
1002
- * call from both the finalize path and _cleanupSession). */
1003
- private _restoreArmedTrackMute;
1018
+ /** Clear the take's mute on the session's track, by its id. Each teardown
1019
+ * path calls this once, right before it drops the session from the map, so
1020
+ * a later path never reaches the same session; clearing an id that is not
1021
+ * set is a no-op in the engine. Another session's mute on another track is
1022
+ * left alone. */
1023
+ private _clearTakeMute;
1004
1024
  /** @param notifyError dispatch daw-recording-error after cleanup — used by
1005
1025
  * disposal paths that would otherwise discard the session silently. The
1006
1026
  * startRecording catch path passes false (it dispatches its own error). */
@@ -1098,12 +1118,24 @@ declare class ClipPointerHandler {
1098
1118
  private _snapDeltaToSamples;
1099
1119
  /** Returns true if a drag interaction is currently in progress. */
1100
1120
  get isActive(): boolean;
1121
+ /** True once the pointer of the current press has moved past the drag
1122
+ * threshold: a press that has not moved is not a drag (#848). */
1123
+ get isDragging(): boolean;
1101
1124
  /**
1102
1125
  * Attempts to handle a pointerdown event on the given target element.
1103
1126
  * Returns true if the target is a recognized clip interaction element.
1104
1127
  */
1105
1128
  tryHandle(target: Element, e: PointerEvent): boolean;
1106
1129
  private _beginDrag;
1130
+ /**
1131
+ * The press has become a drag (the pointer passed the threshold): take the
1132
+ * clip's bounds and open the transaction now, not at the press. An undo
1133
+ * made during the press (it is not a drag, so undo works) then has no
1134
+ * transaction to abort, and the drag that follows starts from the clip as
1135
+ * the undo left it, one undo step (#848, review of #915). Returns false
1136
+ * when the clip is gone (the undo removed it): the press is dropped.
1137
+ */
1138
+ private _startDrag;
1107
1139
  /** Processes pointermove events during an active drag. */
1108
1140
  onPointerMove(e: PointerEvent): void;
1109
1141
  /** Processes pointerup events to finalize and dispatch result events. */
@@ -1167,6 +1199,17 @@ interface DawTrackConnectedDetail {
1167
1199
  interface DawTrackIdDetail {
1168
1200
  trackId: string;
1169
1201
  }
1202
+ interface DawTrackUpdateDetail {
1203
+ trackId: string;
1204
+ /**
1205
+ * The `<daw-track>` properties this update changed, by property name
1206
+ * (`'volume'`, `'pan'`, `'muted'`, `'soloed'`, `'src'`, `'name'`, `'kind'`,
1207
+ * `'renderMode'`, `'spectrogramConfig'`). The editor sends a mixer property
1208
+ * to the engine only when it is in this list, and one update is one undo
1209
+ * step (#843).
1210
+ */
1211
+ changed: readonly string[];
1212
+ }
1170
1213
  interface DawTrackErrorDetail {
1171
1214
  trackId: string;
1172
1215
  error: unknown;
@@ -1188,6 +1231,12 @@ interface DawTrackControlDetail {
1188
1231
  trackId: string;
1189
1232
  prop: string;
1190
1233
  value: number | boolean;
1234
+ /**
1235
+ * The slider's gesture id (#843): events of one volume or pan drag, or of
1236
+ * one key press, carry the same id and are one undo step. Mute and solo
1237
+ * send none: each click is a step.
1238
+ */
1239
+ gesture?: string;
1191
1240
  }
1192
1241
  interface DawTrackRemoveDetail {
1193
1242
  trackId: string;
@@ -1343,7 +1392,7 @@ interface DawEventMap {
1343
1392
  'daw-time-format-change': CustomEvent<DawTimeFormatChangeDetail>;
1344
1393
  'daw-track-select': CustomEvent<DawTrackSelectDetail>;
1345
1394
  'daw-track-connected': CustomEvent<DawTrackConnectedDetail>;
1346
- 'daw-track-update': CustomEvent<DawTrackIdDetail>;
1395
+ 'daw-track-update': CustomEvent<DawTrackUpdateDetail>;
1347
1396
  'daw-track-ready': CustomEvent<DawTrackIdDetail>;
1348
1397
  'daw-track-removed': CustomEvent<DawTrackIdDetail>;
1349
1398
  'daw-track-error': CustomEvent<DawTrackErrorDetail>;
@@ -1586,7 +1635,15 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1586
1635
  get sampleRate(): number;
1587
1636
  /** Resolved sample rate — falls back to sampleRate property until first audio decode. */
1588
1637
  _resolvedSampleRate: number | null;
1589
- _tracks: Map<string, TrackDescriptor>;
1638
+ /** Per-track descriptors, without the mix: the arrangement owns that (#843). */
1639
+ _tracks: Map<string, StoredTrackDescriptor>;
1640
+ /**
1641
+ * The mix of a track the engine does not hold yet: what it will enter the
1642
+ * arrangement with (from the `<daw-track>` element or the `addTrack` config,
1643
+ * changed by a control or `updateTrack` while it loads). Deleted once
1644
+ * `engine.getState().tracks` holds the id; read only through `_mixOf`.
1645
+ */
1646
+ _seedMix: Map<string, TrackMixerValues>;
1590
1647
  _engineTracks: Map<string, ClipTrack>;
1591
1648
  _peaksData: Map<string, PeakData>;
1592
1649
  _isPlaying: boolean;
@@ -1765,6 +1822,28 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1765
1822
  private get _emptyGridHeight();
1766
1823
  _setSelectedTrackId(trackId: string | null): void;
1767
1824
  get tracks(): TrackWithId[];
1825
+ /**
1826
+ * A track's mix, from its one owner: the arrangement (through
1827
+ * `_engineTracks`, which follows `mixerVersion`) for a track the engine
1828
+ * holds, the seed for one still on its way in (#843).
1829
+ */
1830
+ _mixOf(trackId: string): TrackMixerValues;
1831
+ /** Replace a track's seed (a new Map: `_seedMix` is reactive state). */
1832
+ private _setSeedMix;
1833
+ private _deleteSeedMix;
1834
+ /**
1835
+ * Change one mixer field of a track: the seed while the track is loading
1836
+ * (not an undo step, nothing sent), else the engine's setter with
1837
+ * `options` (an undo step; changes with one `gesture` id are one step).
1838
+ */
1839
+ private _writeMix;
1840
+ /**
1841
+ * Change the given mixer fields of a track as ONE undo step (#843): all
1842
+ * of them carry one fresh gesture id. A field left out is not sent.
1843
+ */
1844
+ private _writeMixFields;
1845
+ /** The ordered tracks for `engine.setTracks`, a loading track with its seed. */
1846
+ private _tracksForEngine;
1768
1847
  get selectedTrackId(): string | null;
1769
1848
  get selection(): {
1770
1849
  start: number;
@@ -1937,10 +2016,11 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1937
2016
  private _onTrackReorder;
1938
2017
  private _onTrackReorderGrab;
1939
2018
  /**
1940
- * Update reflected attributes on a track. For DOM-element tracks the changes
1941
- * are written to the `<daw-track>` element (which fires `daw-track-update`);
1942
- * for tracks without a DOM element (file drops) the descriptor and engine
1943
- * state are updated in place.
2019
+ * Update reflected attributes on a track. The mixer fields go to their
2020
+ * owner as one undo step (#843): the engine, or while the track is loading
2021
+ * the values it will enter with (not a step). For DOM-element tracks the
2022
+ * changes are also written to the `<daw-track>` element; for tracks
2023
+ * without a DOM element (file drops) the descriptor is updated in place.
1944
2024
  */
1945
2025
  updateTrack(trackId: string, partial: Partial<TrackConfig>): void;
1946
2026
  /**
@@ -1988,9 +2068,30 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1988
2068
  * subsequent stop-settle dispatch. */
1989
2069
  private _withSeekSuppression;
1990
2070
  seekTo(time: number): void;
1991
- /** Undo the last structural edit. */
2071
+ /**
2072
+ * A clip or track drag is in progress: undo and redo do nothing until it
2073
+ * ends (#848). A clip counts once its pointer has moved past the drag
2074
+ * threshold; annotation drags do not count (annotations are not in the
2075
+ * undo history).
2076
+ */
2077
+ get _dragInProgress(): boolean;
2078
+ /**
2079
+ * Cancel every drag in progress, as a `pointercancel` would. Returns whether
2080
+ * one was. A clip or annotation press that has not moved is not a drag and
2081
+ * is left alone, unless `includePresses` (the editor's disconnect, which
2082
+ * ends every pointer interaction).
2083
+ */
2084
+ _cancelDrags(includePresses?: boolean): boolean;
2085
+ /**
2086
+ * Escape during a drag cancels it and does nothing else: the default is
2087
+ * prevented, so `<daw-keyboard-shortcuts>` (core's `handleKeyboardEvent`)
2088
+ * does not also stop playback. No `stopPropagation`: an app's own listener
2089
+ * can read `defaultPrevented`.
2090
+ */
2091
+ private _onDragEscape;
2092
+ /** Undo the last edit. Does nothing while a drag is in progress. */
1992
2093
  undo(): void;
1993
- /** Redo the last undone edit. */
2094
+ /** Redo the last undone edit. Does nothing while a drag is in progress. */
1994
2095
  redo(): void;
1995
2096
  /** Whether undo is available. */
1996
2097
  get canUndo(): boolean;
@@ -2527,4 +2628,4 @@ interface SplitHost {
2527
2628
  */
2528
2629
  declare function splitAtPlayhead(host: SplitHost): boolean;
2529
2630
 
2530
- 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 DawRecordingClipAddDetail, 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 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, formatDisplayTime, isDomClip, isTimeDisplayFormat, parseDisplayTime, resolveTransportTarget, splitAtPlayhead, targetSupports, warnOnce, warnUnsupportedOnce };
2631
+ 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 DawRecordingClipAddDetail, 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, type DawTrackUpdateDetail, DawTransportButton, DawTransportElement, DawWaveformElement, type DomClipDescriptor, type DropClipDescriptor, 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, formatDisplayTime, isDomClip, isTimeDisplayFormat, parseDisplayTime, resolveTransportTarget, splitAtPlayhead, targetSupports, warnOnce, warnUnsupportedOnce };
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as lit from 'lit';
2
2
  import { LitElement, PropertyValues, ReactiveController, ReactiveControllerHost } from 'lit';
3
3
  import { AnnotationData, AnnotationShortcutMap, MidiNoteData, TrackKind, RenderMode, SpectrogramConfig, Peaks, Bits, FadeType, PeakData, MeterEntry, SnapTo, ColorMapValue, ClipTrack, KeyboardShortcut } from '@waveform-playlist/core';
4
4
  import WaveformData from 'waveform-data';
5
- import { PlayoutAdapter, PlaylistEngine } from '@waveform-playlist/engine';
5
+ import { TrackMixerValues, 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
 
@@ -555,6 +555,14 @@ interface TrackDescriptor {
555
555
  spectrogramConfig?: SpectrogramConfig | null;
556
556
  clips: ClipDescriptor[];
557
557
  }
558
+ /** The mixer fields of a `TrackDescriptor`. */
559
+ type TrackMixFields = 'volume' | 'pan' | 'muted' | 'soloed';
560
+ /**
561
+ * What `<daw-editor>` stores per track (internal, not exported from the
562
+ * package): a `TrackDescriptor` without its mix. The mix is the arrangement's
563
+ * (#843); `editor.tracks` fills the four fields in from it.
564
+ */
565
+ type StoredTrackDescriptor = Omit<TrackDescriptor, TrackMixFields>;
558
566
  /** A `TrackDescriptor` plus its `trackId` — the shape returned by `editor.tracks`
559
567
  * so consumers can map a track's name to the `trackId` the per-track APIs
560
568
  * (`addTrackEffect`, `removeTrack`, `updateTrack`, …) are keyed by. */
@@ -767,19 +775,35 @@ declare class DawTrackControlsElement extends LitElement {
767
775
  volume: number;
768
776
  pan: number;
769
777
  muted: boolean;
778
+ /** A take is recording onto the track: it plays muted, and the M button is disabled. */
779
+ recording: boolean;
770
780
  soloed: boolean;
771
781
  /** Show the reorder grip + move up/down buttons (set by the editor from
772
782
  * its track-reordering attribute). */
773
783
  reorderable: boolean;
774
784
  trackIndex: number;
775
785
  trackCount: number;
786
+ /**
787
+ * One gesture per slider (#843): the `daw-track-control` events of one
788
+ * drag, or of one key press (a held key included), carry the same
789
+ * `gesture` id, and the editor makes them one undo step. Each gesture is
790
+ * attached to its range input while the element is connected.
791
+ */
792
+ private readonly _volumeGesture;
793
+ private readonly _panGesture;
794
+ private _detachGestures;
776
795
  static styles: lit.CSSResult;
796
+ connectedCallback(): void;
797
+ disconnectedCallback(): void;
798
+ private _attachGestures;
799
+ private _detachAllGestures;
777
800
  protected firstUpdated(): void;
778
801
  private _onVolumeInput;
779
802
  private _onPanInput;
780
803
  private _onMuteClick;
781
804
  private _onSoloClick;
782
805
  private _onRemoveClick;
806
+ /** `gesture` for the sliders only: each mute or solo click is a step. */
783
807
  private _dispatchControl;
784
808
  private _dispatchReorder;
785
809
  private _onMoveUp;
@@ -880,9 +904,6 @@ interface RecordingSession {
880
904
  readonly latencySamples: number;
881
905
  /** Display name for the take (preview header + finalized clip name). */
882
906
  readonly clipName?: string;
883
- /** Pre-session mute state of the armed track — restored when the session
884
- * ends. null = mute never engaged (no engine on the host). */
885
- armedPrevMuted: boolean | null;
886
907
  readonly wasOverdub: boolean;
887
908
  /** Stored so it can be removed on stop/cleanup — not just when stream ends. */
888
909
  readonly _onTrackEnded: (() => void) | null;
@@ -921,18 +942,14 @@ interface RecordingHost extends ReactiveControllerHost {
921
942
  readonly shadowRoot: ShadowRoot | null;
922
943
  resolveAudioContextSampleRate(rate: number): void;
923
944
  _addRecordedClip?(trackId: string, buf: AudioBuffer, startSample: number, durSamples: number, offsetSamples?: number, clipName?: string): void;
924
- /** Structural view of the editor's engine for the armed-track transient
925
- * mute (punch-in replaces the overlapped content, so the recorded-over
926
- * track's existing material must not play under the take). Optional —
927
- * hosts without an engine skip the mute. */
945
+ /** Structural view of the editor's engine for the take's mute (#843):
946
+ * punch-in replaces the overlapped content, so the recorded-over track's
947
+ * existing material must not play under the take. The track a take is
948
+ * recording onto plays muted; that mute is outside the undo history and
949
+ * leaves the stored mute alone. Optional — hosts without an engine skip
950
+ * it. */
928
951
  _engine?: {
929
- setTrackMute(trackId: string, muted: boolean): void;
930
- getState(): {
931
- tracks: ReadonlyArray<{
932
- id: string;
933
- muted: boolean;
934
- }>;
935
- };
952
+ setTrackRecording(trackId: string, recording: boolean): void;
936
953
  } | null;
937
954
  play?(startTime?: number): Promise<void>;
938
955
  stop?(): void;
@@ -994,13 +1011,16 @@ declare class RecordingController implements ReactiveController {
994
1011
  private _removeTrackEndedListener;
995
1012
  private _dispatchRecordingError;
996
1013
  /** Shared teardown for finalize paths that end without a take (no data
997
- * captured / too short after latency compensation): restore the armed-track
998
- * mute, drop the session, and notify via daw-recording-error so record
999
- * buttons reset their state. */
1014
+ * captured / too short after latency compensation): clear the take's mute, drop
1015
+ * the session, and notify via daw-recording-error so record buttons reset
1016
+ * their state. */
1000
1017
  private _abandonFinalize;
1001
- /** Restore the armed track's pre-session mute state (idempotent — safe to
1002
- * call from both the finalize path and _cleanupSession). */
1003
- private _restoreArmedTrackMute;
1018
+ /** Clear the take's mute on the session's track, by its id. Each teardown
1019
+ * path calls this once, right before it drops the session from the map, so
1020
+ * a later path never reaches the same session; clearing an id that is not
1021
+ * set is a no-op in the engine. Another session's mute on another track is
1022
+ * left alone. */
1023
+ private _clearTakeMute;
1004
1024
  /** @param notifyError dispatch daw-recording-error after cleanup — used by
1005
1025
  * disposal paths that would otherwise discard the session silently. The
1006
1026
  * startRecording catch path passes false (it dispatches its own error). */
@@ -1098,12 +1118,24 @@ declare class ClipPointerHandler {
1098
1118
  private _snapDeltaToSamples;
1099
1119
  /** Returns true if a drag interaction is currently in progress. */
1100
1120
  get isActive(): boolean;
1121
+ /** True once the pointer of the current press has moved past the drag
1122
+ * threshold: a press that has not moved is not a drag (#848). */
1123
+ get isDragging(): boolean;
1101
1124
  /**
1102
1125
  * Attempts to handle a pointerdown event on the given target element.
1103
1126
  * Returns true if the target is a recognized clip interaction element.
1104
1127
  */
1105
1128
  tryHandle(target: Element, e: PointerEvent): boolean;
1106
1129
  private _beginDrag;
1130
+ /**
1131
+ * The press has become a drag (the pointer passed the threshold): take the
1132
+ * clip's bounds and open the transaction now, not at the press. An undo
1133
+ * made during the press (it is not a drag, so undo works) then has no
1134
+ * transaction to abort, and the drag that follows starts from the clip as
1135
+ * the undo left it, one undo step (#848, review of #915). Returns false
1136
+ * when the clip is gone (the undo removed it): the press is dropped.
1137
+ */
1138
+ private _startDrag;
1107
1139
  /** Processes pointermove events during an active drag. */
1108
1140
  onPointerMove(e: PointerEvent): void;
1109
1141
  /** Processes pointerup events to finalize and dispatch result events. */
@@ -1167,6 +1199,17 @@ interface DawTrackConnectedDetail {
1167
1199
  interface DawTrackIdDetail {
1168
1200
  trackId: string;
1169
1201
  }
1202
+ interface DawTrackUpdateDetail {
1203
+ trackId: string;
1204
+ /**
1205
+ * The `<daw-track>` properties this update changed, by property name
1206
+ * (`'volume'`, `'pan'`, `'muted'`, `'soloed'`, `'src'`, `'name'`, `'kind'`,
1207
+ * `'renderMode'`, `'spectrogramConfig'`). The editor sends a mixer property
1208
+ * to the engine only when it is in this list, and one update is one undo
1209
+ * step (#843).
1210
+ */
1211
+ changed: readonly string[];
1212
+ }
1170
1213
  interface DawTrackErrorDetail {
1171
1214
  trackId: string;
1172
1215
  error: unknown;
@@ -1188,6 +1231,12 @@ interface DawTrackControlDetail {
1188
1231
  trackId: string;
1189
1232
  prop: string;
1190
1233
  value: number | boolean;
1234
+ /**
1235
+ * The slider's gesture id (#843): events of one volume or pan drag, or of
1236
+ * one key press, carry the same id and are one undo step. Mute and solo
1237
+ * send none: each click is a step.
1238
+ */
1239
+ gesture?: string;
1191
1240
  }
1192
1241
  interface DawTrackRemoveDetail {
1193
1242
  trackId: string;
@@ -1343,7 +1392,7 @@ interface DawEventMap {
1343
1392
  'daw-time-format-change': CustomEvent<DawTimeFormatChangeDetail>;
1344
1393
  'daw-track-select': CustomEvent<DawTrackSelectDetail>;
1345
1394
  'daw-track-connected': CustomEvent<DawTrackConnectedDetail>;
1346
- 'daw-track-update': CustomEvent<DawTrackIdDetail>;
1395
+ 'daw-track-update': CustomEvent<DawTrackUpdateDetail>;
1347
1396
  'daw-track-ready': CustomEvent<DawTrackIdDetail>;
1348
1397
  'daw-track-removed': CustomEvent<DawTrackIdDetail>;
1349
1398
  'daw-track-error': CustomEvent<DawTrackErrorDetail>;
@@ -1586,7 +1635,15 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1586
1635
  get sampleRate(): number;
1587
1636
  /** Resolved sample rate — falls back to sampleRate property until first audio decode. */
1588
1637
  _resolvedSampleRate: number | null;
1589
- _tracks: Map<string, TrackDescriptor>;
1638
+ /** Per-track descriptors, without the mix: the arrangement owns that (#843). */
1639
+ _tracks: Map<string, StoredTrackDescriptor>;
1640
+ /**
1641
+ * The mix of a track the engine does not hold yet: what it will enter the
1642
+ * arrangement with (from the `<daw-track>` element or the `addTrack` config,
1643
+ * changed by a control or `updateTrack` while it loads). Deleted once
1644
+ * `engine.getState().tracks` holds the id; read only through `_mixOf`.
1645
+ */
1646
+ _seedMix: Map<string, TrackMixerValues>;
1590
1647
  _engineTracks: Map<string, ClipTrack>;
1591
1648
  _peaksData: Map<string, PeakData>;
1592
1649
  _isPlaying: boolean;
@@ -1765,6 +1822,28 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1765
1822
  private get _emptyGridHeight();
1766
1823
  _setSelectedTrackId(trackId: string | null): void;
1767
1824
  get tracks(): TrackWithId[];
1825
+ /**
1826
+ * A track's mix, from its one owner: the arrangement (through
1827
+ * `_engineTracks`, which follows `mixerVersion`) for a track the engine
1828
+ * holds, the seed for one still on its way in (#843).
1829
+ */
1830
+ _mixOf(trackId: string): TrackMixerValues;
1831
+ /** Replace a track's seed (a new Map: `_seedMix` is reactive state). */
1832
+ private _setSeedMix;
1833
+ private _deleteSeedMix;
1834
+ /**
1835
+ * Change one mixer field of a track: the seed while the track is loading
1836
+ * (not an undo step, nothing sent), else the engine's setter with
1837
+ * `options` (an undo step; changes with one `gesture` id are one step).
1838
+ */
1839
+ private _writeMix;
1840
+ /**
1841
+ * Change the given mixer fields of a track as ONE undo step (#843): all
1842
+ * of them carry one fresh gesture id. A field left out is not sent.
1843
+ */
1844
+ private _writeMixFields;
1845
+ /** The ordered tracks for `engine.setTracks`, a loading track with its seed. */
1846
+ private _tracksForEngine;
1768
1847
  get selectedTrackId(): string | null;
1769
1848
  get selection(): {
1770
1849
  start: number;
@@ -1937,10 +2016,11 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1937
2016
  private _onTrackReorder;
1938
2017
  private _onTrackReorderGrab;
1939
2018
  /**
1940
- * Update reflected attributes on a track. For DOM-element tracks the changes
1941
- * are written to the `<daw-track>` element (which fires `daw-track-update`);
1942
- * for tracks without a DOM element (file drops) the descriptor and engine
1943
- * state are updated in place.
2019
+ * Update reflected attributes on a track. The mixer fields go to their
2020
+ * owner as one undo step (#843): the engine, or while the track is loading
2021
+ * the values it will enter with (not a step). For DOM-element tracks the
2022
+ * changes are also written to the `<daw-track>` element; for tracks
2023
+ * without a DOM element (file drops) the descriptor is updated in place.
1944
2024
  */
1945
2025
  updateTrack(trackId: string, partial: Partial<TrackConfig>): void;
1946
2026
  /**
@@ -1988,9 +2068,30 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1988
2068
  * subsequent stop-settle dispatch. */
1989
2069
  private _withSeekSuppression;
1990
2070
  seekTo(time: number): void;
1991
- /** Undo the last structural edit. */
2071
+ /**
2072
+ * A clip or track drag is in progress: undo and redo do nothing until it
2073
+ * ends (#848). A clip counts once its pointer has moved past the drag
2074
+ * threshold; annotation drags do not count (annotations are not in the
2075
+ * undo history).
2076
+ */
2077
+ get _dragInProgress(): boolean;
2078
+ /**
2079
+ * Cancel every drag in progress, as a `pointercancel` would. Returns whether
2080
+ * one was. A clip or annotation press that has not moved is not a drag and
2081
+ * is left alone, unless `includePresses` (the editor's disconnect, which
2082
+ * ends every pointer interaction).
2083
+ */
2084
+ _cancelDrags(includePresses?: boolean): boolean;
2085
+ /**
2086
+ * Escape during a drag cancels it and does nothing else: the default is
2087
+ * prevented, so `<daw-keyboard-shortcuts>` (core's `handleKeyboardEvent`)
2088
+ * does not also stop playback. No `stopPropagation`: an app's own listener
2089
+ * can read `defaultPrevented`.
2090
+ */
2091
+ private _onDragEscape;
2092
+ /** Undo the last edit. Does nothing while a drag is in progress. */
1992
2093
  undo(): void;
1993
- /** Redo the last undone edit. */
2094
+ /** Redo the last undone edit. Does nothing while a drag is in progress. */
1994
2095
  redo(): void;
1995
2096
  /** Whether undo is available. */
1996
2097
  get canUndo(): boolean;
@@ -2527,4 +2628,4 @@ interface SplitHost {
2527
2628
  */
2528
2629
  declare function splitAtPlayhead(host: SplitHost): boolean;
2529
2630
 
2530
- 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 DawRecordingClipAddDetail, 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 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, formatDisplayTime, isDomClip, isTimeDisplayFormat, parseDisplayTime, resolveTransportTarget, splitAtPlayhead, targetSupports, warnOnce, warnUnsupportedOnce };
2631
+ 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 DawRecordingClipAddDetail, 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, type DawTrackUpdateDetail, DawTransportButton, DawTransportElement, DawWaveformElement, type DomClipDescriptor, type DropClipDescriptor, 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, formatDisplayTime, isDomClip, isTimeDisplayFormat, parseDisplayTime, resolveTransportTarget, splitAtPlayhead, targetSupports, warnOnce, warnUnsupportedOnce };