π₯ Make videos programmatically with React
interestnig
JonnyBurgerffc263e40bdd
diff --git a/packages/studio/src/components/Timeline/SequencePropsObserver.tsx b/packages/studio/src/components/Timeline/SequencePropsObserver.tsxindex 1965f94d57..449ab2cda4 100644--- a/packages/studio/src/components/Timeline/SequencePropsObserver.tsx+++ b/packages/studio/src/components/Timeline/SequencePropsObserver.tsx@@ -26,4 +26,6 @@ export const SequencePropsObserver = () => {unsubscribe();};}, [setCodeValues, subscribeToEvent]);++ return null;};diff --git a/packages/studio/src/components/Timeline/Timeline.tsx b/packages/studio/src/components/Timeline/Timeline.tsxindex 2a68cdeb9f..4f7bd2d097 100644--- a/packages/studio/src/components/Timeline/Timeline.tsx+++ b/packages/studio/src/components/Timeline/Timeline.tsx@@ -9,6 +9,7 @@ import {SplitterElement} from '../Splitter/SplitterElement';import {SplitterHandle} from '../Splitter/SplitterHandle';import {isTrackHidden} from './is-collapsed';import {MAX_TIMELINE_TRACKS} from './MaxTimelineTracks';+import {SequencePropsObserver} from './SequencePropsObserver';import {SubscribeToNodePaths} from './SubscribeToNodePaths';import {timelineVerticalScroll} from './timeline-refs';import {TimelineDragHandler} from './TimelineDragHandler';@@ -76,6 +77,7 @@ const TimelineInner: React.FC = () => {{sequences.map((sequence) => (<SubscribeToNodePaths key={sequence.id} sequence={sequence} />))}+ <SequencePropsObserver /><TimelineWidthProvider><TimelinePinchZoom /><TimelineHeightContainer shown={shown} hasBeenCut={hasBeenCut}>diff --git a/packages/studio/src/components/Timeline/sequence-props-subscription-store.ts b/packages/studio/src/components/Timeline/sequence-props-subscription-store.tsdeleted file mode 100644index 8165cfe0fc..0000000000--- a/packages/studio/src/components/Timeline/sequence-props-subscription-store.ts+++ /dev/null@@ -1,59 +0,0 @@-import type {CanUpdateSequencePropsResponse} from '@remotion/studio-shared';-import {Internals} from 'remotion';-import type {SequenceSchema, SequenceNodePath} from 'remotion';-import {callApi} from '../call-api';--const fireUnsubscribe = (- fileName: string,- nodePath: SequenceNodePath,- clientId: string,-) => {- callApi('/api/unsubscribe-from-sequence-props', {- fileName,- nodePath,- clientId,- }).catch(() => {- // Ignore unsubscribe errors- });-};--export const acquireSequencePropsSubscription = ({- clientId,- fileName,- line,- column,- schema,- onChange,-}: {- clientId: string;- fileName: string;- line: number;- column: number;- schema: SequenceSchema;- onChange: (snapshot: CanUpdateSequencePropsResponse) => void;-}): (() => void) => {- let resolvedNodePath: SequenceNodePath | null = null;- callApi('/api/subscribe-to-sequence-props', {- fileName,- line,- column,- schema,- clientId,- })- .then((result) => {- if (result.canUpdate) {- resolvedNodePath = result.nodePath;- }-- onChange(result);- })- .catch((err) => {- Internals.Log.error(err);- });-- return () => {- if (resolvedNodePath) {- fireUnsubscribe(fileName, resolvedNodePath, clientId);- }- };-};diff --git a/packages/studio/src/components/Timeline/use-sequence-props-subscription.ts b/packages/studio/src/components/Timeline/use-sequence-props-subscription.tsindex 86985e6d28..07cf05834d 100644--- a/packages/studio/src/components/Timeline/use-sequence-props-subscription.ts+++ b/packages/studio/src/components/Timeline/use-sequence-props-subscription.ts@@ -1,10 +1,9 @@-import type {CanUpdateSequencePropsResponse} from '@remotion/studio-shared';import {useContext, useEffect, useMemo, useRef} from 'react';import {Internals} from 'remotion';-import type {SequenceSchema} from 'remotion';+import type {SequenceSchema, SequenceNodePath} from 'remotion';import type {OriginalPosition} from '../../error-overlay/react-overlay/utils/get-source-map';import {StudioServerConnectionCtx} from '../../helpers/client-id';-import {acquireSequencePropsSubscription} from './sequence-props-subscription-store';+import {callApi} from '../call-api';export const useSequencePropsSubscription = (overrideId: string,@@ -64,29 +63,39 @@ export const useSequencePropsSubscription = (return;}- const onChange = (snapshot: CanUpdateSequencePropsResponse) => {- if (snapshot.canUpdate) {- setOverrideIdToNodePath(overrideId, {- nodePath: snapshot.nodePath,- jsxInMapCallback: snapshot.jsxInMapCallback,- });- setCodeValues(snapshot.nodePath, snapshot.props);- }- };-- const release = acquireSequencePropsSubscription({- clientId,+ let resolvedNodePath: SequenceNodePath | null = null;+ callApi('/api/subscribe-to-sequence-props', {fileName: locationSource,line: locationLine,column: locationColumn,schema,- onChange,- });+ clientId,+ })+ .then((result) => {+ if (result.canUpdate) {+ resolvedNodePath = result.nodePath;++ setOverrideIdToNodePath(overrideId, {+ nodePath: result.nodePath,+ jsxInMapCallback: result.jsxInMapCallback,+ });+ setCodeValues(result.nodePath, result.props);+ }+ })+ .catch((err) => {+ Internals.Log.error(err);+ });return () => {- release();- // Only clear props on true unmount, not on re-subscribe due to- // location changes β avoids flicker while re-subscribing.+ if (resolvedNodePath) {+ callApi('/api/unsubscribe-from-sequence-props', {+ fileName: locationSource,+ nodePath: resolvedNodePath,+ clientId,+ }).catch(() => {+ // Ignore unsubscribe errors+ });+ }};}, [clientId,