@dawcore/components 0.0.39-next.15 → 0.0.39-next.17

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
@@ -177,7 +177,7 @@ This expands to a MIDI track, `<daw-track kind="midi">`, containing a `<daw-clip
177
177
  </script>
178
178
  ```
179
179
 
180
- A clip is treated as MIDI iff `clip.midiNotes != null`. MIDI clips skip audio fetch + decode + peak generation. Move drag works on MIDI clips; trim handles and split-at-playhead are inert on them.
180
+ A clip is treated as MIDI iff `clip.midiNotes != null`. MIDI clips skip audio fetch + decode + peak generation. Move drag and split-at-playhead work on MIDI clips (a split keeps the clip's notes, channel and program on both halves, each half playing and drawing the notes inside its own range); trim handles are inert on them.
181
181
 
182
182
  **Theming:** the piano-roll honors `--daw-piano-roll-note-color` (default `#2a7070`), `--daw-piano-roll-selected-note-color` (default `#3d9e9e`), and `--daw-piano-roll-background` (default `#1a1a2e`).
183
183
 
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
- /** Parse a formatted time string back to seconds. Lenient: returns 0 for empty/unparseable input; does not validate segment ranges. */
1307
- declare function parseDisplayTime(value: string, format: TimeDisplayFormat): number;
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
- /** Parse a formatted time string back to seconds. Lenient: returns 0 for empty/unparseable input; does not validate segment ranges. */
1307
- declare function parseDisplayTime(value: string, format: TimeDisplayFormat): number;
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.6", "@waveform-playlist/worklets": "@waveform-playlist/worklets@^13.0.1-next.0", "@waveform-playlist/playout": "@waveform-playlist/playout@^13.0.0-next.9" };
85
+ var define_INSTALL_SPECS_default = { "@dawcore/faust": "@dawcore/faust@^0.0.2-next.1", "@dawcore/midi": "@dawcore/midi@^0.0.6-next.11", "@dawcore/transport": "@dawcore/transport@^0.0.16-next.10", "@dawcore/wam": "@dawcore/wam@^0.0.5-next.0", "@waveform-playlist/core": "@waveform-playlist/core@^13.0.0-next.10", "@waveform-playlist/engine": "@waveform-playlist/engine@^14.0.0-next.8", "@waveform-playlist/worklets": "@waveform-playlist/worklets@^13.0.1-next.0", "@waveform-playlist/playout": "@waveform-playlist/playout@^13.0.0-next.10" };
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 whole = Math.floor(seconds);
611
- const ms = Math.round((seconds - whole) * 1e3);
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 (!value) return 0;
5982
- let seconds = 0;
5983
- if (format === "seconds") {
5984
- seconds = parseFloat(value) || 0;
5985
- } else {
5986
- const parts = value.split(":");
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
@@ -6317,9 +6330,7 @@ function canSplitAtTime(host, time) {
6317
6330
  if (!track) return false;
6318
6331
  const atSample = Math.round(time * host.effectiveSampleRate);
6319
6332
  const clip = findClipAtSample(track.clips, atSample);
6320
- if (!clip) return false;
6321
- if (clip.midiNotes != null) return false;
6322
- return true;
6333
+ return clip !== void 0;
6323
6334
  }
6324
6335
  function performSplit(host, time) {
6325
6336
  const { engine } = host;