@remotion/studio-server 4.0.484 → 4.0.485
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/codemods/recast-mods.js +37 -0
- package/dist/codemods/split-jsx-sequence.d.ts +14 -0
- package/dist/codemods/split-jsx-sequence.js +345 -0
- package/dist/codemods/update-sequence-props/update-sequence-props.d.ts +1 -1
- package/dist/codemods/update-sequence-props/update-sequence-props.js +62 -7
- package/dist/preview-server/api-routes.js +2 -0
- package/dist/preview-server/routes/add-effect-keyframe.js +2 -2
- package/dist/preview-server/routes/add-effect.js +56 -53
- package/dist/preview-server/routes/add-keyframes.js +2 -2
- package/dist/preview-server/routes/add-sequence-keyframe.js +2 -2
- package/dist/preview-server/routes/apply-codemod.js +104 -101
- package/dist/preview-server/routes/apply-visual-control-change.js +83 -80
- package/dist/preview-server/routes/can-update-sequence-props.d.ts +13 -1
- package/dist/preview-server/routes/can-update-sequence-props.js +101 -7
- package/dist/preview-server/routes/delete-effect.js +83 -80
- package/dist/preview-server/routes/delete-jsx-node.js +74 -71
- package/dist/preview-server/routes/delete-keyframes.js +2 -2
- package/dist/preview-server/routes/duplicate-effect.js +77 -74
- package/dist/preview-server/routes/duplicate-jsx-node.js +53 -50
- package/dist/preview-server/routes/insert-element.js +2 -2
- package/dist/preview-server/routes/insert-jsx-element.js +2 -2
- package/dist/preview-server/routes/move-keyframes.js +2 -2
- package/dist/preview-server/routes/paste-effects.js +59 -56
- package/dist/preview-server/routes/reorder-effect.js +55 -52
- package/dist/preview-server/routes/reorder-sequence.js +55 -52
- package/dist/preview-server/routes/save-effect-props.js +2 -2
- package/dist/preview-server/routes/save-sequence-props.js +2 -2
- package/dist/preview-server/routes/source-file-write-queue.d.ts +1 -0
- package/dist/preview-server/routes/source-file-write-queue.js +11 -0
- package/dist/preview-server/routes/split-jsx-sequence.d.ts +3 -0
- package/dist/preview-server/routes/split-jsx-sequence.js +66 -0
- package/dist/preview-server/routes/update-default-props.js +58 -55
- package/dist/preview-server/routes/update-effect-keyframe-settings.js +2 -2
- package/dist/preview-server/routes/update-sequence-keyframe-settings.js +2 -2
- package/dist/preview-server/undo-stack.d.ts +3 -1
- package/package.json +6 -6
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.computeSequencePropsStatusFromFilenameByLine = exports.computeSequencePropsStatus = exports.computeSequencePropsStatusFromContent = exports.lineColumnToNodePath = exports.findNodePathForJsxElement = exports.findJsxElementAtNodePath = exports.getComputedStatus = exports.extractStaticValue = exports.isStaticValue = void 0;
|
|
36
|
+
exports.computeSequencePropsStatusFromFilenameByLine = exports.computeSequencePropsStatus = exports.computeSequencePropsStatusFromContent = exports.lineColumnToNodePath = exports.findNodePathForJsxElement = exports.getStaticJsxTextContent = exports.hasJsxChildrenAttribute = exports.getStaticJsxChildrenAttribute = exports.findJsxElementNodeAtNodePath = exports.findJsxElementAtNodePath = exports.findJsxElementPathAtNodePath = exports.getComputedStatus = exports.extractStaticValue = exports.isStaticValue = void 0;
|
|
37
37
|
const node_fs_1 = require("node:fs");
|
|
38
38
|
const renderer_1 = require("@remotion/renderer");
|
|
39
39
|
const studio_shared_1 = require("@remotion/studio-shared");
|
|
@@ -545,17 +545,88 @@ recastPath, ast) => {
|
|
|
545
545
|
}
|
|
546
546
|
return (0, import_agnostic_node_path_1.toImportAgnosticNodePath)({ ast, nodePath: segments });
|
|
547
547
|
};
|
|
548
|
-
const
|
|
548
|
+
const findJsxElementPathAtNodePath = (ast, nodePath) => {
|
|
549
549
|
const current = (0, get_ast_node_path_1.getAstNodePath)(ast, nodePath);
|
|
550
550
|
if (!current) {
|
|
551
551
|
return null;
|
|
552
552
|
}
|
|
553
553
|
if (recast.types.namedTypes.JSXOpeningElement.check(current.value)) {
|
|
554
|
-
return current
|
|
554
|
+
return current;
|
|
555
555
|
}
|
|
556
556
|
return null;
|
|
557
557
|
};
|
|
558
|
+
exports.findJsxElementPathAtNodePath = findJsxElementPathAtNodePath;
|
|
559
|
+
const findJsxElementAtNodePath = (ast, nodePath) => {
|
|
560
|
+
const current = (0, exports.findJsxElementPathAtNodePath)(ast, nodePath);
|
|
561
|
+
return current ? current.value : null;
|
|
562
|
+
};
|
|
558
563
|
exports.findJsxElementAtNodePath = findJsxElementAtNodePath;
|
|
564
|
+
const findJsxElementNodeAtNodePath = (ast, nodePath) => {
|
|
565
|
+
var _a;
|
|
566
|
+
const current = (0, exports.findJsxElementPathAtNodePath)(ast, nodePath);
|
|
567
|
+
if (!current) {
|
|
568
|
+
return null;
|
|
569
|
+
}
|
|
570
|
+
if (recast.types.namedTypes.JSXElement.check((_a = current.parentPath) === null || _a === void 0 ? void 0 : _a.value)) {
|
|
571
|
+
return current.parentPath.value;
|
|
572
|
+
}
|
|
573
|
+
return null;
|
|
574
|
+
};
|
|
575
|
+
exports.findJsxElementNodeAtNodePath = findJsxElementNodeAtNodePath;
|
|
576
|
+
const findJsxChildrenAttribute = (jsxElement) => {
|
|
577
|
+
const childrenAttr = jsxElement.attributes.find((attr) => {
|
|
578
|
+
return (attr.type === 'JSXAttribute' &&
|
|
579
|
+
attr.name.type === 'JSXIdentifier' &&
|
|
580
|
+
attr.name.name === 'children');
|
|
581
|
+
});
|
|
582
|
+
return childrenAttr && childrenAttr.type === 'JSXAttribute'
|
|
583
|
+
? childrenAttr
|
|
584
|
+
: null;
|
|
585
|
+
};
|
|
586
|
+
const getStaticJsxChildrenAttribute = (jsxElement) => {
|
|
587
|
+
const childrenAttr = findJsxChildrenAttribute(jsxElement);
|
|
588
|
+
if (!(childrenAttr === null || childrenAttr === void 0 ? void 0 : childrenAttr.value)) {
|
|
589
|
+
return null;
|
|
590
|
+
}
|
|
591
|
+
if (childrenAttr.value.type === 'StringLiteral') {
|
|
592
|
+
return { kind: 'jsx-text', value: childrenAttr.value.value };
|
|
593
|
+
}
|
|
594
|
+
if (childrenAttr.value.type === 'JSXExpressionContainer' &&
|
|
595
|
+
childrenAttr.value.expression.type === 'StringLiteral') {
|
|
596
|
+
return {
|
|
597
|
+
kind: 'string-expression',
|
|
598
|
+
value: childrenAttr.value.expression.value,
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
return null;
|
|
602
|
+
};
|
|
603
|
+
exports.getStaticJsxChildrenAttribute = getStaticJsxChildrenAttribute;
|
|
604
|
+
const hasJsxChildrenAttribute = (jsxElement) => findJsxChildrenAttribute(jsxElement) !== null;
|
|
605
|
+
exports.hasJsxChildrenAttribute = hasJsxChildrenAttribute;
|
|
606
|
+
const getStaticJsxTextContent = (jsxElement) => {
|
|
607
|
+
const meaningfulChildren = jsxElement.children.filter((candidate) => {
|
|
608
|
+
return !(candidate.type === 'JSXText' && candidate.value.trim() === '');
|
|
609
|
+
});
|
|
610
|
+
if (meaningfulChildren.length === 0) {
|
|
611
|
+
return { kind: 'jsx-text', value: '' };
|
|
612
|
+
}
|
|
613
|
+
if (meaningfulChildren.length !== 1) {
|
|
614
|
+
return null;
|
|
615
|
+
}
|
|
616
|
+
const child = meaningfulChildren[0];
|
|
617
|
+
if (child.type === 'JSXText') {
|
|
618
|
+
return {
|
|
619
|
+
kind: 'jsx-text',
|
|
620
|
+
value: child.value.includes('\n') ? child.value.trim() : child.value,
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
if (child.type === 'JSXExpressionContainer' &&
|
|
624
|
+
child.expression.type === 'StringLiteral') {
|
|
625
|
+
return { kind: 'string-expression', value: child.expression.value };
|
|
626
|
+
}
|
|
627
|
+
return null;
|
|
628
|
+
};
|
|
629
|
+
exports.getStaticJsxTextContent = getStaticJsxTextContent;
|
|
559
630
|
const findNodePathForJsxElement = (ast, target) => {
|
|
560
631
|
let foundPath = null;
|
|
561
632
|
recast.types.visit(ast, {
|
|
@@ -642,10 +713,26 @@ const computeEffectsForJsx = ({ ast, jsxElement, effects, }) => {
|
|
|
642
713
|
keys: effect,
|
|
643
714
|
}));
|
|
644
715
|
};
|
|
645
|
-
const computeSequenceOnlyPropsRecord = ({ jsxElement, ast, keys, }) => {
|
|
716
|
+
const computeSequenceOnlyPropsRecord = ({ jsxElement, jsxElementNode, ast, keys, }) => {
|
|
646
717
|
const allProps = getPropsStatus(jsxElement, ast);
|
|
647
718
|
const filteredProps = {};
|
|
648
719
|
for (const key of keys) {
|
|
720
|
+
if (key === 'children') {
|
|
721
|
+
const staticChildrenAttribute = (0, exports.getStaticJsxChildrenAttribute)(jsxElement);
|
|
722
|
+
if (staticChildrenAttribute) {
|
|
723
|
+
filteredProps[key] = staticStatus(staticChildrenAttribute.value);
|
|
724
|
+
continue;
|
|
725
|
+
}
|
|
726
|
+
if ((0, exports.hasJsxChildrenAttribute)(jsxElement)) {
|
|
727
|
+
filteredProps[key] = computedStatus();
|
|
728
|
+
continue;
|
|
729
|
+
}
|
|
730
|
+
const staticTextContent = (0, exports.getStaticJsxTextContent)(jsxElementNode);
|
|
731
|
+
filteredProps[key] = staticTextContent
|
|
732
|
+
? staticStatus(staticTextContent.value)
|
|
733
|
+
: computedStatus();
|
|
734
|
+
continue;
|
|
735
|
+
}
|
|
649
736
|
const dotIndex = key.indexOf('.');
|
|
650
737
|
if (dotIndex !== -1) {
|
|
651
738
|
filteredProps[key] = getNestedPropStatus(jsxElement, ast, key.slice(0, dotIndex), key.slice(dotIndex + 1));
|
|
@@ -660,9 +747,11 @@ const computeSequenceOnlyPropsRecord = ({ jsxElement, ast, keys, }) => {
|
|
|
660
747
|
return filteredProps;
|
|
661
748
|
};
|
|
662
749
|
const computeSequencePropsStatusFromContent = ({ fileContents, nodePath, componentIdentity, keys, effects, }) => {
|
|
750
|
+
var _a;
|
|
663
751
|
const ast = (0, parse_ast_1.parseAst)(fileContents);
|
|
664
|
-
const
|
|
665
|
-
|
|
752
|
+
const jsxElementNode = (0, exports.findJsxElementNodeAtNodePath)(ast, nodePath);
|
|
753
|
+
const jsxElement = (_a = jsxElementNode === null || jsxElementNode === void 0 ? void 0 : jsxElementNode.openingElement) !== null && _a !== void 0 ? _a : null;
|
|
754
|
+
if (!jsxElement || !jsxElementNode) {
|
|
666
755
|
throw new jsx_element_not_found_at_location_error_1.JsxElementNotFoundAtLocationError();
|
|
667
756
|
}
|
|
668
757
|
if (!(0, jsx_component_identity_1.jsxComponentIdentitiesMatch)({
|
|
@@ -671,7 +760,12 @@ const computeSequencePropsStatusFromContent = ({ fileContents, nodePath, compone
|
|
|
671
760
|
})) {
|
|
672
761
|
throw new jsx_component_identity_1.JsxElementIdentityMismatchError();
|
|
673
762
|
}
|
|
674
|
-
const filteredProps = computeSequenceOnlyPropsRecord({
|
|
763
|
+
const filteredProps = computeSequenceOnlyPropsRecord({
|
|
764
|
+
jsxElement,
|
|
765
|
+
jsxElementNode,
|
|
766
|
+
ast,
|
|
767
|
+
keys,
|
|
768
|
+
});
|
|
675
769
|
const effectsStatuses = computeEffectsForJsx({ ast, jsxElement, effects });
|
|
676
770
|
return {
|
|
677
771
|
canUpdate: true,
|
|
@@ -10,95 +10,98 @@ const format_log_file_location_1 = require("../format-log-file-location");
|
|
|
10
10
|
const undo_stack_1 = require("../undo-stack");
|
|
11
11
|
const formatting_1 = require("./log-updates/formatting");
|
|
12
12
|
const log_update_1 = require("./log-updates/log-update");
|
|
13
|
+
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
13
14
|
const getDeletedEffectDescription = (effectLabels) => {
|
|
14
15
|
if (effectLabels.length === 1) {
|
|
15
16
|
return effectLabels[0];
|
|
16
17
|
}
|
|
17
18
|
return `${effectLabels.length} effects`;
|
|
18
19
|
};
|
|
19
|
-
const deleteEffectHandler =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
const deleteEffectHandler = ({ input: effects, remotionRoot, logLevel }) => {
|
|
21
|
+
return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
|
|
22
|
+
var _a;
|
|
23
|
+
try {
|
|
24
|
+
if (effects.length === 0) {
|
|
25
|
+
throw new Error('No effects were specified for deletion');
|
|
26
|
+
}
|
|
27
|
+
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[delete-effect] Received request to delete ${effects.length} effect target${effects.length === 1 ? '' : 's'}`);
|
|
28
|
+
const itemsByFileName = new Map();
|
|
29
|
+
for (const item of effects) {
|
|
30
|
+
const fileItems = (_a = itemsByFileName.get(item.fileName)) !== null && _a !== void 0 ? _a : [];
|
|
31
|
+
fileItems.push(item);
|
|
32
|
+
itemsByFileName.set(item.fileName, fileItems);
|
|
33
|
+
}
|
|
34
|
+
const updates = await Promise.all([...itemsByFileName.entries()].map(async ([fileName, fileItems]) => {
|
|
35
|
+
const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
36
|
+
remotionRoot,
|
|
37
|
+
fileName,
|
|
38
|
+
action: 'modify',
|
|
39
|
+
});
|
|
40
|
+
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
41
|
+
const { output, formatted, effectLabels, logLines } = await (0, delete_effect_1.deleteEffects)({
|
|
42
|
+
input: fileContents,
|
|
43
|
+
effects: fileItems.map((item) => item.type === 'single-effect'
|
|
44
|
+
? {
|
|
45
|
+
type: 'single-effect',
|
|
46
|
+
sequenceNodePath: item.sequenceNodePath.nodePath,
|
|
47
|
+
effectIndex: item.effectIndex,
|
|
48
|
+
}
|
|
49
|
+
: {
|
|
50
|
+
type: 'all-effects',
|
|
51
|
+
sequenceNodePath: item.sequenceNodePath.nodePath,
|
|
52
|
+
}),
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
absolutePath,
|
|
56
|
+
fileRelativeToRoot,
|
|
57
|
+
fileContents,
|
|
58
|
+
output,
|
|
59
|
+
formatted,
|
|
60
|
+
effectLabels,
|
|
61
|
+
logLine: Math.min(...logLines),
|
|
62
|
+
};
|
|
63
|
+
}));
|
|
64
|
+
for (const update of updates) {
|
|
65
|
+
const deletedEffectDescription = getDeletedEffectDescription(update.effectLabels);
|
|
66
|
+
(0, undo_stack_1.pushToUndoStack)({
|
|
67
|
+
filePath: update.absolutePath,
|
|
68
|
+
oldContents: update.fileContents,
|
|
69
|
+
newContents: null,
|
|
70
|
+
logLevel,
|
|
71
|
+
remotionRoot,
|
|
72
|
+
logLine: update.logLine,
|
|
73
|
+
description: {
|
|
74
|
+
undoMessage: `↩️ Deletion of ${deletedEffectDescription}`,
|
|
75
|
+
redoMessage: `↪️ Deletion of ${deletedEffectDescription}`,
|
|
76
|
+
},
|
|
77
|
+
entryType: 'delete-effect',
|
|
78
|
+
suppressHmrOnFileRestore: false,
|
|
79
|
+
});
|
|
80
|
+
(0, undo_stack_1.suppressUndoStackInvalidation)(update.absolutePath);
|
|
81
|
+
(0, file_watcher_1.writeFileAndNotifyFileWatchers)(update.absolutePath, update.output, undefined);
|
|
82
|
+
const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
|
|
83
|
+
remotionRoot,
|
|
84
|
+
absolutePath: update.absolutePath,
|
|
85
|
+
line: update.logLine,
|
|
86
|
+
});
|
|
87
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} ${(0, formatting_1.strikeThroughOrRemovedPrefix)(deletedEffectDescription)}`);
|
|
88
|
+
if (!update.formatted) {
|
|
89
|
+
(0, log_update_1.warnAboutPrettierOnce)(logLevel);
|
|
90
|
+
}
|
|
91
|
+
renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[delete-effect] Wrote ${update.fileRelativeToRoot}${update.formatted ? ' (formatted)' : ''}`);
|
|
92
|
+
}
|
|
93
|
+
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
94
|
+
return {
|
|
95
|
+
success: true,
|
|
96
|
+
};
|
|
31
97
|
}
|
|
32
|
-
|
|
33
|
-
const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
34
|
-
remotionRoot,
|
|
35
|
-
fileName,
|
|
36
|
-
action: 'modify',
|
|
37
|
-
});
|
|
38
|
-
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
39
|
-
const { output, formatted, effectLabels, logLines } = await (0, delete_effect_1.deleteEffects)({
|
|
40
|
-
input: fileContents,
|
|
41
|
-
effects: fileItems.map((item) => item.type === 'single-effect'
|
|
42
|
-
? {
|
|
43
|
-
type: 'single-effect',
|
|
44
|
-
sequenceNodePath: item.sequenceNodePath.nodePath,
|
|
45
|
-
effectIndex: item.effectIndex,
|
|
46
|
-
}
|
|
47
|
-
: {
|
|
48
|
-
type: 'all-effects',
|
|
49
|
-
sequenceNodePath: item.sequenceNodePath.nodePath,
|
|
50
|
-
}),
|
|
51
|
-
});
|
|
98
|
+
catch (err) {
|
|
52
99
|
return {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
output,
|
|
57
|
-
formatted,
|
|
58
|
-
effectLabels,
|
|
59
|
-
logLine: Math.min(...logLines),
|
|
100
|
+
success: false,
|
|
101
|
+
reason: err.message,
|
|
102
|
+
stack: err.stack,
|
|
60
103
|
};
|
|
61
|
-
}));
|
|
62
|
-
for (const update of updates) {
|
|
63
|
-
const deletedEffectDescription = getDeletedEffectDescription(update.effectLabels);
|
|
64
|
-
(0, undo_stack_1.pushToUndoStack)({
|
|
65
|
-
filePath: update.absolutePath,
|
|
66
|
-
oldContents: update.fileContents,
|
|
67
|
-
newContents: null,
|
|
68
|
-
logLevel,
|
|
69
|
-
remotionRoot,
|
|
70
|
-
logLine: update.logLine,
|
|
71
|
-
description: {
|
|
72
|
-
undoMessage: `↩️ Deletion of ${deletedEffectDescription}`,
|
|
73
|
-
redoMessage: `↪️ Deletion of ${deletedEffectDescription}`,
|
|
74
|
-
},
|
|
75
|
-
entryType: 'delete-effect',
|
|
76
|
-
suppressHmrOnFileRestore: false,
|
|
77
|
-
});
|
|
78
|
-
(0, undo_stack_1.suppressUndoStackInvalidation)(update.absolutePath);
|
|
79
|
-
(0, file_watcher_1.writeFileAndNotifyFileWatchers)(update.absolutePath, update.output, undefined);
|
|
80
|
-
const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
|
|
81
|
-
remotionRoot,
|
|
82
|
-
absolutePath: update.absolutePath,
|
|
83
|
-
line: update.logLine,
|
|
84
|
-
});
|
|
85
|
-
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} ${(0, formatting_1.strikeThroughOrRemovedPrefix)(deletedEffectDescription)}`);
|
|
86
|
-
if (!update.formatted) {
|
|
87
|
-
(0, log_update_1.warnAboutPrettierOnce)(logLevel);
|
|
88
|
-
}
|
|
89
|
-
renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[delete-effect] Wrote ${update.fileRelativeToRoot}${update.formatted ? ' (formatted)' : ''}`);
|
|
90
104
|
}
|
|
91
|
-
|
|
92
|
-
return {
|
|
93
|
-
success: true,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
catch (err) {
|
|
97
|
-
return {
|
|
98
|
-
success: false,
|
|
99
|
-
reason: err.message,
|
|
100
|
-
stack: err.stack,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
105
|
+
});
|
|
103
106
|
};
|
|
104
107
|
exports.deleteEffectHandler = deleteEffectHandler;
|
|
@@ -9,86 +9,89 @@ const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside
|
|
|
9
9
|
const format_log_file_location_1 = require("../format-log-file-location");
|
|
10
10
|
const undo_stack_1 = require("../undo-stack");
|
|
11
11
|
const log_update_1 = require("./log-updates/log-update");
|
|
12
|
+
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
12
13
|
const getDeletedNodeDescription = (nodeLabels) => {
|
|
13
14
|
if (nodeLabels.length === 1) {
|
|
14
15
|
return nodeLabels[0];
|
|
15
16
|
}
|
|
16
17
|
return `${nodeLabels.length} JSX nodes`;
|
|
17
18
|
};
|
|
18
|
-
const deleteJsxNodeHandler =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
const deleteJsxNodeHandler = ({ input: { nodes }, remotionRoot, logLevel }) => {
|
|
20
|
+
return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
|
|
21
|
+
var _a;
|
|
22
|
+
try {
|
|
23
|
+
if (nodes.length === 0) {
|
|
24
|
+
throw new Error('No JSX nodes were specified for deletion');
|
|
25
|
+
}
|
|
26
|
+
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[delete-jsx-node] Received request to delete ${nodes.length} JSX node${nodes.length === 1 ? '' : 's'}`);
|
|
27
|
+
const itemsByFileName = new Map();
|
|
28
|
+
for (const item of nodes) {
|
|
29
|
+
const fileItems = (_a = itemsByFileName.get(item.fileName)) !== null && _a !== void 0 ? _a : [];
|
|
30
|
+
fileItems.push(item);
|
|
31
|
+
itemsByFileName.set(item.fileName, fileItems);
|
|
32
|
+
}
|
|
33
|
+
const updates = await Promise.all([...itemsByFileName.entries()].map(async ([fileName, fileItems]) => {
|
|
34
|
+
const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
35
|
+
remotionRoot,
|
|
36
|
+
fileName,
|
|
37
|
+
action: 'modify',
|
|
38
|
+
});
|
|
39
|
+
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
40
|
+
const { output, formatted, nodeLabels, logLines } = await (0, delete_jsx_node_1.deleteJsxNodes)({
|
|
41
|
+
input: fileContents,
|
|
42
|
+
nodePaths: fileItems.map((item) => item.nodePath),
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
absolutePath,
|
|
46
|
+
fileRelativeToRoot,
|
|
47
|
+
fileContents,
|
|
48
|
+
output,
|
|
49
|
+
formatted,
|
|
50
|
+
nodeLabels,
|
|
51
|
+
logLine: Math.min(...logLines),
|
|
52
|
+
};
|
|
53
|
+
}));
|
|
54
|
+
for (const update of updates) {
|
|
55
|
+
const deletedNodeDescription = getDeletedNodeDescription(update.nodeLabels);
|
|
56
|
+
(0, undo_stack_1.pushToUndoStack)({
|
|
57
|
+
filePath: update.absolutePath,
|
|
58
|
+
oldContents: update.fileContents,
|
|
59
|
+
newContents: null,
|
|
60
|
+
logLevel,
|
|
61
|
+
remotionRoot,
|
|
62
|
+
logLine: update.logLine,
|
|
63
|
+
description: {
|
|
64
|
+
undoMessage: `↩️ Deletion of ${deletedNodeDescription}`,
|
|
65
|
+
redoMessage: `↪️ Deletion of ${deletedNodeDescription}`,
|
|
66
|
+
},
|
|
67
|
+
entryType: 'delete-jsx-node',
|
|
68
|
+
suppressHmrOnFileRestore: false,
|
|
69
|
+
});
|
|
70
|
+
(0, undo_stack_1.suppressUndoStackInvalidation)(update.absolutePath);
|
|
71
|
+
(0, file_watcher_1.writeFileAndNotifyFileWatchers)(update.absolutePath, update.output, undefined);
|
|
72
|
+
const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
|
|
73
|
+
remotionRoot,
|
|
74
|
+
absolutePath: update.absolutePath,
|
|
75
|
+
line: update.logLine,
|
|
76
|
+
});
|
|
77
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Deleted ${deletedNodeDescription}`);
|
|
78
|
+
if (!update.formatted) {
|
|
79
|
+
(0, log_update_1.warnAboutPrettierOnce)(logLevel);
|
|
80
|
+
}
|
|
81
|
+
renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[delete-jsx-node] Wrote ${update.fileRelativeToRoot}${update.formatted ? ' (formatted)' : ''}`);
|
|
82
|
+
}
|
|
83
|
+
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
84
|
+
return {
|
|
85
|
+
success: true,
|
|
86
|
+
};
|
|
30
87
|
}
|
|
31
|
-
|
|
32
|
-
const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
33
|
-
remotionRoot,
|
|
34
|
-
fileName,
|
|
35
|
-
action: 'modify',
|
|
36
|
-
});
|
|
37
|
-
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
38
|
-
const { output, formatted, nodeLabels, logLines } = await (0, delete_jsx_node_1.deleteJsxNodes)({
|
|
39
|
-
input: fileContents,
|
|
40
|
-
nodePaths: fileItems.map((item) => item.nodePath),
|
|
41
|
-
});
|
|
88
|
+
catch (err) {
|
|
42
89
|
return {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
output,
|
|
47
|
-
formatted,
|
|
48
|
-
nodeLabels,
|
|
49
|
-
logLine: Math.min(...logLines),
|
|
90
|
+
success: false,
|
|
91
|
+
reason: err.message,
|
|
92
|
+
stack: err.stack,
|
|
50
93
|
};
|
|
51
|
-
}));
|
|
52
|
-
for (const update of updates) {
|
|
53
|
-
const deletedNodeDescription = getDeletedNodeDescription(update.nodeLabels);
|
|
54
|
-
(0, undo_stack_1.pushToUndoStack)({
|
|
55
|
-
filePath: update.absolutePath,
|
|
56
|
-
oldContents: update.fileContents,
|
|
57
|
-
newContents: null,
|
|
58
|
-
logLevel,
|
|
59
|
-
remotionRoot,
|
|
60
|
-
logLine: update.logLine,
|
|
61
|
-
description: {
|
|
62
|
-
undoMessage: `↩️ Deletion of ${deletedNodeDescription}`,
|
|
63
|
-
redoMessage: `↪️ Deletion of ${deletedNodeDescription}`,
|
|
64
|
-
},
|
|
65
|
-
entryType: 'delete-jsx-node',
|
|
66
|
-
suppressHmrOnFileRestore: false,
|
|
67
|
-
});
|
|
68
|
-
(0, undo_stack_1.suppressUndoStackInvalidation)(update.absolutePath);
|
|
69
|
-
(0, file_watcher_1.writeFileAndNotifyFileWatchers)(update.absolutePath, update.output, undefined);
|
|
70
|
-
const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
|
|
71
|
-
remotionRoot,
|
|
72
|
-
absolutePath: update.absolutePath,
|
|
73
|
-
line: update.logLine,
|
|
74
|
-
});
|
|
75
|
-
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Deleted ${deletedNodeDescription}`);
|
|
76
|
-
if (!update.formatted) {
|
|
77
|
-
(0, log_update_1.warnAboutPrettierOnce)(logLevel);
|
|
78
|
-
}
|
|
79
|
-
renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[delete-jsx-node] Wrote ${update.fileRelativeToRoot}${update.formatted ? ' (formatted)' : ''}`);
|
|
80
94
|
}
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
success: true,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
catch (err) {
|
|
87
|
-
return {
|
|
88
|
-
success: false,
|
|
89
|
-
reason: err.message,
|
|
90
|
-
stack: err.stack,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
95
|
+
});
|
|
93
96
|
};
|
|
94
97
|
exports.deleteJsxNodeHandler = deleteJsxNodeHandler;
|
|
@@ -14,7 +14,7 @@ const can_update_effect_props_1 = require("./can-update-effect-props");
|
|
|
14
14
|
const can_update_sequence_props_1 = require("./can-update-sequence-props");
|
|
15
15
|
const log_effect_update_1 = require("./log-updates/log-effect-update");
|
|
16
16
|
const log_update_1 = require("./log-updates/log-update");
|
|
17
|
-
const
|
|
17
|
+
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
18
18
|
const groupBy = (items, getKey) => {
|
|
19
19
|
var _a;
|
|
20
20
|
const groups = new Map();
|
|
@@ -251,7 +251,7 @@ const deleteKeyframes = async ({ sequenceKeyframes, effectKeyframes, clientId, r
|
|
|
251
251
|
return { sequenceResults, effectResults };
|
|
252
252
|
};
|
|
253
253
|
exports.deleteKeyframes = deleteKeyframes;
|
|
254
|
-
const deleteKeyframesHandler = ({ input: { sequenceKeyframes, effectKeyframes, clientId }, remotionRoot, logLevel, }) => (0,
|
|
254
|
+
const deleteKeyframesHandler = ({ input: { sequenceKeyframes, effectKeyframes, clientId }, remotionRoot, logLevel, }) => (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
|
|
255
255
|
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[delete-keyframes] Received request to delete ${sequenceKeyframes.length + effectKeyframes.length} keyframe(s)`);
|
|
256
256
|
await (0, exports.deleteKeyframes)({
|
|
257
257
|
sequenceKeyframes,
|