@remotion/studio 4.0.102 → 4.0.103

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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @remotion/studio@4.0.101 build /Users/jonathanburger/remotion/packages/studio
2
+ > @remotion/studio@4.0.102 build /Users/jonathanburger/remotion/packages/studio
3
3
  > tsc -d
4
4
 
package/LICENSE.md CHANGED
@@ -7,7 +7,7 @@ Depending on the type of your legal entity, you are granted permission to use Re
7
7
 
8
8
  ## Free license
9
9
 
10
- Copyright © 2023 [Remotion](https://www.remotion.dev)
10
+ Copyright © 2024 [Remotion](https://www.remotion.dev)
11
11
 
12
12
  ### Eligibility
13
13
 
@@ -40,6 +40,6 @@ const MenuBuildIndicator = () => {
40
40
  window.remotion_finishedBuilding = undefined;
41
41
  };
42
42
  }, []);
43
- return ((0, jsx_runtime_1.jsxs)("div", { style: cwd, title: window.remotion_cwd, children: [showButton ? (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 2 }) : null, isBuilding ? ((0, jsx_runtime_1.jsx)("div", { style: spinner, children: (0, jsx_runtime_1.jsx)(Spinner_1.Spinner, { duration: 0.5, size: spinnerSize }) })) : ((0, jsx_runtime_1.jsx)("div", { style: noSpinner })), showButton ? (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.5 }) : null, window.remotion_projectName, showButton ? (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.25 }) : null, showButton ? (0, jsx_runtime_1.jsx)(OpenEditorButton_1.OpenEditorButton, {}) : null] }));
43
+ return ((0, jsx_runtime_1.jsxs)("div", { style: cwd, title: window.remotion_cwd, children: [showButton ? (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 2 }) : null, isBuilding ? ((0, jsx_runtime_1.jsx)("div", { style: spinner, children: (0, jsx_runtime_1.jsx)(Spinner_1.Spinner, { duration: 0.5, size: spinnerSize }) })) : ((0, jsx_runtime_1.jsx)("div", { style: noSpinner })), showButton ? (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.5 }) : null, window.remotion_projectName, showButton ? (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.25 }) : null, showButton ? ((0, jsx_runtime_1.jsx)(OpenEditorButton_1.OpenEditorButton, { type: "editor" })) : window.remotion_gitSource ? ((0, jsx_runtime_1.jsx)(OpenEditorButton_1.OpenEditorButton, { type: "git" })) : null] }));
44
44
  };
45
45
  exports.MenuBuildIndicator = MenuBuildIndicator;
@@ -1,2 +1,4 @@
1
1
  /// <reference types="react" />
2
- export declare const OpenEditorButton: React.FC<{}>;
2
+ export declare const OpenEditorButton: React.FC<{
3
+ type: 'git' | 'editor';
4
+ }>;
@@ -4,6 +4,7 @@ exports.OpenEditorButton = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const colors_1 = require("../helpers/colors");
7
+ const get_git_menu_item_1 = require("../helpers/get-git-menu-item");
7
8
  const open_in_editor_1 = require("../helpers/open-in-editor");
8
9
  const NotificationCenter_1 = require("./Notifications/NotificationCenter");
9
10
  const svgStyle = {
@@ -17,32 +18,42 @@ const buttonStyle = {
17
18
  justifyContent: 'center',
18
19
  alignItems: 'center',
19
20
  };
20
- const OpenEditorButton = () => {
21
+ const OpenEditorButton = ({ type }) => {
21
22
  const [hovered, setHovered] = (0, react_1.useState)(false);
22
23
  const svgFillColor = (0, react_1.useMemo)(() => {
23
24
  return hovered ? 'white' : colors_1.LIGHT_TEXT;
24
25
  }, [hovered]);
25
- const handleClick = async () => {
26
- await (0, open_in_editor_1.openInEditor)({
27
- originalFileName: `${window.remotion_cwd}`,
28
- originalLineNumber: 1,
29
- originalColumnNumber: 1,
30
- originalFunctionName: null,
31
- originalScriptCode: null,
32
- })
33
- .then((res) => res.json())
34
- .then(({ success }) => {
35
- if (!success) {
26
+ const handleClick = (0, react_1.useCallback)(async () => {
27
+ if (type === 'editor') {
28
+ await (0, open_in_editor_1.openInEditor)({
29
+ originalFileName: `${window.remotion_cwd}`,
30
+ originalLineNumber: 1,
31
+ originalColumnNumber: 1,
32
+ originalFunctionName: null,
33
+ originalScriptCode: null,
34
+ })
35
+ .then((res) => res.json())
36
+ .then(({ success }) => {
37
+ if (!success) {
38
+ (0, NotificationCenter_1.sendErrorNotification)(`Could not open ${window.remotion_editorName}`);
39
+ }
40
+ })
41
+ .catch((err) => {
42
+ // eslint-disable-next-line no-console
43
+ console.error(err);
36
44
  (0, NotificationCenter_1.sendErrorNotification)(`Could not open ${window.remotion_editorName}`);
45
+ });
46
+ }
47
+ if (type === 'git') {
48
+ if (!window.remotion_gitSource) {
49
+ throw new Error('No git source');
37
50
  }
38
- })
39
- .catch((err) => {
40
- // eslint-disable-next-line no-console
41
- console.error(err);
42
- (0, NotificationCenter_1.sendErrorNotification)(`Could not open ${window.remotion_editorName}`);
43
- });
44
- };
45
- const buttonTooltip = `Open in ${window.remotion_editorName}`;
51
+ window.open((0, get_git_menu_item_1.getGitSourceBranchUrl)(window.remotion_gitSource), '_blank');
52
+ }
53
+ }, [type]);
54
+ const buttonTooltip = type === 'git'
55
+ ? `Open ${(0, get_git_menu_item_1.getGitSourceName)(window.remotion_gitSource)} Repo`
56
+ : `Open in ${window.remotion_editorName}`;
46
57
  const openInEditorSvg = ((0, jsx_runtime_1.jsx)("svg", { viewBox: "0 0 512 512", style: svgStyle, children: (0, jsx_runtime_1.jsx)("path", { fill: svgFillColor, d: "M320 0c-17.7 0-32 14.3-32 32s14.3 32 32 32h82.7L201.4 265.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L448 109.3V192c0 17.7 14.3 32 32 32s32-14.3 32-32V32c0-17.7-14.3-32-32-32H320zM80 32C35.8 32 0 67.8 0 112V432c0 44.2 35.8 80 80 80H400c44.2 0 80-35.8 80-80V320c0-17.7-14.3-32-32-32s-32 14.3-32 32V432c0 8.8-7.2 16-16 16H80c-8.8 0-16-7.2-16-16V112c0-8.8 7.2-16 16-16H192c17.7 0 32-14.3 32-32s-14.3-32-32-32H80z" }) }));
47
58
  const onPointerEnter = (0, react_1.useCallback)(() => {
48
59
  setHovered(true);
@@ -5,7 +5,9 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const studio_shared_1 = require("@remotion/studio-shared");
6
6
  const react_1 = require("react");
7
7
  const source_map_1 = require("source-map");
8
+ const client_id_1 = require("../../../helpers/client-id");
8
9
  const colors_1 = require("../../../helpers/colors");
10
+ const get_git_menu_item_1 = require("../../../helpers/get-git-menu-item");
9
11
  const open_in_editor_1 = require("../../../helpers/open-in-editor");
10
12
  const url_state_1 = require("../../../helpers/url-state");
11
13
  const InitialCompositionLoader_1 = require("../../InitialCompositionLoader");
@@ -24,6 +26,8 @@ const TimelineStack = ({ isCompact, sequence }) => {
24
26
  const [titleHovered, setTitleHovered] = (0, react_1.useState)(false);
25
27
  const [opening, setOpening] = (0, react_1.useState)(false);
26
28
  const selectAsset = (0, InitialCompositionLoader_1.useSelectAsset)();
29
+ const connectionStatus = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx)
30
+ .previewServerState.type;
27
31
  const assetPath = (0, react_1.useMemo)(() => {
28
32
  if (sequence.type !== 'video' && sequence.type !== 'audio') {
29
33
  return null;
@@ -60,7 +64,16 @@ const TimelineStack = ({ isCompact, sequence }) => {
60
64
  setOpening(false);
61
65
  }
62
66
  }, []);
67
+ const canOpenInEditor = window.remotion_editorName &&
68
+ connectionStatus === 'connected' &&
69
+ originalLocation;
70
+ const canOpenInGitHub = window.remotion_gitSource && originalLocation;
71
+ const titleHoverable = (isCompact && (canOpenInEditor || canOpenInGitHub)) || assetPath;
72
+ const stackHoverable = !isCompact && (canOpenInEditor || canOpenInGitHub);
63
73
  const onClickTitle = (0, react_1.useCallback)(() => {
74
+ if (!titleHoverable) {
75
+ return null;
76
+ }
64
77
  if (assetPath) {
65
78
  navigateToAsset(assetPath);
66
79
  return;
@@ -68,14 +81,34 @@ const TimelineStack = ({ isCompact, sequence }) => {
68
81
  if (!originalLocation) {
69
82
  return;
70
83
  }
71
- openEditor(originalLocation);
72
- }, [assetPath, navigateToAsset, openEditor, originalLocation]);
84
+ if (canOpenInEditor) {
85
+ openEditor(originalLocation);
86
+ return;
87
+ }
88
+ if (canOpenInGitHub) {
89
+ window.open((0, get_git_menu_item_1.getGitRefUrl)(window.remotion_gitSource, originalLocation), '_blank');
90
+ }
91
+ }, [
92
+ assetPath,
93
+ canOpenInEditor,
94
+ canOpenInGitHub,
95
+ navigateToAsset,
96
+ openEditor,
97
+ originalLocation,
98
+ titleHoverable,
99
+ ]);
73
100
  const onClickStack = (0, react_1.useCallback)(() => {
74
101
  if (!originalLocation) {
75
102
  return;
76
103
  }
77
- openEditor(originalLocation);
78
- }, [openEditor, originalLocation]);
104
+ if (canOpenInEditor) {
105
+ openEditor(originalLocation);
106
+ return;
107
+ }
108
+ if (canOpenInGitHub) {
109
+ window.open((0, get_git_menu_item_1.getGitRefUrl)(window.remotion_gitSource, originalLocation), '_blank');
110
+ }
111
+ }, [canOpenInEditor, canOpenInGitHub, openEditor, originalLocation]);
79
112
  (0, react_1.useEffect)(() => {
80
113
  if (!sequence.stack) {
81
114
  return;
@@ -101,18 +134,16 @@ const TimelineStack = ({ isCompact, sequence }) => {
101
134
  const onTitlePointerLeave = (0, react_1.useCallback)(() => {
102
135
  setTitleHovered(false);
103
136
  }, []);
104
- const hoverable = (originalLocation && isCompact) ||
105
- (assetPath && window.remotion_editorName);
106
137
  const style = (0, react_1.useMemo)(() => {
107
138
  return {
108
139
  fontSize: 12,
109
140
  color: opening
110
141
  ? colors_1.VERY_LIGHT_TEXT
111
- : stackHovered && hoverable
142
+ : stackHovered && stackHoverable
112
143
  ? colors_1.LIGHT_TEXT
113
144
  : colors_1.VERY_LIGHT_TEXT,
114
145
  marginLeft: 10,
115
- cursor: hoverable ? 'pointer' : undefined,
146
+ cursor: stackHoverable ? 'pointer' : undefined,
116
147
  display: 'flex',
117
148
  flexDirection: 'row',
118
149
  alignItems: 'center',
@@ -121,9 +152,9 @@ const TimelineStack = ({ isCompact, sequence }) => {
121
152
  overflow: 'hidden',
122
153
  flexShrink: 100000,
123
154
  };
124
- }, [opening, stackHovered, hoverable]);
125
- const textStyle = (0, react_1.useMemo)(() => {
126
- const hoverEffect = titleHovered && hoverable;
155
+ }, [opening, stackHovered, stackHoverable]);
156
+ const titleStyle = (0, react_1.useMemo)(() => {
157
+ const hoverEffect = titleHovered && titleHoverable;
127
158
  return {
128
159
  fontSize: 12,
129
160
  whiteSpace: 'nowrap',
@@ -135,12 +166,12 @@ const TimelineStack = ({ isCompact, sequence }) => {
135
166
  borderBottom: hoverEffect ? '1px solid #fff' : 'none',
136
167
  cursor: hoverEffect ? 'pointer' : undefined,
137
168
  };
138
- }, [hoverable, isCompact, opening, titleHovered]);
169
+ }, [titleHoverable, isCompact, opening, titleHovered]);
139
170
  const text = sequence.displayName.length > 1000
140
171
  ? sequence.displayName.slice(0, 1000) + '...'
141
172
  : sequence.displayName;
142
173
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { onPointerEnter: onTitlePointerEnter, onPointerLeave: onTitlePointerLeave, title: originalLocation
143
174
  ? (0, source_attribution_1.getOriginalSourceAttribution)(originalLocation)
144
- : text || '<Sequence>', style: textStyle, onClick: onClickTitle, children: text || '<Sequence>' }), isCompact || !originalLocation ? null : ((0, jsx_runtime_1.jsx)("div", { onPointerEnter: onStackPointerEnter, onPointerLeave: onStackPointerLeave, onClick: onClickStack, style: style, children: (0, source_attribution_1.getOriginalSourceAttribution)(originalLocation) })), opening ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.5 }), (0, jsx_runtime_1.jsx)(Spinner_1.Spinner, { duration: 0.5, size: 12 })] })) : null] }));
175
+ : text || '<Sequence>', style: titleStyle, onClick: onClickTitle, children: text || '<Sequence>' }), isCompact || !originalLocation ? null : ((0, jsx_runtime_1.jsx)("div", { onPointerEnter: onStackPointerEnter, onPointerLeave: onStackPointerLeave, onClick: onClickStack, style: style, children: (0, source_attribution_1.getOriginalSourceAttribution)(originalLocation) })), opening ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.5 }), (0, jsx_runtime_1.jsx)(Spinner_1.Spinner, { duration: 0.5, size: 12 })] })) : null] }));
145
176
  };
146
177
  exports.TimelineStack = TimelineStack;
@@ -0,0 +1,7 @@
1
+ import type { GitSource } from '@remotion/studio-shared';
2
+ import type { ComboboxValue } from '../components/NewComposition/ComboBox';
3
+ import type { OriginalPosition } from '../error-overlay/react-overlay/utils/get-source-map';
4
+ export declare const getGitSourceName: (gitSource: GitSource) => string;
5
+ export declare const getGitSourceBranchUrl: (gitSource: GitSource) => string;
6
+ export declare const getGitRefUrl: (gitSource: GitSource, originalLocation: OriginalPosition) => string;
7
+ export declare const getGitMenuItem: () => ComboboxValue | null;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGitMenuItem = exports.getGitRefUrl = exports.getGitSourceBranchUrl = exports.getGitSourceName = void 0;
4
+ const getGitSourceName = (gitSource) => {
5
+ if (gitSource.type === 'github') {
6
+ return 'GitHub';
7
+ }
8
+ throw new Error('Unknown git source type');
9
+ };
10
+ exports.getGitSourceName = getGitSourceName;
11
+ const getGitSourceBranchUrl = (gitSource) => {
12
+ if (gitSource.type === 'github') {
13
+ return `https://github.com/${gitSource.org}/${gitSource.name}/tree/${gitSource.ref}${gitSource.relativeFromGitRoot ? `/${gitSource.relativeFromGitRoot}` : ''}`;
14
+ }
15
+ throw new Error('Unknown git source type');
16
+ };
17
+ exports.getGitSourceBranchUrl = getGitSourceBranchUrl;
18
+ const getGitRefUrl = (gitSource, originalLocation) => {
19
+ if (gitSource.type === 'github') {
20
+ return `https://github.com/${gitSource.org}/${gitSource.name}/tree/${gitSource.ref}/${gitSource.relativeFromGitRoot ? `${gitSource.relativeFromGitRoot}/` : ''}${originalLocation.source}#L${originalLocation.line}`;
21
+ }
22
+ throw new Error('Unknown git source type');
23
+ };
24
+ exports.getGitRefUrl = getGitRefUrl;
25
+ const getGitMenuItem = () => {
26
+ if (!window.remotion_gitSource) {
27
+ return null;
28
+ }
29
+ return {
30
+ id: 'open-git-source',
31
+ value: 'open-git-source',
32
+ label: `Open ${(0, exports.getGitSourceName)(window.remotion_gitSource)} Repo`,
33
+ onClick: () => {
34
+ window.open((0, exports.getGitSourceBranchUrl)(window.remotion_gitSource), '_blank');
35
+ },
36
+ type: 'item',
37
+ keyHint: null,
38
+ leftItem: null,
39
+ subMenu: null,
40
+ quickSwitcherLabel: `Open ${(0, exports.getGitSourceName)(window.remotion_gitSource)} repo`,
41
+ };
42
+ };
43
+ exports.getGitMenuItem = getGitMenuItem;
@@ -21,6 +21,7 @@ const modals_1 = require("../state/modals");
21
21
  const preview_size_1 = require("../state/preview-size");
22
22
  const sidebar_1 = require("../state/sidebar");
23
23
  const client_id_1 = require("./client-id");
24
+ const get_git_menu_item_1 = require("./get-git-menu-item");
24
25
  const open_in_editor_1 = require("./open-in-editor");
25
26
  const pick_color_1 = require("./pick-color");
26
27
  const use_keybinding_1 = require("./use-keybinding");
@@ -136,6 +137,7 @@ const getFileMenu = ({ readOnlyStudio, closeMenu, setSelectedModal, previewServe
136
137
  quickSwitcherLabel: 'Open in editor...',
137
138
  }
138
139
  : null,
140
+ (0, get_git_menu_item_1.getGitMenuItem)(),
139
141
  ].filter(no_react_1.NoReactInternals.truthy);
140
142
  if (items.length === 0) {
141
143
  return null;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export type { RenderDefaults } from '@remotion/studio-shared';
1
+ export type { GitSource, RenderDefaults } from '@remotion/studio-shared';
2
2
  export { Studio } from './Studio';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/studio",
3
- "version": "4.0.102",
3
+ "version": "4.0.103",
4
4
  "description": "Remotion Editor",
5
5
  "main": "dist",
6
6
  "sideEffects": false,
@@ -18,11 +18,11 @@
18
18
  "memfs": "3.4.3",
19
19
  "source-map": "0.7.3",
20
20
  "open": "^8.4.2",
21
- "remotion": "4.0.102",
22
- "@remotion/player": "4.0.102",
23
- "@remotion/renderer": "4.0.102",
24
- "@remotion/media-utils": "4.0.102",
25
- "@remotion/studio-shared": "4.0.102"
21
+ "remotion": "4.0.103",
22
+ "@remotion/player": "4.0.103",
23
+ "@remotion/media-utils": "4.0.103",
24
+ "@remotion/renderer": "4.0.103",
25
+ "@remotion/studio-shared": "4.0.103"
26
26
  },
27
27
  "devDependencies": {
28
28
  "react": "18.2.0",
@@ -40,7 +40,7 @@
40
40
  "prettier-plugin-organize-imports": "3.2.4",
41
41
  "vitest": "0.31.1",
42
42
  "zod": "^3.22.3",
43
- "@remotion/zod-types": "4.0.102"
43
+ "@remotion/zod-types": "4.0.103"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "public"