@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
package/dist/otio.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otio.js","sources":["../src/otio-core/selectors/timeline.ts","../src/otio-core/selectors/track.ts","../src/otio-core/commands/insert.ts","../src/otio-core/commands/move.ts","../src/otio-core/commands/split.ts","../src/otio-core/commands/trim.ts","../src/otio-core/media/clipMetadata.ts","../src/otio-core/media/reference.ts","../src/otio-core/selectors/clip.ts"],"sourcesContent":["import type { RationalTime, Timeline, TimelineItem, Track } from '../types'\n\nexport function toSeconds(time: RationalTime): number {\n return time.rate === 0 ? 0 : time.value / time.rate\n}\n\nexport function getItemDurationSeconds(item: TimelineItem): number {\n return toSeconds(item.source_range.duration)\n}\n\nexport function getTrackDurationSeconds(track: Track): number {\n return track.children.reduce((total, item) => total + getItemDurationSeconds(item), 0)\n}\n\nexport function getTimelineDurationSeconds(timeline: Timeline): number {\n return timeline.tracks.children.reduce((max, track) => Math.max(max, getTrackDurationSeconds(track)), 0)\n}\n","import type { TimelineItem, Track } from '../types'\nimport { isGap } from '../guards'\nimport { getItemDurationSeconds } from './timeline'\n\nexport interface TrackItemOffset {\n item: TimelineItem\n start: number\n end: number\n}\n\nexport function getTrackItemOffsets(track: Track): TrackItemOffset[] {\n let cursor = 0\n\n return track.children.map((item) => {\n const duration = getItemDurationSeconds(item)\n const offset = {\n item,\n start: cursor,\n end: cursor + duration,\n }\n cursor += duration\n return offset\n })\n}\n\nexport function getTrackVisibleItemsAtTime(track: Track, timeSec: number): TrackItemOffset[] {\n return getTrackItemOffsets(track).filter(({ item, start, end }) => !isGap(item) && timeSec >= start && timeSec < end)\n}\n","import type { Clip, Track } from '../types'\nimport { isGap } from '../guards'\nimport { getTrackDurationSeconds } from '../selectors/timeline'\nimport { getTrackItemOffsets } from '../selectors/track'\nimport { cloneTrack, createGapLike, mergeAdjacentGaps } from './helpers'\nimport { createGap } from './create'\n\nexport function insertClipWithGap(track: Track, clip: Clip, atSeconds: number, fps: number): Track {\n const next = cloneTrack(track)\n const clipDurationFrames = clip.source_range.duration.value\n const timelineDurationSeconds = getTrackDurationSeconds(next)\n\n if (atSeconds >= timelineDurationSeconds) {\n const gapSeconds = atSeconds - timelineDurationSeconds\n if (gapSeconds > 0) {\n next.children.push(createGap('Gap', Math.round(gapSeconds * fps), fps))\n }\n next.children.push(clip)\n return {\n ...next,\n children: mergeAdjacentGaps(next.children),\n }\n }\n\n const offsets = getTrackItemOffsets(next)\n const insertionPoint = offsets.find(offset => atSeconds >= offset.start && atSeconds <= offset.end)\n\n if (!insertionPoint) {\n throw new Error('Failed to resolve insertion point')\n }\n\n if (!isGap(insertionPoint.item)) {\n throw new Error('Cannot insert clip into occupied range without explicit ripple command')\n }\n\n const gap = insertionPoint.item\n const gapStartFrames = Math.round((atSeconds - insertionPoint.start) * fps)\n const gapDurationFrames = gap.source_range.duration.value\n const gapEndFrames = gapDurationFrames - gapStartFrames\n\n if (clipDurationFrames > gapEndFrames) {\n throw new Error('Target gap is too small for clip insertion')\n }\n\n const index = next.children.findIndex(item => item.id === gap.id)\n const replacement = []\n\n if (gapStartFrames > 0) {\n replacement.push(createGapLike(gap, gapStartFrames))\n }\n\n replacement.push(clip)\n\n const remainingGapFrames = gapEndFrames - clipDurationFrames\n if (remainingGapFrames > 0) {\n replacement.push(createGapLike(gap, remainingGapFrames))\n }\n\n next.children.splice(index, 1, ...replacement)\n return {\n ...next,\n children: mergeAdjacentGaps(next.children),\n }\n}\n","import type { Clip, Track } from '../types'\nimport { isClip } from '../guards'\nimport { cloneTrack, mergeAdjacentGaps } from './helpers'\nimport { createGap } from './create'\nimport { insertClipWithGap } from './insert'\n\nexport function moveClip(track: Track, clipId: string, targetStartSeconds: number, fps: number): Track {\n const next = cloneTrack(track)\n const index = next.children.findIndex(item => item.id === clipId)\n const item = next.children[index]\n\n if (index === -1 || !item || !isClip(item)) {\n throw new Error(`Clip ${clipId} not found`)\n }\n\n const movedClip: Clip = item\n const sourceGap = createGap(`${item.name} gap`, item.source_range.duration.value, fps)\n next.children.splice(index, 1, sourceGap)\n\n const withMergedGaps = {\n ...next,\n children: mergeAdjacentGaps(next.children),\n }\n\n return insertClipWithGap(withMergedGaps, movedClip, targetStartSeconds, fps)\n}\n","import type { Clip, Track } from '../types'\nimport { isClip } from '../guards'\nimport { cloneTrack, createId } from './helpers'\n\nexport function splitClip(track: Track, clipId: string, splitFrames: number): Track {\n const next = cloneTrack(track)\n const index = next.children.findIndex(item => item.id === clipId)\n const item = next.children[index]\n\n if (index === -1 || !item || !isClip(item)) {\n throw new Error(`Clip ${clipId} not found`)\n }\n\n if (splitFrames <= 0 || splitFrames >= item.source_range.duration.value) {\n throw new Error('Split point must be inside clip duration')\n }\n\n const first: Clip = {\n ...item,\n id: createId('clip'),\n source_range: {\n start_time: { ...item.source_range.start_time },\n duration: {\n ...item.source_range.duration,\n value: splitFrames,\n },\n },\n }\n\n const second: Clip = {\n ...item,\n id: createId('clip'),\n source_range: {\n start_time: {\n ...item.source_range.start_time,\n value: item.source_range.start_time.value + splitFrames,\n },\n duration: {\n ...item.source_range.duration,\n value: item.source_range.duration.value - splitFrames,\n },\n },\n }\n\n next.children.splice(index, 1, first, second)\n return next\n}\n","import type { Clip, Track } from '../types'\nimport { isClip } from '../guards'\nimport { cloneTrack } from './helpers'\n\nfunction getClip(track: Track, clipId: string): Clip {\n const item = track.children.find(child => child.id === clipId)\n if (!item || !isClip(item)) {\n throw new Error(`Clip ${clipId} not found`)\n }\n return item\n}\n\nexport function trimClipStart(track: Track, clipId: string, trimFrames: number): Track {\n const next = cloneTrack(track)\n const clip = getClip(next, clipId)\n\n if (trimFrames <= 0) {\n return next\n }\n\n if (trimFrames >= clip.source_range.duration.value) {\n throw new Error('Trim start exceeds clip duration')\n }\n\n clip.source_range.start_time.value += trimFrames\n clip.source_range.duration.value -= trimFrames\n return next\n}\n\nexport function trimClipEnd(track: Track, clipId: string, trimFrames: number): Track {\n const next = cloneTrack(track)\n const clip = getClip(next, clipId)\n\n if (trimFrames <= 0) {\n return next\n }\n\n if (trimFrames >= clip.source_range.duration.value) {\n throw new Error('Trim end exceeds clip duration')\n }\n\n clip.source_range.duration.value -= trimFrames\n return next\n}\n","export type FlyCutMediaAssetType = 'video' | 'audio' | 'image' | 'gif' | 'svg'\nexport type FlyCutMediaStorage = 'opfs' | 'handle'\n\nconst FLYCUT_MEDIA_ASSET_TYPES: readonly FlyCutMediaAssetType[] = ['video', 'audio', 'image', 'gif', 'svg']\nconst FLYCUT_MEDIA_STORAGES: readonly FlyCutMediaStorage[] = ['opfs', 'handle']\n\nexport interface FlyCutMediaMetadata {\n assetType: FlyCutMediaAssetType\n mediaId: string\n storage: FlyCutMediaStorage\n mimeType: string\n sourceUrl?: string\n sourceDurationSec?: number\n sourceFps?: number\n width?: number\n height?: number\n waveformId?: string\n filmstripId?: string\n thumbnailId?: string\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction readString(value: unknown): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined\n}\n\nfunction readNumber(value: unknown): number | undefined {\n return typeof value === 'number' && Number.isFinite(value) ? value : undefined\n}\n\nfunction isFlyCutMediaAssetType(value: unknown): value is FlyCutMediaAssetType {\n return typeof value === 'string' && FLYCUT_MEDIA_ASSET_TYPES.includes(value as FlyCutMediaAssetType)\n}\n\nfunction isFlyCutMediaStorage(value: unknown): value is FlyCutMediaStorage {\n return typeof value === 'string' && FLYCUT_MEDIA_STORAGES.includes(value as FlyCutMediaStorage)\n}\n\nexport function readFlyCutMediaMetadata(metadata: Record<string, unknown> | undefined): FlyCutMediaMetadata | undefined {\n if (!metadata) {\n return undefined\n }\n\n const flyCut = metadata.flyCut\n if (!isRecord(flyCut)) {\n return undefined\n }\n\n const assetType = isFlyCutMediaAssetType(flyCut.assetType) ? flyCut.assetType : undefined\n const mediaId = readString(flyCut.mediaId)\n const storage = isFlyCutMediaStorage(flyCut.storage) ? flyCut.storage : undefined\n const mimeType = readString(flyCut.mimeType)\n\n if (!assetType || !mediaId || !storage || !mimeType) {\n return undefined\n }\n\n return {\n assetType,\n mediaId,\n storage,\n mimeType,\n sourceUrl: readString(flyCut.sourceUrl),\n sourceDurationSec: readNumber(flyCut.sourceDurationSec),\n sourceFps: readNumber(flyCut.sourceFps),\n width: readNumber(flyCut.width),\n height: readNumber(flyCut.height),\n waveformId: readString(flyCut.waveformId),\n filmstripId: readString(flyCut.filmstripId),\n thumbnailId: readString(flyCut.thumbnailId),\n }\n}\n\nexport function writeFlyCutMediaMetadata(\n metadata: Record<string, unknown> | undefined,\n flyCut: FlyCutMediaMetadata | undefined,\n): Record<string, unknown> | undefined {\n if (!metadata && !flyCut) {\n return undefined\n }\n\n const nextMetadata = { ...(metadata ?? {}) }\n\n if (flyCut) {\n nextMetadata.flyCut = { ...flyCut }\n } else {\n delete nextMetadata.flyCut\n }\n\n return nextMetadata\n}\n","import type { ExternalReference } from '../types'\nimport {\n readFlyCutMediaMetadata as readFlyCutMediaMetadataBag,\n writeFlyCutMediaMetadata as writeFlyCutMediaMetadataBag,\n type FlyCutMediaMetadata,\n} from './clipMetadata'\n\nconst MANAGED_MEDIA_SCHEME = 'flycut-media://'\n\nexport function createManagedExternalReference(mediaId: string): ExternalReference {\n if (mediaId.length === 0) {\n throw new Error('mediaId must not be empty')\n }\n\n return {\n OTIO_SCHEMA: 'ExternalReference.1',\n target_url: `${MANAGED_MEDIA_SCHEME}${mediaId}`,\n }\n}\n\nexport function isManagedExternalReference(reference: Pick<ExternalReference, 'target_url'>): boolean {\n return reference.target_url.startsWith(MANAGED_MEDIA_SCHEME)\n}\n\nexport function getManagedMediaId(reference: Pick<ExternalReference, 'target_url'>): string | undefined {\n if (!isManagedExternalReference(reference)) {\n return undefined\n }\n\n const mediaId = reference.target_url.slice(MANAGED_MEDIA_SCHEME.length)\n return mediaId.length > 0 ? mediaId : undefined\n}\n\nexport function readFlyCutMediaMetadata(metadata: Record<string, unknown> | undefined): FlyCutMediaMetadata | undefined {\n return readFlyCutMediaMetadataBag(metadata)\n}\n\nexport function writeFlyCutMediaMetadata(\n metadata: Record<string, unknown> | undefined,\n flyCut: FlyCutMediaMetadata | undefined,\n): Record<string, unknown> | undefined {\n return writeFlyCutMediaMetadataBag(metadata, flyCut)\n}\n\nexport function readFlyCutMediaMetadataFromReference(reference: ExternalReference): FlyCutMediaMetadata | undefined {\n return readFlyCutMediaMetadata(reference.metadata)\n}\n\nexport function writeFlyCutMediaMetadataToReference(\n reference: ExternalReference,\n flyCut: FlyCutMediaMetadata | undefined,\n): ExternalReference {\n return {\n ...reference,\n metadata: writeFlyCutMediaMetadata(reference.metadata, flyCut),\n }\n}\n","import type { Clip } from '../types'\nimport { toSeconds } from './timeline'\n\nexport function getClipSourceStartSeconds(clip: Clip): number {\n return toSeconds(clip.source_range.start_time)\n}\n\nexport function getClipSourceDurationSeconds(clip: Clip): number {\n return toSeconds(clip.source_range.duration)\n}\n\nexport function getClipSourceEndSeconds(clip: Clip): number {\n return getClipSourceStartSeconds(clip) + getClipSourceDurationSeconds(clip)\n}\n"],"names":["item","readFlyCutMediaMetadata","writeFlyCutMediaMetadata","readFlyCutMediaMetadataBag","writeFlyCutMedia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|
+
* Copyright (c) 2026 timeline-kit authors <x007xyzabc@gmail.com>
|
|
4
|
+
* Dual-licensed: AGPL-3.0-only (see LICENSE) or a commercial license.
|
|
5
|
+
* Commercial licensing: x007xyzabc@gmail.com
|
|
6
|
+
*/
|
|
7
|
+
import { D, c, a, b, d, e, f, g, h, i, p } from "./chunks/index-KK9cAE8q.js";
|
|
8
|
+
import { d as collectSnapPoints, f as findBestSnap, r as pxToMs, s as resolveTargetTrack, p as msToPx } from "./chunks/interactionManager-JoPxZ8st.js";
|
|
9
|
+
import { I, n } from "./chunks/interactionManager-JoPxZ8st.js";
|
|
10
|
+
function createMarqueeSelectPlugin() {
|
|
11
|
+
return {
|
|
12
|
+
name: "plugin:marquee-select",
|
|
13
|
+
interactions: [
|
|
14
|
+
{
|
|
15
|
+
id: "marquee-select",
|
|
16
|
+
priority: 30,
|
|
17
|
+
onPointerDown(event, ctx) {
|
|
18
|
+
if (event.hit.zone !== "track-empty" || event.button !== 0) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const startX = event.hit.x;
|
|
22
|
+
const startY = event.hit.y;
|
|
23
|
+
const startClientX = event.clientX;
|
|
24
|
+
const startClientY = event.clientY;
|
|
25
|
+
let active = false;
|
|
26
|
+
const updateMarqueeSelection = (endX, endY) => {
|
|
27
|
+
const leftPx = Math.min(startX, endX);
|
|
28
|
+
const rightPx = Math.max(startX, endX);
|
|
29
|
+
const topPx = Math.min(startY, endY);
|
|
30
|
+
const bottomPx = Math.max(startY, endY);
|
|
31
|
+
ctx.renderer.setOverlay({
|
|
32
|
+
marqueeRect: {
|
|
33
|
+
leftPx,
|
|
34
|
+
topPx,
|
|
35
|
+
widthPx: Math.max(1, rightPx - leftPx),
|
|
36
|
+
heightPx: Math.max(1, bottomPx - topPx)
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const layout = ctx.renderer.getLayout();
|
|
40
|
+
const selectedIds = [];
|
|
41
|
+
for (const trackLayout of layout.tracks) {
|
|
42
|
+
if (trackLayout.track.locked === true) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (trackLayout.endY < topPx || trackLayout.startY > bottomPx) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
for (const clipLayout of trackLayout.clips) {
|
|
49
|
+
const clipLeft = clipLayout.leftPx;
|
|
50
|
+
const clipRight = clipLeft + Math.max(clipLayout.widthPx, 32);
|
|
51
|
+
if (clipRight >= leftPx && clipLeft <= rightPx) {
|
|
52
|
+
selectedIds.push(clipLayout.clip.id);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
ctx.commands.execute("selection:set", {
|
|
57
|
+
clipIds: selectedIds,
|
|
58
|
+
clipId: selectedIds[0] ?? null
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
onMove(moveEvent) {
|
|
63
|
+
if (!active) {
|
|
64
|
+
const dx = Math.abs(moveEvent.clientX - startClientX);
|
|
65
|
+
const dy = Math.abs(moveEvent.clientY - startClientY);
|
|
66
|
+
if (dx < 4 && dy < 4) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
active = true;
|
|
70
|
+
ctx.renderer.focusContainer?.();
|
|
71
|
+
}
|
|
72
|
+
updateMarqueeSelection(moveEvent.hit.x, moveEvent.hit.y);
|
|
73
|
+
},
|
|
74
|
+
onEnd(endEvent) {
|
|
75
|
+
ctx.renderer.setOverlay({ marqueeRect: null });
|
|
76
|
+
if (!active) {
|
|
77
|
+
ctx.commands.execute("playhead:set", {
|
|
78
|
+
frame: endEvent.hit.frame,
|
|
79
|
+
clampToDuration: true
|
|
80
|
+
});
|
|
81
|
+
ctx.commands.execute("selection:clear");
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
onCancel() {
|
|
85
|
+
ctx.renderer.setOverlay({ marqueeRect: null });
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function createExternalDropPlugin(options) {
|
|
94
|
+
return {
|
|
95
|
+
name: "plugin:external-drop",
|
|
96
|
+
interactions: [
|
|
97
|
+
{
|
|
98
|
+
id: "external-drop",
|
|
99
|
+
priority: 60,
|
|
100
|
+
onDragOver(event, ctx) {
|
|
101
|
+
const item = options.resolveItem(event);
|
|
102
|
+
if (!item) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
event.originalEvent.preventDefault();
|
|
106
|
+
const state = ctx.store.getState();
|
|
107
|
+
const layout = ctx.renderer.getLayout();
|
|
108
|
+
const policies = ctx.getPolicies();
|
|
109
|
+
const durationMs = Math.max(100, item.durationMs);
|
|
110
|
+
let leftPx = Math.max(0, event.hit.x);
|
|
111
|
+
const snapPoints = collectSnapPoints(ctx.getSnapProviders(), {
|
|
112
|
+
layout,
|
|
113
|
+
currentFrame: state.currentFrame,
|
|
114
|
+
excludeClipIds: /* @__PURE__ */ new Set(),
|
|
115
|
+
targetLeftPx: leftPx,
|
|
116
|
+
durationMs
|
|
117
|
+
});
|
|
118
|
+
const snapResult = findBestSnap(leftPx, durationMs, snapPoints, layout.pixelsPerSecond, 10);
|
|
119
|
+
let guidelinePx = null;
|
|
120
|
+
if (snapResult) {
|
|
121
|
+
leftPx = snapResult.leftPx;
|
|
122
|
+
guidelinePx = snapResult.guidelineX;
|
|
123
|
+
}
|
|
124
|
+
const startMs = Math.max(0, Math.round(pxToMs(leftPx, layout.pixelsPerSecond)));
|
|
125
|
+
const draftClip = {
|
|
126
|
+
id: item.id || "external-drop-preview",
|
|
127
|
+
type: item.type,
|
|
128
|
+
name: item.name,
|
|
129
|
+
startMs,
|
|
130
|
+
endMs: startMs + durationMs,
|
|
131
|
+
resource: item.resource,
|
|
132
|
+
durationMs,
|
|
133
|
+
meta: item.meta
|
|
134
|
+
};
|
|
135
|
+
const targetInfo = resolveTargetTrack(
|
|
136
|
+
state.document.tracks,
|
|
137
|
+
layout.tracks,
|
|
138
|
+
event.hit.y,
|
|
139
|
+
draftClip,
|
|
140
|
+
{
|
|
141
|
+
targetStartMs: startMs,
|
|
142
|
+
magnetEnabled: state.isMagnetEnabled,
|
|
143
|
+
policies
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
const widthPx = Math.max(32, msToPx(durationMs, layout.pixelsPerSecond));
|
|
147
|
+
const targetTrack = layout.tracks[targetInfo.insertIndex];
|
|
148
|
+
if (targetInfo.isNewTrack) {
|
|
149
|
+
const insertY = layout.tracks.length === 0 ? 0 : targetInfo.insertIndex <= 0 ? layout.tracks[0].startY - 3 : layout.tracks[Math.min(targetInfo.insertIndex - 1, layout.tracks.length - 1)].endY + 1;
|
|
150
|
+
ctx.renderer.setOverlay({
|
|
151
|
+
verticalGuidelinePx: guidelinePx,
|
|
152
|
+
horizontalGuidelinePx: insertY,
|
|
153
|
+
dragPreview: null
|
|
154
|
+
});
|
|
155
|
+
} else {
|
|
156
|
+
ctx.renderer.setOverlay({
|
|
157
|
+
verticalGuidelinePx: guidelinePx,
|
|
158
|
+
horizontalGuidelinePx: null,
|
|
159
|
+
dragPreview: targetTrack ? {
|
|
160
|
+
leftPx,
|
|
161
|
+
topPx: targetTrack.startY,
|
|
162
|
+
widthPx,
|
|
163
|
+
heightPx: targetTrack.height,
|
|
164
|
+
label: item.name
|
|
165
|
+
} : null
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return true;
|
|
169
|
+
},
|
|
170
|
+
onDragLeave(ctx) {
|
|
171
|
+
ctx.renderer.clearOverlay();
|
|
172
|
+
},
|
|
173
|
+
onDrop(event, ctx) {
|
|
174
|
+
ctx.renderer.clearOverlay();
|
|
175
|
+
const item = options.resolveItem(event);
|
|
176
|
+
if (!item) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
event.originalEvent.preventDefault();
|
|
180
|
+
const state = ctx.store.getState();
|
|
181
|
+
const layout = ctx.renderer.getLayout();
|
|
182
|
+
const policies = ctx.getPolicies();
|
|
183
|
+
const durationMs = Math.max(100, item.durationMs);
|
|
184
|
+
const leftPx = Math.max(0, event.hit.x);
|
|
185
|
+
const snapPoints = collectSnapPoints(ctx.getSnapProviders(), {
|
|
186
|
+
layout,
|
|
187
|
+
currentFrame: state.currentFrame,
|
|
188
|
+
excludeClipIds: /* @__PURE__ */ new Set(),
|
|
189
|
+
targetLeftPx: leftPx,
|
|
190
|
+
durationMs
|
|
191
|
+
});
|
|
192
|
+
const snapResult = findBestSnap(leftPx, durationMs, snapPoints, layout.pixelsPerSecond, 10);
|
|
193
|
+
const startMs = snapResult ? snapResult.startMs : Math.max(0, Math.round(pxToMs(leftPx, layout.pixelsPerSecond)));
|
|
194
|
+
const newClip = {
|
|
195
|
+
id: item.id || `clip-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,
|
|
196
|
+
type: item.type,
|
|
197
|
+
name: item.name,
|
|
198
|
+
startMs,
|
|
199
|
+
endMs: startMs + durationMs,
|
|
200
|
+
resource: item.resource,
|
|
201
|
+
durationMs,
|
|
202
|
+
meta: item.meta
|
|
203
|
+
};
|
|
204
|
+
const targetInfo = resolveTargetTrack(
|
|
205
|
+
state.document.tracks,
|
|
206
|
+
layout.tracks,
|
|
207
|
+
event.hit.y,
|
|
208
|
+
newClip,
|
|
209
|
+
{
|
|
210
|
+
targetStartMs: startMs,
|
|
211
|
+
magnetEnabled: state.isMagnetEnabled,
|
|
212
|
+
policies
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
ctx.commands.execute("clip:insert", {
|
|
216
|
+
trackIndex: targetInfo.insertIndex,
|
|
217
|
+
isNewTrack: targetInfo.isNewTrack,
|
|
218
|
+
clip: newClip
|
|
219
|
+
});
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
export {
|
|
227
|
+
D as DEFAULT_SHORTCUT_KEYMAP,
|
|
228
|
+
I as InteractionManager,
|
|
229
|
+
c as clipEdgeSnapProvider,
|
|
230
|
+
a as createClipDragPlugin,
|
|
231
|
+
b as createClipTrimPlugin,
|
|
232
|
+
d as createDefaultPlugins,
|
|
233
|
+
createExternalDropPlugin,
|
|
234
|
+
e as createGridSnapProvider,
|
|
235
|
+
createMarqueeSelectPlugin,
|
|
236
|
+
f as createPlayheadPlugin,
|
|
237
|
+
g as createSelectionPlugin,
|
|
238
|
+
h as createShortcutsPlugin,
|
|
239
|
+
i as createWheelPlugin,
|
|
240
|
+
n as matchesKeyChord,
|
|
241
|
+
p as playheadSnapProvider
|
|
242
|
+
};
|
|
243
|
+
//# sourceMappingURL=plugins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.js","sources":["../src/plugins/marqueeSelectPlugin.ts","../src/plugins/externalDropPlugin.ts"],"sourcesContent":["import type { TimelinePlugin } from './types'\n\nexport function createMarqueeSelectPlugin(): TimelinePlugin {\n return {\n name: 'plugin:marquee-select',\n interactions: [\n {\n id: 'marquee-select',\n priority: 30,\n onPointerDown(event, ctx) {\n if (event.hit.zone !== 'track-empty' || event.button !== 0) {\n return null\n }\n\n const startX = event.hit.x\n const startY = event.hit.y\n const startClientX = event.clientX\n const startClientY = event.clientY\n let active = false\n\n const updateMarqueeSelection = (endX: number, endY: number) => {\n const leftPx = Math.min(startX, endX)\n const rightPx = Math.max(startX, endX)\n const topPx = Math.min(startY, endY)\n const bottomPx = Math.max(startY, endY)\n\n ctx.renderer.setOverlay({\n marqueeRect: {\n leftPx,\n topPx,\n widthPx: Math.max(1, rightPx - leftPx),\n heightPx: Math.max(1, bottomPx - topPx),\n },\n })\n\n const layout = ctx.renderer.getLayout()\n const selectedIds: string[] = []\n for (const trackLayout of layout.tracks) {\n if (trackLayout.track.locked === true) {\n continue\n }\n if (trackLayout.endY < topPx || trackLayout.startY > bottomPx) {\n continue\n }\n for (const clipLayout of trackLayout.clips) {\n const clipLeft = clipLayout.leftPx\n const clipRight = clipLeft + Math.max(clipLayout.widthPx, 32)\n if (clipRight >= leftPx && clipLeft <= rightPx) {\n selectedIds.push(clipLayout.clip.id)\n }\n }\n }\n\n ctx.commands.execute('selection:set', {\n clipIds: selectedIds,\n clipId: selectedIds[0] ?? null,\n })\n }\n\n return {\n onMove(moveEvent) {\n if (!active) {\n const dx = Math.abs(moveEvent.clientX - startClientX)\n const dy = Math.abs(moveEvent.clientY - startClientY)\n if (dx < 4 && dy < 4) {\n return\n }\n active = true\n ctx.renderer.focusContainer?.()\n }\n updateMarqueeSelection(moveEvent.hit.x, moveEvent.hit.y)\n },\n onEnd(endEvent) {\n ctx.renderer.setOverlay({ marqueeRect: null })\n if (!active) {\n ctx.commands.execute('playhead:set', {\n frame: endEvent.hit.frame,\n clampToDuration: true,\n })\n ctx.commands.execute('selection:clear')\n }\n },\n onCancel() {\n ctx.renderer.setOverlay({ marqueeRect: null })\n },\n }\n },\n },\n ],\n }\n}\n","import { resolveTargetTrack } from '../engine/placement'\nimport { collectSnapPoints, findBestSnap } from '../engine/snap'\nimport { msToPx, pxToMs } from '../engine/timeScale'\nimport type { TimelineClip } from '../model/types'\nimport type { TimelineDropEvent, TimelinePlugin } from './types'\n\nexport interface ExternalDropItem {\n id?: string\n type: string\n name: string\n durationMs: number\n resource?: string\n meta?: Record<string, unknown>\n}\n\nexport interface ExternalDropPluginOptions {\n resolveItem: (event: TimelineDropEvent) => ExternalDropItem | null | undefined\n}\n\nexport function createExternalDropPlugin(options: ExternalDropPluginOptions): TimelinePlugin {\n return {\n name: 'plugin:external-drop',\n interactions: [\n {\n id: 'external-drop',\n priority: 60,\n onDragOver(event, ctx) {\n const item = options.resolveItem(event)\n if (!item) {\n return false\n }\n\n event.originalEvent.preventDefault()\n const state = ctx.store.getState()\n const layout = ctx.renderer.getLayout()\n const policies = ctx.getPolicies()\n const durationMs = Math.max(100, item.durationMs)\n let leftPx = Math.max(0, event.hit.x)\n\n const snapPoints = collectSnapPoints(ctx.getSnapProviders(), {\n layout,\n currentFrame: state.currentFrame,\n excludeClipIds: new Set(),\n targetLeftPx: leftPx,\n durationMs,\n })\n const snapResult = findBestSnap(leftPx, durationMs, snapPoints, layout.pixelsPerSecond, 10)\n let guidelinePx: number | null = null\n if (snapResult) {\n leftPx = snapResult.leftPx\n guidelinePx = snapResult.guidelineX\n }\n\n const startMs = Math.max(0, Math.round(pxToMs(leftPx, layout.pixelsPerSecond)))\n const draftClip: TimelineClip = {\n id: item.id || 'external-drop-preview',\n type: item.type,\n name: item.name,\n startMs,\n endMs: startMs + durationMs,\n resource: item.resource,\n durationMs,\n meta: item.meta,\n }\n\n const targetInfo = resolveTargetTrack(\n state.document.tracks,\n layout.tracks,\n event.hit.y,\n draftClip,\n {\n targetStartMs: startMs,\n magnetEnabled: state.isMagnetEnabled,\n policies,\n },\n )\n\n const widthPx = Math.max(32, msToPx(durationMs, layout.pixelsPerSecond))\n const targetTrack = layout.tracks[targetInfo.insertIndex]\n\n if (targetInfo.isNewTrack) {\n const insertY = layout.tracks.length === 0\n ? 0\n : targetInfo.insertIndex <= 0\n ? layout.tracks[0].startY - 3\n : layout.tracks[Math.min(targetInfo.insertIndex - 1, layout.tracks.length - 1)].endY + 1\n\n ctx.renderer.setOverlay({\n verticalGuidelinePx: guidelinePx,\n horizontalGuidelinePx: insertY,\n dragPreview: null,\n })\n }\n else {\n ctx.renderer.setOverlay({\n verticalGuidelinePx: guidelinePx,\n horizontalGuidelinePx: null,\n dragPreview: targetTrack\n ? {\n leftPx,\n topPx: targetTrack.startY,\n widthPx,\n heightPx: targetTrack.height,\n label: item.name,\n }\n : null,\n })\n }\n\n return true\n },\n onDragLeave(ctx) {\n ctx.renderer.clearOverlay()\n },\n onDrop(event, ctx) {\n ctx.renderer.clearOverlay()\n const item = options.resolveItem(event)\n if (!item) {\n return false\n }\n\n event.originalEvent.preventDefault()\n const state = ctx.store.getState()\n const layout = ctx.renderer.getLayout()\n const policies = ctx.getPolicies()\n const durationMs = Math.max(100, item.durationMs)\n const leftPx = Math.max(0, event.hit.x)\n\n const snapPoints = collectSnapPoints(ctx.getSnapProviders(), {\n layout,\n currentFrame: state.currentFrame,\n excludeClipIds: new Set(),\n targetLeftPx: leftPx,\n durationMs,\n })\n const snapResult = findBestSnap(leftPx, durationMs, snapPoints, layout.pixelsPerSecond, 10)\n const startMs = snapResult\n ? snapResult.startMs\n : Math.max(0, Math.round(pxToMs(leftPx, layout.pixelsPerSecond)))\n\n const newClip: TimelineClip = {\n id: item.id || `clip-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,\n type: item.type,\n name: item.name,\n startMs,\n endMs: startMs + durationMs,\n resource: item.resource,\n durationMs,\n meta: item.meta,\n }\n\n const targetInfo = resolveTargetTrack(\n state.document.tracks,\n layout.tracks,\n event.hit.y,\n newClip,\n {\n targetStartMs: startMs,\n magnetEnabled: state.isMagnetEnabled,\n policies,\n },\n )\n\n ctx.commands.execute('clip:insert', {\n trackIndex: targetInfo.insertIndex,\n isNewTrack: targetInfo.isNewTrack,\n clip: newClip,\n })\n return true\n },\n },\n ],\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAEO,SAAS,4BAA4C;AAC1D,SAAO;AAAA,IACL,MAAM;AAAA,IACN,cAAc;AAAA,MACZ;AAAA,QACE,IAAI;AAAA,QACJ,UAAU;AAAA,QACV,cAAc,OAAO,KAAK;AACxB,cAAI,MAAM,IAAI,SAAS,iBAAiB,MAAM,WAAW,GAAG;AAC1D,mBAAO;AAAA,UACT;AAEA,gBAAM,SAAS,MAAM,IAAI;AACzB,gBAAM,SAAS,MAAM,IAAI;AACzB,gBAAM,eAAe,MAAM;AAC3B,gBAAM,eAAe,MAAM;AAC3B,cAAI,SAAS;AAEb,gBAAM,yBAAyB,CAAC,MAAc,SAAiB;AAC7D,kBAAM,SAAS,KAAK,IAAI,QAAQ,IAAI;AACpC,kBAAM,UAAU,KAAK,IAAI,QAAQ,IAAI;AACrC,kBAAM,QAAQ,KAAK,IAAI,QAAQ,IAAI;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
+
/*!
|
|
2
|
+
* timeline-kit
|
|
3
|
+
* Copyright (c) 2026 timeline-kit authors <x007xyzabc@gmail.com>
|
|
4
|
+
* Dual-licensed: AGPL-3.0-only (see LICENSE) or a commercial license.
|
|
5
|
+
* Commercial licensing: x007xyzabc@gmail.com
|
|
6
|
+
*/
|
|
7
|
+
import { forwardRef, useRef, useState, useMemo, useSyncExternalStore, useImperativeHandle, useEffect, createElement } from "react";
|
|
8
|
+
import { createPortal } from "react-dom";
|
|
9
|
+
import { createSlotBridge } from "./core.js";
|
|
10
|
+
import { T as TimelineEditor$1 } from "./chunks/TimelineEditor-N6_Yud4z.js";
|
|
11
|
+
function useTimelineSelector(editor, selector) {
|
|
12
|
+
const selectorRef = useRef(selector);
|
|
13
|
+
selectorRef.current = selector;
|
|
14
|
+
return useSyncExternalStore(
|
|
15
|
+
(onStoreChange) => {
|
|
16
|
+
if (!editor) {
|
|
17
|
+
return () => {
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return editor.subscribe(() => {
|
|
21
|
+
onStoreChange();
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
() => editor ? selectorRef.current(editor.getState()) : void 0,
|
|
25
|
+
() => editor ? selectorRef.current(editor.getState()) : void 0
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
function mergeBridgeIntoTrackConfigs(trackConfigs, clipSlot, iconSlot) {
|
|
29
|
+
const merged = {};
|
|
30
|
+
if (trackConfigs) {
|
|
31
|
+
for (const [key, config] of Object.entries(trackConfigs)) {
|
|
32
|
+
merged[key] = {
|
|
33
|
+
...config,
|
|
34
|
+
clip: config.clip ?? clipSlot,
|
|
35
|
+
icon: config.icon ?? iconSlot
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
for (const type of ["video", "audio", "image", "text"]) {
|
|
40
|
+
if (!merged[type]) {
|
|
41
|
+
merged[type] = {
|
|
42
|
+
type,
|
|
43
|
+
clip: clipSlot,
|
|
44
|
+
icon: iconSlot
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return merged;
|
|
49
|
+
}
|
|
50
|
+
const TimelineEditor = forwardRef(
|
|
51
|
+
function TimelineEditor2(props, ref) {
|
|
52
|
+
const hostRef = useRef(null);
|
|
53
|
+
const editorRef = useRef(null);
|
|
54
|
+
const [, setEditorInstance] = useState(null);
|
|
55
|
+
const propsRef = useRef(props);
|
|
56
|
+
propsRef.current = props;
|
|
57
|
+
const lastEmittedDocRef = useRef(null);
|
|
58
|
+
const clipBridge = useMemo(
|
|
59
|
+
() => createSlotBridge((ctx) => ctx.clip.id),
|
|
60
|
+
[]
|
|
61
|
+
);
|
|
62
|
+
const iconBridge = useMemo(
|
|
63
|
+
() => createSlotBridge((ctx) => ctx.track.id),
|
|
64
|
+
[]
|
|
65
|
+
);
|
|
66
|
+
const clipEntries = useSyncExternalStore(
|
|
67
|
+
clipBridge.subscribe,
|
|
68
|
+
clipBridge.getEntries,
|
|
69
|
+
clipBridge.getEntries
|
|
70
|
+
);
|
|
71
|
+
const iconEntries = useSyncExternalStore(
|
|
72
|
+
iconBridge.subscribe,
|
|
73
|
+
iconBridge.getEntries,
|
|
74
|
+
iconBridge.getEntries
|
|
75
|
+
);
|
|
76
|
+
const effectiveTrackConfigs = useMemo(
|
|
77
|
+
() => mergeBridgeIntoTrackConfigs(
|
|
78
|
+
props.trackConfigs,
|
|
79
|
+
props.renderClip ? clipBridge.slot : void 0,
|
|
80
|
+
props.renderTrackIcon ? iconBridge.slot : void 0
|
|
81
|
+
),
|
|
82
|
+
[props.trackConfigs, Boolean(props.renderClip), Boolean(props.renderTrackIcon), clipBridge, iconBridge]
|
|
83
|
+
);
|
|
84
|
+
useImperativeHandle(ref, () => ({
|
|
85
|
+
getEditor: () => editorRef.current,
|
|
86
|
+
exec: (command, payload) => editorRef.current?.exec(command, payload) ?? false,
|
|
87
|
+
fitToView: () => editorRef.current?.fitToView() ?? null,
|
|
88
|
+
scrollToTime: (ms) => editorRef.current?.scrollToTime(ms)
|
|
89
|
+
}));
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
const container = hostRef.current;
|
|
92
|
+
if (!container) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const currentProps = propsRef.current;
|
|
96
|
+
const editor = new TimelineEditor$1(container, {
|
|
97
|
+
document: currentProps.document,
|
|
98
|
+
timeline: currentProps.timeline,
|
|
99
|
+
fps: currentProps.fps,
|
|
100
|
+
currentFrame: currentProps.currentFrame,
|
|
101
|
+
trackScale: currentProps.trackScale,
|
|
102
|
+
isMagnetEnabled: currentProps.isMagnetEnabled,
|
|
103
|
+
trackConfigs: effectiveTrackConfigs,
|
|
104
|
+
toolsConfigs: currentProps.toolsConfigs,
|
|
105
|
+
ui: currentProps.ui,
|
|
106
|
+
theme: currentProps.theme,
|
|
107
|
+
injectStyles: currentProps.injectStyles,
|
|
108
|
+
policies: currentProps.policies,
|
|
109
|
+
history: currentProps.history,
|
|
110
|
+
plugins: currentProps.plugins,
|
|
111
|
+
disableDefaultPlugins: currentProps.disableDefaultPlugins,
|
|
112
|
+
shortcuts: currentProps.shortcuts,
|
|
113
|
+
keymap: currentProps.keymap,
|
|
114
|
+
mediaProvider: currentProps.mediaProvider,
|
|
115
|
+
renderHints: currentProps.renderHints,
|
|
116
|
+
onBeforeCommand: (cmd, ctx) => propsRef.current.onBeforeCommand?.(cmd, ctx)
|
|
117
|
+
});
|
|
118
|
+
const onDoc = (e) => {
|
|
119
|
+
const snapshot = e.detail;
|
|
120
|
+
lastEmittedDocRef.current = snapshot.document;
|
|
121
|
+
propsRef.current.onDocumentChange?.(snapshot);
|
|
122
|
+
};
|
|
123
|
+
const onTimeline = (e) => {
|
|
124
|
+
propsRef.current.onTimelineChange?.(e.detail);
|
|
125
|
+
};
|
|
126
|
+
const onSelection = (e) => {
|
|
127
|
+
propsRef.current.onSelectionChange?.(e.detail);
|
|
128
|
+
};
|
|
129
|
+
const onFrame = (e) => {
|
|
130
|
+
propsRef.current.onCurrentFrameChange?.(e.detail);
|
|
131
|
+
};
|
|
132
|
+
const onScale = (e) => {
|
|
133
|
+
propsRef.current.onTrackScaleChange?.(e.detail);
|
|
134
|
+
};
|
|
135
|
+
const onMagnet = (e) => {
|
|
136
|
+
propsRef.current.onMagnetChange?.(e.detail);
|
|
137
|
+
};
|
|
138
|
+
const onCmd = (e) => {
|
|
139
|
+
const detail = e.detail;
|
|
140
|
+
propsRef.current.onCommand?.(detail.command, detail.snapshot);
|
|
141
|
+
};
|
|
142
|
+
editor.addEventListener("documentchange", onDoc);
|
|
143
|
+
editor.addEventListener("timelinechange", onTimeline);
|
|
144
|
+
editor.addEventListener("selectionchange", onSelection);
|
|
145
|
+
editor.addEventListener("currentframechange", onFrame);
|
|
146
|
+
editor.addEventListener("trackscalechange", onScale);
|
|
147
|
+
editor.addEventListener("magnetchange", onMagnet);
|
|
148
|
+
editor.addEventListener("command", onCmd);
|
|
149
|
+
editorRef.current = editor;
|
|
150
|
+
setEditorInstance(editor);
|
|
151
|
+
currentProps.onReady?.(editor);
|
|
152
|
+
return () => {
|
|
153
|
+
editor.removeEventListener("documentchange", onDoc);
|
|
154
|
+
editor.removeEventListener("timelinechange", onTimeline);
|
|
155
|
+
editor.removeEventListener("selectionchange", onSelection);
|
|
156
|
+
editor.removeEventListener("currentframechange", onFrame);
|
|
157
|
+
editor.removeEventListener("trackscalechange", onScale);
|
|
158
|
+
editor.removeEventListener("magnetchange", onMagnet);
|
|
159
|
+
editor.removeEventListener("command", onCmd);
|
|
160
|
+
editor.destroy();
|
|
161
|
+
clipBridge.clear();
|
|
162
|
+
iconBridge.clear();
|
|
163
|
+
editorRef.current = null;
|
|
164
|
+
setEditorInstance(null);
|
|
165
|
+
};
|
|
166
|
+
}, []);
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
const editor = editorRef.current;
|
|
169
|
+
if (!editor || props.document === void 0) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (props.document === lastEmittedDocRef.current) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
editor.setDocument(props.document);
|
|
176
|
+
}, [props.document]);
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
const editor = editorRef.current;
|
|
179
|
+
if (!editor || props.timeline === void 0) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
editor.setTimeline(props.timeline);
|
|
183
|
+
}, [props.timeline]);
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
const editor = editorRef.current;
|
|
186
|
+
if (!editor || props.currentFrame === void 0) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (editor.getCurrentFrame() !== props.currentFrame) {
|
|
190
|
+
editor.setCurrentFrame(props.currentFrame);
|
|
191
|
+
}
|
|
192
|
+
}, [props.currentFrame]);
|
|
193
|
+
useEffect(() => {
|
|
194
|
+
const editor = editorRef.current;
|
|
195
|
+
if (!editor || props.trackScale === void 0) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (editor.getTrackScale() !== props.trackScale) {
|
|
199
|
+
editor.setTrackScale(props.trackScale, props.renderHints);
|
|
200
|
+
}
|
|
201
|
+
}, [props.trackScale]);
|
|
202
|
+
useEffect(() => {
|
|
203
|
+
editorRef.current?.setTrackConfigs(effectiveTrackConfigs);
|
|
204
|
+
}, [effectiveTrackConfigs]);
|
|
205
|
+
useEffect(() => {
|
|
206
|
+
if (props.ui !== void 0) {
|
|
207
|
+
editorRef.current?.setUI(props.ui);
|
|
208
|
+
}
|
|
209
|
+
}, [props.ui]);
|
|
210
|
+
useEffect(() => {
|
|
211
|
+
if (props.theme !== void 0) {
|
|
212
|
+
editorRef.current?.setTheme(props.theme);
|
|
213
|
+
}
|
|
214
|
+
}, [props.theme]);
|
|
215
|
+
useEffect(() => {
|
|
216
|
+
if (props.policies !== void 0) {
|
|
217
|
+
editorRef.current?.setPolicies(props.policies);
|
|
218
|
+
}
|
|
219
|
+
}, [props.policies]);
|
|
220
|
+
useEffect(() => {
|
|
221
|
+
editorRef.current?.setMediaProvider(props.mediaProvider);
|
|
222
|
+
}, [props.mediaProvider]);
|
|
223
|
+
useEffect(() => {
|
|
224
|
+
if (props.renderHints !== void 0) {
|
|
225
|
+
editorRef.current?.setRenderHints(props.renderHints);
|
|
226
|
+
}
|
|
227
|
+
}, [props.renderHints]);
|
|
228
|
+
useEffect(() => {
|
|
229
|
+
if (props.history !== void 0) {
|
|
230
|
+
editorRef.current?.setHistoryMode(props.history);
|
|
231
|
+
}
|
|
232
|
+
}, [props.history]);
|
|
233
|
+
const portals = [];
|
|
234
|
+
if (props.renderClip) {
|
|
235
|
+
for (const entry of clipEntries) {
|
|
236
|
+
portals.push(createPortal(props.renderClip(entry.context), entry.host, `clip:${entry.key}`));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (props.renderTrackIcon) {
|
|
240
|
+
for (const entry of iconEntries) {
|
|
241
|
+
portals.push(createPortal(props.renderTrackIcon(entry.context), entry.host, `icon:${entry.key}`));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return createElement(
|
|
245
|
+
"div",
|
|
246
|
+
{
|
|
247
|
+
ref: hostRef,
|
|
248
|
+
className: props.className,
|
|
249
|
+
style: { width: "100%", height: "100%", ...props.style ?? {} }
|
|
250
|
+
},
|
|
251
|
+
...portals
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
export {
|
|
256
|
+
TimelineEditor,
|
|
257
|
+
useTimelineSelector
|
|
258
|
+
};
|
|
259
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","sources":["../adapters/react/index.ts"],"sourcesContent":["import {\n createElement,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type CSSProperties,\n type ReactNode,\n} from 'react'\nimport { createPortal } from 'react-dom'\nimport type { Timeline as OtioTimeline } from '../../src/otio-core'\nimport {\n TimelineEditor as VanillaTimelineEditor,\n createSlotBridge,\n type BeforeCommandHook,\n type ClipRenderContext,\n type EditPolicies,\n type HistoryMode,\n type KeyBinding,\n type MediaProvider,\n type ThemeMode,\n type TimelineCommand,\n type TimelineDocument,\n type TimelineEditorSnapshot,\n type TimelinePlugin,\n type TimelineRenderHints,\n type TimelineState,\n type ToolbarConfig,\n type TrackConfigMap,\n type TrackHeaderContext,\n type UIConfig,\n} from '../../src/index'\n\nexport interface TimelineEditorProps {\n document?: TimelineDocument\n timeline?: TimelineDocument | OtioTimeline\n fps?: number\n currentFrame?: number\n trackScale?: number\n isMagnetEnabled?: boolean\n trackConfigs?: TrackConfigMap\n toolsConfigs?: ToolbarConfig[]\n ui?: UIConfig\n theme?: ThemeMode\n injectStyles?: boolean\n policies?: Partial<EditPolicies>\n history?: HistoryMode\n plugins?: TimelinePlugin[]\n disableDefaultPlugins?: boolean\n shortcuts?: boolean\n keymap?: Record<string, KeyBinding | null>\n mediaProvider?: MediaProvider\n renderHints?: Partial<TimelineRenderHints>\n className?: string\n style?: CSSProperties\n renderClip?: (ctx: ClipRenderContext) => ReactNode\n renderTrackIcon?: (ctx: TrackHeaderContext) => ReactNode\n onBeforeCommand?: BeforeCommandHook\n onDocumentChange?: (snapshot: TimelineEditorSnapshot) => void\n onTimelineChange?: (snapshot: TimelineEditorSnapshot) => void\n onSelectionChange?: (snapshot: TimelineEditorSnapshot) => void\n onCurrentFrameChange?: (snapshot: TimelineEditorSnapshot) => void\n onTrackScaleChange?: (snapshot: TimelineEditorSnapshot) => void\n onMagnetChange?: (snapshot: TimelineEditorSnapshot) => void\n onCommand?: (command: TimelineCommand, snapshot: TimelineEditorSnapshot) => void\n onReady?: (editor: VanillaTimelineEditor) => void\n}\n\nexport interface TimelineEditorRef {\n getEditor: () => VanillaTimelineEditor | null\n exec: (command: string, payload?: unknown) => boolean\n fitToView: () => number | null\n scrollToTime: (ms: number) => void\n}\n\nexport function useTimelineSelector<TSelected>(\n editor: VanillaTimelineEditor | null | undefined,\n selector: (state: TimelineState) => TSelected,\n): TSelected | undefined {\n const selectorRef = useRef(selector)\n selectorRef.current = selector\n\n return useSyncExternalStore(\n (onStoreChange) => {\n if (!editor) {\n return () => {}\n }\n return editor.subscribe(() => {\n onStoreChange()\n })\n },\n () => (editor ? selectorRef.current(editor.getState()) : undefined),\n () => (editor ? selectorRef.current(editor.getState()) : undefined),\n )\n}\n\nfunction mergeBridgeIntoTrackConfigs(\n trackConfigs: TrackConfigMap | undefined,\n clipSlot: ReturnType<typeof createSlotBridge<ClipRenderContext>>['slot'] | undefined,\n iconSlot: ReturnType<typeof createSlotBridge<TrackHeaderContext>>['slot'] | undefined,\n): TrackConfigMap {\n const merged: TrackConfigMap = {}\n if (trackConfigs) {\n for (const [key, config] of Object.entries(trackConfigs)) {\n merged[key] = {\n ...config,\n clip: config.clip ?? clipSlot,\n icon: config.icon ?? iconSlot,\n }\n }\n }\n\n for (const type of ['video', 'audio', 'image', 'text']) {\n if (!merged[type]) {\n merged[type] = {\n type,\n clip: clipSlot,\n icon: iconSlot,\n }\n }\n }\n\n return merged\n}\n\nexport const TimelineEditor = forwardRef<TimelineEditorRef, TimelineEditorProps>(\n function TimelineEditor(props, ref) {\n const hostRef = useRef<HTMLDivElement | null>(null)\n const editorRef = useRef<VanillaTimelineEditor | null>(null)\n const [, setEditorInstance] = useState<VanillaTimelineEditor | null>(null)\n const propsRef = useRef(props)\n propsRef.current = props\n const lastEmittedDocRef = useRef<TimelineDocument | null>(null)\n\n const clipBridge = useMemo(\n () => createSlotBridge<ClipRenderContext>(ctx => ctx.clip.id),\n [],\n )\n const iconBridge = useMemo(\n () => createSlotBridge<TrackHeaderContext>(ctx => ctx.track.id),\n [],\n )\n\n const clipEntries = useSyncExternalStore(\n clipBridge.subscribe,\n clipBridge.getEntries,\n clipBridge.getEntries,\n )\n const iconEntries = useSyncExternalStore(\n iconBridge.subscribe,\n iconBridge.getEntries,\n iconBridge.getEntries,\n )\n\n const effectiveTrackConfigs = useMemo(\n () => mergeBridgeIntoTrackConfigs(\n props.trackConfigs,\n props.renderClip ? clipBridge.slot : undefined,\n props.renderTrackIcon ? iconBridge.slot : undefined,\n ),\n [props.trackConfigs, Boolean(props.renderClip), Boolean(props.renderTrackIcon), clipBridge, iconBridge],\n )\n\n useImperativeHandle(ref, (): TimelineEditorRef => ({\n getEditor: () => editorRef.current,\n exec: (command: string, payload?: unknown) => editorRef.current?.exec(command, payload) ?? false,\n fitToView: () => editorRef.current?.fitToView() ?? null,\n scrollToTime: (ms: number) => editorRef.current?.scrollToTime(ms),\n }))\n\n useEffect(() => {\n const container = hostRef.current\n if (!container) {\n return\n }\n\n const currentProps = propsRef.current\n const editor = new VanillaTimelineEditor(container, {\n document: currentProps.document,\n timeline: currentProps.timeline,\n fps: currentProps.fps,\n currentFrame: currentProps.currentFrame,\n trackScale: currentProps.trackScale,\n isMagnetEnabled: currentProps.isMagnetEnabled,\n trackConfigs: effectiveTrackConfigs,\n toolsConfigs: currentProps.toolsConfigs,\n ui: currentProps.ui,\n theme: currentProps.theme,\n injectStyles: currentProps.injectStyles,\n policies: currentProps.policies,\n history: currentProps.history,\n plugins: currentProps.plugins,\n disableDefaultPlugins: currentProps.disableDefaultPlugins,\n shortcuts: currentProps.shortcuts,\n keymap: currentProps.keymap,\n mediaProvider: currentProps.mediaProvider,\n renderHints: currentProps.renderHints,\n onBeforeCommand: (cmd, ctx) => propsRef.current.onBeforeCommand?.(cmd, ctx),\n })\n\n const onDoc = (e: Event) => {\n const snapshot = (e as CustomEvent<TimelineEditorSnapshot>).detail\n lastEmittedDocRef.current = snapshot.document\n propsRef.current.onDocumentChange?.(snapshot)\n }\n const onTimeline = (e: Event) => {\n propsRef.current.onTimelineChange?.((e as CustomEvent<TimelineEditorSnapshot>).detail)\n }\n const onSelection = (e: Event) => {\n propsRef.current.onSelectionChange?.((e as CustomEvent<TimelineEditorSnapshot>).detail)\n }\n const onFrame = (e: Event) => {\n propsRef.current.onCurrentFrameChange?.((e as CustomEvent<TimelineEditorSnapshot>).detail)\n }\n const onScale = (e: Event) => {\n propsRef.current.onTrackScaleChange?.((e as CustomEvent<TimelineEditorSnapshot>).detail)\n }\n const onMagnet = (e: Event) => {\n propsRef.current.onMagnetChange?.((e as CustomEvent<TimelineEditorSnapshot>).detail)\n }\n const onCmd = (e: Event) => {\n const detail = (e as CustomEvent<{ command: TimelineCommand, snapshot: TimelineEditorSnapshot }>).detail\n propsRef.current.onCommand?.(detail.command, detail.snapshot)\n }\n\n editor.addEventListener('documentchange', onDoc)\n editor.addEventListener('timelinechange', onTimeline)\n editor.addEventListener('selectionchange', onSelection)\n editor.addEventListener('currentframechange', onFrame)\n editor.addEventListener('trackscalechange', onScale)\n editor.addEventListener('magnetchange', onMagnet)\n editor.addEventListener('command', onCmd)\n\n editorRef.current = editor\n setEditorInstance(editor)\n currentProps.onReady?.(editor)\n\n return () => {\n editor.removeEventListener('documentchange', onDoc)\n editor.removeEventListener('timelinechange', onTimeline)\n editor.removeEventListener('selectionchange', onSelection)\n editor.removeEventListener('currentframechange', onFrame)\n editor.removeEventListener('trackscalechange', onScale)\n editor.removeEventListener('magnetchange', onMagnet)\n editor.removeEventListener('command', onCmd)\n editor.destroy()\n clipBridge.clear()\n iconBridge.clear()\n editorRef.current = null\n setEditorInstance(null)\n }\n }, [])\n\n useEffect(() => {\n const editor = editorRef.current\n if (!editor || props.document === undefined) {\n return\n }\n if (props.document === lastEmittedDocRef.current) {\n return\n }\n editor.setDocument(props.document)\n }, [props.document])\n\n useEffect(() => {\n const editor = editorRef.current\n if (!editor || props.timeline === undefined) {\n return\n }\n editor.setTimeline(props.timeline)\n }, [props.timeline])\n\n useEffect(() => {\n const editor = editorRef.current\n if (!editor || props.currentFrame === undefined) {\n return\n }\n if (editor.getCurrentFrame() !== props.currentFrame) {\n editor.setCurrentFrame(props.currentFrame)\n }\n }, [props.currentFrame])\n\n useEffect(() => {\n const editor = editorRef.current\n if (!editor || props.trackScale === undefined) {\n return\n }\n if (editor.getTrackScale() !== props.trackScale) {\n editor.setTrackScale(props.trackScale, props.renderHints)\n }\n }, [props.trackScale])\n\n useEffect(() => {\n editorRef.current?.setTrackConfigs(effectiveTrackConfigs)\n }, [effectiveTrackConfigs])\n\n useEffect(() => {\n if (props.ui !== undefined) {\n editorRef.current?.setUI(props.ui)\n }\n }, [props.ui])\n\n useEffect(() => {\n if (props.theme !== undefined) {\n editorRef.current?.setTheme(props.theme)\n }\n }, [props.theme])\n\n useEffect(() => {\n if (props.policies !== undefined) {\n editorRef.current?.setPolicies(props.policies)\n }\n }, [props.policies])\n\n useEffect(() => {\n editorRef.current?.setMediaProvider(props.mediaProvider)\n }, [props.mediaProvider])\n\n useEffect(() => {\n if (props.renderHints !== undefined) {\n editorRef.current?.setRenderHints(props.renderHints)\n }\n }, [props.renderHints])\n\n useEffect(() => {\n if (props.history !== undefined) {\n editorRef.current?.setHistoryMode(props.history)\n }\n }, [props.history])\n\n const portals: ReactNode[] = []\n if (props.renderClip) {\n for (const entry of clipEntries) {\n portals.push(createPortal(props.renderClip(entry.context), entry.host, `clip:${entry.key}`))\n }\n }\n if (props.renderTrackIcon) {\n for (const entry of iconEntries) {\n portals.push(createPortal(props.renderTrackIcon(entry.context), entry.host, `icon:${entry.key}`))\n }\n }\n\n return createElement(\n 'div',\n {\n ref: hostRef,\n className: props.className,\n style: { width: '100%', height: '100%', ...(props.style ?? {}) },\n },\n ...portals,\n )\n },\n)\n"],"names":["TimelineEditor","VanillaTimelineEditor"],"mappings":";;;;;;;;;;AA8EO,SAAS,oBACd,QACA,UACuB;AACvB,QAAM,cAAc,OAAO,QAAQ;AACnC,cAAY,UAAU;AAEtB,SAAO;AAAA,IACL,CAAC,kBAAkB;AACjB,UAAI,CAAC,QAAQ;AACX,eAAO,MAAM;AAAA,QAAC;AAAA,MAChB;AACA,aAAO,OAAO,UAAU,MAAM;AAC5B,sBAAA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,MAAO,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AAA;AAAA,EAEP;AACF;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
import type { Timeline as OtioTimeline } from '../../src/otio-core/index.js';
|
|
3
|
+
import { TimelineEditor as VanillaTimelineEditor, type BeforeCommandHook, type ClipRenderContext, type EditPolicies, type HistoryMode, type KeyBinding, type MediaProvider, type ThemeMode, type TimelineCommand, type TimelineDocument, type TimelineEditorSnapshot, type TimelinePlugin, type TimelineRenderHints, type TimelineState, type ToolbarConfig, type TrackConfigMap, type TrackHeaderContext, type UIConfig } from '../../src/index.js';
|
|
4
|
+
export interface TimelineEditorProps {
|
|
5
|
+
document?: TimelineDocument;
|
|
6
|
+
timeline?: TimelineDocument | OtioTimeline;
|
|
7
|
+
fps?: number;
|
|
8
|
+
currentFrame?: number;
|
|
9
|
+
trackScale?: number;
|
|
10
|
+
isMagnetEnabled?: boolean;
|
|
11
|
+
trackConfigs?: TrackConfigMap;
|
|
12
|
+
toolsConfigs?: ToolbarConfig[];
|
|
13
|
+
ui?: UIConfig;
|
|
14
|
+
theme?: ThemeMode;
|
|
15
|
+
injectStyles?: boolean;
|
|
16
|
+
policies?: Partial<EditPolicies>;
|
|
17
|
+
history?: HistoryMode;
|
|
18
|
+
plugins?: TimelinePlugin[];
|
|
19
|
+
disableDefaultPlugins?: boolean;
|
|
20
|
+
shortcuts?: boolean;
|
|
21
|
+
keymap?: Record<string, KeyBinding | null>;
|
|
22
|
+
mediaProvider?: MediaProvider;
|
|
23
|
+
renderHints?: Partial<TimelineRenderHints>;
|
|
24
|
+
className?: string;
|
|
25
|
+
style?: CSSProperties;
|
|
26
|
+
renderClip?: (ctx: ClipRenderContext) => ReactNode;
|
|
27
|
+
renderTrackIcon?: (ctx: TrackHeaderContext) => ReactNode;
|
|
28
|
+
onBeforeCommand?: BeforeCommandHook;
|
|
29
|
+
onDocumentChange?: (snapshot: TimelineEditorSnapshot) => void;
|
|
30
|
+
onTimelineChange?: (snapshot: TimelineEditorSnapshot) => void;
|
|
31
|
+
onSelectionChange?: (snapshot: TimelineEditorSnapshot) => void;
|
|
32
|
+
onCurrentFrameChange?: (snapshot: TimelineEditorSnapshot) => void;
|
|
33
|
+
onTrackScaleChange?: (snapshot: TimelineEditorSnapshot) => void;
|
|
34
|
+
onMagnetChange?: (snapshot: TimelineEditorSnapshot) => void;
|
|
35
|
+
onCommand?: (command: TimelineCommand, snapshot: TimelineEditorSnapshot) => void;
|
|
36
|
+
onReady?: (editor: VanillaTimelineEditor) => void;
|
|
37
|
+
}
|
|
38
|
+
export interface TimelineEditorRef {
|
|
39
|
+
getEditor: () => VanillaTimelineEditor | null;
|
|
40
|
+
exec: (command: string, payload?: unknown) => boolean;
|
|
41
|
+
fitToView: () => number | null;
|
|
42
|
+
scrollToTime: (ms: number) => void;
|
|
43
|
+
}
|
|
44
|
+
export declare function useTimelineSelector<TSelected>(editor: VanillaTimelineEditor | null | undefined, selector: (state: TimelineState) => TSelected): TSelected | undefined;
|
|
45
|
+
export declare const TimelineEditor: import("react").ForwardRefExoticComponent<TimelineEditorProps & import("react").RefAttributes<TimelineEditorRef>>;
|