@twick/studio 0.15.0 → 0.15.2
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/README.md +49 -4
- package/dist/components/header.d.ts +2 -1
- package/dist/hooks/use-studio-operation.d.ts +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +48 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -8
package/README.md
CHANGED
|
@@ -21,14 +21,28 @@ npm install @twick/studio
|
|
|
21
21
|
pnpm add @twick/studio
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
**Note:** All required dependencies
|
|
24
|
+
**Note:** All required dependencies are automatically installed with `@twick/studio`:
|
|
25
|
+
- `@twick/timeline` - Timeline management
|
|
26
|
+
- `@twick/live-player` - Video player components
|
|
27
|
+
- `@twick/video-editor` - Video editor component
|
|
28
|
+
- `@twick/canvas` - Canvas utilities
|
|
29
|
+
- `@twick/media-utils` - Media processing utilities
|
|
30
|
+
- `@twick/visualizer` - Visual rendering
|
|
31
|
+
- `@twick/core` - Core functionality
|
|
32
|
+
- `@twick/player-react` - React player components
|
|
33
|
+
|
|
34
|
+
You can import all components and providers directly from `@twick/studio` - no need to import from individual packages! This simplifies your imports and ensures all dependencies are properly versioned together.
|
|
25
35
|
|
|
26
36
|
## Quick Start
|
|
27
37
|
|
|
28
38
|
```tsx
|
|
29
|
-
|
|
30
|
-
import {
|
|
31
|
-
|
|
39
|
+
// Import everything you need from @twick/studio
|
|
40
|
+
import {
|
|
41
|
+
TwickStudio,
|
|
42
|
+
LivePlayerProvider,
|
|
43
|
+
TimelineProvider,
|
|
44
|
+
INITIAL_TIMELINE_DATA
|
|
45
|
+
} from "@twick/studio";
|
|
32
46
|
import "@twick/studio/dist/studio.css";
|
|
33
47
|
|
|
34
48
|
export default function App() {
|
|
@@ -70,6 +84,16 @@ export default function App() {
|
|
|
70
84
|
}
|
|
71
85
|
```
|
|
72
86
|
|
|
87
|
+
### Alternative: Import from Individual Packages
|
|
88
|
+
|
|
89
|
+
You can also import from individual packages if you prefer:
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
import { LivePlayerProvider } from "@twick/live-player";
|
|
93
|
+
import { TimelineProvider, INITIAL_TIMELINE_DATA } from "@twick/timeline";
|
|
94
|
+
import { TwickStudio } from "@twick/studio";
|
|
95
|
+
```
|
|
96
|
+
|
|
73
97
|
## Components
|
|
74
98
|
|
|
75
99
|
### TwickStudio
|
|
@@ -178,6 +202,27 @@ The studio includes specialized panels for different element types:
|
|
|
178
202
|
### Hooks
|
|
179
203
|
|
|
180
204
|
- **useStudioManager**: Hook for managing studio state, selected tools, and element manipulation
|
|
205
|
+
- **useGenerateSubtitles**: Hook for subtitle generation and polling
|
|
206
|
+
|
|
207
|
+
### Re-exported Components
|
|
208
|
+
|
|
209
|
+
For convenience, `@twick/studio` re-exports commonly used components from other packages:
|
|
210
|
+
|
|
211
|
+
- **VideoEditor**: Main video editor component (from `@twick/video-editor`)
|
|
212
|
+
- **LivePlayer**, **LivePlayerProvider**: Player components (from `@twick/live-player`)
|
|
213
|
+
- **TimelineProvider**, **INITIAL_TIMELINE_DATA**: Timeline components (from `@twick/timeline`)
|
|
214
|
+
|
|
215
|
+
You can import these directly from `@twick/studio`:
|
|
216
|
+
|
|
217
|
+
```tsx
|
|
218
|
+
import {
|
|
219
|
+
VideoEditor,
|
|
220
|
+
LivePlayer,
|
|
221
|
+
LivePlayerProvider,
|
|
222
|
+
TimelineProvider,
|
|
223
|
+
INITIAL_TIMELINE_DATA
|
|
224
|
+
} from "@twick/studio";
|
|
225
|
+
```
|
|
181
226
|
|
|
182
227
|
## Development
|
|
183
228
|
|
|
@@ -2,9 +2,10 @@ import { Size } from '@twick/timeline';
|
|
|
2
2
|
|
|
3
3
|
interface StudioHeaderProps {
|
|
4
4
|
setVideoResolution: (resolution: Size) => void;
|
|
5
|
+
onNewProject: () => void;
|
|
5
6
|
onLoadProject: () => void;
|
|
6
7
|
onSaveProject: () => void;
|
|
7
8
|
onExportVideo: () => void;
|
|
8
9
|
}
|
|
9
|
-
export declare const StudioHeader: ({ setVideoResolution, onLoadProject, onSaveProject, onExportVideo, }: StudioHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const StudioHeader: ({ setVideoResolution, onNewProject, onLoadProject, onSaveProject, onExportVideo, }: StudioHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export default StudioHeader;
|
|
@@ -5,6 +5,7 @@ declare const useStudioOperation: (studioConfig?: StudioConfig) => {
|
|
|
5
5
|
onLoadProject: () => Promise<void>;
|
|
6
6
|
onSaveProject: () => Promise<void>;
|
|
7
7
|
onExportVideo: () => Promise<void>;
|
|
8
|
+
onNewProject: () => void;
|
|
8
9
|
onGenerateSubtitles: (videoElement: VideoElement) => Promise<string | null>;
|
|
9
10
|
addSubtitlesToTimeline: (subtitles: SubtitleEntry[]) => void;
|
|
10
11
|
getSubtitleStatus: (reqId: string) => Promise<ISubtitleGenerationPollingResponse>;
|
package/dist/index.d.ts
CHANGED
|
@@ -44,6 +44,23 @@ useGenerateSubtitles, };
|
|
|
44
44
|
export * from './helpers/generate-subtitles.service';
|
|
45
45
|
export * from './helpers/constant';
|
|
46
46
|
export * from './types';
|
|
47
|
+
/**
|
|
48
|
+
* Re-export commonly used components from dependencies.
|
|
49
|
+
*
|
|
50
|
+
* This allows users to import everything from @twick/studio without needing
|
|
51
|
+
* to install or import from individual @twick packages. All required dependencies
|
|
52
|
+
* are automatically installed when you install @twick/studio.
|
|
53
|
+
*
|
|
54
|
+
* Re-exported components:
|
|
55
|
+
* - VideoEditor: Main video editor component from @twick/video-editor
|
|
56
|
+
* - LivePlayerProvider, LivePlayer: Player components from @twick/live-player
|
|
57
|
+
* - TimelineProvider, INITIAL_TIMELINE_DATA: Timeline components from @twick/timeline
|
|
58
|
+
*/
|
|
59
|
+
export { default as VideoEditor } from '@twick/video-editor';
|
|
60
|
+
export type { VideoEditorProps, VideoEditorConfig } from '@twick/video-editor';
|
|
61
|
+
export { LivePlayerProvider, LivePlayer } from '@twick/live-player';
|
|
62
|
+
export { TimelineProvider, INITIAL_TIMELINE_DATA } from '@twick/timeline';
|
|
63
|
+
export type { TimelineProviderProps } from '@twick/timeline';
|
|
47
64
|
/**
|
|
48
65
|
* Default export: TwickStudio (full editor component)
|
|
49
66
|
*/
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
7
7
|
const react = require("react");
|
|
8
8
|
const timeline = require("@twick/timeline");
|
|
9
9
|
const VideoEditor = require("@twick/video-editor");
|
|
10
|
+
const livePlayer = require("@twick/live-player");
|
|
10
11
|
/**
|
|
11
12
|
* @license lucide-react v0.511.0 - ISC
|
|
12
13
|
*
|
|
@@ -551,6 +552,7 @@ function Toolbar({ selectedTool, setSelectedTool }) {
|
|
|
551
552
|
}
|
|
552
553
|
const StudioHeader = ({
|
|
553
554
|
setVideoResolution,
|
|
555
|
+
onNewProject,
|
|
554
556
|
onLoadProject,
|
|
555
557
|
onSaveProject,
|
|
556
558
|
onExportVideo
|
|
@@ -579,6 +581,18 @@ const StudioHeader = ({
|
|
|
579
581
|
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-gradient", children: "Twick Studio" })
|
|
580
582
|
] }) }),
|
|
581
583
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-container", children: [
|
|
584
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
585
|
+
"button",
|
|
586
|
+
{
|
|
587
|
+
className: "btn-ghost",
|
|
588
|
+
title: "New Project",
|
|
589
|
+
onClick: onNewProject,
|
|
590
|
+
children: [
|
|
591
|
+
/* @__PURE__ */ jsxRuntime.jsx(Plus, { className: "icon-sm" }),
|
|
592
|
+
"New Project"
|
|
593
|
+
]
|
|
594
|
+
}
|
|
595
|
+
),
|
|
582
596
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
583
597
|
"button",
|
|
584
598
|
{
|
|
@@ -2436,7 +2450,7 @@ function SubtitlesPanel({
|
|
|
2436
2450
|
const CAPTION_PROPS = {
|
|
2437
2451
|
[timeline.CAPTION_STYLE.WORD_BG_HIGHLIGHT]: {
|
|
2438
2452
|
font: {
|
|
2439
|
-
size:
|
|
2453
|
+
size: 46,
|
|
2440
2454
|
weight: 700,
|
|
2441
2455
|
family: "Bangers"
|
|
2442
2456
|
},
|
|
@@ -2453,7 +2467,7 @@ const CAPTION_PROPS = {
|
|
|
2453
2467
|
},
|
|
2454
2468
|
[timeline.CAPTION_STYLE.WORD_BY_WORD]: {
|
|
2455
2469
|
font: {
|
|
2456
|
-
size:
|
|
2470
|
+
size: 46,
|
|
2457
2471
|
weight: 700,
|
|
2458
2472
|
family: "Bangers"
|
|
2459
2473
|
},
|
|
@@ -2470,7 +2484,7 @@ const CAPTION_PROPS = {
|
|
|
2470
2484
|
},
|
|
2471
2485
|
[timeline.CAPTION_STYLE.WORD_BY_WORD_WITH_BG]: {
|
|
2472
2486
|
font: {
|
|
2473
|
-
size:
|
|
2487
|
+
size: 46,
|
|
2474
2488
|
weight: 700,
|
|
2475
2489
|
family: "Bangers"
|
|
2476
2490
|
},
|
|
@@ -3504,9 +3518,19 @@ function PropertiesPanelContainer({
|
|
|
3504
3518
|
}
|
|
3505
3519
|
const useStudioOperation = (studioConfig) => {
|
|
3506
3520
|
const { editor, present } = timeline.useTimelineContext();
|
|
3521
|
+
const { setSeekTime, setPlayerState } = livePlayer.useLivePlayerContext();
|
|
3507
3522
|
const [projectName, setProjectName] = react.useState("");
|
|
3523
|
+
const onNewProject = () => {
|
|
3524
|
+
setPlayerState(timeline.PLAYER_STATE.PAUSED);
|
|
3525
|
+
editor.loadProject({
|
|
3526
|
+
tracks: [],
|
|
3527
|
+
version: 0
|
|
3528
|
+
});
|
|
3529
|
+
setSeekTime(0);
|
|
3530
|
+
};
|
|
3508
3531
|
const onLoadProject = async () => {
|
|
3509
3532
|
let project;
|
|
3533
|
+
setPlayerState(timeline.PLAYER_STATE.PAUSED);
|
|
3510
3534
|
if (studioConfig == null ? void 0 : studioConfig.loadProject) {
|
|
3511
3535
|
project = await studioConfig.loadProject();
|
|
3512
3536
|
} else {
|
|
@@ -3515,8 +3539,8 @@ const useStudioOperation = (studioConfig) => {
|
|
|
3515
3539
|
setProjectName(file.name);
|
|
3516
3540
|
project = JSON.parse(text);
|
|
3517
3541
|
}
|
|
3518
|
-
console.log("Editor", editor);
|
|
3519
3542
|
editor.loadProject(project);
|
|
3543
|
+
setSeekTime(0.01);
|
|
3520
3544
|
};
|
|
3521
3545
|
const onSaveProject = async () => {
|
|
3522
3546
|
let fileName;
|
|
@@ -3585,6 +3609,7 @@ const useStudioOperation = (studioConfig) => {
|
|
|
3585
3609
|
onLoadProject,
|
|
3586
3610
|
onSaveProject,
|
|
3587
3611
|
onExportVideo,
|
|
3612
|
+
onNewProject,
|
|
3588
3613
|
onGenerateSubtitles,
|
|
3589
3614
|
addSubtitlesToTimeline,
|
|
3590
3615
|
getSubtitleStatus
|
|
@@ -3642,6 +3667,7 @@ function TwickStudio({ studioConfig }) {
|
|
|
3642
3667
|
} = useStudioManager();
|
|
3643
3668
|
const { videoResolution, setVideoResolution } = timeline.useTimelineContext();
|
|
3644
3669
|
const {
|
|
3670
|
+
onNewProject,
|
|
3645
3671
|
onLoadProject,
|
|
3646
3672
|
onSaveProject,
|
|
3647
3673
|
onExportVideo
|
|
@@ -3664,6 +3690,7 @@ function TwickStudio({ studioConfig }) {
|
|
|
3664
3690
|
StudioHeader,
|
|
3665
3691
|
{
|
|
3666
3692
|
setVideoResolution,
|
|
3693
|
+
onNewProject,
|
|
3667
3694
|
onLoadProject,
|
|
3668
3695
|
onSaveProject,
|
|
3669
3696
|
onExportVideo
|
|
@@ -3720,6 +3747,23 @@ function TwickStudio({ studioConfig }) {
|
|
|
3720
3747
|
] })
|
|
3721
3748
|
] }) });
|
|
3722
3749
|
}
|
|
3750
|
+
Object.defineProperty(exports, "INITIAL_TIMELINE_DATA", {
|
|
3751
|
+
enumerable: true,
|
|
3752
|
+
get: () => timeline.INITIAL_TIMELINE_DATA
|
|
3753
|
+
});
|
|
3754
|
+
Object.defineProperty(exports, "TimelineProvider", {
|
|
3755
|
+
enumerable: true,
|
|
3756
|
+
get: () => timeline.TimelineProvider
|
|
3757
|
+
});
|
|
3758
|
+
exports.VideoEditor = VideoEditor;
|
|
3759
|
+
Object.defineProperty(exports, "LivePlayer", {
|
|
3760
|
+
enumerable: true,
|
|
3761
|
+
get: () => livePlayer.LivePlayer
|
|
3762
|
+
});
|
|
3763
|
+
Object.defineProperty(exports, "LivePlayerProvider", {
|
|
3764
|
+
enumerable: true,
|
|
3765
|
+
get: () => livePlayer.LivePlayerProvider
|
|
3766
|
+
});
|
|
3723
3767
|
exports.AudioPanel = AudioPanel;
|
|
3724
3768
|
exports.CAPTION_PROPS = CAPTION_PROPS;
|
|
3725
3769
|
exports.CirclePanel = CirclePanel;
|