@twick/studio 0.14.12 → 0.14.14
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/hooks/use-generate-subtitles.d.ts +9 -0
- package/dist/index.d.ts +21 -13
- package/dist/index.js +43 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { VideoElement } from '@twick/timeline';
|
|
2
|
+
import { ISubtitleGenerationPollingResponse, StudioConfig, SubtitleEntry } from '../types';
|
|
3
|
+
|
|
4
|
+
declare const useGenerateSubtitles: (studioConfig?: StudioConfig) => {
|
|
5
|
+
onGenerateSubtitles: (videoElement: VideoElement) => Promise<string | null>;
|
|
6
|
+
addSubtitlesToTimeline: (subtitles: SubtitleEntry[]) => void;
|
|
7
|
+
getSubtitleStatus: (reqId: string) => Promise<ISubtitleGenerationPollingResponse>;
|
|
8
|
+
};
|
|
9
|
+
export default useGenerateSubtitles;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TwickStudio } from './components/twick-studio';
|
|
2
2
|
import { Toolbar } from './components/toolbar';
|
|
3
3
|
import { useStudioManager } from './hooks/use-studio-manager';
|
|
4
|
+
import { default as useGenerateSubtitles } from './hooks/use-generate-subtitles';
|
|
4
5
|
import { default as StudioHeader } from './components/header';
|
|
5
6
|
import { AudioPanel } from './components/panel/audio-panel';
|
|
6
7
|
import { VideoPanel } from './components/panel/video-panel';
|
|
@@ -12,31 +13,38 @@ import { IconPanel } from './components/panel/icon-panel';
|
|
|
12
13
|
import { SubtitlesPanel } from './components/panel/subtitles-panel';
|
|
13
14
|
|
|
14
15
|
export {
|
|
15
|
-
/** Main studio
|
|
16
|
+
/** Main studio editing environment */
|
|
16
17
|
TwickStudio,
|
|
17
|
-
/**
|
|
18
|
+
/** Editing tool/mode selector */
|
|
18
19
|
Toolbar,
|
|
19
|
-
/** Studio
|
|
20
|
+
/** Studio top bar with controls */
|
|
20
21
|
StudioHeader, };
|
|
21
22
|
export {
|
|
22
|
-
/**
|
|
23
|
+
/** Panel for audio assets */
|
|
23
24
|
AudioPanel,
|
|
24
|
-
/**
|
|
25
|
+
/** Panel for video assets */
|
|
25
26
|
VideoPanel,
|
|
26
|
-
/**
|
|
27
|
+
/** Panel for image assets */
|
|
27
28
|
ImagePanel,
|
|
28
|
-
/**
|
|
29
|
+
/** Panel for editing/add text elements */
|
|
29
30
|
TextPanel,
|
|
30
|
-
/**
|
|
31
|
+
/** Panel for subtitle/caption management */
|
|
31
32
|
SubtitlesPanel,
|
|
32
|
-
/**
|
|
33
|
+
/** Panel for adding circles */
|
|
33
34
|
CirclePanel,
|
|
34
|
-
/**
|
|
35
|
+
/** Panel for adding rectangles */
|
|
35
36
|
RectPanel,
|
|
36
|
-
/**
|
|
37
|
+
/** Panel for icon assets */
|
|
37
38
|
IconPanel, };
|
|
38
39
|
export {
|
|
39
|
-
/**
|
|
40
|
-
useStudioManager,
|
|
40
|
+
/** Hook for managing studio state and selections */
|
|
41
|
+
useStudioManager,
|
|
42
|
+
/** Hook for polling-based subtitle generation */
|
|
43
|
+
useGenerateSubtitles, };
|
|
44
|
+
export * from './helpers/generate-subtitles.service';
|
|
45
|
+
export * from './helpers/constant';
|
|
41
46
|
export * from './types';
|
|
47
|
+
/**
|
|
48
|
+
* Default export: TwickStudio (full editor component)
|
|
49
|
+
*/
|
|
42
50
|
export default TwickStudio;
|
package/dist/index.js
CHANGED
|
@@ -3588,6 +3588,45 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3588
3588
|
getSubtitleStatus
|
|
3589
3589
|
};
|
|
3590
3590
|
};
|
|
3591
|
+
const useGenerateSubtitles = (studioConfig) => {
|
|
3592
|
+
const { editor, present } = timeline.useTimelineContext();
|
|
3593
|
+
const onGenerateSubtitles = async (videoElement) => {
|
|
3594
|
+
if (studioConfig == null ? void 0 : studioConfig.subtitleGenerationService) {
|
|
3595
|
+
const service = studioConfig.subtitleGenerationService;
|
|
3596
|
+
const reqId = await service.generateSubtitles(
|
|
3597
|
+
videoElement,
|
|
3598
|
+
present
|
|
3599
|
+
);
|
|
3600
|
+
return reqId;
|
|
3601
|
+
}
|
|
3602
|
+
alert("Generate subtitles not supported in demo mode");
|
|
3603
|
+
return null;
|
|
3604
|
+
};
|
|
3605
|
+
const addSubtitlesToTimeline = (subtitles) => {
|
|
3606
|
+
var _a;
|
|
3607
|
+
const updatedProjectJSON = (_a = studioConfig == null ? void 0 : studioConfig.subtitleGenerationService) == null ? void 0 : _a.updateProjectWithSubtitles(
|
|
3608
|
+
subtitles
|
|
3609
|
+
);
|
|
3610
|
+
if (updatedProjectJSON) {
|
|
3611
|
+
editor.loadProject(updatedProjectJSON);
|
|
3612
|
+
}
|
|
3613
|
+
};
|
|
3614
|
+
const getSubtitleStatus = async (reqId) => {
|
|
3615
|
+
if (studioConfig == null ? void 0 : studioConfig.subtitleGenerationService) {
|
|
3616
|
+
const service = studioConfig.subtitleGenerationService;
|
|
3617
|
+
return await service.getRequestStatus(reqId);
|
|
3618
|
+
}
|
|
3619
|
+
return {
|
|
3620
|
+
status: "failed",
|
|
3621
|
+
error: "Subtitle generation service not found"
|
|
3622
|
+
};
|
|
3623
|
+
};
|
|
3624
|
+
return {
|
|
3625
|
+
onGenerateSubtitles,
|
|
3626
|
+
addSubtitlesToTimeline,
|
|
3627
|
+
getSubtitleStatus
|
|
3628
|
+
};
|
|
3629
|
+
};
|
|
3591
3630
|
function TwickStudio({ studioConfig }) {
|
|
3592
3631
|
var _a;
|
|
3593
3632
|
const {
|
|
@@ -3603,11 +3642,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3603
3642
|
const {
|
|
3604
3643
|
onLoadProject,
|
|
3605
3644
|
onSaveProject,
|
|
3606
|
-
onExportVideo
|
|
3607
|
-
onGenerateSubtitles,
|
|
3608
|
-
addSubtitlesToTimeline,
|
|
3609
|
-
getSubtitleStatus
|
|
3645
|
+
onExportVideo
|
|
3610
3646
|
} = useStudioOperation(studioConfig);
|
|
3647
|
+
const { onGenerateSubtitles, addSubtitlesToTimeline, getSubtitleStatus } = useGenerateSubtitles(studioConfig);
|
|
3611
3648
|
const twickStudiConfig = react.useMemo(
|
|
3612
3649
|
() => ({
|
|
3613
3650
|
canvasMode: true,
|
|
@@ -3682,6 +3719,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3682
3719
|
] }) });
|
|
3683
3720
|
}
|
|
3684
3721
|
exports2.AudioPanel = AudioPanel;
|
|
3722
|
+
exports2.CAPTION_PROPS = CAPTION_PROPS;
|
|
3685
3723
|
exports2.CirclePanel = CirclePanel;
|
|
3686
3724
|
exports2.IconPanel = IconPanel;
|
|
3687
3725
|
exports2.ImagePanel = ImagePanel;
|
|
@@ -3693,6 +3731,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3693
3731
|
exports2.TwickStudio = TwickStudio;
|
|
3694
3732
|
exports2.VideoPanel = VideoPanel;
|
|
3695
3733
|
exports2.default = TwickStudio;
|
|
3734
|
+
exports2.useGenerateSubtitles = useGenerateSubtitles;
|
|
3696
3735
|
exports2.useStudioManager = useStudioManager;
|
|
3697
3736
|
Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3698
3737
|
});
|