@remotion/studio 4.0.500 → 4.0.501
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Studio.js +1 -1
- package/dist/api/delete-static-file.js +8 -3
- package/dist/api/rename-static-file.js +8 -0
- package/dist/api/watch-public-folder.js +2 -1
- package/dist/api/watch-static-file.js +2 -1
- package/dist/api/write-static-file.js +8 -3
- package/dist/components/AssetSelector.js +3 -1
- package/dist/components/AssetSelectorItem.d.ts +2 -1
- package/dist/components/AssetSelectorItem.js +5 -2
- package/dist/components/Canvas.js +6 -1
- package/dist/components/CaptionInspector.d.ts +10 -0
- package/dist/components/CaptionInspector.js +24 -0
- package/dist/components/CaptionTextEditor.d.ts +9 -0
- package/dist/components/CaptionTextEditor.js +132 -0
- package/dist/components/CurrentAsset.js +3 -2
- package/dist/components/EditorContexts.d.ts +0 -1
- package/dist/components/EditorContexts.js +2 -2
- package/dist/components/FpsCounter.js +3 -3
- package/dist/components/FullscreenToggle.js +2 -1
- package/dist/components/GlobalKeybindings.js +2 -0
- package/dist/components/InitialCompositionLoader.d.ts +1 -1
- package/dist/components/InlineAction.js +1 -0
- package/dist/components/InlineCaptionInspector.d.ts +11 -0
- package/dist/components/InlineCaptionInspector.js +108 -0
- package/dist/components/InspectorPanel/CompositionInspector.js +5 -3
- package/dist/components/InspectorPanel/SelectedInspector.d.ts +1 -0
- package/dist/components/InspectorPanel/SelectedInspector.js +2 -2
- package/dist/components/InspectorPanel/SequenceSelectionInspector.d.ts +1 -0
- package/dist/components/InspectorPanel/SequenceSelectionInspector.js +4 -4
- package/dist/components/InspectorPanel/inspector-section-collapse.d.ts +22 -0
- package/dist/components/InspectorPanel/inspector-section-collapse.js +165 -0
- package/dist/components/InspectorPanel/styles.js +7 -1
- package/dist/components/InspectorPanel/use-composition-actions.d.ts +3 -0
- package/dist/components/InspectorPanel/use-composition-actions.js +91 -6
- package/dist/components/InspectorPanel.js +2 -2
- package/dist/components/InspectorSequenceSection.d.ts +2 -1
- package/dist/components/InspectorSequenceSection.js +238 -8
- package/dist/components/MenuToolbar.js +8 -1
- package/dist/components/Modals.js +1 -1
- package/dist/components/QuickSwitcher/ExplorerQuickSwitcherTrigger.js +1 -0
- package/dist/components/QuickSwitcher/QuickSwitcher.d.ts +5 -0
- package/dist/components/QuickSwitcher/QuickSwitcher.js +2 -2
- package/dist/components/QuickSwitcher/QuickSwitcherContent.d.ts +5 -0
- package/dist/components/QuickSwitcher/QuickSwitcherContent.js +26 -8
- package/dist/components/RenderQueue/ClientRenderQueueProcessor.d.ts +0 -1
- package/dist/components/RenderQueue/ClientRenderQueueProcessor.js +3 -14
- package/dist/components/RenderQueue/RenderQueueDownloadItem.js +2 -2
- package/dist/components/SelectedOutlineElement.js +1 -4
- package/dist/components/SelectedOutlineOverlay.js +17 -8
- package/dist/components/ShowOutlinesProvider.js +4 -1
- package/dist/components/Timeline/Timeline.js +19 -5
- package/dist/components/Timeline/TimelineAssetField.js +1 -0
- package/dist/components/Timeline/TimelineExpandedKeyframeRow.js +8 -2
- package/dist/components/Timeline/TimelinePrimitiveFieldValue.d.ts +7 -2
- package/dist/components/Timeline/TimelinePrimitiveFieldValue.js +3 -1
- package/dist/components/Timeline/TimelineRowChrome.d.ts +3 -0
- package/dist/components/Timeline/TimelineRowChrome.js +4 -3
- package/dist/components/Timeline/TimelineSelection.d.ts +4 -2
- package/dist/components/Timeline/TimelineSelection.js +9 -6
- package/dist/components/Timeline/TimelineSequence.js +1 -4
- package/dist/components/Timeline/TimelineSequenceItem.js +4 -5
- package/dist/components/Timeline/TimelineSequencePropItem.js +9 -10
- package/dist/components/Timeline/TimelineTrack.js +4 -2
- package/dist/components/Timeline/border-radius-representation.d.ts +16 -0
- package/dist/components/Timeline/border-radius-representation.js +60 -0
- package/dist/components/Timeline/delete-selected-timeline-item.js +1 -6
- package/dist/components/Timeline/get-sequence-prop-reset-changes.d.ts +10 -0
- package/dist/components/Timeline/get-sequence-prop-reset-changes.js +33 -0
- package/dist/components/Timeline/reset-selected-timeline-props.js +2 -8
- package/dist/components/Timeline/save-sequence-prop.d.ts +12 -1
- package/dist/components/Timeline/save-sequence-prop.js +25 -1
- package/dist/components/Timeline/timeline-field-display-utils.js +1 -0
- package/dist/components/Timeline/use-timeline-asset-drop.js +4 -0
- package/dist/components/UndoRedoButtons.js +15 -6
- package/dist/components/handle-drop.d.ts +3 -2
- package/dist/components/handle-drop.js +2 -1
- package/dist/components/import-assets.d.ts +4 -2
- package/dist/components/import-assets.js +20 -7
- package/dist/components/use-element-overwrite-confirmation.d.ts +2 -0
- package/dist/components/use-element-overwrite-confirmation.js +73 -0
- package/dist/components/use-static-files.js +7 -2
- package/dist/error-overlay/react-overlay/effects/resolve-file-source.js +13 -2
- package/dist/esm/{chunk-dr1y1vm3.js → chunk-n1kj09yv.js} +7634 -6308
- package/dist/esm/index.mjs +24 -8
- package/dist/esm/internals.mjs +7634 -6308
- package/dist/esm/previewEntry.mjs +7646 -6320
- package/dist/esm/renderEntry.mjs +1 -1
- package/dist/helpers/browser-studio-operations.d.ts +3 -0
- package/dist/helpers/browser-studio-operations.js +14 -0
- package/dist/helpers/client-id.d.ts +0 -1
- package/dist/helpers/client-id.js +15 -10
- package/dist/helpers/download-blob.d.ts +1 -0
- package/dist/helpers/download-blob.js +15 -0
- package/dist/helpers/inject-css.js +5 -3
- package/dist/helpers/open-in-editor.js +26 -5
- package/dist/helpers/preview-server-events.js +46 -9
- package/dist/helpers/use-create-composition.js +8 -6
- package/dist/helpers/use-menu-structure.js +29 -0
- package/dist/hot-middleware-client/client.js +3 -3
- package/dist/icons/border-radius.d.ts +4 -0
- package/dist/icons/border-radius.js +8 -0
- package/dist/icons/fullscreen.d.ts +4 -0
- package/dist/icons/fullscreen.js +6 -0
- package/dist/previewEntry.js +1 -1
- package/dist/state/modals.d.ts +4 -0
- package/dist/state/timeline-sequence-hover.d.ts +17 -0
- package/dist/state/timeline-sequence-hover.js +33 -0
- package/package.json +13 -12
|
@@ -4,6 +4,7 @@ exports.resetSelectedTimelineProps = exports.getTimelinePropResetTargets = void
|
|
|
4
4
|
const studio_shared_1 = require("@remotion/studio-shared");
|
|
5
5
|
const remotion_1 = require("remotion");
|
|
6
6
|
const find_track_for_node_path_info_1 = require("./find-track-for-node-path-info");
|
|
7
|
+
const get_sequence_prop_reset_changes_1 = require("./get-sequence-prop-reset-changes");
|
|
7
8
|
const save_effect_prop_1 = require("./save-effect-prop");
|
|
8
9
|
const save_sequence_prop_1 = require("./save-sequence-prop");
|
|
9
10
|
const isPropResetSelection = (selection) => selection.type === 'sequence-prop' ||
|
|
@@ -157,14 +158,7 @@ const resetSelectedTimelineProps = ({ selections, sequences, overrideIdsToNodePa
|
|
|
157
158
|
resetPromises.push((0, save_sequence_prop_1.saveSequenceProps)({
|
|
158
159
|
addedKeyframes: null,
|
|
159
160
|
movedKeyframes: null,
|
|
160
|
-
changes: sequencePropTargets.
|
|
161
|
-
fileName: target.fileName,
|
|
162
|
-
nodePath: target.nodePath,
|
|
163
|
-
fieldKey: target.fieldKey,
|
|
164
|
-
value: target.value,
|
|
165
|
-
defaultValue: target.defaultValue,
|
|
166
|
-
schema: target.schema,
|
|
167
|
-
})),
|
|
161
|
+
changes: sequencePropTargets.flatMap((target) => (0, get_sequence_prop_reset_changes_1.getSequencePropResetChanges)(target)),
|
|
168
162
|
setPropStatuses,
|
|
169
163
|
clientId,
|
|
170
164
|
undoLabel: sequencePropTargets.length > 1
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type SaveSequencePropSourceEdit } from '@remotion/studio-shared';
|
|
1
|
+
import { type CaptionPatch, type SaveSequencePropSourceEdit } from '@remotion/studio-shared';
|
|
2
2
|
import type { CanUpdateSequencePropsResponse, SequencePropsSubscriptionKey, InteractivitySchema } from 'remotion';
|
|
3
3
|
import type { AddSequenceKeyframeChange } from './call-add-keyframe';
|
|
4
4
|
import { type MoveEffectKeyframeChange, type MoveSequenceKeyframeChange } from './call-move-keyframe';
|
|
@@ -24,5 +24,16 @@ type SaveSequencePropsOptions = {
|
|
|
24
24
|
undoLabel: string;
|
|
25
25
|
redoLabel: string;
|
|
26
26
|
};
|
|
27
|
+
export declare const saveInlineCaptionPatches: ({ fileName, nodePath, schema, patches, nextCaptions, setPropStatuses, clientId, undoLabel, redoLabel, }: {
|
|
28
|
+
fileName: string;
|
|
29
|
+
nodePath: SequencePropsSubscriptionKey;
|
|
30
|
+
schema: InteractivitySchema;
|
|
31
|
+
patches: CaptionPatch[];
|
|
32
|
+
nextCaptions: unknown;
|
|
33
|
+
setPropStatuses: SetPropStatuses;
|
|
34
|
+
clientId: string;
|
|
35
|
+
undoLabel: string;
|
|
36
|
+
redoLabel: string;
|
|
37
|
+
}) => Promise<void>;
|
|
27
38
|
export declare const saveSequenceProps: ({ changes, addedKeyframes, movedKeyframes, setPropStatuses, clientId, undoLabel, redoLabel, }: SaveSequencePropsOptions) => Promise<void>;
|
|
28
39
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.saveSequenceProps = void 0;
|
|
3
|
+
exports.saveSequenceProps = exports.saveInlineCaptionPatches = void 0;
|
|
4
4
|
const studio_shared_1 = require("@remotion/studio-shared");
|
|
5
5
|
const call_api_1 = require("../call-api");
|
|
6
6
|
const call_move_keyframe_1 = require("./call-move-keyframe");
|
|
@@ -11,6 +11,30 @@ const serializeSequencePropValue = (value) => {
|
|
|
11
11
|
}
|
|
12
12
|
return { type: 'json', serialized: JSON.stringify(value) };
|
|
13
13
|
};
|
|
14
|
+
const saveInlineCaptionPatches = ({ fileName, nodePath, schema, patches, nextCaptions, setPropStatuses, clientId, undoLabel, redoLabel, }) => {
|
|
15
|
+
return (0, save_prop_queue_1.enqueueSavePropChange)({
|
|
16
|
+
nodePath,
|
|
17
|
+
setPropStatuses,
|
|
18
|
+
applyOptimistic: (previous) => (0, studio_shared_1.optimisticUpdateForPropStatuses)({
|
|
19
|
+
previous,
|
|
20
|
+
fieldKey: 'captions',
|
|
21
|
+
value: nextCaptions,
|
|
22
|
+
defaultValue: null,
|
|
23
|
+
schema,
|
|
24
|
+
}),
|
|
25
|
+
apiCall: () => (0, call_api_1.callApi)('/api/save-sequence-props', {
|
|
26
|
+
edits: [],
|
|
27
|
+
captionPatches: [{ fileName, nodePath, schema, patches }],
|
|
28
|
+
addedKeyframes: null,
|
|
29
|
+
movedKeyframes: null,
|
|
30
|
+
clientId,
|
|
31
|
+
undoLabel,
|
|
32
|
+
redoLabel,
|
|
33
|
+
}),
|
|
34
|
+
errorLabel: 'Could not save captions',
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
exports.saveInlineCaptionPatches = saveInlineCaptionPatches;
|
|
14
38
|
const saveSequenceProps = ({ changes, addedKeyframes, movedKeyframes, setPropStatuses, clientId, undoLabel, redoLabel, }) => {
|
|
15
39
|
const keyframesToAdd = addedKeyframes === null ? [] : addedKeyframes;
|
|
16
40
|
const sequenceKeyframes = movedKeyframes === null ? [] : movedKeyframes.sequenceKeyframes;
|
|
@@ -11,6 +11,7 @@ const effect_drag_and_drop_1 = require("../effect-drag-and-drop");
|
|
|
11
11
|
const handle_drop_1 = require("../handle-drop");
|
|
12
12
|
const NotificationCenter_1 = require("../Notifications/NotificationCenter");
|
|
13
13
|
const SvgImportDialog_1 = require("../SvgImportDialog");
|
|
14
|
+
const use_element_overwrite_confirmation_1 = require("../use-element-overwrite-confirmation");
|
|
14
15
|
const timeline_refs_1 = require("./timeline-refs");
|
|
15
16
|
const timeline_scroll_logic_1 = require("./timeline-scroll-logic");
|
|
16
17
|
const use_resolved_stack_1 = require("./use-resolved-stack");
|
|
@@ -30,6 +31,7 @@ const useTimelineAssetDrop = () => {
|
|
|
30
31
|
const videoConfig = remotion_1.Internals.useUnsafeVideoConfig();
|
|
31
32
|
const timelinePosition = remotion_1.Internals.Timeline.useTimelinePosition();
|
|
32
33
|
const chooseSvgImportMode = (0, SvgImportDialog_1.useSvgImportDialog)();
|
|
34
|
+
const confirmElementOverwrite = (0, use_element_overwrite_confirmation_1.useElementOverwriteConfirmation)();
|
|
33
35
|
const { previewServerState } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
|
|
34
36
|
const [isAddingAsset, setIsAddingAsset] = (0, react_1.useState)(false);
|
|
35
37
|
const [assetDropFrame, setAssetDropFrame] = (0, react_1.useState)(null);
|
|
@@ -120,6 +122,7 @@ const useTimelineAssetDrop = () => {
|
|
|
120
122
|
await (0, handle_drop_1.handleDrop)({
|
|
121
123
|
chooseSvgImportMode,
|
|
122
124
|
compositionFile,
|
|
125
|
+
confirmElementOverwrite,
|
|
123
126
|
compositionId: currentCompositionId,
|
|
124
127
|
destinationDimensions: {
|
|
125
128
|
height: videoConfig.height,
|
|
@@ -142,6 +145,7 @@ const useTimelineAssetDrop = () => {
|
|
|
142
145
|
chooseSvgImportMode,
|
|
143
146
|
compositionComponentInfo === null || compositionComponentInfo === void 0 ? void 0 : compositionComponentInfo.canAddSequence,
|
|
144
147
|
compositionFile,
|
|
148
|
+
confirmElementOverwrite,
|
|
145
149
|
currentCompositionId,
|
|
146
150
|
getDropFrame,
|
|
147
151
|
videoConfig,
|
|
@@ -4,6 +4,7 @@ exports.UndoRedoButtons = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const ShortcutHint_1 = require("../error-overlay/remotion-overlay/ShortcutHint");
|
|
7
|
+
const browser_studio_operations_1 = require("../helpers/browser-studio-operations");
|
|
7
8
|
const client_id_1 = require("../helpers/client-id");
|
|
8
9
|
const is_mac_1 = require("../helpers/is-mac");
|
|
9
10
|
const use_keybinding_1 = require("../helpers/use-keybinding");
|
|
@@ -37,7 +38,11 @@ const UndoRedoButtons = () => {
|
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
40
|
undoInFlight.current = true;
|
|
40
|
-
(0,
|
|
41
|
+
const browserStudioOperations = (0, browser_studio_operations_1.getBrowserStudioOperations)();
|
|
42
|
+
const promise = browserStudioOperations
|
|
43
|
+
? browserStudioOperations.undo()
|
|
44
|
+
: (0, call_api_1.callApi)('/api/undo', {});
|
|
45
|
+
promise
|
|
41
46
|
.catch(() => {
|
|
42
47
|
// Ignore errors
|
|
43
48
|
})
|
|
@@ -50,7 +55,11 @@ const UndoRedoButtons = () => {
|
|
|
50
55
|
return;
|
|
51
56
|
}
|
|
52
57
|
redoInFlight.current = true;
|
|
53
|
-
(0,
|
|
58
|
+
const browserStudioOperations = (0, browser_studio_operations_1.getBrowserStudioOperations)();
|
|
59
|
+
const promise = browserStudioOperations
|
|
60
|
+
? browserStudioOperations.redo()
|
|
61
|
+
: (0, call_api_1.callApi)('/api/redo', {});
|
|
62
|
+
promise
|
|
54
63
|
.catch(() => {
|
|
55
64
|
// Ignore errors
|
|
56
65
|
})
|
|
@@ -121,11 +130,11 @@ const UndoRedoButtons = () => {
|
|
|
121
130
|
? `Redo (${ShortcutHint_1.cmdOrCtrlCharacter}+Shift+Z)`
|
|
122
131
|
: `Redo (${ShortcutHint_1.cmdOrCtrlCharacter}+Y)`;
|
|
123
132
|
const renderUndo = (0, react_1.useCallback)((color) => {
|
|
124
|
-
return
|
|
125
|
-
}, [
|
|
133
|
+
return jsx_runtime_1.jsx(undo_1.UndoIcon, { style: { ...iconStyle, color } });
|
|
134
|
+
}, []);
|
|
126
135
|
const renderRedo = (0, react_1.useCallback)((color) => {
|
|
127
|
-
return
|
|
128
|
-
}, [
|
|
136
|
+
return jsx_runtime_1.jsx(redo_1.RedoIcon, { style: { ...iconStyle, color } });
|
|
137
|
+
}, []);
|
|
129
138
|
const canUndo = undoFile !== null;
|
|
130
139
|
const canRedo = redoFile !== null;
|
|
131
140
|
if (!canUndo && !canRedo) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Dimensions } from '../helpers/is-current-selected-still';
|
|
2
|
-
import { type InsertElementDropPosition } from './import-assets';
|
|
2
|
+
import { type ConfirmElementOverwrite, type InsertElementDropPosition } from './import-assets';
|
|
3
3
|
import type { SvgImportMode } from './SvgImportDialog';
|
|
4
|
-
export declare const handleDrop: ({ chooseSvgImportMode, compositionFile, compositionId, destinationDimensions, dropPosition, event, fps, from, }: {
|
|
4
|
+
export declare const handleDrop: ({ chooseSvgImportMode, compositionFile, confirmElementOverwrite, compositionId, destinationDimensions, dropPosition, event, fps, from, }: {
|
|
5
5
|
chooseSvgImportMode: () => Promise<SvgImportMode | null>;
|
|
6
6
|
compositionFile: string;
|
|
7
|
+
confirmElementOverwrite: ConfirmElementOverwrite;
|
|
7
8
|
compositionId: string;
|
|
8
9
|
destinationDimensions: Dimensions | null;
|
|
9
10
|
dropPosition: InsertElementDropPosition | null;
|
|
@@ -5,7 +5,7 @@ const remote_asset_drag_1 = require("../helpers/remote-asset-drag");
|
|
|
5
5
|
const drop_handler_data_1 = require("./drop-handler-data");
|
|
6
6
|
const element_drag_and_drop_1 = require("./element-drag-and-drop");
|
|
7
7
|
const import_assets_1 = require("./import-assets");
|
|
8
|
-
const handleDrop = async ({ chooseSvgImportMode, compositionFile, compositionId, destinationDimensions, dropPosition, event, fps, from, }) => {
|
|
8
|
+
const handleDrop = async ({ chooseSvgImportMode, compositionFile, confirmElementOverwrite, compositionId, destinationDimensions, dropPosition, event, fps, from, }) => {
|
|
9
9
|
var _a;
|
|
10
10
|
var _b;
|
|
11
11
|
if ((0, drop_handler_data_1.isFileDragEvent)(event)) {
|
|
@@ -80,6 +80,7 @@ const handleDrop = async ({ chooseSvgImportMode, compositionFile, compositionId,
|
|
|
80
80
|
await (0, import_assets_1.insertElement)({
|
|
81
81
|
compositionFile,
|
|
82
82
|
compositionId,
|
|
83
|
+
confirmOverwrite: confirmElementOverwrite,
|
|
83
84
|
dropPosition,
|
|
84
85
|
element: element.element,
|
|
85
86
|
from,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type CompositionDragData, type ComponentProp } from '@remotion/drag-and-drop';
|
|
2
|
-
import { type FileType, type InsertableCompositionElementPosition } from '@remotion/studio-shared';
|
|
2
|
+
import { type FileType, type InsertElementFileConflict, type InsertableCompositionElementPosition } from '@remotion/studio-shared';
|
|
3
3
|
import type { Dimensions } from '../helpers/is-current-selected-still';
|
|
4
4
|
export type InsertElementDropPosition = {
|
|
5
5
|
readonly centerX: number;
|
|
6
6
|
readonly centerY: number;
|
|
7
7
|
};
|
|
8
|
+
export type ConfirmElementOverwrite = (conflict: InsertElementFileConflict) => Promise<boolean>;
|
|
8
9
|
export declare const getAssetElement: ({ fileType, src, }: {
|
|
9
10
|
fileType: FileType;
|
|
10
11
|
src: string;
|
|
@@ -144,9 +145,10 @@ export declare const insertComposition: ({ composition, compositionFile, composi
|
|
|
144
145
|
dropPosition: InsertElementDropPosition | null;
|
|
145
146
|
from: number | null;
|
|
146
147
|
}) => Promise<void>;
|
|
147
|
-
export declare const insertElement: ({ compositionFile, compositionId, dropPosition, element, from, }: {
|
|
148
|
+
export declare const insertElement: ({ compositionFile, compositionId, confirmOverwrite, dropPosition, element, from, }: {
|
|
148
149
|
compositionFile: string;
|
|
149
150
|
compositionId: string;
|
|
151
|
+
confirmOverwrite: ConfirmElementOverwrite;
|
|
150
152
|
dropPosition: InsertElementDropPosition | null;
|
|
151
153
|
element: {
|
|
152
154
|
dependencies: string[];
|
|
@@ -872,21 +872,34 @@ const insertComposition = async ({ composition, compositionFile, compositionId,
|
|
|
872
872
|
}
|
|
873
873
|
};
|
|
874
874
|
exports.insertComposition = insertComposition;
|
|
875
|
-
const insertElement = async ({ compositionFile, compositionId, dropPosition, element, from, }) => {
|
|
875
|
+
const insertElement = async ({ compositionFile, compositionId, confirmOverwrite, dropPosition, element, from, }) => {
|
|
876
876
|
try {
|
|
877
877
|
await (0, install_required_package_1.installRequiredPackages)(element.dependencies);
|
|
878
|
-
const
|
|
878
|
+
const position = (0, exports.getElementPositionForDrop)({
|
|
879
|
+
dimensions: element.dimensions,
|
|
880
|
+
dropPosition,
|
|
881
|
+
});
|
|
882
|
+
const callInsertElementApi = (overwriteExisting) => (0, call_api_1.callApi)('/api/insert-element', {
|
|
879
883
|
compositionFile,
|
|
880
884
|
compositionId,
|
|
881
885
|
element,
|
|
882
886
|
from,
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
dropPosition,
|
|
886
|
-
}),
|
|
887
|
+
overwriteExisting,
|
|
888
|
+
position,
|
|
887
889
|
});
|
|
890
|
+
let response = await callInsertElementApi(false);
|
|
891
|
+
if (!response.success && response.type === 'file-conflict') {
|
|
892
|
+
const shouldOverwrite = await confirmOverwrite(response.conflict);
|
|
893
|
+
if (!shouldOverwrite) {
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
response = await callInsertElementApi(true);
|
|
897
|
+
}
|
|
888
898
|
if (!response.success) {
|
|
889
|
-
|
|
899
|
+
const reason = response.type === 'error'
|
|
900
|
+
? response.reason
|
|
901
|
+
: `Element file still conflicts: ${response.conflict.filePath}`;
|
|
902
|
+
(0, NotificationCenter_1.showNotification)(`Could not add Element: ${reason}`, 4000);
|
|
890
903
|
return;
|
|
891
904
|
}
|
|
892
905
|
(0, NotificationCenter_1.showNotification)(`Added ${element.displayName} to source file`, 2000);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useElementOverwriteConfirmation = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const ConfirmationDialog_1 = require("./ConfirmationDialog");
|
|
7
|
+
const filePathStyle = {
|
|
8
|
+
color: 'inherit',
|
|
9
|
+
fontFamily: 'monospace',
|
|
10
|
+
fontSize: 13,
|
|
11
|
+
lineHeight: 1.4,
|
|
12
|
+
};
|
|
13
|
+
const warningStyle = {
|
|
14
|
+
color: 'inherit',
|
|
15
|
+
fontFamily: 'sans-serif',
|
|
16
|
+
fontSize: 14,
|
|
17
|
+
lineHeight: 1.4,
|
|
18
|
+
marginTop: 12,
|
|
19
|
+
};
|
|
20
|
+
const sourceDetailsStyle = {
|
|
21
|
+
color: 'inherit',
|
|
22
|
+
fontFamily: 'sans-serif',
|
|
23
|
+
fontSize: 13,
|
|
24
|
+
lineHeight: 1.4,
|
|
25
|
+
marginTop: 12,
|
|
26
|
+
};
|
|
27
|
+
const sourceSummaryStyle = {
|
|
28
|
+
color: 'inherit',
|
|
29
|
+
cursor: 'pointer',
|
|
30
|
+
fontFamily: 'sans-serif',
|
|
31
|
+
fontSize: 13,
|
|
32
|
+
fontWeight: 500,
|
|
33
|
+
lineHeight: 1.4,
|
|
34
|
+
};
|
|
35
|
+
const sourceCodeBlockStyle = {
|
|
36
|
+
backgroundColor: 'rgba(255, 255, 255, 0.06)',
|
|
37
|
+
borderRadius: 6,
|
|
38
|
+
color: 'inherit',
|
|
39
|
+
fontFamily: 'monospace',
|
|
40
|
+
fontSize: 12,
|
|
41
|
+
lineHeight: 1.5,
|
|
42
|
+
marginBottom: 0,
|
|
43
|
+
marginTop: 8,
|
|
44
|
+
maxHeight: 200,
|
|
45
|
+
overflow: 'auto',
|
|
46
|
+
padding: 12,
|
|
47
|
+
whiteSpace: 'pre',
|
|
48
|
+
};
|
|
49
|
+
const sourceCodeStyle = {
|
|
50
|
+
color: 'inherit',
|
|
51
|
+
fontFamily: 'monospace',
|
|
52
|
+
fontSize: 12,
|
|
53
|
+
lineHeight: 1.5,
|
|
54
|
+
};
|
|
55
|
+
const useElementOverwriteConfirmation = () => {
|
|
56
|
+
const confirm = (0, ConfirmationDialog_1.useConfirmationDialog)();
|
|
57
|
+
return (0, react_1.useCallback)((conflict) => {
|
|
58
|
+
return confirm({
|
|
59
|
+
title: 'Overwrite Element file?',
|
|
60
|
+
message: (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: ["The Element file", ' ', jsx_runtime_1.jsx("code", { style: filePathStyle, children: conflict.filePath }),
|
|
61
|
+
" already exists with different contents.",
|
|
62
|
+
jsx_runtime_1.jsx("div", { style: warningStyle, children: "Overwriting will replace local changes in this file. The composition will only be updated if you choose Overwrite." }), jsx_runtime_1.jsxs("details", { style: sourceDetailsStyle, open: true, children: [
|
|
63
|
+
jsx_runtime_1.jsx("summary", { style: sourceSummaryStyle, children: "Existing source" }), jsx_runtime_1.jsx("pre", { style: sourceCodeBlockStyle, children: jsx_runtime_1.jsx("code", { style: sourceCodeStyle, children: conflict.existingSource }) })
|
|
64
|
+
] }), jsx_runtime_1.jsxs("details", { style: sourceDetailsStyle, children: [
|
|
65
|
+
jsx_runtime_1.jsx("summary", { style: sourceSummaryStyle, children: "Incoming source" }), jsx_runtime_1.jsx("pre", { style: sourceCodeBlockStyle, children: jsx_runtime_1.jsx("code", { style: sourceCodeStyle, children: conflict.incomingSource }) })
|
|
66
|
+
] })
|
|
67
|
+
] })),
|
|
68
|
+
confirmLabel: 'Overwrite',
|
|
69
|
+
cancelLabel: 'Cancel',
|
|
70
|
+
});
|
|
71
|
+
}, [confirm]);
|
|
72
|
+
};
|
|
73
|
+
exports.useElementOverwriteConfirmation = useElementOverwriteConfirmation;
|
|
@@ -38,22 +38,27 @@ const react_1 = __importStar(require("react"));
|
|
|
38
38
|
const remotion_1 = require("remotion");
|
|
39
39
|
const get_static_files_1 = require("../api/get-static-files");
|
|
40
40
|
const watch_public_folder_1 = require("../api/watch-public-folder");
|
|
41
|
+
const browser_studio_operations_1 = require("../helpers/browser-studio-operations");
|
|
42
|
+
const client_id_1 = require("../helpers/client-id");
|
|
41
43
|
const StaticFilesContext = (0, react_1.createContext)([]);
|
|
42
44
|
const StaticFilesProvider = ({ children }) => {
|
|
43
45
|
const [files, setFiles] = (0, react_1.useState)(() => (0, get_static_files_1.getStaticFiles)());
|
|
44
46
|
const env = (0, remotion_1.useRemotionEnvironment)();
|
|
47
|
+
const { previewServerState } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
|
|
48
|
+
const browserStudioCanWatch = previewServerState.type === 'connected' &&
|
|
49
|
+
(0, browser_studio_operations_1.getBrowserStudioOperations)() !== null;
|
|
45
50
|
(0, react_1.useEffect)(() => {
|
|
46
51
|
if (!env.isStudio) {
|
|
47
52
|
return;
|
|
48
53
|
}
|
|
49
|
-
if (env.isReadOnlyStudio) {
|
|
54
|
+
if (env.isReadOnlyStudio && !browserStudioCanWatch) {
|
|
50
55
|
return;
|
|
51
56
|
}
|
|
52
57
|
const { cancel } = (0, watch_public_folder_1.watchPublicFolder)((newFiles) => {
|
|
53
58
|
setFiles(newFiles);
|
|
54
59
|
});
|
|
55
60
|
return cancel;
|
|
56
|
-
}, [env.isStudio, env.isReadOnlyStudio]);
|
|
61
|
+
}, [browserStudioCanWatch, env.isStudio, env.isReadOnlyStudio]);
|
|
57
62
|
return react_1.default.createElement(StaticFilesContext.Provider, { value: files }, children);
|
|
58
63
|
};
|
|
59
64
|
exports.StaticFilesProvider = StaticFilesProvider;
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveFileSource = void 0;
|
|
4
|
+
const browser_studio_operations_1 = require("../../../helpers/browser-studio-operations");
|
|
4
5
|
const resolveFileSource = async (location, contextLines) => {
|
|
5
|
-
const
|
|
6
|
-
|
|
6
|
+
const browserStudioOperations = (0, browser_studio_operations_1.getBrowserStudioOperations)();
|
|
7
|
+
let text;
|
|
8
|
+
if (browserStudioOperations) {
|
|
9
|
+
const browserSource = await browserStudioOperations.getFileSource(location.fileName);
|
|
10
|
+
if (browserSource === null) {
|
|
11
|
+
throw new Error(`Could not find ${location.fileName}`);
|
|
12
|
+
}
|
|
13
|
+
text = browserSource;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
text = await (await fetch(`/api/file-source?f=${encodeURIComponent(location.fileName)}`)).text();
|
|
17
|
+
}
|
|
7
18
|
const lines = text
|
|
8
19
|
.split('\n')
|
|
9
20
|
.map((l, i) => {
|