@remotion/studio-shared 4.0.475 → 4.0.476

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.
package/dist/index.d.ts CHANGED
@@ -33,7 +33,7 @@ export { EnumPath, stringifyDefaultProps } from './stringify-default-props';
33
33
  export type { VisualControlChange } from './codemods';
34
34
  export { optimisticAddEffectKeyframe, optimisticAddSequenceKeyframe, } from './optimistic-add-keyframe';
35
35
  export { optimisticDeleteEffectKeyframe, optimisticDeleteEffectKeyframes, optimisticDeleteSequenceKeyframe, optimisticDeleteSequenceKeyframes, } from './optimistic-delete-keyframe';
36
- export { canMoveKeyframesWithoutCollisions, optimisticMoveEffectKeyframes, optimisticMoveSequenceKeyframes, type OptimisticKeyframeMove, } from './optimistic-move-keyframe';
36
+ export { canMoveKeyframesWithoutCollisions, moveKeyframesInPropStatus, optimisticMoveEffectKeyframes, optimisticMoveSequenceKeyframes, type OptimisticKeyframeMove, } from './optimistic-move-keyframe';
37
37
  export { optimisticUpdateForEffectPropStatuses } from './optimistic-update-for-effect-prop-statuses';
38
38
  export { optimisticUpdateForPropStatuses } from './optimistic-update-for-prop-statuses';
39
39
  export { optimisticUpdateEffectKeyframeSettings, optimisticUpdateSequenceKeyframeSettings, } from './optimistic-update-keyframe-settings';
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.optimisticDeleteEffectKeyframe = exports.optimisticAddSequenceKeyframe = exports.optimisticAddEffectKeyframe = exports.stringifyDefaultProps = exports.parseSfxDragData = exports.SFX_DRAG_MIME_TYPE = exports.getFieldsToShow = exports.getEffectFieldsToShow = exports.SCHEMA_FIELD_ROW_HEIGHT = exports.getRequiredPackageForInsertableElement = exports.getRequiredPackageForEffectImportPath = exports.packages = exports.installableMap = exports.extraPackages = exports.descriptions = exports.apiDocs = exports.DEFAULT_TIMELINE_TRACKS = exports.keyframeInterpolationFunctions = exports.isSequenceFieldSchemaKeyframable = exports.isSchemaFieldKeyframable = exports.isKeyframeInterpolationFunction = exports.getKeyframeInterpolationFunctionForSchemaField = exports.getKeyframeInterpolationFunction = exports.hotMiddlewareOptions = exports.getProjectName = exports.getLocationFromBuildError = exports.getDefaultOutLocation = exports.getAllSchemaKeys = exports.formatBytes = exports.parseEffectDragData = exports.EFFECT_DRAG_MIME_TYPE = exports.parseEffectPropClipboardDataResult = exports.parseEffectPropClipboardData = exports.parseEffectClipboardDataResult = exports.parseEffectClipboardData = exports.isImageFileType = exports.detectFileType = exports.KEYFRAME_EASING_PRESETS = exports.DEFAULT_BUFFER_STATE_DELAY_IN_MILLISECONDS = exports.parseComponentDragData = exports.makeComponentDragData = exports.isComponentImportPath = exports.isComponentIdentifier = exports.areComponentProps = exports.COMPONENT_DRAG_MIME_TYPE = exports.parseAssetDragData = exports.makeAssetDragData = exports.ASSET_DRAG_MIME_TYPE = exports.stripAnsi = exports.splitAnsi = void 0;
18
- exports.isUrl = exports.stringifySequenceSubscriptionKey = exports.stringifySequenceExpandedRowKey = exports.optimisticUpdateSequenceKeyframeSettings = exports.optimisticUpdateEffectKeyframeSettings = exports.optimisticUpdateForPropStatuses = exports.optimisticUpdateForEffectPropStatuses = exports.optimisticMoveSequenceKeyframes = exports.optimisticMoveEffectKeyframes = exports.canMoveKeyframesWithoutCollisions = exports.optimisticDeleteSequenceKeyframes = exports.optimisticDeleteSequenceKeyframe = exports.optimisticDeleteEffectKeyframes = void 0;
18
+ exports.isUrl = exports.stringifySequenceSubscriptionKey = exports.stringifySequenceExpandedRowKey = exports.optimisticUpdateSequenceKeyframeSettings = exports.optimisticUpdateEffectKeyframeSettings = exports.optimisticUpdateForPropStatuses = exports.optimisticUpdateForEffectPropStatuses = exports.optimisticMoveSequenceKeyframes = exports.optimisticMoveEffectKeyframes = exports.moveKeyframesInPropStatus = exports.canMoveKeyframesWithoutCollisions = exports.optimisticDeleteSequenceKeyframes = exports.optimisticDeleteSequenceKeyframe = exports.optimisticDeleteEffectKeyframes = void 0;
19
19
  const ansi_1 = require("./ansi");
20
20
  Object.defineProperty(exports, "splitAnsi", { enumerable: true, get: function () { return ansi_1.splitAnsi; } });
21
21
  Object.defineProperty(exports, "stripAnsi", { enumerable: true, get: function () { return ansi_1.stripAnsi; } });
@@ -95,6 +95,7 @@ Object.defineProperty(exports, "optimisticDeleteSequenceKeyframe", { enumerable:
95
95
  Object.defineProperty(exports, "optimisticDeleteSequenceKeyframes", { enumerable: true, get: function () { return optimistic_delete_keyframe_1.optimisticDeleteSequenceKeyframes; } });
96
96
  const optimistic_move_keyframe_1 = require("./optimistic-move-keyframe");
97
97
  Object.defineProperty(exports, "canMoveKeyframesWithoutCollisions", { enumerable: true, get: function () { return optimistic_move_keyframe_1.canMoveKeyframesWithoutCollisions; } });
98
+ Object.defineProperty(exports, "moveKeyframesInPropStatus", { enumerable: true, get: function () { return optimistic_move_keyframe_1.moveKeyframesInPropStatus; } });
98
99
  Object.defineProperty(exports, "optimisticMoveEffectKeyframes", { enumerable: true, get: function () { return optimistic_move_keyframe_1.optimisticMoveEffectKeyframes; } });
99
100
  Object.defineProperty(exports, "optimisticMoveSequenceKeyframes", { enumerable: true, get: function () { return optimistic_move_keyframe_1.optimisticMoveSequenceKeyframes; } });
100
101
  const optimistic_update_for_effect_prop_statuses_1 = require("./optimistic-update-for-effect-prop-statuses");
@@ -11,6 +11,13 @@ export declare const canMoveKeyframesWithoutCollisions: ({ status, moves, }: {
11
11
  toFrame: number;
12
12
  }[];
13
13
  }) => boolean;
14
+ export declare const moveKeyframesInPropStatus: ({ status, moves, }: {
15
+ status: CanUpdateSequencePropStatus;
16
+ moves: readonly {
17
+ fromFrame: number;
18
+ toFrame: number;
19
+ }[];
20
+ }) => CanUpdateSequencePropStatus;
14
21
  export declare const optimisticMoveSequenceKeyframes: ({ previous, keyframes, }: {
15
22
  previous: CanUpdateSequencePropsResponse;
16
23
  keyframes: readonly OptimisticKeyframeMove[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.optimisticMoveEffectKeyframes = exports.optimisticMoveSequenceKeyframes = exports.canMoveKeyframesWithoutCollisions = void 0;
3
+ exports.optimisticMoveEffectKeyframes = exports.optimisticMoveSequenceKeyframes = exports.moveKeyframesInPropStatus = exports.canMoveKeyframesWithoutCollisions = void 0;
4
4
  const getMoveMap = (moves) => {
5
5
  const moveMap = new Map();
6
6
  for (const move of moves) {
@@ -14,62 +14,86 @@ const getMoveMap = (moves) => {
14
14
  }
15
15
  return moveMap;
16
16
  };
17
- const canMoveKeyframesWithoutCollisions = ({ status, moves, }) => {
18
- var _a;
17
+ const getMovedKeyframes = ({ status, moves, }) => {
19
18
  if (status.status !== 'keyframed') {
20
- return false;
19
+ return null;
21
20
  }
22
21
  const moveMap = getMoveMap(moves);
23
22
  if (moveMap === null) {
24
- return false;
23
+ return null;
25
24
  }
26
25
  if (moveMap.size === 0) {
27
- return true;
26
+ return { keyframes: status.keyframes, removedKeyframeIndexes: [] };
28
27
  }
29
28
  const frames = new Set(status.keyframes.map((keyframe) => keyframe.frame));
30
29
  for (const fromFrame of moveMap.keys()) {
31
30
  if (!frames.has(fromFrame)) {
32
- return false;
31
+ return null;
33
32
  }
34
33
  }
34
+ const movedFromFrames = new Set(moveMap.keys());
35
+ const movedToFrames = new Set(moveMap.values());
36
+ const removedKeyframeIndexes = [];
37
+ const nextKeyframes = status.keyframes.flatMap((keyframe, index) => {
38
+ const movedFrame = moveMap.get(keyframe.frame);
39
+ if (movedFrame !== undefined) {
40
+ return [{ ...keyframe, frame: movedFrame }];
41
+ }
42
+ if (movedToFrames.has(keyframe.frame) &&
43
+ !movedFromFrames.has(keyframe.frame)) {
44
+ removedKeyframeIndexes.push(index);
45
+ return [];
46
+ }
47
+ return [keyframe];
48
+ });
35
49
  const nextFrames = new Set();
36
- for (const keyframe of status.keyframes) {
37
- const frame = (_a = moveMap.get(keyframe.frame)) !== null && _a !== void 0 ? _a : keyframe.frame;
38
- if (nextFrames.has(frame)) {
39
- return false;
50
+ for (const keyframe of nextKeyframes) {
51
+ if (nextFrames.has(keyframe.frame)) {
52
+ return null;
53
+ }
54
+ nextFrames.add(keyframe.frame);
55
+ }
56
+ return {
57
+ keyframes: nextKeyframes.sort((a, b) => a.frame - b.frame),
58
+ removedKeyframeIndexes,
59
+ };
60
+ };
61
+ const removeEasingForRemovedKeyframes = ({ easing, removedKeyframeIndexes, }) => {
62
+ const nextEasing = [...easing];
63
+ for (const removedKeyframeIndex of [...removedKeyframeIndexes].sort((a, b) => b - a)) {
64
+ if (nextEasing.length === 0) {
65
+ break;
40
66
  }
41
- nextFrames.add(frame);
67
+ const easingIndexToRemove = removedKeyframeIndex === 0 ? 0 : removedKeyframeIndex - 1;
68
+ nextEasing.splice(easingIndexToRemove, 1);
42
69
  }
43
- return true;
70
+ return nextEasing;
71
+ };
72
+ const canMoveKeyframesWithoutCollisions = ({ status, moves, }) => {
73
+ return getMovedKeyframes({ status, moves }) !== null;
44
74
  };
45
75
  exports.canMoveKeyframesWithoutCollisions = canMoveKeyframesWithoutCollisions;
46
76
  const moveKeyframesInPropStatus = ({ status, moves, }) => {
47
77
  if (status.status !== 'keyframed') {
48
78
  return status;
49
79
  }
50
- if (!(0, exports.canMoveKeyframesWithoutCollisions)({ status, moves })) {
51
- return status;
52
- }
53
- const moveMap = getMoveMap(moves);
54
- if (moveMap === null) {
55
- return status;
56
- }
57
- if (moveMap.size === 0) {
80
+ const moved = getMovedKeyframes({ status, moves });
81
+ if (moved === null ||
82
+ (moved.removedKeyframeIndexes.length === 0 &&
83
+ moved.keyframes === status.keyframes)) {
58
84
  return status;
59
85
  }
86
+ const easing = removeEasingForRemovedKeyframes({
87
+ easing: status.easing,
88
+ removedKeyframeIndexes: moved.removedKeyframeIndexes,
89
+ });
60
90
  return {
61
91
  ...status,
62
- keyframes: status.keyframes
63
- .map((keyframe) => {
64
- var _a;
65
- return ({
66
- ...keyframe,
67
- frame: (_a = moveMap.get(keyframe.frame)) !== null && _a !== void 0 ? _a : keyframe.frame,
68
- });
69
- })
70
- .sort((a, b) => a.frame - b.frame),
92
+ keyframes: moved.keyframes,
93
+ easing,
71
94
  };
72
95
  };
96
+ exports.moveKeyframesInPropStatus = moveKeyframesInPropStatus;
73
97
  const optimisticMoveSequenceKeyframes = ({ previous, keyframes, }) => {
74
98
  var _a;
75
99
  if (!previous.canUpdate) {
@@ -87,7 +111,7 @@ const optimisticMoveSequenceKeyframes = ({ previous, keyframes, }) => {
87
111
  if (!status) {
88
112
  continue;
89
113
  }
90
- props[fieldKey] = moveKeyframesInPropStatus({ status, moves });
114
+ props[fieldKey] = (0, exports.moveKeyframesInPropStatus)({ status, moves });
91
115
  }
92
116
  return {
93
117
  ...previous,
@@ -127,7 +151,7 @@ const optimisticMoveEffectKeyframes = ({ previous, keyframes, }) => {
127
151
  if (!status) {
128
152
  continue;
129
153
  }
130
- props[fieldKey] = moveKeyframesInPropStatus({ status, moves });
154
+ props[fieldKey] = (0, exports.moveKeyframesInPropStatus)({ status, moves });
131
155
  }
132
156
  return {
133
157
  ...effect,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/studio-shared"
4
4
  },
5
5
  "name": "@remotion/studio-shared",
6
- "version": "4.0.475",
6
+ "version": "4.0.476",
7
7
  "description": "Internal package for shared objects between the Studio backend and frontend",
8
8
  "main": "dist",
9
9
  "scripts": {
@@ -20,11 +20,11 @@
20
20
  "url": "https://github.com/remotion-dev/remotion/issues"
21
21
  },
22
22
  "dependencies": {
23
- "remotion": "4.0.475"
23
+ "remotion": "4.0.476"
24
24
  },
25
25
  "devDependencies": {
26
- "@remotion/renderer": "4.0.475",
27
- "@remotion/eslint-config-internal": "4.0.475",
26
+ "@remotion/renderer": "4.0.476",
27
+ "@remotion/eslint-config-internal": "4.0.476",
28
28
  "eslint": "9.19.0",
29
29
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
30
30
  },