@remotion/studio 4.0.522 → 4.0.524
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/api/install-package.js +4 -2
- package/dist/components/ActionTooltip.d.ts +9 -0
- package/dist/components/ActionTooltip.js +143 -0
- package/dist/components/AssetAudioVolume.d.ts +5 -0
- package/dist/components/AssetAudioVolume.js +33 -0
- package/dist/components/Canvas.js +8 -8
- package/dist/components/CaptionInspector.js +74 -20
- package/dist/components/CheckboardToggle.js +9 -10
- package/dist/components/Checkbox.d.ts +1 -0
- package/dist/components/Checkbox.js +2 -2
- package/dist/components/CompositionContextButton.js +4 -1
- package/dist/components/CompositionSelectorItem.js +2 -2
- package/dist/components/ConfigureLicenseModal.js +1 -1
- package/dist/components/CurrentAsset.js +40 -6
- package/dist/components/EditorContexts.js +3 -1
- package/dist/components/ElementInstallConfirmation.js +254 -137
- package/dist/components/FixComputedValueModal.js +38 -8
- package/dist/components/FullscreenToggle.js +8 -10
- package/dist/components/GlobalKeybindings.js +107 -49
- package/dist/components/InspectorPanel/MultiSequenceField.d.ts +12 -0
- package/dist/components/InspectorPanel/MultiSequenceField.js +131 -0
- package/dist/components/InspectorPanel/MultiSequenceInspector.d.ts +8 -0
- package/dist/components/InspectorPanel/MultiSequenceInspector.js +102 -0
- package/dist/components/InspectorPanel/MultiSequenceNumberField.d.ts +9 -0
- package/dist/components/InspectorPanel/MultiSequenceNumberField.js +88 -0
- package/dist/components/InspectorPanel.js +4 -0
- package/dist/components/InspectorSequenceSection.js +69 -6
- package/dist/components/InstallPackage.js +4 -5
- package/dist/components/KeyboardShortcutsSettings.js +212 -33
- package/dist/components/LazySyntaxHighlightedSource.d.ts +4 -0
- package/dist/components/LazySyntaxHighlightedSource.js +43 -0
- package/dist/components/LoopToggle.js +8 -2
- package/dist/components/MenuToolbar.js +11 -7
- package/dist/components/ModalContainer.d.ts +1 -0
- package/dist/components/ModalContainer.js +2 -2
- package/dist/components/Modals.js +3 -1
- package/dist/components/ModelManager.d.ts +16 -0
- package/dist/components/ModelManager.js +200 -0
- package/dist/components/ModelsSettings.d.ts +2 -0
- package/dist/components/ModelsSettings.js +133 -0
- package/dist/components/MuteToggle.d.ts +1 -0
- package/dist/components/MuteToggle.js +16 -6
- package/dist/components/NewComposition/DismissableModal.d.ts +1 -0
- package/dist/components/NewComposition/DismissableModal.js +2 -2
- package/dist/components/NewComposition/InputDragger.d.ts +2 -2
- package/dist/components/NewComposition/InputDragger.js +6 -6
- package/dist/components/NewComposition/NewComposition.d.ts +1 -0
- package/dist/components/NewComposition/NewComposition.js +5 -4
- package/dist/components/NewComposition/NewFolder.js +9 -8
- package/dist/components/NewComposition/RenameComposition.js +3 -2
- package/dist/components/NewComposition/RenameFolder.js +15 -10
- package/dist/components/NewComposition/SlugPreview.d.ts +7 -0
- package/dist/components/NewComposition/SlugPreview.js +18 -0
- package/dist/components/OptionalPackageModal.d.ts +11 -0
- package/dist/components/OptionalPackageModal.js +155 -0
- package/dist/components/OutlineToggle.js +16 -10
- package/dist/components/PlayPause.js +11 -9
- package/dist/components/PlaybackKeyboardShortcutsManager.d.ts +2 -0
- package/dist/components/PlaybackKeyboardShortcutsManager.js +39 -7
- package/dist/components/PlaybackRateSelector.js +2 -2
- package/dist/components/PreviewToolbar.js +1 -1
- package/dist/components/PreviewToolbarOverflowButton.js +19 -4
- package/dist/components/QuickSwitcher/ExplorerQuickSwitcherTrigger.js +5 -2
- package/dist/components/RadioButton.d.ts +1 -0
- package/dist/components/RadioButton.js +2 -2
- package/dist/components/RenderButton.js +5 -1
- package/dist/components/RenderModal/NumberSetting.d.ts +6 -1
- package/dist/components/RenderModal/NumberSetting.js +2 -2
- package/dist/components/RenderModal/RenderModalBasic.js +1 -1
- package/dist/components/RenderModal/RenderModalOutputName.d.ts +3 -1
- package/dist/components/RenderModal/RenderModalOutputName.js +4 -4
- package/dist/components/RenderModal/SeparateAudioOption.js +1 -1
- package/dist/components/RenderModal/WebRenderModalBasic.js +1 -1
- package/dist/components/RenderQueue/CaptionQueueItem.d.ts +6 -0
- package/dist/components/RenderQueue/CaptionQueueItem.js +130 -0
- package/dist/components/RenderQueue/CaptionQueueProcessor.d.ts +1 -0
- package/dist/components/RenderQueue/CaptionQueueProcessor.js +110 -0
- package/dist/components/RenderQueue/CaptionQueueProcessorLoader.d.ts +2 -0
- package/dist/components/RenderQueue/CaptionQueueProcessorLoader.js +54 -0
- package/dist/components/RenderQueue/RenderQueueCopyToClipboard.js +2 -1
- package/dist/components/RenderQueue/RenderQueueDownloadItem.js +2 -1
- package/dist/components/RenderQueue/RenderQueueItem.js +3 -3
- package/dist/components/RenderQueue/RenderQueueItemCancelButton.js +2 -1
- package/dist/components/RenderQueue/RenderQueueOpenInFolder.js +2 -1
- package/dist/components/RenderQueue/RenderQueueRemoveItem.js +2 -1
- package/dist/components/RenderQueue/RenderQueueRepeat.js +2 -1
- package/dist/components/RenderQueue/VideoMattingQueueItem.d.ts +6 -0
- package/dist/components/RenderQueue/VideoMattingQueueItem.js +130 -0
- package/dist/components/RenderQueue/VideoMattingQueueProcessor.d.ts +1 -0
- package/dist/components/RenderQueue/VideoMattingQueueProcessor.js +105 -0
- package/dist/components/RenderQueue/VideoMattingQueueProcessorLoader.d.ts +2 -0
- package/dist/components/RenderQueue/VideoMattingQueueProcessorLoader.js +54 -0
- package/dist/components/RenderQueue/caption-job-types.d.ts +47 -0
- package/dist/components/RenderQueue/caption-job-types.js +7 -0
- package/dist/components/RenderQueue/context.d.ts +16 -0
- package/dist/components/RenderQueue/context.js +224 -11
- package/dist/components/RenderQueue/index.js +34 -10
- package/dist/components/RenderQueue/item-style.d.ts +1 -0
- package/dist/components/RenderQueue/item-style.js +2 -1
- package/dist/components/RenderQueue/load-model-for-job.d.ts +11 -0
- package/dist/components/RenderQueue/load-model-for-job.js +14 -0
- package/dist/components/RenderQueue/video-matting-job-types.d.ts +38 -0
- package/dist/components/RenderQueue/video-matting-job-types.js +5 -0
- package/dist/components/RendersTab.js +4 -4
- package/dist/components/RulersAndGuidesToggle.js +7 -1
- package/dist/components/SegmentedControl.d.ts +2 -2
- package/dist/components/SegmentedControl.js +38 -13
- package/dist/components/SelectedOutlinePolygon.js +8 -2
- package/dist/components/SettingsButton.d.ts +4 -0
- package/dist/components/SettingsButton.js +51 -0
- package/dist/components/SettingsModal.d.ts +1 -1
- package/dist/components/SettingsModal.js +3 -1
- package/dist/components/ShowOutlinesProvider.js +12 -0
- package/dist/components/SidebarCollapserControls.js +17 -21
- package/dist/components/SizeSelector.js +12 -4
- package/dist/components/SkillsSettings.js +2 -3
- package/dist/components/SnappingToggle.js +9 -8
- package/dist/components/StudioSettings.js +32 -18
- package/dist/components/SyntaxHighlightedSource.d.ts +5 -0
- package/dist/components/SyntaxHighlightedSource.js +78 -0
- package/dist/components/Tabs/vertical.d.ts +1 -0
- package/dist/components/Tabs/vertical.js +2 -2
- package/dist/components/TimeValue.js +2 -3
- package/dist/components/Timeline/SequencePropsObserver.js +4 -0
- package/dist/components/Timeline/Timeline.js +49 -81
- package/dist/components/Timeline/TimelineClipboardKeybindings.js +2 -4
- package/dist/components/Timeline/TimelineDeleteKeybindings.js +3 -18
- package/dist/components/Timeline/TimelineDragHandler.js +2 -2
- package/dist/components/Timeline/TimelineExpandedKeyframeRow.js +1 -0
- package/dist/components/Timeline/TimelineLayerChildren.js +12 -9
- package/dist/components/Timeline/TimelineRowChrome.js +11 -3
- package/dist/components/Timeline/TimelineSchemaField.js +8 -4
- package/dist/components/Timeline/TimelineSelection.d.ts +2 -0
- package/dist/components/Timeline/TimelineSelection.js +55 -2
- package/dist/components/Timeline/TimelineSequence.js +75 -17
- package/dist/components/Timeline/TimelineSequenceItem.d.ts +0 -1
- package/dist/components/Timeline/TimelineSequenceItem.js +208 -111
- package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.d.ts +23 -3
- package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.js +73 -25
- package/dist/components/Timeline/TimelineTimeIndicators.js +1 -0
- package/dist/components/Timeline/TimelineZoomControls.js +2 -1
- package/dist/components/Timeline/timeline-field-display-utils.js +8 -5
- package/dist/components/Timeline/use-asset-timeline-context-menu.d.ts +2 -0
- package/dist/components/Timeline/use-asset-timeline-context-menu.js +52 -0
- package/dist/components/TimelineCombobox.d.ts +1 -0
- package/dist/components/TimelineCombobox.js +8 -4
- package/dist/components/TimelineInOutToggle.js +14 -18
- package/dist/components/Transcription/LazyModels.d.ts +1 -0
- package/dist/components/Transcription/LazyModels.js +5 -0
- package/dist/components/Transcription/Models.d.ts +6 -0
- package/dist/components/Transcription/Models.js +18 -0
- package/dist/components/Transcription/TranscriptionModal.d.ts +3 -0
- package/dist/components/Transcription/TranscriptionModal.js +428 -0
- package/dist/components/Transcription/TranscriptionModalWithOptionalWhisper.d.ts +5 -0
- package/dist/components/Transcription/TranscriptionModalWithOptionalWhisper.js +48 -0
- package/dist/components/Transcription/caption-output-name.d.ts +2 -0
- package/dist/components/Transcription/caption-output-name.js +10 -0
- package/dist/components/Transcription/resample-media-to-16-khz.d.ts +6 -0
- package/dist/components/Transcription/resample-media-to-16-khz.js +82 -0
- package/dist/components/Transcription/whisper-languages.d.ts +2 -0
- package/dist/components/Transcription/whisper-languages.js +104 -0
- package/dist/components/Transcription/whisper-webgpu-capability.d.ts +2 -0
- package/dist/components/Transcription/whisper-webgpu-capability.js +7 -0
- package/dist/components/UndoRedoButtons.js +13 -38
- package/dist/components/UpdatesSettings.js +8 -12
- package/dist/components/VideoMatting/LazyModels.d.ts +1 -0
- package/dist/components/VideoMatting/LazyModels.js +5 -0
- package/dist/components/VideoMatting/Models.d.ts +6 -0
- package/dist/components/VideoMatting/Models.js +18 -0
- package/dist/components/VideoMatting/VideoMattingModal.d.ts +3 -0
- package/dist/components/VideoMatting/VideoMattingModal.js +207 -0
- package/dist/components/VideoMatting/VideoMattingModalWithOptionalPackage.d.ts +5 -0
- package/dist/components/VideoMatting/VideoMattingModalWithOptionalPackage.js +46 -0
- package/dist/components/VideoMatting/video-matting-capability.d.ts +2 -0
- package/dist/components/VideoMatting/video-matting-capability.js +7 -0
- package/dist/components/WebMcp.js +439 -22
- package/dist/components/handle-drop.js +3 -2
- package/dist/components/import-assets.d.ts +3 -2
- package/dist/components/import-assets.js +5 -9
- package/dist/components/keyboard-shortcuts.d.ts +17 -1
- package/dist/components/keyboard-shortcuts.js +191 -89
- package/dist/components/public-output-name.d.ts +5 -0
- package/dist/components/public-output-name.js +60 -0
- package/dist/components/use-model-cache-status.d.ts +7 -0
- package/dist/components/use-model-cache-status.js +35 -0
- package/dist/error-overlay/remotion-overlay/CodeFrame.js +29 -18
- package/dist/esm/CaptionQueueProcessor-k0yrm3dj.mjs +211 -0
- package/dist/esm/LazyModels-hc33szyn.mjs +11 -0
- package/dist/esm/LazyModels-sg40rjw6.mjs +11 -0
- package/dist/esm/SyntaxHighlightedSource-3xks91rz.mjs +1236 -0
- package/dist/esm/TranscriptionModal-3ctnxpt6.mjs +1011 -0
- package/dist/esm/VideoMattingModal-b0r7e60n.mjs +374 -0
- package/dist/esm/VideoMattingQueueProcessor-t1hgm2rm.mjs +109 -0
- package/dist/esm/index-1b9skrrd.mjs +142 -0
- package/dist/esm/index-2j3d1g81.mjs +261 -0
- package/dist/esm/index-5zrb1ft4.mjs +39 -0
- package/dist/esm/index-7tt71e8n.mjs +36 -0
- package/dist/esm/index-9qtvmwtx.mjs +1366 -0
- package/dist/esm/index-9x6e1dq0.mjs +428 -0
- package/dist/esm/index-c37kme2v.mjs +46209 -0
- package/dist/esm/index-cw0pnpg5.mjs +50 -0
- package/dist/esm/index-e3zwf3e7.mjs +36 -0
- package/dist/esm/index-er3mh6em.mjs +54688 -0
- package/dist/esm/{chunk-je0h1bgt.js → index-k426ye99.mjs} +4 -1
- package/dist/esm/index-q2epbw93.mjs +423 -0
- package/dist/esm/index-q5xv20xx.mjs +41 -0
- package/dist/esm/{chunk-6jf1natv.js → index-rcv7qkt5.mjs} +18 -1
- package/dist/esm/index-v4tr1bft.mjs +20 -0
- package/dist/esm/index-wbmp5srk.mjs +35 -0
- package/dist/esm/index-yfrysr5f.mjs +1154 -0
- package/dist/esm/index.mjs +45 -933
- package/dist/esm/internals.mjs +13 -114393
- package/dist/esm/previewEntry.mjs +387 -115050
- package/dist/esm/renderEntry.mjs +5 -5
- package/dist/esm/{chunk-m0jqdbkr.js → resolve-composition-component-location-bt2d6qxq.mjs} +1 -1
- package/dist/helpers/colors.d.ts +1 -0
- package/dist/helpers/colors.js +4 -3
- package/dist/helpers/drag-aware-double-click.d.ts +2 -1
- package/dist/helpers/drag-aware-double-click.js +12 -1
- package/dist/helpers/get-asset-metadata.d.ts +1 -0
- package/dist/helpers/get-asset-metadata.js +4 -0
- package/dist/helpers/hoverable.js +8 -0
- package/dist/helpers/inject-css.js +2 -0
- package/dist/helpers/optional-package-dependencies.d.ts +3 -0
- package/dist/helpers/optional-package-dependencies.js +24 -0
- package/dist/helpers/pointer-session.d.ts +6 -0
- package/dist/helpers/pointer-session.js +36 -14
- package/dist/helpers/prism-vsc-dark-plus.d.ts +1 -0
- package/dist/helpers/prism-vsc-dark-plus.js +305 -0
- package/dist/helpers/sequence-node-path-mutations.js +11 -0
- package/dist/helpers/slugify-name.d.ts +1 -0
- package/dist/helpers/slugify-name.js +14 -0
- package/dist/helpers/studio-runtime-config.d.ts +1 -0
- package/dist/helpers/studio-runtime-config.js +6 -1
- package/dist/helpers/use-create-composition.d.ts +1 -0
- package/dist/helpers/use-create-composition.js +12 -7
- package/dist/helpers/use-keybinding.d.ts +9 -3
- package/dist/helpers/use-keybinding.js +8 -9
- package/dist/helpers/use-keyboard-shortcut-label.d.ts +2 -0
- package/dist/helpers/use-keyboard-shortcut-label.js +15 -0
- package/dist/helpers/use-menu-structure.js +59 -14
- package/dist/helpers/use-rename-composition.d.ts +1 -0
- package/dist/helpers/use-rename-composition.js +11 -5
- package/dist/icons/input-props.d.ts +1 -1
- package/dist/icons/input-props.js +2 -2
- package/dist/icons/models.d.ts +4 -0
- package/dist/icons/models.js +7 -0
- package/dist/icons/separation.d.ts +4 -0
- package/dist/icons/separation.js +7 -0
- package/dist/icons/skills.js +1 -1
- package/dist/icons/transcription.d.ts +4 -0
- package/dist/icons/transcription.js +7 -0
- package/dist/icons/upload.js +1 -1
- package/dist/renderEntry.js +2 -2
- package/dist/state/modals.d.ts +14 -2
- package/package.json +35 -21
- package/dist/components/UpdateCheck.d.ts +0 -1
- package/dist/components/UpdateCheck.js +0 -79
- package/dist/esm/chunk-3netyjd9.js +0 -99793
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
// src/components/RenderQueue/context.tsx
|
|
2
|
+
import React, {
|
|
3
|
+
createRef,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useImperativeHandle,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState
|
|
10
|
+
} from "react";
|
|
11
|
+
|
|
12
|
+
// src/components/RenderQueue/client-render-queue.ts
|
|
13
|
+
var compositionRegistry = new Map;
|
|
14
|
+
var registerCompositionForJob = (jobId, compositionRef) => {
|
|
15
|
+
compositionRegistry.set(jobId, compositionRef);
|
|
16
|
+
};
|
|
17
|
+
var getCompositionForJob = (jobId) => {
|
|
18
|
+
return compositionRegistry.get(jobId);
|
|
19
|
+
};
|
|
20
|
+
var cleanupCompositionForJob = (jobId) => {
|
|
21
|
+
compositionRegistry.delete(jobId);
|
|
22
|
+
};
|
|
23
|
+
var generateJobId = () => {
|
|
24
|
+
return `client-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
25
|
+
};
|
|
26
|
+
var clientJobAbortControllers = new Map;
|
|
27
|
+
var getAbortController = (jobId) => {
|
|
28
|
+
let controller = clientJobAbortControllers.get(jobId);
|
|
29
|
+
if (!controller) {
|
|
30
|
+
controller = new AbortController;
|
|
31
|
+
clientJobAbortControllers.set(jobId, controller);
|
|
32
|
+
}
|
|
33
|
+
return controller;
|
|
34
|
+
};
|
|
35
|
+
var deleteAbortController = (jobId) => {
|
|
36
|
+
clientJobAbortControllers.delete(jobId);
|
|
37
|
+
};
|
|
38
|
+
var cancelAbortController = (jobId) => {
|
|
39
|
+
const controller = clientJobAbortControllers.get(jobId);
|
|
40
|
+
if (controller) {
|
|
41
|
+
controller.abort();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// src/components/RenderQueue/context.tsx
|
|
46
|
+
import { jsx } from "react/jsx-runtime";
|
|
47
|
+
var restorePersistedClientRenders = () => {
|
|
48
|
+
const persisted = window.remotion_initialClientRenders ?? [];
|
|
49
|
+
return persisted.map((r) => ({ ...r, status: "done" }));
|
|
50
|
+
};
|
|
51
|
+
var isClientRenderJob = (job) => {
|
|
52
|
+
return job.type === "client-still" || job.type === "client-video";
|
|
53
|
+
};
|
|
54
|
+
var noopString = () => "";
|
|
55
|
+
var noop = () => {
|
|
56
|
+
return;
|
|
57
|
+
};
|
|
58
|
+
var RenderQueueContext = React.createContext({
|
|
59
|
+
jobs: [],
|
|
60
|
+
serverJobs: [],
|
|
61
|
+
clientJobs: [],
|
|
62
|
+
captionJobs: [],
|
|
63
|
+
videoMattingJobs: [],
|
|
64
|
+
addClientStillJob: noopString,
|
|
65
|
+
addClientVideoJob: noopString,
|
|
66
|
+
updateClientJobProgress: noop,
|
|
67
|
+
markClientJobSaving: noop,
|
|
68
|
+
markClientJobDone: noop,
|
|
69
|
+
markClientJobFailed: noop,
|
|
70
|
+
markClientJobCancelled: noop,
|
|
71
|
+
removeClientJob: noop,
|
|
72
|
+
cancelClientJob: noop,
|
|
73
|
+
setProcessJobCallback: noop,
|
|
74
|
+
addCaptionJob: noopString,
|
|
75
|
+
updateCaptionJobProgress: noop,
|
|
76
|
+
markCaptionJobDone: noop,
|
|
77
|
+
markCaptionJobFailed: noop,
|
|
78
|
+
removeCaptionJob: noop,
|
|
79
|
+
setProcessCaptionJobCallback: noop,
|
|
80
|
+
addVideoMattingJob: noopString,
|
|
81
|
+
updateVideoMattingJobProgress: noop,
|
|
82
|
+
markVideoMattingJobDone: noop,
|
|
83
|
+
markVideoMattingJobFailed: noop,
|
|
84
|
+
removeVideoMattingJob: noop,
|
|
85
|
+
setProcessVideoMattingJobCallback: noop,
|
|
86
|
+
getAbortController: () => new AbortController,
|
|
87
|
+
getCompositionForJob: () => {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
var renderJobsRef = createRef();
|
|
92
|
+
var RenderQueueContextProvider = ({ children }) => {
|
|
93
|
+
const [serverJobs, setServerJobs] = useState(window.remotion_initialRenderQueue ?? []);
|
|
94
|
+
const [clientJobs, setClientJobs] = useState(restorePersistedClientRenders);
|
|
95
|
+
const [captionJobs, setCaptionJobs] = useState([]);
|
|
96
|
+
const [videoMattingJobs, setVideoMattingJobs] = useState([]);
|
|
97
|
+
const hasActiveLocalJob = clientJobs.some((job) => job.status === "idle" || job.status === "running" || job.status === "saving") || captionJobs.some((job) => job.status === "idle" || job.status === "running") || videoMattingJobs.some((job) => job.status === "idle" || job.status === "running");
|
|
98
|
+
const [currentlyProcessing, setCurrentlyProcessing] = useState(null);
|
|
99
|
+
const lastLocalJobStartedAt = useRef(clientJobs.reduce((latest, job) => Math.max(latest, job.startedAt), 0));
|
|
100
|
+
const processJobCallbackRef = useRef(null);
|
|
101
|
+
const processCaptionJobCallbackRef = useRef(null);
|
|
102
|
+
const processVideoMattingJobCallbackRef = useRef(null);
|
|
103
|
+
const [processorCallbacksVersion, setProcessorCallbacksVersion] = useState(0);
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (!hasActiveLocalJob) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const preventClose = (event) => {
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
event.returnValue = "";
|
|
111
|
+
};
|
|
112
|
+
window.addEventListener("beforeunload", preventClose);
|
|
113
|
+
return () => window.removeEventListener("beforeunload", preventClose);
|
|
114
|
+
}, [hasActiveLocalJob]);
|
|
115
|
+
const getLocalJobStartedAt = useCallback(() => {
|
|
116
|
+
const startedAt = Math.max(Date.now(), lastLocalJobStartedAt.current + 1);
|
|
117
|
+
lastLocalJobStartedAt.current = startedAt;
|
|
118
|
+
return startedAt;
|
|
119
|
+
}, []);
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (currentlyProcessing) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const nextJob = [...clientJobs, ...captionJobs, ...videoMattingJobs].filter((job) => job.status === "idle").sort((a, b) => a.startedAt - b.startedAt)[0];
|
|
125
|
+
if (!nextJob) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (nextJob.type === "caption") {
|
|
129
|
+
if (!processCaptionJobCallbackRef.current) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
setCurrentlyProcessing(nextJob.id);
|
|
133
|
+
setCaptionJobs((prev) => prev.map((job) => job.id === nextJob.id ? {
|
|
134
|
+
...job,
|
|
135
|
+
status: "running",
|
|
136
|
+
progress: {
|
|
137
|
+
message: "Starting transcription...",
|
|
138
|
+
value: 0
|
|
139
|
+
}
|
|
140
|
+
} : job));
|
|
141
|
+
processCaptionJobCallbackRef.current(nextJob);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (nextJob.type === "video-matting") {
|
|
145
|
+
if (!processVideoMattingJobCallbackRef.current) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
setCurrentlyProcessing(nextJob.id);
|
|
149
|
+
setVideoMattingJobs((prev) => prev.map((job) => job.id === nextJob.id ? {
|
|
150
|
+
...job,
|
|
151
|
+
status: "running",
|
|
152
|
+
progress: {
|
|
153
|
+
detail: null,
|
|
154
|
+
message: "Starting video matting...",
|
|
155
|
+
value: 0
|
|
156
|
+
}
|
|
157
|
+
} : job));
|
|
158
|
+
processVideoMattingJobCallbackRef.current(nextJob);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (!processJobCallbackRef.current) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
setCurrentlyProcessing(nextJob.id);
|
|
165
|
+
setClientJobs((prev) => prev.map((job) => job.id === nextJob.id ? {
|
|
166
|
+
...job,
|
|
167
|
+
status: "running",
|
|
168
|
+
progress: {
|
|
169
|
+
encodedFrames: 0,
|
|
170
|
+
totalFrames: 0,
|
|
171
|
+
doneIn: null,
|
|
172
|
+
renderEstimatedTime: 0,
|
|
173
|
+
progress: 0
|
|
174
|
+
}
|
|
175
|
+
} : job));
|
|
176
|
+
processJobCallbackRef.current(nextJob);
|
|
177
|
+
}, [
|
|
178
|
+
captionJobs,
|
|
179
|
+
clientJobs,
|
|
180
|
+
currentlyProcessing,
|
|
181
|
+
processorCallbacksVersion,
|
|
182
|
+
videoMattingJobs
|
|
183
|
+
]);
|
|
184
|
+
const addClientStillJob = useCallback((params, compositionRef) => {
|
|
185
|
+
const id = generateJobId();
|
|
186
|
+
registerCompositionForJob(id, compositionRef);
|
|
187
|
+
const newJob = {
|
|
188
|
+
...params,
|
|
189
|
+
id,
|
|
190
|
+
startedAt: getLocalJobStartedAt(),
|
|
191
|
+
status: "idle"
|
|
192
|
+
};
|
|
193
|
+
setClientJobs((prev) => [...prev, newJob]);
|
|
194
|
+
return id;
|
|
195
|
+
}, [getLocalJobStartedAt]);
|
|
196
|
+
const addClientVideoJob = useCallback((params, compositionRef) => {
|
|
197
|
+
const id = generateJobId();
|
|
198
|
+
registerCompositionForJob(id, compositionRef);
|
|
199
|
+
const newJob = {
|
|
200
|
+
...params,
|
|
201
|
+
id,
|
|
202
|
+
startedAt: getLocalJobStartedAt(),
|
|
203
|
+
status: "idle"
|
|
204
|
+
};
|
|
205
|
+
setClientJobs((prev) => [...prev, newJob]);
|
|
206
|
+
return id;
|
|
207
|
+
}, [getLocalJobStartedAt]);
|
|
208
|
+
const updateClientJobProgress = useCallback((jobId, progress) => {
|
|
209
|
+
setClientJobs((prev) => prev.map((job) => job.id === jobId ? { ...job, status: "running", progress } : job));
|
|
210
|
+
}, []);
|
|
211
|
+
const markClientJobSaving = useCallback((jobId) => {
|
|
212
|
+
setClientJobs((prev) => prev.map((job) => job.id === jobId ? { ...job, status: "saving" } : job));
|
|
213
|
+
}, []);
|
|
214
|
+
const markClientJobDone = useCallback((jobId, metadata, getBlob) => {
|
|
215
|
+
deleteAbortController(jobId);
|
|
216
|
+
cleanupCompositionForJob(jobId);
|
|
217
|
+
setClientJobs((prev) => prev.map((job) => job.id === jobId ? { ...job, status: "done", metadata, getBlob } : job));
|
|
218
|
+
setCurrentlyProcessing((current) => current === jobId ? null : current);
|
|
219
|
+
}, []);
|
|
220
|
+
const markClientJobFailed = useCallback((jobId, error) => {
|
|
221
|
+
deleteAbortController(jobId);
|
|
222
|
+
cleanupCompositionForJob(jobId);
|
|
223
|
+
setClientJobs((prev) => prev.map((job) => job.id === jobId ? {
|
|
224
|
+
...job,
|
|
225
|
+
status: "failed",
|
|
226
|
+
error: { message: error.message, stack: error.stack }
|
|
227
|
+
} : job));
|
|
228
|
+
setCurrentlyProcessing((current) => current === jobId ? null : current);
|
|
229
|
+
}, []);
|
|
230
|
+
const markClientJobCancelled = useCallback((jobId) => {
|
|
231
|
+
deleteAbortController(jobId);
|
|
232
|
+
cleanupCompositionForJob(jobId);
|
|
233
|
+
setClientJobs((prev) => prev.map((job) => job.id === jobId ? {
|
|
234
|
+
...job,
|
|
235
|
+
status: "cancelled"
|
|
236
|
+
} : job));
|
|
237
|
+
setCurrentlyProcessing((current) => current === jobId ? null : current);
|
|
238
|
+
}, []);
|
|
239
|
+
const removeClientJob = useCallback((jobId) => {
|
|
240
|
+
setClientJobs((prev) => {
|
|
241
|
+
const jobToRemove = prev.find((j) => j.id === jobId);
|
|
242
|
+
if (jobToRemove?.status === "running") {
|
|
243
|
+
return prev;
|
|
244
|
+
}
|
|
245
|
+
deleteAbortController(jobId);
|
|
246
|
+
cleanupCompositionForJob(jobId);
|
|
247
|
+
return prev.filter((job) => job.id !== jobId);
|
|
248
|
+
});
|
|
249
|
+
}, []);
|
|
250
|
+
const cancelClientJob = useCallback((jobId) => {
|
|
251
|
+
cancelAbortController(jobId);
|
|
252
|
+
}, []);
|
|
253
|
+
const setProcessJobCallback = useCallback((callback) => {
|
|
254
|
+
processJobCallbackRef.current = callback;
|
|
255
|
+
setProcessorCallbacksVersion((version) => version + 1);
|
|
256
|
+
}, []);
|
|
257
|
+
const addCaptionJob = useCallback((params) => {
|
|
258
|
+
const id = `caption-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
259
|
+
const newJob = {
|
|
260
|
+
...params,
|
|
261
|
+
id,
|
|
262
|
+
type: "caption",
|
|
263
|
+
startedAt: getLocalJobStartedAt(),
|
|
264
|
+
status: "idle"
|
|
265
|
+
};
|
|
266
|
+
setCaptionJobs((prev) => [...prev, newJob]);
|
|
267
|
+
return id;
|
|
268
|
+
}, [getLocalJobStartedAt]);
|
|
269
|
+
const updateCaptionJobProgress = useCallback((jobId, progress) => {
|
|
270
|
+
setCaptionJobs((prev) => prev.map((job) => job.id === jobId ? { ...job, status: "running", progress } : job));
|
|
271
|
+
}, []);
|
|
272
|
+
const markCaptionJobDone = useCallback((jobId, captionCount) => {
|
|
273
|
+
setCaptionJobs((prev) => prev.map((job) => job.id === jobId ? { ...job, status: "done", captionCount } : job));
|
|
274
|
+
setCurrentlyProcessing((current) => current === jobId ? null : current);
|
|
275
|
+
}, []);
|
|
276
|
+
const markCaptionJobFailed = useCallback((jobId, error) => {
|
|
277
|
+
setCaptionJobs((prev) => prev.map((job) => job.id === jobId ? {
|
|
278
|
+
...job,
|
|
279
|
+
status: "failed",
|
|
280
|
+
error: { message: error.message, stack: error.stack }
|
|
281
|
+
} : job));
|
|
282
|
+
setCurrentlyProcessing((current) => current === jobId ? null : current);
|
|
283
|
+
}, []);
|
|
284
|
+
const removeCaptionJob = useCallback((jobId) => {
|
|
285
|
+
setCaptionJobs((prev) => {
|
|
286
|
+
const jobToRemove = prev.find((job) => job.id === jobId);
|
|
287
|
+
if (jobToRemove?.status === "running") {
|
|
288
|
+
return prev;
|
|
289
|
+
}
|
|
290
|
+
return prev.filter((job) => job.id !== jobId);
|
|
291
|
+
});
|
|
292
|
+
}, []);
|
|
293
|
+
const setProcessCaptionJobCallback = useCallback((callback) => {
|
|
294
|
+
processCaptionJobCallbackRef.current = callback;
|
|
295
|
+
setProcessorCallbacksVersion((version) => version + 1);
|
|
296
|
+
}, []);
|
|
297
|
+
const addVideoMattingJob = useCallback((params) => {
|
|
298
|
+
const id = `video-matting-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
299
|
+
setVideoMattingJobs((prev) => [
|
|
300
|
+
...prev,
|
|
301
|
+
{
|
|
302
|
+
...params,
|
|
303
|
+
id,
|
|
304
|
+
type: "video-matting",
|
|
305
|
+
startedAt: getLocalJobStartedAt(),
|
|
306
|
+
status: "idle"
|
|
307
|
+
}
|
|
308
|
+
]);
|
|
309
|
+
return id;
|
|
310
|
+
}, [getLocalJobStartedAt]);
|
|
311
|
+
const updateVideoMattingJobProgress = useCallback((jobId, progress) => {
|
|
312
|
+
setVideoMattingJobs((prev) => prev.map((job) => job.id === jobId ? { ...job, status: "running", progress } : job));
|
|
313
|
+
}, []);
|
|
314
|
+
const markVideoMattingJobDone = useCallback((jobId) => {
|
|
315
|
+
setVideoMattingJobs((prev) => prev.map((job) => job.id === jobId ? { ...job, status: "done" } : job));
|
|
316
|
+
setCurrentlyProcessing((current) => current === jobId ? null : current);
|
|
317
|
+
}, []);
|
|
318
|
+
const markVideoMattingJobFailed = useCallback((jobId, error) => {
|
|
319
|
+
setVideoMattingJobs((prev) => prev.map((job) => job.id === jobId ? {
|
|
320
|
+
...job,
|
|
321
|
+
status: "failed",
|
|
322
|
+
error: { message: error.message, stack: error.stack }
|
|
323
|
+
} : job));
|
|
324
|
+
setCurrentlyProcessing((current) => current === jobId ? null : current);
|
|
325
|
+
}, []);
|
|
326
|
+
const removeVideoMattingJob = useCallback((jobId) => {
|
|
327
|
+
setVideoMattingJobs((prev) => {
|
|
328
|
+
const jobToRemove = prev.find((job) => job.id === jobId);
|
|
329
|
+
if (jobToRemove?.status === "running") {
|
|
330
|
+
return prev;
|
|
331
|
+
}
|
|
332
|
+
return prev.filter((job) => job.id !== jobId);
|
|
333
|
+
});
|
|
334
|
+
}, []);
|
|
335
|
+
const setProcessVideoMattingJobCallback = useCallback((callback) => {
|
|
336
|
+
processVideoMattingJobCallbackRef.current = callback;
|
|
337
|
+
setProcessorCallbacksVersion((version) => version + 1);
|
|
338
|
+
}, []);
|
|
339
|
+
useImperativeHandle(renderJobsRef, () => ({
|
|
340
|
+
updateRenderJobs: (newJobs) => {
|
|
341
|
+
setServerJobs(newJobs);
|
|
342
|
+
},
|
|
343
|
+
updateClientRenders: (renders) => {
|
|
344
|
+
setClientJobs((prev) => {
|
|
345
|
+
const existingIds = new Set(prev.map((j) => j.id));
|
|
346
|
+
const updatedPrev = prev.map((job) => {
|
|
347
|
+
const updated = renders.find((r) => r.id === job.id);
|
|
348
|
+
if (updated && job.status === "done") {
|
|
349
|
+
return {
|
|
350
|
+
...job,
|
|
351
|
+
deletedOutputLocation: updated.deletedOutputLocation,
|
|
352
|
+
metadata: updated.metadata
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
return job;
|
|
356
|
+
});
|
|
357
|
+
const newJobs = renders.filter((r) => !existingIds.has(r.id)).map((r) => ({ ...r, status: "done" }));
|
|
358
|
+
return [...updatedPrev, ...newJobs];
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}), []);
|
|
362
|
+
const value = useMemo(() => {
|
|
363
|
+
return {
|
|
364
|
+
jobs: [...serverJobs, ...clientJobs].sort((a, b) => a.startedAt - b.startedAt),
|
|
365
|
+
serverJobs,
|
|
366
|
+
clientJobs,
|
|
367
|
+
captionJobs,
|
|
368
|
+
videoMattingJobs,
|
|
369
|
+
addClientStillJob,
|
|
370
|
+
addClientVideoJob,
|
|
371
|
+
updateClientJobProgress,
|
|
372
|
+
markClientJobSaving,
|
|
373
|
+
markClientJobDone,
|
|
374
|
+
markClientJobFailed,
|
|
375
|
+
markClientJobCancelled,
|
|
376
|
+
removeClientJob,
|
|
377
|
+
cancelClientJob,
|
|
378
|
+
setProcessJobCallback,
|
|
379
|
+
addCaptionJob,
|
|
380
|
+
updateCaptionJobProgress,
|
|
381
|
+
markCaptionJobDone,
|
|
382
|
+
markCaptionJobFailed,
|
|
383
|
+
removeCaptionJob,
|
|
384
|
+
setProcessCaptionJobCallback,
|
|
385
|
+
addVideoMattingJob,
|
|
386
|
+
updateVideoMattingJobProgress,
|
|
387
|
+
markVideoMattingJobDone,
|
|
388
|
+
markVideoMattingJobFailed,
|
|
389
|
+
removeVideoMattingJob,
|
|
390
|
+
setProcessVideoMattingJobCallback,
|
|
391
|
+
getAbortController,
|
|
392
|
+
getCompositionForJob
|
|
393
|
+
};
|
|
394
|
+
}, [
|
|
395
|
+
serverJobs,
|
|
396
|
+
clientJobs,
|
|
397
|
+
captionJobs,
|
|
398
|
+
videoMattingJobs,
|
|
399
|
+
addClientStillJob,
|
|
400
|
+
addClientVideoJob,
|
|
401
|
+
updateClientJobProgress,
|
|
402
|
+
markClientJobSaving,
|
|
403
|
+
markClientJobDone,
|
|
404
|
+
markClientJobFailed,
|
|
405
|
+
markClientJobCancelled,
|
|
406
|
+
removeClientJob,
|
|
407
|
+
cancelClientJob,
|
|
408
|
+
setProcessJobCallback,
|
|
409
|
+
addCaptionJob,
|
|
410
|
+
updateCaptionJobProgress,
|
|
411
|
+
markCaptionJobDone,
|
|
412
|
+
markCaptionJobFailed,
|
|
413
|
+
removeCaptionJob,
|
|
414
|
+
setProcessCaptionJobCallback,
|
|
415
|
+
addVideoMattingJob,
|
|
416
|
+
updateVideoMattingJobProgress,
|
|
417
|
+
markVideoMattingJobDone,
|
|
418
|
+
markVideoMattingJobFailed,
|
|
419
|
+
removeVideoMattingJob,
|
|
420
|
+
setProcessVideoMattingJobCallback
|
|
421
|
+
]);
|
|
422
|
+
return /* @__PURE__ */ jsx(RenderQueueContext.Provider, {
|
|
423
|
+
value,
|
|
424
|
+
children
|
|
425
|
+
});
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
export { isClientRenderJob, RenderQueueContext, renderJobsRef, RenderQueueContextProvider };
|