@remotion/studio-shared 4.0.472 → 4.0.474

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.
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.optimisticMoveEffectKeyframes = exports.optimisticMoveSequenceKeyframes = exports.canMoveKeyframesWithoutCollisions = void 0;
4
+ const getMoveMap = (moves) => {
5
+ const moveMap = new Map();
6
+ for (const move of moves) {
7
+ if (move.fromFrame === move.toFrame) {
8
+ continue;
9
+ }
10
+ if (moveMap.has(move.fromFrame)) {
11
+ return null;
12
+ }
13
+ moveMap.set(move.fromFrame, move.toFrame);
14
+ }
15
+ return moveMap;
16
+ };
17
+ const canMoveKeyframesWithoutCollisions = ({ status, moves, }) => {
18
+ var _a;
19
+ if (status.status !== 'keyframed') {
20
+ return false;
21
+ }
22
+ const moveMap = getMoveMap(moves);
23
+ if (moveMap === null) {
24
+ return false;
25
+ }
26
+ if (moveMap.size === 0) {
27
+ return true;
28
+ }
29
+ const frames = new Set(status.keyframes.map((keyframe) => keyframe.frame));
30
+ for (const fromFrame of moveMap.keys()) {
31
+ if (!frames.has(fromFrame)) {
32
+ return false;
33
+ }
34
+ }
35
+ 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;
40
+ }
41
+ nextFrames.add(frame);
42
+ }
43
+ return true;
44
+ };
45
+ exports.canMoveKeyframesWithoutCollisions = canMoveKeyframesWithoutCollisions;
46
+ const moveKeyframesInPropStatus = ({ status, moves, }) => {
47
+ if (status.status !== 'keyframed') {
48
+ return status;
49
+ }
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) {
58
+ return status;
59
+ }
60
+ return {
61
+ ...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),
71
+ };
72
+ };
73
+ const optimisticMoveSequenceKeyframes = ({ previous, keyframes, }) => {
74
+ var _a;
75
+ if (!previous.canUpdate) {
76
+ return previous;
77
+ }
78
+ const movesByField = new Map();
79
+ for (const keyframe of keyframes) {
80
+ const moves = (_a = movesByField.get(keyframe.fieldKey)) !== null && _a !== void 0 ? _a : [];
81
+ moves.push(keyframe);
82
+ movesByField.set(keyframe.fieldKey, moves);
83
+ }
84
+ const props = { ...previous.props };
85
+ for (const [fieldKey, moves] of movesByField) {
86
+ const status = props[fieldKey];
87
+ if (!status) {
88
+ continue;
89
+ }
90
+ props[fieldKey] = moveKeyframesInPropStatus({ status, moves });
91
+ }
92
+ return {
93
+ ...previous,
94
+ props,
95
+ };
96
+ };
97
+ exports.optimisticMoveSequenceKeyframes = optimisticMoveSequenceKeyframes;
98
+ const optimisticMoveEffectKeyframes = ({ previous, keyframes, }) => {
99
+ var _a;
100
+ if (!previous.canUpdate) {
101
+ return previous;
102
+ }
103
+ const movesByEffect = new Map();
104
+ for (const keyframe of keyframes) {
105
+ const moves = (_a = movesByEffect.get(keyframe.effectIndex)) !== null && _a !== void 0 ? _a : [];
106
+ moves.push(keyframe);
107
+ movesByEffect.set(keyframe.effectIndex, moves);
108
+ }
109
+ const effects = previous.effects.map((effect) => {
110
+ var _a;
111
+ if (!effect.canUpdate) {
112
+ return effect;
113
+ }
114
+ const movesForEffect = movesByEffect.get(effect.effectIndex);
115
+ if (!movesForEffect) {
116
+ return effect;
117
+ }
118
+ const props = { ...effect.props };
119
+ const movesByField = new Map();
120
+ for (const move of movesForEffect) {
121
+ const moves = (_a = movesByField.get(move.fieldKey)) !== null && _a !== void 0 ? _a : [];
122
+ moves.push(move);
123
+ movesByField.set(move.fieldKey, moves);
124
+ }
125
+ for (const [fieldKey, moves] of movesByField) {
126
+ const status = props[fieldKey];
127
+ if (!status) {
128
+ continue;
129
+ }
130
+ props[fieldKey] = moveKeyframesInPropStatus({ status, moves });
131
+ }
132
+ return {
133
+ ...effect,
134
+ props,
135
+ };
136
+ });
137
+ return {
138
+ ...previous,
139
+ effects,
140
+ };
141
+ };
142
+ exports.optimisticMoveEffectKeyframes = optimisticMoveEffectKeyframes;
@@ -0,0 +1,8 @@
1
+ import { type CanUpdateSequencePropsResponse, type SequenceSchema } from 'remotion';
2
+ export declare const optimisticUpdateForEffectPropStatuses: ({ previous, effectIndex, fieldKey, value, schema, }: {
3
+ previous: CanUpdateSequencePropsResponse;
4
+ effectIndex: number;
5
+ fieldKey: string;
6
+ value: unknown;
7
+ schema: SequenceSchema;
8
+ }) => CanUpdateSequencePropsResponse;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.optimisticUpdateForEffectPropStatuses = void 0;
4
+ const no_react_1 = require("remotion/no-react");
5
+ const optimisticUpdateForEffectPropStatuses = ({ previous, effectIndex, fieldKey, value, schema, }) => {
6
+ var _a;
7
+ if (!previous.canUpdate) {
8
+ return previous;
9
+ }
10
+ const targetIndex = previous.effects.findIndex((e) => e.effectIndex === effectIndex);
11
+ if (targetIndex === -1) {
12
+ return previous;
13
+ }
14
+ const target = previous.effects[targetIndex];
15
+ if (!target.canUpdate) {
16
+ return previous;
17
+ }
18
+ const props = {
19
+ ...target.props,
20
+ [fieldKey]: { status: 'static', codeValue: value },
21
+ };
22
+ if (((_a = schema[fieldKey]) === null || _a === void 0 ? void 0 : _a.type) === 'enum') {
23
+ const propsToDelete = no_react_1.NoReactInternals.findPropsToDelete({
24
+ schema,
25
+ key: fieldKey,
26
+ value,
27
+ });
28
+ for (const propToDelete of propsToDelete) {
29
+ delete props[propToDelete];
30
+ }
31
+ }
32
+ const updatedEffect = {
33
+ ...target,
34
+ props,
35
+ };
36
+ const effects = [...previous.effects];
37
+ effects[targetIndex] = updatedEffect;
38
+ return {
39
+ ...previous,
40
+ effects,
41
+ };
42
+ };
43
+ exports.optimisticUpdateForEffectPropStatuses = optimisticUpdateForEffectPropStatuses;
@@ -0,0 +1,7 @@
1
+ import { type CanUpdateSequencePropsResponse, type SequenceSchema } from 'remotion';
2
+ export declare const optimisticUpdateForPropStatuses: ({ previous, fieldKey, value, schema, }: {
3
+ previous: CanUpdateSequencePropsResponse;
4
+ fieldKey: string;
5
+ value: unknown;
6
+ schema: SequenceSchema;
7
+ }) => CanUpdateSequencePropsResponse;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.optimisticUpdateForPropStatuses = void 0;
4
+ const no_react_1 = require("remotion/no-react");
5
+ const optimisticUpdateForPropStatuses = ({ previous, fieldKey, value, schema, }) => {
6
+ var _a;
7
+ if (!previous.canUpdate) {
8
+ return previous;
9
+ }
10
+ const props = {
11
+ ...previous.props,
12
+ [fieldKey]: { status: 'static', codeValue: value },
13
+ };
14
+ if (((_a = schema[fieldKey]) === null || _a === void 0 ? void 0 : _a.type) === 'enum') {
15
+ const propsToDelete = no_react_1.NoReactInternals.findPropsToDelete({
16
+ schema,
17
+ key: fieldKey,
18
+ value,
19
+ });
20
+ for (const propToDelete of propsToDelete) {
21
+ delete props[propToDelete];
22
+ }
23
+ }
24
+ return {
25
+ canUpdate: true,
26
+ props,
27
+ effects: previous.effects,
28
+ };
29
+ };
30
+ exports.optimisticUpdateForPropStatuses = optimisticUpdateForPropStatuses;
@@ -0,0 +1,13 @@
1
+ import type { CanUpdateSequencePropsResponse } from 'remotion';
2
+ import type { KeyframeSettings } from './api-requests';
3
+ export declare const optimisticUpdateSequenceKeyframeSettings: ({ previous, fieldKey, settings, }: {
4
+ previous: CanUpdateSequencePropsResponse;
5
+ fieldKey: string;
6
+ settings: KeyframeSettings;
7
+ }) => CanUpdateSequencePropsResponse;
8
+ export declare const optimisticUpdateEffectKeyframeSettings: ({ previous, effectIndex, fieldKey, settings, }: {
9
+ previous: CanUpdateSequencePropsResponse;
10
+ effectIndex: number;
11
+ fieldKey: string;
12
+ settings: KeyframeSettings;
13
+ }) => CanUpdateSequencePropsResponse;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.optimisticUpdateEffectKeyframeSettings = exports.optimisticUpdateSequenceKeyframeSettings = void 0;
4
+ const applySettingsToStatus = (status, settings) => {
5
+ if (!status || status.status !== 'keyframed') {
6
+ throw new Error('Expected keyframed status');
7
+ }
8
+ return {
9
+ ...status,
10
+ ...(settings.clamping ? { clamping: settings.clamping } : {}),
11
+ posterize: settings.posterize,
12
+ };
13
+ };
14
+ const optimisticUpdateSequenceKeyframeSettings = ({ previous, fieldKey, settings, }) => {
15
+ if (!previous.canUpdate) {
16
+ return previous;
17
+ }
18
+ const status = previous.props[fieldKey];
19
+ if (!status || status.status !== 'keyframed') {
20
+ return previous;
21
+ }
22
+ return {
23
+ ...previous,
24
+ props: {
25
+ ...previous.props,
26
+ [fieldKey]: applySettingsToStatus(status, settings),
27
+ },
28
+ };
29
+ };
30
+ exports.optimisticUpdateSequenceKeyframeSettings = optimisticUpdateSequenceKeyframeSettings;
31
+ const optimisticUpdateEffectKeyframeSettings = ({ previous, effectIndex, fieldKey, settings, }) => {
32
+ if (!previous.canUpdate) {
33
+ return previous;
34
+ }
35
+ const targetIndex = previous.effects.findIndex((effect) => effect.effectIndex === effectIndex);
36
+ if (targetIndex === -1) {
37
+ return previous;
38
+ }
39
+ const target = previous.effects[targetIndex];
40
+ if (!target.canUpdate) {
41
+ return previous;
42
+ }
43
+ const status = target.props[fieldKey];
44
+ if (!status || status.status !== 'keyframed') {
45
+ return previous;
46
+ }
47
+ const effects = [...previous.effects];
48
+ effects[targetIndex] = {
49
+ ...target,
50
+ props: {
51
+ ...target.props,
52
+ [fieldKey]: applySettingsToStatus(status, settings),
53
+ },
54
+ };
55
+ return {
56
+ ...previous,
57
+ effects,
58
+ };
59
+ };
60
+ exports.optimisticUpdateEffectKeyframeSettings = optimisticUpdateEffectKeyframeSettings;
@@ -0,0 +1,4 @@
1
+ import type { InsertableCompositionElement } from './api-requests';
2
+ export declare const getRequiredPackageForImportPath: (importPath: string) => string | null;
3
+ export declare const getRequiredPackageForInsertableElement: (element: InsertableCompositionElement) => string | null;
4
+ export declare const getRequiredPackageForEffectImportPath: (importPath: string) => string | null;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRequiredPackageForEffectImportPath = exports.getRequiredPackageForInsertableElement = exports.getRequiredPackageForImportPath = void 0;
4
+ const getRequiredPackageForImportPath = (importPath) => {
5
+ if (importPath === 'remotion' || importPath.startsWith('.')) {
6
+ return null;
7
+ }
8
+ if (importPath.startsWith('@')) {
9
+ const [scope, scopedPackageName] = importPath.split('/');
10
+ return scope && scopedPackageName ? `${scope}/${scopedPackageName}` : null;
11
+ }
12
+ const [packageName] = importPath.split('/');
13
+ return packageName || null;
14
+ };
15
+ exports.getRequiredPackageForImportPath = getRequiredPackageForImportPath;
16
+ const getRequiredPackageForInsertableElement = (element) => {
17
+ if (element.type === 'solid') {
18
+ return null;
19
+ }
20
+ if (element.type === 'component') {
21
+ return (0, exports.getRequiredPackageForImportPath)(element.importPath);
22
+ }
23
+ if (element.assetType === 'video' || element.assetType === 'audio') {
24
+ return '@remotion/media';
25
+ }
26
+ if (element.assetType === 'gif') {
27
+ return '@remotion/gif';
28
+ }
29
+ return null;
30
+ };
31
+ exports.getRequiredPackageForInsertableElement = getRequiredPackageForInsertableElement;
32
+ const getRequiredPackageForEffectImportPath = (importPath) => {
33
+ if (importPath.startsWith('@remotion/effects/')) {
34
+ return '@remotion/effects';
35
+ }
36
+ if (importPath === '@remotion/light-leaks' ||
37
+ importPath === '@remotion/starburst') {
38
+ return importPath;
39
+ }
40
+ return null;
41
+ };
42
+ exports.getRequiredPackageForEffectImportPath = getRequiredPackageForEffectImportPath;
@@ -1,5 +1,5 @@
1
- import type { CodeValues, DragOverrides, EffectDefinition, GetDragOverrides, GetEffectDragOverrides, SequenceControls, SequencePropsSubscriptionKey, SequenceSchema, VisibleFieldSchema } from 'remotion';
2
- export type { CodeValues, DragOverrides, SequenceControls };
1
+ import type { DragOverrides, EffectDefinition, GetDragOverrides, GetEffectDragOverrides, PropStatuses, SequenceControls, SequencePropsSubscriptionKey, SequenceSchema, VisibleFieldSchema } from 'remotion';
2
+ export type { DragOverrides, PropStatuses, SequenceControls };
3
3
  export type SchemaFieldInfo = {
4
4
  key: string;
5
5
  description: string | undefined;
@@ -19,17 +19,17 @@ export type AnySchemaFieldInfo = SequenceSchemaFieldInfo | EffectSchemaFieldInfo
19
19
  export declare const SCHEMA_FIELD_ROW_HEIGHT = 22;
20
20
  declare const SUPPORTED_SCHEMA_TYPES: readonly ["number", "boolean", "rotation-css", "rotation-degrees", "translate", "scale", "uv-coordinate", "color", "array", "enum", "hidden"];
21
21
  type SupportedSchemaType = (typeof SUPPORTED_SCHEMA_TYPES)[number];
22
- export declare const getFieldsToShow: ({ getDragOverrides, codeValues, nodePath, schema, currentRuntimeValueDotNotation, }: {
22
+ export declare const getFieldsToShow: ({ getDragOverrides, propStatuses, nodePath, schema, currentRuntimeValueDotNotation, }: {
23
23
  schema: SequenceSchema;
24
24
  currentRuntimeValueDotNotation: Record<string, unknown>;
25
25
  getDragOverrides: GetDragOverrides;
26
- codeValues: CodeValues;
26
+ propStatuses: PropStatuses;
27
27
  nodePath: SequencePropsSubscriptionKey;
28
28
  }) => SequenceSchemaFieldInfo[] | null;
29
- export declare const getEffectFieldsToShow: ({ effect, effectIndex, nodePath, codeValues, getEffectDragOverrides, }: {
29
+ export declare const getEffectFieldsToShow: ({ effect, effectIndex, nodePath, propStatuses, getEffectDragOverrides, }: {
30
30
  effect: EffectDefinition<unknown>;
31
31
  effectIndex: number;
32
32
  nodePath: SequencePropsSubscriptionKey | null;
33
- codeValues: CodeValues;
33
+ propStatuses: PropStatuses;
34
34
  getEffectDragOverrides: GetEffectDragOverrides;
35
35
  }) => EffectSchemaFieldInfo[];
@@ -50,12 +50,12 @@ const getEffectFieldValue = ({ key, dragOverrides, effectStatus, }) => {
50
50
  }
51
51
  return propStatus.codeValue;
52
52
  };
53
- const getFieldsToShow = ({ getDragOverrides, codeValues, nodePath, schema, currentRuntimeValueDotNotation, }) => {
53
+ const getFieldsToShow = ({ getDragOverrides, propStatuses, nodePath, schema, currentRuntimeValueDotNotation, }) => {
54
54
  const { merged: valuesDotNotation } = remotion_1.Internals.computeEffectiveSchemaValuesDotNotation({
55
55
  schema,
56
56
  currentValue: currentRuntimeValueDotNotation,
57
57
  overrideValues: getDragOverrides(nodePath),
58
- propStatus: remotion_1.Internals.getCodeValuesCtx(codeValues, nodePath),
58
+ propStatus: remotion_1.Internals.getPropStatusesCtx(propStatuses, nodePath),
59
59
  frame: null,
60
60
  });
61
61
  const activeSchema = remotion_1.Internals.flattenActiveSchema(schema, (key) => valuesDotNotation[key]);
@@ -91,11 +91,11 @@ const getFieldsToShow = ({ getDragOverrides, codeValues, nodePath, schema, curre
91
91
  .filter(no_react_1.NoReactInternals.truthy);
92
92
  };
93
93
  exports.getFieldsToShow = getFieldsToShow;
94
- const getEffectFieldsToShow = ({ effect, effectIndex, nodePath, codeValues, getEffectDragOverrides, }) => {
94
+ const getEffectFieldsToShow = ({ effect, effectIndex, nodePath, propStatuses, getEffectDragOverrides, }) => {
95
95
  const effectStatus = nodePath === null
96
96
  ? null
97
- : remotion_1.Internals.getEffectCodeValuesCtx({
98
- codeValues,
97
+ : remotion_1.Internals.getEffectPropStatusesCtx({
98
+ propStatuses,
99
99
  nodePath,
100
100
  effectIndex,
101
101
  });
@@ -0,0 +1,10 @@
1
+ export declare const SFX_DRAG_MIME_TYPE = "application/vnd.remotion.sfx+json";
2
+ export type SfxDragData = {
3
+ type: 'remotion-sfx';
4
+ version: 1;
5
+ sfx: {
6
+ name: string;
7
+ url: string;
8
+ };
9
+ };
10
+ export declare const parseSfxDragData: (value: string) => SfxDragData | null;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseSfxDragData = exports.SFX_DRAG_MIME_TYPE = void 0;
4
+ const url_1 = require("./url");
5
+ exports.SFX_DRAG_MIME_TYPE = 'application/vnd.remotion.sfx+json';
6
+ const isRecord = (value) => {
7
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
8
+ };
9
+ const parseSfxDragData = (value) => {
10
+ try {
11
+ const parsed = JSON.parse(value);
12
+ if (!isRecord(parsed)) {
13
+ return null;
14
+ }
15
+ if (parsed.type !== 'remotion-sfx' || parsed.version !== 1) {
16
+ return null;
17
+ }
18
+ if (!isRecord(parsed.sfx)) {
19
+ return null;
20
+ }
21
+ const { name, url } = parsed.sfx;
22
+ if (typeof name !== 'string' ||
23
+ name.length === 0 ||
24
+ typeof url !== 'string' ||
25
+ !(0, url_1.isUrl)(url)) {
26
+ return null;
27
+ }
28
+ return {
29
+ type: 'remotion-sfx',
30
+ version: 1,
31
+ sfx: {
32
+ name,
33
+ url,
34
+ },
35
+ };
36
+ }
37
+ catch (_a) {
38
+ return null;
39
+ }
40
+ };
41
+ exports.parseSfxDragData = parseSfxDragData;
package/dist/url.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const isUrl: (value: string) => boolean;
package/dist/url.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUrl = void 0;
4
+ const isUrl = (value) => {
5
+ try {
6
+ const parsed = new URL(value);
7
+ return parsed.href.length > 0;
8
+ }
9
+ catch (_a) {
10
+ return false;
11
+ }
12
+ };
13
+ exports.isUrl = isUrl;
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.472",
6
+ "version": "4.0.474",
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.472"
23
+ "remotion": "4.0.474"
24
24
  },
25
25
  "devDependencies": {
26
- "@remotion/renderer": "4.0.472",
27
- "@remotion/eslint-config-internal": "4.0.472",
26
+ "@remotion/renderer": "4.0.474",
27
+ "@remotion/eslint-config-internal": "4.0.474",
28
28
  "eslint": "9.19.0",
29
29
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
30
30
  },