@waveform-playlist/core 13.0.0-next.10 → 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 +13 -22
- package/dist/index.d.ts +13 -22
- 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
|
@@ -681,23 +681,6 @@ type FadeType = 'logarithmic' | 'linear' | 'sCurve' | 'exponential';
|
|
|
681
681
|
* Alias for Fade — used by media-element-playout and playout packages
|
|
682
682
|
*/
|
|
683
683
|
type FadeConfig = Fade;
|
|
684
|
-
interface PlaylistConfig {
|
|
685
|
-
samplesPerPixel?: number;
|
|
686
|
-
waveHeight?: number;
|
|
687
|
-
container?: HTMLElement;
|
|
688
|
-
isAutomaticScroll?: boolean;
|
|
689
|
-
timescale?: boolean;
|
|
690
|
-
colors?: {
|
|
691
|
-
waveOutlineColor?: string;
|
|
692
|
-
waveFillColor?: string;
|
|
693
|
-
waveProgressColor?: string;
|
|
694
|
-
};
|
|
695
|
-
controls?: {
|
|
696
|
-
show?: boolean;
|
|
697
|
-
width?: number;
|
|
698
|
-
};
|
|
699
|
-
zoomLevels?: number[];
|
|
700
|
-
}
|
|
701
684
|
interface PlayoutState {
|
|
702
685
|
isPlaying: boolean;
|
|
703
686
|
isPaused: boolean;
|
|
@@ -1411,10 +1394,18 @@ interface AnnotationBoundaryUpdate {
|
|
|
1411
1394
|
linkEndpoints: boolean;
|
|
1412
1395
|
}
|
|
1413
1396
|
/**
|
|
1414
|
-
* Pure boundary-update logic
|
|
1415
|
-
*
|
|
1416
|
-
*
|
|
1417
|
-
*
|
|
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.
|
|
1418
1409
|
*/
|
|
1419
1410
|
declare function updateAnnotationBoundaries(params: AnnotationBoundaryUpdate, options?: AnnotationBoundaryOptions): AnnotationData[];
|
|
1420
1411
|
|
|
@@ -1785,4 +1776,4 @@ declare function needsPrepare(type: string, audioContext: BaseAudioContext): boo
|
|
|
1785
1776
|
declare function ensureEffectPrepared(type: string, audioContext: BaseAudioContext): Promise<void>;
|
|
1786
1777
|
declare function createEffectInstance(type: string, audioContext: BaseAudioContext, params?: Record<string, number>): CreatedNativeEffect;
|
|
1787
1778
|
|
|
1788
|
-
export { ANNOTATION_LINK_THRESHOLD_TICKS, type AnnotationAction, type AnnotationActionOptions, type AnnotationBoundaryOptions, type AnnotationBoundaryUpdate, type AnnotationBoundsChange, type AnnotationData, type AnnotationEventMap, type AnnotationFormat, type AnnotationListOptions, type AnnotationShortcutAction, type AnnotationShortcutMap, type AnnotationStore, type AnnotationStoreOptions, type ArrangementTrack, type AudioBuffer$1 as AudioBuffer, type AudioClip, type AudioTrackOptions, type Bits, type ClipSource, type ClipTrack, type ColorMapEntry, type ColorMapName, type ColorMapValue, type CreateClipOptions, type CreateClipOptionsSeconds, type CreateClipOptionsTicks, type CreateTrackOptions, type CreatedNativeEffect, DEFAULT_ANNOTATION_SHORTCUTS, DEFAULT_PAN_LAW, DEFAULT_SPECTROGRAM_COLOR_MAP, type DecidedPanLaw, type EffectParamDef, type FFTSize, type Fade, type FadeConfig, type FadeType, type Gap, InteractionState, type KeyBinding, type KeyboardShortcut, LINK_THRESHOLD, type LoadingClip, MAX_CANVAS_WIDTH, METER_PEAK_DECAY, MIN_ANNOTATION_DURATION, MIN_PIXELS_PER_UNIT, type MeterEntry, type MeterLevels, type MeterReading, type MeterSource, type MicrophoneDeviceInfo, type MicrophoneEnumeration, type MidiNoteData, type MixerGesture, type MusicalTick, type MusicalTickData, type MusicalTickParams, type NativeEffectDefinition, type NativeEffectInstance, PAN_LAW_RAMP_SECONDS, PPQN, type PanLaw, type PanMatrix, type PanStage, type PanStageContext, type PeakData, type Peaks, type
|
|
1779
|
+
export { ANNOTATION_LINK_THRESHOLD_TICKS, type AnnotationAction, type AnnotationActionOptions, type AnnotationBoundaryOptions, type AnnotationBoundaryUpdate, type AnnotationBoundsChange, type AnnotationData, type AnnotationEventMap, type AnnotationFormat, type AnnotationListOptions, type AnnotationShortcutAction, type AnnotationShortcutMap, type AnnotationStore, type AnnotationStoreOptions, type ArrangementTrack, type AudioBuffer$1 as AudioBuffer, type AudioClip, type AudioTrackOptions, type Bits, type ClipSource, type ClipTrack, type ColorMapEntry, type ColorMapName, type ColorMapValue, type CreateClipOptions, type CreateClipOptionsSeconds, type CreateClipOptionsTicks, type CreateTrackOptions, type CreatedNativeEffect, DEFAULT_ANNOTATION_SHORTCUTS, DEFAULT_PAN_LAW, DEFAULT_SPECTROGRAM_COLOR_MAP, type DecidedPanLaw, type EffectParamDef, type FFTSize, type Fade, type FadeConfig, type FadeType, type Gap, InteractionState, type KeyBinding, type KeyboardShortcut, LINK_THRESHOLD, type LoadingClip, MAX_CANVAS_WIDTH, METER_PEAK_DECAY, MIN_ANNOTATION_DURATION, MIN_PIXELS_PER_UNIT, type MeterEntry, type MeterLevels, type MeterReading, type MeterSource, type MicrophoneDeviceInfo, type MicrophoneEnumeration, type MidiNoteData, type MixerGesture, type MusicalTick, type MusicalTickData, type MusicalTickParams, type NativeEffectDefinition, type NativeEffectInstance, PAN_LAW_RAMP_SECONDS, PPQN, type PanLaw, type PanMatrix, type PanStage, type PanStageContext, type PeakData, type Peaks, type PlayoutState, type PlayoutTrack, type RangeSupport, type ReadMeterMessageParams, type RecordingProgress, type RecordingProgressSource, type RenderAnnotationItemProps, type RenderMode, SPECTROGRAM_DEFAULTS, type SnapTo, type SourceLoader, type SourceState, type SpectrogramCanvasIdParts, type SpectrogramCanvasRegistration, type SpectrogramComputeConfig, type SpectrogramConfig, type SpectrogramData, type SpectrogramDisplayConfig, TRACK_VIEW_FIELDS, type TickType, type TimeSelection, type Timeline, type Track, type TrackChannelSource, type TrackKind, type TrackPanLawSource, type TrackViewField, type ValueSource, type ValueSourceHandle, type WaveformConfig, type WaveformDataObject, type ZoomLevel, annotationMinDurationTicks, appendPeaks, appendToAudioBuffer, applyAnnotationBounds, applyFadeIn, applyFadeOut, assertTrackKind, audibleLatencySamples, audioPanLaw, audioTrack, buildSpectrogramCanvasId, carveClipRange, clipDurationTime, clipEndTime, clipKind, clipOffsetTime, clipPixelWidth, clipStartTime, clipsOverlap, computeMusicalTicks, concatenateAudioData, createAnnotationStore, createAudioBuffer, createClip, createClipFromSeconds, createClipFromTicks, createEffectInstance, createMixerGesture, createPanStage, createSourceLoader, createTimeline, createTrack, createValueSource, dBToNormalized, detectMeterChanges, ensureEffectPrepared, enumerateMicrophones, exponentialCurve, findGaps, gainToDb, gainToNormalized, generateCurve, generatePeaks, getClipsAtSample, getClipsInRange, getEffectDefinitions, handleKeyboardEvent, isDecidedPanLaw, isLoadingClip, keyBelongsToFocusedControl, linearCurve, logarithmicCurve, matchesKeyBinding, needsPrepare, normalizedToDb, panMatrix, parseSpectrogramCanvasId, pixelsToSamples, pixelsToSeconds, prepareEffect, probeRangeSupport, readMeterMessage, registerEffect, resolveAnnotationShortcuts, resolveRecordingOffsetSamples, sCurveCurve, samplesToPixels, samplesToSeconds, samplesToTicks, secondsToPixels, secondsToSamples, silentMeterLevels, snapTickToGrid, snapToGrid, snapToTicks, sortClipsByTime, splitTrackByKind, ticksPerBar, ticksPerBeat, ticksToBarBeat, ticksToSamples, trackChannelCount, trackKind, trackPanLaw, unregisterEffect, updateAnnotationBoundaries, watchMicrophoneDevices };
|
package/dist/index.d.ts
CHANGED
|
@@ -681,23 +681,6 @@ type FadeType = 'logarithmic' | 'linear' | 'sCurve' | 'exponential';
|
|
|
681
681
|
* Alias for Fade — used by media-element-playout and playout packages
|
|
682
682
|
*/
|
|
683
683
|
type FadeConfig = Fade;
|
|
684
|
-
interface PlaylistConfig {
|
|
685
|
-
samplesPerPixel?: number;
|
|
686
|
-
waveHeight?: number;
|
|
687
|
-
container?: HTMLElement;
|
|
688
|
-
isAutomaticScroll?: boolean;
|
|
689
|
-
timescale?: boolean;
|
|
690
|
-
colors?: {
|
|
691
|
-
waveOutlineColor?: string;
|
|
692
|
-
waveFillColor?: string;
|
|
693
|
-
waveProgressColor?: string;
|
|
694
|
-
};
|
|
695
|
-
controls?: {
|
|
696
|
-
show?: boolean;
|
|
697
|
-
width?: number;
|
|
698
|
-
};
|
|
699
|
-
zoomLevels?: number[];
|
|
700
|
-
}
|
|
701
684
|
interface PlayoutState {
|
|
702
685
|
isPlaying: boolean;
|
|
703
686
|
isPaused: boolean;
|
|
@@ -1411,10 +1394,18 @@ interface AnnotationBoundaryUpdate {
|
|
|
1411
1394
|
linkEndpoints: boolean;
|
|
1412
1395
|
}
|
|
1413
1396
|
/**
|
|
1414
|
-
* Pure boundary-update logic
|
|
1415
|
-
*
|
|
1416
|
-
*
|
|
1417
|
-
*
|
|
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.
|
|
1418
1409
|
*/
|
|
1419
1410
|
declare function updateAnnotationBoundaries(params: AnnotationBoundaryUpdate, options?: AnnotationBoundaryOptions): AnnotationData[];
|
|
1420
1411
|
|
|
@@ -1785,4 +1776,4 @@ declare function needsPrepare(type: string, audioContext: BaseAudioContext): boo
|
|
|
1785
1776
|
declare function ensureEffectPrepared(type: string, audioContext: BaseAudioContext): Promise<void>;
|
|
1786
1777
|
declare function createEffectInstance(type: string, audioContext: BaseAudioContext, params?: Record<string, number>): CreatedNativeEffect;
|
|
1787
1778
|
|
|
1788
|
-
export { ANNOTATION_LINK_THRESHOLD_TICKS, type AnnotationAction, type AnnotationActionOptions, type AnnotationBoundaryOptions, type AnnotationBoundaryUpdate, type AnnotationBoundsChange, type AnnotationData, type AnnotationEventMap, type AnnotationFormat, type AnnotationListOptions, type AnnotationShortcutAction, type AnnotationShortcutMap, type AnnotationStore, type AnnotationStoreOptions, type ArrangementTrack, type AudioBuffer$1 as AudioBuffer, type AudioClip, type AudioTrackOptions, type Bits, type ClipSource, type ClipTrack, type ColorMapEntry, type ColorMapName, type ColorMapValue, type CreateClipOptions, type CreateClipOptionsSeconds, type CreateClipOptionsTicks, type CreateTrackOptions, type CreatedNativeEffect, DEFAULT_ANNOTATION_SHORTCUTS, DEFAULT_PAN_LAW, DEFAULT_SPECTROGRAM_COLOR_MAP, type DecidedPanLaw, type EffectParamDef, type FFTSize, type Fade, type FadeConfig, type FadeType, type Gap, InteractionState, type KeyBinding, type KeyboardShortcut, LINK_THRESHOLD, type LoadingClip, MAX_CANVAS_WIDTH, METER_PEAK_DECAY, MIN_ANNOTATION_DURATION, MIN_PIXELS_PER_UNIT, type MeterEntry, type MeterLevels, type MeterReading, type MeterSource, type MicrophoneDeviceInfo, type MicrophoneEnumeration, type MidiNoteData, type MixerGesture, type MusicalTick, type MusicalTickData, type MusicalTickParams, type NativeEffectDefinition, type NativeEffectInstance, PAN_LAW_RAMP_SECONDS, PPQN, type PanLaw, type PanMatrix, type PanStage, type PanStageContext, type PeakData, type Peaks, type
|
|
1779
|
+
export { ANNOTATION_LINK_THRESHOLD_TICKS, type AnnotationAction, type AnnotationActionOptions, type AnnotationBoundaryOptions, type AnnotationBoundaryUpdate, type AnnotationBoundsChange, type AnnotationData, type AnnotationEventMap, type AnnotationFormat, type AnnotationListOptions, type AnnotationShortcutAction, type AnnotationShortcutMap, type AnnotationStore, type AnnotationStoreOptions, type ArrangementTrack, type AudioBuffer$1 as AudioBuffer, type AudioClip, type AudioTrackOptions, type Bits, type ClipSource, type ClipTrack, type ColorMapEntry, type ColorMapName, type ColorMapValue, type CreateClipOptions, type CreateClipOptionsSeconds, type CreateClipOptionsTicks, type CreateTrackOptions, type CreatedNativeEffect, DEFAULT_ANNOTATION_SHORTCUTS, DEFAULT_PAN_LAW, DEFAULT_SPECTROGRAM_COLOR_MAP, type DecidedPanLaw, type EffectParamDef, type FFTSize, type Fade, type FadeConfig, type FadeType, type Gap, InteractionState, type KeyBinding, type KeyboardShortcut, LINK_THRESHOLD, type LoadingClip, MAX_CANVAS_WIDTH, METER_PEAK_DECAY, MIN_ANNOTATION_DURATION, MIN_PIXELS_PER_UNIT, type MeterEntry, type MeterLevels, type MeterReading, type MeterSource, type MicrophoneDeviceInfo, type MicrophoneEnumeration, type MidiNoteData, type MixerGesture, type MusicalTick, type MusicalTickData, type MusicalTickParams, type NativeEffectDefinition, type NativeEffectInstance, PAN_LAW_RAMP_SECONDS, PPQN, type PanLaw, type PanMatrix, type PanStage, type PanStageContext, type PeakData, type Peaks, type PlayoutState, type PlayoutTrack, type RangeSupport, type ReadMeterMessageParams, type RecordingProgress, type RecordingProgressSource, type RenderAnnotationItemProps, type RenderMode, SPECTROGRAM_DEFAULTS, type SnapTo, type SourceLoader, type SourceState, type SpectrogramCanvasIdParts, type SpectrogramCanvasRegistration, type SpectrogramComputeConfig, type SpectrogramConfig, type SpectrogramData, type SpectrogramDisplayConfig, TRACK_VIEW_FIELDS, type TickType, type TimeSelection, type Timeline, type Track, type TrackChannelSource, type TrackKind, type TrackPanLawSource, type TrackViewField, type ValueSource, type ValueSourceHandle, type WaveformConfig, type WaveformDataObject, type ZoomLevel, annotationMinDurationTicks, appendPeaks, appendToAudioBuffer, applyAnnotationBounds, applyFadeIn, applyFadeOut, assertTrackKind, audibleLatencySamples, audioPanLaw, audioTrack, buildSpectrogramCanvasId, carveClipRange, clipDurationTime, clipEndTime, clipKind, clipOffsetTime, clipPixelWidth, clipStartTime, clipsOverlap, computeMusicalTicks, concatenateAudioData, createAnnotationStore, createAudioBuffer, createClip, createClipFromSeconds, createClipFromTicks, createEffectInstance, createMixerGesture, createPanStage, createSourceLoader, createTimeline, createTrack, createValueSource, dBToNormalized, detectMeterChanges, ensureEffectPrepared, enumerateMicrophones, exponentialCurve, findGaps, gainToDb, gainToNormalized, generateCurve, generatePeaks, getClipsAtSample, getClipsInRange, getEffectDefinitions, handleKeyboardEvent, isDecidedPanLaw, isLoadingClip, keyBelongsToFocusedControl, linearCurve, logarithmicCurve, matchesKeyBinding, needsPrepare, normalizedToDb, panMatrix, parseSpectrogramCanvasId, pixelsToSamples, pixelsToSeconds, prepareEffect, probeRangeSupport, readMeterMessage, registerEffect, resolveAnnotationShortcuts, resolveRecordingOffsetSamples, sCurveCurve, samplesToPixels, samplesToSeconds, samplesToTicks, secondsToPixels, secondsToSamples, silentMeterLevels, snapTickToGrid, snapToGrid, snapToTicks, sortClipsByTime, splitTrackByKind, ticksPerBar, ticksPerBeat, ticksToBarBeat, ticksToSamples, trackChannelCount, trackKind, trackPanLaw, unregisterEffect, updateAnnotationBoundaries, watchMicrophoneDevices };
|
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
|