@dawcore/components 0.0.39-next.4 → 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 +3 -1
- package/dist/index.d.mts +35 -2
- package/dist/index.d.ts +35 -2
- package/dist/index.js +139 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +139 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// <define:__INSTALL_SPECS__>
|
|
13
|
-
var define_INSTALL_SPECS_default = { "@dawcore/faust": "@dawcore/faust@^0.0.2-next.1", "@dawcore/midi": "@dawcore/midi@^0.0.6-next.
|
|
13
|
+
var define_INSTALL_SPECS_default = { "@dawcore/faust": "@dawcore/faust@^0.0.2-next.1", "@dawcore/midi": "@dawcore/midi@^0.0.6-next.4", "@dawcore/transport": "@dawcore/transport@^0.0.16-next.4", "@dawcore/wam": "@dawcore/wam@^0.0.5-next.0", "@waveform-playlist/core": "@waveform-playlist/core@^13.0.0-next.4", "@waveform-playlist/engine": "@waveform-playlist/engine@^14.0.0-next.2", "@waveform-playlist/worklets": "@waveform-playlist/worklets@^13.0.1-next.0", "@waveform-playlist/playout": "@waveform-playlist/playout@^13.0.0-next.4" };
|
|
14
14
|
|
|
15
15
|
// src/elements/daw-annotation.ts
|
|
16
16
|
import { LitElement } from "lit";
|
|
@@ -241,6 +241,7 @@ var DawAnnotationTrackElement = class extends LitElement2 {
|
|
|
241
241
|
this._onKeyDownCapture = (e) => {
|
|
242
242
|
if (!this.keyboardControls) return;
|
|
243
243
|
if (e.repeat) return;
|
|
244
|
+
if (e.key === "Escape" && e.defaultPrevented) return;
|
|
244
245
|
if (keyBelongsToFocusedControl(e)) return;
|
|
245
246
|
const match = this._shortcutEntries().find((entry) => matchesKeyBinding(e, entry.binding));
|
|
246
247
|
if (!match) return;
|
|
@@ -4625,6 +4626,8 @@ var PointerHandler = class {
|
|
|
4625
4626
|
// still holds; zeroing only the host would desync the two).
|
|
4626
4627
|
this._preDragSelectionStart = 0;
|
|
4627
4628
|
this._preDragSelectionEnd = 0;
|
|
4629
|
+
/** Cancels the armed clip drag; set while one is armed (#848). */
|
|
4630
|
+
this._cancelArmedClipDrag = null;
|
|
4628
4631
|
this.onPointerDown = (e) => {
|
|
4629
4632
|
const clipHandler = this._host._clipHandler;
|
|
4630
4633
|
if (clipHandler) {
|
|
@@ -4639,12 +4642,13 @@ var PointerHandler = class {
|
|
|
4639
4642
|
console.warn("[dawcore] setPointerCapture failed: " + String(err));
|
|
4640
4643
|
}
|
|
4641
4644
|
const onMove = (me) => clipHandler.onPointerMove(me);
|
|
4642
|
-
const detach = (
|
|
4645
|
+
const detach = (pointerId) => {
|
|
4646
|
+
this._cancelArmedClipDrag = null;
|
|
4643
4647
|
this._timeline?.removeEventListener("pointermove", onMove);
|
|
4644
4648
|
this._timeline?.removeEventListener("pointerup", onUp);
|
|
4645
4649
|
this._timeline?.removeEventListener("pointercancel", onCancel);
|
|
4646
4650
|
try {
|
|
4647
|
-
this._timeline?.releasePointerCapture(
|
|
4651
|
+
this._timeline?.releasePointerCapture(pointerId);
|
|
4648
4652
|
} catch (err) {
|
|
4649
4653
|
console.warn(
|
|
4650
4654
|
"[dawcore] releasePointerCapture failed (may already be released): " + String(err)
|
|
@@ -4654,13 +4658,19 @@ var PointerHandler = class {
|
|
|
4654
4658
|
};
|
|
4655
4659
|
const onUp = (ue) => {
|
|
4656
4660
|
clipHandler.onPointerUp(ue);
|
|
4657
|
-
detach(ue);
|
|
4661
|
+
detach(ue.pointerId);
|
|
4658
4662
|
};
|
|
4659
4663
|
const downPointerId = e.pointerId;
|
|
4660
4664
|
const onCancel = (ce) => {
|
|
4661
4665
|
if (ce.pointerId !== downPointerId) return;
|
|
4662
4666
|
clipHandler.onPointerCancel(ce);
|
|
4663
|
-
detach(ce);
|
|
4667
|
+
detach(ce.pointerId);
|
|
4668
|
+
};
|
|
4669
|
+
this._cancelArmedClipDrag = () => {
|
|
4670
|
+
clipHandler.onPointerCancel(
|
|
4671
|
+
new PointerEvent("pointercancel", { pointerId: downPointerId })
|
|
4672
|
+
);
|
|
4673
|
+
detach(downPointerId);
|
|
4664
4674
|
};
|
|
4665
4675
|
this._timeline.addEventListener("pointermove", onMove);
|
|
4666
4676
|
this._timeline.addEventListener("pointerup", onUp);
|
|
@@ -4773,6 +4783,17 @@ var PointerHandler = class {
|
|
|
4773
4783
|
}
|
|
4774
4784
|
return time * h.effectiveSampleRate / h.samplesPerPixel;
|
|
4775
4785
|
}
|
|
4786
|
+
/**
|
|
4787
|
+
* Cancel an armed clip move or trim as a `pointercancel` would: the clip
|
|
4788
|
+
* handler reverts it and the timeline's listeners and pointer capture are
|
|
4789
|
+
* released. Returns whether a clip drag was armed.
|
|
4790
|
+
*/
|
|
4791
|
+
cancelClipDrag() {
|
|
4792
|
+
const cancel = this._cancelArmedClipDrag;
|
|
4793
|
+
if (!cancel) return false;
|
|
4794
|
+
cancel();
|
|
4795
|
+
return true;
|
|
4796
|
+
}
|
|
4776
4797
|
/** Detach the drag listeners and release capture — shared by the up and
|
|
4777
4798
|
* cancel terminals so a new listener added to onPointerDown can't be
|
|
4778
4799
|
* missed on one of them. */
|
|
@@ -4927,6 +4948,11 @@ var ClipPointerHandler = class {
|
|
|
4927
4948
|
get isActive() {
|
|
4928
4949
|
return this._mode !== null;
|
|
4929
4950
|
}
|
|
4951
|
+
/** True once the pointer of the current press has moved past the drag
|
|
4952
|
+
* threshold: a press that has not moved is not a drag (#848). */
|
|
4953
|
+
get isDragging() {
|
|
4954
|
+
return this._isDragging;
|
|
4955
|
+
}
|
|
4930
4956
|
/**
|
|
4931
4957
|
* Attempts to handle a pointerdown event on the given target element.
|
|
4932
4958
|
* Returns true if the target is a recognized clip interaction element.
|
|
@@ -4961,21 +4987,32 @@ var ClipPointerHandler = class {
|
|
|
4961
4987
|
this._startPx = e.clientX;
|
|
4962
4988
|
this._isDragging = false;
|
|
4963
4989
|
this._cumulativeDeltaSamples = 0;
|
|
4990
|
+
}
|
|
4991
|
+
/**
|
|
4992
|
+
* The press has become a drag (the pointer passed the threshold): take the
|
|
4993
|
+
* clip's bounds and open the transaction now, not at the press. An undo
|
|
4994
|
+
* made during the press (it is not a drag, so undo works) then has no
|
|
4995
|
+
* transaction to abort, and the drag that follows starts from the clip as
|
|
4996
|
+
* the undo left it, one undo step (#848, review of #915). Returns false
|
|
4997
|
+
* when the clip is gone (the undo removed it): the press is dropped.
|
|
4998
|
+
*/
|
|
4999
|
+
_startDrag() {
|
|
4964
5000
|
const engine = this._host.engine;
|
|
5001
|
+
const trackId = this._trackId;
|
|
5002
|
+
const clipId = this._clipId;
|
|
4965
5003
|
if (engine) {
|
|
4966
5004
|
const bounds = engine.getClipBounds(trackId, clipId);
|
|
4967
|
-
if (bounds)
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
if (engine) {
|
|
5005
|
+
if (!bounds) return false;
|
|
5006
|
+
this._originalStartSample = bounds.startSample;
|
|
5007
|
+
this._originalOffsetSamples = bounds.offsetSamples;
|
|
5008
|
+
this._originalDurationSamples = bounds.durationSamples;
|
|
4972
5009
|
engine.beginTransaction();
|
|
4973
5010
|
} else {
|
|
4974
5011
|
console.warn(
|
|
4975
|
-
"[dawcore]
|
|
5012
|
+
"[dawcore] drag start: engine unavailable, drag mutations will not be grouped for undo"
|
|
4976
5013
|
);
|
|
4977
5014
|
}
|
|
4978
|
-
if (
|
|
5015
|
+
if (this._mode === "trim-left" || this._mode === "trim-right") {
|
|
4979
5016
|
const container = this._host.shadowRoot?.querySelector(
|
|
4980
5017
|
`.clip-container[data-clip-id="${clipId}"]`
|
|
4981
5018
|
);
|
|
@@ -4986,21 +5023,18 @@ var ClipPointerHandler = class {
|
|
|
4986
5023
|
} else {
|
|
4987
5024
|
console.warn("[dawcore] clip container not found for trim visual feedback: " + clipId);
|
|
4988
5025
|
}
|
|
4989
|
-
const engine2 = this._host.engine;
|
|
4990
|
-
if (engine2) {
|
|
4991
|
-
const bounds = engine2.getClipBounds(trackId, clipId);
|
|
4992
|
-
if (bounds) {
|
|
4993
|
-
this._originalOffsetSamples = bounds.offsetSamples;
|
|
4994
|
-
this._originalDurationSamples = bounds.durationSamples;
|
|
4995
|
-
}
|
|
4996
|
-
}
|
|
4997
5026
|
}
|
|
5027
|
+
return true;
|
|
4998
5028
|
}
|
|
4999
5029
|
/** Processes pointermove events during an active drag. */
|
|
5000
5030
|
onPointerMove(e) {
|
|
5001
5031
|
if (this._mode === null) return;
|
|
5002
5032
|
const totalDeltaPx = e.clientX - this._startPx;
|
|
5003
5033
|
if (!this._isDragging && Math.abs(totalDeltaPx) > DRAG_THRESHOLD) {
|
|
5034
|
+
if (!this._startDrag()) {
|
|
5035
|
+
this._reset();
|
|
5036
|
+
return;
|
|
5037
|
+
}
|
|
5004
5038
|
this._isDragging = true;
|
|
5005
5039
|
if (this._boundaryEl) {
|
|
5006
5040
|
this._boundaryEl.classList.add("dragging");
|
|
@@ -5122,10 +5156,12 @@ var ClipPointerHandler = class {
|
|
|
5122
5156
|
}
|
|
5123
5157
|
}
|
|
5124
5158
|
} finally {
|
|
5125
|
-
if (this._isDragging
|
|
5126
|
-
this.
|
|
5127
|
-
|
|
5128
|
-
|
|
5159
|
+
if (this._isDragging) {
|
|
5160
|
+
if (this._cumulativeDeltaSamples !== 0) {
|
|
5161
|
+
this._host.engine?.commitTransaction();
|
|
5162
|
+
} else {
|
|
5163
|
+
this._host.engine?.abortTransaction();
|
|
5164
|
+
}
|
|
5129
5165
|
}
|
|
5130
5166
|
this._reset();
|
|
5131
5167
|
}
|
|
@@ -5143,7 +5179,7 @@ var ClipPointerHandler = class {
|
|
|
5143
5179
|
try {
|
|
5144
5180
|
this._restoreTrimVisual();
|
|
5145
5181
|
} finally {
|
|
5146
|
-
this._host.engine?.abortTransaction();
|
|
5182
|
+
if (this._isDragging) this._host.engine?.abortTransaction();
|
|
5147
5183
|
this._reset();
|
|
5148
5184
|
}
|
|
5149
5185
|
}
|
|
@@ -5318,16 +5354,35 @@ var AnnotationDragHandler = class {
|
|
|
5318
5354
|
this._onPointerCancel = (e) => {
|
|
5319
5355
|
const drag = this._drag;
|
|
5320
5356
|
if (!drag || e.pointerId !== drag.pointerId) return;
|
|
5321
|
-
|
|
5322
|
-
if (drag.mode === "ticks") {
|
|
5323
|
-
applyTickBoundaryResults(elements, drag.snapshot, (t) => this._host._ticksToSeconds(t));
|
|
5324
|
-
} else {
|
|
5325
|
-
applyBoundaryResults(elements, drag.snapshot);
|
|
5326
|
-
}
|
|
5327
|
-
this._teardown();
|
|
5357
|
+
this._restoreAndTeardown(drag);
|
|
5328
5358
|
};
|
|
5329
5359
|
this._host = host;
|
|
5330
5360
|
}
|
|
5361
|
+
/** True from pointerdown on an annotation until the drag ends or is cancelled. */
|
|
5362
|
+
get isActive() {
|
|
5363
|
+
return this._drag !== null;
|
|
5364
|
+
}
|
|
5365
|
+
/** True once the pointer has moved at least `DRAG_THRESHOLD` px (an edge
|
|
5366
|
+
* drag, or a box press that moved): a press that has not moved (a click on
|
|
5367
|
+
* the box) is not a drag (#848). */
|
|
5368
|
+
get isDragging() {
|
|
5369
|
+
return this._drag?.moved ?? false;
|
|
5370
|
+
}
|
|
5371
|
+
/** Cancel the drag in progress (Escape, editor disconnect): the boundaries
|
|
5372
|
+
* go back to where they were when it began (#848). */
|
|
5373
|
+
cancel() {
|
|
5374
|
+
if (this._drag) this._restoreAndTeardown(this._drag);
|
|
5375
|
+
}
|
|
5376
|
+
/** Restore the drag-start snapshot — a cancelled drag must not commit. */
|
|
5377
|
+
_restoreAndTeardown(drag) {
|
|
5378
|
+
const elements = drag.track.annotationElements;
|
|
5379
|
+
if (drag.mode === "ticks") {
|
|
5380
|
+
applyTickBoundaryResults(elements, drag.snapshot, (t) => this._host._ticksToSeconds(t));
|
|
5381
|
+
} else {
|
|
5382
|
+
applyBoundaryResults(elements, drag.snapshot);
|
|
5383
|
+
}
|
|
5384
|
+
this._teardown();
|
|
5385
|
+
}
|
|
5331
5386
|
_teardown() {
|
|
5332
5387
|
const drag = this._drag;
|
|
5333
5388
|
if (!drag) return;
|
|
@@ -5475,6 +5530,10 @@ var TrackReorderHandler = class _TrackReorderHandler {
|
|
|
5475
5530
|
static _reducedMotion() {
|
|
5476
5531
|
return typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
5477
5532
|
}
|
|
5533
|
+
/** True from the grab until the drag ends or is cancelled. */
|
|
5534
|
+
get isActive() {
|
|
5535
|
+
return this._trackId !== null;
|
|
5536
|
+
}
|
|
5478
5537
|
/** Abort any in-progress drag and reset state. Called by the editor on
|
|
5479
5538
|
* disconnect — without this, a drag interrupted by editor removal (with no
|
|
5480
5539
|
* pointercancel delivered) would leave the handler wedged and silently
|
|
@@ -7791,6 +7850,16 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
7791
7850
|
if (!this.trackReordering) return;
|
|
7792
7851
|
this._trackReorderDrag.onGrab(e.detail.trackId, e.detail.pointerEvent, e.detail.gripElement);
|
|
7793
7852
|
};
|
|
7853
|
+
/**
|
|
7854
|
+
* Escape during a drag cancels it and does nothing else: the default is
|
|
7855
|
+
* prevented, so `<daw-keyboard-shortcuts>` (core's `handleKeyboardEvent`)
|
|
7856
|
+
* does not also stop playback. No `stopPropagation`: an app's own listener
|
|
7857
|
+
* can read `defaultPrevented`.
|
|
7858
|
+
*/
|
|
7859
|
+
this._onDragEscape = (e) => {
|
|
7860
|
+
if (e.key !== "Escape") return;
|
|
7861
|
+
if (this._cancelDrags()) e.preventDefault();
|
|
7862
|
+
};
|
|
7794
7863
|
// --- Recording ---
|
|
7795
7864
|
this.recordingStream = null;
|
|
7796
7865
|
/** Set in togglePauseRecording when Transport is paused alongside the
|
|
@@ -8389,6 +8458,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8389
8458
|
// --- Lifecycle ---
|
|
8390
8459
|
connectedCallback() {
|
|
8391
8460
|
super.connectedCallback();
|
|
8461
|
+
window.addEventListener("keydown", this._onDragEscape, { capture: true });
|
|
8392
8462
|
this.addEventListener("daw-track-connected", this._onTrackConnected);
|
|
8393
8463
|
this.addEventListener("daw-track-update", this._onTrackUpdate);
|
|
8394
8464
|
this.addEventListener("daw-track-control", this._onTrackControl);
|
|
@@ -8449,6 +8519,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8449
8519
|
}
|
|
8450
8520
|
disconnectedCallback() {
|
|
8451
8521
|
super.disconnectedCallback();
|
|
8522
|
+
window.removeEventListener("keydown", this._onDragEscape, { capture: true });
|
|
8452
8523
|
this._effectsManager?.disposeAll();
|
|
8453
8524
|
this._effectsManager = null;
|
|
8454
8525
|
this.removeEventListener("daw-track-connected", this._onTrackConnected);
|
|
@@ -8464,7 +8535,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8464
8535
|
this.removeEventListener("daw-annotation-select", this._onAnnotationSelect);
|
|
8465
8536
|
this.removeEventListener("daw-track-reorder", this._onTrackReorder);
|
|
8466
8537
|
this.removeEventListener("daw-track-reorder-grab", this._onTrackReorderGrab);
|
|
8467
|
-
this.
|
|
8538
|
+
this._cancelDrags(true);
|
|
8468
8539
|
this._childObserver?.disconnect();
|
|
8469
8540
|
this._childObserver = null;
|
|
8470
8541
|
this._trackElements.clear();
|
|
@@ -9855,16 +9926,49 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9855
9926
|
})
|
|
9856
9927
|
);
|
|
9857
9928
|
}
|
|
9858
|
-
/**
|
|
9929
|
+
/**
|
|
9930
|
+
* A clip or track drag is in progress: undo and redo do nothing until it
|
|
9931
|
+
* ends (#848). A clip counts once its pointer has moved past the drag
|
|
9932
|
+
* threshold; annotation drags do not count (annotations are not in the
|
|
9933
|
+
* undo history).
|
|
9934
|
+
*/
|
|
9935
|
+
get _dragInProgress() {
|
|
9936
|
+
return this._clipPointer.isDragging || this._trackReorderDrag.isActive;
|
|
9937
|
+
}
|
|
9938
|
+
/**
|
|
9939
|
+
* Cancel every drag in progress, as a `pointercancel` would. Returns whether
|
|
9940
|
+
* one was. A clip or annotation press that has not moved is not a drag and
|
|
9941
|
+
* is left alone, unless `includePresses` (the editor's disconnect, which
|
|
9942
|
+
* ends every pointer interaction).
|
|
9943
|
+
*/
|
|
9944
|
+
_cancelDrags(includePresses = false) {
|
|
9945
|
+
let cancelled = false;
|
|
9946
|
+
if (includePresses || this._clipPointer.isDragging) {
|
|
9947
|
+
cancelled = this._pointer.cancelClipDrag() || cancelled;
|
|
9948
|
+
}
|
|
9949
|
+
if (this._trackReorderDrag.isActive) {
|
|
9950
|
+
this._trackReorderDrag.cancel();
|
|
9951
|
+
cancelled = true;
|
|
9952
|
+
}
|
|
9953
|
+
const annotation = this._annotationDrag;
|
|
9954
|
+
if (includePresses ? annotation.isActive : annotation.isDragging) {
|
|
9955
|
+
annotation.cancel();
|
|
9956
|
+
cancelled = true;
|
|
9957
|
+
}
|
|
9958
|
+
return cancelled;
|
|
9959
|
+
}
|
|
9960
|
+
/** Undo the last edit. Does nothing while a drag is in progress. */
|
|
9859
9961
|
undo() {
|
|
9962
|
+
if (this._dragInProgress) return;
|
|
9860
9963
|
if (!this._engine) {
|
|
9861
9964
|
console.warn("[dawcore] undo: engine not ready, call ignored");
|
|
9862
9965
|
return;
|
|
9863
9966
|
}
|
|
9864
9967
|
this._engine.undo();
|
|
9865
9968
|
}
|
|
9866
|
-
/** Redo the last undone edit. */
|
|
9969
|
+
/** Redo the last undone edit. Does nothing while a drag is in progress. */
|
|
9867
9970
|
redo() {
|
|
9971
|
+
if (this._dragInProgress) return;
|
|
9868
9972
|
if (!this._engine) {
|
|
9869
9973
|
console.warn("[dawcore] redo: engine not ready, call ignored");
|
|
9870
9974
|
return;
|