@dawcore/components 0.0.29 → 0.0.30
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 +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +46 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -210,6 +210,8 @@ declare class DawWaveformElement extends LitElement {
|
|
|
210
210
|
waveHeight: number;
|
|
211
211
|
barWidth: number;
|
|
212
212
|
barGap: number;
|
|
213
|
+
/** Draw bars with pill-shaped rounded caps (radius barWidth/2). */
|
|
214
|
+
roundedBars: boolean;
|
|
213
215
|
/** Visible viewport start in pixels (relative to timeline origin). */
|
|
214
216
|
visibleStart: number;
|
|
215
217
|
/** Visible viewport end in pixels (relative to timeline origin). */
|
|
@@ -230,6 +232,8 @@ declare class DawWaveformElement extends LitElement {
|
|
|
230
232
|
private _scheduleDraw;
|
|
231
233
|
private _drawDirty;
|
|
232
234
|
private _drawChunk;
|
|
235
|
+
/** Draw bar rects: fillRect when radius is null, else add rounded bars to the current path. */
|
|
236
|
+
private _drawBarRects;
|
|
233
237
|
private _drawSegments;
|
|
234
238
|
connectedCallback(): void;
|
|
235
239
|
disconnectedCallback(): void;
|
|
@@ -1152,6 +1156,7 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
|
|
|
1152
1156
|
mono: boolean;
|
|
1153
1157
|
barWidth: number;
|
|
1154
1158
|
barGap: number;
|
|
1159
|
+
roundedBars: boolean;
|
|
1155
1160
|
fileDrop: boolean;
|
|
1156
1161
|
clipHeaders: boolean;
|
|
1157
1162
|
clipHeaderHeight: number;
|
|
@@ -1814,6 +1819,7 @@ declare class DawPlayerElement extends LitElement {
|
|
|
1814
1819
|
mono: boolean;
|
|
1815
1820
|
barWidth: number;
|
|
1816
1821
|
barGap: number;
|
|
1822
|
+
roundedBars: boolean;
|
|
1817
1823
|
get playbackRate(): number;
|
|
1818
1824
|
set playbackRate(value: number);
|
|
1819
1825
|
private _playbackRate;
|
package/dist/index.d.ts
CHANGED
|
@@ -210,6 +210,8 @@ declare class DawWaveformElement extends LitElement {
|
|
|
210
210
|
waveHeight: number;
|
|
211
211
|
barWidth: number;
|
|
212
212
|
barGap: number;
|
|
213
|
+
/** Draw bars with pill-shaped rounded caps (radius barWidth/2). */
|
|
214
|
+
roundedBars: boolean;
|
|
213
215
|
/** Visible viewport start in pixels (relative to timeline origin). */
|
|
214
216
|
visibleStart: number;
|
|
215
217
|
/** Visible viewport end in pixels (relative to timeline origin). */
|
|
@@ -230,6 +232,8 @@ declare class DawWaveformElement extends LitElement {
|
|
|
230
232
|
private _scheduleDraw;
|
|
231
233
|
private _drawDirty;
|
|
232
234
|
private _drawChunk;
|
|
235
|
+
/** Draw bar rects: fillRect when radius is null, else add rounded bars to the current path. */
|
|
236
|
+
private _drawBarRects;
|
|
233
237
|
private _drawSegments;
|
|
234
238
|
connectedCallback(): void;
|
|
235
239
|
disconnectedCallback(): void;
|
|
@@ -1152,6 +1156,7 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
|
|
|
1152
1156
|
mono: boolean;
|
|
1153
1157
|
barWidth: number;
|
|
1154
1158
|
barGap: number;
|
|
1159
|
+
roundedBars: boolean;
|
|
1155
1160
|
fileDrop: boolean;
|
|
1156
1161
|
clipHeaders: boolean;
|
|
1157
1162
|
clipHeaderHeight: number;
|
|
@@ -1814,6 +1819,7 @@ declare class DawPlayerElement extends LitElement {
|
|
|
1814
1819
|
mono: boolean;
|
|
1815
1820
|
barWidth: number;
|
|
1816
1821
|
barGap: number;
|
|
1822
|
+
roundedBars: boolean;
|
|
1817
1823
|
get playbackRate(): number;
|
|
1818
1824
|
set playbackRate(value: number);
|
|
1819
1825
|
private _playbackRate;
|
package/dist/index.js
CHANGED
|
@@ -433,6 +433,13 @@ function calculateBarRects(x, barWidth, halfHeight, minPeak, maxPeak, drawMode)
|
|
|
433
433
|
{ x, y: halfHeight + min, width: barWidth, height: halfHeight - min }
|
|
434
434
|
];
|
|
435
435
|
}
|
|
436
|
+
function addBarToPath(ctx, rect, radius) {
|
|
437
|
+
if (typeof ctx.roundRect === "function") {
|
|
438
|
+
ctx.roundRect(rect.x, rect.y, rect.width, rect.height, radius);
|
|
439
|
+
} else {
|
|
440
|
+
ctx.rect(rect.x, rect.y, rect.width, rect.height);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
436
443
|
|
|
437
444
|
// src/utils/viewport.ts
|
|
438
445
|
function getVisibleChunkIndices(totalWidth, chunkWidth, visibleStart, visibleEnd, originX = 0) {
|
|
@@ -450,7 +457,14 @@ function getVisibleChunkIndices(totalWidth, chunkWidth, visibleStart, visibleEnd
|
|
|
450
457
|
|
|
451
458
|
// src/elements/daw-waveform.ts
|
|
452
459
|
var MAX_CANVAS_WIDTH = 1e3;
|
|
453
|
-
var LAYOUT_PROPS = /* @__PURE__ */ new Set([
|
|
460
|
+
var LAYOUT_PROPS = /* @__PURE__ */ new Set([
|
|
461
|
+
"length",
|
|
462
|
+
"waveHeight",
|
|
463
|
+
"barWidth",
|
|
464
|
+
"barGap",
|
|
465
|
+
"roundedBars",
|
|
466
|
+
"segments"
|
|
467
|
+
]);
|
|
454
468
|
function groupDirtyByChunk(dirtyPixels, step) {
|
|
455
469
|
const dirtyByChunk = /* @__PURE__ */ new Map();
|
|
456
470
|
for (const peakIdx of dirtyPixels) {
|
|
@@ -481,6 +495,7 @@ var DawWaveformElement = class extends import_lit3.LitElement {
|
|
|
481
495
|
this.waveHeight = 128;
|
|
482
496
|
this.barWidth = 1;
|
|
483
497
|
this.barGap = 0;
|
|
498
|
+
this.roundedBars = false;
|
|
484
499
|
this.visibleStart = -Infinity;
|
|
485
500
|
this.visibleEnd = Infinity;
|
|
486
501
|
this.originX = 0;
|
|
@@ -590,6 +605,8 @@ var DawWaveformElement = class extends import_lit3.LitElement {
|
|
|
590
605
|
ctx.fillStyle = waveColor;
|
|
591
606
|
const canvasWidth = Math.min(MAX_CANVAS_WIDTH, this.length - globalOffset);
|
|
592
607
|
const regionEnd = Math.min(globalOffset + clearEnd, globalOffset + canvasWidth);
|
|
608
|
+
const barRadius = this.roundedBars ? this.barWidth / 2 : null;
|
|
609
|
+
if (barRadius !== null) ctx.beginPath();
|
|
593
610
|
for (let bar = Math.max(0, firstBar); bar < regionEnd; bar += step) {
|
|
594
611
|
const peak = aggregatePeaks(this._peaks, bits, bar, bar + step);
|
|
595
612
|
if (!peak) continue;
|
|
@@ -601,8 +618,17 @@ var DawWaveformElement = class extends import_lit3.LitElement {
|
|
|
601
618
|
peak.max,
|
|
602
619
|
"normal"
|
|
603
620
|
);
|
|
604
|
-
|
|
621
|
+
this._drawBarRects(ctx, rects, barRadius);
|
|
622
|
+
}
|
|
623
|
+
if (barRadius !== null) ctx.fill();
|
|
624
|
+
}
|
|
625
|
+
/** Draw bar rects: fillRect when radius is null, else add rounded bars to the current path. */
|
|
626
|
+
_drawBarRects(ctx, rects, radius) {
|
|
627
|
+
for (const r of rects) {
|
|
628
|
+
if (radius === null) {
|
|
605
629
|
ctx.fillRect(r.x, r.y, r.width, r.height);
|
|
630
|
+
} else {
|
|
631
|
+
addBarToPath(ctx, r, radius);
|
|
606
632
|
}
|
|
607
633
|
}
|
|
608
634
|
}
|
|
@@ -617,6 +643,8 @@ var DawWaveformElement = class extends import_lit3.LitElement {
|
|
|
617
643
|
ctx.scale(dpr, dpr);
|
|
618
644
|
ctx.fillStyle = waveColor;
|
|
619
645
|
const step = Math.max(1, Math.round(this.barWidth + this.barGap));
|
|
646
|
+
const barRadius = this.roundedBars ? this.barWidth / 2 : null;
|
|
647
|
+
if (barRadius !== null) ctx.beginPath();
|
|
620
648
|
for (const seg of this.segments) {
|
|
621
649
|
if (seg.pixelEnd <= globalOffset || seg.pixelStart >= globalOffset + canvasWidth) continue;
|
|
622
650
|
const localStart = Math.max(0, seg.pixelStart - globalOffset);
|
|
@@ -639,11 +667,10 @@ var DawWaveformElement = class extends import_lit3.LitElement {
|
|
|
639
667
|
peak.max,
|
|
640
668
|
"normal"
|
|
641
669
|
);
|
|
642
|
-
|
|
643
|
-
ctx.fillRect(r.x, r.y, r.width, r.height);
|
|
644
|
-
}
|
|
670
|
+
this._drawBarRects(ctx, rects, barRadius);
|
|
645
671
|
}
|
|
646
672
|
}
|
|
673
|
+
if (barRadius !== null) ctx.fill();
|
|
647
674
|
}
|
|
648
675
|
connectedCallback() {
|
|
649
676
|
super.connectedCallback();
|
|
@@ -730,6 +757,9 @@ __decorateClass([
|
|
|
730
757
|
__decorateClass([
|
|
731
758
|
(0, import_decorators3.property)({ type: Number, attribute: false })
|
|
732
759
|
], DawWaveformElement.prototype, "barGap", 2);
|
|
760
|
+
__decorateClass([
|
|
761
|
+
(0, import_decorators3.property)({ type: Boolean, attribute: false })
|
|
762
|
+
], DawWaveformElement.prototype, "roundedBars", 2);
|
|
733
763
|
__decorateClass([
|
|
734
764
|
(0, import_decorators3.property)({ type: Number, attribute: false })
|
|
735
765
|
], DawWaveformElement.prototype, "visibleStart", 2);
|
|
@@ -5618,6 +5648,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
5618
5648
|
this.mono = false;
|
|
5619
5649
|
this.barWidth = 1;
|
|
5620
5650
|
this.barGap = 0;
|
|
5651
|
+
this.roundedBars = false;
|
|
5621
5652
|
this.fileDrop = false;
|
|
5622
5653
|
this.clipHeaders = false;
|
|
5623
5654
|
this.clipHeaderHeight = 20;
|
|
@@ -7658,6 +7689,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7658
7689
|
.waveHeight=${chH}
|
|
7659
7690
|
.barWidth=${this.barWidth}
|
|
7660
7691
|
.barGap=${this.barGap}
|
|
7692
|
+
.roundedBars=${this.roundedBars}
|
|
7661
7693
|
.visibleStart=${this._viewport.visibleStart}
|
|
7662
7694
|
.visibleEnd=${this._viewport.visibleEnd}
|
|
7663
7695
|
.originX=${left}
|
|
@@ -7907,6 +7939,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7907
7939
|
.waveHeight=${chH}
|
|
7908
7940
|
.barWidth=${this.barWidth}
|
|
7909
7941
|
.barGap=${this.barGap}
|
|
7942
|
+
.roundedBars=${this.roundedBars}
|
|
7910
7943
|
.visibleStart=${this._viewport.visibleStart}
|
|
7911
7944
|
.visibleEnd=${this._viewport.visibleEnd}
|
|
7912
7945
|
.originX=${clipLeft}
|
|
@@ -8036,6 +8069,9 @@ __decorateClass([
|
|
|
8036
8069
|
__decorateClass([
|
|
8037
8070
|
(0, import_decorators13.property)({ type: Number, attribute: "bar-gap" })
|
|
8038
8071
|
], DawEditorElement.prototype, "barGap", 2);
|
|
8072
|
+
__decorateClass([
|
|
8073
|
+
(0, import_decorators13.property)({ type: Boolean, attribute: "rounded-bars" })
|
|
8074
|
+
], DawEditorElement.prototype, "roundedBars", 2);
|
|
8039
8075
|
__decorateClass([
|
|
8040
8076
|
(0, import_decorators13.property)({ type: Boolean, attribute: "file-drop" })
|
|
8041
8077
|
], DawEditorElement.prototype, "fileDrop", 2);
|
|
@@ -8811,6 +8847,7 @@ var DawPlayerElement = class extends import_lit22.LitElement {
|
|
|
8811
8847
|
this.mono = false;
|
|
8812
8848
|
this.barWidth = 1;
|
|
8813
8849
|
this.barGap = 0;
|
|
8850
|
+
this.roundedBars = false;
|
|
8814
8851
|
this._playbackRate = 1;
|
|
8815
8852
|
this._engine = new import_media_element_playout.MediaElementPlayout();
|
|
8816
8853
|
this._trackId = null;
|
|
@@ -8914,6 +8951,7 @@ var DawPlayerElement = class extends import_lit22.LitElement {
|
|
|
8914
8951
|
.waveHeight=${channelHeight}
|
|
8915
8952
|
.barWidth=${this.barWidth}
|
|
8916
8953
|
.barGap=${this.barGap}
|
|
8954
|
+
.roundedBars=${this.roundedBars}
|
|
8917
8955
|
></daw-waveform>`
|
|
8918
8956
|
)}
|
|
8919
8957
|
<daw-playhead></daw-playhead>
|
|
@@ -9097,6 +9135,9 @@ __decorateClass([
|
|
|
9097
9135
|
__decorateClass([
|
|
9098
9136
|
(0, import_decorators20.property)({ type: Number, attribute: "bar-gap" })
|
|
9099
9137
|
], DawPlayerElement.prototype, "barGap", 2);
|
|
9138
|
+
__decorateClass([
|
|
9139
|
+
(0, import_decorators20.property)({ type: Boolean, attribute: "rounded-bars" })
|
|
9140
|
+
], DawPlayerElement.prototype, "roundedBars", 2);
|
|
9100
9141
|
__decorateClass([
|
|
9101
9142
|
(0, import_decorators20.property)({ type: Number, attribute: "playback-rate", noAccessor: true })
|
|
9102
9143
|
], DawPlayerElement.prototype, "playbackRate", 1);
|