🎥 Make videos programmatically with React
Hide composition-root interactive sequence from timeline
Jonny Burgerd1d328ed8ad5
diff --git a/packages/core/src/Interactive.tsx b/packages/core/src/Interactive.tsxindex 3ab91bbae8..84ab815a0d 100644--- a/packages/core/src/Interactive.tsx+++ b/packages/core/src/Interactive.tsx@@ -28,6 +28,7 @@ import {import {resolveSequenceDuration} from './resolve-sequence-duration.js';import type {AbsoluteFillLayout, SequenceProps} from './Sequence.js';import {Sequence, SequenceWithoutSchema} from './Sequence.js';+import {SequenceContext} from './SequenceContext.js';import {useCropStyle} from './use-crop-style.js';import {usePremounting} from './use-premounting.js';import {@@ -354,15 +355,18 @@ const withSchema: WithSchema = (untypedOptions: unknown) => {ComponentWrappedInSequenceProps>((props, ref) => {const {canvasContent, compositions} = useContext(CompositionManager);+ const parentSequence = useContext(SequenceContext);// The render callback runs after the exported wrapper has been initialized.// eslint-disable-next-line @typescript-eslint/no-use-before-defineconst componentIdentity = resolveComponentIdentity(Wrapped);- const isCurrentComposition = compositions.some(- (composition) =>- canvasContent?.type === 'composition' &&- composition.id === canvasContent.compositionId &&- composition.componentFromProps === componentIdentity,- );+ const isCurrentComposition =+ parentSequence === null &&+ compositions.some(+ (composition) =>+ canvasContent?.type === 'composition' &&+ composition.id === canvasContent.compositionId &&+ composition.componentFromProps === componentIdentity,+ );const {durationInFrames,from,@@ -437,7 +441,7 @@ const withSchema: WithSchema = (untypedOptions: unknown) => {freeze={freeze}hidden={hidden}name={name ?? componentName}- showInTimeline={showInTimeline}+ showInTimeline={isCurrentComposition ? false : showInTimeline}controls={controls}_remotionInternalPremountDisplay={effectivePremountFor || null}_remotionInternalPostmountDisplay={effectivePostmountFor || null}diff --git a/packages/studio/src/components/InspectorOpenInEditor.tsx b/packages/studio/src/components/InspectorOpenInEditor.tsxindex 659d29f8ce..e6c07b1981 100644--- a/packages/studio/src/components/InspectorOpenInEditor.tsx+++ b/packages/studio/src/components/InspectorOpenInEditor.tsx@@ -116,7 +116,9 @@ export const InspectorOpenInEditor: React.FC<{defaultOpenInTarget === 'git-source'? 'GitHub': (defaultEditorName ?? 'default editor');- const canOpenDefault = location !== null && defaultOpenInTarget !== null;+ const canOpenDefault = Boolean(+ location?.source && defaultOpenInTarget !== null,+ );const onOpenDefault: React.MouseEventHandler<HTMLButtonElement> = useCallback((event) => {event.stopPropagation();@@ -138,7 +140,7 @@ export const InspectorOpenInEditor: React.FC<{const items = getOpenInMenuItems({canOpenDesktopApps: canConfigureApps,codingAgentInfo,- editorDisabled: location === null || !canOpenInEditor,+ editorDisabled: !location?.source || !canOpenInEditor,editorInfo,excludeCodingAgentId: null,excludeEditorId: defaultEditorId,@@ -146,7 +148,7 @@ export const InspectorOpenInEditor: React.FC<{fileManagerDisabled:!location?.source || previewServerState.type !== 'connected',folder: locationType === 'folder',- gitSourceDisabled: location === null,+ gitSourceDisabled: !location?.source,onConfigureApps: configureDefaultApps,onCopyPath:locationType === 'folder' &&@@ -257,7 +259,7 @@ export const InspectorOpenInEditor: React.FC<{result.push({ariaLabel: 'Open in...',buttonId: null,- disabled: false,+ disabled: !location?.source && !contextForAgents,idleColor: LIGHT_TEXT,leaveLeftSpace: true,onOpenChange: null,@@ -274,10 +276,12 @@ export const InspectorOpenInEditor: React.FC<{return result;}, [canOpenDefault,+ contextForAgents,defaultAppName,defaultEditorId,defaultOpenInTarget,label,+ location,menuItems,onOpenDefault,showTooltips,diff --git a/packages/studio/src/components/Timeline/TimelineStack/get-stack.ts b/packages/studio/src/components/Timeline/TimelineStack/get-stack.tsindex 5b7c89bf9b..a907b2742d 100644--- a/packages/studio/src/components/Timeline/TimelineStack/get-stack.ts+++ b/packages/studio/src/components/Timeline/TimelineStack/get-stack.ts@@ -11,6 +11,20 @@ const traceMapPromises: Partial<Record<string, Promise<TraceMap>>> = {};const traceMapsByOriginalSource = new Map<string, TraceMap>();const sourceMapFilesCache = new WeakMap<TraceMap, Record<string, string>>();+const isInternalSource = (source: string | null): boolean => {+ if (source === null) {+ return false;+ }++ const normalizedSource = source.replaceAll('\\', '/');+ // Generated and Remotion runtime files are not authored sequence locations.+ return (+ /(?:^|\/)node_modules\//.test(normalizedSource) ||+ /(?:^|\/)dist\/(?:[^/]+\/)*[^/]+\.(?:cjs|mjs|js)$/.test(normalizedSource) ||+ /(?:^|\/)(?:packages\/)?core\/src\//.test(normalizedSource)+ );+};+const getSourceMapCache = (fileName: string): Promise<TraceMap> => {if (traceMapCache[fileName]) {return Promise.resolve(traceMapCache[fileName]);@@ -84,6 +98,10 @@ export const getOriginalLocationFromStack = async (// Bundlers that record the JSX source location skip symbolication.const originalSource = Internals.parseOriginalSourceStack(stack);if (originalSource) {+ if (isInternalSource(originalSource.fileName)) {+ return null;+ }+return {column: originalSource.column,line: originalSource.line,@@ -97,5 +115,5 @@ export const getOriginalLocationFromStack = async (location.lineNumber as number,location.columnNumber as number,);- return originalPosition;+ return isInternalSource(originalPosition.source) ? null : originalPosition;};diff --git a/packages/studio/src/components/Timeline/get-sequence-context-menu-items.ts b/packages/studio/src/components/Timeline/get-sequence-context-menu-items.tsindex 5fc96567b8..003ec62669 100644--- a/packages/studio/src/components/Timeline/get-sequence-context-menu-items.ts+++ b/packages/studio/src/components/Timeline/get-sequence-context-menu-items.ts@@ -260,14 +260,14 @@ export const getSequenceContextMenuItems = ({const openInMenuItems = getOpenInMenuItems({canOpenDesktopApps: onConfigureApps !== null,codingAgentInfo,- editorDisabled: !canOpenInEditor || !originalLocation,+ editorDisabled: !canOpenInEditor || !originalLocation?.source,editorInfo,excludeCodingAgentId: null,excludeEditorId: defaultEditorId,excludeGitSource: defaultOpenInTarget === 'git-source',fileManagerDisabled: !originalLocation?.source,folder: false,- gitSourceDisabled: !originalLocation,+ gitSourceDisabled: !originalLocation?.source,onConfigureApps,onOpenInCodingAgent: openInCodingAgentWithContext,onOpenInEditor: openInEditor,@@ -298,7 +298,7 @@ export const getSequenceContextMenuItems = ({keyHint: null,label: `Open in ${defaultOpenInName}`,leftItem: null,- disabled: !originalLocation,+ disabled: !originalLocation?.source,onClick: () => {if (defaultOpenInTarget === 'editor') {openInEditor(null);@@ -322,7 +322,7 @@ export const getSequenceContextMenuItems = ({keyHint: null,label: 'Open in...',leftItem: null,- disabled: false,+ disabled: !originalLocation?.source,onClick: () => undefined,quickSwitcherLabel: null,subMenu: {diff --git a/packages/studio/src/components/composition-menu-items.ts b/packages/studio/src/components/composition-menu-items.tsindex 13a6e225e5..7d554f9aae 100644--- a/packages/studio/src/components/composition-menu-items.ts+++ b/packages/studio/src/components/composition-menu-items.ts@@ -65,7 +65,10 @@ export const getCompositionMenuItems = ({root: window.remotion_cwd,});const openCompositionInEditorDisabled =- !defaultEditorId || !composition || !canOpenInEditor || !resolvedLocation;+ !defaultEditorId ||+ !composition ||+ !canOpenInEditor ||+ !resolvedLocation?.source;const openComponentInEditorDisabled =openCompositionInEditorDisabled || !resolvedLocation?.source;const gitSourceName = window.remotion_gitSource@@ -74,7 +77,8 @@ export const getCompositionMenuItems = ({const defaultOpenInTarget = getDefaultOpenInTarget({canOpenInEditor});const defaultOpenInName =defaultOpenInTarget === 'editor' ? defaultEditorName : gitSourceName;- const openCompositionInGitSourceDisabled = !composition || !resolvedLocation;+ const openCompositionInGitSourceDisabled =+ !composition || !resolvedLocation?.source;const openComponentInGitSourceDisabled =openCompositionInGitSourceDisabled ||!resolvedLocation?.source ||@@ -258,6 +262,7 @@ export const getCompositionMenuItems = ({keyHint: null,label: 'Open composition in...',leftItem: null,+ disabled: !resolvedLocation?.source,onClick: () => undefined,quickSwitcherLabel: 'Composition',subMenu: {@@ -304,6 +309,7 @@ export const getCompositionMenuItems = ({keyHint: null,label: 'Open component in...',leftItem: null,+ disabled: !resolvedLocation?.source,onClick: () => undefined,quickSwitcherLabel: 'Component',subMenu: {