@waveform-playlist/core 13.0.0-next.11 → 13.0.0-next.12
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 +1 -1
- package/dist/index.d.mts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +34 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -72
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Used by nearly every `@waveform-playlist/*` and `@dawcore/*` package (`engine`,
|
|
|
13
13
|
- **Peaks generation** — real-time min/max peak extraction during recording
|
|
14
14
|
- **Musical time** — PPQN tick math, bar/beat conversion, time-signature meter detection, grid snapping
|
|
15
15
|
- **Keyboard shortcuts** — a framework-agnostic shortcut matcher shared by the React and Web Components layers
|
|
16
|
-
- **Annotation store** — `createAnnotationStore`, the one owner of a list of annotations that both React providers take as `annotationStore`: `set` / `update` apply at once, every list is
|
|
16
|
+
- **Annotation store** — `createAnnotationStore`, the one owner of a list of annotations that both React providers take as `annotationStore`: `set` / `update` apply at once, every list is checked for finite times and unique ids (not for order, overlaps or an end before its start), and an optional `beforeChange` rule can accept, refuse or adjust each change
|
|
17
17
|
- **Spectrogram canvas-ID contract** — canonical build/parse helpers for the `${clipId}-ch${n}-chunk${m}` canvas ID format shared by the worker pool and rendering layers
|
|
18
18
|
- **HTTP range support probing** — detect whether an audio host supports byte-range seeking
|
|
19
19
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1394,10 +1394,18 @@ interface AnnotationBoundaryUpdate {
|
|
|
1394
1394
|
linkEndpoints: boolean;
|
|
1395
1395
|
}
|
|
1396
1396
|
/**
|
|
1397
|
-
* Pure boundary-update logic
|
|
1398
|
-
*
|
|
1399
|
-
*
|
|
1400
|
-
*
|
|
1397
|
+
* Pure boundary-update logic of an annotation edge drag and of the boundary
|
|
1398
|
+
* keys, used by `@waveform-playlist/browser` and by the dawcore annotation
|
|
1399
|
+
* elements, and exported for a custom annotation UI. Returns a NEW array;
|
|
1400
|
+
* never mutates inputs. Expects annotations in time order that do not
|
|
1401
|
+
* overlap; an overlapping list is invalid data (maintainer, #748), and an
|
|
1402
|
+
* out-of-order one is too (dawcore sorts its elements; React's store does not).
|
|
1403
|
+
*
|
|
1404
|
+
* A neighbour is a hard stop: a dragged edge stops at the neighbour's edge,
|
|
1405
|
+
* and the neighbour does not move (#748). With `linkEndpoints`, a neighbour
|
|
1406
|
+
* whose edge is within the link threshold is carried instead: its edge moves
|
|
1407
|
+
* with the dragged edge, which stops where the neighbour reaches the minimum
|
|
1408
|
+
* duration. Annotations further along never move.
|
|
1401
1409
|
*/
|
|
1402
1410
|
declare function updateAnnotationBoundaries(params: AnnotationBoundaryUpdate, options?: AnnotationBoundaryOptions): AnnotationData[];
|
|
1403
1411
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1394,10 +1394,18 @@ interface AnnotationBoundaryUpdate {
|
|
|
1394
1394
|
linkEndpoints: boolean;
|
|
1395
1395
|
}
|
|
1396
1396
|
/**
|
|
1397
|
-
* Pure boundary-update logic
|
|
1398
|
-
*
|
|
1399
|
-
*
|
|
1400
|
-
*
|
|
1397
|
+
* Pure boundary-update logic of an annotation edge drag and of the boundary
|
|
1398
|
+
* keys, used by `@waveform-playlist/browser` and by the dawcore annotation
|
|
1399
|
+
* elements, and exported for a custom annotation UI. Returns a NEW array;
|
|
1400
|
+
* never mutates inputs. Expects annotations in time order that do not
|
|
1401
|
+
* overlap; an overlapping list is invalid data (maintainer, #748), and an
|
|
1402
|
+
* out-of-order one is too (dawcore sorts its elements; React's store does not).
|
|
1403
|
+
*
|
|
1404
|
+
* A neighbour is a hard stop: a dragged edge stops at the neighbour's edge,
|
|
1405
|
+
* and the neighbour does not move (#748). With `linkEndpoints`, a neighbour
|
|
1406
|
+
* whose edge is within the link threshold is carried instead: its edge moves
|
|
1407
|
+
* with the dragged edge, which stops where the neighbour reaches the minimum
|
|
1408
|
+
* duration. Annotations further along never move.
|
|
1401
1409
|
*/
|
|
1402
1410
|
declare function updateAnnotationBoundaries(params: AnnotationBoundaryUpdate, options?: AnnotationBoundaryOptions): AnnotationData[];
|
|
1403
1411
|
|
package/dist/index.js
CHANGED
|
@@ -1229,81 +1229,43 @@ function annotationMinDurationTicks(ppqn) {
|
|
|
1229
1229
|
return Math.max(1, Math.round(ppqn / 32));
|
|
1230
1230
|
}
|
|
1231
1231
|
function updateAnnotationBoundaries(params, options = {}) {
|
|
1232
|
-
const
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1232
|
+
const units = {
|
|
1233
|
+
linkThreshold: options.linkThreshold ?? LINK_THRESHOLD,
|
|
1234
|
+
minDuration: options.minDuration ?? MIN_ANNOTATION_DURATION
|
|
1235
|
+
};
|
|
1236
|
+
return params.isDraggingStart ? moveStart(params, units) : moveEnd(params, units);
|
|
1237
|
+
}
|
|
1238
|
+
function moveStart({ annotationIndex, newTime, annotations, linkEndpoints }, { linkThreshold, minDuration }) {
|
|
1239
|
+
const updated = [...annotations];
|
|
1236
1240
|
const annotation = annotations[annotationIndex];
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
end: Math.max(prevAnnotation.start + minDuration, constrainedStart)
|
|
1246
|
-
};
|
|
1247
|
-
} else if (constrainedStart <= prevAnnotation.end) {
|
|
1248
|
-
updatedAnnotations[annotationIndex] = {
|
|
1249
|
-
...updatedAnnotations[annotationIndex],
|
|
1250
|
-
start: prevAnnotation.end
|
|
1251
|
-
};
|
|
1252
|
-
}
|
|
1253
|
-
} else if (!linkEndpoints && annotationIndex > 0 && constrainedStart < updatedAnnotations[annotationIndex - 1].end) {
|
|
1254
|
-
updatedAnnotations[annotationIndex - 1] = {
|
|
1255
|
-
...updatedAnnotations[annotationIndex - 1],
|
|
1256
|
-
end: constrainedStart
|
|
1257
|
-
};
|
|
1258
|
-
}
|
|
1241
|
+
const prev = annotationIndex > 0 ? annotations[annotationIndex - 1] : void 0;
|
|
1242
|
+
const start = Math.max(0, Math.min(annotation.end - minDuration, newTime));
|
|
1243
|
+
if (!prev) {
|
|
1244
|
+
updated[annotationIndex] = { ...annotation, start };
|
|
1245
|
+
} else if (linkEndpoints && Math.abs(prev.end - annotation.start) < linkThreshold) {
|
|
1246
|
+
const shared = Math.max(start, Math.min(prev.start + minDuration, prev.end));
|
|
1247
|
+
updated[annotationIndex - 1] = { ...prev, end: shared };
|
|
1248
|
+
updated[annotationIndex] = { ...annotation, start: shared };
|
|
1259
1249
|
} else {
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
start: Math.min(next.end - minDuration, next.start + nextDelta)
|
|
1278
|
-
};
|
|
1279
|
-
currentIndex++;
|
|
1280
|
-
} else {
|
|
1281
|
-
break;
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
} else if (constrainedEnd >= nextAnnotation.start) {
|
|
1285
|
-
updatedAnnotations[annotationIndex] = {
|
|
1286
|
-
...updatedAnnotations[annotationIndex],
|
|
1287
|
-
end: nextAnnotation.start
|
|
1288
|
-
};
|
|
1289
|
-
}
|
|
1290
|
-
} else if (!linkEndpoints && annotationIndex < updatedAnnotations.length - 1 && constrainedEnd > updatedAnnotations[annotationIndex + 1].start) {
|
|
1291
|
-
const nextAnnotation = updatedAnnotations[annotationIndex + 1];
|
|
1292
|
-
updatedAnnotations[annotationIndex + 1] = { ...nextAnnotation, start: constrainedEnd };
|
|
1293
|
-
let currentIndex = annotationIndex + 1;
|
|
1294
|
-
while (currentIndex < updatedAnnotations.length - 1) {
|
|
1295
|
-
const current = updatedAnnotations[currentIndex];
|
|
1296
|
-
const next = updatedAnnotations[currentIndex + 1];
|
|
1297
|
-
if (current.end > next.start) {
|
|
1298
|
-
updatedAnnotations[currentIndex + 1] = { ...next, start: current.end };
|
|
1299
|
-
currentIndex++;
|
|
1300
|
-
} else {
|
|
1301
|
-
break;
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1250
|
+
updated[annotationIndex] = { ...annotation, start: Math.max(start, prev.end) };
|
|
1251
|
+
}
|
|
1252
|
+
return updated;
|
|
1253
|
+
}
|
|
1254
|
+
function moveEnd({ annotationIndex, newTime, annotations, duration, linkEndpoints }, { linkThreshold, minDuration }) {
|
|
1255
|
+
const updated = [...annotations];
|
|
1256
|
+
const annotation = annotations[annotationIndex];
|
|
1257
|
+
const next = annotations[annotationIndex + 1];
|
|
1258
|
+
const end = Math.max(annotation.start + minDuration, Math.min(newTime, duration));
|
|
1259
|
+
if (!next) {
|
|
1260
|
+
updated[annotationIndex] = { ...annotation, end };
|
|
1261
|
+
} else if (linkEndpoints && Math.abs(next.start - annotation.end) < linkThreshold) {
|
|
1262
|
+
const shared = Math.min(end, Math.max(next.end - minDuration, next.start));
|
|
1263
|
+
updated[annotationIndex] = { ...annotation, end: shared };
|
|
1264
|
+
updated[annotationIndex + 1] = { ...next, start: shared };
|
|
1265
|
+
} else {
|
|
1266
|
+
updated[annotationIndex] = { ...annotation, end: Math.min(end, next.start) };
|
|
1305
1267
|
}
|
|
1306
|
-
return
|
|
1268
|
+
return updated;
|
|
1307
1269
|
}
|
|
1308
1270
|
|
|
1309
1271
|
// src/annotations/shortcuts.ts
|