@twick/studio 0.15.15 → 0.15.16
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/container/properties-panel-container.d.ts +2 -1
- package/dist/components/properties/generate-captions.d.ts +2 -1
- package/dist/hooks/use-generate-captions.d.ts +1 -0
- package/dist/index.js +22 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -8
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/package.json +12 -12
|
@@ -7,7 +7,8 @@ interface PropertiesPanelContainerProps {
|
|
|
7
7
|
addCaptionsToTimeline: (captions: CaptionEntry[]) => void;
|
|
8
8
|
onGenerateCaptions: (videoElement: VideoElement) => Promise<string | null>;
|
|
9
9
|
getCaptionstatus: (reqId: string) => Promise<ICaptionGenerationPollingResponse>;
|
|
10
|
+
pollingIntervalMs: number;
|
|
10
11
|
videoResolution: Size;
|
|
11
12
|
}
|
|
12
|
-
export declare function PropertiesPanelContainer({ selectedElement, updateElement, addCaptionsToTimeline, onGenerateCaptions, getCaptionstatus, videoResolution, }: PropertiesPanelContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function PropertiesPanelContainer({ selectedElement, updateElement, addCaptionsToTimeline, onGenerateCaptions, getCaptionstatus, pollingIntervalMs, videoResolution, }: PropertiesPanelContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TrackElement, VideoElement } from '@twick/timeline';
|
|
2
2
|
import { ICaptionGenerationPollingResponse } from '../../types';
|
|
3
3
|
|
|
4
|
-
export declare function GenerateCaptionsPanel({ selectedElement, addCaptionsToTimeline, onGenerateCaptions, getCaptionstatus, }: {
|
|
4
|
+
export declare function GenerateCaptionsPanel({ selectedElement, addCaptionsToTimeline, onGenerateCaptions, getCaptionstatus, pollingIntervalMs, }: {
|
|
5
5
|
selectedElement: TrackElement;
|
|
6
6
|
addCaptionsToTimeline: (captions: {
|
|
7
7
|
s: number;
|
|
@@ -10,4 +10,5 @@ export declare function GenerateCaptionsPanel({ selectedElement, addCaptionsToTi
|
|
|
10
10
|
}[]) => void;
|
|
11
11
|
onGenerateCaptions: (videoElement: VideoElement) => Promise<string | null>;
|
|
12
12
|
getCaptionstatus: (reqId: string) => Promise<ICaptionGenerationPollingResponse>;
|
|
13
|
+
pollingIntervalMs?: number;
|
|
13
14
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,5 +5,6 @@ declare const useGenerateCaptions: (studioConfig?: StudioConfig) => {
|
|
|
5
5
|
onGenerateCaptions: (videoElement: VideoElement) => Promise<string | null>;
|
|
6
6
|
addCaptionsToTimeline: (captions: CaptionEntry[]) => void;
|
|
7
7
|
getCaptionstatus: (reqId: string) => Promise<ICaptionGenerationPollingResponse>;
|
|
8
|
+
pollingIntervalMs: number;
|
|
8
9
|
};
|
|
9
10
|
export default useGenerateCaptions;
|
package/dist/index.js
CHANGED
|
@@ -3400,7 +3400,8 @@ function GenerateCaptionsPanel({
|
|
|
3400
3400
|
selectedElement,
|
|
3401
3401
|
addCaptionsToTimeline,
|
|
3402
3402
|
onGenerateCaptions,
|
|
3403
|
-
getCaptionstatus
|
|
3403
|
+
getCaptionstatus,
|
|
3404
|
+
pollingIntervalMs = 5e3
|
|
3404
3405
|
}) {
|
|
3405
3406
|
const [containsAudio, setContainsAudio] = react.useState(null);
|
|
3406
3407
|
const [isLoading, setIsLoading] = react.useState(true);
|
|
@@ -3457,12 +3458,14 @@ function GenerateCaptionsPanel({
|
|
|
3457
3458
|
}
|
|
3458
3459
|
};
|
|
3459
3460
|
await poll();
|
|
3460
|
-
pollingIntervalRef.current = setInterval(poll,
|
|
3461
|
+
pollingIntervalRef.current = setInterval(poll, pollingIntervalMs);
|
|
3461
3462
|
};
|
|
3462
3463
|
const handleGenerateCaptions = async () => {
|
|
3463
3464
|
if (!(selectedElement instanceof timeline.VideoElement)) {
|
|
3464
3465
|
return;
|
|
3465
3466
|
}
|
|
3467
|
+
setIsGenerating(true);
|
|
3468
|
+
setPollingStatus("polling");
|
|
3466
3469
|
const videoElement = selectedElement;
|
|
3467
3470
|
try {
|
|
3468
3471
|
const reqId = await onGenerateCaptions(videoElement);
|
|
@@ -3669,6 +3672,7 @@ function PropertiesPanelContainer({
|
|
|
3669
3672
|
addCaptionsToTimeline,
|
|
3670
3673
|
onGenerateCaptions,
|
|
3671
3674
|
getCaptionstatus,
|
|
3675
|
+
pollingIntervalMs,
|
|
3672
3676
|
videoResolution
|
|
3673
3677
|
}) {
|
|
3674
3678
|
const title = selectedElement instanceof timeline.TextElement ? selectedElement.getText() : (selectedElement == null ? void 0 : selectedElement.getName()) || (selectedElement == null ? void 0 : selectedElement.getType()) || "Element";
|
|
@@ -3736,7 +3740,8 @@ function PropertiesPanelContainer({
|
|
|
3736
3740
|
selectedElement,
|
|
3737
3741
|
addCaptionsToTimeline,
|
|
3738
3742
|
onGenerateCaptions,
|
|
3739
|
-
getCaptionstatus
|
|
3743
|
+
getCaptionstatus,
|
|
3744
|
+
pollingIntervalMs
|
|
3740
3745
|
}
|
|
3741
3746
|
)
|
|
3742
3747
|
] });
|
|
@@ -3858,7 +3863,12 @@ function TwickStudio({ studioConfig }) {
|
|
|
3858
3863
|
onSaveProject,
|
|
3859
3864
|
onExportVideo
|
|
3860
3865
|
} = useStudioOperation(studioConfig);
|
|
3861
|
-
const {
|
|
3866
|
+
const {
|
|
3867
|
+
onGenerateCaptions,
|
|
3868
|
+
addCaptionsToTimeline,
|
|
3869
|
+
getCaptionstatus,
|
|
3870
|
+
pollingIntervalMs
|
|
3871
|
+
} = useGenerateCaptions(studioConfig);
|
|
3862
3872
|
const twickStudiConfig = react.useMemo(
|
|
3863
3873
|
() => ({
|
|
3864
3874
|
canvasMode: true,
|
|
@@ -3906,7 +3916,7 @@ function TwickStudio({ studioConfig }) {
|
|
|
3906
3916
|
{
|
|
3907
3917
|
className: "canvas-container",
|
|
3908
3918
|
style: {
|
|
3909
|
-
maxWidth: ((_a = twickStudiConfig.playerProps) == null ? void 0 : _a.maxWidth) ??
|
|
3919
|
+
maxWidth: ((_a = twickStudiConfig.playerProps) == null ? void 0 : _a.maxWidth) ?? "100%"
|
|
3910
3920
|
},
|
|
3911
3921
|
children: /* @__PURE__ */ jsxRuntime.jsx(VideoEditor, { editorConfig: twickStudiConfig })
|
|
3912
3922
|
}
|
|
@@ -3919,6 +3929,7 @@ function TwickStudio({ studioConfig }) {
|
|
|
3919
3929
|
addCaptionsToTimeline,
|
|
3920
3930
|
onGenerateCaptions,
|
|
3921
3931
|
getCaptionstatus,
|
|
3932
|
+
pollingIntervalMs,
|
|
3922
3933
|
videoResolution
|
|
3923
3934
|
}
|
|
3924
3935
|
) })
|
|
@@ -3926,6 +3937,7 @@ function TwickStudio({ studioConfig }) {
|
|
|
3926
3937
|
] }) });
|
|
3927
3938
|
}
|
|
3928
3939
|
const useGenerateCaptions = (studioConfig) => {
|
|
3940
|
+
var _a;
|
|
3929
3941
|
const { editor, present } = timeline.useTimelineContext();
|
|
3930
3942
|
const onGenerateCaptions = async (videoElement) => {
|
|
3931
3943
|
if (studioConfig == null ? void 0 : studioConfig.captionGenerationService) {
|
|
@@ -3940,8 +3952,8 @@ const useGenerateCaptions = (studioConfig) => {
|
|
|
3940
3952
|
return null;
|
|
3941
3953
|
};
|
|
3942
3954
|
const addCaptionsToTimeline = (captions) => {
|
|
3943
|
-
var
|
|
3944
|
-
const updatedProjectJSON = (
|
|
3955
|
+
var _a2;
|
|
3956
|
+
const updatedProjectJSON = (_a2 = studioConfig == null ? void 0 : studioConfig.captionGenerationService) == null ? void 0 : _a2.updateProjectWithCaptions(
|
|
3945
3957
|
captions
|
|
3946
3958
|
);
|
|
3947
3959
|
if (updatedProjectJSON) {
|
|
@@ -3958,10 +3970,12 @@ const useGenerateCaptions = (studioConfig) => {
|
|
|
3958
3970
|
error: "Caption generation service not found"
|
|
3959
3971
|
};
|
|
3960
3972
|
};
|
|
3973
|
+
const pollingIntervalMs = ((_a = studioConfig == null ? void 0 : studioConfig.captionGenerationService) == null ? void 0 : _a.pollingIntervalMs) ?? 5e3;
|
|
3961
3974
|
return {
|
|
3962
3975
|
onGenerateCaptions,
|
|
3963
3976
|
addCaptionsToTimeline,
|
|
3964
|
-
getCaptionstatus
|
|
3977
|
+
getCaptionstatus,
|
|
3978
|
+
pollingIntervalMs
|
|
3965
3979
|
};
|
|
3966
3980
|
};
|
|
3967
3981
|
Object.defineProperty(exports, "AudioElement", {
|