@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/dist/index.mjs CHANGED
@@ -3,8 +3,12 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { forwardRef, createElement, useState, useEffect, useRef, createContext, useContext, useCallback, useMemo } from "react";
6
- import { useTimelineContext, TrackElement, Track, ImageElement, AudioElement, VideoElement, TextElement, IconElement, RectElement, CircleElement, CAPTION_STYLE, CaptionElement, ElementTextEffect, ElementAnimation } from "@twick/timeline";
6
+ import { useTimelineContext, TrackElement, Track, ImageElement, AudioElement, VideoElement, TextElement, IconElement, RectElement, CircleElement, CAPTION_STYLE, CaptionElement, ElementTextEffect, ElementAnimation, PLAYER_STATE } from "@twick/timeline";
7
+ import { INITIAL_TIMELINE_DATA, TimelineProvider } from "@twick/timeline";
7
8
  import VideoEditor, { useEditorManager, BrowserMediaManager, AVAILABLE_TEXT_FONTS, TEXT_EFFECTS, ANIMATIONS } from "@twick/video-editor";
9
+ import { default as default2 } from "@twick/video-editor";
10
+ import { useLivePlayerContext } from "@twick/live-player";
11
+ import { LivePlayer, LivePlayerProvider } from "@twick/live-player";
8
12
  /**
9
13
  * @license lucide-react v0.511.0 - ISC
10
14
  *
@@ -549,6 +553,7 @@ function Toolbar({ selectedTool, setSelectedTool }) {
549
553
  }
550
554
  const StudioHeader = ({
551
555
  setVideoResolution,
556
+ onNewProject,
552
557
  onLoadProject,
553
558
  onSaveProject,
554
559
  onExportVideo
@@ -577,6 +582,18 @@ const StudioHeader = ({
577
582
  /* @__PURE__ */ jsx("h1", { className: "text-gradient", children: "Twick Studio" })
578
583
  ] }) }),
579
584
  /* @__PURE__ */ jsxs("div", { className: "flex-container", children: [
585
+ /* @__PURE__ */ jsxs(
586
+ "button",
587
+ {
588
+ className: "btn-ghost",
589
+ title: "New Project",
590
+ onClick: onNewProject,
591
+ children: [
592
+ /* @__PURE__ */ jsx(Plus, { className: "icon-sm" }),
593
+ "New Project"
594
+ ]
595
+ }
596
+ ),
580
597
  /* @__PURE__ */ jsxs(
581
598
  "button",
582
599
  {
@@ -2434,7 +2451,7 @@ function SubtitlesPanel({
2434
2451
  const CAPTION_PROPS = {
2435
2452
  [CAPTION_STYLE.WORD_BG_HIGHLIGHT]: {
2436
2453
  font: {
2437
- size: 50,
2454
+ size: 46,
2438
2455
  weight: 700,
2439
2456
  family: "Bangers"
2440
2457
  },
@@ -2451,7 +2468,7 @@ const CAPTION_PROPS = {
2451
2468
  },
2452
2469
  [CAPTION_STYLE.WORD_BY_WORD]: {
2453
2470
  font: {
2454
- size: 50,
2471
+ size: 46,
2455
2472
  weight: 700,
2456
2473
  family: "Bangers"
2457
2474
  },
@@ -2468,7 +2485,7 @@ const CAPTION_PROPS = {
2468
2485
  },
2469
2486
  [CAPTION_STYLE.WORD_BY_WORD_WITH_BG]: {
2470
2487
  font: {
2471
- size: 50,
2488
+ size: 46,
2472
2489
  weight: 700,
2473
2490
  family: "Bangers"
2474
2491
  },
@@ -3502,9 +3519,19 @@ function PropertiesPanelContainer({
3502
3519
  }
3503
3520
  const useStudioOperation = (studioConfig) => {
3504
3521
  const { editor, present } = useTimelineContext();
3522
+ const { setSeekTime, setPlayerState } = useLivePlayerContext();
3505
3523
  const [projectName, setProjectName] = useState("");
3524
+ const onNewProject = () => {
3525
+ setPlayerState(PLAYER_STATE.PAUSED);
3526
+ editor.loadProject({
3527
+ tracks: [],
3528
+ version: 0
3529
+ });
3530
+ setSeekTime(0);
3531
+ };
3506
3532
  const onLoadProject = async () => {
3507
3533
  let project;
3534
+ setPlayerState(PLAYER_STATE.PAUSED);
3508
3535
  if (studioConfig == null ? void 0 : studioConfig.loadProject) {
3509
3536
  project = await studioConfig.loadProject();
3510
3537
  } else {
@@ -3513,8 +3540,8 @@ const useStudioOperation = (studioConfig) => {
3513
3540
  setProjectName(file.name);
3514
3541
  project = JSON.parse(text);
3515
3542
  }
3516
- console.log("Editor", editor);
3517
3543
  editor.loadProject(project);
3544
+ setSeekTime(0.01);
3518
3545
  };
3519
3546
  const onSaveProject = async () => {
3520
3547
  let fileName;
@@ -3583,6 +3610,7 @@ const useStudioOperation = (studioConfig) => {
3583
3610
  onLoadProject,
3584
3611
  onSaveProject,
3585
3612
  onExportVideo,
3613
+ onNewProject,
3586
3614
  onGenerateSubtitles,
3587
3615
  addSubtitlesToTimeline,
3588
3616
  getSubtitleStatus
@@ -3640,6 +3668,7 @@ function TwickStudio({ studioConfig }) {
3640
3668
  } = useStudioManager();
3641
3669
  const { videoResolution, setVideoResolution } = useTimelineContext();
3642
3670
  const {
3671
+ onNewProject,
3643
3672
  onLoadProject,
3644
3673
  onSaveProject,
3645
3674
  onExportVideo
@@ -3662,6 +3691,7 @@ function TwickStudio({ studioConfig }) {
3662
3691
  StudioHeader,
3663
3692
  {
3664
3693
  setVideoResolution,
3694
+ onNewProject,
3665
3695
  onLoadProject,
3666
3696
  onSaveProject,
3667
3697
  onExportVideo
@@ -3722,14 +3752,19 @@ export {
3722
3752
  AudioPanel,
3723
3753
  CAPTION_PROPS,
3724
3754
  CirclePanel,
3755
+ INITIAL_TIMELINE_DATA,
3725
3756
  IconPanel,
3726
3757
  ImagePanel,
3758
+ LivePlayer,
3759
+ LivePlayerProvider,
3727
3760
  RectPanel,
3728
3761
  StudioHeader,
3729
3762
  SubtitlesPanel,
3730
3763
  TextPanel,
3764
+ TimelineProvider,
3731
3765
  Toolbar,
3732
3766
  TwickStudio,
3767
+ default2 as VideoEditor,
3733
3768
  VideoPanel,
3734
3769
  TwickStudio as default,
3735
3770
  useGenerateSubtitles,