@remotion/cli 3.2.1 → 3.2.4

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.
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare const serverDisconnectedRef: React.RefObject<{
3
+ setServerDisconnected: () => void;
4
+ }>;
5
+ export declare const ServerDisconnected: React.FC;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ServerDisconnected = exports.serverDisconnectedRef = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const container = {
7
+ position: 'fixed',
8
+ justifyContent: 'flex-end',
9
+ alignItems: 'flex-start',
10
+ display: 'flex',
11
+ width: '100%',
12
+ height: '100%',
13
+ flexDirection: 'column',
14
+ padding: 30,
15
+ pointerEvents: 'none',
16
+ backgroundColor: 'transparent',
17
+ fontFamily: 'SF Pro, Arial, Helvetica, sans-serif',
18
+ };
19
+ const message = {
20
+ backgroundColor: '#e74c3c',
21
+ color: 'white',
22
+ paddingLeft: 20,
23
+ paddingRight: 20,
24
+ paddingTop: 12,
25
+ paddingBottom: 12,
26
+ borderRadius: 4,
27
+ boxShadow: '0 2px 4px rgba(0, 0, 0, 0.4)',
28
+ lineHeight: 1.5,
29
+ };
30
+ const inlineCode = {
31
+ fontSize: 16,
32
+ fontFamily: 'monospace',
33
+ };
34
+ exports.serverDisconnectedRef = (0, react_1.createRef)();
35
+ let pageIsGoingToReload = false;
36
+ window.addEventListener('beforeunload', () => {
37
+ pageIsGoingToReload = true;
38
+ });
39
+ const ServerDisconnected = () => {
40
+ const [serverDisconnected, setServerDisconnected] = (0, react_1.useState)(false);
41
+ (0, react_1.useImperativeHandle)(exports.serverDisconnectedRef, () => {
42
+ return {
43
+ setServerDisconnected: () => {
44
+ setServerDisconnected(true);
45
+ },
46
+ };
47
+ }, []);
48
+ if (!serverDisconnected) {
49
+ return null;
50
+ }
51
+ if (pageIsGoingToReload) {
52
+ return null;
53
+ }
54
+ return ((0, jsx_runtime_1.jsx)("div", { style: container, className: "css-reset", children: (0, jsx_runtime_1.jsxs)("div", { style: message, children: ["The preview server has disconnected. ", (0, jsx_runtime_1.jsx)("br", {}), window.remotion_previewServerCommand ? ((0, jsx_runtime_1.jsxs)("span", { children: ["Run", ' ', (0, jsx_runtime_1.jsx)("code", { style: inlineCode, children: window.remotion_previewServerCommand }), ' ', "to run it again."] })) : ((0, jsx_runtime_1.jsx)("span", { children: "Fast refresh will not work." }))] }) }));
55
+ };
56
+ exports.ServerDisconnected = ServerDisconnected;
@@ -12,4 +12,4 @@ export declare const TIMELINE_BACKGROUND = "#111";
12
12
  export declare const getBackgroundFromHoverState: ({ selected, hovered, }: {
13
13
  selected: boolean;
14
14
  hovered: boolean;
15
- }) => "hsla(0, 0%, 100%, 0.15)" | "hsla(0, 0%, 100%, 0.25)" | "rgba(255, 255, 255, 0.06)" | "transparent";
15
+ }) => "transparent" | "hsla(0, 0%, 100%, 0.15)" | "hsla(0, 0%, 100%, 0.25)" | "rgba(255, 255, 255, 0.06)";
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.openEventSource = void 0;
4
+ const ServerDisconnected_1 = require("./editor/components/Notifications/ServerDisconnected");
4
5
  let source = null;
5
6
  const openEventSource = () => {
6
7
  source = new EventSource('/events');
@@ -10,5 +11,10 @@ const openEventSource = () => {
10
11
  window.location.reload();
11
12
  }
12
13
  });
14
+ source.addEventListener('error', () => {
15
+ var _a;
16
+ // Display an error message that the preview server has disconnected.
17
+ (_a = ServerDisconnected_1.serverDisconnectedRef.current) === null || _a === void 0 ? void 0 : _a.setServerDisconnected();
18
+ });
13
19
  };
14
20
  exports.openEventSource = openEventSource;
@@ -31,7 +31,15 @@ const crashWithFrames = (crash) => (error) => {
31
31
  var _a;
32
32
  const didHookOrderChange = error.message.startsWith('Rendered fewer hooks') ||
33
33
  error.message.startsWith('Rendered more hooks');
34
- if (didHookOrderChange) {
34
+ const key = 'remotion.lastCrashBecauseOfHooks';
35
+ const previousCrashWasBecauseOfHooks = window.localStorage.getItem(key);
36
+ // When rendering conditional hooks, refreshing does not help.
37
+ // So we only refresh once.
38
+ const justRefreshedBecauseOfHooks = previousCrashWasBecauseOfHooks
39
+ ? Date.now() - Number(previousCrashWasBecauseOfHooks) < 5000
40
+ : false;
41
+ window.localStorage.setItem('remotion.lastCrashBecauseOfHooks', String(Date.now()));
42
+ if (didHookOrderChange && !justRefreshedBecauseOfHooks) {
35
43
  // eslint-disable-next-line no-console
36
44
  console.log('Hook order changed. Reloading app...');
37
45
  window.location.reload();
@@ -26,6 +26,6 @@ const Button = ({ children, onClick, disabled, style }) => {
26
26
  ...(style !== null && style !== void 0 ? style : {}),
27
27
  };
28
28
  }, [style]);
29
- return ((0, jsx_runtime_1.jsx)("button", { style: combined, type: "button", disabled: disabled, onClick: onClick, children: (0, jsx_runtime_1.jsx)("div", { style: buttonContainer, children: children }) }));
29
+ return ((0, jsx_runtime_1.jsx)("button", { style: combined, type: "button", disabled: disabled, onClick: onClick, children: (0, jsx_runtime_1.jsx)("div", { className: "css-reset", style: buttonContainer, children: children }) }));
30
30
  };
31
31
  exports.Button = Button;
@@ -13,6 +13,8 @@ const lineNumber = {
13
13
  paddingLeft: 10,
14
14
  paddingRight: 12,
15
15
  marginRight: 12,
16
+ color: 'inherit',
17
+ fontSize: 14,
16
18
  };
17
19
  const CodeFrame = ({ source, lineNumberWidth }) => {
18
20
  return ((0, jsx_runtime_1.jsx)("div", { style: frame, children: source.map((s, j) => {
@@ -16,9 +16,11 @@ const container = {
16
16
  marginBottom: 15,
17
17
  };
18
18
  const messageContainer = {
19
+ overflow: 'hidden',
20
+ };
21
+ const textContainer = {
19
22
  fontSize,
20
23
  lineHeight,
21
- overflow: 'hidden',
22
24
  };
23
25
  const moreLine = {
24
26
  width: '100%',
@@ -62,6 +64,6 @@ const ErrorMessage = ({ message }) => {
62
64
  const toggle = (0, react_1.useCallback)(() => {
63
65
  setExpanded((e) => !e);
64
66
  }, []);
65
- return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: [(0, jsx_runtime_1.jsx)("div", { style: style, children: (0, jsx_runtime_1.jsx)("div", { ref: ref, children: message }) }), errorLines !== null && errorLines > maxLines ? ((0, jsx_runtime_1.jsx)("div", { style: moreLine, children: (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: toggle, style: moreButton, children: (0, jsx_runtime_1.jsx)(carets_1.CaretDown, { invert: expanded }) }) })) : null] }));
67
+ return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: [(0, jsx_runtime_1.jsx)("div", { style: style, children: (0, jsx_runtime_1.jsx)("div", { ref: ref, style: textContainer, children: message }) }), errorLines !== null && errorLines > maxLines ? ((0, jsx_runtime_1.jsx)("div", { style: moreLine, children: (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: toggle, style: moreButton, children: (0, jsx_runtime_1.jsx)(carets_1.CaretDown, { invert: expanded }) }) })) : null] }));
66
68
  };
67
69
  exports.ErrorMessage = ErrorMessage;
@@ -32,6 +32,6 @@ const spacer = {
32
32
  width: 5,
33
33
  };
34
34
  const ErrorTitle = ({ name, message, symbolicating }) => {
35
- return ((0, jsx_runtime_1.jsxs)("div", { style: title, children: [(0, jsx_runtime_1.jsxs)("div", { style: left, children: [(0, jsx_runtime_1.jsx)("span", { style: errName, children: name }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)("div", { style: row, children: [symbolicating ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Symbolicating_1.Symbolicating, {}), (0, jsx_runtime_1.jsx)("div", { style: spacer })] })) : null, (0, jsx_runtime_1.jsx)(ErrorMessage_1.ErrorMessage, { message: message })] })] }), (0, react_overlay_1.didUnmountReactApp)() ? null : (0, jsx_runtime_1.jsx)(DismissButton_1.DismissButton, {})] }));
35
+ return ((0, jsx_runtime_1.jsxs)("div", { style: title, className: "css-reset", children: [(0, jsx_runtime_1.jsxs)("div", { style: left, children: [(0, jsx_runtime_1.jsx)("span", { style: errName, children: name }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)("div", { style: row, children: [symbolicating ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Symbolicating_1.Symbolicating, {}), (0, jsx_runtime_1.jsx)("div", { style: spacer })] })) : null, (0, jsx_runtime_1.jsx)(ErrorMessage_1.ErrorMessage, { message: message })] })] }), (0, react_overlay_1.didUnmountReactApp)() ? null : (0, jsx_runtime_1.jsx)(DismissButton_1.DismissButton, {})] }));
36
36
  };
37
37
  exports.ErrorTitle = ErrorTitle;
@@ -10,6 +10,7 @@ const format_location_1 = require("./format-location");
10
10
  const location = {
11
11
  color: 'rgba(255, 255, 255, 0.6)',
12
12
  fontFamily: 'monospace',
13
+ fontSize: 14,
13
14
  };
14
15
  const header = {
15
16
  paddingLeft: 14,
@@ -28,6 +29,7 @@ const left = {
28
29
  };
29
30
  const fnName = {
30
31
  fontSize: 14,
32
+ lineHeight: 1.5,
31
33
  marginBottom: 3,
32
34
  };
33
35
  const StackElement = ({ s, lineNumberWidth, isFirst, defaultFunctionName }) => {
@@ -41,7 +43,7 @@ const StackElement = ({ s, lineNumberWidth, isFirst, defaultFunctionName }) => {
41
43
  const toggleCodeFrame = (0, react_1.useCallback)(() => {
42
44
  setShowCodeFrame((f) => !f);
43
45
  }, []);
44
- return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { style: header, children: [(0, jsx_runtime_1.jsxs)("div", { style: left, children: [(0, jsx_runtime_1.jsx)("div", { style: fnName, children: (_a = s.originalFunctionName) !== null && _a !== void 0 ? _a : defaultFunctionName }), s.originalFileName ? ((0, jsx_runtime_1.jsxs)("div", { style: location, children: [(0, format_location_1.formatLocation)(s.originalFileName), ":", s.originalLineNumber] })) : null] }), s.originalScriptCode && s.originalScriptCode.length > 0 ? ((0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: toggleCodeFrame, children: showCodeFrame ? (0, jsx_runtime_1.jsx)(carets_1.CaretDown, { invert: false }) : (0, jsx_runtime_1.jsx)(carets_1.CaretRight, {}) })) : null] }), (0, jsx_runtime_1.jsx)("div", { children: s.originalScriptCode &&
46
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "css-reset", children: [(0, jsx_runtime_1.jsxs)("div", { style: header, children: [(0, jsx_runtime_1.jsxs)("div", { style: left, children: [(0, jsx_runtime_1.jsx)("div", { style: fnName, children: (_a = s.originalFunctionName) !== null && _a !== void 0 ? _a : defaultFunctionName }), s.originalFileName ? ((0, jsx_runtime_1.jsxs)("div", { style: location, children: [(0, format_location_1.formatLocation)(s.originalFileName), ":", s.originalLineNumber] })) : null] }), s.originalScriptCode && s.originalScriptCode.length > 0 ? ((0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: toggleCodeFrame, children: showCodeFrame ? (0, jsx_runtime_1.jsx)(carets_1.CaretDown, { invert: false }) : (0, jsx_runtime_1.jsx)(carets_1.CaretRight, {}) })) : null] }), (0, jsx_runtime_1.jsx)("div", { children: s.originalScriptCode &&
45
47
  s.originalScriptCode.length > 0 &&
46
48
  showCodeFrame ? ((0, jsx_runtime_1.jsx)(CodeFrame_1.CodeFrame, { lineNumberWidth: lineNumberWidth, source: s.originalScriptCode })) : null })] }));
47
49
  };
@@ -3,6 +3,7 @@ declare type LockfilePath = {
3
3
  manager: PackageManager;
4
4
  path: string;
5
5
  installCommand: string;
6
+ startCommand: string;
6
7
  };
7
8
  export declare const lockFilePaths: LockfilePath[];
8
9
  export declare const getPackageManager: (remotionRoot: string) => LockfilePath | 'unknown';
@@ -7,16 +7,23 @@ exports.getPackageManager = exports.lockFilePaths = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  exports.lockFilePaths = [
10
- { path: 'package-lock.json', manager: 'npm', installCommand: 'npm i' },
10
+ {
11
+ path: 'package-lock.json',
12
+ manager: 'npm',
13
+ installCommand: 'npm i',
14
+ startCommand: 'npm start',
15
+ },
11
16
  {
12
17
  path: 'yarn.lock',
13
18
  manager: 'yarn',
14
19
  installCommand: 'yarn add',
20
+ startCommand: 'yarn start',
15
21
  },
16
22
  {
17
23
  path: 'pnpm-lock.yaml',
18
24
  manager: 'pnpm',
19
25
  installCommand: 'pnpm i',
26
+ startCommand: 'pnpm start',
20
27
  },
21
28
  ];
22
29
  const getPackageManager = (remotionRoot) => {
@@ -10,6 +10,7 @@ const path_1 = __importDefault(require("path"));
10
10
  const url_1 = require("url");
11
11
  const get_file_source_1 = require("./error-overlay/react-overlay/utils/get-file-source");
12
12
  const open_in_editor_1 = require("./error-overlay/react-overlay/utils/open-in-editor");
13
+ const get_package_manager_1 = require("./get-package-manager");
13
14
  const project_info_1 = require("./project-info");
14
15
  const serve_static_1 = require("./serve-static");
15
16
  const update_available_1 = require("./update-available");
@@ -29,12 +30,14 @@ const handleFallback = async ({ remotionRoot, hash, response, getCurrentInputPro
29
30
  const displayName = (0, open_in_editor_1.getDisplayNameForEditor)(edit ? edit.command : null);
30
31
  response.setHeader('content-type', 'text/html');
31
32
  response.writeHead(200);
33
+ const packageManager = (0, get_package_manager_1.getPackageManager)(remotionRoot);
32
34
  response.end(bundler_1.BundlerInternals.indexHtml({
33
35
  staticHash: hash,
34
36
  baseDir: '/',
35
37
  editorName: displayName,
36
38
  inputProps: getCurrentInputProps(),
37
39
  remotionRoot,
40
+ previewServerCommand: packageManager === 'unknown' ? null : packageManager.startCommand,
38
41
  }));
39
42
  };
40
43
  const handleProjectInfo = async (remotionRoot, _, response) => {
@@ -9,13 +9,19 @@ const client_1 = __importDefault(require("react-dom/client"));
9
9
  const remotion_1 = require("remotion");
10
10
  require("../styles/styles.css");
11
11
  const Editor_1 = require("./editor/components/Editor");
12
+ const ServerDisconnected_1 = require("./editor/components/Notifications/ServerDisconnected");
12
13
  const event_source_1 = require("./event-source");
13
14
  remotion_1.Internals.CSSUtils.injectCSS(remotion_1.Internals.CSSUtils.makeDefaultCSS(null, '#1f2428'));
15
+ const getServerDisconnectedDomElement = () => {
16
+ return document.getElementById('server-disconnected-overlay');
17
+ };
14
18
  const content = ((0, jsx_runtime_1.jsx)(remotion_1.Internals.RemotionRoot, { children: (0, jsx_runtime_1.jsx)(Editor_1.Editor, {}) }));
15
19
  if (client_1.default.createRoot) {
16
20
  client_1.default.createRoot(remotion_1.Internals.getPreviewDomElement()).render(content);
21
+ client_1.default.createRoot(getServerDisconnectedDomElement()).render((0, jsx_runtime_1.jsx)(ServerDisconnected_1.ServerDisconnected, {}));
17
22
  }
18
23
  else {
19
24
  client_1.default.render((0, jsx_runtime_1.jsx)(remotion_1.Internals.RemotionRoot, { children: (0, jsx_runtime_1.jsx)(Editor_1.Editor, {}) }), remotion_1.Internals.getPreviewDomElement());
25
+ client_1.default.render((0, jsx_runtime_1.jsx)(ServerDisconnected_1.ServerDisconnected, {}), getServerDisconnectedDomElement());
20
26
  }
21
27
  (0, event_source_1.openEventSource)();
package/dist/upgrade.js CHANGED
@@ -41,6 +41,7 @@ const upgrade = async (remotionRoot) => {
41
41
  '@remotion/media-utils',
42
42
  '@remotion/babel-loader',
43
43
  '@remotion/lambda',
44
+ '@remotion/player',
44
45
  '@remotion/preload',
45
46
  '@remotion/three',
46
47
  '@remotion/gif',
package/dist/versions.js CHANGED
@@ -21,6 +21,7 @@ const packages = [
21
21
  '@remotion/babel-loader',
22
22
  '@remotion/lambda',
23
23
  '@remotion/preload',
24
+ '@remotion/player',
24
25
  '@remotion/three',
25
26
  '@remotion/gif',
26
27
  'remotion',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/cli",
3
- "version": "3.2.1",
3
+ "version": "3.2.4",
4
4
  "description": "CLI for Remotion",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -23,15 +23,15 @@
23
23
  "author": "Jonny Burger <jonny@remotion.dev>",
24
24
  "license": "SEE LICENSE IN LICENSE.md",
25
25
  "dependencies": {
26
- "@remotion/bundler": "3.2.1",
27
- "@remotion/media-utils": "3.2.1",
28
- "@remotion/player": "3.2.1",
29
- "@remotion/renderer": "3.2.1",
26
+ "@remotion/bundler": "3.2.4",
27
+ "@remotion/media-utils": "3.2.4",
28
+ "@remotion/player": "3.2.4",
29
+ "@remotion/renderer": "3.2.4",
30
30
  "better-opn": "2.1.1",
31
31
  "dotenv": "9.0.2",
32
32
  "memfs": "3.4.3",
33
33
  "minimist": "1.2.6",
34
- "remotion": "3.2.1",
34
+ "remotion": "3.2.4",
35
35
  "semver": "7.3.5",
36
36
  "source-map": "0.6.1"
37
37
  },
@@ -71,5 +71,5 @@
71
71
  "publishConfig": {
72
72
  "access": "public"
73
73
  },
74
- "gitHead": "0c4f0e1fdd423b882bf3dbc48b50037f9d5251c8"
74
+ "gitHead": "ee420b99227e0e5bcf093c108e3695f5d46e3658"
75
75
  }