@flycut/timeline-kit 0.0.0-stage → 0.2.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.
- package/LICENSE +661 -0
- package/README.md +225 -2
- package/dist/chunks/TimelineEditor-N6_Yud4z.js +2046 -0
- package/dist/chunks/TimelineEditor-N6_Yud4z.js.map +1 -0
- package/dist/chunks/index-KK9cAE8q.js +661 -0
- package/dist/chunks/index-KK9cAE8q.js.map +1 -0
- package/dist/chunks/interactionManager-JoPxZ8st.js +775 -0
- package/dist/chunks/interactionManager-JoPxZ8st.js.map +1 -0
- package/dist/chunks/otio-6KO_Tfi1.js +510 -0
- package/dist/chunks/otio-6KO_Tfi1.js.map +1 -0
- package/dist/core.js +1673 -0
- package/dist/core.js.map +1 -0
- package/dist/index.js +100 -0
- package/dist/index.js.map +1 -0
- package/dist/otio.js +313 -0
- package/dist/otio.js.map +1 -0
- package/dist/plugins.js +243 -0
- package/dist/plugins.js.map +1 -0
- package/dist/react.js +259 -0
- package/dist/react.js.map +1 -0
- package/dist/types/adapters/react/index.d.ts +45 -0
- package/dist/types/adapters/vue/index.d.ts +202 -0
- package/dist/types/src/adapters/otio.d.ts +7 -0
- package/dist/types/src/core-entry.d.ts +8 -0
- package/dist/types/src/editor/TimelineEditor.d.ts +96 -0
- package/dist/types/src/editor/index.d.ts +2 -0
- package/dist/types/src/editor/types.d.ts +30 -0
- package/dist/types/src/engine/hitTest.d.ts +23 -0
- package/dist/types/src/engine/index.d.ts +7 -0
- package/dist/types/src/engine/layout.d.ts +47 -0
- package/dist/types/src/engine/magnet.d.ts +46 -0
- package/dist/types/src/engine/placement.d.ts +13 -0
- package/dist/types/src/engine/snap.d.ts +28 -0
- package/dist/types/src/engine/timeScale.d.ts +12 -0
- package/dist/types/src/engine/virtualization.d.ts +11 -0
- package/dist/types/src/frameworks/slotBridge.d.ts +13 -0
- package/dist/types/src/index.d.ts +10 -0
- package/dist/types/src/model/demoDocument.d.ts +3 -0
- package/dist/types/src/model/index.d.ts +4 -0
- package/dist/types/src/model/operations.d.ts +77 -0
- package/dist/types/src/model/structuralSharing.d.ts +11 -0
- package/dist/types/src/model/types.d.ts +55 -0
- package/dist/types/src/otio-core/commands/create.d.ts +6 -0
- package/dist/types/src/otio-core/commands/helpers.d.ts +5 -0
- package/dist/types/src/otio-core/commands/insert.d.ts +2 -0
- package/dist/types/src/otio-core/commands/move.d.ts +2 -0
- package/dist/types/src/otio-core/commands/split.d.ts +2 -0
- package/dist/types/src/otio-core/commands/trim.d.ts +3 -0
- package/dist/types/src/otio-core/flycut-otio-draft.d.ts +239 -0
- package/dist/types/src/otio-core/guards.d.ts +5 -0
- package/dist/types/src/otio-core/index.d.ts +14 -0
- package/dist/types/src/otio-core/media/clipMetadata.d.ts +18 -0
- package/dist/types/src/otio-core/media/reference.d.ts +9 -0
- package/dist/types/src/otio-core/selectors/clip.d.ts +4 -0
- package/dist/types/src/otio-core/selectors/timeline.d.ts +5 -0
- package/dist/types/src/otio-core/selectors/track.d.ts +8 -0
- package/dist/types/src/otio-core/types.d.ts +61 -0
- package/dist/types/src/otio-entry.d.ts +2 -0
- package/dist/types/src/plugins/clipDragPlugin.d.ts +2 -0
- package/dist/types/src/plugins/clipTrimPlugin.d.ts +2 -0
- package/dist/types/src/plugins/externalDropPlugin.d.ts +13 -0
- package/dist/types/src/plugins/index.d.ts +17 -0
- package/dist/types/src/plugins/interactionManager.d.ts +33 -0
- package/dist/types/src/plugins/marqueeSelectPlugin.d.ts +2 -0
- package/dist/types/src/plugins/playheadPlugin.d.ts +2 -0
- package/dist/types/src/plugins/selectionPlugin.d.ts +2 -0
- package/dist/types/src/plugins/shortcutsPlugin.d.ts +7 -0
- package/dist/types/src/plugins/snapProviders.d.ts +9 -0
- package/dist/types/src/plugins/types.d.ts +110 -0
- package/dist/types/src/plugins/wheelPlugin.d.ts +2 -0
- package/dist/types/src/plugins-entry.d.ts +1 -0
- package/dist/types/src/renderer/domRenderer.d.ts +72 -0
- package/dist/types/src/renderer/index.d.ts +6 -0
- package/dist/types/src/renderer/ruler.d.ts +18 -0
- package/dist/types/src/renderer/styles.d.ts +1 -0
- package/dist/types/src/renderer/types.d.ts +65 -0
- package/dist/types/src/renderer/ui/icons.d.ts +7 -0
- package/dist/types/src/renderer/ui/sidebar.d.ts +14 -0
- package/dist/types/src/renderer/ui/toolbar.d.ts +16 -0
- package/dist/types/src/store/builtinCommands.d.ts +56 -0
- package/dist/types/src/store/commandBus.d.ts +18 -0
- package/dist/types/src/store/index.d.ts +4 -0
- package/dist/types/src/store/store.d.ts +53 -0
- package/dist/types/src/store/types.d.ts +59 -0
- package/dist/types/src/utils/trimOffset.d.ts +9 -0
- package/dist/vue.js +278 -0
- package/dist/vue.js.map +1 -0
- package/package.json +111 -4
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { TimelineHitTarget } from '../engine/hitTest.js';
|
|
2
|
+
import type { TimelineLayoutSnapshot } from '../engine/layout.js';
|
|
3
|
+
import type { SnapProvider } from '../engine/snap.js';
|
|
4
|
+
import type { EditPolicies } from '../model/types.js';
|
|
5
|
+
import type { CommandBus } from '../store/commandBus.js';
|
|
6
|
+
import type { TimelineStore } from '../store/store.js';
|
|
7
|
+
import type { CommandSpec } from '../store/types.js';
|
|
8
|
+
export interface DragPreviewBox {
|
|
9
|
+
leftPx: number;
|
|
10
|
+
topPx: number;
|
|
11
|
+
widthPx: number;
|
|
12
|
+
heightPx: number;
|
|
13
|
+
label?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface MarqueeRect {
|
|
16
|
+
leftPx: number;
|
|
17
|
+
topPx: number;
|
|
18
|
+
widthPx: number;
|
|
19
|
+
heightPx: number;
|
|
20
|
+
}
|
|
21
|
+
export interface OverlayState {
|
|
22
|
+
verticalGuidelinePx: number | null;
|
|
23
|
+
horizontalGuidelinePx: number | null;
|
|
24
|
+
dragPreview: DragPreviewBox | null;
|
|
25
|
+
marqueeRect: MarqueeRect | null;
|
|
26
|
+
}
|
|
27
|
+
export interface ClipPreviewOverride {
|
|
28
|
+
leftPx?: number;
|
|
29
|
+
widthPx?: number;
|
|
30
|
+
translateX?: number;
|
|
31
|
+
translateY?: number;
|
|
32
|
+
isDragging?: boolean;
|
|
33
|
+
isTrimming?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface ViewportMetrics {
|
|
36
|
+
scrollLeft: number;
|
|
37
|
+
scrollTop: number;
|
|
38
|
+
clientWidth: number;
|
|
39
|
+
clientHeight: number;
|
|
40
|
+
trackPaddingLeft: number;
|
|
41
|
+
}
|
|
42
|
+
export interface PluginRendererPort {
|
|
43
|
+
getLayout: () => TimelineLayoutSnapshot;
|
|
44
|
+
getViewportMetrics: () => ViewportMetrics;
|
|
45
|
+
setScrollLeft: (scrollLeft: number) => void;
|
|
46
|
+
setOverlay: (patch: Partial<OverlayState>) => void;
|
|
47
|
+
clearOverlay: () => void;
|
|
48
|
+
setClipPreview: (clipId: string, override: ClipPreviewOverride | null) => void;
|
|
49
|
+
clearAllClipPreviews: () => void;
|
|
50
|
+
lockUserSelect?: () => void;
|
|
51
|
+
restoreUserSelect?: () => void;
|
|
52
|
+
focusContainer?: () => void;
|
|
53
|
+
}
|
|
54
|
+
export interface TimelinePointerEvent {
|
|
55
|
+
originalEvent: PointerEvent;
|
|
56
|
+
hit: TimelineHitTarget;
|
|
57
|
+
clientX: number;
|
|
58
|
+
clientY: number;
|
|
59
|
+
shiftKey: boolean;
|
|
60
|
+
ctrlKey: boolean;
|
|
61
|
+
metaKey: boolean;
|
|
62
|
+
altKey: boolean;
|
|
63
|
+
button: number;
|
|
64
|
+
}
|
|
65
|
+
export interface TimelineWheelEvent {
|
|
66
|
+
originalEvent: WheelEvent;
|
|
67
|
+
hit: TimelineHitTarget;
|
|
68
|
+
deltaX: number;
|
|
69
|
+
deltaY: number;
|
|
70
|
+
ctrlKey: boolean;
|
|
71
|
+
metaKey: boolean;
|
|
72
|
+
shiftKey: boolean;
|
|
73
|
+
}
|
|
74
|
+
export interface TimelineDropEvent {
|
|
75
|
+
originalEvent: DragEvent;
|
|
76
|
+
hit: TimelineHitTarget;
|
|
77
|
+
dataTransfer: DataTransfer | null;
|
|
78
|
+
}
|
|
79
|
+
export interface InteractionSession {
|
|
80
|
+
onMove?: (event: TimelinePointerEvent) => void;
|
|
81
|
+
onEnd?: (event: TimelinePointerEvent) => void;
|
|
82
|
+
onCancel?: () => void;
|
|
83
|
+
}
|
|
84
|
+
export interface InteractionHandler {
|
|
85
|
+
id: string;
|
|
86
|
+
priority: number;
|
|
87
|
+
onPointerDown?: (event: TimelinePointerEvent, ctx: PluginContext) => InteractionSession | null | void;
|
|
88
|
+
onWheel?: (event: TimelineWheelEvent, ctx: PluginContext) => boolean | void;
|
|
89
|
+
onDragOver?: (event: TimelineDropEvent, ctx: PluginContext) => boolean | void;
|
|
90
|
+
onDragLeave?: (ctx: PluginContext) => void;
|
|
91
|
+
onDrop?: (event: TimelineDropEvent, ctx: PluginContext) => boolean | void;
|
|
92
|
+
onKeyDown?: (event: KeyboardEvent, ctx: PluginContext) => boolean | void;
|
|
93
|
+
onKeyUp?: (event: KeyboardEvent, ctx: PluginContext) => boolean | void;
|
|
94
|
+
}
|
|
95
|
+
export type KeyBinding = string | ((event: KeyboardEvent, ctx: PluginContext) => boolean | void);
|
|
96
|
+
export interface PluginContext {
|
|
97
|
+
store: TimelineStore;
|
|
98
|
+
commands: CommandBus;
|
|
99
|
+
renderer: PluginRendererPort;
|
|
100
|
+
getPolicies: () => EditPolicies;
|
|
101
|
+
getSnapProviders: () => readonly SnapProvider[];
|
|
102
|
+
}
|
|
103
|
+
export interface TimelinePlugin {
|
|
104
|
+
name: string;
|
|
105
|
+
commands?: Record<string, CommandSpec<any>>;
|
|
106
|
+
keymap?: Record<string, KeyBinding | null>;
|
|
107
|
+
interactions?: InteractionHandler[];
|
|
108
|
+
snapProviders?: SnapProvider[];
|
|
109
|
+
setup?: (ctx: PluginContext) => (() => void) | void;
|
|
110
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './plugins/index.js';
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { TimelineHitTarget } from '../engine/hitTest.js';
|
|
2
|
+
import { type TimelineLayoutSnapshot } from '../engine/layout.js';
|
|
3
|
+
import type { TimelineDocument } from '../model/types.js';
|
|
4
|
+
import type { ClipPreviewOverride, OverlayState, PluginRendererPort, ViewportMetrics } from '../plugins/types.js';
|
|
5
|
+
import type { RenderChannel, ThemeMode, TimelineState } from '../store/types.js';
|
|
6
|
+
import { type MediaProvider, type TrackConfigMap, type UIConfig } from './types.js';
|
|
7
|
+
export interface DomRendererOptions {
|
|
8
|
+
trackConfigs?: TrackConfigMap;
|
|
9
|
+
ui?: UIConfig;
|
|
10
|
+
theme?: ThemeMode;
|
|
11
|
+
injectStyles?: boolean;
|
|
12
|
+
mediaProvider?: MediaProvider;
|
|
13
|
+
/** Accessible name for the timeline root. Overrides `ui.ariaLabel`; default "Timeline". */
|
|
14
|
+
ariaLabel?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class DomTimelineRenderer implements PluginRendererPort {
|
|
17
|
+
private readonly container;
|
|
18
|
+
private readonly refs;
|
|
19
|
+
private readonly toolbarRenderer;
|
|
20
|
+
private readonly sidebarRenderer;
|
|
21
|
+
private readonly mountedClips;
|
|
22
|
+
private readonly clipPreviewOverrides;
|
|
23
|
+
private readonly overlayState;
|
|
24
|
+
private trackConfigs;
|
|
25
|
+
private uiConfig;
|
|
26
|
+
private mediaProvider;
|
|
27
|
+
private layout;
|
|
28
|
+
private lastState;
|
|
29
|
+
private lastVirtualizedScrollLeft;
|
|
30
|
+
private previousUserSelect;
|
|
31
|
+
private readonly ariaLabelOverride;
|
|
32
|
+
private lastAnnouncedSelection;
|
|
33
|
+
constructor(container: HTMLElement, options?: DomRendererOptions);
|
|
34
|
+
getRootElement(): HTMLElement;
|
|
35
|
+
getMainScrollerElement(): HTMLElement;
|
|
36
|
+
setTrackConfigs(trackConfigs: TrackConfigMap): void;
|
|
37
|
+
setUIConfig(uiConfig: UIConfig): void;
|
|
38
|
+
private resolveAriaLabel;
|
|
39
|
+
setMediaProvider(provider: MediaProvider | undefined): void;
|
|
40
|
+
getLayout(): TimelineLayoutSnapshot;
|
|
41
|
+
getViewportMetrics(): ViewportMetrics;
|
|
42
|
+
setScrollLeft(scrollLeft: number): void;
|
|
43
|
+
lockUserSelect(): void;
|
|
44
|
+
restoreUserSelect(): void;
|
|
45
|
+
focusContainer(): void;
|
|
46
|
+
setOverlay(patch: Partial<OverlayState>): void;
|
|
47
|
+
clearOverlay(): void;
|
|
48
|
+
setClipPreview(clipId: string, override: ClipPreviewOverride | null): void;
|
|
49
|
+
clearAllClipPreviews(): void;
|
|
50
|
+
render(state: TimelineState, dirty?: ReadonlySet<RenderChannel>): void;
|
|
51
|
+
handleScroll(): void;
|
|
52
|
+
hitTestClientPoint(clientX: number, clientY: number, target: EventTarget | null, doc: TimelineDocument): TimelineHitTarget;
|
|
53
|
+
destroy(): void;
|
|
54
|
+
private mountDom;
|
|
55
|
+
private resolveIsDark;
|
|
56
|
+
private renderRuler;
|
|
57
|
+
private renderTracks;
|
|
58
|
+
private renderTrackRow;
|
|
59
|
+
private renderClip;
|
|
60
|
+
private renderDefaultClipContent;
|
|
61
|
+
private renderSelectionOnly;
|
|
62
|
+
private positionPlayhead;
|
|
63
|
+
/** Announces the selection through the live region. Called only on the selection channel. */
|
|
64
|
+
private announceSelection;
|
|
65
|
+
private renderOverlay;
|
|
66
|
+
private applyClipPreview;
|
|
67
|
+
private applyPreviewStyleToNode;
|
|
68
|
+
private findLayoutClip;
|
|
69
|
+
private getOrCreateClipRecord;
|
|
70
|
+
private pruneUnmountedClips;
|
|
71
|
+
private renderTrackOverlay;
|
|
72
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export { ensureTimelineStyles } from './styles.js';
|
|
3
|
+
export { drawTimeRuler, type RulerDrawOptions } from './ruler.js';
|
|
4
|
+
export { DEFAULT_TOOLS, ToolbarRenderer } from './ui/toolbar.js';
|
|
5
|
+
export { SidebarRenderer } from './ui/sidebar.js';
|
|
6
|
+
export { DomTimelineRenderer, type DomRendererOptions } from './domRenderer.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface RulerDrawOptions {
|
|
2
|
+
startPx: number;
|
|
3
|
+
fps: number;
|
|
4
|
+
scale: number;
|
|
5
|
+
totalFrames: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
ratio: number;
|
|
9
|
+
palette: {
|
|
10
|
+
bgColor: string;
|
|
11
|
+
longColor: string;
|
|
12
|
+
shortColor: string;
|
|
13
|
+
textColor: string;
|
|
14
|
+
subTextColor: string;
|
|
15
|
+
focusColor: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export declare function drawTimeRuler(context: CanvasRenderingContext2D, options: RulerDrawOptions): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ensureTimelineStyles(enabled?: boolean): void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { TimelineClip, TimelineTrack } from '../model/types.js';
|
|
2
|
+
import type { TimelineRenderHints, TimelineState } from '../store/types.js';
|
|
3
|
+
export interface SlotHandle<TCtx> {
|
|
4
|
+
update?: (ctx: TCtx) => void;
|
|
5
|
+
destroy?: () => void;
|
|
6
|
+
}
|
|
7
|
+
export interface SlotRendererObject<TCtx> {
|
|
8
|
+
mount: (host: HTMLElement, ctx: TCtx) => SlotHandle<TCtx> | void;
|
|
9
|
+
}
|
|
10
|
+
export type SlotRendererFn<TCtx> = (ctx: TCtx) => HTMLElement | string | null | undefined;
|
|
11
|
+
export type SlotRenderer<TCtx> = SlotRendererObject<TCtx> | SlotRendererFn<TCtx>;
|
|
12
|
+
export declare function isSlotRendererObject<TCtx>(slot: SlotRenderer<TCtx>): slot is SlotRendererObject<TCtx>;
|
|
13
|
+
export declare function normalizeSlotRenderer<TCtx>(slot: SlotRenderer<TCtx>): SlotRendererObject<TCtx>;
|
|
14
|
+
export interface ClipRenderContext {
|
|
15
|
+
clip: TimelineClip;
|
|
16
|
+
track: TimelineTrack;
|
|
17
|
+
trackIndex: number;
|
|
18
|
+
clipIndex: number;
|
|
19
|
+
isSelected: boolean;
|
|
20
|
+
renderHints: TimelineRenderHints;
|
|
21
|
+
clipWidthPx: number;
|
|
22
|
+
isVisible: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface TrackHeaderContext {
|
|
25
|
+
track: TimelineTrack;
|
|
26
|
+
trackIndex: number;
|
|
27
|
+
height: number;
|
|
28
|
+
}
|
|
29
|
+
export interface TrackConfig {
|
|
30
|
+
type: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
height?: number;
|
|
33
|
+
icon?: SlotRenderer<TrackHeaderContext>;
|
|
34
|
+
clip?: SlotRenderer<ClipRenderContext>;
|
|
35
|
+
}
|
|
36
|
+
export type TrackConfigMap = Record<string, TrackConfig>;
|
|
37
|
+
export interface ToolbarContext {
|
|
38
|
+
snapshot: TimelineState;
|
|
39
|
+
}
|
|
40
|
+
export interface ToolbarConfig {
|
|
41
|
+
id: string;
|
|
42
|
+
sort: number;
|
|
43
|
+
position: 'left' | 'right';
|
|
44
|
+
label?: string;
|
|
45
|
+
title?: string;
|
|
46
|
+
command?: string;
|
|
47
|
+
isDisabled?: (ctx: ToolbarContext) => boolean;
|
|
48
|
+
isActive?: (ctx: ToolbarContext) => boolean;
|
|
49
|
+
render?: (ctx: ToolbarContext) => HTMLElement | string | null;
|
|
50
|
+
}
|
|
51
|
+
export interface SidebarConfig {
|
|
52
|
+
width?: number;
|
|
53
|
+
showTrackActions?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface UIConfig {
|
|
56
|
+
toolbar?: boolean | ToolbarConfig[];
|
|
57
|
+
sidebar?: boolean | SidebarConfig;
|
|
58
|
+
ruler?: boolean;
|
|
59
|
+
/** Accessible name for the timeline root (default "Timeline"). */
|
|
60
|
+
ariaLabel?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface MediaProvider {
|
|
63
|
+
renderFilmstrip?: (canvas: HTMLCanvasElement, ctx: ClipRenderContext) => (() => void) | void;
|
|
64
|
+
renderWaveform?: (canvas: HTMLCanvasElement, ctx: ClipRenderContext) => (() => void) | void;
|
|
65
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function createSvgIcon(paths: readonly string[], options?: {
|
|
2
|
+
color?: string;
|
|
3
|
+
size?: number;
|
|
4
|
+
}): SVGSVGElement;
|
|
5
|
+
export declare function createTrackTypeIcon(type: string): SVGSVGElement;
|
|
6
|
+
export declare function createTrackActionIcon(command: 'locked' | 'visible' | 'muted', active: boolean): SVGSVGElement;
|
|
7
|
+
export declare function createToolbarIcon(id: string): SVGSVGElement;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TimelineLayoutSnapshot } from '../../engine/layout.js';
|
|
2
|
+
import { type SidebarConfig, type TrackConfigMap } from '../types.js';
|
|
3
|
+
export declare class SidebarRenderer {
|
|
4
|
+
private readonly sidebarEl;
|
|
5
|
+
private readonly headerEl;
|
|
6
|
+
private readonly bodyEl;
|
|
7
|
+
private readonly mountedRows;
|
|
8
|
+
constructor(sidebarEl: HTMLElement, headerEl: HTMLElement, bodyEl: HTMLElement);
|
|
9
|
+
render(layout: TimelineLayoutSnapshot, trackConfigs: TrackConfigMap, sidebarConfig: boolean | SidebarConfig | undefined, showRuler: boolean): void;
|
|
10
|
+
syncScroll(scrollTop: number): void;
|
|
11
|
+
syncHeights(trackRowElements: readonly HTMLElement[]): void;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
private renderTrackActions;
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TimelineState } from '../../store/types.js';
|
|
2
|
+
import type { ToolbarConfig } from '../types.js';
|
|
3
|
+
export declare const DEFAULT_TOOLS: ToolbarConfig[];
|
|
4
|
+
export declare class ToolbarRenderer {
|
|
5
|
+
private readonly host;
|
|
6
|
+
private readonly buttons;
|
|
7
|
+
private slider;
|
|
8
|
+
private lastToolsSignature;
|
|
9
|
+
constructor(host: HTMLElement);
|
|
10
|
+
render(state: TimelineState, customTools: readonly ToolbarConfig[] | boolean | undefined): void;
|
|
11
|
+
destroy(): void;
|
|
12
|
+
private resolveTools;
|
|
13
|
+
private rebuild;
|
|
14
|
+
private updateStates;
|
|
15
|
+
private applyButtonState;
|
|
16
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { TimelineClip } from '../model/types.js';
|
|
2
|
+
import type { CommandBus } from './commandBus.js';
|
|
3
|
+
import type { TimelineRenderHints } from './types.js';
|
|
4
|
+
export interface ClipMovePayload {
|
|
5
|
+
sourceTrackIndex: number;
|
|
6
|
+
sourceClipIndex: number;
|
|
7
|
+
targetTrackIndex: number;
|
|
8
|
+
isNewTrack: boolean;
|
|
9
|
+
startMs: number;
|
|
10
|
+
endMs: number;
|
|
11
|
+
clipType?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ClipMagnetMovePayload {
|
|
14
|
+
sourceTrackIndex: number;
|
|
15
|
+
sourceClipIndex: number;
|
|
16
|
+
targetTrackIndex: number;
|
|
17
|
+
insertPosition: number;
|
|
18
|
+
previewArrangement: TimelineClip[];
|
|
19
|
+
dragClipDurationMs: number;
|
|
20
|
+
}
|
|
21
|
+
export interface ClipTrimPayload {
|
|
22
|
+
trackIndex: number;
|
|
23
|
+
clipIndex: number;
|
|
24
|
+
offsetMs: number;
|
|
25
|
+
edge: 'start' | 'end';
|
|
26
|
+
}
|
|
27
|
+
export interface ClipSplitPayload {
|
|
28
|
+
trackIndex?: number;
|
|
29
|
+
clipIndex?: number;
|
|
30
|
+
splitMs?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface ClipDeletePayload {
|
|
33
|
+
clipIds?: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface ClipInsertPayload {
|
|
36
|
+
trackIndex: number;
|
|
37
|
+
isNewTrack: boolean;
|
|
38
|
+
clip: TimelineClip;
|
|
39
|
+
}
|
|
40
|
+
export interface TrackToggleFlagPayload {
|
|
41
|
+
trackIndex: number;
|
|
42
|
+
flag: 'locked' | 'visible' | 'muted';
|
|
43
|
+
}
|
|
44
|
+
export interface SelectionSetPayload {
|
|
45
|
+
clipIds?: string[];
|
|
46
|
+
clipId?: string | null;
|
|
47
|
+
}
|
|
48
|
+
export interface PlayheadSetPayload {
|
|
49
|
+
frame: number;
|
|
50
|
+
clampToDuration?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface ScaleSetPayload {
|
|
53
|
+
scale: number;
|
|
54
|
+
renderHints?: Partial<TimelineRenderHints>;
|
|
55
|
+
}
|
|
56
|
+
export declare function registerBuiltinCommands(bus: CommandBus): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AfterCommandHook, BeforeCommandHook, CommandContext, CommandSpec } from './types.js';
|
|
2
|
+
export declare class CommandBus {
|
|
3
|
+
private readonly context;
|
|
4
|
+
private readonly commands;
|
|
5
|
+
private readonly aliases;
|
|
6
|
+
private readonly beforeHooks;
|
|
7
|
+
private readonly afterHooks;
|
|
8
|
+
constructor(context: CommandContext);
|
|
9
|
+
register<TPayload = any>(type: string, spec: CommandSpec<TPayload>): () => void;
|
|
10
|
+
unregister(type: string): void;
|
|
11
|
+
registerAlias(alias: string, targetType: string): () => void;
|
|
12
|
+
resolveType(type: string): string;
|
|
13
|
+
has(type: string): boolean;
|
|
14
|
+
addBeforeHook(hook: BeforeCommandHook): () => void;
|
|
15
|
+
addAfterHook(hook: AfterCommandHook): () => void;
|
|
16
|
+
canExecute(type: string, payload?: unknown): boolean;
|
|
17
|
+
execute(type: string, payload?: unknown): boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { TimelineDocument } from '../model/types.js';
|
|
2
|
+
import type { HistoryMode, RenderChannel, ThemeMode, TimelineRenderHints, TimelineState, TimelineStateChange, TimelineStoreLike } from './types.js';
|
|
3
|
+
export interface TimelineStoreOptions {
|
|
4
|
+
document: TimelineDocument;
|
|
5
|
+
currentFrame?: number;
|
|
6
|
+
trackScale?: number;
|
|
7
|
+
isMagnetEnabled?: boolean;
|
|
8
|
+
renderHints?: Partial<TimelineRenderHints>;
|
|
9
|
+
theme?: ThemeMode;
|
|
10
|
+
historyMode?: HistoryMode;
|
|
11
|
+
maxHistory?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class TimelineStore implements TimelineStoreLike {
|
|
14
|
+
private state;
|
|
15
|
+
private historyMode;
|
|
16
|
+
private readonly maxHistory;
|
|
17
|
+
private historyPast;
|
|
18
|
+
private historyFuture;
|
|
19
|
+
private externalCanUndo;
|
|
20
|
+
private externalCanRedo;
|
|
21
|
+
private readonly listeners;
|
|
22
|
+
constructor(options: TimelineStoreOptions);
|
|
23
|
+
getState(): TimelineState;
|
|
24
|
+
getSnapshot(): TimelineState;
|
|
25
|
+
getHistoryMode(): HistoryMode;
|
|
26
|
+
setHistoryMode(mode: HistoryMode): void;
|
|
27
|
+
setExternalHistoryState(flags: {
|
|
28
|
+
canUndo?: boolean;
|
|
29
|
+
canRedo?: boolean;
|
|
30
|
+
}): void;
|
|
31
|
+
setDocument(doc: TimelineDocument, options?: {
|
|
32
|
+
pushHistory?: boolean;
|
|
33
|
+
dirty?: readonly RenderChannel[];
|
|
34
|
+
selectionClipIds?: readonly string[];
|
|
35
|
+
primaryClipId?: string | null;
|
|
36
|
+
}): boolean;
|
|
37
|
+
setCurrentFrame(frame: number): boolean;
|
|
38
|
+
setTrackScale(scale: number, renderHints?: Partial<TimelineRenderHints>): boolean;
|
|
39
|
+
setRenderHints(hints: Partial<TimelineRenderHints>): boolean;
|
|
40
|
+
setTheme(theme: ThemeMode): boolean;
|
|
41
|
+
setMagnetEnabled(enabled: boolean): boolean;
|
|
42
|
+
toggleMagnetEnabled(): boolean;
|
|
43
|
+
setSelection(clipIds: readonly string[], primaryClipId?: string | null): boolean;
|
|
44
|
+
clearSelection(): boolean;
|
|
45
|
+
undo(): boolean;
|
|
46
|
+
redo(): boolean;
|
|
47
|
+
subscribe(listener: (change: TimelineStateChange) => void): () => void;
|
|
48
|
+
subscribeSelector<TSelected>(selector: (state: TimelineState) => TSelected, listener: (selected: TSelected, prevSelected: TSelected) => void, isEqual?: (a: TSelected, b: TSelected) => boolean): () => void;
|
|
49
|
+
private computeCanUndo;
|
|
50
|
+
private computeCanRedo;
|
|
51
|
+
private pushHistorySnapshot;
|
|
52
|
+
private commitState;
|
|
53
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { EditPolicies, TimelineDocument, TimelineSelection } from '../model/types.js';
|
|
2
|
+
export type RenderChannel = 'toolbar' | 'sidebar' | 'ruler' | 'tracks' | 'selection' | 'playhead' | 'overlay';
|
|
3
|
+
export interface TimelineRenderHints {
|
|
4
|
+
zoomActive: boolean;
|
|
5
|
+
settleVersion: number;
|
|
6
|
+
}
|
|
7
|
+
export type ThemeMode = 'light' | 'dark' | 'auto';
|
|
8
|
+
export type HistoryMode = 'internal' | 'external';
|
|
9
|
+
export interface TimelineState {
|
|
10
|
+
document: TimelineDocument;
|
|
11
|
+
currentFrame: number;
|
|
12
|
+
trackScale: number;
|
|
13
|
+
isMagnetEnabled: boolean;
|
|
14
|
+
selection: TimelineSelection;
|
|
15
|
+
canUndo: boolean;
|
|
16
|
+
canRedo: boolean;
|
|
17
|
+
renderHints: TimelineRenderHints;
|
|
18
|
+
theme: ThemeMode;
|
|
19
|
+
}
|
|
20
|
+
export interface TimelineStateChange {
|
|
21
|
+
state: TimelineState;
|
|
22
|
+
prevState: TimelineState;
|
|
23
|
+
dirty: ReadonlySet<RenderChannel>;
|
|
24
|
+
}
|
|
25
|
+
export interface TimelineCommand<TPayload = unknown> {
|
|
26
|
+
type: string;
|
|
27
|
+
payload?: TPayload;
|
|
28
|
+
}
|
|
29
|
+
export interface TimelineStoreLike {
|
|
30
|
+
getState: () => TimelineState;
|
|
31
|
+
getSnapshot: () => TimelineState;
|
|
32
|
+
setDocument: (doc: TimelineDocument, options?: {
|
|
33
|
+
pushHistory?: boolean;
|
|
34
|
+
dirty?: readonly RenderChannel[];
|
|
35
|
+
selectionClipIds?: readonly string[];
|
|
36
|
+
primaryClipId?: string | null;
|
|
37
|
+
}) => boolean;
|
|
38
|
+
setCurrentFrame: (frame: number) => boolean;
|
|
39
|
+
setTrackScale: (scale: number, renderHints?: Partial<TimelineRenderHints>) => boolean;
|
|
40
|
+
setRenderHints: (hints: Partial<TimelineRenderHints>) => boolean;
|
|
41
|
+
setTheme: (theme: ThemeMode) => boolean;
|
|
42
|
+
setMagnetEnabled: (enabled: boolean) => boolean;
|
|
43
|
+
toggleMagnetEnabled: () => boolean;
|
|
44
|
+
setSelection: (clipIds: readonly string[], primaryClipId?: string | null) => boolean;
|
|
45
|
+
clearSelection: () => boolean;
|
|
46
|
+
undo: () => boolean;
|
|
47
|
+
redo: () => boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface CommandContext {
|
|
50
|
+
store: TimelineStoreLike;
|
|
51
|
+
getPolicies: () => EditPolicies;
|
|
52
|
+
fitToView?: () => number | null;
|
|
53
|
+
}
|
|
54
|
+
export interface CommandSpec<TPayload = any> {
|
|
55
|
+
canExecute?: (ctx: CommandContext, payload: TPayload) => boolean;
|
|
56
|
+
execute: (ctx: CommandContext, payload: TPayload) => boolean | void;
|
|
57
|
+
}
|
|
58
|
+
export type BeforeCommandHook = (command: TimelineCommand, ctx: CommandContext) => boolean | TimelineCommand | void;
|
|
59
|
+
export type AfterCommandHook = (command: TimelineCommand, executed: boolean, ctx: CommandContext) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute normalized trim start offset percentage and visible window scale percentage.
|
|
3
|
+
* Supports TimelineClip (`trim` + `durationMs`), legacy clips (`trimInfo` + `resourceInfo`),
|
|
4
|
+
* and OTIO `Clip.1` items.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getTrimOffset(input: unknown): {
|
|
7
|
+
offsetPercent: number;
|
|
8
|
+
scalePercent: number;
|
|
9
|
+
};
|