@twick/studio 0.15.15 → 0.15.18

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
@@ -3401,7 +3401,8 @@ function GenerateCaptionsPanel({
3401
3401
  selectedElement,
3402
3402
  addCaptionsToTimeline,
3403
3403
  onGenerateCaptions,
3404
- getCaptionstatus
3404
+ getCaptionstatus,
3405
+ pollingIntervalMs = 5e3
3405
3406
  }) {
3406
3407
  const [containsAudio, setContainsAudio] = useState(null);
3407
3408
  const [isLoading, setIsLoading] = useState(true);
@@ -3458,12 +3459,14 @@ function GenerateCaptionsPanel({
3458
3459
  }
3459
3460
  };
3460
3461
  await poll();
3461
- pollingIntervalRef.current = setInterval(poll, 2e3);
3462
+ pollingIntervalRef.current = setInterval(poll, pollingIntervalMs);
3462
3463
  };
3463
3464
  const handleGenerateCaptions = async () => {
3464
3465
  if (!(selectedElement instanceof VideoElement)) {
3465
3466
  return;
3466
3467
  }
3468
+ setIsGenerating(true);
3469
+ setPollingStatus("polling");
3467
3470
  const videoElement = selectedElement;
3468
3471
  try {
3469
3472
  const reqId = await onGenerateCaptions(videoElement);
@@ -3670,13 +3673,14 @@ function PropertiesPanelContainer({
3670
3673
  addCaptionsToTimeline,
3671
3674
  onGenerateCaptions,
3672
3675
  getCaptionstatus,
3676
+ pollingIntervalMs,
3673
3677
  videoResolution
3674
3678
  }) {
3675
3679
  const title = selectedElement instanceof TextElement ? selectedElement.getText() : (selectedElement == null ? void 0 : selectedElement.getName()) || (selectedElement == null ? void 0 : selectedElement.getType()) || "Element";
3676
3680
  return /* @__PURE__ */ jsxs("aside", { className: "properties-panel", "aria-label": "Element properties inspector", children: [
3677
3681
  /* @__PURE__ */ jsxs("div", { className: "properties-header", children: [
3678
3682
  !selectedElement && /* @__PURE__ */ jsx("h3", { className: "properties-title", children: "Composition" }),
3679
- selectedElement && selectedElement.getType() === "caption" && /* @__PURE__ */ jsx("h3", { className: "properties-title", children: "Subtitles are edited from the captions panel" }),
3683
+ selectedElement && selectedElement.getType() === "caption" && /* @__PURE__ */ jsx("h3", { className: "properties-title", children: "Edit from the captions panel" }),
3680
3684
  selectedElement && selectedElement.getType() !== "caption" && /* @__PURE__ */ jsx("h3", { className: "properties-title", children: title })
3681
3685
  ] }),
3682
3686
  /* @__PURE__ */ jsxs("div", { className: "prop-content", children: [
@@ -3737,7 +3741,8 @@ function PropertiesPanelContainer({
3737
3741
  selectedElement,
3738
3742
  addCaptionsToTimeline,
3739
3743
  onGenerateCaptions,
3740
- getCaptionstatus
3744
+ getCaptionstatus,
3745
+ pollingIntervalMs
3741
3746
  }
3742
3747
  )
3743
3748
  ] });
@@ -3859,7 +3864,12 @@ function TwickStudio({ studioConfig }) {
3859
3864
  onSaveProject,
3860
3865
  onExportVideo
3861
3866
  } = useStudioOperation(studioConfig);
3862
- const { onGenerateCaptions, addCaptionsToTimeline, getCaptionstatus } = useGenerateCaptions(studioConfig);
3867
+ const {
3868
+ onGenerateCaptions,
3869
+ addCaptionsToTimeline,
3870
+ getCaptionstatus,
3871
+ pollingIntervalMs
3872
+ } = useGenerateCaptions(studioConfig);
3863
3873
  const twickStudiConfig = useMemo(
3864
3874
  () => ({
3865
3875
  canvasMode: true,
@@ -3907,7 +3917,7 @@ function TwickStudio({ studioConfig }) {
3907
3917
  {
3908
3918
  className: "canvas-container",
3909
3919
  style: {
3910
- maxWidth: ((_a = twickStudiConfig.playerProps) == null ? void 0 : _a.maxWidth) ?? 960
3920
+ maxWidth: ((_a = twickStudiConfig.playerProps) == null ? void 0 : _a.maxWidth) ?? "100%"
3911
3921
  },
3912
3922
  children: /* @__PURE__ */ jsx(VideoEditor, { editorConfig: twickStudiConfig })
3913
3923
  }
@@ -3920,6 +3930,7 @@ function TwickStudio({ studioConfig }) {
3920
3930
  addCaptionsToTimeline,
3921
3931
  onGenerateCaptions,
3922
3932
  getCaptionstatus,
3933
+ pollingIntervalMs,
3923
3934
  videoResolution
3924
3935
  }
3925
3936
  ) })
@@ -3927,6 +3938,7 @@ function TwickStudio({ studioConfig }) {
3927
3938
  ] }) });
3928
3939
  }
3929
3940
  const useGenerateCaptions = (studioConfig) => {
3941
+ var _a;
3930
3942
  const { editor, present } = useTimelineContext();
3931
3943
  const onGenerateCaptions = async (videoElement) => {
3932
3944
  if (studioConfig == null ? void 0 : studioConfig.captionGenerationService) {
@@ -3941,8 +3953,8 @@ const useGenerateCaptions = (studioConfig) => {
3941
3953
  return null;
3942
3954
  };
3943
3955
  const addCaptionsToTimeline = (captions) => {
3944
- var _a;
3945
- const updatedProjectJSON = (_a = studioConfig == null ? void 0 : studioConfig.captionGenerationService) == null ? void 0 : _a.updateProjectWithCaptions(
3956
+ var _a2;
3957
+ const updatedProjectJSON = (_a2 = studioConfig == null ? void 0 : studioConfig.captionGenerationService) == null ? void 0 : _a2.updateProjectWithCaptions(
3946
3958
  captions
3947
3959
  );
3948
3960
  if (updatedProjectJSON) {
@@ -3959,10 +3971,12 @@ const useGenerateCaptions = (studioConfig) => {
3959
3971
  error: "Caption generation service not found"
3960
3972
  };
3961
3973
  };
3974
+ const pollingIntervalMs = ((_a = studioConfig == null ? void 0 : studioConfig.captionGenerationService) == null ? void 0 : _a.pollingIntervalMs) ?? 5e3;
3962
3975
  return {
3963
3976
  onGenerateCaptions,
3964
3977
  addCaptionsToTimeline,
3965
- getCaptionstatus
3978
+ getCaptionstatus,
3979
+ pollingIntervalMs
3966
3980
  };
3967
3981
  };
3968
3982
  export {