@remotion/studio-server 4.0.460 → 4.0.462
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/update-effect-props/update-effect-props.d.ts +52 -0
- package/dist/codemods/update-effect-props/update-effect-props.js +229 -0
- package/dist/codemods/update-sequence-props/find-props-to-delete.d.ts +6 -0
- package/dist/codemods/update-sequence-props/find-props-to-delete.js +37 -0
- package/dist/codemods/update-sequence-props/update-sequence-props.d.ts +35 -0
- package/dist/codemods/update-sequence-props/update-sequence-props.js +224 -0
- package/dist/codemods/update-sequence-props.d.ts +7 -1
- package/dist/codemods/update-sequence-props.js +46 -3
- package/dist/index.d.ts +1 -2
- package/dist/preview-server/api-routes.js +2 -0
- package/dist/preview-server/routes/apply-visual-control-change.js +4 -4
- package/dist/preview-server/routes/can-update-effect-props.d.ts +20 -0
- package/dist/preview-server/routes/can-update-effect-props.js +146 -0
- package/dist/preview-server/routes/can-update-sequence-props.d.ts +26 -6
- package/dist/preview-server/routes/can-update-sequence-props.js +82 -35
- package/dist/preview-server/routes/delete-jsx-node.js +4 -4
- package/dist/preview-server/routes/duplicate-jsx-node.js +4 -4
- package/dist/preview-server/routes/log-update.d.ts +13 -2
- package/dist/preview-server/routes/log-update.js +56 -30
- package/dist/preview-server/routes/log-updates/format-effect-prop-change.d.ts +10 -0
- package/dist/preview-server/routes/log-updates/format-effect-prop-change.js +51 -0
- package/dist/preview-server/routes/log-updates/format-prop-change.d.ts +9 -0
- package/dist/preview-server/routes/log-updates/format-prop-change.js +29 -0
- package/dist/preview-server/routes/log-updates/format-side-prop.d.ts +0 -0
- package/dist/preview-server/routes/log-updates/format-side-prop.js +1 -0
- package/dist/preview-server/routes/log-updates/format-side-props.d.ts +5 -0
- package/dist/preview-server/routes/log-updates/format-side-props.js +18 -0
- package/dist/preview-server/routes/log-updates/formatting.d.ts +19 -0
- package/dist/preview-server/routes/log-updates/formatting.js +67 -0
- package/dist/preview-server/routes/log-updates/log-effect-update.d.ts +14 -0
- package/dist/preview-server/routes/log-updates/log-effect-update.js +23 -0
- package/dist/preview-server/routes/log-updates/log-update.d.ts +15 -0
- package/dist/preview-server/routes/log-updates/log-update.js +39 -0
- package/dist/preview-server/routes/save-effect-props.d.ts +3 -0
- package/dist/preview-server/routes/save-effect-props.js +107 -0
- package/dist/preview-server/routes/save-sequence-props.js +82 -87
- package/dist/preview-server/routes/subscribe-to-sequence-props.js +4 -3
- package/dist/preview-server/routes/unsubscribe-from-sequence-props.js +4 -2
- package/dist/preview-server/routes/update-default-props.js +4 -4
- package/dist/preview-server/sequence-props-watchers.d.ts +9 -4
- package/dist/preview-server/sequence-props-watchers.js +54 -24
- package/dist/preview-server/start-server.d.ts +0 -1
- package/dist/preview-server/start-server.js +0 -1
- package/dist/preview-server/undo-stack.d.ts +3 -1
- package/dist/preview-server/undo-stack.js +1 -1
- package/dist/routes.js +0 -14
- package/dist/start-studio.d.ts +1 -2
- package/dist/start-studio.js +1 -2
- package/package.json +8 -10
- package/dist/codemods/jsx-sequence-context.d.ts +0 -11
- package/dist/codemods/jsx-sequence-context.js +0 -68
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.logUpdate = exports.formatPropChange = exports.normalizeQuotes = exports.warnAboutPrettierOnce = void 0;
|
|
3
|
+
exports.logUpdate = exports.formatPropChange = exports.strikeThrough = exports.bg = exports.fg = exports.normalizeQuotes = exports.warnAboutPrettierOnce = void 0;
|
|
4
4
|
const renderer_1 = require("@remotion/renderer");
|
|
5
5
|
let warnedAboutPrettier = false;
|
|
6
6
|
const warnAboutPrettierOnce = (logLevel) => {
|
|
@@ -22,13 +22,19 @@ const normalizeQuotes = (str) => {
|
|
|
22
22
|
exports.normalizeQuotes = normalizeQuotes;
|
|
23
23
|
// 24-bit ANSI helpers
|
|
24
24
|
const fg = (r, g, b, str) => `\u001b[38;2;${r};${g};${b}m${str}\u001b[39m`;
|
|
25
|
+
exports.fg = fg;
|
|
25
26
|
const bg = (r, g, b, str) => `\u001b[48;2;${r};${g};${b}m${str}\u001b[49m`;
|
|
27
|
+
exports.bg = bg;
|
|
28
|
+
// eslint-disable-next-line no-control-regex
|
|
29
|
+
const stripAnsi = (str) => str.replace(/\u001b\[[0-9;]*m/g, '');
|
|
30
|
+
const strikeThrough = (str) => `\u001b[9m\u001b[38;2;255;85;85m${stripAnsi(str)}\u001b[39m\u001b[29m`;
|
|
31
|
+
exports.strikeThrough = strikeThrough;
|
|
26
32
|
// Monokai-inspired syntax colors
|
|
27
|
-
const attrName = (str) => fg(166, 226, 46, str);
|
|
28
|
-
const equals = (str) => fg(249, 38, 114, str);
|
|
29
|
-
const punctuation = (str) => fg(248, 248, 242, str);
|
|
30
|
-
const stringValue = (str) => fg(230, 219, 116, str);
|
|
31
|
-
const numberValue = (str) => fg(174, 129, 255, str);
|
|
33
|
+
const attrName = (str) => (0, exports.fg)(166, 226, 46, str);
|
|
34
|
+
const equals = (str) => (0, exports.fg)(249, 38, 114, str);
|
|
35
|
+
const punctuation = (str) => (0, exports.fg)(248, 248, 242, str);
|
|
36
|
+
const stringValue = (str) => (0, exports.fg)(230, 219, 116, str);
|
|
37
|
+
const numberValue = (str) => (0, exports.fg)(174, 129, 255, str);
|
|
32
38
|
const colorValue = (str) => {
|
|
33
39
|
if ((str.startsWith("'") && str.endsWith("'")) ||
|
|
34
40
|
(str.startsWith('"') && str.endsWith('"'))) {
|
|
@@ -39,9 +45,6 @@ const colorValue = (str) => {
|
|
|
39
45
|
}
|
|
40
46
|
return punctuation(str);
|
|
41
47
|
};
|
|
42
|
-
// Subtle background tints
|
|
43
|
-
const removedBg = (str) => bg(80, 20, 20, str);
|
|
44
|
-
const addedBg = (str) => bg(30, 80, 30, str);
|
|
45
48
|
const colorEnabled = () => renderer_1.RenderInternals.chalk.enabled();
|
|
46
49
|
// Format key={value} with Monokai syntax highlighting
|
|
47
50
|
const formatSimpleProp = (key, value) => {
|
|
@@ -51,46 +54,69 @@ const formatSimpleProp = (key, value) => {
|
|
|
51
54
|
const formatNestedProp = (parentKey, childKey, value) => {
|
|
52
55
|
return `${attrName(parentKey)}${equals('=')}${punctuation('{{')}${punctuation(childKey)}${punctuation(':')} ${colorValue(value)}${punctuation('}}')}`;
|
|
53
56
|
};
|
|
54
|
-
const
|
|
57
|
+
const formatPropDelta = ({ key, valueString }) => {
|
|
55
58
|
if (!colorEnabled()) {
|
|
56
59
|
const dotIdx = key.indexOf('.');
|
|
57
60
|
if (dotIdx === -1) {
|
|
58
|
-
return `${key}={${
|
|
61
|
+
return `${key}={${valueString}}`;
|
|
59
62
|
}
|
|
60
63
|
const parent = key.slice(0, dotIdx);
|
|
61
64
|
const child = key.slice(dotIdx + 1);
|
|
62
|
-
return `${parent}={{${child}: ${
|
|
65
|
+
return `${parent}={{${child}: ${valueString}}}`;
|
|
63
66
|
}
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
const dotIdx = key.indexOf('.');
|
|
68
|
+
if (dotIdx === -1) {
|
|
69
|
+
return formatSimpleProp(key, valueString);
|
|
70
|
+
}
|
|
71
|
+
return formatNestedProp(key.slice(0, dotIdx), key.slice(dotIdx + 1), valueString);
|
|
72
|
+
};
|
|
73
|
+
const formatSideProps = ({ removedProps, addedProps, }) => {
|
|
74
|
+
const parts = [];
|
|
75
|
+
for (const prop of removedProps) {
|
|
76
|
+
const formatted = formatPropDelta(prop);
|
|
77
|
+
parts.push(colorEnabled() ? (0, exports.strikeThrough)(formatted) : formatted);
|
|
78
|
+
}
|
|
79
|
+
for (const prop of addedProps) {
|
|
80
|
+
parts.push(formatPropDelta(prop));
|
|
81
|
+
}
|
|
82
|
+
if (parts.length === 0) {
|
|
83
|
+
return '';
|
|
84
|
+
}
|
|
85
|
+
return `, ${parts.join(', ')}`;
|
|
86
|
+
};
|
|
87
|
+
const formatPropChange = ({ key, oldValueString, newValueString, defaultValueString, removedProps, addedProps, }) => {
|
|
88
|
+
const suffix = formatSideProps({ removedProps, addedProps });
|
|
89
|
+
if (!colorEnabled()) {
|
|
90
|
+
const dotIdx = key.indexOf('.');
|
|
91
|
+
if (dotIdx === -1) {
|
|
92
|
+
return `${key}={${oldValueString}} \u2192 ${key}={${newValueString}}${suffix}`;
|
|
73
93
|
}
|
|
74
|
-
|
|
94
|
+
const parent = key.slice(0, dotIdx);
|
|
95
|
+
const child = key.slice(dotIdx + 1);
|
|
96
|
+
return `${parent}={{${child}: ${oldValueString}}} \u2192 ${parent}={{${child}: ${newValueString}}}${suffix}`;
|
|
75
97
|
}
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
98
|
+
const dotIndex = key.indexOf('.');
|
|
99
|
+
const formatProp = (value) => dotIndex === -1
|
|
100
|
+
? formatSimpleProp(key, value)
|
|
101
|
+
: formatNestedProp(key.slice(0, dotIndex), key.slice(dotIndex + 1), value);
|
|
102
|
+
if (defaultValueString !== null && newValueString === defaultValueString) {
|
|
103
|
+
return `${(0, exports.strikeThrough)(formatProp(oldValueString))}${suffix}`;
|
|
80
104
|
}
|
|
81
|
-
if (
|
|
82
|
-
return
|
|
105
|
+
if (defaultValueString !== null && oldValueString === defaultValueString) {
|
|
106
|
+
return `${formatProp(newValueString)}${suffix}`;
|
|
83
107
|
}
|
|
84
|
-
return `${
|
|
108
|
+
return `${formatProp(oldValueString)} \u2192 ${formatProp(newValueString)}${suffix}`;
|
|
85
109
|
};
|
|
86
110
|
exports.formatPropChange = formatPropChange;
|
|
87
|
-
const logUpdate = ({ fileRelativeToRoot, line, key, oldValueString, newValueString, defaultValueString, formatted, logLevel, }) => {
|
|
111
|
+
const logUpdate = ({ fileRelativeToRoot, line, key, oldValueString, newValueString, defaultValueString, formatted, logLevel, removedProps, addedProps, }) => {
|
|
88
112
|
const locationLabel = `${fileRelativeToRoot}:${line}`;
|
|
89
113
|
const propChange = (0, exports.formatPropChange)({
|
|
90
114
|
key,
|
|
91
115
|
oldValueString: (0, exports.normalizeQuotes)(oldValueString),
|
|
92
116
|
newValueString: (0, exports.normalizeQuotes)(newValueString),
|
|
93
117
|
defaultValueString: defaultValueString !== null ? (0, exports.normalizeQuotes)(defaultValueString) : null,
|
|
118
|
+
removedProps,
|
|
119
|
+
addedProps,
|
|
94
120
|
});
|
|
95
121
|
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}:`)} ${propChange}`);
|
|
96
122
|
if (!formatted) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PropDelta } from './formatting';
|
|
2
|
+
export declare const formatEffectPropChange: ({ effectName, key, oldValueString, newValueString, defaultValueString, removedProps, addedProps, }: {
|
|
3
|
+
effectName: string;
|
|
4
|
+
key: string;
|
|
5
|
+
oldValueString: string;
|
|
6
|
+
newValueString: string;
|
|
7
|
+
defaultValueString: string | null;
|
|
8
|
+
removedProps: PropDelta[];
|
|
9
|
+
addedProps: PropDelta[];
|
|
10
|
+
}) => string;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatEffectPropChange = void 0;
|
|
4
|
+
const format_side_props_1 = require("./format-side-props");
|
|
5
|
+
const formatting_1 = require("./formatting");
|
|
6
|
+
const formatEffectPropBody = (key, valueString) => {
|
|
7
|
+
return `${(0, formatting_1.punctuation)(key)}${(0, formatting_1.punctuation)(': ')}${(0, formatting_1.colorValue)(valueString)}`;
|
|
8
|
+
};
|
|
9
|
+
const formatEffectCall = (effectName, key, valueString) => {
|
|
10
|
+
return `${(0, formatting_1.attrName)(effectName)}${(0, formatting_1.punctuation)('(')}${(0, formatting_1.punctuation)('{')}${formatEffectPropBody(key, valueString)}${(0, formatting_1.punctuation)('}')}${(0, formatting_1.punctuation)(')')}`;
|
|
11
|
+
};
|
|
12
|
+
const formatEffectDeletion = ({ effectName, key, valueString, }) => {
|
|
13
|
+
const inner = formatEffectPropBody(key, valueString);
|
|
14
|
+
return `${(0, formatting_1.attrName)(effectName)}${(0, formatting_1.punctuation)('(')}${(0, formatting_1.punctuation)('{')}${(0, formatting_1.strikeThroughOrRemovedPrefix)(inner)}${(0, formatting_1.punctuation)('}')}${(0, formatting_1.punctuation)(')')}`;
|
|
15
|
+
};
|
|
16
|
+
const formatEffectAddition = ({ effectName, key, valueString, }) => {
|
|
17
|
+
return (0, formatting_1.addedPrefixIfNoColor)(formatEffectCall(effectName, key, valueString));
|
|
18
|
+
};
|
|
19
|
+
const formatEffectInnerPropChange = ({ effectName, key, oldValueString, newValueString, defaultValueString, }) => {
|
|
20
|
+
if (defaultValueString !== null && newValueString === defaultValueString) {
|
|
21
|
+
return formatEffectDeletion({
|
|
22
|
+
effectName,
|
|
23
|
+
key,
|
|
24
|
+
valueString: oldValueString,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (defaultValueString !== null && oldValueString === defaultValueString) {
|
|
28
|
+
return formatEffectAddition({
|
|
29
|
+
effectName,
|
|
30
|
+
key,
|
|
31
|
+
valueString: newValueString,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return `${formatEffectCall(effectName, key, oldValueString)} \u2192 ${formatEffectCall(effectName, key, newValueString)}`;
|
|
35
|
+
};
|
|
36
|
+
const formatEffectPropChange = ({ effectName, key, oldValueString, newValueString, defaultValueString, removedProps, addedProps, }) => {
|
|
37
|
+
const suffix = (0, format_side_props_1.formatSideProps)({ removedProps, addedProps });
|
|
38
|
+
return [
|
|
39
|
+
formatEffectInnerPropChange({
|
|
40
|
+
effectName,
|
|
41
|
+
key,
|
|
42
|
+
oldValueString,
|
|
43
|
+
newValueString,
|
|
44
|
+
defaultValueString,
|
|
45
|
+
}),
|
|
46
|
+
suffix,
|
|
47
|
+
]
|
|
48
|
+
.filter(Boolean)
|
|
49
|
+
.join(', ');
|
|
50
|
+
};
|
|
51
|
+
exports.formatEffectPropChange = formatEffectPropChange;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type PropDelta } from './formatting';
|
|
2
|
+
export declare const formatPropChange: ({ key, oldValueString, newValueString, defaultValueString, removedProps, addedProps, }: {
|
|
3
|
+
key: string;
|
|
4
|
+
oldValueString: string;
|
|
5
|
+
newValueString: string;
|
|
6
|
+
defaultValueString: string | null;
|
|
7
|
+
removedProps: PropDelta[];
|
|
8
|
+
addedProps: PropDelta[];
|
|
9
|
+
}) => string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatPropChange = void 0;
|
|
4
|
+
const format_side_props_1 = require("./format-side-props");
|
|
5
|
+
const formatting_1 = require("./formatting");
|
|
6
|
+
const formatInnerPropChange = ({ key, oldValueString, newValueString, defaultValueString, }) => {
|
|
7
|
+
if (defaultValueString !== null && newValueString === defaultValueString) {
|
|
8
|
+
return (0, formatting_1.formatDeletion)({ valueString: oldValueString, key });
|
|
9
|
+
}
|
|
10
|
+
if (defaultValueString !== null && oldValueString === defaultValueString) {
|
|
11
|
+
return (0, formatting_1.formatAddition)({ valueString: newValueString, key });
|
|
12
|
+
}
|
|
13
|
+
return `${(0, formatting_1.formatPropDelta)({ valueString: oldValueString, key })} \u2192 ${(0, formatting_1.formatPropDelta)({ valueString: newValueString, key })}`;
|
|
14
|
+
};
|
|
15
|
+
const formatPropChange = ({ key, oldValueString, newValueString, defaultValueString, removedProps, addedProps, }) => {
|
|
16
|
+
const suffix = (0, format_side_props_1.formatSideProps)({ removedProps, addedProps });
|
|
17
|
+
return [
|
|
18
|
+
formatInnerPropChange({
|
|
19
|
+
key,
|
|
20
|
+
oldValueString,
|
|
21
|
+
newValueString,
|
|
22
|
+
defaultValueString,
|
|
23
|
+
}),
|
|
24
|
+
suffix,
|
|
25
|
+
]
|
|
26
|
+
.filter(Boolean)
|
|
27
|
+
.join(', ');
|
|
28
|
+
};
|
|
29
|
+
exports.formatPropChange = formatPropChange;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatSideProps = void 0;
|
|
4
|
+
const formatting_1 = require("./formatting");
|
|
5
|
+
const formatSideProps = ({ removedProps, addedProps, }) => {
|
|
6
|
+
const parts = [];
|
|
7
|
+
for (const prop of removedProps) {
|
|
8
|
+
parts.push((0, formatting_1.formatDeletion)(prop));
|
|
9
|
+
}
|
|
10
|
+
for (const prop of addedProps) {
|
|
11
|
+
parts.push((0, formatting_1.formatAddition)(prop));
|
|
12
|
+
}
|
|
13
|
+
if (parts.length === 0) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return parts.join(', ');
|
|
17
|
+
};
|
|
18
|
+
exports.formatSideProps = formatSideProps;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const colorEnabled: () => boolean;
|
|
2
|
+
export declare const colorValue: (str: string) => string;
|
|
3
|
+
export declare const fg: (r: number, g: number, b: number, str: string) => string;
|
|
4
|
+
export declare const bg: (r: number, g: number, b: number, str: string) => string;
|
|
5
|
+
export declare const attrName: (str: string) => string;
|
|
6
|
+
export declare const equals: (str: string) => string;
|
|
7
|
+
export declare const punctuation: (str: string) => string;
|
|
8
|
+
export declare const stringValue: (str: string) => string;
|
|
9
|
+
export declare const numberValue: (str: string) => string;
|
|
10
|
+
export declare const strikeThrough: (str: string) => string;
|
|
11
|
+
export declare const strikeThroughOrRemovedPrefix: (str: string) => string;
|
|
12
|
+
export declare const addedPrefixIfNoColor: (str: string) => string;
|
|
13
|
+
export type PropDelta = {
|
|
14
|
+
key: string;
|
|
15
|
+
valueString: string;
|
|
16
|
+
};
|
|
17
|
+
export declare const formatPropDelta: ({ key, valueString }: PropDelta) => string;
|
|
18
|
+
export declare const formatDeletion: (prop: PropDelta) => string;
|
|
19
|
+
export declare const formatAddition: (prop: PropDelta) => string;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatAddition = exports.formatDeletion = exports.formatPropDelta = exports.addedPrefixIfNoColor = exports.strikeThroughOrRemovedPrefix = exports.strikeThrough = exports.numberValue = exports.stringValue = exports.punctuation = exports.equals = exports.attrName = exports.bg = exports.fg = exports.colorValue = exports.colorEnabled = void 0;
|
|
4
|
+
const renderer_1 = require("@remotion/renderer");
|
|
5
|
+
const colorEnabled = () => renderer_1.RenderInternals.chalk.enabled();
|
|
6
|
+
exports.colorEnabled = colorEnabled;
|
|
7
|
+
const colorValue = (str) => {
|
|
8
|
+
if ((str.startsWith("'") && str.endsWith("'")) ||
|
|
9
|
+
(str.startsWith('"') && str.endsWith('"'))) {
|
|
10
|
+
return (0, exports.stringValue)(str);
|
|
11
|
+
}
|
|
12
|
+
if (/^-?\d+(\.\d+)?$/.test(str)) {
|
|
13
|
+
return (0, exports.numberValue)(str);
|
|
14
|
+
}
|
|
15
|
+
return (0, exports.punctuation)(str);
|
|
16
|
+
};
|
|
17
|
+
exports.colorValue = colorValue;
|
|
18
|
+
// eslint-disable-next-line no-control-regex
|
|
19
|
+
const stripAnsi = (str) => str.replace(/\u001b\[[0-9;]*m/g, '');
|
|
20
|
+
// 24-bit ANSI helpers
|
|
21
|
+
const fg = (r, g, b, str) => (0, exports.colorEnabled)() ? `\u001b[38;2;${r};${g};${b}m${str}\u001b[39m` : str;
|
|
22
|
+
exports.fg = fg;
|
|
23
|
+
const bg = (r, g, b, str) => (0, exports.colorEnabled)() ? `\u001b[48;2;${r};${g};${b}m${str}\u001b[49m` : str;
|
|
24
|
+
exports.bg = bg;
|
|
25
|
+
// Monokai-inspired syntax colors
|
|
26
|
+
const attrName = (str) => (0, exports.fg)(166, 226, 46, str);
|
|
27
|
+
exports.attrName = attrName;
|
|
28
|
+
const equals = (str) => (0, exports.fg)(249, 38, 114, str);
|
|
29
|
+
exports.equals = equals;
|
|
30
|
+
const punctuation = (str) => (0, exports.fg)(248, 248, 242, str);
|
|
31
|
+
exports.punctuation = punctuation;
|
|
32
|
+
const stringValue = (str) => (0, exports.fg)(230, 219, 116, str);
|
|
33
|
+
exports.stringValue = stringValue;
|
|
34
|
+
const numberValue = (str) => (0, exports.fg)(174, 129, 255, str);
|
|
35
|
+
exports.numberValue = numberValue;
|
|
36
|
+
const strikeThrough = (str) => `\u001b[9m\u001b[38;2;255;85;85m${stripAnsi(str)}\u001b[39m\u001b[29m`;
|
|
37
|
+
exports.strikeThrough = strikeThrough;
|
|
38
|
+
const strikeThroughOrRemovedPrefix = (str) => (0, exports.colorEnabled)() ? (0, exports.strikeThrough)(str) : 'removed: ' + str;
|
|
39
|
+
exports.strikeThroughOrRemovedPrefix = strikeThroughOrRemovedPrefix;
|
|
40
|
+
const addedPrefixIfNoColor = (str) => (0, exports.colorEnabled)() ? str : 'added: ' + stripAnsi(str);
|
|
41
|
+
exports.addedPrefixIfNoColor = addedPrefixIfNoColor;
|
|
42
|
+
// Format key={value} with Monokai syntax highlighting
|
|
43
|
+
const formatSimpleProp = (key, value) => {
|
|
44
|
+
return `${(0, exports.attrName)(key)}${(0, exports.equals)('=')}${(0, exports.punctuation)('{')}${(0, exports.colorValue)(value)}${(0, exports.punctuation)('}')}`;
|
|
45
|
+
};
|
|
46
|
+
// Format parentKey={{childKey: value}} with Monokai syntax highlighting
|
|
47
|
+
const formatNestedProp = (parentKey, childKey, value) => {
|
|
48
|
+
return `${(0, exports.attrName)(parentKey)}${(0, exports.equals)('=')}${(0, exports.punctuation)('{{')}${(0, exports.punctuation)(childKey)}${(0, exports.punctuation)(':')} ${(0, exports.colorValue)(value)}${(0, exports.punctuation)('}}')}`;
|
|
49
|
+
};
|
|
50
|
+
const formatPropDelta = ({ key, valueString }) => {
|
|
51
|
+
const dotIdx = key.indexOf('.');
|
|
52
|
+
if (dotIdx === -1) {
|
|
53
|
+
return formatSimpleProp(key, valueString);
|
|
54
|
+
}
|
|
55
|
+
return formatNestedProp(key.slice(0, dotIdx), key.slice(dotIdx + 1), valueString);
|
|
56
|
+
};
|
|
57
|
+
exports.formatPropDelta = formatPropDelta;
|
|
58
|
+
const formatDeletion = (prop) => {
|
|
59
|
+
const formatted = (0, exports.formatPropDelta)(prop);
|
|
60
|
+
return (0, exports.strikeThroughOrRemovedPrefix)(formatted);
|
|
61
|
+
};
|
|
62
|
+
exports.formatDeletion = formatDeletion;
|
|
63
|
+
const formatAddition = (prop) => {
|
|
64
|
+
const formatted = (0, exports.formatPropDelta)(prop);
|
|
65
|
+
return (0, exports.addedPrefixIfNoColor)(formatted);
|
|
66
|
+
};
|
|
67
|
+
exports.formatAddition = formatAddition;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PropDelta } from './formatting';
|
|
2
|
+
export declare const logEffectUpdate: ({ fileRelativeToRoot, line, effectName, propKey, oldValueString, newValueString, defaultValueString, formatted, logLevel, removedProps, addedProps, }: {
|
|
3
|
+
fileRelativeToRoot: string;
|
|
4
|
+
line: number;
|
|
5
|
+
effectName: string;
|
|
6
|
+
propKey: string;
|
|
7
|
+
oldValueString: string;
|
|
8
|
+
newValueString: string;
|
|
9
|
+
defaultValueString: string | null;
|
|
10
|
+
formatted: boolean;
|
|
11
|
+
logLevel: "error" | "info" | "trace" | "verbose" | "warn";
|
|
12
|
+
removedProps: PropDelta[];
|
|
13
|
+
addedProps: PropDelta[];
|
|
14
|
+
}) => void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logEffectUpdate = void 0;
|
|
4
|
+
const renderer_1 = require("@remotion/renderer");
|
|
5
|
+
const format_effect_prop_change_1 = require("./format-effect-prop-change");
|
|
6
|
+
const log_update_1 = require("./log-update");
|
|
7
|
+
const logEffectUpdate = ({ fileRelativeToRoot, line, effectName, propKey, oldValueString, newValueString, defaultValueString, formatted, logLevel, removedProps, addedProps, }) => {
|
|
8
|
+
const locationLabel = `${fileRelativeToRoot}:${line}`;
|
|
9
|
+
const propChange = (0, format_effect_prop_change_1.formatEffectPropChange)({
|
|
10
|
+
effectName,
|
|
11
|
+
key: propKey,
|
|
12
|
+
oldValueString: (0, log_update_1.normalizeQuotes)(oldValueString),
|
|
13
|
+
newValueString: (0, log_update_1.normalizeQuotes)(newValueString),
|
|
14
|
+
defaultValueString: defaultValueString !== null ? (0, log_update_1.normalizeQuotes)(defaultValueString) : null,
|
|
15
|
+
removedProps,
|
|
16
|
+
addedProps,
|
|
17
|
+
});
|
|
18
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} ${propChange}`);
|
|
19
|
+
if (!formatted) {
|
|
20
|
+
(0, log_update_1.warnAboutPrettierOnce)(logLevel);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
exports.logEffectUpdate = logEffectUpdate;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PropDelta } from './formatting';
|
|
2
|
+
export declare const warnAboutPrettierOnce: (logLevel: "error" | "info" | "trace" | "verbose" | "warn") => void;
|
|
3
|
+
export declare const normalizeQuotes: (str: string) => string;
|
|
4
|
+
export declare const logUpdate: ({ fileRelativeToRoot, line, key, oldValueString, newValueString, defaultValueString, formatted, logLevel, removedProps, addedProps, }: {
|
|
5
|
+
fileRelativeToRoot: string;
|
|
6
|
+
line: number;
|
|
7
|
+
key: string;
|
|
8
|
+
oldValueString: string;
|
|
9
|
+
newValueString: string;
|
|
10
|
+
defaultValueString: string | null;
|
|
11
|
+
formatted: boolean;
|
|
12
|
+
logLevel: "error" | "info" | "trace" | "verbose" | "warn";
|
|
13
|
+
removedProps: PropDelta[];
|
|
14
|
+
addedProps: PropDelta[];
|
|
15
|
+
}) => void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logUpdate = exports.normalizeQuotes = exports.warnAboutPrettierOnce = void 0;
|
|
4
|
+
const renderer_1 = require("@remotion/renderer");
|
|
5
|
+
const format_prop_change_1 = require("./format-prop-change");
|
|
6
|
+
let warnedAboutPrettier = false;
|
|
7
|
+
const warnAboutPrettierOnce = (logLevel) => {
|
|
8
|
+
if (warnedAboutPrettier) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
warnedAboutPrettier = true;
|
|
12
|
+
renderer_1.RenderInternals.Log.warn({ indent: false, logLevel }, renderer_1.RenderInternals.chalk.yellow('Could not format with Prettier. File will need to be formatted manually.'));
|
|
13
|
+
};
|
|
14
|
+
exports.warnAboutPrettierOnce = warnAboutPrettierOnce;
|
|
15
|
+
const normalizeQuotes = (str) => {
|
|
16
|
+
if (str.length >= 2 &&
|
|
17
|
+
((str.startsWith("'") && str.endsWith("'")) ||
|
|
18
|
+
(str.startsWith('"') && str.endsWith('"')))) {
|
|
19
|
+
return `'${str.slice(1, -1)}'`;
|
|
20
|
+
}
|
|
21
|
+
return str;
|
|
22
|
+
};
|
|
23
|
+
exports.normalizeQuotes = normalizeQuotes;
|
|
24
|
+
const logUpdate = ({ fileRelativeToRoot, line, key, oldValueString, newValueString, defaultValueString, formatted, logLevel, removedProps, addedProps, }) => {
|
|
25
|
+
const locationLabel = `${fileRelativeToRoot}:${line}`;
|
|
26
|
+
const propChange = (0, format_prop_change_1.formatPropChange)({
|
|
27
|
+
key,
|
|
28
|
+
oldValueString: (0, exports.normalizeQuotes)(oldValueString),
|
|
29
|
+
newValueString: (0, exports.normalizeQuotes)(newValueString),
|
|
30
|
+
defaultValueString: defaultValueString !== null ? (0, exports.normalizeQuotes)(defaultValueString) : null,
|
|
31
|
+
removedProps,
|
|
32
|
+
addedProps,
|
|
33
|
+
});
|
|
34
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} ${propChange}`);
|
|
35
|
+
if (!formatted) {
|
|
36
|
+
(0, exports.warnAboutPrettierOnce)(logLevel);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.logUpdate = logUpdate;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.saveEffectPropsHandler = void 0;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const renderer_1 = require("@remotion/renderer");
|
|
10
|
+
const studio_shared_1 = require("@remotion/studio-shared");
|
|
11
|
+
const parse_ast_1 = require("../../codemods/parse-ast");
|
|
12
|
+
const update_effect_props_1 = require("../../codemods/update-effect-props/update-effect-props");
|
|
13
|
+
const file_watcher_1 = require("../../file-watcher");
|
|
14
|
+
const undo_stack_1 = require("../undo-stack");
|
|
15
|
+
const watch_ignore_next_change_1 = require("../watch-ignore-next-change");
|
|
16
|
+
const can_update_effect_props_1 = require("./can-update-effect-props");
|
|
17
|
+
const can_update_sequence_props_1 = require("./can-update-sequence-props");
|
|
18
|
+
const format_effect_prop_change_1 = require("./log-updates/format-effect-prop-change");
|
|
19
|
+
const log_effect_update_1 = require("./log-updates/log-effect-update");
|
|
20
|
+
const log_update_1 = require("./log-updates/log-update");
|
|
21
|
+
const saveEffectPropsHandler = async ({ input: { fileName, sequenceNodePath, effectIndex, key, value, defaultValue, schema, }, remotionRoot, logLevel, }) => {
|
|
22
|
+
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[save-effect-props] Received request for fileName="${fileName}" effectIndex=${effectIndex} key="${key}"`);
|
|
23
|
+
const absolutePath = node_path_1.default.resolve(remotionRoot, fileName);
|
|
24
|
+
const fileRelativeToRoot = node_path_1.default.relative(remotionRoot, absolutePath);
|
|
25
|
+
if (fileRelativeToRoot.startsWith('..')) {
|
|
26
|
+
throw new Error('Cannot modify a file outside the project');
|
|
27
|
+
}
|
|
28
|
+
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
29
|
+
const parsedDefault = defaultValue !== null ? JSON.parse(defaultValue) : null;
|
|
30
|
+
const { output, oldValueString, formatted, logLine, effectCallee } = await (0, update_effect_props_1.updateEffectProps)({
|
|
31
|
+
input: fileContents,
|
|
32
|
+
sequenceNodePath: sequenceNodePath.nodePath,
|
|
33
|
+
effectIndex,
|
|
34
|
+
update: {
|
|
35
|
+
key,
|
|
36
|
+
value: JSON.parse(value),
|
|
37
|
+
defaultValue: parsedDefault,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
const defaultValueString = parsedDefault !== null ? JSON.stringify(parsedDefault) : null;
|
|
41
|
+
const normalizedOld = (0, log_update_1.normalizeQuotes)(oldValueString);
|
|
42
|
+
const normalizedNew = (0, log_update_1.normalizeQuotes)(value);
|
|
43
|
+
const normalizedDefault = defaultValueString !== null ? (0, log_update_1.normalizeQuotes)(defaultValueString) : null;
|
|
44
|
+
const undoPropChange = (0, format_effect_prop_change_1.formatEffectPropChange)({
|
|
45
|
+
effectName: effectCallee,
|
|
46
|
+
key,
|
|
47
|
+
oldValueString: normalizedNew,
|
|
48
|
+
newValueString: normalizedOld,
|
|
49
|
+
defaultValueString: normalizedDefault,
|
|
50
|
+
removedProps: [],
|
|
51
|
+
addedProps: [],
|
|
52
|
+
});
|
|
53
|
+
const redoPropChange = (0, format_effect_prop_change_1.formatEffectPropChange)({
|
|
54
|
+
effectName: effectCallee,
|
|
55
|
+
key,
|
|
56
|
+
oldValueString: normalizedOld,
|
|
57
|
+
newValueString: normalizedNew,
|
|
58
|
+
defaultValueString: normalizedDefault,
|
|
59
|
+
removedProps: [],
|
|
60
|
+
addedProps: [],
|
|
61
|
+
});
|
|
62
|
+
(0, undo_stack_1.pushToUndoStack)({
|
|
63
|
+
filePath: absolutePath,
|
|
64
|
+
oldContents: fileContents,
|
|
65
|
+
logLevel,
|
|
66
|
+
remotionRoot,
|
|
67
|
+
logLine,
|
|
68
|
+
description: {
|
|
69
|
+
undoMessage: `↩️ ${undoPropChange}`,
|
|
70
|
+
redoMessage: `↪️ ${redoPropChange}`,
|
|
71
|
+
},
|
|
72
|
+
entryType: 'effect-props',
|
|
73
|
+
suppressHmrOnFileRestore: true,
|
|
74
|
+
});
|
|
75
|
+
(0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
|
|
76
|
+
(0, watch_ignore_next_change_1.suppressBundlerUpdateForFile)(absolutePath);
|
|
77
|
+
(0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output);
|
|
78
|
+
(0, log_effect_update_1.logEffectUpdate)({
|
|
79
|
+
fileRelativeToRoot,
|
|
80
|
+
line: logLine,
|
|
81
|
+
effectName: effectCallee,
|
|
82
|
+
propKey: key,
|
|
83
|
+
oldValueString,
|
|
84
|
+
newValueString: value,
|
|
85
|
+
defaultValueString,
|
|
86
|
+
formatted,
|
|
87
|
+
logLevel,
|
|
88
|
+
removedProps: [],
|
|
89
|
+
addedProps: [],
|
|
90
|
+
});
|
|
91
|
+
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
92
|
+
const ast = (0, parse_ast_1.parseAst)((0, node_fs_1.readFileSync)(absolutePath, 'utf-8'));
|
|
93
|
+
const jsx = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, sequenceNodePath.nodePath);
|
|
94
|
+
if (!jsx) {
|
|
95
|
+
return {
|
|
96
|
+
canUpdate: false,
|
|
97
|
+
effectIndex,
|
|
98
|
+
reason: 'not-found',
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return (0, can_update_effect_props_1.computeEffectPropStatus)({
|
|
102
|
+
jsx,
|
|
103
|
+
effectIndex,
|
|
104
|
+
keys: (0, studio_shared_1.getAllSchemaKeys)(schema),
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
exports.saveEffectPropsHandler = saveEffectPropsHandler;
|