@dawcore/components 0.0.29 → 0.0.31
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 +51 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/dist/index.mjs
CHANGED
|
@@ -362,6 +362,13 @@ function calculateBarRects(x, barWidth, halfHeight, minPeak, maxPeak, drawMode)
|
|
|
362
362
|
{ x, y: halfHeight + min, width: barWidth, height: halfHeight - min }
|
|
363
363
|
];
|
|
364
364
|
}
|
|
365
|
+
function addBarToPath(ctx, rect, radius) {
|
|
366
|
+
if (typeof ctx.roundRect === "function") {
|
|
367
|
+
ctx.roundRect(rect.x, rect.y, rect.width, rect.height, radius);
|
|
368
|
+
} else {
|
|
369
|
+
ctx.rect(rect.x, rect.y, rect.width, rect.height);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
365
372
|
|
|
366
373
|
// src/utils/viewport.ts
|
|
367
374
|
function getVisibleChunkIndices(totalWidth, chunkWidth, visibleStart, visibleEnd, originX = 0) {
|
|
@@ -379,7 +386,14 @@ function getVisibleChunkIndices(totalWidth, chunkWidth, visibleStart, visibleEnd
|
|
|
379
386
|
|
|
380
387
|
// src/elements/daw-waveform.ts
|
|
381
388
|
var MAX_CANVAS_WIDTH = 1e3;
|
|
382
|
-
var LAYOUT_PROPS = /* @__PURE__ */ new Set([
|
|
389
|
+
var LAYOUT_PROPS = /* @__PURE__ */ new Set([
|
|
390
|
+
"length",
|
|
391
|
+
"waveHeight",
|
|
392
|
+
"barWidth",
|
|
393
|
+
"barGap",
|
|
394
|
+
"roundedBars",
|
|
395
|
+
"segments"
|
|
396
|
+
]);
|
|
383
397
|
function groupDirtyByChunk(dirtyPixels, step) {
|
|
384
398
|
const dirtyByChunk = /* @__PURE__ */ new Map();
|
|
385
399
|
for (const peakIdx of dirtyPixels) {
|
|
@@ -410,6 +424,7 @@ var DawWaveformElement = class extends LitElement3 {
|
|
|
410
424
|
this.waveHeight = 128;
|
|
411
425
|
this.barWidth = 1;
|
|
412
426
|
this.barGap = 0;
|
|
427
|
+
this.roundedBars = false;
|
|
413
428
|
this.visibleStart = -Infinity;
|
|
414
429
|
this.visibleEnd = Infinity;
|
|
415
430
|
this.originX = 0;
|
|
@@ -519,6 +534,8 @@ var DawWaveformElement = class extends LitElement3 {
|
|
|
519
534
|
ctx.fillStyle = waveColor;
|
|
520
535
|
const canvasWidth = Math.min(MAX_CANVAS_WIDTH, this.length - globalOffset);
|
|
521
536
|
const regionEnd = Math.min(globalOffset + clearEnd, globalOffset + canvasWidth);
|
|
537
|
+
const barRadius = this.roundedBars ? this.barWidth / 2 : null;
|
|
538
|
+
if (barRadius !== null) ctx.beginPath();
|
|
522
539
|
for (let bar = Math.max(0, firstBar); bar < regionEnd; bar += step) {
|
|
523
540
|
const peak = aggregatePeaks(this._peaks, bits, bar, bar + step);
|
|
524
541
|
if (!peak) continue;
|
|
@@ -530,8 +547,17 @@ var DawWaveformElement = class extends LitElement3 {
|
|
|
530
547
|
peak.max,
|
|
531
548
|
"normal"
|
|
532
549
|
);
|
|
533
|
-
|
|
550
|
+
this._drawBarRects(ctx, rects, barRadius);
|
|
551
|
+
}
|
|
552
|
+
if (barRadius !== null) ctx.fill();
|
|
553
|
+
}
|
|
554
|
+
/** Draw bar rects: fillRect when radius is null, else add rounded bars to the current path. */
|
|
555
|
+
_drawBarRects(ctx, rects, radius) {
|
|
556
|
+
for (const r of rects) {
|
|
557
|
+
if (radius === null) {
|
|
534
558
|
ctx.fillRect(r.x, r.y, r.width, r.height);
|
|
559
|
+
} else {
|
|
560
|
+
addBarToPath(ctx, r, radius);
|
|
535
561
|
}
|
|
536
562
|
}
|
|
537
563
|
}
|
|
@@ -546,6 +572,8 @@ var DawWaveformElement = class extends LitElement3 {
|
|
|
546
572
|
ctx.scale(dpr, dpr);
|
|
547
573
|
ctx.fillStyle = waveColor;
|
|
548
574
|
const step = Math.max(1, Math.round(this.barWidth + this.barGap));
|
|
575
|
+
const barRadius = this.roundedBars ? this.barWidth / 2 : null;
|
|
576
|
+
if (barRadius !== null) ctx.beginPath();
|
|
549
577
|
for (const seg of this.segments) {
|
|
550
578
|
if (seg.pixelEnd <= globalOffset || seg.pixelStart >= globalOffset + canvasWidth) continue;
|
|
551
579
|
const localStart = Math.max(0, seg.pixelStart - globalOffset);
|
|
@@ -568,11 +596,10 @@ var DawWaveformElement = class extends LitElement3 {
|
|
|
568
596
|
peak.max,
|
|
569
597
|
"normal"
|
|
570
598
|
);
|
|
571
|
-
|
|
572
|
-
ctx.fillRect(r.x, r.y, r.width, r.height);
|
|
573
|
-
}
|
|
599
|
+
this._drawBarRects(ctx, rects, barRadius);
|
|
574
600
|
}
|
|
575
601
|
}
|
|
602
|
+
if (barRadius !== null) ctx.fill();
|
|
576
603
|
}
|
|
577
604
|
connectedCallback() {
|
|
578
605
|
super.connectedCallback();
|
|
@@ -659,6 +686,9 @@ __decorateClass([
|
|
|
659
686
|
__decorateClass([
|
|
660
687
|
property3({ type: Number, attribute: false })
|
|
661
688
|
], DawWaveformElement.prototype, "barGap", 2);
|
|
689
|
+
__decorateClass([
|
|
690
|
+
property3({ type: Boolean, attribute: false })
|
|
691
|
+
], DawWaveformElement.prototype, "roundedBars", 2);
|
|
662
692
|
__decorateClass([
|
|
663
693
|
property3({ type: Number, attribute: false })
|
|
664
694
|
], DawWaveformElement.prototype, "visibleStart", 2);
|
|
@@ -5561,6 +5591,7 @@ var DawEditorElement = class extends LitElement11 {
|
|
|
5561
5591
|
this.mono = false;
|
|
5562
5592
|
this.barWidth = 1;
|
|
5563
5593
|
this.barGap = 0;
|
|
5594
|
+
this.roundedBars = false;
|
|
5564
5595
|
this.fileDrop = false;
|
|
5565
5596
|
this.clipHeaders = false;
|
|
5566
5597
|
this.clipHeaderHeight = 20;
|
|
@@ -7601,6 +7632,7 @@ var DawEditorElement = class extends LitElement11 {
|
|
|
7601
7632
|
.waveHeight=${chH}
|
|
7602
7633
|
.barWidth=${this.barWidth}
|
|
7603
7634
|
.barGap=${this.barGap}
|
|
7635
|
+
.roundedBars=${this.roundedBars}
|
|
7604
7636
|
.visibleStart=${this._viewport.visibleStart}
|
|
7605
7637
|
.visibleEnd=${this._viewport.visibleEnd}
|
|
7606
7638
|
.originX=${left}
|
|
@@ -7850,6 +7882,7 @@ var DawEditorElement = class extends LitElement11 {
|
|
|
7850
7882
|
.waveHeight=${chH}
|
|
7851
7883
|
.barWidth=${this.barWidth}
|
|
7852
7884
|
.barGap=${this.barGap}
|
|
7885
|
+
.roundedBars=${this.roundedBars}
|
|
7853
7886
|
.visibleStart=${this._viewport.visibleStart}
|
|
7854
7887
|
.visibleEnd=${this._viewport.visibleEnd}
|
|
7855
7888
|
.originX=${clipLeft}
|
|
@@ -7979,6 +8012,9 @@ __decorateClass([
|
|
|
7979
8012
|
__decorateClass([
|
|
7980
8013
|
property9({ type: Number, attribute: "bar-gap" })
|
|
7981
8014
|
], DawEditorElement.prototype, "barGap", 2);
|
|
8015
|
+
__decorateClass([
|
|
8016
|
+
property9({ type: Boolean, attribute: "rounded-bars" })
|
|
8017
|
+
], DawEditorElement.prototype, "roundedBars", 2);
|
|
7982
8018
|
__decorateClass([
|
|
7983
8019
|
property9({ type: Boolean, attribute: "file-drop" })
|
|
7984
8020
|
], DawEditorElement.prototype, "fileDrop", 2);
|
|
@@ -8358,7 +8394,7 @@ DawKeyboardShortcutsElement = __decorateClass([
|
|
|
8358
8394
|
// src/elements/daw-spectrogram.ts
|
|
8359
8395
|
import { LitElement as LitElement14, html as html13, css as css13 } from "lit";
|
|
8360
8396
|
import { customElement as customElement17, property as property12 } from "lit/decorators.js";
|
|
8361
|
-
|
|
8397
|
+
import { MAX_CANVAS_WIDTH as MAX_CANVAS_WIDTH5 } from "@waveform-playlist/core";
|
|
8362
8398
|
var DawSpectrogramElement = class extends LitElement14 {
|
|
8363
8399
|
constructor() {
|
|
8364
8400
|
super(...arguments);
|
|
@@ -8754,6 +8790,7 @@ var DawPlayerElement = class extends LitElement17 {
|
|
|
8754
8790
|
this.mono = false;
|
|
8755
8791
|
this.barWidth = 1;
|
|
8756
8792
|
this.barGap = 0;
|
|
8793
|
+
this.roundedBars = false;
|
|
8757
8794
|
this._playbackRate = 1;
|
|
8758
8795
|
this._engine = new MediaElementPlayout();
|
|
8759
8796
|
this._trackId = null;
|
|
@@ -8857,6 +8894,7 @@ var DawPlayerElement = class extends LitElement17 {
|
|
|
8857
8894
|
.waveHeight=${channelHeight}
|
|
8858
8895
|
.barWidth=${this.barWidth}
|
|
8859
8896
|
.barGap=${this.barGap}
|
|
8897
|
+
.roundedBars=${this.roundedBars}
|
|
8860
8898
|
></daw-waveform>`
|
|
8861
8899
|
)}
|
|
8862
8900
|
<daw-playhead></daw-playhead>
|
|
@@ -9040,6 +9078,9 @@ __decorateClass([
|
|
|
9040
9078
|
__decorateClass([
|
|
9041
9079
|
property13({ type: Number, attribute: "bar-gap" })
|
|
9042
9080
|
], DawPlayerElement.prototype, "barGap", 2);
|
|
9081
|
+
__decorateClass([
|
|
9082
|
+
property13({ type: Boolean, attribute: "rounded-bars" })
|
|
9083
|
+
], DawPlayerElement.prototype, "roundedBars", 2);
|
|
9043
9084
|
__decorateClass([
|
|
9044
9085
|
property13({ type: Number, attribute: "playback-rate", noAccessor: true })
|
|
9045
9086
|
], DawPlayerElement.prototype, "playbackRate", 1);
|