@dawcore/components 0.0.39-next.15 → 0.0.39-next.16
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 +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +29 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1303,8 +1303,16 @@ declare const TIME_DISPLAY_FORMATS: readonly TimeDisplayFormat[];
|
|
|
1303
1303
|
declare function isTimeDisplayFormat(value: unknown): value is TimeDisplayFormat;
|
|
1304
1304
|
/** Format seconds for display. Non-finite or negative input renders as 0. */
|
|
1305
1305
|
declare function formatDisplayTime(seconds: number, format: TimeDisplayFormat): string;
|
|
1306
|
-
/**
|
|
1307
|
-
|
|
1306
|
+
/**
|
|
1307
|
+
* Parse text typed for a time back to seconds, or `null` when it is not a
|
|
1308
|
+
* time: empty text, a negative number, letters, a number followed by
|
|
1309
|
+
* anything else, a number too large to be finite, or a value that is not a
|
|
1310
|
+
* string. Spaces around the text are ignored. `seconds` reads a plain
|
|
1311
|
+
* number; the clock formats also read `1.5` (seconds) and `1:30` (minutes and
|
|
1312
|
+
* seconds) besides `01:02:03.500`. Segment ranges are checked: `00:75:00` is
|
|
1313
|
+
* not a time.
|
|
1314
|
+
*/
|
|
1315
|
+
declare function parseDisplayTime(value: string, format: TimeDisplayFormat): number | null;
|
|
1308
1316
|
|
|
1309
1317
|
interface DawSelectionDetail {
|
|
1310
1318
|
start: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -1303,8 +1303,16 @@ declare const TIME_DISPLAY_FORMATS: readonly TimeDisplayFormat[];
|
|
|
1303
1303
|
declare function isTimeDisplayFormat(value: unknown): value is TimeDisplayFormat;
|
|
1304
1304
|
/** Format seconds for display. Non-finite or negative input renders as 0. */
|
|
1305
1305
|
declare function formatDisplayTime(seconds: number, format: TimeDisplayFormat): string;
|
|
1306
|
-
/**
|
|
1307
|
-
|
|
1306
|
+
/**
|
|
1307
|
+
* Parse text typed for a time back to seconds, or `null` when it is not a
|
|
1308
|
+
* time: empty text, a negative number, letters, a number followed by
|
|
1309
|
+
* anything else, a number too large to be finite, or a value that is not a
|
|
1310
|
+
* string. Spaces around the text are ignored. `seconds` reads a plain
|
|
1311
|
+
* number; the clock formats also read `1.5` (seconds) and `1:30` (minutes and
|
|
1312
|
+
* seconds) besides `01:02:03.500`. Segment ranges are checked: `00:75:00` is
|
|
1313
|
+
* not a time.
|
|
1314
|
+
*/
|
|
1315
|
+
declare function parseDisplayTime(value: string, format: TimeDisplayFormat): number | null;
|
|
1308
1316
|
|
|
1309
1317
|
interface DawSelectionDetail {
|
|
1310
1318
|
start: number;
|
package/dist/index.js
CHANGED
|
@@ -82,7 +82,7 @@ __export(index_exports, {
|
|
|
82
82
|
module.exports = __toCommonJS(index_exports);
|
|
83
83
|
|
|
84
84
|
// <define:__INSTALL_SPECS__>
|
|
85
|
-
var define_INSTALL_SPECS_default = { "@dawcore/faust": "@dawcore/faust@^0.0.2-next.1", "@dawcore/midi": "@dawcore/midi@^0.0.6-next.10", "@dawcore/transport": "@dawcore/transport@^0.0.16-next.9", "@dawcore/wam": "@dawcore/wam@^0.0.5-next.0", "@waveform-playlist/core": "@waveform-playlist/core@^13.0.0-next.9", "@waveform-playlist/engine": "@waveform-playlist/engine@^14.0.0-next.
|
|
85
|
+
var define_INSTALL_SPECS_default = { "@dawcore/faust": "@dawcore/faust@^0.0.2-next.1", "@dawcore/midi": "@dawcore/midi@^0.0.6-next.10", "@dawcore/transport": "@dawcore/transport@^0.0.16-next.9", "@dawcore/wam": "@dawcore/wam@^0.0.5-next.0", "@waveform-playlist/core": "@waveform-playlist/core@^13.0.0-next.9", "@waveform-playlist/engine": "@waveform-playlist/engine@^14.0.0-next.7", "@waveform-playlist/worklets": "@waveform-playlist/worklets@^13.0.1-next.0", "@waveform-playlist/playout": "@waveform-playlist/playout@^13.0.0-next.9" };
|
|
86
86
|
|
|
87
87
|
// src/elements/daw-annotation.ts
|
|
88
88
|
var import_lit = require("lit");
|
|
@@ -607,8 +607,11 @@ function computePlayingAnnotationId(annotations, time) {
|
|
|
607
607
|
|
|
608
608
|
// src/elements/daw-annotation-list.ts
|
|
609
609
|
function formatAnnotationTime(seconds) {
|
|
610
|
-
const
|
|
611
|
-
const
|
|
610
|
+
const safe = Number.isFinite(seconds) && seconds > 0 ? seconds : 0;
|
|
611
|
+
const floor = Math.floor(safe);
|
|
612
|
+
const rounded = Math.round((safe - floor) * 1e3);
|
|
613
|
+
const whole = rounded === 1e3 ? floor + 1 : floor;
|
|
614
|
+
const ms = rounded === 1e3 ? 0 : rounded;
|
|
612
615
|
const s = whole % 60;
|
|
613
616
|
const m = (whole - s) / 60;
|
|
614
617
|
return m + ":" + String(s).padStart(2, "0") + "." + String(ms).padStart(3, "0");
|
|
@@ -5977,20 +5980,30 @@ function formatDisplayTime(seconds, format) {
|
|
|
5977
5980
|
return clockFormat(safe, 3);
|
|
5978
5981
|
}
|
|
5979
5982
|
}
|
|
5983
|
+
var DECIMAL = /^(\d+(\.\d*)?|\.\d+)$/;
|
|
5984
|
+
var WHOLE = /^\d+$/;
|
|
5985
|
+
var SECONDS_PER_UNIT = [3600, 60, 1];
|
|
5986
|
+
function parseClock(text) {
|
|
5987
|
+
const parts = text.split(":");
|
|
5988
|
+
if (parts.length > 3) return null;
|
|
5989
|
+
const units = SECONDS_PER_UNIT.slice(3 - parts.length);
|
|
5990
|
+
let total = 0;
|
|
5991
|
+
for (let i = 0; i < parts.length; i++) {
|
|
5992
|
+
const isLast = i === parts.length - 1;
|
|
5993
|
+
if (!(isLast ? DECIMAL : WHOLE).test(parts[i])) return null;
|
|
5994
|
+
const value = Number(parts[i]);
|
|
5995
|
+
if (i > 0 && value >= 60) return null;
|
|
5996
|
+
total += value * units[i];
|
|
5997
|
+
}
|
|
5998
|
+
return Number.isFinite(total) ? total : null;
|
|
5999
|
+
}
|
|
5980
6000
|
function parseDisplayTime(value, format) {
|
|
5981
|
-
if (
|
|
5982
|
-
|
|
5983
|
-
if (format
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
if (parts.length !== 3) return 0;
|
|
5988
|
-
const h = parseInt(parts[0], 10) || 0;
|
|
5989
|
-
const m = parseInt(parts[1], 10) || 0;
|
|
5990
|
-
const s = parseFloat(parts[2]) || 0;
|
|
5991
|
-
seconds = h * 3600 + m * 60 + s;
|
|
5992
|
-
}
|
|
5993
|
-
return Math.max(0, seconds);
|
|
6001
|
+
if (typeof value !== "string") return null;
|
|
6002
|
+
const text = value.trim();
|
|
6003
|
+
if (format !== "seconds") return parseClock(text);
|
|
6004
|
+
if (!DECIMAL.test(text)) return null;
|
|
6005
|
+
const seconds = Number(text);
|
|
6006
|
+
return Number.isFinite(seconds) ? seconds : null;
|
|
5994
6007
|
}
|
|
5995
6008
|
|
|
5996
6009
|
// src/interactions/abort.ts
|