@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/dist/index.mjs
CHANGED
|
@@ -1103,81 +1103,43 @@ function annotationMinDurationTicks(ppqn) {
|
|
|
1103
1103
|
return Math.max(1, Math.round(ppqn / 32));
|
|
1104
1104
|
}
|
|
1105
1105
|
function updateAnnotationBoundaries(params, options = {}) {
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1106
|
+
const units = {
|
|
1107
|
+
linkThreshold: options.linkThreshold ?? LINK_THRESHOLD,
|
|
1108
|
+
minDuration: options.minDuration ?? MIN_ANNOTATION_DURATION
|
|
1109
|
+
};
|
|
1110
|
+
return params.isDraggingStart ? moveStart(params, units) : moveEnd(params, units);
|
|
1111
|
+
}
|
|
1112
|
+
function moveStart({ annotationIndex, newTime, annotations, linkEndpoints }, { linkThreshold, minDuration }) {
|
|
1113
|
+
const updated = [...annotations];
|
|
1110
1114
|
const annotation = annotations[annotationIndex];
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
end: Math.max(prevAnnotation.start + minDuration, constrainedStart)
|
|
1120
|
-
};
|
|
1121
|
-
} else if (constrainedStart <= prevAnnotation.end) {
|
|
1122
|
-
updatedAnnotations[annotationIndex] = {
|
|
1123
|
-
...updatedAnnotations[annotationIndex],
|
|
1124
|
-
start: prevAnnotation.end
|
|
1125
|
-
};
|
|
1126
|
-
}
|
|
1127
|
-
} else if (!linkEndpoints && annotationIndex > 0 && constrainedStart < updatedAnnotations[annotationIndex - 1].end) {
|
|
1128
|
-
updatedAnnotations[annotationIndex - 1] = {
|
|
1129
|
-
...updatedAnnotations[annotationIndex - 1],
|
|
1130
|
-
end: constrainedStart
|
|
1131
|
-
};
|
|
1132
|
-
}
|
|
1115
|
+
const prev = annotationIndex > 0 ? annotations[annotationIndex - 1] : void 0;
|
|
1116
|
+
const start = Math.max(0, Math.min(annotation.end - minDuration, newTime));
|
|
1117
|
+
if (!prev) {
|
|
1118
|
+
updated[annotationIndex] = { ...annotation, start };
|
|
1119
|
+
} else if (linkEndpoints && Math.abs(prev.end - annotation.start) < linkThreshold) {
|
|
1120
|
+
const shared = Math.max(start, Math.min(prev.start + minDuration, prev.end));
|
|
1121
|
+
updated[annotationIndex - 1] = { ...prev, end: shared };
|
|
1122
|
+
updated[annotationIndex] = { ...annotation, start: shared };
|
|
1133
1123
|
} else {
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
start: Math.min(next.end - minDuration, next.start + nextDelta)
|
|
1152
|
-
};
|
|
1153
|
-
currentIndex++;
|
|
1154
|
-
} else {
|
|
1155
|
-
break;
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
} else if (constrainedEnd >= nextAnnotation.start) {
|
|
1159
|
-
updatedAnnotations[annotationIndex] = {
|
|
1160
|
-
...updatedAnnotations[annotationIndex],
|
|
1161
|
-
end: nextAnnotation.start
|
|
1162
|
-
};
|
|
1163
|
-
}
|
|
1164
|
-
} else if (!linkEndpoints && annotationIndex < updatedAnnotations.length - 1 && constrainedEnd > updatedAnnotations[annotationIndex + 1].start) {
|
|
1165
|
-
const nextAnnotation = updatedAnnotations[annotationIndex + 1];
|
|
1166
|
-
updatedAnnotations[annotationIndex + 1] = { ...nextAnnotation, start: constrainedEnd };
|
|
1167
|
-
let currentIndex = annotationIndex + 1;
|
|
1168
|
-
while (currentIndex < updatedAnnotations.length - 1) {
|
|
1169
|
-
const current = updatedAnnotations[currentIndex];
|
|
1170
|
-
const next = updatedAnnotations[currentIndex + 1];
|
|
1171
|
-
if (current.end > next.start) {
|
|
1172
|
-
updatedAnnotations[currentIndex + 1] = { ...next, start: current.end };
|
|
1173
|
-
currentIndex++;
|
|
1174
|
-
} else {
|
|
1175
|
-
break;
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1124
|
+
updated[annotationIndex] = { ...annotation, start: Math.max(start, prev.end) };
|
|
1125
|
+
}
|
|
1126
|
+
return updated;
|
|
1127
|
+
}
|
|
1128
|
+
function moveEnd({ annotationIndex, newTime, annotations, duration, linkEndpoints }, { linkThreshold, minDuration }) {
|
|
1129
|
+
const updated = [...annotations];
|
|
1130
|
+
const annotation = annotations[annotationIndex];
|
|
1131
|
+
const next = annotations[annotationIndex + 1];
|
|
1132
|
+
const end = Math.max(annotation.start + minDuration, Math.min(newTime, duration));
|
|
1133
|
+
if (!next) {
|
|
1134
|
+
updated[annotationIndex] = { ...annotation, end };
|
|
1135
|
+
} else if (linkEndpoints && Math.abs(next.start - annotation.end) < linkThreshold) {
|
|
1136
|
+
const shared = Math.min(end, Math.max(next.end - minDuration, next.start));
|
|
1137
|
+
updated[annotationIndex] = { ...annotation, end: shared };
|
|
1138
|
+
updated[annotationIndex + 1] = { ...next, start: shared };
|
|
1139
|
+
} else {
|
|
1140
|
+
updated[annotationIndex] = { ...annotation, end: Math.min(end, next.start) };
|
|
1179
1141
|
}
|
|
1180
|
-
return
|
|
1142
|
+
return updated;
|
|
1181
1143
|
}
|
|
1182
1144
|
|
|
1183
1145
|
// src/annotations/shortcuts.ts
|