remotion 4.0.478 → 4.0.481

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.
Files changed (45) hide show
  1. package/dist/cjs/CompositionManager.d.ts +3 -2
  2. package/dist/cjs/HtmlInCanvas.d.ts +4 -3
  3. package/dist/cjs/HtmlInCanvas.js +8 -10
  4. package/dist/cjs/Img.d.ts +6 -4
  5. package/dist/cjs/Img.js +11 -13
  6. package/dist/cjs/Interactive.d.ts +188 -2
  7. package/dist/cjs/Interactive.js +13 -10
  8. package/dist/cjs/Sequence.d.ts +4 -3
  9. package/dist/cjs/Sequence.js +9 -7
  10. package/dist/cjs/animated-image/AnimatedImage.d.ts +2 -3
  11. package/dist/cjs/animated-image/AnimatedImage.js +8 -10
  12. package/dist/cjs/animated-image/props.d.ts +2 -3
  13. package/dist/cjs/canvas-image/CanvasImage.d.ts +5 -3
  14. package/dist/cjs/canvas-image/CanvasImage.js +87 -42
  15. package/dist/cjs/canvas-image/props.d.ts +5 -4
  16. package/dist/cjs/effects/Solid.d.ts +2 -2
  17. package/dist/cjs/effects/Solid.js +8 -10
  18. package/dist/cjs/effects/create-effect.d.ts +2 -2
  19. package/dist/cjs/effects/effect-types.d.ts +2 -2
  20. package/dist/cjs/effects/index.d.ts +2 -1
  21. package/dist/cjs/effects/index.js +3 -0
  22. package/dist/cjs/find-props-to-delete.d.ts +2 -2
  23. package/dist/cjs/flatten-schema.d.ts +3 -3
  24. package/dist/cjs/index.d.ts +4 -4
  25. package/dist/cjs/index.js +16 -14
  26. package/dist/cjs/interactivity-schema.d.ts +524 -0
  27. package/dist/cjs/interactivity-schema.js +143 -0
  28. package/dist/cjs/internals.d.ts +95 -21
  29. package/dist/cjs/internals.js +12 -11
  30. package/dist/cjs/interpolate-keyframed-status.js +14 -3
  31. package/dist/cjs/no-react.d.ts +11 -12
  32. package/dist/cjs/no-react.js +2 -2
  33. package/dist/cjs/series/index.js +5 -4
  34. package/dist/cjs/use-schema.d.ts +21 -3
  35. package/dist/cjs/use-schema.js +5 -2
  36. package/dist/cjs/version.d.ts +1 -1
  37. package/dist/cjs/version.js +1 -1
  38. package/dist/cjs/with-interactivity-schema.d.ts +21 -0
  39. package/dist/cjs/with-interactivity-schema.js +204 -0
  40. package/dist/cjs/wrap-in-schema.d.ts +3 -3
  41. package/dist/cjs/wrap-in-schema.js +2 -2
  42. package/dist/esm/index.mjs +234 -166
  43. package/dist/esm/no-react.mjs +133 -131
  44. package/dist/esm/version.mjs +1 -1
  45. package/package.json +2 -2
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.withInteractivitySchema = exports.mergeValues = exports.selectActiveKeys = exports.readValuesFromProps = exports.getNestedValue = void 0;
37
+ const react_1 = __importStar(require("react"));
38
+ const delete_nested_key_js_1 = require("./delete-nested-key.js");
39
+ const use_memoized_effects_js_1 = require("./effects/use-memoized-effects.js");
40
+ const flatten_schema_js_1 = require("./flatten-schema.js");
41
+ const interactivity_schema_js_1 = require("./interactivity-schema.js");
42
+ const sequence_node_path_js_1 = require("./sequence-node-path.js");
43
+ const SequenceManager_js_1 = require("./SequenceManager.js");
44
+ const use_current_frame_js_1 = require("./use-current-frame.js");
45
+ const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
46
+ const use_schema_js_1 = require("./use-schema.js");
47
+ const getNestedValue = (obj, key) => {
48
+ const parts = key.split('.');
49
+ let current = obj;
50
+ for (const part of parts) {
51
+ if (current === null ||
52
+ current === undefined ||
53
+ typeof current !== 'object')
54
+ return undefined;
55
+ current = current[part];
56
+ }
57
+ return current;
58
+ };
59
+ exports.getNestedValue = getNestedValue;
60
+ const readValuesFromProps = (props, keys) => {
61
+ const out = {};
62
+ for (const key of keys) {
63
+ out[key] = (0, exports.getNestedValue)(props, key);
64
+ }
65
+ return out;
66
+ };
67
+ exports.readValuesFromProps = readValuesFromProps;
68
+ const selectActiveKeys = (schema, values) => {
69
+ return Object.keys((0, flatten_schema_js_1.flattenActiveSchema)(schema, (key) => values[key]));
70
+ };
71
+ exports.selectActiveKeys = selectActiveKeys;
72
+ const mergeValues = ({ props, valuesDotNotation, schemaKeys, propsToDelete, }) => {
73
+ const merged = { ...props };
74
+ for (const key of schemaKeys) {
75
+ const value = valuesDotNotation[key];
76
+ const parts = key.split('.');
77
+ if (parts.length === 1) {
78
+ merged[key] = value;
79
+ continue;
80
+ }
81
+ // For dot-notation keys like 'style.opacity',
82
+ // clone and set the nested path
83
+ let current = merged;
84
+ for (let i = 0; i < parts.length - 1; i++) {
85
+ const part = parts[i];
86
+ if (typeof current[part] === 'object' && current[part] !== null) {
87
+ current[part] = { ...current[part] };
88
+ }
89
+ else {
90
+ current[part] = {};
91
+ }
92
+ current = current[part];
93
+ }
94
+ current[parts[parts.length - 1]] = value;
95
+ }
96
+ (0, delete_nested_key_js_1.deleteNestedKey)(merged, propsToDelete);
97
+ return merged;
98
+ };
99
+ exports.mergeValues = mergeValues;
100
+ const stackToOverrideMap = {};
101
+ const withInteractivitySchema = ({ Component, componentName, componentIdentity, schema, supportsEffects, }) => {
102
+ // Schema is static for a component, so we move this outside
103
+ const schemaWithSequenceName = (0, interactivity_schema_js_1.extendSchemaWithSequenceName)(schema);
104
+ const flatSchema = (0, flatten_schema_js_1.getFlatSchemaWithAllKeys)(schemaWithSequenceName);
105
+ const flatKeys = Object.keys(flatSchema);
106
+ const Wrapped = (0, react_1.forwardRef)((props, ref) => {
107
+ var _a;
108
+ const env = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
109
+ if (!env.isStudio || env.isReadOnlyStudio || env.isRendering) {
110
+ return react_1.default.createElement(Component, {
111
+ ...props,
112
+ controls: null,
113
+ ref,
114
+ });
115
+ }
116
+ // eslint-disable-next-line react-hooks/rules-of-hooks
117
+ const { propStatuses } = (0, react_1.useContext)(SequenceManager_js_1.VisualModePropStatusesContext);
118
+ // eslint-disable-next-line react-hooks/rules-of-hooks
119
+ const { getDragOverrides } = (0, react_1.useContext)(SequenceManager_js_1.VisualModeDragOverridesContext);
120
+ // eslint-disable-next-line react-hooks/rules-of-hooks
121
+ const nodePathMapping = (0, react_1.useContext)(sequence_node_path_js_1.OverrideIdsToNodePathsGettersContext);
122
+ // eslint-disable-next-line react-hooks/rules-of-hooks
123
+ const frame = (0, use_current_frame_js_1.useCurrentFrame)();
124
+ // If the parent has passed `controls`, we should not override it.
125
+ // @ts-expect-error
126
+ if (props.controls) {
127
+ return react_1.default.createElement(Component, {
128
+ ...props,
129
+ ref,
130
+ });
131
+ }
132
+ // eslint-disable-next-line react-hooks/rules-of-hooks
133
+ const [overrideId] = (0, react_1.useState)(() => {
134
+ const { stack } = props;
135
+ if (!stack) {
136
+ return String(Math.random());
137
+ }
138
+ const existingOverrideId = stackToOverrideMap[stack];
139
+ if (existingOverrideId) {
140
+ return existingOverrideId;
141
+ }
142
+ const newOverrideId = String(Math.random());
143
+ stackToOverrideMap[stack] = newOverrideId;
144
+ return newOverrideId;
145
+ });
146
+ const nodePath = (_a = nodePathMapping.overrideIdToNodePathMappings[overrideId]) !== null && _a !== void 0 ? _a : null;
147
+ // Read the runtime values for every flat key from the JSX props,
148
+ // memoized on the leaf values so the object reference is stable
149
+ // when nothing changed — otherwise downstream `useMemo`s churn and
150
+ // effects (e.g. Sequence registration) re-fire every render.
151
+ const runtimeValues = flatKeys.map((k) => (0, exports.getNestedValue)(props, k));
152
+ // eslint-disable-next-line react-hooks/rules-of-hooks
153
+ const currentRuntimeValueDotNotation = (0, react_1.useMemo)(() => (0, exports.readValuesFromProps)(props, flatKeys),
154
+ // eslint-disable-next-line react-hooks/exhaustive-deps
155
+ runtimeValues);
156
+ // eslint-disable-next-line react-hooks/rules-of-hooks
157
+ const controls = (0, react_1.useMemo)(() => {
158
+ return {
159
+ schema: schemaWithSequenceName,
160
+ currentRuntimeValueDotNotation,
161
+ overrideId,
162
+ supportsEffects,
163
+ componentIdentity,
164
+ componentName,
165
+ };
166
+ }, [currentRuntimeValueDotNotation, overrideId]);
167
+ // 3. Apply drag/code overrides on top of the runtime values.
168
+ // eslint-disable-next-line react-hooks/rules-of-hooks
169
+ const { merged: valuesDotNotation, propsToDelete } = (0, react_1.useMemo)(() => {
170
+ return (0, use_schema_js_1.computeEffectiveSchemaValuesDotNotation)({
171
+ schema: schemaWithSequenceName,
172
+ currentValue: currentRuntimeValueDotNotation,
173
+ overrideValues: nodePath === null ? {} : getDragOverrides(nodePath),
174
+ propStatus: nodePath === null
175
+ ? undefined
176
+ : (0, use_memoized_effects_js_1.getPropStatusesCtx)(propStatuses, nodePath),
177
+ frame,
178
+ });
179
+ }, [
180
+ currentRuntimeValueDotNotation,
181
+ getDragOverrides,
182
+ nodePath,
183
+ propStatuses,
184
+ frame,
185
+ ]);
186
+ // 4. Eliminate values forbidden by the resolved discriminated union.
187
+ const activeKeys = (0, exports.selectActiveKeys)(schemaWithSequenceName, valuesDotNotation);
188
+ // 5. Apply the active values back onto the props.
189
+ const mergedProps = (0, exports.mergeValues)({
190
+ props: props,
191
+ valuesDotNotation,
192
+ schemaKeys: activeKeys,
193
+ propsToDelete,
194
+ });
195
+ return react_1.default.createElement(Component, {
196
+ ...mergedProps,
197
+ controls,
198
+ ref,
199
+ });
200
+ });
201
+ Wrapped.displayName = `withInteractivitySchema(${Component.displayName || Component.name || 'Component'})`;
202
+ return Wrapped;
203
+ };
204
+ exports.withInteractivitySchema = withInteractivitySchema;
@@ -1,16 +1,16 @@
1
1
  import React from 'react';
2
2
  import type { SequenceControls } from './CompositionManager.js';
3
- import { type SequenceSchema } from './sequence-field-schema.js';
3
+ import { type InteractivitySchema } from './interactivity-schema.js';
4
4
  export declare const getNestedValue: (obj: Record<string, unknown>, key: string) => unknown;
5
5
  export declare const readValuesFromProps: (props: Record<string, unknown>, keys: string[]) => Record<string, unknown>;
6
- export declare const selectActiveKeys: (schema: SequenceSchema, values: Record<string, unknown>) => string[];
6
+ export declare const selectActiveKeys: (schema: InteractivitySchema, values: Record<string, unknown>) => string[];
7
7
  export declare const mergeValues: ({ props, valuesDotNotation, schemaKeys, propsToDelete, }: {
8
8
  props: Record<string, unknown>;
9
9
  valuesDotNotation: Record<string, unknown>;
10
10
  schemaKeys: string[];
11
11
  propsToDelete: Set<string>;
12
12
  }) => Record<string, unknown>;
13
- export declare const wrapInSchema: <S extends SequenceSchema, Props extends object>({ Component, componentIdentity, schema, supportsEffects, }: {
13
+ export declare const wrapInSchema: <S extends InteractivitySchema, Props extends object>({ Component, componentIdentity, schema, supportsEffects, }: {
14
14
  Component: React.ComponentType<Props & {
15
15
  readonly _experimentalControls: SequenceControls | undefined;
16
16
  }>;
@@ -38,7 +38,7 @@ const react_1 = __importStar(require("react"));
38
38
  const delete_nested_key_js_1 = require("./delete-nested-key.js");
39
39
  const use_memoized_effects_js_1 = require("./effects/use-memoized-effects.js");
40
40
  const flatten_schema_js_1 = require("./flatten-schema.js");
41
- const sequence_field_schema_js_1 = require("./sequence-field-schema.js");
41
+ const interactivity_schema_js_1 = require("./interactivity-schema.js");
42
42
  const sequence_node_path_js_1 = require("./sequence-node-path.js");
43
43
  const SequenceManager_js_1 = require("./SequenceManager.js");
44
44
  const use_current_frame_js_1 = require("./use-current-frame.js");
@@ -100,7 +100,7 @@ exports.mergeValues = mergeValues;
100
100
  const stackToOverrideMap = {};
101
101
  const wrapInSchema = ({ Component, componentIdentity, schema, supportsEffects, }) => {
102
102
  // Schema is static for a component, so we move this outside
103
- const schemaWithSequenceName = (0, sequence_field_schema_js_1.extendSchemaWithSequenceName)(schema);
103
+ const schemaWithSequenceName = (0, interactivity_schema_js_1.extendSchemaWithSequenceName)(schema);
104
104
  const flatSchema = (0, flatten_schema_js_1.getFlatSchemaWithAllKeys)(schemaWithSequenceName);
105
105
  const flatKeys = Object.keys(flatSchema);
106
106
  const Wrapped = (0, react_1.forwardRef)((props, ref) => {