@remotion/studio 4.0.463 → 4.0.464

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 (78) hide show
  1. package/dist/components/CanvasOrLoading.js +1 -1
  2. package/dist/components/ColorPicker/AlphaSlider.d.ts +9 -0
  3. package/dist/components/ColorPicker/AlphaSlider.js +88 -0
  4. package/dist/components/ColorPicker/ColorPicker.d.ts +18 -0
  5. package/dist/components/ColorPicker/ColorPicker.js +176 -0
  6. package/dist/components/ColorPicker/ColorPickerPopup.d.ts +8 -0
  7. package/dist/components/ColorPicker/ColorPickerPopup.js +276 -0
  8. package/dist/components/ColorPicker/HueSlider.d.ts +6 -0
  9. package/dist/components/ColorPicker/HueSlider.js +68 -0
  10. package/dist/components/ColorPicker/SaturationValueArea.d.ts +14 -0
  11. package/dist/components/ColorPicker/SaturationValueArea.js +93 -0
  12. package/dist/components/ColorPicker/checker.d.ts +4 -0
  13. package/dist/components/ColorPicker/checker.js +9 -0
  14. package/dist/components/ExpandedTracksProvider.d.ts +2 -0
  15. package/dist/components/ExpandedTracksProvider.js +18 -1
  16. package/dist/components/RenderModal/SchemaEditor/ZodColorEditor.js +8 -47
  17. package/dist/components/Timeline/Padder.js +2 -2
  18. package/dist/components/Timeline/SubscribeToNodePaths.d.ts +1 -1
  19. package/dist/components/Timeline/SubscribeToNodePaths.js +9 -4
  20. package/dist/components/Timeline/Timeline.js +4 -7
  21. package/dist/components/Timeline/TimelineColorField.js +18 -156
  22. package/dist/components/Timeline/TimelineEffectFieldRow.d.ts +1 -2
  23. package/dist/components/Timeline/TimelineEffectFieldRow.js +22 -31
  24. package/dist/components/Timeline/TimelineEffectGroupRow.d.ts +1 -2
  25. package/dist/components/Timeline/TimelineEffectGroupRow.js +15 -12
  26. package/dist/components/Timeline/TimelineExpandedRow.js +15 -30
  27. package/dist/components/Timeline/TimelineFieldRow.d.ts +1 -2
  28. package/dist/components/Timeline/TimelineFieldRow.js +19 -16
  29. package/dist/components/Timeline/TimelineImageInfo.js +5 -17
  30. package/dist/components/Timeline/TimelineListItem.d.ts +0 -1
  31. package/dist/components/Timeline/TimelineListItem.js +12 -14
  32. package/dist/components/Timeline/TimelineRowChrome.d.ts +8 -0
  33. package/dist/components/Timeline/TimelineRowChrome.js +21 -0
  34. package/dist/components/Timeline/TimelineTracks.js +0 -4
  35. package/dist/components/Timeline/save-effect-prop.d.ts +2 -1
  36. package/dist/components/Timeline/save-effect-prop.js +2 -13
  37. package/dist/components/Timeline/save-prop-queue.d.ts +1 -2
  38. package/dist/components/Timeline/save-prop-queue.js +3 -12
  39. package/dist/components/Timeline/save-sequence-prop.d.ts +2 -1
  40. package/dist/components/Timeline/save-sequence-prop.js +2 -11
  41. package/dist/components/Timeline/should-show-track-in-timeline.d.ts +2 -0
  42. package/dist/components/Timeline/should-show-track-in-timeline.js +23 -0
  43. package/dist/components/Timeline/timeline-field-row-layout.d.ts +2 -0
  44. package/dist/components/Timeline/timeline-field-row-layout.js +14 -0
  45. package/dist/components/Timeline/timeline-indent.d.ts +1 -0
  46. package/dist/components/Timeline/timeline-indent.js +4 -0
  47. package/dist/components/Timeline/timeline-row-layout.d.ts +11 -0
  48. package/dist/components/Timeline/timeline-row-layout.js +27 -0
  49. package/dist/components/Timeline/use-resolved-stack-react-to-change.d.ts +2 -0
  50. package/dist/components/Timeline/use-resolved-stack-react-to-change.js +59 -0
  51. package/dist/components/Timeline/use-sequence-props-subscription.js +27 -1
  52. package/dist/error-overlay/remotion-overlay/ShortcutHint.js +5 -3
  53. package/dist/esm/chunk-6jf1natv.js +25 -0
  54. package/dist/esm/{chunk-b0m62frw.js → chunk-mawnnpzg.js} +4811 -3975
  55. package/dist/esm/index.mjs +16 -0
  56. package/dist/esm/internals.mjs +4824 -3973
  57. package/dist/esm/previewEntry.mjs +4835 -3985
  58. package/dist/esm/renderEntry.mjs +4 -3
  59. package/dist/helpers/client-id.d.ts +2 -9
  60. package/dist/helpers/client-id.js +15 -40
  61. package/dist/helpers/color-conversion.d.ts +36 -0
  62. package/dist/helpers/color-conversion.js +121 -0
  63. package/dist/helpers/inject-css.js +4 -7
  64. package/dist/helpers/migrate-expanded-tracks-for-subscription-key.d.ts +3 -0
  65. package/dist/helpers/migrate-expanded-tracks-for-subscription-key.js +26 -0
  66. package/dist/helpers/preview-server-events.d.ts +15 -0
  67. package/dist/helpers/preview-server-events.js +81 -0
  68. package/dist/helpers/timeline-layout.d.ts +0 -1
  69. package/dist/helpers/timeline-layout.js +29 -25
  70. package/dist/hot-middleware-client/client.js +10 -16
  71. package/package.json +10 -10
  72. package/dist/components/NewComposition/RemInputTypeColor.d.ts +0 -8
  73. package/dist/components/NewComposition/RemInputTypeColor.js +0 -53
  74. package/dist/components/Timeline/is-collapsed.d.ts +0 -2
  75. package/dist/components/Timeline/is-collapsed.js +0 -10
  76. package/dist/esm/chunk-5gtx3pza.js +0 -9
  77. package/dist/helpers/color-math.d.ts +0 -1
  78. package/dist/helpers/color-math.js +0 -13
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SaturationValueArea = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const color_conversion_1 = require("../../helpers/color-conversion");
7
+ const AREA_HEIGHT = 140;
8
+ const containerStyle = {
9
+ position: 'relative',
10
+ width: '100%',
11
+ height: AREA_HEIGHT,
12
+ cursor: 'crosshair',
13
+ borderRadius: 3,
14
+ overflow: 'hidden',
15
+ touchAction: 'none',
16
+ };
17
+ const valueOverlay = {
18
+ position: 'absolute',
19
+ inset: 0,
20
+ background: 'linear-gradient(to top, #000, transparent)',
21
+ };
22
+ const saturationOverlay = {
23
+ position: 'absolute',
24
+ inset: 0,
25
+ background: 'linear-gradient(to right, #fff, transparent)',
26
+ };
27
+ const SaturationValueArea = ({ hue, saturation, value, onChange, onChangeComplete }) => {
28
+ const containerRef = (0, react_1.useRef)(null);
29
+ const baseColor = (0, react_1.useMemo)(() => {
30
+ const { r, g, b } = (0, color_conversion_1.hsvToRgb)({ h: hue, s: 1, v: 1 });
31
+ return `rgb(${r}, ${g}, ${b})`;
32
+ }, [hue]);
33
+ const updateFromEvent = (0, react_1.useCallback)((clientX, clientY, isFinal) => {
34
+ const { current } = containerRef;
35
+ if (!current) {
36
+ return;
37
+ }
38
+ const rect = current.getBoundingClientRect();
39
+ const x = (0, color_conversion_1.clamp)((clientX - rect.left) / rect.width, 0, 1);
40
+ const y = (0, color_conversion_1.clamp)((clientY - rect.top) / rect.height, 0, 1);
41
+ const next = { s: x, v: 1 - y };
42
+ if (isFinal) {
43
+ onChangeComplete(next);
44
+ }
45
+ else {
46
+ onChange(next);
47
+ }
48
+ }, [onChange, onChangeComplete]);
49
+ const onPointerDown = (0, react_1.useCallback)((e) => {
50
+ var _a, _b;
51
+ if (e.button !== 0) {
52
+ return;
53
+ }
54
+ e.preventDefault();
55
+ (_b = (_a = e.target).setPointerCapture) === null || _b === void 0 ? void 0 : _b.call(_a, e.pointerId);
56
+ updateFromEvent(e.clientX, e.clientY, false);
57
+ const onMove = (ev) => {
58
+ updateFromEvent(ev.clientX, ev.clientY, false);
59
+ };
60
+ const onUp = (ev) => {
61
+ window.removeEventListener('pointermove', onMove);
62
+ window.removeEventListener('pointerup', onUp);
63
+ updateFromEvent(ev.clientX, ev.clientY, true);
64
+ };
65
+ window.addEventListener('pointermove', onMove);
66
+ window.addEventListener('pointerup', onUp);
67
+ }, [updateFromEvent]);
68
+ const containerWithBg = (0, react_1.useMemo)(() => {
69
+ return {
70
+ ...containerStyle,
71
+ backgroundColor: baseColor,
72
+ };
73
+ }, [baseColor]);
74
+ const handleStyle = (0, react_1.useMemo)(() => {
75
+ return {
76
+ position: 'absolute',
77
+ left: `${saturation * 100}%`,
78
+ top: `${(1 - value) * 100}%`,
79
+ width: 12,
80
+ height: 12,
81
+ marginLeft: -6,
82
+ marginTop: -6,
83
+ borderRadius: '50%',
84
+ border: '2px solid #fff',
85
+ boxShadow: '0 0 0 1px rgba(0, 0, 0, 0.6)',
86
+ pointerEvents: 'none',
87
+ };
88
+ }, [saturation, value]);
89
+ return (jsx_runtime_1.jsxs("div", { ref: containerRef, style: containerWithBg, onPointerDown: onPointerDown, children: [
90
+ jsx_runtime_1.jsx("div", { style: saturationOverlay }), jsx_runtime_1.jsx("div", { style: valueOverlay }), jsx_runtime_1.jsx("div", { style: handleStyle })
91
+ ] }));
92
+ };
93
+ exports.SaturationValueArea = SaturationValueArea;
@@ -0,0 +1,4 @@
1
+ export declare const CHECKER_BACKGROUND_IMAGE = "linear-gradient(45deg, #888 25%, transparent 25%), linear-gradient(-45deg, #888 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #888 75%), linear-gradient(-45deg, transparent 75%, #888 75%)";
2
+ export declare const CHECKER_BACKGROUND_SIZE = "8px 8px";
3
+ export declare const CHECKER_BACKGROUND_POSITION = "0 0, 0 4px, 4px -4px, -4px 0";
4
+ export declare const CHECKER_BACKGROUND_COLOR = "#444";
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CHECKER_BACKGROUND_COLOR = exports.CHECKER_BACKGROUND_POSITION = exports.CHECKER_BACKGROUND_SIZE = exports.CHECKER_BACKGROUND_IMAGE = void 0;
4
+ // Checkerboard background used to indicate transparency in color swatches
5
+ // and the alpha slider. Rendered as a CSS gradient so we don't need an asset.
6
+ exports.CHECKER_BACKGROUND_IMAGE = 'linear-gradient(45deg, #888 25%, transparent 25%), linear-gradient(-45deg, #888 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #888 75%), linear-gradient(-45deg, transparent 75%, #888 75%)';
7
+ exports.CHECKER_BACKGROUND_SIZE = '8px 8px';
8
+ exports.CHECKER_BACKGROUND_POSITION = '0 0, 0 4px, 4px -4px, -4px 0';
9
+ exports.CHECKER_BACKGROUND_COLOR = '#444';
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import type { SequencePropsSubscriptionKey } from 'remotion';
2
3
  import type { SequenceNodePathInfo } from '../helpers/get-timeline-sequence-sort-key';
3
4
  export type GetIsExpanded = (nodePathInfo: SequenceNodePathInfo) => boolean;
4
5
  type ExpandedTracksGetterContextValue = {
@@ -6,6 +7,7 @@ type ExpandedTracksGetterContextValue = {
6
7
  };
7
8
  type ExpandedTracksSetterContextValue = {
8
9
  readonly toggleTrack: (nodePathInfo: SequenceNodePathInfo) => void;
10
+ readonly migrateExpandedTracksForSubscriptionKey: (oldKey: SequencePropsSubscriptionKey, newKey: SequencePropsSubscriptionKey) => void;
9
11
  };
10
12
  export declare const ExpandedTracksGetterContext: React.Context<ExpandedTracksGetterContextValue>;
11
13
  export declare const ExpandedTracksSetterContext: React.Context<ExpandedTracksSetterContextValue>;
@@ -4,6 +4,7 @@ exports.ExpandedTracksProvider = exports.ExpandedTracksSetterContext = exports.E
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const studio_shared_1 = require("@remotion/studio-shared");
6
6
  const react_1 = require("react");
7
+ const migrate_expanded_tracks_for_subscription_key_1 = require("../helpers/migrate-expanded-tracks-for-subscription-key");
7
8
  const persist_boolean_map_1 = require("../helpers/persist-boolean-map");
8
9
  const nodePathInfoToExpandedKey = (info) => [
9
10
  (0, studio_shared_1.stringifySequenceExpandedRowKey)(info.sequenceSubscriptionKey),
@@ -23,6 +24,9 @@ exports.ExpandedTracksSetterContext = (0, react_1.createContext)({
23
24
  toggleTrack: () => {
24
25
  throw new Error('ExpandedTracksSetterContext not initialized');
25
26
  },
27
+ migrateExpandedTracksForSubscriptionKey: () => {
28
+ throw new Error('ExpandedTracksSetterContext not initialized');
29
+ },
26
30
  });
27
31
  const ExpandedTracksProvider = ({ children }) => {
28
32
  const [expandedTracks, setExpandedTracks] = (0, react_1.useState)(loadExpandedTracks);
@@ -34,13 +38,26 @@ const ExpandedTracksProvider = ({ children }) => {
34
38
  return next;
35
39
  });
36
40
  }, []);
41
+ const migrateExpandedTracks = (0, react_1.useCallback)((oldKey, newKey) => {
42
+ setExpandedTracks((prev) => {
43
+ const next = (0, migrate_expanded_tracks_for_subscription_key_1.migrateExpandedTracksForSubscriptionKey)(prev, oldKey, newKey);
44
+ if (!next) {
45
+ return prev;
46
+ }
47
+ (0, persist_boolean_map_1.persistBooleanMap)(SESSION_STORAGE_KEY, next);
48
+ return next;
49
+ });
50
+ }, []);
37
51
  const getterValue = (0, react_1.useMemo)(() => ({
38
52
  getIsExpanded: (nodePathInfo) => {
39
53
  var _a;
40
54
  return (_a = expandedTracks[nodePathInfoToExpandedKey(nodePathInfo)]) !== null && _a !== void 0 ? _a : false;
41
55
  },
42
56
  }), [expandedTracks]);
43
- const setterValue = (0, react_1.useMemo)(() => ({ toggleTrack }), [toggleTrack]);
57
+ const setterValue = (0, react_1.useMemo)(() => ({
58
+ toggleTrack,
59
+ migrateExpandedTracksForSubscriptionKey: migrateExpandedTracks,
60
+ }), [toggleTrack, migrateExpandedTracks]);
44
61
  return (jsx_runtime_1.jsx(exports.ExpandedTracksSetterContext.Provider, { value: setterValue, children: jsx_runtime_1.jsx(exports.ExpandedTracksGetterContext.Provider, { value: getterValue, children: children }) }));
45
62
  };
46
63
  exports.ExpandedTracksProvider = ExpandedTracksProvider;
@@ -3,12 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZodColorEditor = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
- const color_math_1 = require("../../../helpers/color-math");
7
- const get_zod_if_possible_1 = require("../../get-zod-if-possible");
6
+ const ColorPicker_1 = require("../../ColorPicker/ColorPicker");
8
7
  const layout_1 = require("../../layout");
9
- const InputDragger_1 = require("../../NewComposition/InputDragger");
10
8
  const RemInput_1 = require("../../NewComposition/RemInput");
11
- const RemInputTypeColor_1 = require("../../NewComposition/RemInputTypeColor");
12
9
  const Fieldset_1 = require("./Fieldset");
13
10
  const SchemaLabel_1 = require("./SchemaLabel");
14
11
  const zod_schema_type_1 = require("./zod-schema-type");
@@ -17,25 +14,13 @@ const fullWidth = {
17
14
  width: '100%',
18
15
  };
19
16
  const ZodColorEditor = ({ jsonPath, value, setValue, schema, onRemove, mayPad }) => {
20
- const z = (0, get_zod_if_possible_1.useZodIfPossible)();
21
- if (!z) {
22
- throw new Error('expected zod');
23
- }
24
- const zodTypes = (0, get_zod_if_possible_1.useZodTypesIfPossible)();
25
- if (!zodTypes) {
26
- throw new Error('expected zod color');
27
- }
28
17
  const localValue = (0, react_1.useMemo)(() => (0, zod_schema_type_1.zodSafeParse)(schema, value), [schema, value]);
29
- const { a, b, g, r } = localValue.success
30
- ? zodTypes.ZodZypesInternals.parseColor(value)
31
- : { a: 1, b: 0, g: 0, r: 0 };
32
- const onChange = (0, react_1.useCallback)((e) => {
33
- const newColor = (0, color_math_1.colorWithNewOpacity)(e.target.value, Math.round(a), zodTypes);
34
- setValue(() => newColor, { shouldSave: false });
35
- }, [a, setValue, zodTypes]);
36
- const onColorBlur = (0, react_1.useCallback)(() => {
37
- setValue(() => value, { shouldSave: true });
38
- }, [setValue, value]);
18
+ const onPickerChange = (0, react_1.useCallback)((next) => {
19
+ setValue(() => next, { shouldSave: false });
20
+ }, [setValue]);
21
+ const onPickerComplete = (0, react_1.useCallback)((next) => {
22
+ setValue(() => next, { shouldSave: true });
23
+ }, [setValue]);
39
24
  const onTextChange = (0, react_1.useCallback)((e) => {
40
25
  const newValue = e.target.value;
41
26
  setValue(() => newValue, { shouldSave: false });
@@ -43,35 +28,11 @@ const ZodColorEditor = ({ jsonPath, value, setValue, schema, onRemove, mayPad })
43
28
  const onTextBlur = (0, react_1.useCallback)(() => {
44
29
  setValue(() => value, { shouldSave: true });
45
30
  }, [setValue, value]);
46
- const rgb = `#${r.toString(16).padStart(2, '0')}${g
47
- .toString(16)
48
- .padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;
49
31
  const status = localValue.success ? 'ok' : 'error';
50
- const colorPicker = (0, react_1.useMemo)(() => {
51
- return {
52
- height: 39,
53
- width: 45,
54
- display: 'inline-block',
55
- };
56
- }, []);
57
- const onOpacityChange = (0, react_1.useCallback)((newValue) => {
58
- const newColor = (0, color_math_1.colorWithNewOpacity)(value, Math.round((Number(newValue) / 100) * 255), zodTypes);
59
- setValue(() => newColor, { shouldSave: true });
60
- }, [setValue, value, zodTypes]);
61
- const onOpacityValueChange = (0, react_1.useCallback)((newValue) => {
62
- const newColor = (0, color_math_1.colorWithNewOpacity)(value, Math.round((Number(newValue) / 100) * 255), zodTypes);
63
- setValue(() => newColor, { shouldSave: false });
64
- }, [setValue, value, zodTypes]);
65
- const onOpacityValueChangeEnd = (0, react_1.useCallback)((newValue) => {
66
- const newColor = (0, color_math_1.colorWithNewOpacity)(value, Math.round((Number(newValue) / 100) * 255), zodTypes);
67
- setValue(() => newColor, { shouldSave: true });
68
- }, [setValue, value, zodTypes]);
69
32
  return (jsx_runtime_1.jsxs(Fieldset_1.Fieldset, { shouldPad: mayPad, children: [
70
33
  jsx_runtime_1.jsx(SchemaLabel_1.SchemaLabel, { handleClick: null, jsonPath: jsonPath, onRemove: onRemove, valid: localValue.success, suffix: null }), jsx_runtime_1.jsxs("div", { style: fullWidth, children: [
71
34
  jsx_runtime_1.jsxs(layout_1.Row, { align: "center", children: [
72
- jsx_runtime_1.jsx("div", { style: colorPicker, children: jsx_runtime_1.jsx(RemInputTypeColor_1.RemInputTypeColor, { type: "color", style: {
73
- height: 39,
74
- }, value: rgb, onChange: onChange, onBlur: onColorBlur, className: "__remotion_color_picker", status: status, name: jsonPath.join('.') }) }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1, block: true }), jsx_runtime_1.jsx(RemInput_1.RemotionInput, { value: value, status: status, placeholder: jsonPath.join('.'), onChange: onTextChange, onBlur: onTextBlur, rightAlign: false }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1 }), jsx_runtime_1.jsx(InputDragger_1.InputDragger, { onTextChange: onOpacityChange, onValueChange: onOpacityValueChange, onValueChangeEnd: onOpacityValueChangeEnd, status: status, value: (a / 255) * 100, min: 0, max: 100, step: 1, formatter: (v) => `${Math.round(Number(v))}%`, rightAlign: false })
35
+ jsx_runtime_1.jsx(ColorPicker_1.ColorPicker, { value: value, status: status, onChange: onPickerChange, onChangeComplete: onPickerComplete, width: 45, height: 39, name: jsonPath.join('.') }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1, block: true }), jsx_runtime_1.jsx(RemInput_1.RemotionInput, { value: value, status: status, placeholder: jsonPath.join('.'), onChange: onTextChange, onBlur: onTextBlur, rightAlign: false })
75
36
  ] }), jsx_runtime_1.jsx(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, zodValidation: localValue })
76
37
  ] })
77
38
  ] }));
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Padder = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
- const TimelineListItem_1 = require("./TimelineListItem");
6
+ const timeline_indent_1 = require("./timeline-indent");
7
7
  const Padder = ({ depth }) => {
8
8
  const style = (0, react_1.useMemo)(() => ({
9
- width: TimelineListItem_1.INDENT * depth,
9
+ width: timeline_indent_1.TIMELINE_INDENT * depth,
10
10
  flexShrink: 0,
11
11
  }), [depth]);
12
12
  return jsx_runtime_1.jsx("div", { style: style });
@@ -3,6 +3,6 @@ import type { EffectDefinition, SequenceSchema } from 'remotion';
3
3
  export declare const SubscribeToNodePaths: FC<{
4
4
  readonly overrideId: string;
5
5
  readonly schema: SequenceSchema;
6
- readonly stack: string;
6
+ readonly getStack: () => string | null;
7
7
  readonly effects: readonly EffectDefinition<unknown>[];
8
8
  }>;
@@ -2,12 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SubscribeToNodePaths = void 0;
4
4
  const react_1 = require("react");
5
- const use_resolved_stack_1 = require("./use-resolved-stack");
5
+ const no_react_1 = require("remotion/no-react");
6
+ const use_resolved_stack_react_to_change_1 = require("./use-resolved-stack-react-to-change");
6
7
  const use_sequence_props_subscription_1 = require("./use-sequence-props-subscription");
7
- const SubscribeToNodePaths = ({ overrideId, schema, stack, effects }) => {
8
- const originalLocation = (0, use_resolved_stack_1.useResolvedStack)(stack);
8
+ const SubscribeToNodePaths = ({ overrideId, schema, getStack, effects }) => {
9
+ const originalLocation = (0, use_resolved_stack_react_to_change_1.useResolveStackAndReactToChange)(getStack);
9
10
  const effectSubscriptions = (0, react_1.useMemo)(() => {
10
- return effects.map((effect) => effect.schema);
11
+ return effects
12
+ .map((effect) => {
13
+ return effect.schema;
14
+ })
15
+ .filter(no_react_1.NoReactInternals.truthy);
11
16
  }, [effects]);
12
17
  (0, use_sequence_props_subscription_1.useSequencePropsSubscription)({
13
18
  overrideId,
@@ -44,9 +44,9 @@ const is_menu_item_1 = require("../Menu/is-menu-item");
44
44
  const SplitterContainer_1 = require("../Splitter/SplitterContainer");
45
45
  const SplitterElement_1 = require("../Splitter/SplitterElement");
46
46
  const SplitterHandle_1 = require("../Splitter/SplitterHandle");
47
- const is_collapsed_1 = require("./is-collapsed");
48
47
  const MaxTimelineTracks_1 = require("./MaxTimelineTracks");
49
48
  const SequencePropsObserver_1 = require("./SequencePropsObserver");
49
+ const should_show_track_in_timeline_1 = require("./should-show-track-in-timeline");
50
50
  const SubscribeToNodePaths_1 = require("./SubscribeToNodePaths");
51
51
  const timeline_refs_1 = require("./timeline-refs");
52
52
  const TimelineDragHandler_1 = require("./TimelineDragHandler");
@@ -88,10 +88,7 @@ const TimelineInner = () => {
88
88
  }, [sequences, videoConfigIsNull, overrideIdToNodePathMappings]);
89
89
  const durationInFrames = (_a = videoConfig === null || videoConfig === void 0 ? void 0 : videoConfig.durationInFrames) !== null && _a !== void 0 ? _a : 0;
90
90
  const filtered = (0, react_1.useMemo)(() => {
91
- return timeline.filter((t) => !(0, is_collapsed_1.isTrackHidden)(t) &&
92
- t.sequence.from <= durationInFrames &&
93
- t.sequence.duration > 0 &&
94
- t.sequence.showInTimeline);
91
+ return timeline.filter((t) => (0, should_show_track_in_timeline_1.shouldShowTrackInTimeline)(t, durationInFrames));
95
92
  }, [durationInFrames, timeline]);
96
93
  const shown = (0, react_1.useMemo)(() => {
97
94
  return filtered.length > MaxTimelineTracks_1.MAX_TIMELINE_TRACKS
@@ -100,10 +97,10 @@ const TimelineInner = () => {
100
97
  }, [filtered]);
101
98
  const hasBeenCut = filtered.length > shown.length;
102
99
  return (jsx_runtime_1.jsxs("div", { ref: timeline_refs_1.timelineVerticalScroll, style: container, className: 'css-reset ' + is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: [sequences.map((sequence) => {
103
- if (!sequence.controls || !previewConnected || !sequence.stack) {
100
+ if (!sequence.controls || !previewConnected || !sequence.getStack()) {
104
101
  return null;
105
102
  }
106
- return (jsx_runtime_1.jsx(SubscribeToNodePaths_1.SubscribeToNodePaths, { overrideId: sequence.controls.overrideId, schema: sequence.controls.schema, stack: sequence.stack, effects: sequence.effects }, sequence.id));
103
+ return (jsx_runtime_1.jsx(SubscribeToNodePaths_1.SubscribeToNodePaths, { overrideId: sequence.controls.overrideId, schema: sequence.controls.schema, getStack: sequence.getStack, effects: sequence.effects }, sequence.id));
107
104
  }), jsx_runtime_1.jsx(SequencePropsObserver_1.SequencePropsObserver, {}), jsx_runtime_1.jsxs(TimelineWidthProvider_1.TimelineWidthProvider, { children: [
108
105
  jsx_runtime_1.jsx(TimelinePinchZoom_1.TimelinePinchZoom, {}), jsx_runtime_1.jsx(TimelineHeightContainer_1.TimelineHeightContainer, { shown: shown, hasBeenCut: hasBeenCut, children: jsx_runtime_1.jsxs(SplitterContainer_1.SplitterContainer, { orientation: "vertical", defaultFlex: 0.2, id: "names-to-timeline", maxFlex: 0.5, minFlex: 0.15, children: [
109
106
  jsx_runtime_1.jsx(SplitterElement_1.SplitterElement, { type: "flexer", sticky: jsx_runtime_1.jsx(TimelineTimeIndicators_1.TimelineTimePlaceholders, {}), children: jsx_runtime_1.jsx(TimelineList_1.TimelineList, { timeline: shown }) }), jsx_runtime_1.jsx(SplitterHandle_1.SplitterHandle, { onCollapse: noop, allowToCollapse: "none" }), jsx_runtime_1.jsx(SplitterElement_1.SplitterElement, { type: "anti-flexer", sticky: null, children: jsx_runtime_1.jsxs(TimelineScrollable_1.TimelineScrollable, { children: [
@@ -3,179 +3,41 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TimelineColorField = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
- const no_react_1 = require("remotion/no-react");
7
- const colors_1 = require("../../helpers/colors");
8
- const eyedropper_1 = require("../../icons/eyedropper");
9
- const z_index_1 = require("../../state/z-index");
10
- const SWATCH_WIDTH = 20;
11
- const SWATCH_HEIGHT = 15;
6
+ const ColorPicker_1 = require("../ColorPicker/ColorPicker");
12
7
  const containerStyle = {
13
8
  display: 'flex',
14
9
  alignItems: 'center',
15
10
  gap: 3,
16
11
  };
17
- const swatchWrapperBase = {
18
- position: 'relative',
19
- width: SWATCH_WIDTH,
20
- height: SWATCH_HEIGHT,
21
- display: 'inline-block',
22
- borderRadius: 3,
23
- overflow: 'hidden',
24
- cursor: 'pointer',
25
- borderStyle: 'solid',
26
- borderWidth: 1,
27
- };
28
- const hiddenInputStyle = {
29
- position: 'absolute',
30
- inset: 0,
31
- width: '100%',
32
- height: '100%',
33
- opacity: 0,
34
- cursor: 'pointer',
35
- border: 'none',
36
- padding: 0,
37
- margin: 0,
38
- };
39
- const swatchFillStyle = {
40
- width: '100%',
41
- height: '100%',
42
- };
43
- const eyedropperButtonBase = {
44
- background: 'transparent',
45
- border: 'none',
46
- padding: 0,
47
- margin: 0,
48
- cursor: 'pointer',
49
- display: 'inline-flex',
50
- alignItems: 'center',
51
- justifyContent: 'center',
52
- width: 20,
53
- height: 20,
54
- color: 'rgba(255, 255, 255, 0.7)',
55
- };
56
- const eyedropperIconStyle = {
57
- width: 16,
58
- height: 16,
59
- };
60
- // Normalizes any color string the user provided (e.g. `red`, `rgb(...)`, `#fff`)
61
- // into a `#rrggbb` string that `<input type="color">` accepts.
62
- const toHex = (value) => {
63
- try {
64
- const argb = no_react_1.NoReactInternals.processColor(value);
65
- const r = (argb >>> 16) & 0xff;
66
- const g = (argb >>> 8) & 0xff;
67
- const b = argb & 0xff;
68
- return `#${r.toString(16).padStart(2, '0')}${g
69
- .toString(16)
70
- .padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;
71
- }
72
- catch (_a) {
73
- return '#000000';
74
- }
75
- };
76
- const hasEyeDropper = () => typeof window !== 'undefined' && 'EyeDropper' in window;
12
+ const SWATCH_WIDTH = 20;
13
+ const SWATCH_HEIGHT = 15;
77
14
  const TimelineColorField = ({ field, effectiveValue, propStatus, onSave, onDragValueChange, onDragEnd, }) => {
78
- const inputRef = (0, react_1.useRef)(null);
79
- const [isHovered, setIsHovered] = (0, react_1.useState)(false);
80
- const [isFocused, setIsFocused] = (0, react_1.useState)(false);
81
- const { tabIndex } = (0, z_index_1.useZIndex)();
82
- const commitTimeoutRef = (0, react_1.useRef)(null);
83
- const pendingCommitRef = (0, react_1.useRef)(null);
84
- // `<input type="color">` doesn't fire an event when dismissed; debounce
85
- // commits and flush any pending commit on unmount so we never lose the
86
- // final value.
87
- (0, react_1.useEffect)(() => {
88
- return () => {
89
- if (commitTimeoutRef.current) {
90
- clearTimeout(commitTimeoutRef.current);
91
- }
92
- if (pendingCommitRef.current) {
93
- pendingCommitRef.current();
94
- }
95
- };
96
- }, []);
15
+ var _a;
97
16
  const currentValue = typeof effectiveValue === 'string'
98
17
  ? effectiveValue
99
18
  : field.fieldSchema.type === 'color'
100
- ? field.fieldSchema.default
19
+ ? ((_a = field.fieldSchema.default) !== null && _a !== void 0 ? _a : '#000')
101
20
  : '';
102
- const hexValue = (0, react_1.useMemo)(() => toHex(currentValue), [currentValue]);
103
- const onColorChange = (0, react_1.useCallback)((e) => {
104
- const newValue = e.target.value;
21
+ const onChange = (0, react_1.useCallback)((next) => {
105
22
  if (!propStatus.canUpdate) {
106
23
  return;
107
24
  }
108
- onDragValueChange(newValue);
109
- if (commitTimeoutRef.current) {
110
- clearTimeout(commitTimeoutRef.current);
111
- }
112
- const commit = () => {
113
- pendingCommitRef.current = null;
114
- if (propStatus.canUpdate && newValue !== propStatus.codeValue) {
115
- onSave(newValue);
116
- }
117
- onDragEnd();
118
- };
119
- pendingCommitRef.current = commit;
120
- commitTimeoutRef.current = setTimeout(() => {
121
- commitTimeoutRef.current = null;
122
- commit();
123
- }, 500);
124
- }, [onSave, onDragValueChange, onDragEnd, propStatus]);
125
- const onPickColor = (0, react_1.useCallback)(() => {
126
- // `EyeDropper` is a Chromium-only API; it's feature-detected at render
127
- // time so this only runs in supported browsers.
128
- const EyeDropperCtor = typeof window !== 'undefined'
129
- ? window.EyeDropper
130
- : undefined;
131
- if (!EyeDropperCtor) {
25
+ onDragValueChange(next);
26
+ }, [onDragValueChange, propStatus.canUpdate]);
27
+ const onChangeComplete = (0, react_1.useCallback)((next) => {
28
+ if (!propStatus.canUpdate) {
132
29
  return;
133
30
  }
134
- const eyeDropper = new EyeDropperCtor();
135
- eyeDropper
136
- .open()
137
- .then((result) => {
138
- if (propStatus.canUpdate && result.sRGBHex !== propStatus.codeValue) {
139
- onSave(result.sRGBHex);
140
- }
141
- })
142
- .catch(() => {
143
- // User aborted or picker failed; safe to ignore.
144
- });
145
- }, [onSave, propStatus]);
146
- const swatchWrapperStyle = (0, react_1.useMemo)(() => {
31
+ if (next !== propStatus.codeValue) {
32
+ onSave(next);
33
+ }
34
+ onDragEnd();
35
+ }, [onSave, onDragEnd, propStatus]);
36
+ const swatchStyle = (0, react_1.useMemo)(() => {
147
37
  return {
148
- ...swatchWrapperBase,
149
- borderColor: isHovered || isFocused
150
- ? colors_1.INPUT_BORDER_COLOR_HOVERED
151
- : colors_1.INPUT_BORDER_COLOR_UNHOVERED,
152
- cursor: propStatus.canUpdate ? 'pointer' : 'not-allowed',
153
38
  marginLeft: 5,
154
39
  };
155
- }, [isFocused, isHovered, propStatus.canUpdate]);
156
- const swatchFill = (0, react_1.useMemo)(() => {
157
- return {
158
- ...swatchFillStyle,
159
- backgroundColor: currentValue || hexValue,
160
- position: 'absolute',
161
- display: 'block',
162
- };
163
- }, [currentValue, hexValue]);
164
- const onMouseEnter = (0, react_1.useCallback)(() => setIsHovered(true), []);
165
- const onMouseLeave = (0, react_1.useCallback)(() => setIsHovered(false), []);
166
- const onFocus = (0, react_1.useCallback)(() => setIsFocused(true), []);
167
- const onBlur = (0, react_1.useCallback)(() => setIsFocused(false), []);
168
- const onSwatchClick = (0, react_1.useCallback)(() => {
169
- var _a;
170
- if (!propStatus.canUpdate) {
171
- return;
172
- }
173
- (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.click();
174
- }, [propStatus.canUpdate]);
175
- const showEyeDropper = hasEyeDropper();
176
- return (jsx_runtime_1.jsxs("span", { style: containerStyle, children: [
177
- jsx_runtime_1.jsxs("span", { style: swatchWrapperStyle, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onClick: onSwatchClick, title: currentValue, children: [
178
- jsx_runtime_1.jsx("span", { style: swatchFill }), jsx_runtime_1.jsx("input", { ref: inputRef, type: "color", value: hexValue, onChange: onColorChange, onFocus: onFocus, onBlur: onBlur, disabled: !propStatus.canUpdate, name: field.key, tabIndex: tabIndex, style: hiddenInputStyle })
179
- ] }), showEyeDropper ? (jsx_runtime_1.jsx("button", { type: "button", onClick: onPickColor, disabled: !propStatus.canUpdate, style: eyedropperButtonBase, tabIndex: tabIndex, title: "Pick color from screen", "aria-label": "Pick color from screen", children: jsx_runtime_1.jsx(eyedropper_1.EyedropperIcon, { style: eyedropperIconStyle, color: "rgba(255, 255, 255, 0.7)" }) })) : null] }));
40
+ }, []);
41
+ return (jsx_runtime_1.jsx("span", { style: containerStyle, children: jsx_runtime_1.jsx(ColorPicker_1.ColorPicker, { value: currentValue, status: "ok", onChange: onChange, onChangeComplete: onChangeComplete, width: SWATCH_WIDTH, height: SWATCH_HEIGHT, disabled: !propStatus.canUpdate, name: field.key, title: currentValue, style: swatchStyle }) }));
180
42
  };
181
43
  exports.TimelineColorField = TimelineColorField;
@@ -5,7 +5,6 @@ import type { EffectSchemaFieldInfo } from '../../helpers/timeline-layout';
5
5
  export declare const TimelineEffectFieldRow: React.FC<{
6
6
  readonly field: EffectSchemaFieldInfo;
7
7
  readonly validatedLocation: CodePosition;
8
- readonly paddingLeft: number;
9
- readonly nestedDepth: number;
8
+ readonly rowDepth: number;
10
9
  readonly nodePath: SequencePropsSubscriptionKey;
11
10
  }>;