react-av-timeline 2.0.0 → 3.0.1
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/LICENSE +7 -0
- package/README.md +97 -2
- package/dist/TraceWaterfall.d.ts +2 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +611 -244
- package/dist/waterfall.d.ts +137 -0
- package/package.json +4 -3
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
export interface TimelineClip {
|
|
3
|
+
/** 唯一 id */
|
|
4
|
+
id: string;
|
|
5
|
+
/** 行标签与搜索文案,缺省用 id */
|
|
6
|
+
name?: string;
|
|
7
|
+
/** 轨道号,相同 index 即同一轨 */
|
|
8
|
+
index: number;
|
|
9
|
+
/** 开始时间 */
|
|
10
|
+
start: number;
|
|
11
|
+
/** 时长,唯一结束依据 */
|
|
12
|
+
duration: number;
|
|
13
|
+
/** 条形内自定义内容,缺省用 name */
|
|
14
|
+
label?: ReactNode;
|
|
15
|
+
/** 条形颜色,缺省按轨道取 --wf-clip-N */
|
|
16
|
+
color?: string;
|
|
17
|
+
/** 条形自定义样式 */
|
|
18
|
+
style?: CSSProperties;
|
|
19
|
+
/** 原始数据,详情中展示 */
|
|
20
|
+
meta?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
export interface TimelineTrack {
|
|
23
|
+
/** 轨道号 */
|
|
24
|
+
index: number;
|
|
25
|
+
/** 轨道名 */
|
|
26
|
+
name?: string;
|
|
27
|
+
}
|
|
28
|
+
export type TimeFormat = {
|
|
29
|
+
type: 'number';
|
|
30
|
+
} | {
|
|
31
|
+
type: 'clock';
|
|
32
|
+
millisecond?: boolean;
|
|
33
|
+
offset?: number;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'smpte';
|
|
36
|
+
fps: number;
|
|
37
|
+
offset?: number;
|
|
38
|
+
};
|
|
39
|
+
export interface TimelineRange {
|
|
40
|
+
start: number;
|
|
41
|
+
end: number;
|
|
42
|
+
duration: number;
|
|
43
|
+
}
|
|
44
|
+
export interface TimelineRow {
|
|
45
|
+
id: string;
|
|
46
|
+
index: number;
|
|
47
|
+
trackName: string;
|
|
48
|
+
label: string;
|
|
49
|
+
start: number;
|
|
50
|
+
end: number;
|
|
51
|
+
clips: TimelineClip[];
|
|
52
|
+
}
|
|
53
|
+
export interface TimelineLabels {
|
|
54
|
+
search: string;
|
|
55
|
+
noMatch: (query: string) => string;
|
|
56
|
+
empty: string;
|
|
57
|
+
current: string;
|
|
58
|
+
total: string;
|
|
59
|
+
track: string;
|
|
60
|
+
start: string;
|
|
61
|
+
end: string;
|
|
62
|
+
duration: string;
|
|
63
|
+
close: string;
|
|
64
|
+
zoom: string;
|
|
65
|
+
lanesColumn: string;
|
|
66
|
+
sequenceColumn: string;
|
|
67
|
+
}
|
|
68
|
+
export interface TraceWaterfallProps {
|
|
69
|
+
/** 数据 */
|
|
70
|
+
clips: TimelineClip[];
|
|
71
|
+
tracks?: TimelineTrack[];
|
|
72
|
+
/** 行布局,默认 lanes;followMode 非 off 时强制 sequence */
|
|
73
|
+
layout?: 'lanes' | 'sequence';
|
|
74
|
+
/** 时间单位,默认 s */
|
|
75
|
+
unit?: 'ms' | 's';
|
|
76
|
+
viewStart?: number;
|
|
77
|
+
viewDuration?: number;
|
|
78
|
+
currentTime?: number;
|
|
79
|
+
onCurrentTimeChange?: (time: number) => void;
|
|
80
|
+
formatTime?: TimeFormat | ((value: number) => string);
|
|
81
|
+
formatDuration?: (value: number) => string;
|
|
82
|
+
/** 视口 */
|
|
83
|
+
fixedPlayhead?: boolean;
|
|
84
|
+
playheadPosition?: number;
|
|
85
|
+
followMode?: 'off' | 'scroll' | 'hide';
|
|
86
|
+
zoom?: number;
|
|
87
|
+
defaultZoom?: number;
|
|
88
|
+
onZoomChange?: (zoom: number) => void;
|
|
89
|
+
/** 外观 */
|
|
90
|
+
labelWidth?: number;
|
|
91
|
+
height?: CSSProperties['height'];
|
|
92
|
+
minTickGap?: number;
|
|
93
|
+
showTime?: boolean;
|
|
94
|
+
showDetail?: boolean;
|
|
95
|
+
showSearch?: boolean;
|
|
96
|
+
showZoom?: boolean;
|
|
97
|
+
emptyText?: string;
|
|
98
|
+
labels?: Partial<TimelineLabels>;
|
|
99
|
+
onClipClick?: (clip: TimelineClip) => void;
|
|
100
|
+
className?: string;
|
|
101
|
+
style?: CSSProperties;
|
|
102
|
+
}
|
|
103
|
+
export declare const DEFAULT_TIME_FORMAT: TimeFormat;
|
|
104
|
+
export declare const ZOOM_LEVELS: number[];
|
|
105
|
+
export declare const DEFAULT_LABELS: TimelineLabels;
|
|
106
|
+
/** 片段结束时间;负时长按 0 处理 */
|
|
107
|
+
export declare function getClipEnd(clip: TimelineClip): number;
|
|
108
|
+
/** 计算视图范围;空数据时回退到 0 */
|
|
109
|
+
export declare function resolveRange(clips: TimelineClip[], viewStart?: number, viewDuration?: number): TimelineRange;
|
|
110
|
+
/** 把时间钳制到视图范围 */
|
|
111
|
+
export declare function clampTime(time: number, range: TimelineRange): number;
|
|
112
|
+
/** 返回该时刻所有活跃片段(闭区间),保持声明顺序 */
|
|
113
|
+
export declare function getActiveAt(clips: TimelineClip[], time: number, range?: TimelineRange): TimelineClip[];
|
|
114
|
+
/**
|
|
115
|
+
* 返回每轨最上层的活跃片段,按轨道号升序。
|
|
116
|
+
* 同轨重叠时取声明顺序中的最后一个。
|
|
117
|
+
*/
|
|
118
|
+
export declare function getTopActiveAt(clips: TimelineClip[], time: number, range?: TimelineRange): TimelineClip[];
|
|
119
|
+
/** 搜索匹配 name 与 id,大小写不敏感 */
|
|
120
|
+
export declare function matchClip(clip: TimelineClip, query: string): boolean;
|
|
121
|
+
/** 构建行:lanes 按轨道,sequence 按 start 平铺 */
|
|
122
|
+
export declare function buildRows(clips: TimelineClip[], tracks: TimelineTrack[] | undefined, layout: 'lanes' | 'sequence', labels: Pick<TimelineLabels, 'track'>): TimelineRow[];
|
|
123
|
+
/** 从 1 / 2 / 5 / 10 × 10^n 中选出不小于 min 的最小步长 */
|
|
124
|
+
export declare function niceStep(min: number): number;
|
|
125
|
+
/** 生成整数刻度;最多 500 个 */
|
|
126
|
+
export declare function buildTicks(range: TimelineRange, pxPerUnit: number, minGap?: number): {
|
|
127
|
+
step: number;
|
|
128
|
+
ticks: Array<{
|
|
129
|
+
value: number;
|
|
130
|
+
x: number;
|
|
131
|
+
}>;
|
|
132
|
+
firstOffset: number;
|
|
133
|
+
};
|
|
134
|
+
/** 绝对时间格式化,会应用 offset */
|
|
135
|
+
export declare function formatTime(value: number, format?: TimeFormat | ((value: number) => string), unit?: 'ms' | 's'): string;
|
|
136
|
+
/** 时长格式化,不应用 offset */
|
|
137
|
+
export declare function formatDuration(value: number, format?: TimeFormat | ((value: number) => string), unit?: 'ms' | 's'): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-av-timeline",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"author": "ArSrNa",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"bugs": {
|
|
44
44
|
"url": "https://cnb.cool/arsrna/os/react-timeline/-/issues"
|
|
45
45
|
},
|
|
46
|
-
"description": "React
|
|
46
|
+
"description": "React 音视频时间线组件,含导播瀑布时间线",
|
|
47
47
|
"files": [
|
|
48
48
|
"dist",
|
|
49
49
|
"image"
|
|
@@ -53,11 +53,12 @@
|
|
|
53
53
|
"slider",
|
|
54
54
|
"react",
|
|
55
55
|
"timeline",
|
|
56
|
+
"waterfall",
|
|
56
57
|
"audio",
|
|
57
58
|
"video",
|
|
58
59
|
"visualize"
|
|
59
60
|
],
|
|
60
|
-
"license": "
|
|
61
|
+
"license": "MIT",
|
|
61
62
|
"scripts": {
|
|
62
63
|
"build": "vite build",
|
|
63
64
|
"dev": "vite",
|