@linker-design-plus/timeline-track 1.0.10 → 2.0.0

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.
Files changed (75) hide show
  1. package/README.md +328 -381
  2. package/dist/components/interaction/globalPointerDragSession.d.ts +8 -0
  3. package/dist/components/panel/ClipConfigPanel.d.ts +48 -0
  4. package/dist/components/panel/TrackInfoPanel.d.ts +33 -0
  5. package/dist/components/scrollbar/KonvaScrollbarView.d.ts +58 -0
  6. package/dist/components/timeline/ManagedPlayhead.d.ts +29 -0
  7. package/dist/components/{Playhead.d.ts → timeline/Playhead.d.ts} +1 -1
  8. package/dist/components/{Timeline.d.ts → timeline/Timeline.d.ts} +8 -7
  9. package/dist/components/timeline/TimelineHeaderView.d.ts +45 -0
  10. package/dist/components/track/Clip.d.ts +16 -0
  11. package/dist/components/track/Track.d.ts +121 -0
  12. package/dist/components/track/trackClipLayout.d.ts +23 -0
  13. package/dist/components/track/trackInteractionState.d.ts +79 -0
  14. package/dist/core/commands/timelineCommands.d.ts +121 -0
  15. package/dist/core/controllers/demoPreviewRebuildState.d.ts +54 -0
  16. package/dist/core/controllers/domPreviewBackend.d.ts +5 -0
  17. package/dist/core/controllers/index.d.ts +13 -0
  18. package/dist/core/controllers/previewBackend.d.ts +53 -0
  19. package/dist/core/controllers/previewBackendSupport.d.ts +2 -0
  20. package/dist/core/controllers/previewClockController.d.ts +13 -0
  21. package/dist/core/controllers/previewTransformMath.d.ts +27 -0
  22. package/dist/core/controllers/previewTransformOverlay.d.ts +45 -0
  23. package/dist/core/controllers/timelineClipConfigController.d.ts +17 -0
  24. package/dist/core/controllers/timelineClipEventController.d.ts +32 -0
  25. package/dist/core/controllers/timelineClipWorkflowController.d.ts +30 -0
  26. package/dist/core/controllers/timelineDurationController.d.ts +14 -0
  27. package/dist/core/controllers/timelineEventDispatcher.d.ts +12 -0
  28. package/dist/core/controllers/timelinePlaybackResolver.d.ts +17 -0
  29. package/dist/core/controllers/timelinePreviewSession.d.ts +94 -0
  30. package/dist/core/controllers/timelineSelectionController.d.ts +17 -0
  31. package/dist/core/controllers/timelineTrackInfoPanelController.d.ts +19 -0
  32. package/dist/core/controllers/timelineTrackMutationController.d.ts +46 -0
  33. package/dist/core/facade/timelineManager.d.ts +385 -0
  34. package/dist/core/{history.d.ts → history/history.d.ts} +16 -14
  35. package/dist/core/history/index.d.ts +3 -0
  36. package/dist/core/history/timelineHistoryExecutor.d.ts +23 -0
  37. package/dist/core/history/timelineHistoryRecorder.d.ts +15 -0
  38. package/dist/core/layout/index.d.ts +1 -0
  39. package/dist/core/layout/timelineManagerDom.d.ts +22 -0
  40. package/dist/core/layout/timelineTrackLayout.d.ts +10 -0
  41. package/dist/core/models/clipState.d.ts +3 -0
  42. package/dist/core/{constants.d.ts → models/constants.d.ts} +4 -0
  43. package/dist/core/models/index.d.ts +3 -0
  44. package/dist/core/models/types.d.ts +400 -0
  45. package/dist/core/presentation/index.d.ts +1 -0
  46. package/dist/core/presentation/timelinePresentationAdapter.d.ts +22 -0
  47. package/dist/core/stores/index.d.ts +4 -0
  48. package/dist/core/stores/playbackStore.d.ts +17 -0
  49. package/dist/core/stores/selectionStore.d.ts +7 -0
  50. package/dist/core/stores/timelineStore.d.ts +44 -0
  51. package/dist/core/stores/viewportStore.d.ts +33 -0
  52. package/dist/core/testing/konva-test-stub.d.ts +81 -0
  53. package/dist/core/tracks/index.d.ts +3 -0
  54. package/dist/core/tracks/timelineTrackBridge.d.ts +37 -0
  55. package/dist/core/tracks/timelineTrackCollection.d.ts +50 -0
  56. package/dist/core/tracks/trackManager.d.ts +19 -0
  57. package/dist/core/utils/mountManager.d.ts +10 -0
  58. package/dist/index.cjs.js +29 -3
  59. package/dist/index.d.ts +12 -7
  60. package/dist/index.es.js +8924 -4414
  61. package/dist/utils/logging/Logger.d.ts +30 -0
  62. package/dist/utils/logging/index.d.ts +1 -0
  63. package/dist/utils/{KonvaUtils.d.ts → rendering/KonvaUtils.d.ts} +3 -43
  64. package/dist/utils/rendering/clipCoverRenderer.d.ts +23 -0
  65. package/dist/utils/rendering/clipVisualRenderer.d.ts +5 -0
  66. package/dist/utils/rendering/index.d.ts +4 -0
  67. package/dist/utils/rendering/timelineGridDrawing.d.ts +8 -0
  68. package/dist/utils/time/index.d.ts +1 -0
  69. package/dist/utils/{timeUtils.d.ts → time/timeUtils.d.ts} +4 -0
  70. package/package.json +4 -2
  71. package/dist/components/Clip.d.ts +0 -44
  72. package/dist/components/VideoTrack.d.ts +0 -137
  73. package/dist/core/timelineManager.d.ts +0 -226
  74. package/dist/core/types.d.ts +0 -187
  75. package/dist/utils/Logger.d.ts +0 -49
@@ -0,0 +1,30 @@
1
+ import type { LogConfig } from '../../core/models/types';
2
+ export declare class Logger {
3
+ private static config;
4
+ private static dedupeWindowMs;
5
+ private static readonly dedupeState;
6
+ /**
7
+ * 配置日志系统
8
+ * @param config 日志配置
9
+ */
10
+ static setConfig(config?: LogConfig): void;
11
+ /**
12
+ * 输出调试级别日志
13
+ * @param module 模块名称
14
+ * @param message 日志消息
15
+ * @param data 附加数据
16
+ */
17
+ static debug(module: string, message: string, data?: any): void;
18
+ static debugLazy(module: string, messageFactory: () => string, dataFactory?: () => any): void;
19
+ static info(module: string, message: string, data?: any): void;
20
+ static infoLazy(module: string, messageFactory: () => string, dataFactory?: () => any): void;
21
+ static warn(module: string, message: string, data?: any): void;
22
+ static warnLazy(module: string, messageFactory: () => string, dataFactory?: () => any): void;
23
+ static error(module: string, message: string, data?: any): void;
24
+ /**
25
+ * 设置去重窗口,减少高频日志刷屏
26
+ */
27
+ static setDedupeWindowMs(windowMs: number): void;
28
+ private static emit;
29
+ private static resolveConsoleMethod;
30
+ }
@@ -0,0 +1 @@
1
+ export { Logger } from './Logger';
@@ -1,15 +1,10 @@
1
1
  import Konva from 'konva';
2
- import type { Theme } from '../core/types';
2
+ import type { Theme, TrackType } from '../../core/models';
3
3
  /**
4
4
  * Konva工具类,封装常用的Konva操作
5
5
  */
6
6
  export declare class KonvaUtils {
7
7
  static readonly RESIZE_AREA_WIDTH = 3;
8
- /** 单张封面图的最小展示宽度(px),zoom 过小时通过减少显示段数保证每段不低于此宽度,且仍填满整条 */
9
- static readonly MIN_IMAGE_DISPLAY_WIDTH = 24;
10
- private static keyframeDimensionsCache;
11
- private static imageCache;
12
- private static readonly MAX_CACHE_SIZE;
13
8
  /**
14
9
  * 创建舞台
15
10
  */
@@ -49,32 +44,6 @@ export declare class KonvaUtils {
49
44
  * 绘制网格线
50
45
  */
51
46
  static drawGrid(layer: Konva.Layer, x: number, y: number, width: number, height: number, gridSize: number): void;
52
- /**
53
- * 格式化时间(毫秒 -> mm:ss.ms)
54
- */
55
- static formatTime(ms: number): string;
56
- /**
57
- * 格式化时长(毫秒 -> ss.ms)
58
- */
59
- static formatDuration(ms: number): string;
60
- /**
61
- * 获取关键帧的尺寸信息(按 keyframeUrl 缓存,保证每张缩略图使用自身真实比例)
62
- * @param videoSrc 视频源的URL(用于兼容旧调用)
63
- * @param keyframeUrl 关键帧图片的URL
64
- * @returns Promise<{ width: number; height: number }> 关键帧的宽度和高度
65
- */
66
- private static getKeyframeDimensions;
67
- /**
68
- * 获取缓存的图片对象
69
- * @param imageUrl 图片的URL
70
- * @returns HTMLImageElement 图片对象
71
- */
72
- private static getCachedImage;
73
- /**
74
- * 检查并清理缓存,防止内存占用过大
75
- * 优先驱逐未加载完成的图片,已加载的图片尽量保留,避免滚动时重复请求
76
- */
77
- private static checkAndTrimCache;
78
47
  /**
79
48
  * 清空图片缓存
80
49
  */
@@ -82,11 +51,11 @@ export declare class KonvaUtils {
82
51
  /**
83
52
  * 创建片段组
84
53
  */
85
- static createClipGroup(x: number, y: number, width: number, height: number, clipName: string, duration: number, theme: Theme, isSelected?: boolean, thumbnails?: string[], videoSrc?: string): Konva.Group;
54
+ static createClipGroup(x: number, y: number, width: number, height: number, clipName: string, duration: number, theme: Theme, isSelected?: boolean, thumbnails?: string[], videoSrc?: string, clipType?: TrackType, hasSeparatedAudio?: boolean, deferCoverRender?: boolean): Konva.Group;
86
55
  /**
87
56
  * 更新片段组
88
57
  */
89
- static updateClipGroup(group: Konva.Group, width: number, height: number, clipName: string, duration: number, theme?: Theme, isSelected?: boolean, thumbnails?: string[], videoSrc?: string): void;
58
+ static updateClipGroup(group: Konva.Group, width: number, height: number, clipName: string, duration: number, theme?: Theme, isSelected?: boolean, thumbnails?: string[], videoSrc?: string, clipType?: TrackType, hasSeparatedAudio?: boolean, deferCoverRender?: boolean): void;
90
59
  /**
91
60
  * 创建选中效果
92
61
  */
@@ -95,15 +64,6 @@ export declare class KonvaUtils {
95
64
  * 时间到像素的转换
96
65
  */
97
66
  static timeToPixels(time: number, zoom: number): number;
98
- private static readonly COVER_RENDER_VERSION_KEY;
99
- /**
100
- * 渲染关键帧封面(统一放大/缩小逻辑,始终填满无空轴)
101
- * - 将 coverWidth 等分为若干段,每段对应一张缩略图(时间对应)。
102
- * - 放大:段数 = N,段宽可能很大 → 用同一张图重复平铺填满该段。
103
- * - 缩小:段数减少以保证每段宽度 ≥ MIN_IMAGE_DISPLAY_WIDTH,从 N 张中均匀抽样;每段仍用一张图缩放或重复填满。
104
- * - 使用版本号避免 zoom 快速变化时,旧渲染覆盖新渲染导致空轴。
105
- */
106
- static renderClipCovers(coversGroup: Konva.Group, coverSource: string[], coverWidth: number, coverHeight: number, videoSrc?: string): Promise<void>;
107
67
  /**
108
68
  * 像素到时间的转换
109
69
  */
@@ -0,0 +1,23 @@
1
+ import Konva from 'konva';
2
+ export declare class ClipCoverRenderer {
3
+ static readonly MIN_IMAGE_DISPLAY_WIDTH = 24;
4
+ private static readonly COVER_RENDER_VERSION_KEY;
5
+ private static readonly MAX_CACHE_SIZE;
6
+ private static readonly DEFAULT_DIMENSIONS;
7
+ private static keyframeDimensionsCache;
8
+ private static keyframeDimensionsPromiseCache;
9
+ private static imageCache;
10
+ static clearImageCache(): void;
11
+ static renderClipCovers(coversGroup: Konva.Group, coverSource: string[], coverWidth: number, coverHeight: number, videoSrc?: string, deferInitialRender?: boolean): void;
12
+ private static startRenderJob;
13
+ private static buildSegmentsData;
14
+ private static buildSegmentsDataSync;
15
+ private static requestRender;
16
+ private static isRenderJobCurrent;
17
+ private static renderSegments;
18
+ private static getSafeKeyframeDimensions;
19
+ private static getKeyframeDimensions;
20
+ private static getCachedKeyframeDimensions;
21
+ private static getCachedImage;
22
+ private static checkAndTrimCache;
23
+ }
@@ -0,0 +1,5 @@
1
+ import Konva from 'konva';
2
+ import { type Theme, type TrackType } from '../../core/models';
3
+ export declare function createClipGroup(x: number, y: number, width: number, height: number, clipName: string, duration: number, theme: Theme, isSelected?: boolean, thumbnails?: string[], videoSrc?: string, clipType?: TrackType, hasSeparatedAudio?: boolean, deferCoverRender?: boolean): Konva.Group;
4
+ export declare function updateClipGroup(group: Konva.Group, width: number, height: number, clipName: string, duration: number, theme?: Theme, isSelected?: boolean, thumbnails?: string[], videoSrc?: string, clipType?: TrackType, hasSeparatedAudio?: boolean, deferCoverRender?: boolean): void;
5
+ export declare function createSelectionEffect(x: number, y: number, width: number, height: number): Konva.Rect;
@@ -0,0 +1,4 @@
1
+ export { KonvaUtils } from './KonvaUtils';
2
+ export { ClipCoverRenderer } from './clipCoverRenderer';
3
+ export { createClipGroup, createSelectionEffect, updateClipGroup } from './clipVisualRenderer';
4
+ export { drawGrid, drawTimeTick } from './timelineGridDrawing';
@@ -0,0 +1,8 @@
1
+ import Konva from 'konva';
2
+ interface TimeTickTheme {
3
+ timeTick: string;
4
+ timeText: string;
5
+ }
6
+ export declare function drawTimeTick(layer: Konva.Layer, x: number, y: number, height: number, time: number, theme: TimeTickTheme, tickType: 'major' | 'minor', timeScaleHeight?: number): void;
7
+ export declare function drawGrid(layer: Konva.Layer, x: number, y: number, width: number, height: number, gridSize: number): void;
8
+ export {};
@@ -0,0 +1 @@
1
+ export { TimeUtils } from './timeUtils';
@@ -23,6 +23,10 @@ export declare class TimeUtils {
23
23
  * 格式化时间显示
24
24
  */
25
25
  static formatTime(ms: number): string;
26
+ /**
27
+ * 格式化时长(毫秒 -> ss.ms)
28
+ */
29
+ static formatDuration(ms: number): string;
26
30
  /**
27
31
  * 计算两个时间点之间的差值
28
32
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linker-design-plus/timeline-track",
3
- "version": "1.0.10",
3
+ "version": "2.0.0",
4
4
  "description": "A TypeScript-based video editing library with timeline and track functionality",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
@@ -16,13 +16,15 @@
16
16
  "build": "vite build && npm run build:types",
17
17
  "build:types": "tsc -p tsconfig.build.json",
18
18
  "preview": "vite preview",
19
- "test:e2e": "vitest run src/components/__tests__/*.test.ts src/core/__tests__/*.test.ts"
19
+ "test": "vitest run src/components/__tests__/*.test.ts src/core/__tests__/*.test.ts"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@vitejs/plugin-vue": "^5.0.0",
23
+ "jsdom": "^29.0.1",
23
24
  "typescript": "^5.3.0",
24
25
  "vite": "^5.0.0",
25
26
  "vite-plugin-dts": "^3.6.0",
27
+ "vitest": "^4.0.18",
26
28
  "vue": "^3.4.0"
27
29
  },
28
30
  "keywords": [
@@ -1,44 +0,0 @@
1
- import { Clip as ClipType, Position } from '../core/types';
2
- export declare class Clip {
3
- private clip;
4
- private onUpdate;
5
- private onSplit;
6
- private isMoving;
7
- private isMovingVisualApplied;
8
- private dragStartPos;
9
- private originalStart;
10
- private originalDuration;
11
- private originalStartTimeAtSource;
12
- private originalEndTimeAtSource;
13
- private originalOpacity;
14
- constructor(clip: ClipType, onUpdate: (clip: ClipType) => void, onSplit: (clip: ClipType, time: number) => void);
15
- /**
16
- * 检查与其他片段是否重叠
17
- */
18
- checkCollision(newStartTime: number, newDuration: number, otherClips: ClipType[]): ClipType | undefined;
19
- /**
20
- * 检查是否超出边界
21
- */
22
- checkBoundary(newStartTimeAtSource: number, newEndTimeAtSource: number, newDuration: number, newStartTime: number): boolean;
23
- /**
24
- * 获取片段的中心点
25
- */
26
- getCenterTime(): number;
27
- getClip(): ClipType;
28
- setSelected(selected: boolean): void;
29
- isPointInClip(x: number, y: number, zoom: number, trackY: number, trackHeight: number, scrollLeft: number): boolean;
30
- isPointInResizeHandle(x: number, y: number, zoom: number, trackY: number, trackHeight: number, scrollLeft: number): boolean;
31
- startDrag(pos: Position): void;
32
- startResize(pos: Position): void;
33
- /**
34
- * 拖动片段或调整片段大小
35
- * @param pos 当前鼠标位置
36
- * @param zoom 缩放比例
37
- * @param otherClips 其他片段列表(用于碰撞检测)
38
- * @param enableBoundaryCheck 是否启用边界检查
39
- * @returns 是否成功更新(即是否在边界内)
40
- */
41
- drag(pos: Position, zoom: number, otherClips?: ClipType[], enableBoundaryCheck?: boolean): boolean;
42
- endDrag(): void;
43
- split(time: number): void;
44
- }
@@ -1,137 +0,0 @@
1
- import Konva from 'konva';
2
- import { Clip as ClipType, TrackConfig, TimeMs, Theme } from '../core/types';
3
- export declare class VideoTrack {
4
- private layer;
5
- private trackGroup;
6
- private config;
7
- private theme;
8
- private clips;
9
- private clipGroups;
10
- private zoom;
11
- private scrollLeft;
12
- private trackY;
13
- private trackHeight;
14
- private selectedClip;
15
- private originalClipsState;
16
- private nonDraggedClips;
17
- private isVisualUpdate;
18
- private onClipUpdate;
19
- private onClipAdd;
20
- private onClipRemove;
21
- private onClipSplit;
22
- private onClipSelect;
23
- private onTimeJump;
24
- private onAutoScrollDuringDrag?;
25
- private dragAutoScrollOffsetPx;
26
- private hasBoundGlobalPointerListenersForDrag;
27
- private handleGlobalPointerMove;
28
- private handleGlobalPointerEnd;
29
- constructor(layer: Konva.Layer, config: TrackConfig, zoom: number, trackY: number, trackHeight: number, theme: Theme, onClipUpdate: (clip: ClipType, originalClip?: ClipType, clipUpdates?: Array<{
30
- clipId: string;
31
- newState: any;
32
- previousState: any;
33
- }>) => void, onClipAdd: (clip: ClipType) => void, onClipRemove: (clipId: string) => void, onClipSplit: (clip1: ClipType, clip2: ClipType) => void, onClipSelect: (clip: ClipType) => void, onTimeJump: (time: TimeMs) => void, onAutoScrollDuringDrag?: (targetScrollLeft: number) => void);
34
- private initClips;
35
- private initEventListeners;
36
- private bindGlobalPointerListenersForDrag;
37
- private unbindGlobalPointerListenersForDrag;
38
- private handleVisibilityChange;
39
- /**
40
- * 处理轨道背景点击事件
41
- */
42
- private handleTrackBackgroundClick;
43
- /**
44
- * 创建片段组
45
- */
46
- private createClipGroup;
47
- /**
48
- * 处理片段点击事件
49
- */
50
- private handleClipClick;
51
- /**
52
- * 处理片段鼠标按下事件
53
- */
54
- private handleClipMouseDown;
55
- /**
56
- * 处理片段鼠标移动事件
57
- */
58
- private handleClipMouseMove;
59
- /**
60
- * 处理片段鼠标释放事件
61
- */
62
- private handleClipMouseUp;
63
- /**
64
- * 处理片段移动结束后的重叠检测和重新排序
65
- */
66
- private handleClipMoveEnd;
67
- /**
68
- * 调整片段以解决重叠问题
69
- * @param clips 需要调整的片段数组
70
- * @param startIndex 开始调整的索引
71
- */
72
- private adjustClipsForOverlap;
73
- /**
74
- * 批量更新所有片段状态
75
- * @param processedClips 处理后的片段数组
76
- */
77
- private updateAllClips;
78
- /**
79
- * 构建并发送更新数据
80
- * @param draggedClip 拖动的片段
81
- * @param processedClips 处理后的片段数组
82
- */
83
- private buildAndSendUpdates;
84
- /**
85
- * 处理舞台鼠标移动事件
86
- */
87
- private handleStageMouseMove;
88
- private isDragSessionActive;
89
- private handleDragMove;
90
- private maybeAutoScrollDuringDrag;
91
- /**
92
- * 处理片段鼠标离开事件
93
- */
94
- private handleClipMouseLeave;
95
- /**
96
- * 更新片段的视觉状态
97
- */
98
- private updateClipVisualState;
99
- /**
100
- * 更新片段组
101
- */
102
- private updateClipGroup;
103
- private handleClipUpdate;
104
- private handleClipSplit;
105
- addClip(clip: ClipType): void;
106
- removeClip(clipId: string): void;
107
- updateClip(clipId: string, updates: Partial<ClipType>): void;
108
- setZoom(zoom: number): void;
109
- setCurrentTime(_time: TimeMs): void;
110
- setScrollLeft(scrollLeft: number): void;
111
- /**
112
- * 更新片段的可见性
113
- */
114
- private updateClipVisibility;
115
- setTrackY(trackY: number): void;
116
- render(): void;
117
- getClips(): ClipType[];
118
- getSelectedClip(): ClipType | null;
119
- /**
120
- * 选择指定的片段
121
- * @param clipId 目标片段的 ID
122
- */
123
- selectClip(clipId: string): void;
124
- splitSelectedClip(time: TimeMs): void;
125
- /**
126
- * 删除轨道内片段之间的空隙
127
- */
128
- removeClipGaps(): void;
129
- /**
130
- * 获取轨道组
131
- */
132
- getTrackGroup(): Konva.Group;
133
- /**
134
- * 获取轨道ID
135
- */
136
- getId(): string;
137
- }
@@ -1,226 +0,0 @@
1
- import { TimelineConfig, Clip, ClipConfig, TimeMs, PlayState, Action, TimelineEvent, EventListener as TimelineEventListener, VideoPreviewConfig, TimelineExportData, ThumbnailProvider } from './types';
2
- export declare class TimelineManager {
3
- private timeline;
4
- private tracks;
5
- private playhead;
6
- private history;
7
- private config;
8
- private eventListeners;
9
- private animationFrameId;
10
- private lastUpdateTime;
11
- private isInitialized;
12
- private stage;
13
- private gridLayer;
14
- private trackLayer;
15
- private playheadLayer;
16
- private selectionLayer;
17
- private resizeObserver;
18
- private videoPreview;
19
- private isExecutingHistoryAction;
20
- private lastTrackDuration;
21
- private thumbnailProvider;
22
- private canPlay;
23
- private isBuffering;
24
- private sourceLoadingCount;
25
- private lastSelectedClipId;
26
- private playStateBeforeBuffering;
27
- private isPausingForBuffering;
28
- private videoBufferingListeners;
29
- constructor(config?: Partial<TimelineConfig>);
30
- init(container: HTMLElement): void;
31
- play(): void;
32
- pause(): void;
33
- togglePlay(): void;
34
- private animate;
35
- setCurrentTime(time: TimeMs): void;
36
- getCurrentTime(): TimeMs;
37
- setZoom(zoom: number): void;
38
- /**
39
- * 以游标(playhead)为中心设置缩放,用于外置 slider 等非幕布上的缩放操作
40
- * 调整 scrollLeft 使游标在屏幕上的位置保持不变
41
- */
42
- setZoomCenteredOnPlayhead(zoom: number): void;
43
- /**
44
- * 外部缩放入口:
45
- * - 鼠标在时间轴内:以鼠标位置为中心缩放
46
- * - 鼠标不在时间轴内:回退为以游标(playhead)为中心缩放
47
- */
48
- setZoomByInteraction(zoom: number): void;
49
- /**
50
- * 以时间轴上的指定像素点为中心缩放,保持该像素对应时间不变
51
- */
52
- setZoomCenteredOnTimelinePointer(zoom: number, pointerX: number): void;
53
- getZoom(): number;
54
- /**
55
- * 设置播放倍速
56
- * @param speed 播放倍速,默认为 1.0
57
- */
58
- setSpeed(speed: number): void;
59
- /**
60
- * 获取当前播放倍速
61
- * @returns 当前播放倍速
62
- */
63
- getSpeed(): number;
64
- /**
65
- * 获取当前是否可以播放
66
- * @returns 是否可以播放
67
- */
68
- getCanPlay(): boolean;
69
- /**
70
- * 当前是否存在视频源加载任务(例如 addClip 期间读取视频时长)
71
- */
72
- isSourceLoading(): boolean;
73
- /**
74
- * 获取视频源加载状态
75
- */
76
- getSourceLoadingState(): {
77
- isLoading: boolean;
78
- pending: number;
79
- };
80
- /**
81
- * 设置缩略图提供器
82
- * @param provider 缩略图提供器
83
- */
84
- setThumbnailProvider(provider: ThumbnailProvider): void;
85
- /**
86
- * 加载片段的封面
87
- * @param clip 片段对象
88
- * @returns Promise<boolean> 加载是否成功
89
- */
90
- private loadClipThumbnails;
91
- /**
92
- * 刷新指定片段的封面
93
- * @param clipId 片段 ID
94
- * @returns Promise<boolean> 刷新是否成功
95
- */
96
- refreshClipThumbnails(clipId: string): Promise<boolean>;
97
- /**
98
- * 刷新所有片段的封面
99
- * @returns Promise<boolean[]> 每个片段的刷新结果
100
- */
101
- refreshAllClipThumbnails(): Promise<boolean[]>;
102
- addClip(clipConfig: ClipConfig): Promise<string>;
103
- /**
104
- * 批量添加片段。批量模式下仅维护一段连续的视频源加载状态。
105
- */
106
- addClips(clipConfigs: ClipConfig[]): Promise<string[]>;
107
- private addClipInternal;
108
- removeClip(clipId: string): void;
109
- updateClip(clipId: string, updates: Partial<Clip>): void;
110
- splitClip(clipId: string, time: TimeMs): void;
111
- splitCurrentClip(): void;
112
- getClips(): Clip[];
113
- exportTimeline(): TimelineExportData;
114
- getClipsData(): Clip[];
115
- /**
116
- * 获取插件版本号
117
- */
118
- getVersion(): string;
119
- undo(): boolean;
120
- redo(): boolean;
121
- getHistoryState(): {
122
- past: Action[];
123
- future: Action[];
124
- };
125
- /** 调整缩放比例以适应当前所有片段 */
126
- fitZoom(): void;
127
- /** 删除轨道内clip 间的空隙 */
128
- removeClipGaps(): void;
129
- private handleTimeChange;
130
- private handleZoomChange;
131
- private handleScrollChange;
132
- private handleTrackAutoScrollRequest;
133
- private handleClipUpdate;
134
- private handleClipAdd;
135
- private handleClipRemove;
136
- /**
137
- * 检查并重新加载关键帧(如果需要)
138
- * @param clip 更新后的片段
139
- * @param originalClip 原始片段
140
- */
141
- private reloadClipThumbnailsIfNeeded;
142
- /**
143
- * 更新 canPlay 状态
144
- */
145
- private updateCanPlayState;
146
- private handleClipSplit;
147
- private handleClipSelect;
148
- private handleActionUndo;
149
- private handleActionRedo;
150
- on(event: TimelineEvent, listener: TimelineEventListener): void;
151
- off(event: TimelineEvent, listener: TimelineEventListener): void;
152
- private emitEvent;
153
- private emitSelectedClipChangeIfNeeded;
154
- private beginSourceLoading;
155
- private endSourceLoading;
156
- getPlayState(): PlayState;
157
- setDuration(duration: TimeMs): void;
158
- getDuration(): TimeMs;
159
- /**
160
- * 调整时间轴大小以适配容器
161
- * @param width 新的宽度
162
- * @param height 新的高度
163
- */
164
- resize(width: number, height: number): void;
165
- /**
166
- * 滚动到指定时间
167
- * @param time 目标时间(毫秒)
168
- * @param setCurrentTime 是否同时将当前时间设置为该时间点,默认为 false
169
- */
170
- scrollToTime(time: TimeMs, setCurrentTime?: boolean): void;
171
- /**
172
- * 选择指定的片段
173
- * @param clipId 目标片段的 ID
174
- */
175
- selectClip(clipId: string): void;
176
- /**
177
- * 滚动到指定片段
178
- * @param clipId 目标片段的 ID
179
- * @param options 配置选项
180
- */
181
- scrollToClip(clipId: string, options?: {
182
- selectClip?: boolean;
183
- setCurrentTime?: boolean;
184
- }): void;
185
- /**
186
- * 获取当前时间点所在的clip
187
- * @returns 当前时间点所在的clip,如果没有则返回null
188
- */
189
- /**
190
- * 获取当前选中的 clip
191
- * @returns 当前选中的 clip,如果没有则返回 null
192
- */
193
- getSelectedClip(): Clip | null;
194
- getCurrentClip(): Clip | null;
195
- /**
196
- * 删除当前选中的 clip
197
- * @returns 是否成功删除了选中的 clip
198
- */
199
- removeSelectedClip(): boolean;
200
- /**
201
- * 获取轨道内的总时长(包含空隙)
202
- * @returns 从0到最后一个clip结束时间的总时长(毫秒)
203
- */
204
- getTrackTotalDuration(): TimeMs;
205
- destroy(): void;
206
- connectTo(videoElement: HTMLVideoElement): void;
207
- connectTo(config: VideoPreviewConfig): void;
208
- disconnectVideo(): void;
209
- /** 清除历史堆栈 */
210
- clearHistory(): void;
211
- private handleVideoTimeUpdate;
212
- private getLastClipByEndTime;
213
- private handlePlayStateChange;
214
- private handleClipChange;
215
- private findClipAtTime;
216
- private loadClipToVideo;
217
- private attachVideoBufferingListeners;
218
- private detachVideoBufferingListeners;
219
- private enterBuffering;
220
- private exitBuffering;
221
- private clearBufferingStateForNoSource;
222
- /**
223
- * 检查轨道总时长是否变化,如果变化则触发事件并更新时间轴时长
224
- */
225
- private checkTrackDurationChange;
226
- }