@remotion/studio 4.0.279 → 4.0.282

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 (27) hide show
  1. package/.turbo/turbo-make.log +2 -2
  2. package/dist/api/get-zod-schema-from-primitive.d.ts +2 -0
  3. package/dist/api/get-zod-schema-from-primitive.js +13 -0
  4. package/dist/api/use-visual-control.d.ts +7 -0
  5. package/dist/api/use-visual-control.js +58 -0
  6. package/dist/components/AudioWaveform.js +1 -0
  7. package/dist/components/RenderModal/SchemaEditor/ZodMatrixEditor.d.ts +17 -0
  8. package/dist/components/RenderModal/SchemaEditor/ZodMatrixEditor.js +91 -0
  9. package/dist/components/VisualControls/ClickableFileName.d.ts +3 -0
  10. package/dist/components/VisualControls/ClickableFileName.js +39 -0
  11. package/dist/components/VisualControls/VisualControlHandle.d.ts +8 -0
  12. package/dist/components/VisualControls/VisualControlHandle.js +34 -0
  13. package/dist/components/VisualControls/VisualControlsContent.d.ts +1 -0
  14. package/dist/components/VisualControls/VisualControlsContent.js +29 -0
  15. package/dist/components/VisualControls/VisualControlsTabs.d.ts +1 -0
  16. package/dist/components/VisualControls/VisualControlsTabs.js +11 -0
  17. package/dist/components/VisualControls/get-original-stack-trace.d.ts +2 -0
  18. package/dist/components/VisualControls/get-original-stack-trace.js +23 -0
  19. package/dist/esm/internals.mjs +2 -1
  20. package/dist/esm/previewEntry.mjs +2 -1
  21. package/dist/esm/renderEntry.mjs +2 -1
  22. package/dist/visual-controls/VisualControls.d.ts +36 -0
  23. package/dist/visual-controls/VisualControls.js +118 -0
  24. package/dist/visual-controls/get-current-edited-value.d.ts +6 -0
  25. package/dist/visual-controls/get-current-edited-value.js +9 -0
  26. package/package.json +9 -9
  27. package/tsconfig.tsbuildinfo +1 -1
@@ -1,6 +1,6 @@
1
1
 
2
2
  
3
- > @remotion/studio@4.0.279 make /Users/jonathanburger/remotion/packages/studio
3
+ > @remotion/studio@4.0.282 make /Users/jonathanburger/remotion/packages/studio
4
4
  > tsc -d && bun --env-file=../.env.bundle bundle.ts
5
5
 
6
- [170.43ms] Generated.
6
+ [54.39ms] Generated.
@@ -0,0 +1,2 @@
1
+ import type { ZodType } from '../components/get-zod-if-possible';
2
+ export declare const getZodSchemaFromPrimitive: (value: unknown, z: ZodType) => import("zod").ZodString | import("zod").ZodNumber;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getZodSchemaFromPrimitive = void 0;
4
+ const getZodSchemaFromPrimitive = (value, z) => {
5
+ if (typeof value === 'string') {
6
+ return z.string();
7
+ }
8
+ if (typeof value === 'number') {
9
+ return z.number();
10
+ }
11
+ throw new Error('Unknown primitive type');
12
+ };
13
+ exports.getZodSchemaFromPrimitive = getZodSchemaFromPrimitive;
@@ -0,0 +1,7 @@
1
+ import type { z } from 'zod';
2
+ type VisualControl = <T>(key: string, value: T, schema?: z.ZodTypeAny) => T;
3
+ type UseVisualControl = {
4
+ visualControl: VisualControl;
5
+ };
6
+ export declare const useVisualControl: () => UseVisualControl;
7
+ export {};
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useVisualControl = void 0;
4
+ const react_1 = require("react");
5
+ const remotion_1 = require("remotion");
6
+ const get_zod_if_possible_1 = require("../components/get-zod-if-possible");
7
+ const VisualControls_1 = require("../visual-controls/VisualControls");
8
+ const get_zod_schema_from_primitive_1 = require("./get-zod-schema-from-primitive");
9
+ const useVisualControl = () => {
10
+ const { addHook, removeHook, setControl, updateHandles } = (0, react_1.useContext)(VisualControls_1.SetVisualControlsContext);
11
+ const { handles } = (0, react_1.useContext)(VisualControls_1.VisualControlsContext);
12
+ const changed = (0, react_1.useRef)(false);
13
+ const [stack] = (0, react_1.useState)(() => {
14
+ return new Error().stack;
15
+ });
16
+ const [hook] = (0, react_1.useState)(() => {
17
+ return (0, VisualControls_1.makeHook)(stack);
18
+ });
19
+ (0, react_1.useEffect)(() => {
20
+ if (!(0, remotion_1.getRemotionEnvironment)().isStudio) {
21
+ return;
22
+ }
23
+ addHook(hook);
24
+ }, [addHook, hook]);
25
+ (0, react_1.useEffect)(() => {
26
+ return () => {
27
+ removeHook(hook);
28
+ };
29
+ }, [hook, removeHook]);
30
+ (0, react_1.useEffect)(() => {
31
+ if (changed.current) {
32
+ updateHandles();
33
+ changed.current = false;
34
+ }
35
+ }, [updateHandles]);
36
+ const z = (0, get_zod_if_possible_1.useZodIfPossible)();
37
+ return (0, react_1.useMemo)(() => ({
38
+ visualControl(key, value, schema) {
39
+ if (!(0, remotion_1.getRemotionEnvironment)().isStudio) {
40
+ return value;
41
+ }
42
+ if (!z) {
43
+ return value;
44
+ }
45
+ const { same, currentValue } = setControl(hook, key, {
46
+ valueInCode: value,
47
+ unsavedValue: value,
48
+ schema: schema !== null && schema !== void 0 ? schema : (0, get_zod_schema_from_primitive_1.getZodSchemaFromPrimitive)(value, z),
49
+ stack: new Error().stack,
50
+ });
51
+ if (!same) {
52
+ changed.current = true;
53
+ }
54
+ return currentValue;
55
+ },
56
+ }), [handles, hook, setControl, z]);
57
+ };
58
+ exports.useVisualControl = useVisualControl;
@@ -100,6 +100,7 @@ const AudioWaveform = ({ src, startFrom, durationInFrames, visualizationWidth, s
100
100
  startTimeInSeconds: startFrom / vidConf.fps,
101
101
  durationInSeconds: Math.min((durationInFrames / vidConf.fps) * playbackRate, metadata.durationInSeconds),
102
102
  numberOfSamples,
103
+ normalize: false,
103
104
  });
104
105
  }, [
105
106
  durationInFrames,
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import type { z } from 'zod';
3
+ import type { UpdaterFunction } from './ZodSwitch';
4
+ import type { JSONPath } from './zod-types';
5
+ export declare const ZodMatrixEditor: React.FC<{
6
+ readonly schema: z.ZodTypeAny;
7
+ readonly jsonPath: JSONPath;
8
+ readonly value: unknown[];
9
+ readonly defaultValue: unknown[];
10
+ readonly setValue: UpdaterFunction<unknown[]>;
11
+ readonly onSave: UpdaterFunction<unknown[]>;
12
+ readonly showSaveButton: boolean;
13
+ readonly onRemove: null | (() => void);
14
+ readonly saving: boolean;
15
+ readonly saveDisabledByParent: boolean;
16
+ readonly mayPad: boolean;
17
+ }>;
@@ -0,0 +1,91 @@
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ZodMatrixEditor = void 0;
27
+ const jsx_runtime_1 = require("react/jsx-runtime");
28
+ const react_1 = __importStar(require("react"));
29
+ const get_zod_if_possible_1 = require("../../get-zod-if-possible");
30
+ const Fieldset_1 = require("./Fieldset");
31
+ const SchemaLabel_1 = require("./SchemaLabel");
32
+ const SchemaSeparationLine_1 = require("./SchemaSeparationLine");
33
+ const SchemaVerticalGuide_1 = require("./SchemaVerticalGuide");
34
+ const ZodArrayItemEditor_1 = require("./ZodArrayItemEditor");
35
+ const ZodFieldValidation_1 = require("./ZodFieldValidation");
36
+ const create_zod_values_1 = require("./create-zod-values");
37
+ const deep_equal_1 = require("./deep-equal");
38
+ const local_state_1 = require("./local-state");
39
+ const rowStyle = {
40
+ display: 'flex',
41
+ flexDirection: 'row',
42
+ width: '100%',
43
+ };
44
+ const ZodMatrixEditor = ({ schema, jsonPath, setValue, defaultValue, value, onSave, showSaveButton, onRemove, saving, saveDisabledByParent, mayPad, }) => {
45
+ const { localValue, onChange, RevisionContextProvider, reset } = (0, local_state_1.useLocalState)({
46
+ unsavedValue: value,
47
+ schema,
48
+ setValue,
49
+ savedValue: defaultValue,
50
+ });
51
+ const [expanded, setExpanded] = (0, react_1.useState)(true);
52
+ const def = schema._def;
53
+ const suffix = (0, react_1.useMemo)(() => {
54
+ return expanded ? ' [' : ' [...] ';
55
+ }, [expanded]);
56
+ const z = (0, get_zod_if_possible_1.useZodIfPossible)();
57
+ if (!z) {
58
+ throw new Error('expected zod');
59
+ }
60
+ const zodTypes = (0, get_zod_if_possible_1.useZodTypesIfPossible)();
61
+ const isDefaultValue = (0, react_1.useMemo)(() => {
62
+ return (0, deep_equal_1.deepEqual)(localValue.value, defaultValue);
63
+ }, [defaultValue, localValue]);
64
+ const dimensions = Math.sqrt(localValue.value.length);
65
+ if (!Number.isInteger(dimensions)) {
66
+ throw new Error('Invalid matrix');
67
+ }
68
+ const chunkedItems = (0, react_1.useMemo)(() => {
69
+ return localValue.value.reduce((acc, item, index) => {
70
+ const chunkIndex = Math.floor(index / dimensions);
71
+ acc[chunkIndex] = acc[chunkIndex] || [];
72
+ acc[chunkIndex].push(item);
73
+ return acc;
74
+ }, []);
75
+ }, [localValue.value, dimensions]);
76
+ return ((0, jsx_runtime_1.jsxs)(Fieldset_1.Fieldset, { shouldPad: mayPad, success: localValue.zodValidation.success, children: [(0, jsx_runtime_1.jsx)("div", { style: {
77
+ display: 'flex',
78
+ flexDirection: 'row',
79
+ }, children: (0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { onReset: reset, isDefaultValue: isDefaultValue, jsonPath: jsonPath, onRemove: onRemove, suffix: suffix, onSave: () => {
80
+ onSave(() => localValue.value, false, false);
81
+ }, saveDisabledByParent: saveDisabledByParent, saving: saving, showSaveButton: showSaveButton, valid: localValue.zodValidation.success, handleClick: () => setExpanded(!expanded) }) }), expanded ? ((0, jsx_runtime_1.jsx)(RevisionContextProvider, { children: (0, jsx_runtime_1.jsxs)(SchemaVerticalGuide_1.SchemaVerticalGuide, { isRoot: false, children: [chunkedItems.map((row, rowIndex) => {
82
+ return ((0, jsx_runtime_1.jsx)(react_1.default.Fragment
83
+ // eslint-disable-next-line react/no-array-index-key
84
+ , { children: (0, jsx_runtime_1.jsx)("div", { style: rowStyle, children: row.map((item, _index) => {
85
+ var _a;
86
+ const actualIndex = rowIndex * dimensions + _index;
87
+ return ((0, jsx_runtime_1.jsx)("div", { style: { flex: 1 }, children: (0, jsx_runtime_1.jsx)(ZodArrayItemEditor_1.ZodArrayItemEditor, { onChange: onChange, value: item, def: def, index: actualIndex, jsonPath: jsonPath, defaultValue: (_a = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue[actualIndex]) !== null && _a !== void 0 ? _a : (0, create_zod_values_1.createZodValues)(def.type, z, zodTypes), onSave: onSave, showSaveButton: showSaveButton, saving: saving, saveDisabledByParent: saveDisabledByParent, mayPad: mayPad, mayRemove: false }) }, `${_index}${localValue.keyStabilityRevision}`));
88
+ }) }) }, `${rowIndex}${localValue.keyStabilityRevision}`));
89
+ }), value.length === 0 ? ((0, jsx_runtime_1.jsx)(SchemaSeparationLine_1.SchemaArrayItemSeparationLine, { schema: schema, index: 0, onChange: onChange, isLast: true, showAddButton: true })) : null] }) })) : null, (0, jsx_runtime_1.jsx)(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, localValue: localValue })] }));
90
+ };
91
+ exports.ZodMatrixEditor = ZodMatrixEditor;
@@ -0,0 +1,3 @@
1
+ export declare const ClickableFileName: ({ stack }: {
2
+ readonly stack: string;
3
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClickableFileName = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const open_in_editor_1 = require("../../helpers/open-in-editor");
7
+ const source_attribution_1 = require("../Timeline/TimelineStack/source-attribution");
8
+ const get_original_stack_trace_1 = require("./get-original-stack-trace");
9
+ const label = {
10
+ fontSize: 13,
11
+ };
12
+ const ClickableFileName = ({ stack }) => {
13
+ const originalFileName = (0, get_original_stack_trace_1.useOriginalFileName)(stack);
14
+ const [titleHovered, setTitleHovered] = (0, react_1.useState)(false);
15
+ const hoverEffect = titleHovered && originalFileName;
16
+ const onTitlePointerEnter = (0, react_1.useCallback)(() => {
17
+ setTitleHovered(true);
18
+ }, []);
19
+ const onTitlePointerLeave = (0, react_1.useCallback)(() => {
20
+ setTitleHovered(false);
21
+ }, []);
22
+ const style = (0, react_1.useMemo)(() => {
23
+ return {
24
+ ...label,
25
+ cursor: originalFileName ? 'pointer' : undefined,
26
+ borderBottom: hoverEffect ? '1px solid #fff' : 'none',
27
+ };
28
+ }, [originalFileName, hoverEffect]);
29
+ const onClick = (0, react_1.useCallback)(async () => {
30
+ if (!originalFileName) {
31
+ return;
32
+ }
33
+ await (0, open_in_editor_1.openOriginalPositionInEditor)(originalFileName);
34
+ }, [originalFileName]);
35
+ return ((0, jsx_runtime_1.jsx)("span", { style: style, onClick: onClick, onPointerEnter: onTitlePointerEnter, onPointerLeave: onTitlePointerLeave, children: originalFileName
36
+ ? (0, source_attribution_1.getOriginalSourceAttribution)(originalFileName)
37
+ : 'Loading...' }));
38
+ };
39
+ exports.ClickableFileName = ClickableFileName;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import type { VisualControlHook } from '../../visual-controls/VisualControls';
3
+ import { type VisualControlValue } from '../../visual-controls/VisualControls';
4
+ export declare const VisualControlHandle: React.FC<{
5
+ readonly value: VisualControlValue;
6
+ readonly keyName: string;
7
+ readonly hook: VisualControlHook;
8
+ }>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VisualControlHandle = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const VisualControls_1 = require("../../visual-controls/VisualControls");
7
+ const get_current_edited_value_1 = require("../../visual-controls/get-current-edited-value");
8
+ const ZodSwitch_1 = require("../RenderModal/SchemaEditor/ZodSwitch");
9
+ const local_state_1 = require("../RenderModal/SchemaEditor/local-state");
10
+ const get_zod_if_possible_1 = require("../get-zod-if-possible");
11
+ const container = {
12
+ marginBottom: 10,
13
+ };
14
+ const VisualControlHandle = ({ value, keyName, hook }) => {
15
+ const z = (0, get_zod_if_possible_1.useZodIfPossible)();
16
+ if (!z) {
17
+ throw new Error('expected zod');
18
+ }
19
+ const state = (0, react_1.useContext)(VisualControls_1.VisualControlsContext);
20
+ const { updateValue } = (0, react_1.useContext)(VisualControls_1.SetVisualControlsContext);
21
+ const currentValue = (0, get_current_edited_value_1.getVisualControlEditedValue)({
22
+ handles: state.handles,
23
+ hook,
24
+ key: keyName,
25
+ });
26
+ const { localValue, RevisionContextProvider, onChange } = (0, local_state_1.useLocalState)({
27
+ schema: value.schema,
28
+ setValue: (updater) => updateValue(hook, keyName, updater(currentValue)),
29
+ unsavedValue: currentValue,
30
+ savedValue: value.valueInCode,
31
+ });
32
+ return ((0, jsx_runtime_1.jsx)("div", { style: container, children: (0, jsx_runtime_1.jsx)(RevisionContextProvider, { children: (0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { mayPad: true, schema: value.schema, showSaveButton: true, saving: false, saveDisabledByParent: false, onSave: () => undefined, jsonPath: [keyName], value: localValue.value, defaultValue: value.valueInCode, setValue: onChange, onRemove: null }) }) }));
33
+ };
34
+ exports.VisualControlHandle = VisualControlHandle;
@@ -0,0 +1 @@
1
+ export declare const VisualControlsContent: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VisualControlsContent = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const VisualControls_1 = require("../../visual-controls/VisualControls");
7
+ const layout_1 = require("../layout");
8
+ const is_menu_item_1 = require("../Menu/is-menu-item");
9
+ const ClickableFileName_1 = require("./ClickableFileName");
10
+ const VisualControlHandle_1 = require("./VisualControlHandle");
11
+ const Control = ({ hook }) => {
12
+ const { handles } = (0, react_1.useContext)(VisualControls_1.VisualControlsContext);
13
+ const handle = handles[hook.id];
14
+ if (!handle) {
15
+ return null;
16
+ }
17
+ return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(ClickableFileName_1.ClickableFileName, { stack: hook.stack }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { block: true, y: 1 }), Object.entries(handle).map(([key, value]) => {
18
+ return ((0, jsx_runtime_1.jsx)(VisualControlHandle_1.VisualControlHandle, { keyName: key, value: value, hook: hook }, key));
19
+ })] }, hook.id));
20
+ };
21
+ const container = {
22
+ padding: 12,
23
+ overflowY: 'auto',
24
+ };
25
+ const VisualControlsContent = () => {
26
+ const { hooks: controls } = (0, react_1.useContext)(VisualControls_1.VisualControlsContext);
27
+ return ((0, jsx_runtime_1.jsx)("div", { style: container, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: controls.map((hook) => ((0, jsx_runtime_1.jsx)(Control, { hook: hook }, hook.id))) }));
28
+ };
29
+ exports.VisualControlsContent = VisualControlsContent;
@@ -0,0 +1 @@
1
+ export declare const VisualControlsContent: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VisualControlsContent = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const VisualControls_1 = require("../../visual-controls/VisualControls");
7
+ const VisualControlsContent = () => {
8
+ const { controls } = (0, react_1.useContext)(VisualControls_1.VisualControlsContext);
9
+ return ((0, jsx_runtime_1.jsx)("div", { children: controls.map((control) => ((0, jsx_runtime_1.jsx)("div", { children: control.id }, control.id))) }));
10
+ };
11
+ exports.VisualControlsContent = VisualControlsContent;
@@ -0,0 +1,2 @@
1
+ import type { OriginalPosition } from '../../error-overlay/react-overlay/utils/get-source-map';
2
+ export declare const useOriginalFileName: (stack: string) => OriginalPosition | null;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useOriginalFileName = void 0;
4
+ const react_1 = require("react");
5
+ const get_stack_1 = require("../Timeline/TimelineStack/get-stack");
6
+ const useOriginalFileName = (stack) => {
7
+ const [originalFileName, setOriginalFileName] = (0, react_1.useState)(null);
8
+ (0, react_1.useEffect)(() => {
9
+ if (!stack) {
10
+ return;
11
+ }
12
+ (0, get_stack_1.getOriginalLocationFromStack)(stack, 'visual-control')
13
+ .then((frame) => {
14
+ setOriginalFileName(frame);
15
+ })
16
+ .catch((err) => {
17
+ // eslint-disable-next-line no-console
18
+ console.error('Could not get original location of Sequence', err);
19
+ });
20
+ }, [stack]);
21
+ return originalFileName;
22
+ };
23
+ exports.useOriginalFileName = useOriginalFileName;
@@ -19364,7 +19364,8 @@ var AudioWaveform = ({
19364
19364
  audioData: metadata,
19365
19365
  startTimeInSeconds: startFrom / vidConf.fps,
19366
19366
  durationInSeconds: Math.min(durationInFrames / vidConf.fps * playbackRate, metadata.durationInSeconds),
19367
- numberOfSamples
19367
+ numberOfSamples,
19368
+ normalize: false
19368
19369
  });
19369
19370
  }, [
19370
19371
  durationInFrames,
@@ -19646,7 +19646,8 @@ var AudioWaveform = ({
19646
19646
  audioData: metadata,
19647
19647
  startTimeInSeconds: startFrom / vidConf.fps,
19648
19648
  durationInSeconds: Math.min(durationInFrames / vidConf.fps * playbackRate, metadata.durationInSeconds),
19649
- numberOfSamples
19649
+ numberOfSamples,
19650
+ normalize: false
19650
19651
  });
19651
19652
  }, [
19652
19653
  durationInFrames,
@@ -19993,7 +19993,8 @@ var container39, errorMessage, canvasStyle, AudioWaveform = ({
19993
19993
  audioData: metadata,
19994
19994
  startTimeInSeconds: startFrom / vidConf.fps,
19995
19995
  durationInSeconds: Math.min(durationInFrames / vidConf.fps * playbackRate, metadata.durationInSeconds),
19996
- numberOfSamples
19996
+ numberOfSamples,
19997
+ normalize: false
19997
19998
  });
19998
19999
  }, [
19999
20000
  durationInFrames,
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import type { ZodTypeAny } from 'zod';
3
+ export type VisualControlValue = {
4
+ valueInCode: unknown;
5
+ unsavedValue: unknown;
6
+ schema: ZodTypeAny;
7
+ stack: string;
8
+ };
9
+ export type VisualControlHook = {
10
+ id: number;
11
+ stack: string;
12
+ };
13
+ type Handle = Record<string, VisualControlValue>;
14
+ export type Handles = Record<number, Handle>;
15
+ export type VisualControlsContextType = {
16
+ hooks: VisualControlHook[];
17
+ handles: Handles;
18
+ };
19
+ export declare const VisualControlsTabActivatedContext: React.Context<boolean>;
20
+ export type SetVisualControlsContextType = {
21
+ addHook: (hook: VisualControlHook) => void;
22
+ removeHook: (hook: VisualControlHook) => void;
23
+ setControl: (hook: VisualControlHook, key: string, value: VisualControlValue) => {
24
+ same: boolean;
25
+ currentValue: unknown;
26
+ };
27
+ updateHandles: () => void;
28
+ updateValue: (hook: VisualControlHook, key: string, value: unknown) => void;
29
+ };
30
+ export declare const makeHook: (stack: string) => VisualControlHook;
31
+ export declare const VisualControlsContext: React.Context<VisualControlsContextType>;
32
+ export declare const SetVisualControlsContext: React.Context<SetVisualControlsContextType>;
33
+ export declare const VisualControlsProvider: React.FC<{
34
+ readonly children: React.ReactNode;
35
+ }>;
36
+ export {};
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VisualControlsProvider = exports.SetVisualControlsContext = exports.VisualControlsContext = exports.makeHook = exports.VisualControlsTabActivatedContext = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const get_current_edited_value_1 = require("./get-current-edited-value");
7
+ exports.VisualControlsTabActivatedContext = (0, react_1.createContext)(false);
8
+ const makeHook = (stack) => {
9
+ return { id: Math.random(), stack };
10
+ };
11
+ exports.makeHook = makeHook;
12
+ exports.VisualControlsContext = (0, react_1.createContext)({
13
+ hooks: [],
14
+ handles: {},
15
+ });
16
+ exports.SetVisualControlsContext = (0, react_1.createContext)({
17
+ addHook: () => {
18
+ throw new Error('addControl is not implemented');
19
+ },
20
+ removeHook: () => {
21
+ throw new Error('removeControl is not implemented');
22
+ },
23
+ setControl: () => {
24
+ throw new Error('addControl is not implemented');
25
+ },
26
+ updateHandles: () => {
27
+ throw new Error('updateHandles is not implemented');
28
+ },
29
+ updateValue: () => {
30
+ throw new Error('updateValue is not implemented');
31
+ },
32
+ });
33
+ const VisualControlsProvider = ({ children }) => {
34
+ const [hooks, setHooks] = (0, react_1.useState)([]);
35
+ const imperativeHandles = (0, react_1.useRef)({});
36
+ const [handles, setHandles] = (0, react_1.useState)({});
37
+ const [tabActivated, setTabActivated] = (0, react_1.useState)(false);
38
+ const addHook = (0, react_1.useCallback)((hook) => {
39
+ setHooks((prev) => {
40
+ if (prev.find((c) => c.id === hook.id)) {
41
+ return prev;
42
+ }
43
+ return [...prev, hook];
44
+ });
45
+ setTabActivated(true);
46
+ }, [setHooks]);
47
+ const removeHook = (0, react_1.useCallback)((hook) => {
48
+ setHooks((prev) => prev.filter((c) => c !== hook));
49
+ }, [setHooks]);
50
+ const state = (0, react_1.useMemo)(() => {
51
+ return {
52
+ hooks,
53
+ handles,
54
+ };
55
+ }, [hooks, handles]);
56
+ const setControl = (0, react_1.useCallback)((hook, key, value) => {
57
+ var _a, _b, _c, _d, _e, _f;
58
+ const currentSaved = (_c = (_b = (_a = imperativeHandles.current) === null || _a === void 0 ? void 0 : _a[hook.id]) === null || _b === void 0 ? void 0 : _b[key]) === null || _c === void 0 ? void 0 : _c.valueInCode;
59
+ const currentUnsaved = (_f = (_e = (_d = imperativeHandles.current) === null || _d === void 0 ? void 0 : _d[hook.id]) === null || _e === void 0 ? void 0 : _e[key]) === null || _f === void 0 ? void 0 : _f.unsavedValue;
60
+ if (currentSaved === value.valueInCode) {
61
+ return {
62
+ same: true,
63
+ currentValue: (0, get_current_edited_value_1.getVisualControlEditedValue)({
64
+ hook,
65
+ key,
66
+ handles: imperativeHandles.current,
67
+ }),
68
+ };
69
+ }
70
+ imperativeHandles.current = {
71
+ ...imperativeHandles.current,
72
+ [hook.id]: {
73
+ ...imperativeHandles.current[hook.id],
74
+ [key]: {
75
+ ...value,
76
+ unsavedValue: currentUnsaved !== null && currentUnsaved !== void 0 ? currentUnsaved : value.valueInCode,
77
+ },
78
+ },
79
+ };
80
+ return {
81
+ same: false,
82
+ currentValue: (0, get_current_edited_value_1.getVisualControlEditedValue)({
83
+ hook,
84
+ key,
85
+ handles: imperativeHandles.current,
86
+ }),
87
+ };
88
+ }, []);
89
+ const updateHandles = (0, react_1.useCallback)(() => {
90
+ setHandles(() => {
91
+ return imperativeHandles.current;
92
+ });
93
+ }, []);
94
+ const updateValue = (0, react_1.useCallback)((hook, key, value) => {
95
+ imperativeHandles.current = {
96
+ ...imperativeHandles.current,
97
+ [hook.id]: {
98
+ ...imperativeHandles.current[hook.id],
99
+ [key]: {
100
+ ...imperativeHandles.current[hook.id][key],
101
+ unsavedValue: value,
102
+ },
103
+ },
104
+ };
105
+ updateHandles();
106
+ }, [updateHandles]);
107
+ const setState = (0, react_1.useMemo)(() => {
108
+ return {
109
+ addHook,
110
+ removeHook,
111
+ setControl,
112
+ updateHandles,
113
+ updateValue,
114
+ };
115
+ }, [addHook, removeHook, setControl, updateHandles, updateValue]);
116
+ return ((0, jsx_runtime_1.jsx)(exports.VisualControlsTabActivatedContext.Provider, { value: tabActivated, children: (0, jsx_runtime_1.jsx)(exports.VisualControlsContext.Provider, { value: state, children: (0, jsx_runtime_1.jsx)(exports.SetVisualControlsContext.Provider, { value: setState, children: children }) }) }));
117
+ };
118
+ exports.VisualControlsProvider = VisualControlsProvider;
@@ -0,0 +1,6 @@
1
+ import type { Handles, VisualControlHook } from './VisualControls';
2
+ export declare const getVisualControlEditedValue: ({ handles, hook, key, }: {
3
+ handles: Handles;
4
+ hook: VisualControlHook;
5
+ key: string;
6
+ }) => unknown;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getVisualControlEditedValue = void 0;
4
+ const getVisualControlEditedValue = ({ handles, hook, key, }) => {
5
+ var _a, _b, _c;
6
+ // TODO: What if z.null()
7
+ return (_c = (_b = (_a = handles === null || handles === void 0 ? void 0 : handles[hook.id]) === null || _a === void 0 ? void 0 : _a[key]) === null || _b === void 0 ? void 0 : _b.unsavedValue) !== null && _c !== void 0 ? _c : null;
8
+ };
9
+ exports.getVisualControlEditedValue = getVisualControlEditedValue;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/studio"
4
4
  },
5
5
  "name": "@remotion/studio",
6
- "version": "4.0.279",
6
+ "version": "4.0.282",
7
7
  "description": "APIs for interacting with the Remotion Studio",
8
8
  "main": "dist",
9
9
  "sideEffects": false,
@@ -23,20 +23,20 @@
23
23
  "source-map": "0.7.3",
24
24
  "open": "^8.4.2",
25
25
  "zod": "3.22.3",
26
- "remotion": "4.0.279",
27
- "@remotion/player": "4.0.279",
28
- "@remotion/media-parser": "4.0.279",
29
- "@remotion/media-utils": "4.0.279",
30
- "@remotion/renderer": "4.0.279",
31
- "@remotion/studio-shared": "4.0.279",
32
- "@remotion/zod-types": "4.0.279"
26
+ "remotion": "4.0.282",
27
+ "@remotion/player": "4.0.282",
28
+ "@remotion/media-parser": "4.0.282",
29
+ "@remotion/media-utils": "4.0.282",
30
+ "@remotion/studio-shared": "4.0.282",
31
+ "@remotion/zod-types": "4.0.282",
32
+ "@remotion/renderer": "4.0.282"
33
33
  },
34
34
  "devDependencies": {
35
35
  "react": "19.0.0",
36
36
  "react-dom": "19.0.0",
37
37
  "@types/semver": "^7.3.4",
38
38
  "eslint": "9.19.0",
39
- "@remotion/eslint-config-internal": "4.0.279"
39
+ "@remotion/eslint-config-internal": "4.0.282"
40
40
  },
41
41
  "publishConfig": {
42
42
  "access": "public"