@remotion/cli 3.2.38 → 3.2.40

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 (76) hide show
  1. package/dist/benchmark.js +7 -6
  2. package/dist/compositions.d.ts +1 -1
  3. package/dist/compositions.js +4 -3
  4. package/dist/config/entry-point.d.ts +2 -0
  5. package/dist/config/entry-point.js +12 -0
  6. package/dist/config/every-nth-frame.d.ts +1 -2
  7. package/dist/config/every-nth-frame.js +3 -11
  8. package/dist/config/height.d.ts +2 -2
  9. package/dist/config/height.js +6 -7
  10. package/dist/config/index.d.ts +5 -2
  11. package/dist/config/index.js +15 -8
  12. package/dist/config/number-of-gif-loops.d.ts +1 -2
  13. package/dist/config/number-of-gif-loops.js +3 -9
  14. package/dist/config/width.d.ts +2 -2
  15. package/dist/config/width.js +7 -6
  16. package/dist/editor/components/Canvas.js +3 -0
  17. package/dist/editor/components/Editor.js +1 -2
  18. package/dist/editor/components/GlobalKeybindings.js +9 -1
  19. package/dist/editor/components/KeyboardShortcutsExplainer.d.ts +2 -0
  20. package/dist/editor/components/KeyboardShortcutsExplainer.js +56 -0
  21. package/dist/editor/components/NewComposition/MenuContent.js +7 -0
  22. package/dist/editor/components/PlayPause.js +6 -0
  23. package/dist/editor/components/PlaybackKeyboardShortcutsManager.js +3 -0
  24. package/dist/editor/components/QuickSwitcher/AlgoliaCredit.d.ts +2 -0
  25. package/dist/editor/components/QuickSwitcher/AlgoliaCredit.js +11 -0
  26. package/dist/editor/components/QuickSwitcher/NoResults.d.ts +2 -2
  27. package/dist/editor/components/QuickSwitcher/NoResults.js +6 -1
  28. package/dist/editor/components/QuickSwitcher/QuickSwitcher.d.ts +5 -1
  29. package/dist/editor/components/QuickSwitcher/QuickSwitcher.js +2 -2
  30. package/dist/editor/components/QuickSwitcher/QuickSwitcherContent.d.ts +5 -1
  31. package/dist/editor/components/QuickSwitcher/QuickSwitcherContent.js +117 -27
  32. package/dist/editor/components/QuickSwitcher/QuickSwitcherResult.d.ts +4 -0
  33. package/dist/editor/components/QuickSwitcher/QuickSwitcherResult.js +27 -8
  34. package/dist/editor/components/QuickSwitcher/algolia-search.d.ts +29 -0
  35. package/dist/editor/components/QuickSwitcher/algolia-search.js +63 -0
  36. package/dist/editor/components/TimelineInOutToggle.js +3 -0
  37. package/dist/editor/helpers/use-keybinding.d.ts +1 -0
  38. package/dist/editor/helpers/use-keybinding.js +3 -1
  39. package/dist/editor/helpers/use-menu-structure.js +37 -9
  40. package/dist/editor/state/modals.d.ts +3 -2
  41. package/dist/editor/state/z-index.js +1 -0
  42. package/dist/entry-point.d.ts +5 -0
  43. package/dist/entry-point.js +46 -0
  44. package/dist/get-cli-options.d.ts +3 -3
  45. package/dist/get-cli-options.js +7 -25
  46. package/dist/get-composition-id.d.ts +2 -1
  47. package/dist/get-composition-id.js +8 -6
  48. package/dist/get-composition-with-dimension-override.d.ts +12 -0
  49. package/dist/get-composition-with-dimension-override.js +16 -0
  50. package/dist/get-filename.d.ts +2 -1
  51. package/dist/get-filename.js +2 -1
  52. package/dist/get-render-media-options.js +8 -3
  53. package/dist/index.d.ts +9 -5
  54. package/dist/index.js +11 -11
  55. package/dist/lambda-command.d.ts +1 -1
  56. package/dist/lambda-command.js +2 -3
  57. package/dist/list-of-remotion-packages.js +1 -0
  58. package/dist/parse-command-line.d.ts +2 -0
  59. package/dist/parse-command-line.js +6 -0
  60. package/dist/preview-server/error-overlay/remotion-overlay/AskOnDiscord.js +1 -0
  61. package/dist/preview-server/error-overlay/remotion-overlay/HelpLink.js +1 -0
  62. package/dist/preview-server/error-overlay/remotion-overlay/OpenInEditor.js +1 -0
  63. package/dist/preview-server/error-overlay/remotion-overlay/SearchGitHubIssues.js +1 -0
  64. package/dist/preview-server/error-overlay/remotion-overlay/ShortcutHint.d.ts +1 -0
  65. package/dist/preview-server/error-overlay/remotion-overlay/ShortcutHint.js +3 -3
  66. package/dist/preview.d.ts +1 -1
  67. package/dist/preview.js +4 -2
  68. package/dist/render.d.ts +1 -1
  69. package/dist/render.js +21 -12
  70. package/dist/still.d.ts +1 -1
  71. package/dist/still.js +26 -14
  72. package/dist/user-passed-output-location.d.ts +3 -2
  73. package/dist/user-passed-output-location.js +5 -7
  74. package/package.json +8 -8
  75. package/dist/editor/components/KeyboardShortcutsModal.d.ts +0 -2
  76. package/dist/editor/components/KeyboardShortcutsModal.js +0 -67
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AlgoliaCredit = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const link = {
6
+ display: 'inline-flex',
7
+ };
8
+ const AlgoliaCredit = () => {
9
+ return ((0, jsx_runtime_1.jsx)("a", { style: link, href: "https://www.algolia.com/ref/docsearch/?utm_source=www.remotion.dev&utm_medium=referral&utm_content=powered_by&utm_campaign=docsearch", target: "_blank", rel: "noopener noreferrer", children: (0, jsx_runtime_1.jsx)("svg", { width: "77", height: "19", "aria-label": "Algolia", role: "img", children: (0, jsx_runtime_1.jsx)("path", { d: "M2.5067 0h14.0245c1.384.001 2.5058 1.1205 2.5068 2.5017V16.5c-.0014 1.3808-1.1232 2.4995-2.5068 2.5H2.5067C1.1232 18.9995.0014 17.8808 0 16.5V2.4958A2.495 2.495 0 01.735.7294 2.505 2.505 0 012.5068 0zM37.95 15.0695c-3.7068.0168-3.7068-2.986-3.7068-3.4634L34.2372.3576 36.498 0v11.1794c0 .2715 0 1.9889 1.452 1.994v1.8961zm-9.1666-1.8388c.694 0 1.2086-.0397 1.5678-.1088v-2.2934a5.3639 5.3639 0 00-1.3303-.1679 4.8283 4.8283 0 00-.758.0582 2.2845 2.2845 0 00-.688.2024c-.2029.0979-.371.2362-.4919.4142-.1268.1788-.185.2826-.185.5533 0 .5297.185.8359.5205 1.0375.3355.2016.7928.3053 1.365.3053v-.0008zm-.1969-8.1817c.7463 0 1.3768.092 1.8856.2767.5088.1838.9195.4428 1.2204.7717.3068.334.5147.7777.6423 1.251.1327.4723.196.991.196 1.5603v5.798c-.5235.1036-1.05.192-1.5787.2649-.7048.1037-1.4976.156-2.3774.156-.5832 0-1.1215-.0582-1.6016-.167a3.385 3.385 0 01-1.2432-.5364 2.6034 2.6034 0 01-.8037-.9565c-.191-.3922-.29-.9447-.29-1.5208 0-.5533.11-.905.3246-1.2863a2.7351 2.7351 0 01.8849-.9329c.376-.242.8029-.415 1.2948-.5187a7.4517 7.4517 0 011.5381-.156 7.1162 7.1162 0 011.6667.2024V8.886c0-.259-.0296-.5061-.093-.7372a1.5847 1.5847 0 00-.3245-.6158 1.5079 1.5079 0 00-.6119-.4158 2.6788 2.6788 0 00-.966-.173c-.5206 0-.9948.0634-1.4283.1384a6.5481 6.5481 0 00-1.065.259l-.2712-1.849c.2831-.0986.7048-.1964 1.2491-.2943a9.2979 9.2979 0 011.752-.1501v.0008zm44.6597 8.1193c.6947 0 1.2086-.0405 1.567-.1097v-2.2942a5.3743 5.3743 0 00-1.3303-.1679c-.2485 0-.503.0177-.7573.0582a2.2853 2.2853 0 00-.688.2024 1.2333 1.2333 0 00-.4918.4142c-.1268.1788-.1843.2826-.1843.5533 0 .5297.1843.8359.5198 1.0375.3414.2066.7927.3053 1.365.3053v.0009zm-.191-8.1767c.7463 0 1.3768.0912 1.8856.2759.5087.1847.9195.4436 1.2204.7717.3.329.5147.7786.6414 1.251a5.7248 5.7248 0 01.197 1.562v5.7972c-.3466.0742-.874.1602-1.5788.2648-.7049.1038-1.4976.1552-2.3774.1552-.5832 0-1.1215-.0573-1.6016-.167a3.385 3.385 0 01-1.2432-.5356 2.6034 2.6034 0 01-.8038-.9565c-.191-.3922-.2898-.9447-.2898-1.5216 0-.5533.1098-.905.3245-1.2854a2.7373 2.7373 0 01.8849-.9338c.376-.2412.8029-.4141 1.2947-.5178a7.4545 7.4545 0 012.325-.1097c.2781.0287.5672.081.879.156v-.3686a2.7781 2.7781 0 00-.092-.738 1.5788 1.5788 0 00-.3246-.6166 1.5079 1.5079 0 00-.612-.415 2.6797 2.6797 0 00-.966-.1729c-.5205 0-.9947.0633-1.4282.1384a6.5608 6.5608 0 00-1.065.259l-.2712-1.8498c.283-.0979.7048-.1957 1.2491-.2935a9.8597 9.8597 0 011.752-.1494zm-6.79-1.072c-.7576.001-1.373-.6103-1.3759-1.3664 0-.755.6128-1.3664 1.376-1.3664.764 0 1.3775.6115 1.3775 1.3664s-.6195 1.3664-1.3776 1.3664zm1.1393 11.1507h-2.2726V5.3409l2.2734-.3568v10.0845l-.0008.0017zm-3.984 0c-3.707.0168-3.707-2.986-3.707-3.4642L59.7069.3576 61.9685 0v11.1794c0 .2715 0 1.9889 1.452 1.994V15.0703zm-7.3512-4.979c0-.975-.2138-1.7873-.6305-2.3516-.4167-.571-.9998-.852-1.747-.852-.7454 0-1.3302.281-1.7452.852-.4166.5702-.6195 1.3765-.6195 2.3516 0 .9851.208 1.6473.6254 2.2183.4158.576.9998.8587 1.7461.8587.7454 0 1.3303-.2885 1.747-.8595.4158-.5761.6237-1.2315.6237-2.2184v.0009zm2.3132-.006c0 .7609-.1099 1.3361-.3356 1.9654a4.654 4.654 0 01-.9533 1.6076A4.214 4.214 0 0155.613 14.69c-.579.2412-1.4697.3795-1.9143.3795-.4462-.005-1.3303-.1324-1.9033-.3795a4.307 4.307 0 01-1.474-1.0316c-.4115-.4445-.7293-.9801-.9609-1.6076a5.3423 5.3423 0 01-.3465-1.9653c0-.7608.104-1.493.3356-2.1155a4.683 4.683 0 01.9719-1.5958 4.3383 4.3383 0 011.479-1.0257c.5739-.242 1.2043-.3567 1.8864-.3567.6829 0 1.3125.1197 1.8906.3567a4.1245 4.1245 0 011.4816 1.0257 4.7587 4.7587 0 01.9592 1.5958c.2426.6225.3643 1.3547.3643 2.1155zm-17.0198 0c0 .9448.208 1.9932.6238 2.431.4166.4386.955.6579 1.6142.6579.3584 0 .6998-.0523 1.0176-.1502.3186-.0978.5721-.2134.775-.3517V7.0784a8.8706 8.8706 0 00-1.4926-.1906c-.8206-.0236-1.4452.312-1.8847.8468-.4335.5365-.6533 1.476-.6533 2.3516v-.0008zm6.2863 4.4485c0 1.5385-.3938 2.662-1.1866 3.3773-.791.7136-2.0005 1.0712-3.6308 1.0712-.5958 0-1.834-.1156-2.8228-.334l.3643-1.7865c.8282.173 1.9202.2193 2.4932.2193.9077 0 1.555-.1847 1.943-.5533.388-.3686.578-.916.578-1.643v-.3687a6.8289 6.8289 0 01-.8848.3349c-.3634.1096-.786.167-1.261.167-.6246 0-1.1917-.0979-1.7055-.2944a3.5554 3.5554 0 01-1.3244-.8645c-.3642-.3796-.6541-.8579-.8561-1.4289-.2028-.571-.3068-1.59-.3068-2.339 0-.7034.1099-1.5856.3245-2.1735.2198-.5871.5316-1.0949.9542-1.515.4167-.42.9255-.743 1.5213-.98a5.5923 5.5923 0 012.052-.3855c.7353 0 1.4114.092 2.0707.2024.6592.1088 1.2204.2236 1.6776.35v8.945-.0008zM11.5026 4.2418v-.6511c-.0005-.4553-.3704-.8241-.8266-.8241H8.749c-.4561 0-.826.3688-.8265.824v.669c0 .0742.0693.1264.1445.1096a6.0346 6.0346 0 011.6768-.2362 6.125 6.125 0 011.6202.2185.1116.1116 0 00.1386-.1097zm-5.2806.852l-.3296-.3282a.8266.8266 0 00-1.168 0l-.393.3922a.8199.8199 0 000 1.164l.3237.323c.0524.0515.1268.0397.1733-.0117.191-.259.3989-.507.6305-.7372.2374-.2362.48-.4437.7462-.6335.0575-.0354.0634-.1155.017-.1687zm3.5159 2.069v2.818c0 .081.0879.1392.1622.0987l2.5102-1.2964c.0574-.0287.0752-.0987.0464-.1552a3.1237 3.1237 0 00-2.603-1.574c-.0575 0-.115.0456-.115.1097l-.0008-.0009zm.0008 6.789c-2.0933.0005-3.7915-1.6912-3.7947-3.7804C5.9468 8.0821 7.6452 6.39 9.7387 6.391c2.0932-.0005 3.7911 1.6914 3.794 3.7804a3.7783 3.7783 0 01-1.1124 2.675 3.7936 3.7936 0 01-2.6824 1.1054h.0008zM9.738 4.8002c-1.9218 0-3.6975 1.0232-4.6584 2.6841a5.359 5.359 0 000 5.3683c.9609 1.661 2.7366 2.6841 4.6584 2.6841a5.3891 5.3891 0 003.8073-1.5725 5.3675 5.3675 0 001.578-3.7987 5.3574 5.3574 0 00-1.5771-3.797A5.379 5.379 0 009.7387 4.801l-.0008-.0008z", fill: "currentColor", fillRule: "evenodd" }) }) }));
10
+ };
11
+ exports.AlgoliaCredit = AlgoliaCredit;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- export declare type Mode = 'commands' | 'compositions';
2
+ export declare type QuickSwitcherMode = 'commands' | 'compositions' | 'docs';
3
3
  export declare const QuickSwitcherNoResults: React.FC<{
4
4
  query: string;
5
- mode: Mode;
5
+ mode: QuickSwitcherMode;
6
6
  }>;
@@ -9,7 +9,12 @@ const container = {
9
9
  textAlign: 'center',
10
10
  fontSize: 14,
11
11
  };
12
+ const MODE_TO_STRING = {
13
+ commands: 'commands',
14
+ compositions: 'compositions',
15
+ docs: 'documentation',
16
+ };
12
17
  const QuickSwitcherNoResults = ({ query, mode }) => {
13
- return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: ["No ", mode === 'commands' ? 'commands' : 'compositions', " matching ", '"', query, '"'] }));
18
+ return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: ["No ", MODE_TO_STRING[mode], " matching ", '"', query, '"'] }));
14
19
  };
15
20
  exports.QuickSwitcherNoResults = QuickSwitcherNoResults;
@@ -1,3 +1,7 @@
1
1
  import React from 'react';
2
- declare const QuickSwitcher: React.FC;
2
+ import type { QuickSwitcherMode } from './NoResults';
3
+ declare const QuickSwitcher: React.FC<{
4
+ initialMode: QuickSwitcherMode;
5
+ invocationTimestamp: number;
6
+ }>;
3
7
  export default QuickSwitcher;
@@ -5,12 +5,12 @@ const react_1 = require("react");
5
5
  const modals_1 = require("../../state/modals");
6
6
  const ModalContainer_1 = require("../ModalContainer");
7
7
  const QuickSwitcherContent_1 = require("./QuickSwitcherContent");
8
- const QuickSwitcher = () => {
8
+ const QuickSwitcher = ({ initialMode, invocationTimestamp }) => {
9
9
  const { setSelectedModal } = (0, react_1.useContext)(modals_1.ModalsContext);
10
10
  const onQuit = (0, react_1.useCallback)(() => {
11
11
  setSelectedModal(null);
12
12
  }, [setSelectedModal]);
13
13
  // Separate child component to correctly capture keybindings
14
- return ((0, jsx_runtime_1.jsx)(ModalContainer_1.ModalContainer, { onOutsideClick: onQuit, onEscape: onQuit, children: (0, jsx_runtime_1.jsx)(QuickSwitcherContent_1.QuickSwitcherContent, {}) }));
14
+ return ((0, jsx_runtime_1.jsx)(ModalContainer_1.ModalContainer, { onOutsideClick: onQuit, onEscape: onQuit, children: (0, jsx_runtime_1.jsx)(QuickSwitcherContent_1.QuickSwitcherContent, { invocationTimestamp: invocationTimestamp, initialMode: initialMode }) }));
15
15
  };
16
16
  exports.default = QuickSwitcher;
@@ -1,2 +1,6 @@
1
1
  import React from 'react';
2
- export declare const QuickSwitcherContent: React.FC;
2
+ import type { QuickSwitcherMode } from './NoResults';
3
+ export declare const QuickSwitcherContent: React.FC<{
4
+ initialMode: QuickSwitcherMode;
5
+ invocationTimestamp: number;
6
+ }>;
@@ -10,7 +10,10 @@ const use_keybinding_1 = require("../../helpers/use-keybinding");
10
10
  const use_menu_structure_1 = require("../../helpers/use-menu-structure");
11
11
  const modals_1 = require("../../state/modals");
12
12
  const InitialCompositionLoader_1 = require("../InitialCompositionLoader");
13
+ const KeyboardShortcutsExplainer_1 = require("../KeyboardShortcutsExplainer");
13
14
  const layout_1 = require("../layout");
15
+ const algolia_search_1 = require("./algolia-search");
16
+ const AlgoliaCredit_1 = require("./AlgoliaCredit");
14
17
  const fuzzy_search_1 = require("./fuzzy-search");
15
18
  const NoResults_1 = require("./NoResults");
16
19
  const QuickSwitcherResult_1 = require("./QuickSwitcherResult");
@@ -19,9 +22,6 @@ const input = {
19
22
  border: '2px solid ' + colors_1.INPUT_BORDER_COLOR_UNHOVERED,
20
23
  width: '100%',
21
24
  };
22
- const container = {
23
- width: 500,
24
- };
25
25
  const modeSelector = {
26
26
  paddingLeft: 16,
27
27
  paddingRight: 16,
@@ -52,10 +52,9 @@ const content = {
52
52
  paddingRight: 16,
53
53
  paddingTop: 4,
54
54
  paddingBottom: 10,
55
- };
56
- const results = {
57
- overflowY: 'auto',
58
- height: 300,
55
+ display: 'flex',
56
+ flexDirection: 'row',
57
+ alignItems: 'center',
59
58
  };
60
59
  const loopIndex = (index, length) => {
61
60
  if (index < 0) {
@@ -63,25 +62,56 @@ const loopIndex = (index, length) => {
63
62
  }
64
63
  return index % length;
65
64
  };
66
- const QuickSwitcherContent = () => {
65
+ const stripQuery = (query) => {
66
+ if (query.startsWith('>') || query.startsWith('?')) {
67
+ return query.substring(1).trim();
68
+ }
69
+ return query.trim();
70
+ };
71
+ const mapQueryToMode = (query) => {
72
+ return query.startsWith('>')
73
+ ? 'commands'
74
+ : query.startsWith('?')
75
+ ? 'docs'
76
+ : 'compositions';
77
+ };
78
+ const mapModeToQuery = (mode) => {
79
+ if (mode === 'commands') {
80
+ return '> ';
81
+ }
82
+ if (mode === 'compositions') {
83
+ return '';
84
+ }
85
+ if (mode === 'docs') {
86
+ return '? ';
87
+ }
88
+ throw new Error('no mode' + mode);
89
+ };
90
+ const QuickSwitcherContent = ({ initialMode, invocationTimestamp }) => {
67
91
  const { compositions } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
68
- const [state, setState] = (0, react_1.useState)({
69
- query: '',
70
- selectedIndex: 0,
92
+ const [state, setState] = (0, react_1.useState)(() => {
93
+ return {
94
+ query: mapModeToQuery(initialMode),
95
+ selectedIndex: 0,
96
+ };
71
97
  });
98
+ (0, react_1.useEffect)(() => {
99
+ setState({
100
+ query: mapModeToQuery(initialMode),
101
+ selectedIndex: 0,
102
+ });
103
+ }, [initialMode, invocationTimestamp]);
72
104
  const inputRef = (0, react_1.useRef)(null);
73
105
  const selectComposition = (0, InitialCompositionLoader_1.useSelectComposition)();
74
106
  const closeMenu = (0, react_1.useCallback)(() => undefined, []);
75
107
  const actions = (0, use_menu_structure_1.useMenuStructure)(closeMenu);
108
+ const [docResults, setDocResults] = (0, react_1.useState)({ type: 'initial' });
76
109
  const { setSelectedModal } = (0, react_1.useContext)(modals_1.ModalsContext);
77
110
  const keybindings = (0, use_keybinding_1.useKeybinding)();
78
- const mode = state.query.startsWith('>') ? 'commands' : 'compositions';
111
+ const mode = mapQueryToMode(state.query);
79
112
  const actualQuery = (0, react_1.useMemo)(() => {
80
- if (mode === 'commands') {
81
- return state.query.substring(1).trim();
82
- }
83
- return state.query.trim();
84
- }, [mode, state.query]);
113
+ return stripQuery(state.query);
114
+ }, [state.query]);
85
115
  const menuActions = (0, react_1.useMemo)(() => {
86
116
  if (mode !== 'commands') {
87
117
  return [];
@@ -92,6 +122,9 @@ const QuickSwitcherContent = () => {
92
122
  if (mode === 'commands') {
93
123
  return (0, fuzzy_search_1.fuzzySearch)(actualQuery, menuActions);
94
124
  }
125
+ if (mode === 'docs' && docResults.type === 'results') {
126
+ return docResults.results;
127
+ }
95
128
  return (0, fuzzy_search_1.fuzzySearch)(actualQuery, compositions.map((c) => {
96
129
  return {
97
130
  id: 'composition-' + c.id,
@@ -106,9 +139,10 @@ const QuickSwitcherContent = () => {
106
139
  }));
107
140
  }, [
108
141
  mode,
109
- compositions,
110
142
  actualQuery,
143
+ compositions,
111
144
  menuActions,
145
+ docResults,
112
146
  selectComposition,
113
147
  setSelectedModal,
114
148
  ]);
@@ -135,11 +169,39 @@ const QuickSwitcherContent = () => {
135
169
  callback: onArrowUp,
136
170
  commandCtrlKey: false,
137
171
  event: 'keydown',
172
+ preventDefault: true,
138
173
  });
139
174
  return () => {
140
175
  binding.unregister();
141
176
  };
142
177
  }, [keybindings, onArrowDown, onArrowUp]);
178
+ (0, react_1.useEffect)(() => {
179
+ if (mode !== 'docs') {
180
+ return;
181
+ }
182
+ if (actualQuery.trim() === '') {
183
+ setDocResults({ type: 'initial' });
184
+ return;
185
+ }
186
+ let cancelled = false;
187
+ setDocResults({ type: 'loading' });
188
+ (0, algolia_search_1.algoliaSearch)(actualQuery)
189
+ .then((agoliaResults) => {
190
+ if (cancelled) {
191
+ return;
192
+ }
193
+ setDocResults({ type: 'results', results: agoliaResults });
194
+ })
195
+ .catch((err) => {
196
+ if (cancelled) {
197
+ return;
198
+ }
199
+ setDocResults({ type: 'error', error: err });
200
+ });
201
+ return () => {
202
+ cancelled = true;
203
+ };
204
+ }, [actualQuery, mode]);
143
205
  // Arrow down
144
206
  (0, react_1.useEffect)(() => {
145
207
  const binding = keybindings.registerKeybinding({
@@ -147,6 +209,7 @@ const QuickSwitcherContent = () => {
147
209
  callback: onArrowDown,
148
210
  commandCtrlKey: false,
149
211
  event: 'keydown',
212
+ preventDefault: true,
150
213
  });
151
214
  return () => {
152
215
  binding.unregister();
@@ -158,22 +221,49 @@ const QuickSwitcherContent = () => {
158
221
  const selectedIndexRounded = loopIndex(state.selectedIndex, resultsArray.length);
159
222
  const onActionsSelected = (0, react_1.useCallback)(() => {
160
223
  var _a;
161
- setState({
162
- query: '> ',
224
+ setState((s) => ({
225
+ query: `> ${stripQuery(s.query)}`,
163
226
  selectedIndex: 0,
164
- });
227
+ }));
165
228
  (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
166
229
  }, []);
167
230
  const onCompositionsSelected = (0, react_1.useCallback)(() => {
168
231
  var _a;
169
- setState({
170
- query: '',
232
+ setState((s) => ({
233
+ query: stripQuery(s.query),
171
234
  selectedIndex: 0,
172
- });
235
+ }));
236
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
237
+ }, []);
238
+ const onDocSearchSelected = (0, react_1.useCallback)(() => {
239
+ var _a;
240
+ setState((s) => ({
241
+ query: `? ${stripQuery(s.query)}`,
242
+ selectedIndex: 0,
243
+ }));
244
+ setDocResults({ type: 'initial' });
173
245
  (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
174
246
  }, []);
175
- return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: [(0, jsx_runtime_1.jsxs)("div", { style: modeSelector, children: [(0, jsx_runtime_1.jsx)("button", { onClick: onCompositionsSelected, style: mode === 'compositions' ? modeActive : modeInactive, type: "button", children: "Compositions" }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)("button", { onClick: onActionsSelected, style: mode === 'commands' ? modeActive : modeInactive, type: "button", children: "Actions" })] }), (0, jsx_runtime_1.jsx)("div", { style: content, children: (0, jsx_runtime_1.jsx)("input", { ref: inputRef, type: "text", style: input, autoFocus: true, value: state.query, onChange: onTextChange, placeholder: "Search compositions..." }) }), (0, jsx_runtime_1.jsxs)("div", { style: results, children: [resultsArray.map((result, i) => {
176
- return ((0, jsx_runtime_1.jsx)(QuickSwitcherResult_1.QuickSwitcherResult, { selected: selectedIndexRounded === i, result: result }, result.id));
177
- }), resultsArray.length === 0 ? ((0, jsx_runtime_1.jsx)(NoResults_1.QuickSwitcherNoResults, { mode: mode, query: actualQuery })) : null] })] }));
247
+ const showKeyboardShortcuts = mode === 'docs' && actualQuery.trim() === '';
248
+ const showSearchLoadingState = mode === 'docs' && docResults.type === 'loading';
249
+ const container = (0, react_1.useMemo)(() => {
250
+ return {
251
+ width: showKeyboardShortcuts ? 800 : 500,
252
+ };
253
+ }, [showKeyboardShortcuts]);
254
+ const results = (0, react_1.useMemo)(() => {
255
+ if (showKeyboardShortcuts) {
256
+ return {
257
+ maxHeight: 600,
258
+ };
259
+ }
260
+ return {
261
+ overflowY: 'auto',
262
+ height: 300,
263
+ };
264
+ }, [showKeyboardShortcuts]);
265
+ return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: [(0, jsx_runtime_1.jsxs)("div", { style: modeSelector, children: [(0, jsx_runtime_1.jsx)("button", { onClick: onCompositionsSelected, style: mode === 'compositions' ? modeActive : modeInactive, type: "button", children: "Compositions" }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)("button", { onClick: onActionsSelected, style: mode === 'commands' ? modeActive : modeInactive, type: "button", children: "Actions" }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)("button", { onClick: onDocSearchSelected, style: mode === 'docs' ? modeActive : modeInactive, type: "button", children: "Documentation" })] }), (0, jsx_runtime_1.jsxs)("div", { style: content, children: [(0, jsx_runtime_1.jsx)("input", { ref: inputRef, type: "text", style: input, autoFocus: true, value: state.query, onChange: onTextChange, placeholder: "Search compositions..." }), showKeyboardShortcuts ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 2 }), " ", (0, jsx_runtime_1.jsx)(AlgoliaCredit_1.AlgoliaCredit, {})] })) : null] }), (0, jsx_runtime_1.jsx)("div", { style: results, children: showKeyboardShortcuts ? ((0, jsx_runtime_1.jsx)(KeyboardShortcutsExplainer_1.KeyboardShortcutsExplainer, {})) : showSearchLoadingState ? null : resultsArray.length === 0 ? ((0, jsx_runtime_1.jsx)(NoResults_1.QuickSwitcherNoResults, { mode: mode, query: actualQuery })) : (resultsArray.map((result, i) => {
266
+ return ((0, jsx_runtime_1.jsx)(QuickSwitcherResult_1.QuickSwitcherResult, { selected: selectedIndexRounded === i, result: result }, result.id));
267
+ })) })] }));
178
268
  };
179
269
  exports.QuickSwitcherContent = QuickSwitcherContent;
@@ -4,6 +4,10 @@ declare type QuickSwitcherResultDetail = {
4
4
  compositionType: 'composition' | 'still';
5
5
  } | {
6
6
  type: 'menu-item';
7
+ } | {
8
+ type: 'search-result';
9
+ titleLine: string;
10
+ subtitleLine: string;
7
11
  };
8
12
  export declare type TQuickSwitcherResult = {
9
13
  title: string;
@@ -11,23 +11,29 @@ const layout_1 = require("../layout");
11
11
  const container = {
12
12
  paddingLeft: 16,
13
13
  paddingRight: 16,
14
- paddingTop: 3,
15
- paddingBottom: 3,
16
14
  display: 'flex',
17
15
  flexDirection: 'row',
18
16
  alignItems: 'center',
19
17
  cursor: 'pointer',
20
18
  };
21
19
  const label = {
22
- flex: 1,
23
20
  whiteSpace: 'nowrap',
24
21
  textOverflow: 'ellipsis',
25
- overflow: 'hidden',
22
+ };
23
+ const searchLabel = {
24
+ ...label,
25
+ lineHeight: 1.25,
26
26
  };
27
27
  const iconStyle = {
28
28
  width: 14,
29
29
  height: 14,
30
30
  };
31
+ const labelContainer = {
32
+ overflow: 'hidden',
33
+ flex: 1,
34
+ paddingTop: 5,
35
+ paddingBottom: 5,
36
+ };
31
37
  const QuickSwitcherResult = ({ result, selected }) => {
32
38
  const [hovered, setIsHovered] = (0, react_1.useState)(false);
33
39
  const ref = (0, react_1.useRef)(null);
@@ -55,6 +61,7 @@ const QuickSwitcherResult = ({ result, selected }) => {
55
61
  callback: result.onSelected,
56
62
  commandCtrlKey: false,
57
63
  event: 'keydown',
64
+ preventDefault: true,
58
65
  });
59
66
  return () => {
60
67
  binding.unregister();
@@ -80,11 +87,23 @@ const QuickSwitcherResult = ({ result, selected }) => {
80
87
  }, [hovered, selected]);
81
88
  const labelStyle = (0, react_1.useMemo)(() => {
82
89
  return {
83
- ...label,
84
- color: selected || hovered ? 'white' : colors_1.LIGHT_TEXT,
90
+ ...(result.type === 'search-result' ? searchLabel : label),
91
+ color: result.type === 'search-result'
92
+ ? colors_1.LIGHT_TEXT
93
+ : selected || hovered
94
+ ? 'white'
95
+ : colors_1.LIGHT_TEXT,
85
96
  fontSize: 15,
86
97
  };
87
- }, [hovered, selected]);
88
- return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, style: style, onClick: result.onSelected, children: [result.type === 'composition' ? (result.compositionType === 'still' ? ((0, jsx_runtime_1.jsx)(still_1.StillIcon, { style: iconStyle })) : ((0, jsx_runtime_1.jsx)(film_1.FilmIcon, { style: iconStyle }))) : null, (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)("div", { style: labelStyle, children: result.title })] }, result.id));
98
+ }, [hovered, result.type, selected]);
99
+ return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, style: style, onClick: result.onSelected, children: [result.type === 'composition' ? (result.compositionType === 'still' ? ((0, jsx_runtime_1.jsx)(still_1.StillIcon, { style: iconStyle })) : ((0, jsx_runtime_1.jsx)(film_1.FilmIcon, { style: iconStyle }))) : null, (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)("div", { style: labelContainer, children: result.type === 'search-result' ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: labelStyle,
100
+ // eslint-disable-next-line react/no-danger
101
+ dangerouslySetInnerHTML: {
102
+ __html: result.titleLine,
103
+ } }), (0, jsx_runtime_1.jsx)("div", { style: labelStyle,
104
+ // eslint-disable-next-line react/no-danger
105
+ dangerouslySetInnerHTML: {
106
+ __html: result.subtitleLine,
107
+ } })] })) : ((0, jsx_runtime_1.jsx)("div", { style: labelStyle, children: result.title })) })] }, result.id));
89
108
  };
90
109
  exports.QuickSwitcherResult = QuickSwitcherResult;
@@ -0,0 +1,29 @@
1
+ import type { TQuickSwitcherResult } from './QuickSwitcherResult';
2
+ declare type Levels = 'lvl0' | 'lvl1' | 'lvl2' | 'lvl3' | 'lvl4' | 'lvl5' | 'lvl6';
3
+ export declare type Match = {
4
+ value: string;
5
+ matchLevel: 'none' | 'partial' | 'full';
6
+ };
7
+ declare type DynamicHit = {
8
+ type: 'content';
9
+ _highlightResult: {
10
+ content: Match;
11
+ hierarchy: Record<Levels, Match>;
12
+ };
13
+ } | {
14
+ type: Levels;
15
+ _highlightResult: {
16
+ hierarchy: Record<Levels, Match>;
17
+ };
18
+ };
19
+ declare type Hit = {
20
+ url: string;
21
+ hierarchy: Record<Levels, string | null>;
22
+ objectID: string;
23
+ } & DynamicHit;
24
+ export declare const algoliaSearch: (query: string) => Promise<TQuickSwitcherResult[]>;
25
+ export declare const splitMatchIntoTitleAndSubtitle: (match: Hit) => {
26
+ title: string;
27
+ subtitle: string;
28
+ };
29
+ export {};
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.splitMatchIntoTitleAndSubtitle = exports.algoliaSearch = void 0;
4
+ const truthy_1 = require("../../../truthy");
5
+ const ALGOLIA_API_KEY = '3e42dbd4f895fe93ff5cf40d860c4a85';
6
+ const ALGOLIA_APPLICATION_ID = 'PLSDUOL1CA';
7
+ const AGOLIA_SEARCH_URL = 'https://plsduol1ca-dsn.algolia.net/1/indexes/*/queries';
8
+ const algoliaSearch = async (query) => {
9
+ const url = new URL(AGOLIA_SEARCH_URL);
10
+ url.searchParams.set('x-algolia-agen', encodeURIComponent('Remotion Preview DocSearch'));
11
+ url.searchParams.set('x-algolia-api-key', ALGOLIA_API_KEY);
12
+ url.searchParams.set('x-algolia-application-id', ALGOLIA_APPLICATION_ID);
13
+ const { results } = await fetch(url.toString(), {
14
+ headers: {
15
+ 'content-type': 'application/x-www-form-urlencoded',
16
+ },
17
+ body: JSON.stringify({
18
+ requests: [
19
+ {
20
+ query,
21
+ indexName: 'remotion',
22
+ params: 'attributesToRetrieve=["hierarchy.lvl0","hierarchy.lvl1","hierarchy.lvl2","hierarchy.lvl3","hierarchy.lvl4","hierarchy.lvl5","hierarchy.lvl6","content","type","url"]&attributesToSnippet=["hierarchy.lvl1:10","hierarchy.lvl2:10","hierarchy.lvl3:10","hierarchy.lvl4:10","hierarchy.lvl5:10","hierarchy.lvl6:10","content:10"]&hitsPerPage=20',
23
+ },
24
+ ],
25
+ }),
26
+ method: 'POST',
27
+ }).then((res) => res.json());
28
+ const { hits } = results[0];
29
+ return hits
30
+ .map((hit) => {
31
+ var _a;
32
+ const entries = Object.values(hit._highlightResult.hierarchy);
33
+ const result = (_a = entries.find((value) => value.matchLevel === 'full')) !== null && _a !== void 0 ? _a : entries.find((value) => value.matchLevel === 'partial');
34
+ const { subtitle, title } = (0, exports.splitMatchIntoTitleAndSubtitle)(hit);
35
+ if (!result) {
36
+ return null;
37
+ }
38
+ return {
39
+ type: 'search-result',
40
+ id: hit.objectID,
41
+ title: 'Should not display',
42
+ titleLine: title,
43
+ subtitleLine: subtitle,
44
+ onSelected: () => {
45
+ window.open(hit.url);
46
+ },
47
+ };
48
+ })
49
+ .filter(truthy_1.truthy);
50
+ };
51
+ exports.algoliaSearch = algoliaSearch;
52
+ const splitMatchIntoTitleAndSubtitle = (match) => {
53
+ const main = match.type === 'content'
54
+ ? match._highlightResult.content
55
+ : match._highlightResult.hierarchy[match.type];
56
+ const title = main.value;
57
+ const subtitle = Object.entries(match._highlightResult.hierarchy)
58
+ .filter(([level]) => level !== match.type)
59
+ .map((value) => value[1].value)
60
+ .join(' • ');
61
+ return { title, subtitle };
62
+ };
63
+ exports.splitMatchIntoTitleAndSubtitle = splitMatchIntoTitleAndSubtitle;
@@ -144,6 +144,7 @@ const TimelineInOutPointToggle = () => {
144
144
  onInMark(e);
145
145
  },
146
146
  commandCtrlKey: false,
147
+ preventDefault: true,
147
148
  });
148
149
  const oKey = keybindings.registerKeybinding({
149
150
  event: 'keypress',
@@ -152,6 +153,7 @@ const TimelineInOutPointToggle = () => {
152
153
  onOutMark(e);
153
154
  },
154
155
  commandCtrlKey: false,
156
+ preventDefault: true,
155
157
  });
156
158
  const xKey = keybindings.registerKeybinding({
157
159
  event: 'keypress',
@@ -160,6 +162,7 @@ const TimelineInOutPointToggle = () => {
160
162
  onInOutClear();
161
163
  },
162
164
  commandCtrlKey: false,
165
+ preventDefault: true,
163
166
  });
164
167
  return () => {
165
168
  oKey.unregister();
@@ -6,6 +6,7 @@ export declare const useKeybinding: () => {
6
6
  key: string;
7
7
  commandCtrlKey: boolean;
8
8
  callback: (e: KeyboardEvent) => void;
9
+ preventDefault: boolean;
9
10
  }) => {
10
11
  unregister: () => void;
11
12
  };
@@ -33,7 +33,9 @@ const useKeybinding = () => {
33
33
  if (e.key.toLowerCase() === options.key.toLowerCase() &&
34
34
  options.commandCtrlKey === commandKey) {
35
35
  options.callback(e);
36
- e.preventDefault();
36
+ if (options.preventDefault) {
37
+ e.preventDefault();
38
+ }
37
39
  }
38
40
  };
39
41
  const toRegister = {
@@ -4,6 +4,7 @@ exports.makeSearchResults = exports.useMenuStructure = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const remotion_1 = require("remotion");
7
+ const ShortcutHint_1 = require("../../preview-server/error-overlay/remotion-overlay/ShortcutHint");
7
8
  const truthy_1 = require("../../truthy");
8
9
  const layout_1 = require("../components/layout");
9
10
  const SizeSelector_1 = require("../components/SizeSelector");
@@ -160,7 +161,7 @@ const useMenuStructure = (closeMenu) => {
160
161
  quickSwitcherLabel: null,
161
162
  },
162
163
  {
163
- id: 'timeline-divider',
164
+ id: 'timeline-divider-1',
164
165
  type: 'divider',
165
166
  },
166
167
  {
@@ -199,7 +200,7 @@ const useMenuStructure = (closeMenu) => {
199
200
  subMenu: null,
200
201
  type: 'item',
201
202
  value: 'expanded',
202
- quickSwitcherLabel: null,
203
+ quickSwitcherLabel: 'Expand',
203
204
  },
204
205
  {
205
206
  id: 'sidebar-collapsed',
@@ -212,14 +213,14 @@ const useMenuStructure = (closeMenu) => {
212
213
  subMenu: null,
213
214
  type: 'item',
214
215
  value: 'collapsed',
215
- quickSwitcherLabel: null,
216
+ quickSwitcherLabel: 'Collapse',
216
217
  },
217
218
  ],
218
219
  },
219
220
  onClick: () => undefined,
220
221
  },
221
222
  {
222
- id: 'timeline-divider',
223
+ id: 'timeline-divider-2',
223
224
  type: 'divider',
224
225
  },
225
226
  {
@@ -239,7 +240,7 @@ const useMenuStructure = (closeMenu) => {
239
240
  : 'Enable Checkerboard Transparency',
240
241
  },
241
242
  {
242
- id: 'timeline-divider',
243
+ id: 'timeline-divider-3',
243
244
  type: 'divider',
244
245
  },
245
246
  {
@@ -289,7 +290,29 @@ const useMenuStructure = (closeMenu) => {
289
290
  quickSwitcherLabel: 'Timeline: Collapse all layers',
290
291
  },
291
292
  {
292
- id: 'in-out-divider',
293
+ id: 'in-out-divider-4',
294
+ type: 'divider',
295
+ },
296
+ {
297
+ id: 'quick-switcher',
298
+ keyHint: `${ShortcutHint_1.cmdOrCtrlCharacter}+K`,
299
+ label: 'Quick Switcher',
300
+ onClick: () => {
301
+ closeMenu();
302
+ setSelectedModal({
303
+ type: 'quick-switcher',
304
+ mode: 'compositions',
305
+ invocationTimestamp: Date.now(),
306
+ });
307
+ },
308
+ type: 'item',
309
+ value: 'quick-switcher',
310
+ leftItem: null,
311
+ subMenu: null,
312
+ quickSwitcherLabel: 'Switch composition',
313
+ },
314
+ {
315
+ id: 'in-out-divider-5',
293
316
  type: 'divider',
294
317
  },
295
318
  {
@@ -349,7 +372,10 @@ const useMenuStructure = (closeMenu) => {
349
372
  id: 'color-picker',
350
373
  value: 'color-picker',
351
374
  label: 'Color Picker',
352
- onClick: () => (0, pick_color_1.pickColor)(),
375
+ onClick: () => {
376
+ closeMenu();
377
+ (0, pick_color_1.pickColor)();
378
+ },
353
379
  leftItem: null,
354
380
  keyHint: null,
355
381
  subMenu: null,
@@ -374,7 +400,9 @@ const useMenuStructure = (closeMenu) => {
374
400
  onClick: () => {
375
401
  closeMenu();
376
402
  setSelectedModal({
377
- type: 'shortcuts',
403
+ type: 'quick-switcher',
404
+ mode: 'docs',
405
+ invocationTimestamp: Date.now(),
378
406
  });
379
407
  },
380
408
  keyHint: '?',
@@ -428,7 +456,7 @@ const useMenuStructure = (closeMenu) => {
428
456
  quickSwitcherLabel: null,
429
457
  },
430
458
  {
431
- id: 'help-divider',
459
+ id: 'help-divider-6',
432
460
  type: 'divider',
433
461
  },
434
462
  {