@twick/video-editor 0.14.4 → 0.14.5
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/dist/components/player/player-manager.d.ts +4 -1
- package/dist/components/timeline/timeline-manager.d.ts +1 -2
- package/dist/components/timeline/timeline-view.d.ts +0 -1
- package/dist/components/video-editor.d.ts +5 -2
- package/dist/index.js +15 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
export declare const PlayerManager: ({ videoProps, canvasMode, }: {
|
|
2
|
+
export declare const PlayerManager: ({ videoProps, playerProps, canvasMode, }: {
|
|
3
3
|
videoProps: {
|
|
4
4
|
width: number;
|
|
5
5
|
height: number;
|
|
6
6
|
backgroundColor?: string;
|
|
7
7
|
};
|
|
8
|
+
playerProps?: {
|
|
9
|
+
quality?: number;
|
|
10
|
+
};
|
|
8
11
|
canvasMode: boolean;
|
|
9
12
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Track, TrackElement } from '@twick/timeline';
|
|
2
2
|
|
|
3
3
|
declare function TimelineView({ zoomLevel, selectedItem, duration, tracks, seekTrack, onAddTrack, onReorder, onSelectionChange, onElementDrag, }: {
|
|
4
|
-
timelineControls?: React.ReactNode;
|
|
5
4
|
zoomLevel: number;
|
|
6
5
|
duration: number;
|
|
7
6
|
tracks: Track[];
|
|
@@ -22,6 +22,11 @@ export interface VideoEditorConfig {
|
|
|
22
22
|
/** Background color of the video */
|
|
23
23
|
backgroundColor?: string;
|
|
24
24
|
};
|
|
25
|
+
playerProps?: {
|
|
26
|
+
quality?: number;
|
|
27
|
+
maxWidth?: number;
|
|
28
|
+
maxHeight?: number;
|
|
29
|
+
};
|
|
25
30
|
/** Whether to use canvas mode for rendering */
|
|
26
31
|
canvasMode?: boolean;
|
|
27
32
|
}
|
|
@@ -50,8 +55,6 @@ export interface VideoEditorProps {
|
|
|
50
55
|
rightPanel?: React.ReactNode;
|
|
51
56
|
/** Custom bottom panel component (e.g., effects library) */
|
|
52
57
|
bottomPanel?: React.ReactNode;
|
|
53
|
-
/** Custom play controls component */
|
|
54
|
-
playControls?: React.ReactNode;
|
|
55
58
|
/** Whether to show default play controls if no custom controls provided */
|
|
56
59
|
defaultPlayControls?: boolean;
|
|
57
60
|
/** Editor configuration including video properties and mode settings */
|
package/dist/index.js
CHANGED
|
@@ -6958,8 +6958,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6958
6958
|
};
|
|
6959
6959
|
const convertToVideoPosition = (x2, y2, canvasMetadata, videoSize) => {
|
|
6960
6960
|
return {
|
|
6961
|
-
x: x2 / canvasMetadata.scaleX - videoSize.width / 2,
|
|
6962
|
-
y: y2 / canvasMetadata.scaleY - videoSize.height / 2
|
|
6961
|
+
x: Number((x2 / canvasMetadata.scaleX - videoSize.width / 2).toFixed(2)),
|
|
6962
|
+
y: Number((y2 / canvasMetadata.scaleY - videoSize.height / 2).toFixed(2))
|
|
6963
6963
|
};
|
|
6964
6964
|
};
|
|
6965
6965
|
const getCurrentFrameEffect = (item, seekTime) => {
|
|
@@ -6994,7 +6994,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6994
6994
|
ctx.save();
|
|
6995
6995
|
ctx.translate(left, top);
|
|
6996
6996
|
ctx.fillStyle = "#red";
|
|
6997
|
-
ctx.fillRect(-
|
|
6997
|
+
ctx.fillRect(-size / 2, -size / 2, size, size);
|
|
6998
6998
|
ctx.restore();
|
|
6999
6999
|
}
|
|
7000
7000
|
});
|
|
@@ -7837,7 +7837,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7837
7837
|
videoProps
|
|
7838
7838
|
}) => {
|
|
7839
7839
|
const [projectData, setProjectData] = React.useState(null);
|
|
7840
|
-
const { timelineAction, setTimelineAction, setSelectedItem, editor } = timeline.useTimelineContext();
|
|
7840
|
+
const { timelineAction, setTimelineAction, setSelectedItem, editor, changeLog } = timeline.useTimelineContext();
|
|
7841
|
+
const currentChangeLog = React.useRef(changeLog);
|
|
7841
7842
|
const [playerUpdating, setPlayerUpdating] = React.useState(false);
|
|
7842
7843
|
const handleCanvasReady = (canvas) => {
|
|
7843
7844
|
console.log("canvas ready", canvas);
|
|
@@ -7851,6 +7852,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7851
7852
|
case CANVAS_OPERATIONS.ITEM_UPDATED:
|
|
7852
7853
|
if (element) {
|
|
7853
7854
|
const updatedElement = editor.updateElement(element);
|
|
7855
|
+
currentChangeLog.current = currentChangeLog.current + 1;
|
|
7854
7856
|
setSelectedItem(updatedElement);
|
|
7855
7857
|
}
|
|
7856
7858
|
break;
|
|
@@ -7862,6 +7864,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7862
7864
|
});
|
|
7863
7865
|
const updateCanvas = (seekTime) => {
|
|
7864
7866
|
var _a2;
|
|
7867
|
+
if (changeLog === currentChangeLog.current) {
|
|
7868
|
+
return;
|
|
7869
|
+
}
|
|
7865
7870
|
const elements = timeline.getCurrentElements(
|
|
7866
7871
|
seekTime,
|
|
7867
7872
|
((_a2 = editor.getTimelineData()) == null ? void 0 : _a2.tracks) ?? []
|
|
@@ -7872,6 +7877,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7872
7877
|
captionProps: {},
|
|
7873
7878
|
cleanAndAdd: true
|
|
7874
7879
|
});
|
|
7880
|
+
currentChangeLog.current = changeLog;
|
|
7875
7881
|
};
|
|
7876
7882
|
const onPlayerUpdate = (event) => {
|
|
7877
7883
|
var _a2;
|
|
@@ -7913,6 +7919,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7913
7919
|
};
|
|
7914
7920
|
const PlayerManager = ({
|
|
7915
7921
|
videoProps,
|
|
7922
|
+
playerProps,
|
|
7916
7923
|
canvasMode
|
|
7917
7924
|
}) => {
|
|
7918
7925
|
const { changeLog } = timeline.useTimelineContext();
|
|
@@ -7979,6 +7986,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7979
7986
|
{
|
|
7980
7987
|
seekTime,
|
|
7981
7988
|
projectData,
|
|
7989
|
+
quality: playerProps == null ? void 0 : playerProps.quality,
|
|
7982
7990
|
videoSize: {
|
|
7983
7991
|
width: videoProps.width,
|
|
7984
7992
|
height: videoProps.height
|
|
@@ -12548,7 +12556,7 @@ This message will only show in development mode. It won't appear in production.
|
|
|
12548
12556
|
envelope = (undampedFreq2) => {
|
|
12549
12557
|
const a2 = Math.exp(-undampedFreq2 * duration);
|
|
12550
12558
|
const b2 = (undampedFreq2 - velocity) * duration + 1;
|
|
12551
|
-
return -
|
|
12559
|
+
return -safeMin + a2 * b2;
|
|
12552
12560
|
};
|
|
12553
12561
|
derivative = (undampedFreq2) => {
|
|
12554
12562
|
const a2 = Math.exp(-undampedFreq2 * duration);
|
|
@@ -17416,7 +17424,6 @@ This message will only show in development mode. It won't appear in production.
|
|
|
17416
17424
|
};
|
|
17417
17425
|
};
|
|
17418
17426
|
const TimelineManager = ({
|
|
17419
|
-
timelineControls,
|
|
17420
17427
|
trackZoom
|
|
17421
17428
|
}) => {
|
|
17422
17429
|
var _a2;
|
|
@@ -17424,7 +17431,6 @@ This message will only show in development mode. It won't appear in production.
|
|
|
17424
17431
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
17425
17432
|
TimelineView,
|
|
17426
17433
|
{
|
|
17427
|
-
timelineControls,
|
|
17428
17434
|
tracks: (timelineData == null ? void 0 : timelineData.tracks) ?? [],
|
|
17429
17435
|
zoomLevel: trackZoom,
|
|
17430
17436
|
duration: totalDuration,
|
|
@@ -17675,7 +17681,6 @@ This message will only show in development mode. It won't appear in production.
|
|
|
17675
17681
|
rightPanel,
|
|
17676
17682
|
bottomPanel,
|
|
17677
17683
|
editorConfig,
|
|
17678
|
-
playControls,
|
|
17679
17684
|
defaultPlayControls = true
|
|
17680
17685
|
}) => {
|
|
17681
17686
|
const [trackZoom, setTrackZoom] = React.useState(DEFAULT_TIMELINE_ZOOM);
|
|
@@ -17684,6 +17689,7 @@ This message will only show in development mode. It won't appear in production.
|
|
|
17684
17689
|
PlayerManager,
|
|
17685
17690
|
{
|
|
17686
17691
|
videoProps: editorConfig.videoProps,
|
|
17692
|
+
playerProps: editorConfig.playerProps,
|
|
17687
17693
|
canvasMode: editorConfig.canvasMode ?? true
|
|
17688
17694
|
}
|
|
17689
17695
|
),
|
|
@@ -17697,7 +17703,7 @@ This message will only show in development mode. It won't appear in production.
|
|
|
17697
17703
|
] }),
|
|
17698
17704
|
bottomPanel ? bottomPanel : null,
|
|
17699
17705
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twick-editor-timeline-section", children: [
|
|
17700
|
-
|
|
17706
|
+
defaultPlayControls ? /* @__PURE__ */ jsxRuntime.jsx(ControlManager, { trackZoom, setTrackZoom }) : null,
|
|
17701
17707
|
/* @__PURE__ */ jsxRuntime.jsx(TimelineManager, { trackZoom })
|
|
17702
17708
|
] })
|
|
17703
17709
|
] });
|