@remotion/studio 4.0.442 → 4.0.444

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.
Files changed (38) hide show
  1. package/dist/components/CanvasOrLoading.js +5 -0
  2. package/dist/components/Editor.js +10 -2
  3. package/dist/components/MenuBuildIndicator.js +58 -3
  4. package/dist/components/MenuCompositionName.d.ts +2 -0
  5. package/dist/components/MenuCompositionName.js +80 -0
  6. package/dist/components/RenderErrorContext.d.ts +4 -0
  7. package/dist/components/RenderErrorContext.js +7 -0
  8. package/dist/components/RenderModal/RenderModalJSONPropsEditor.js +7 -5
  9. package/dist/components/RenderModal/SchemaEditor/SchemaEditor.js +5 -1
  10. package/dist/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +5 -3
  11. package/dist/components/Timeline/TimelineListItem.js +71 -8
  12. package/dist/components/Timeline/TimelineRotationField.js +11 -0
  13. package/dist/components/Timeline/TimelineSequence.js +1 -1
  14. package/dist/components/Timeline/TimelineStack/index.js +2 -1
  15. package/dist/components/Timeline/TimelineVideoInfo.d.ts +4 -0
  16. package/dist/components/Timeline/TimelineVideoInfo.js +32 -30
  17. package/dist/components/Timeline/use-sequence-props-subscription.d.ts +1 -1
  18. package/dist/components/Timeline/use-sequence-props-subscription.js +25 -6
  19. package/dist/error-overlay/react-overlay/listen-to-runtime-errors.js +1 -5
  20. package/dist/error-overlay/remotion-overlay/CopyStackTrace.d.ts +5 -0
  21. package/dist/error-overlay/remotion-overlay/CopyStackTrace.js +50 -0
  22. package/dist/error-overlay/remotion-overlay/ErrorDisplay.js +16 -13
  23. package/dist/error-overlay/remotion-overlay/MediaPlaybackErrorExplainer.d.ts +4 -0
  24. package/dist/error-overlay/remotion-overlay/MediaPlaybackErrorExplainer.js +87 -0
  25. package/dist/esm/{chunk-j8c13fkw.js → chunk-1zvzzrkf.js} +3589 -3290
  26. package/dist/esm/internals.mjs +3589 -3290
  27. package/dist/esm/previewEntry.mjs +3687 -3392
  28. package/dist/esm/renderEntry.mjs +1 -1
  29. package/dist/helpers/frame-database.d.ts +2 -2
  30. package/dist/helpers/frame-database.js +36 -25
  31. package/dist/helpers/timeline-layout.d.ts +4 -1
  32. package/dist/helpers/timeline-layout.js +10 -4
  33. package/dist/helpers/use-max-media-duration.js +1 -1
  34. package/package.json +9 -9
  35. package/dist/components/OpenEditorButton.d.ts +0 -3
  36. package/dist/components/OpenEditorButton.js +0 -67
  37. package/dist/error-overlay/remotion-overlay/CompositionIdsDropdown.d.ts +0 -5
  38. package/dist/error-overlay/remotion-overlay/CompositionIdsDropdown.js +0 -108
@@ -11,6 +11,7 @@ const Canvas_1 = require("./Canvas");
11
11
  const FramePersistor_1 = require("./FramePersistor");
12
12
  const is_menu_item_1 = require("./Menu/is-menu-item");
13
13
  const RefreshCompositionOverlay_1 = require("./RefreshCompositionOverlay");
14
+ const RenderErrorContext_1 = require("./RenderErrorContext");
14
15
  const RunningCalculateMetadata_1 = require("./RunningCalculateMetadata");
15
16
  const imperative_state_1 = require("./Timeline/imperative-state");
16
17
  const timeline_scroll_logic_1 = require("./Timeline/timeline-scroll-logic");
@@ -28,6 +29,7 @@ const CanvasOrLoading = ({ size }) => {
28
29
  const resolved = remotion_1.Internals.useResolvedVideoConfig(null);
29
30
  const { setZoom } = (0, react_1.useContext)(timeline_zoom_1.TimelineZoomCtx);
30
31
  const { canvasContent } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
32
+ const { error: renderError } = (0, react_1.useContext)(RenderErrorContext_1.RenderErrorContext);
31
33
  (0, react_1.useEffect)(() => {
32
34
  if ((resolved === null || resolved === void 0 ? void 0 : resolved.type) !== 'success' &&
33
35
  (resolved === null || resolved === void 0 ? void 0 : resolved.type) !== 'success-and-refreshing') {
@@ -42,6 +44,9 @@ const CanvasOrLoading = ({ size }) => {
42
44
  });
43
45
  });
44
46
  }, [resolved, setZoom]);
47
+ if (renderError) {
48
+ return jsx_runtime_1.jsx(ErrorLoading, { error: renderError });
49
+ }
45
50
  if (!canvasContent) {
46
51
  const compname = window.location.pathname.replace('/', '');
47
52
  return (jsx_runtime_1.jsx("div", { style: container, className: "css-reset", children: jsx_runtime_1.jsxs("div", { style: RunningCalculateMetadata_1.loaderLabel, children: ["Composition with ID ", compname, " not found."] }) }));
@@ -48,6 +48,7 @@ const ForceSpecificCursor_1 = require("./ForceSpecificCursor");
48
48
  const GlobalKeybindings_1 = require("./GlobalKeybindings");
49
49
  const Modals_1 = require("./Modals");
50
50
  const NotificationCenter_1 = require("./Notifications/NotificationCenter");
51
+ const RenderErrorContext_1 = require("./RenderErrorContext");
51
52
  const TopPanel_1 = require("./TopPanel");
52
53
  const background = {
53
54
  backgroundColor: colors_1.BACKGROUND,
@@ -83,10 +84,17 @@ const Editor = ({ Root, readOnlyStudio }) => {
83
84
  const MemoRoot = (0, react_1.useMemo)(() => {
84
85
  return react_1.default.memo(Root);
85
86
  }, [Root]);
87
+ const [renderError, setRenderError] = (0, react_1.useState)(null);
88
+ const clearError = (0, react_1.useCallback)(() => {
89
+ setRenderError(null);
90
+ }, []);
91
+ const compositionRenderErrorContextValue = (0, react_1.useMemo)(() => ({ setError: setRenderError, clearError }), [clearError]);
92
+ const renderErrorContextValue = (0, react_1.useMemo)(() => ({ error: renderError }), [renderError]);
86
93
  return (jsx_runtime_1.jsx(z_index_1.HigherZIndex, { onEscape: noop_1.noop, onOutsideClick: noop_1.noop, children: jsx_runtime_1.jsxs(timeline_zoom_1.TimelineZoomContext, { children: [
87
94
  jsx_runtime_1.jsxs(remotion_1.Internals.CurrentScaleContext.Provider, { value: value, children: [
88
- jsx_runtime_1.jsx(ForceSpecificCursor_1.ForceSpecificCursor, {}), jsx_runtime_1.jsxs("div", { style: background, children: [canvasMounted ? jsx_runtime_1.jsx(MemoRoot, {}) : null, jsx_runtime_1.jsxs(remotion_1.Internals.CanUseRemotionHooksProvider, { children: [
89
- jsx_runtime_1.jsx(EditorContent_1.EditorContent, { readOnlyStudio: readOnlyStudio, children: jsx_runtime_1.jsx(TopPanel_1.TopPanel, { drawRef: canvas_ref_1.drawRef, bufferStateDelayInMilliseconds: exports.BUFFER_STATE_DELAY_IN_MILLISECONDS, onMounted: onMounted, readOnlyStudio: readOnlyStudio }) }), jsx_runtime_1.jsx(GlobalKeybindings_1.GlobalKeybindings, {})
95
+ jsx_runtime_1.jsx(ForceSpecificCursor_1.ForceSpecificCursor, {}), jsx_runtime_1.jsxs("div", { style: background, children: [
96
+ jsx_runtime_1.jsx(remotion_1.Internals.CompositionRenderErrorContext.Provider, { value: compositionRenderErrorContextValue, children: canvasMounted ? jsx_runtime_1.jsx(MemoRoot, {}) : null }), jsx_runtime_1.jsxs(remotion_1.Internals.CanUseRemotionHooksProvider, { children: [
97
+ jsx_runtime_1.jsx(RenderErrorContext_1.RenderErrorContext.Provider, { value: renderErrorContextValue, children: jsx_runtime_1.jsx(EditorContent_1.EditorContent, { readOnlyStudio: readOnlyStudio, children: jsx_runtime_1.jsx(TopPanel_1.TopPanel, { drawRef: canvas_ref_1.drawRef, bufferStateDelayInMilliseconds: exports.BUFFER_STATE_DELAY_IN_MILLISECONDS, onMounted: onMounted, readOnlyStudio: readOnlyStudio }) }) }), jsx_runtime_1.jsx(GlobalKeybindings_1.GlobalKeybindings, {})
90
98
  ] })
91
99
  ] })
92
100
  ] }), jsx_runtime_1.jsx(Modals_1.Modals, { readOnlyStudio: readOnlyStudio }), jsx_runtime_1.jsx(NotificationCenter_1.NotificationCenter, {})
@@ -4,8 +4,11 @@ exports.MenuBuildIndicator = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const client_id_1 = require("../helpers/client-id");
7
+ const get_git_menu_item_1 = require("../helpers/get-git-menu-item");
8
+ const open_in_editor_1 = require("../helpers/open-in-editor");
7
9
  const layout_1 = require("./layout");
8
- const OpenEditorButton_1 = require("./OpenEditorButton");
10
+ const MenuCompositionName_1 = require("./MenuCompositionName");
11
+ const NotificationCenter_1 = require("./Notifications/NotificationCenter");
9
12
  const Spinner_1 = require("./Spinner");
10
13
  const cwd = {
11
14
  fontSize: 13,
@@ -25,10 +28,61 @@ const noSpinner = {
25
28
  position: 'relative',
26
29
  width: spinnerSize,
27
30
  };
31
+ const projectNameLinkBase = {
32
+ color: 'inherit',
33
+ textDecoration: 'none',
34
+ cursor: 'pointer',
35
+ fontSize: 'inherit',
36
+ textUnderlineOffset: 2,
37
+ };
38
+ const projectNameLink = {
39
+ ...projectNameLinkBase,
40
+ };
41
+ const projectNameLinkHovered = {
42
+ ...projectNameLinkBase,
43
+ textDecoration: 'underline',
44
+ };
28
45
  const MenuBuildIndicator = () => {
29
46
  const [isBuilding, setIsBuilding] = (0, react_1.useState)(false);
47
+ const [projectNameHovered, setProjectNameHovered] = (0, react_1.useState)(false);
30
48
  const ctx = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx).previewServerState;
31
- const showButton = window.remotion_editorName && ctx.type === 'connected';
49
+ const showEditorLink = window.remotion_editorName && ctx.type === 'connected';
50
+ const showGitLink = !showEditorLink && Boolean(window.remotion_gitSource);
51
+ const handleProjectNameClick = (0, react_1.useCallback)(async () => {
52
+ if (showEditorLink) {
53
+ await (0, open_in_editor_1.openInEditor)({
54
+ originalFileName: `${window.remotion_cwd}`,
55
+ originalLineNumber: 1,
56
+ originalColumnNumber: 1,
57
+ originalFunctionName: null,
58
+ originalScriptCode: null,
59
+ })
60
+ .then((res) => res.json())
61
+ .then(({ success }) => {
62
+ if (!success) {
63
+ (0, NotificationCenter_1.showNotification)(`Could not open ${window.remotion_editorName}`, 2000);
64
+ }
65
+ })
66
+ .catch((err) => {
67
+ // eslint-disable-next-line no-console
68
+ console.error(err);
69
+ (0, NotificationCenter_1.showNotification)(`Could not open ${window.remotion_editorName}`, 2000);
70
+ });
71
+ }
72
+ else if (showGitLink) {
73
+ window.open((0, get_git_menu_item_1.getGitSourceBranchUrl)(window.remotion_gitSource), '_blank');
74
+ }
75
+ }, [showEditorLink, showGitLink]);
76
+ const projectNameTitle = (0, react_1.useMemo)(() => {
77
+ if (showEditorLink) {
78
+ return `Open in ${window.remotion_editorName}`;
79
+ }
80
+ if (showGitLink) {
81
+ return `Open ${(0, get_git_menu_item_1.getGitSourceName)(window.remotion_gitSource)} Repo`;
82
+ }
83
+ return undefined;
84
+ }, [showEditorLink, showGitLink]);
85
+ const isClickable = showEditorLink || showGitLink;
32
86
  (0, react_1.useEffect)(() => {
33
87
  window.remotion_isBuilding = () => {
34
88
  setIsBuilding(true);
@@ -41,6 +95,7 @@ const MenuBuildIndicator = () => {
41
95
  window.remotion_finishedBuilding = undefined;
42
96
  };
43
97
  }, []);
44
- return (jsx_runtime_1.jsxs("div", { style: cwd, title: window.remotion_cwd, children: [showButton ? jsx_runtime_1.jsx(layout_1.Spacing, { x: 2 }) : null, isBuilding ? (jsx_runtime_1.jsx("div", { style: spinner, children: jsx_runtime_1.jsx(Spinner_1.Spinner, { duration: 0.5, size: spinnerSize }) })) : (jsx_runtime_1.jsx("div", { style: noSpinner })), showButton ? jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }) : null, window.remotion_projectName, showButton ? jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.25 }) : null, showButton ? (jsx_runtime_1.jsx(OpenEditorButton_1.OpenEditorButton, { type: "editor" })) : window.remotion_gitSource ? (jsx_runtime_1.jsx(OpenEditorButton_1.OpenEditorButton, { type: "git" })) : null] }));
98
+ return (jsx_runtime_1.jsxs("div", { style: cwd, title: window.remotion_cwd, children: [isClickable ? jsx_runtime_1.jsx(layout_1.Spacing, { x: 2 }) : null, isBuilding ? (jsx_runtime_1.jsx("div", { style: spinner, children: jsx_runtime_1.jsx(Spinner_1.Spinner, { duration: 0.5, size: spinnerSize }) })) : (jsx_runtime_1.jsx("div", { style: noSpinner })), isClickable ? jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }) : null, isClickable ? (jsx_runtime_1.jsx("a", { style: projectNameHovered ? projectNameLinkHovered : projectNameLink, title: projectNameTitle, onClick: handleProjectNameClick, onPointerEnter: () => setProjectNameHovered(true), onPointerLeave: () => setProjectNameHovered(false), children: window.remotion_projectName })) : (window.remotion_projectName), jsx_runtime_1.jsx(MenuCompositionName_1.MenuCompositionName, {})
99
+ ] }));
45
100
  };
46
101
  exports.MenuBuildIndicator = MenuBuildIndicator;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const MenuCompositionName: React.FC;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MenuCompositionName = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const remotion_1 = require("remotion");
7
+ const client_id_1 = require("../helpers/client-id");
8
+ const colors_1 = require("../helpers/colors");
9
+ const open_in_editor_1 = require("../helpers/open-in-editor");
10
+ const NotificationCenter_1 = require("./Notifications/NotificationCenter");
11
+ const use_resolved_stack_1 = require("./Timeline/use-resolved-stack");
12
+ const baseStyle = {
13
+ color: 'inherit',
14
+ textDecoration: 'none',
15
+ fontSize: 'inherit',
16
+ textUnderlineOffset: 2,
17
+ };
18
+ const compositionNameStyle = {
19
+ ...baseStyle,
20
+ cursor: 'default',
21
+ };
22
+ const clickableStyle = {
23
+ ...baseStyle,
24
+ cursor: 'pointer',
25
+ };
26
+ const clickableHoveredStyle = {
27
+ ...clickableStyle,
28
+ textDecoration: 'underline',
29
+ };
30
+ const slashStyle = {
31
+ color: colors_1.LIGHT_TEXT,
32
+ marginInline: 4,
33
+ position: 'relative',
34
+ top: 1,
35
+ };
36
+ const MenuCompositionName = () => {
37
+ var _a;
38
+ const { canvasContent, compositions } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
39
+ const connectionStatus = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx)
40
+ .previewServerState.type;
41
+ const [opening, setOpening] = (0, react_1.useState)(false);
42
+ const [hovered, setHovered] = (0, react_1.useState)(false);
43
+ const composition = (0, react_1.useMemo)(() => {
44
+ var _a;
45
+ if (canvasContent === null || canvasContent.type !== 'composition') {
46
+ return null;
47
+ }
48
+ return ((_a = compositions.find((c) => c.id === canvasContent.compositionId)) !== null && _a !== void 0 ? _a : null);
49
+ }, [canvasContent, compositions]);
50
+ const resolvedLocation = (0, use_resolved_stack_1.useResolvedStack)((_a = composition === null || composition === void 0 ? void 0 : composition.stack) !== null && _a !== void 0 ? _a : null);
51
+ const canOpen = resolvedLocation &&
52
+ window.remotion_editorName &&
53
+ connectionStatus === 'connected';
54
+ const handleClick = (0, react_1.useCallback)(async () => {
55
+ if (!canOpen || !resolvedLocation) {
56
+ return;
57
+ }
58
+ setOpening(true);
59
+ try {
60
+ await (0, open_in_editor_1.openOriginalPositionInEditor)(resolvedLocation);
61
+ }
62
+ catch (err) {
63
+ (0, NotificationCenter_1.showNotification)(err.message, 2000);
64
+ }
65
+ finally {
66
+ setOpening(false);
67
+ }
68
+ }, [canOpen, resolvedLocation]);
69
+ if (!composition) {
70
+ return null;
71
+ }
72
+ return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
73
+ jsx_runtime_1.jsx("span", { style: slashStyle, children: "/" }), jsx_runtime_1.jsx("a", { style: canOpen && !opening
74
+ ? hovered
75
+ ? clickableHoveredStyle
76
+ : clickableStyle
77
+ : compositionNameStyle, title: canOpen ? `Open in ${window.remotion_editorName}` : composition.id, onClick: handleClick, onPointerEnter: () => setHovered(true), onPointerLeave: () => setHovered(false), children: composition.id })
78
+ ] }));
79
+ };
80
+ exports.MenuCompositionName = MenuCompositionName;
@@ -0,0 +1,4 @@
1
+ export type RenderErrorContextType = {
2
+ error: Error | null;
3
+ };
4
+ export declare const RenderErrorContext: import("react").Context<RenderErrorContextType>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RenderErrorContext = void 0;
4
+ const react_1 = require("react");
5
+ exports.RenderErrorContext = (0, react_1.createContext)({
6
+ error: null,
7
+ });
@@ -112,11 +112,13 @@ const RenderModalJSONPropsEditor = ({ setValue, value, defaultProps, onSave, ser
112
112
  };
113
113
  }, [subscribeToEvent, compositionId, schema]);
114
114
  (0, react_1.useEffect)(() => {
115
- if (localValue.validJSON && (0, deep_equal_1.deepEqual)(value, localValue.value)) {
116
- return;
117
- }
118
- setLocalValue(parseJS(value, schema));
119
- }, [value, schema, localValue]);
115
+ setLocalValue((prev) => {
116
+ if (prev.validJSON && (0, deep_equal_1.deepEqual)(value, prev.value)) {
117
+ return prev;
118
+ }
119
+ return parseJS(value, schema);
120
+ });
121
+ }, [value, schema]);
120
122
  const onPretty = (0, react_1.useCallback)(() => {
121
123
  if (!localValue.validJSON) {
122
124
  return;
@@ -7,6 +7,7 @@ const is_menu_item_1 = require("../../Menu/is-menu-item");
7
7
  const SchemaErrorMessages_1 = require("./SchemaErrorMessages");
8
8
  const scroll_to_default_props_path_1 = require("./scroll-to-default-props-path");
9
9
  const zod_schema_type_1 = require("./zod-schema-type");
10
+ const ZodDiscriminatedUnionEditor_1 = require("./ZodDiscriminatedUnionEditor");
10
11
  const ZodObjectEditor_1 = require("./ZodObjectEditor");
11
12
  const scrollable = {
12
13
  display: 'flex',
@@ -19,9 +20,12 @@ const SchemaEditor = ({ schema, value, setValue }) => {
19
20
  throw new Error('expected zod');
20
21
  }
21
22
  const typeName = (0, zod_schema_type_1.getZodSchemaType)(schema);
22
- if (typeName !== 'object') {
23
+ if (typeName !== 'object' && typeName !== 'discriminatedUnion') {
23
24
  return jsx_runtime_1.jsx(SchemaErrorMessages_1.TopLevelZodValue, { typeReceived: typeName });
24
25
  }
26
+ if (typeName === 'discriminatedUnion') {
27
+ return (jsx_runtime_1.jsx("div", { ref: scroll_to_default_props_path_1.defaultPropsEditorScrollableAreaRef, style: scrollable, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: jsx_runtime_1.jsx(ZodDiscriminatedUnionEditor_1.ZodDiscriminatedUnionEditor, { schema: schema, setValue: setValue, value: value, mayPad: true, jsonPath: [], onRemove: null }) }));
28
+ }
25
29
  return (jsx_runtime_1.jsx("div", { ref: scroll_to_default_props_path_1.defaultPropsEditorScrollableAreaRef, style: scrollable, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: jsx_runtime_1.jsx(ZodObjectEditor_1.ZodObjectEditor, { discriminatedUnionReplacement: null, value: value, setValue: setValue, jsonPath: [], schema: schema, onRemove: null, mayPad: true }) }));
26
30
  };
27
31
  exports.SchemaEditor = SchemaEditor;
@@ -78,9 +78,11 @@ const InvalidSchema = ({ zodValidationResult }) => {
78
78
  exports.InvalidSchema = InvalidSchema;
79
79
  const TopLevelZodValue = ({ typeReceived }) => {
80
80
  return (jsx_runtime_1.jsxs("div", { style: explainer, children: [
81
- jsx_runtime_1.jsxs("div", { style: errorExplanation, children: ["The top-level type of the schema must be a pure", ' ', jsx_runtime_1.jsx("code", { style: codeSnippet, children: "z.object" }),
82
- ". Instead got a schema of type", ' ', jsx_runtime_1.jsx("code", { style: codeSnippet, children: typeReceived })
83
- ] }), jsx_runtime_1.jsx(layout_1.Spacing, { y: 1 }), jsx_runtime_1.jsx("div", { style: errorExplanation, children: "Fix the schema by changing the top-level Zod type to an object." }), jsx_runtime_1.jsx(layout_1.Spacing, { y: 2, block: true }), jsx_runtime_1.jsx(Button_1.Button, { onClick: openDocs, children: "Learn more" })
81
+ jsx_runtime_1.jsxs("div", { style: errorExplanation, children: ["The top-level type of the schema must be", ' ', jsx_runtime_1.jsx("code", { style: codeSnippet, children: "z.object()" }),
82
+ " or", ' ', jsx_runtime_1.jsx("code", { style: codeSnippet, children: "z.discriminatedUnion()" }),
83
+ ". Instead got a schema of type ",
84
+ jsx_runtime_1.jsx("code", { style: codeSnippet, children: typeReceived })
85
+ ] }), jsx_runtime_1.jsx(layout_1.Spacing, { y: 1 }), jsx_runtime_1.jsx("div", { style: errorExplanation, children: "Fix the schema by changing the top-level Zod type to an object or discriminated union." }), jsx_runtime_1.jsx(layout_1.Spacing, { y: 2, block: true }), jsx_runtime_1.jsx(Button_1.Button, { onClick: openDocs, children: "Learn more" })
84
86
  ] }));
85
87
  };
86
88
  exports.TopLevelZodValue = TopLevelZodValue;
@@ -7,7 +7,10 @@ const remotion_1 = require("remotion");
7
7
  const client_id_1 = require("../../helpers/client-id");
8
8
  const colors_1 = require("../../helpers/colors");
9
9
  const timeline_layout_1 = require("../../helpers/timeline-layout");
10
+ const call_api_1 = require("../call-api");
11
+ const ContextMenu_1 = require("../ContextMenu");
10
12
  const ExpandedTracksProvider_1 = require("../ExpandedTracksProvider");
13
+ const NotificationCenter_1 = require("../Notifications/NotificationCenter");
11
14
  const TimelineExpandedSection_1 = require("./TimelineExpandedSection");
12
15
  const TimelineLayerEye_1 = require("./TimelineLayerEye");
13
16
  const TimelineStack_1 = require("./TimelineStack");
@@ -39,13 +42,73 @@ const arrowButton = {
39
42
  const TimelineListItem = ({ nestedDepth, sequence, isCompact }) => {
40
43
  var _a, _b;
41
44
  const { previewServerState } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
42
- const visualModeEnabled = Boolean(process.env.EXPERIMENTAL_VISUAL_MODE_ENABLED) &&
43
- previewServerState.type === 'connected';
45
+ const visualModeEnvEnabled = Boolean(process.env.EXPERIMENTAL_VISUAL_MODE_ENABLED);
46
+ const previewConnected = previewServerState.type === 'connected';
47
+ const visualModeActive = visualModeEnvEnabled && previewConnected;
44
48
  const { hidden, setHidden } = (0, react_1.useContext)(remotion_1.Internals.SequenceVisibilityToggleContext);
45
49
  const { expandedTracks, toggleTrack } = (0, react_1.useContext)(ExpandedTracksProvider_1.ExpandedTracksContext);
46
50
  const originalLocation = (0, use_resolved_stack_1.useResolvedStack)((_a = sequence.stack) !== null && _a !== void 0 ? _a : null);
47
- const nodePath = (0, use_sequence_props_subscription_1.useSequencePropsSubscription)(sequence, originalLocation);
48
- const isExpanded = visualModeEnabled && ((_b = expandedTracks[sequence.id]) !== null && _b !== void 0 ? _b : false);
51
+ const nodePath = (0, use_sequence_props_subscription_1.useSequencePropsSubscription)(sequence, originalLocation, visualModeActive);
52
+ const validatedLocation = (0, react_1.useMemo)(() => {
53
+ var _a;
54
+ if (!originalLocation ||
55
+ !originalLocation.source ||
56
+ !originalLocation.line) {
57
+ return null;
58
+ }
59
+ return {
60
+ source: originalLocation.source,
61
+ line: originalLocation.line,
62
+ column: (_a = originalLocation.column) !== null && _a !== void 0 ? _a : 0,
63
+ };
64
+ }, [originalLocation]);
65
+ const canDeleteFromSource = Boolean(nodePath && (validatedLocation === null || validatedLocation === void 0 ? void 0 : validatedLocation.source));
66
+ const deleteDisabled = (0, react_1.useMemo)(() => !previewConnected || !sequence.controls || !canDeleteFromSource, [previewConnected, sequence.controls, canDeleteFromSource]);
67
+ const onDeleteSequenceFromSource = (0, react_1.useCallback)(async () => {
68
+ if (!(validatedLocation === null || validatedLocation === void 0 ? void 0 : validatedLocation.source) || !nodePath) {
69
+ return;
70
+ }
71
+ try {
72
+ const result = await (0, call_api_1.callApi)('/api/delete-jsx-node', {
73
+ fileName: validatedLocation.source,
74
+ nodePath,
75
+ });
76
+ if (result.success) {
77
+ (0, NotificationCenter_1.showNotification)('Removed sequence from source file', 2000);
78
+ }
79
+ else {
80
+ (0, NotificationCenter_1.showNotification)(result.reason, 4000);
81
+ }
82
+ }
83
+ catch (err) {
84
+ (0, NotificationCenter_1.showNotification)(err.message, 4000);
85
+ }
86
+ }, [nodePath, validatedLocation === null || validatedLocation === void 0 ? void 0 : validatedLocation.source]);
87
+ const contextMenuValues = (0, react_1.useMemo)(() => {
88
+ if (!visualModeEnvEnabled) {
89
+ return [];
90
+ }
91
+ return [
92
+ {
93
+ type: 'item',
94
+ id: 'delete-sequence',
95
+ keyHint: null,
96
+ label: 'Delete',
97
+ leftItem: null,
98
+ disabled: deleteDisabled,
99
+ onClick: () => {
100
+ if (deleteDisabled) {
101
+ return;
102
+ }
103
+ onDeleteSequenceFromSource();
104
+ },
105
+ quickSwitcherLabel: null,
106
+ subMenu: null,
107
+ value: 'delete-sequence',
108
+ },
109
+ ];
110
+ }, [deleteDisabled, onDeleteSequenceFromSource, visualModeEnvEnabled]);
111
+ const isExpanded = visualModeActive && ((_b = expandedTracks[sequence.id]) !== null && _b !== void 0 ? _b : false);
49
112
  const onToggleExpand = (0, react_1.useCallback)(() => {
50
113
  toggleTrack(sequence.id);
51
114
  }, [sequence.id, toggleTrack]);
@@ -87,9 +150,9 @@ const TimelineListItem = ({ nestedDepth, sequence, isCompact }) => {
87
150
  transform: isExpanded ? 'rotate(90deg)' : 'rotate(0deg)',
88
151
  };
89
152
  }, [isExpanded]);
90
- return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
91
- jsx_runtime_1.jsxs("div", { style: outer, children: [
92
- jsx_runtime_1.jsx(TimelineLayerEye_1.TimelineLayerEye, { type: sequence.type === 'audio' ? 'speaker' : 'eye', hidden: isItemHidden, onInvoked: onToggleVisibility }), jsx_runtime_1.jsx("div", { style: padder }), sequence.parent && nestedDepth > 0 ? jsx_runtime_1.jsx("div", { style: space }) : null, visualModeEnabled ? (sequence.controls ? (jsx_runtime_1.jsx("button", { type: "button", style: arrowStyle, onClick: onToggleExpand, "aria-expanded": isExpanded, "aria-label": `${isExpanded ? 'Collapse' : 'Expand'} track`, children: jsx_runtime_1.jsx("svg", { width: "12", height: "12", viewBox: "0 0 8 8", style: { display: 'block' }, children: jsx_runtime_1.jsx("path", { d: "M2 1L6 4L2 7Z", fill: "white" }) }) })) : (jsx_runtime_1.jsx("div", { style: arrowButton }))) : null, jsx_runtime_1.jsx(TimelineStack_1.TimelineStack, { sequence: sequence, isCompact: isCompact, originalLocation: originalLocation })
93
- ] }), visualModeEnabled && isExpanded && sequence.controls ? (jsx_runtime_1.jsx(TimelineExpandedSection_1.TimelineExpandedSection, { sequence: sequence, originalLocation: originalLocation, nestedDepth: nestedDepth, nodePath: nodePath })) : null] }));
153
+ const trackRow = (jsx_runtime_1.jsxs("div", { style: outer, children: [
154
+ jsx_runtime_1.jsx(TimelineLayerEye_1.TimelineLayerEye, { type: sequence.type === 'audio' ? 'speaker' : 'eye', hidden: isItemHidden, onInvoked: onToggleVisibility }), jsx_runtime_1.jsx("div", { style: padder }), sequence.parent && nestedDepth > 0 ? jsx_runtime_1.jsx("div", { style: space }) : null, visualModeActive ? (sequence.controls ? (jsx_runtime_1.jsx("button", { type: "button", style: arrowStyle, onClick: onToggleExpand, "aria-expanded": isExpanded, "aria-label": `${isExpanded ? 'Collapse' : 'Expand'} track`, children: jsx_runtime_1.jsx("svg", { width: "12", height: "12", viewBox: "0 0 8 8", style: { display: 'block' }, children: jsx_runtime_1.jsx("path", { d: "M2 1L6 4L2 7Z", fill: "white" }) }) })) : (jsx_runtime_1.jsx("div", { style: arrowButton }))) : null, jsx_runtime_1.jsx(TimelineStack_1.TimelineStack, { sequence: sequence, isCompact: isCompact, originalLocation: originalLocation })
155
+ ] }));
156
+ return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [visualModeEnvEnabled ? (jsx_runtime_1.jsx(ContextMenu_1.ContextMenu, { values: contextMenuValues, children: trackRow })) : (trackRow), visualModeActive && isExpanded && sequence.controls ? (jsx_runtime_1.jsx(TimelineExpandedSection_1.TimelineExpandedSection, { sequence: sequence, originalLocation: originalLocation, nestedDepth: nestedDepth, nodePath: nodePath })) : null] }));
94
157
  };
95
158
  exports.TimelineListItem = TimelineListItem;
@@ -5,7 +5,18 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const InputDragger_1 = require("../NewComposition/InputDragger");
7
7
  const timeline_field_utils_1 = require("./timeline-field-utils");
8
+ const unitPattern = /^([+-]?(?:\d+\.?\d*|\.\d+))(deg|rad|turn|grad)$/;
9
+ const unitToDegrees = {
10
+ deg: 1,
11
+ rad: 180 / Math.PI,
12
+ turn: 360,
13
+ grad: 360 / 400,
14
+ };
8
15
  const parseCssRotationToDegrees = (value) => {
16
+ const match = value.trim().match(unitPattern);
17
+ if (match) {
18
+ return Number(match[1]) * unitToDegrees[match[2]];
19
+ }
9
20
  try {
10
21
  const m = new DOMMatrix(`rotate(${value})`);
11
22
  return Math.round(Math.atan2(m.b, m.a) * (180 / Math.PI) * 1e6) / 1e6;
@@ -107,7 +107,7 @@ const Inner = ({ s, windowWidth }) => {
107
107
  )`,
108
108
  position: 'absolute',
109
109
  right: 0,
110
- } })) : null, s.type === 'audio' ? (jsx_runtime_1.jsx(AudioWaveform_1.AudioWaveform, { src: s.src, doesVolumeChange: s.doesVolumeChange, visualizationWidth: width, startFrom: s.startMediaFrom, durationInFrames: s.duration, volume: s.volume, playbackRate: s.playbackRate })) : null, s.type === 'video' ? (jsx_runtime_1.jsx(TimelineVideoInfo_1.TimelineVideoInfo, { src: s.src, visualizationWidth: width, naturalWidth: naturalWidth, trimBefore: s.startMediaFrom, durationInFrames: s.duration, playbackRate: s.playbackRate })) : null, s.type === 'image' ? (jsx_runtime_1.jsx(TimelineImageInfo_1.TimelineImageInfo, { src: s.src, visualizationWidth: width })) : null, s.loopDisplay === undefined ? null : (jsx_runtime_1.jsx(LoopedTimelineIndicators_1.LoopedTimelineIndicator, { loops: s.loopDisplay.numberOfTimes })), s.type !== 'audio' &&
110
+ } })) : null, s.type === 'audio' ? (jsx_runtime_1.jsx(AudioWaveform_1.AudioWaveform, { src: s.src, doesVolumeChange: s.doesVolumeChange, visualizationWidth: width, startFrom: s.startMediaFrom, durationInFrames: s.duration, volume: s.volume, playbackRate: s.playbackRate })) : null, s.type === 'video' ? (jsx_runtime_1.jsx(TimelineVideoInfo_1.TimelineVideoInfo, { src: s.src, visualizationWidth: width, naturalWidth: naturalWidth, trimBefore: s.startMediaFrom, durationInFrames: s.duration, playbackRate: s.playbackRate, volume: s.volume, doesVolumeChange: s.doesVolumeChange, premountWidth: premountWidth !== null && premountWidth !== void 0 ? premountWidth : 0, postmountWidth: postmountWidth !== null && postmountWidth !== void 0 ? postmountWidth : 0 })) : null, s.type === 'image' ? (jsx_runtime_1.jsx(TimelineImageInfo_1.TimelineImageInfo, { src: s.src, visualizationWidth: width })) : null, s.loopDisplay === undefined ? null : (jsx_runtime_1.jsx(LoopedTimelineIndicators_1.LoopedTimelineIndicator, { loops: s.loopDisplay.numberOfTimes })), s.type !== 'audio' &&
111
111
  s.type !== 'video' &&
112
112
  s.type !== 'image' &&
113
113
  s.loopDisplay === undefined &&
@@ -149,7 +149,8 @@ const TimelineStack = ({ isCompact, sequence, originalLocation }) => {
149
149
  color: opening && isCompact ? colors_1.VERY_LIGHT_TEXT : colors_1.LIGHT_COLOR,
150
150
  userSelect: 'none',
151
151
  WebkitUserSelect: 'none',
152
- borderBottom: hoverEffect ? '1px solid #fff' : 'none',
152
+ textDecoration: hoverEffect ? 'underline' : 'none',
153
+ textUnderlineOffset: 2,
153
154
  cursor: hoverEffect ? 'pointer' : undefined,
154
155
  };
155
156
  }, [titleHoverable, isCompact, opening, titleHovered]);
@@ -6,4 +6,8 @@ export declare const TimelineVideoInfo: React.FC<{
6
6
  readonly trimBefore: number;
7
7
  readonly durationInFrames: number;
8
8
  readonly playbackRate: number;
9
+ readonly volume: string | number;
10
+ readonly doesVolumeChange: boolean;
11
+ readonly premountWidth: number;
12
+ readonly postmountWidth: number;
9
13
  }>;
@@ -8,21 +8,27 @@ const extract_frames_1 = require("../../helpers/extract-frames");
8
8
  const frame_database_1 = require("../../helpers/frame-database");
9
9
  const resize_video_frame_1 = require("../../helpers/resize-video-frame");
10
10
  const timeline_layout_1 = require("../../helpers/timeline-layout");
11
- const HEIGHT = (0, timeline_layout_1.getTimelineLayerHeight)('video') - 2;
12
- const containerStyle = {
13
- height: HEIGHT,
11
+ const AudioWaveform_1 = require("../AudioWaveform");
12
+ const FILMSTRIP_HEIGHT = timeline_layout_1.TIMELINE_LAYER_HEIGHT_IMAGE - 2;
13
+ const outerStyle = {
14
+ width: '100%',
15
+ height: '100%',
16
+ display: 'flex',
17
+ flexDirection: 'column',
18
+ };
19
+ const filmstripContainerStyle = {
20
+ height: FILMSTRIP_HEIGHT,
14
21
  width: '100%',
15
22
  backgroundColor: 'rgba(0, 0, 0, 0.3)',
16
23
  display: 'flex',
17
24
  borderTopLeftRadius: 2,
18
- borderBottomLeftRadius: 2,
19
25
  fontSize: 10,
20
26
  fontFamily: 'Arial, Helvetica',
21
27
  };
22
28
  const WEBCODECS_TIMESCALE = 1000000;
23
29
  const MAX_TIME_DEVIATION = WEBCODECS_TIMESCALE * 0.05;
24
30
  const getDurationOfOneFrame = ({ visualizationWidth, aspectRatio, segmentDuration, }) => {
25
- const framesFitInWidthUnrounded = visualizationWidth / (HEIGHT * aspectRatio);
31
+ const framesFitInWidthUnrounded = visualizationWidth / (FILMSTRIP_HEIGHT * aspectRatio);
26
32
  return (segmentDuration / framesFitInWidthUnrounded) * WEBCODECS_TIMESCALE;
27
33
  };
28
34
  const fixRounding = (value) => {
@@ -32,7 +38,7 @@ const fixRounding = (value) => {
32
38
  return Math.floor(value);
33
39
  };
34
40
  const calculateTimestampSlots = ({ visualizationWidth, fromSeconds, segmentDuration, aspectRatio, }) => {
35
- const framesFitInWidthUnrounded = visualizationWidth / (HEIGHT * aspectRatio);
41
+ const framesFitInWidthUnrounded = visualizationWidth / (FILMSTRIP_HEIGHT * aspectRatio);
36
42
  const framesFitInWidth = Math.ceil(framesFitInWidthUnrounded);
37
43
  const durationOfOneFrame = getDurationOfOneFrame({
38
44
  visualizationWidth,
@@ -70,8 +76,10 @@ const drawSlot = ({ frame, ctx, filledSlots, visualizationWidth, timestamp, segm
70
76
  });
71
77
  const relativeTimestamp = timestamp - fromSeconds * WEBCODECS_TIMESCALE;
72
78
  const frameIndex = relativeTimestamp / durationOfOneFrame;
73
- const left = Math.floor((frameIndex * frame.displayWidth) / window.devicePixelRatio); // round to avoid antialiasing
74
- ctx.drawImage(frame, left, 0, frame.displayWidth / window.devicePixelRatio, frame.displayHeight / window.devicePixelRatio);
79
+ const thumbnailWidth = frame.displayWidth / window.devicePixelRatio;
80
+ const left = Math.floor(frameIndex * thumbnailWidth);
81
+ const right = Math.ceil((frameIndex + 1) * thumbnailWidth);
82
+ ctx.drawImage(frame, left, 0, right - left, frame.displayHeight / window.devicePixelRatio);
75
83
  filledSlots.set(timestamp, frame.timestamp);
76
84
  };
77
85
  const fillWithCachedFrames = ({ ctx, naturalWidth, filledSlots, src, segmentDuration, fromSeconds, }) => {
@@ -138,16 +146,11 @@ const fillFrameWhereItFits = ({ frame, filledSlots, ctx, visualizationWidth, seg
138
146
  });
139
147
  }
140
148
  };
141
- const TimelineVideoInfo = ({ src, visualizationWidth, naturalWidth, trimBefore, durationInFrames, playbackRate, }) => {
149
+ const TimelineVideoInfo = ({ src, visualizationWidth, naturalWidth, trimBefore, durationInFrames, playbackRate, volume, doesVolumeChange, premountWidth, postmountWidth, }) => {
142
150
  const { fps } = (0, remotion_1.useVideoConfig)();
143
151
  const ref = (0, react_1.useRef)(null);
144
152
  const [error, setError] = (0, react_1.useState)(null);
145
153
  const aspectRatio = (0, react_1.useRef)((0, frame_database_1.getAspectRatioFromCache)(src));
146
- (0, react_1.useEffect)(() => {
147
- return () => {
148
- (0, frame_database_1.clearFramesForSrc)(src);
149
- };
150
- }, [src]);
151
154
  // for rendering frames
152
155
  (0, react_1.useEffect)(() => {
153
156
  if (error) {
@@ -160,7 +163,7 @@ const TimelineVideoInfo = ({ src, visualizationWidth, naturalWidth, trimBefore,
160
163
  const controller = new AbortController();
161
164
  const canvas = document.createElement('canvas');
162
165
  canvas.width = visualizationWidth;
163
- canvas.height = HEIGHT;
166
+ canvas.height = FILMSTRIP_HEIGHT;
164
167
  const ctx = canvas.getContext('2d');
165
168
  if (!ctx) {
166
169
  return;
@@ -193,11 +196,9 @@ const TimelineVideoInfo = ({ src, visualizationWidth, naturalWidth, trimBefore,
193
196
  if (unfilled.length === 0) {
194
197
  return () => {
195
198
  current.removeChild(canvas);
196
- (0, frame_database_1.clearOldFrames)();
197
199
  };
198
200
  }
199
201
  }
200
- (0, frame_database_1.clearOldFrames)();
201
202
  (0, extract_frames_1.extractFrames)({
202
203
  timestampsInSeconds: ({ track, }) => {
203
204
  aspectRatio.current = track.width / track.height;
@@ -216,7 +217,7 @@ const TimelineVideoInfo = ({ src, visualizationWidth, naturalWidth, trimBefore,
216
217
  let frame;
217
218
  try {
218
219
  frame = sample.toVideoFrame();
219
- const scale = (HEIGHT / frame.displayHeight) * window.devicePixelRatio;
220
+ const scale = (FILMSTRIP_HEIGHT / frame.displayHeight) * window.devicePixelRatio;
220
221
  const transformed = (0, resize_video_frame_1.resizeVideoFrame)({
221
222
  frame,
222
223
  scale,
@@ -226,14 +227,7 @@ const TimelineVideoInfo = ({ src, visualizationWidth, naturalWidth, trimBefore,
226
227
  }
227
228
  frame = undefined;
228
229
  const databaseKey = (0, frame_database_1.makeFrameDatabaseKey)(src, transformed.timestamp);
229
- const existingFrame = frame_database_1.frameDatabase.get(databaseKey);
230
- if (existingFrame) {
231
- existingFrame.frame.close();
232
- }
233
- frame_database_1.frameDatabase.set(databaseKey, {
234
- frame: transformed,
235
- lastUsed: Date.now(),
236
- });
230
+ (0, frame_database_1.addFrameToCache)(databaseKey, transformed);
237
231
  if (aspectRatio.current === null) {
238
232
  throw new Error('Aspect ratio is not set');
239
233
  }
@@ -280,9 +274,6 @@ const TimelineVideoInfo = ({ src, visualizationWidth, naturalWidth, trimBefore,
280
274
  })
281
275
  .catch((e) => {
282
276
  setError(e);
283
- })
284
- .finally(() => {
285
- (0, frame_database_1.clearOldFrames)();
286
277
  });
287
278
  return () => {
288
279
  controller.abort();
@@ -298,6 +289,17 @@ const TimelineVideoInfo = ({ src, visualizationWidth, naturalWidth, trimBefore,
298
289
  trimBefore,
299
290
  visualizationWidth,
300
291
  ]);
301
- return jsx_runtime_1.jsx("div", { ref: ref, style: containerStyle });
292
+ const audioWidth = visualizationWidth - premountWidth - postmountWidth;
293
+ const audioStyle = (0, react_1.useMemo)(() => {
294
+ return {
295
+ height: timeline_layout_1.TIMELINE_LAYER_HEIGHT_AUDIO,
296
+ width: audioWidth,
297
+ position: 'relative',
298
+ marginLeft: premountWidth,
299
+ };
300
+ }, [audioWidth, premountWidth]);
301
+ return (jsx_runtime_1.jsxs("div", { style: outerStyle, children: [
302
+ jsx_runtime_1.jsx("div", { ref: ref, style: filmstripContainerStyle }), jsx_runtime_1.jsx("div", { style: audioStyle, children: jsx_runtime_1.jsx(AudioWaveform_1.AudioWaveform, { src: src, visualizationWidth: audioWidth, startFrom: trimBefore, durationInFrames: durationInFrames, volume: volume, doesVolumeChange: doesVolumeChange, playbackRate: playbackRate }) })
303
+ ] }));
302
304
  };
303
305
  exports.TimelineVideoInfo = TimelineVideoInfo;
@@ -1,4 +1,4 @@
1
1
  import type { SequenceNodePath } from '@remotion/studio-shared';
2
2
  import type { TSequence } from 'remotion';
3
3
  import type { OriginalPosition } from '../../error-overlay/react-overlay/utils/get-source-map';
4
- export declare const useSequencePropsSubscription: (sequence: TSequence, originalLocation: OriginalPosition | null) => SequenceNodePath | null;
4
+ export declare const useSequencePropsSubscription: (sequence: TSequence, originalLocation: OriginalPosition | null, visualModeEnabled: boolean) => SequenceNodePath | null;