Skip to content

🎥 Make videos programmatically with React

sequencekeys, effectkeys

JonnyBurger53ede4b6f7b2
diff --git a/packages/studio-server/src/preview-server/routes/unsubscribe-from-sequence-props.ts b/packages/studio-server/src/preview-server/routes/unsubscribe-from-sequence-props.ts
index 48b6540f67..77e18e5b17 100644
--- a/packages/studio-server/src/preview-server/routes/unsubscribe-from-sequence-props.ts
+++ b/packages/studio-server/src/preview-server/routes/unsubscribe-from-sequence-props.ts
@@ -5,12 +5,17 @@ import {unsubscribeFromSequencePropsWatchers} from '../sequence-props-watchers';
export const unsubscribeFromSequenceProps: ApiHandler<
UnsubscribeFromSequencePropsRequest,
undefined
-> = ({input: {fileName, nodePath, clientId}, remotionRoot}) => {
+> = ({
+ input: {fileName, nodePath, clientId, sequenceKeys, effectKeys},
+ remotionRoot,
+}) => {
unsubscribeFromSequencePropsWatchers({
fileName,
nodePath,
remotionRoot,
clientId,
+ sequenceKeys,
+ effectKeys,
});
return Promise.resolve(undefined);
};
diff --git a/packages/studio-server/src/preview-server/sequence-props-watchers.ts b/packages/studio-server/src/preview-server/sequence-props-watchers.ts
index caa17ed027..e14e21d6de 100644
--- a/packages/studio-server/src/preview-server/sequence-props-watchers.ts
+++ b/packages/studio-server/src/preview-server/sequence-props-watchers.ts
@@ -1,5 +1,8 @@
import path from 'node:path';
-import type {SubscribeToSequencePropsResponse} from '@remotion/studio-shared';
+import {
+ getAllSchemaKeys,
+ type SubscribeToSequencePropsResponse,
+} from '@remotion/studio-shared';
import type {
CanUpdateSequencePropsResponse,
SequenceNodePath,
@@ -24,11 +27,15 @@ const sequencePropsWatchers: Record<string, Record<string, WatcherInfo>> = {};
const makeWatcherKey = ({
absolutePath,
nodePath,
+ sequenceKeys,
+ effectKeys,
}: {
absolutePath: string;
nodePath: SequenceNodePath;
+ sequenceKeys: string[];
+ effectKeys: string[][];
}): string => {
- return `${absolutePath}:${JSON.stringify(nodePath)}`;
+ return `${absolutePath}:${JSON.stringify(nodePath)}:${sequenceKeys.join('\0')}:${effectKeys.map((keys) => keys.join('\0')).join('\0\0')}`;
};
const getSequencePropsStatus = ({
@@ -110,7 +117,12 @@ export const subscribeToSequencePropsWatchers = ({
setCachedNodePath(fileName, line, column, initialResult.nodePath);
const {nodePath} = initialResult;
- const watcherKey = makeWatcherKey({absolutePath, nodePath});
+ const watcherKey = makeWatcherKey({
+ absolutePath,
+ nodePath,
+ sequenceKeys: keys,
+ effectKeys: effects.map((effect) => getAllSchemaKeys(effect)),
+ });
// If a watcher already exists for this key, just bump the ref count
if (sequencePropsWatchers[clientId]?.[watcherKey]) {
@@ -163,14 +175,23 @@ export const unsubscribeFromSequencePropsWatchers = ({
nodePath,
remotionRoot,
clientId,
+ sequenceKeys,
+ effectKeys,
}: {
fileName: string;
nodePath: SequenceNodePath;
remotionRoot: string;
clientId: string;
+ sequenceKeys: string[];
+ effectKeys: string[][];
}) => {
const absolutePath = path.resolve(remotionRoot, fileName);
- const watcherKey = makeWatcherKey({absolutePath, nodePath});
+ const watcherKey = makeWatcherKey({
+ absolutePath,
+ nodePath,
+ sequenceKeys,
+ effectKeys,
+ });
if (
!sequencePropsWatchers[clientId] ||
diff --git a/packages/studio-shared/src/api-requests.ts b/packages/studio-shared/src/api-requests.ts
index 7bb00802ca..fea5025ed6 100644
--- a/packages/studio-shared/src/api-requests.ts
+++ b/packages/studio-shared/src/api-requests.ts
@@ -239,6 +239,8 @@ export type UnsubscribeFromSequencePropsRequest = {
fileName: string;
nodePath: SequenceNodePath;
clientId: string;
+ sequenceKeys: string[];
+ effectKeys: string[][];
};
export type SaveSequencePropsRequest = {
diff --git a/packages/studio/src/components/Timeline/sequence-props-subscription-store.ts b/packages/studio/src/components/Timeline/sequence-props-subscription-store.ts
index 8fe0a24093..a5d608cc7f 100644
--- a/packages/studio/src/components/Timeline/sequence-props-subscription-store.ts
+++ b/packages/studio/src/components/Timeline/sequence-props-subscription-store.ts
@@ -51,7 +51,6 @@ export const acquireSequencePropsSubscription = ({
}): {release: () => void} => {
const sequenceKeys = getAllSchemaKeys(schema);
const effectKeys = effects.map((effect) => getAllSchemaKeys(effect));
- // TODO: Bug - schema keys and effects are not part of the cache key
const key = makeKey(fileName, line, column, sequenceKeys, effectKeys);
let entry = entries.get(key);
@@ -131,6 +130,8 @@ export const acquireSequencePropsSubscription = ({
fileName: acquired.fileName,
nodePath: result.nodePath,
clientId: acquired.clientId,
+ sequenceKeys,
+ effectKeys,
});
})
.catch(() => {