@remotion/studio-server 4.0.459 → 4.0.461
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/delete-jsx-node.d.ts +1 -1
- package/dist/codemods/duplicate-jsx-node.d.ts +1 -1
- package/dist/codemods/jsx-sequence-context.d.ts +1 -1
- 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 +37 -3
- package/dist/helpers/get-ast-node-path.d.ts +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/preview-server/node-path-cache.d.ts +1 -1
- package/dist/preview-server/routes/apply-visual-control-change.js +4 -4
- package/dist/preview-server/routes/can-update-sequence-props.d.ts +6 -4
- package/dist/preview-server/routes/can-update-sequence-props.js +20 -24
- 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 +40 -31
- 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-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-update.d.ts +15 -0
- package/dist/preview-server/routes/log-updates/log-update.js +39 -0
- package/dist/preview-server/routes/save-sequence-props.d.ts +3 -2
- package/dist/preview-server/routes/save-sequence-props.js +80 -85
- package/dist/preview-server/routes/update-default-props.js +4 -4
- package/dist/preview-server/sequence-props-watchers.d.ts +3 -2
- package/dist/preview-server/sequence-props-watchers.js +4 -3
- 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.js +1 -1
- package/dist/preview-server/watch-ignore-next-change.d.ts +1 -0
- package/dist/preview-server/watch-ignore-next-change.js +25 -1
- package/dist/routes.js +6 -14
- package/dist/start-studio.d.ts +1 -2
- package/dist/start-studio.js +1 -2
- package/package.json +8 -9
|
@@ -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,52 @@ 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 formatSideProps = ({ removedProps, addedProps, }) => {
|
|
58
|
+
const parts = [];
|
|
59
|
+
for (const { valueString } of removedProps) {
|
|
60
|
+
parts.push(colorEnabled() ? (0, exports.strikeThrough)(valueString) : valueString);
|
|
61
|
+
}
|
|
62
|
+
for (const { valueString } of addedProps) {
|
|
63
|
+
parts.push(valueString);
|
|
64
|
+
}
|
|
65
|
+
if (parts.length === 0) {
|
|
66
|
+
return '';
|
|
67
|
+
}
|
|
68
|
+
return `, ${parts.join(', ')}`;
|
|
69
|
+
};
|
|
70
|
+
const formatPropChange = ({ key, oldValueString, newValueString, defaultValueString, removedProps, addedProps, }) => {
|
|
71
|
+
const suffix = formatSideProps({ removedProps, addedProps });
|
|
55
72
|
if (!colorEnabled()) {
|
|
56
73
|
const dotIdx = key.indexOf('.');
|
|
57
74
|
if (dotIdx === -1) {
|
|
58
|
-
return `${key}={${oldValueString}} \u2192 ${key}={${newValueString}}`;
|
|
75
|
+
return `${key}={${oldValueString}} \u2192 ${key}={${newValueString}}${suffix}`;
|
|
59
76
|
}
|
|
60
77
|
const parent = key.slice(0, dotIdx);
|
|
61
78
|
const child = key.slice(dotIdx + 1);
|
|
62
|
-
return `${parent}={{${child}: ${oldValueString}}} \u2192 ${parent}={{${child}: ${newValueString}}}`;
|
|
79
|
+
return `${parent}={{${child}: ${oldValueString}}} \u2192 ${parent}={{${child}: ${newValueString}}}${suffix}`;
|
|
63
80
|
}
|
|
64
|
-
const isResetToDefault = defaultValueString !== null && newValueString === defaultValueString;
|
|
65
|
-
const isChangeFromDefault = defaultValueString !== null && oldValueString === defaultValueString;
|
|
66
81
|
const dotIndex = key.indexOf('.');
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return addedBg(formatSimpleProp(key, newValueString));
|
|
73
|
-
}
|
|
74
|
-
return `${removedBg(formatSimpleProp(key, oldValueString))} \u2192 ${addedBg(formatSimpleProp(key, newValueString))}`;
|
|
75
|
-
}
|
|
76
|
-
const parentKey = key.slice(0, dotIndex);
|
|
77
|
-
const childKey = key.slice(dotIndex + 1);
|
|
78
|
-
if (isResetToDefault) {
|
|
79
|
-
return removedBg(formatNestedProp(parentKey, childKey, oldValueString));
|
|
82
|
+
const formatProp = (value) => dotIndex === -1
|
|
83
|
+
? formatSimpleProp(key, value)
|
|
84
|
+
: formatNestedProp(key.slice(0, dotIndex), key.slice(dotIndex + 1), value);
|
|
85
|
+
if (defaultValueString !== null && newValueString === defaultValueString) {
|
|
86
|
+
return `${(0, exports.strikeThrough)(formatProp(oldValueString))}${suffix}`;
|
|
80
87
|
}
|
|
81
|
-
if (
|
|
82
|
-
return
|
|
88
|
+
if (defaultValueString !== null && oldValueString === defaultValueString) {
|
|
89
|
+
return `${formatProp(newValueString)}${suffix}`;
|
|
83
90
|
}
|
|
84
|
-
return `${
|
|
91
|
+
return `${formatProp(oldValueString)} \u2192 ${formatProp(newValueString)}${suffix}`;
|
|
85
92
|
};
|
|
86
93
|
exports.formatPropChange = formatPropChange;
|
|
87
|
-
const logUpdate = ({ fileRelativeToRoot, line, key, oldValueString, newValueString, defaultValueString, formatted, logLevel, }) => {
|
|
94
|
+
const logUpdate = ({ fileRelativeToRoot, line, key, oldValueString, newValueString, defaultValueString, formatted, logLevel, removedProps, addedProps, }) => {
|
|
88
95
|
const locationLabel = `${fileRelativeToRoot}:${line}`;
|
|
89
96
|
const propChange = (0, exports.formatPropChange)({
|
|
90
97
|
key,
|
|
91
98
|
oldValueString: (0, exports.normalizeQuotes)(oldValueString),
|
|
92
99
|
newValueString: (0, exports.normalizeQuotes)(newValueString),
|
|
93
100
|
defaultValueString: defaultValueString !== null ? (0, exports.normalizeQuotes)(defaultValueString) : null,
|
|
101
|
+
removedProps,
|
|
102
|
+
addedProps,
|
|
94
103
|
});
|
|
95
104
|
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}:`)} ${propChange}`);
|
|
96
105
|
if (!formatted) {
|
|
@@ -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;
|
|
@@ -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,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;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type { SaveSequencePropsRequest
|
|
1
|
+
import type { SaveSequencePropsRequest } from '@remotion/studio-shared';
|
|
2
|
+
import type { CanUpdateSequencePropsResponse } from 'remotion';
|
|
2
3
|
import type { ApiHandler } from '../api-types';
|
|
3
|
-
export declare const saveSequencePropsHandler: ApiHandler<SaveSequencePropsRequest,
|
|
4
|
+
export declare const saveSequencePropsHandler: ApiHandler<SaveSequencePropsRequest, CanUpdateSequencePropsResponse>;
|
|
@@ -9,96 +9,91 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
9
9
|
const renderer_1 = require("@remotion/renderer");
|
|
10
10
|
const remotion_1 = require("remotion");
|
|
11
11
|
const get_all_schema_keys_1 = require("../../codemods/get-all-schema-keys");
|
|
12
|
-
const update_sequence_props_1 = require("../../codemods/update-sequence-props");
|
|
12
|
+
const update_sequence_props_1 = require("../../codemods/update-sequence-props/update-sequence-props");
|
|
13
13
|
const file_watcher_1 = require("../../file-watcher");
|
|
14
14
|
const undo_stack_1 = require("../undo-stack");
|
|
15
15
|
const watch_ignore_next_change_1 = require("../watch-ignore-next-change");
|
|
16
16
|
const can_update_sequence_props_1 = require("./can-update-sequence-props");
|
|
17
|
-
const
|
|
17
|
+
const format_prop_change_1 = require("./log-updates/format-prop-change");
|
|
18
|
+
const log_update_1 = require("./log-updates/log-update");
|
|
18
19
|
const saveSequencePropsHandler = async ({ input: { fileName, nodePath, key, value, defaultValue, schema }, remotionRoot, logLevel, }) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
throw new Error('Cannot modify a file outside the project');
|
|
25
|
-
}
|
|
26
|
-
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
27
|
-
const { output, oldValueStrings, formatted, logLine } = await (0, update_sequence_props_1.updateSequenceProps)({
|
|
28
|
-
input: fileContents,
|
|
29
|
-
nodePath,
|
|
30
|
-
updates: [
|
|
31
|
-
{
|
|
32
|
-
key,
|
|
33
|
-
value: JSON.parse(value),
|
|
34
|
-
defaultValue: defaultValue !== null ? JSON.parse(defaultValue) : null,
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
schema: remotion_1.Internals.sequenceSchema,
|
|
38
|
-
});
|
|
39
|
-
const oldValueString = oldValueStrings[0];
|
|
40
|
-
const newValueString = JSON.stringify(JSON.parse(value));
|
|
41
|
-
const parsedDefault = defaultValue !== null ? JSON.parse(defaultValue) : null;
|
|
42
|
-
const defaultValueString = parsedDefault !== null ? JSON.stringify(parsedDefault) : null;
|
|
43
|
-
const normalizedOld = (0, log_update_1.normalizeQuotes)(oldValueString);
|
|
44
|
-
const normalizedNew = (0, log_update_1.normalizeQuotes)(newValueString);
|
|
45
|
-
const normalizedDefault = defaultValueString !== null ? (0, log_update_1.normalizeQuotes)(defaultValueString) : null;
|
|
46
|
-
const undoPropChange = (0, log_update_1.formatPropChange)({
|
|
47
|
-
key,
|
|
48
|
-
oldValueString: normalizedNew,
|
|
49
|
-
newValueString: normalizedOld,
|
|
50
|
-
defaultValueString: normalizedDefault,
|
|
51
|
-
});
|
|
52
|
-
const redoPropChange = (0, log_update_1.formatPropChange)({
|
|
53
|
-
key,
|
|
54
|
-
oldValueString: normalizedOld,
|
|
55
|
-
newValueString: normalizedNew,
|
|
56
|
-
defaultValueString: normalizedDefault,
|
|
57
|
-
});
|
|
58
|
-
(0, undo_stack_1.pushToUndoStack)({
|
|
59
|
-
filePath: absolutePath,
|
|
60
|
-
oldContents: fileContents,
|
|
61
|
-
logLevel,
|
|
62
|
-
remotionRoot,
|
|
63
|
-
logLine,
|
|
64
|
-
description: {
|
|
65
|
-
undoMessage: `Undo: ${undoPropChange}`,
|
|
66
|
-
redoMessage: `Redo: ${redoPropChange}`,
|
|
67
|
-
},
|
|
68
|
-
entryType: 'sequence-props',
|
|
69
|
-
suppressHmrOnFileRestore: true,
|
|
70
|
-
});
|
|
71
|
-
(0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
|
|
72
|
-
(0, watch_ignore_next_change_1.suppressBundlerUpdateForFile)(absolutePath);
|
|
73
|
-
(0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output);
|
|
74
|
-
(0, log_update_1.logUpdate)({
|
|
75
|
-
fileRelativeToRoot,
|
|
76
|
-
line: logLine,
|
|
77
|
-
key,
|
|
78
|
-
oldValueString,
|
|
79
|
-
newValueString,
|
|
80
|
-
defaultValueString,
|
|
81
|
-
formatted,
|
|
82
|
-
logLevel,
|
|
83
|
-
});
|
|
84
|
-
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
85
|
-
const newStatus = (0, can_update_sequence_props_1.computeSequencePropsStatus)({
|
|
86
|
-
fileName,
|
|
87
|
-
keys: (0, get_all_schema_keys_1.getAllSchemaKeys)(schema),
|
|
88
|
-
nodePath,
|
|
89
|
-
remotionRoot,
|
|
90
|
-
});
|
|
91
|
-
return {
|
|
92
|
-
success: true,
|
|
93
|
-
newStatus,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
catch (err) {
|
|
97
|
-
return {
|
|
98
|
-
success: false,
|
|
99
|
-
reason: err.message,
|
|
100
|
-
stack: err.stack,
|
|
101
|
-
};
|
|
20
|
+
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[save-sequence-props] Received request for fileName="${fileName}" key="${key}"`);
|
|
21
|
+
const absolutePath = node_path_1.default.resolve(remotionRoot, fileName);
|
|
22
|
+
const fileRelativeToRoot = node_path_1.default.relative(remotionRoot, absolutePath);
|
|
23
|
+
if (fileRelativeToRoot.startsWith('..')) {
|
|
24
|
+
throw new Error('Cannot modify a file outside the project');
|
|
102
25
|
}
|
|
26
|
+
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
27
|
+
const { output, oldValueStrings, formatted, logLine, removedProps } = await (0, update_sequence_props_1.updateSequenceProps)({
|
|
28
|
+
input: fileContents,
|
|
29
|
+
nodePath,
|
|
30
|
+
updates: [
|
|
31
|
+
{
|
|
32
|
+
key,
|
|
33
|
+
value: JSON.parse(value),
|
|
34
|
+
defaultValue: defaultValue !== null ? JSON.parse(defaultValue) : null,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
schema: remotion_1.Internals.sequenceSchema,
|
|
38
|
+
});
|
|
39
|
+
const oldValueString = oldValueStrings[0];
|
|
40
|
+
const newValueString = JSON.stringify(JSON.parse(value));
|
|
41
|
+
const parsedDefault = defaultValue !== null ? JSON.parse(defaultValue) : null;
|
|
42
|
+
const defaultValueString = parsedDefault !== null ? JSON.stringify(parsedDefault) : null;
|
|
43
|
+
const normalizedOld = (0, log_update_1.normalizeQuotes)(oldValueString);
|
|
44
|
+
const normalizedNew = (0, log_update_1.normalizeQuotes)(newValueString);
|
|
45
|
+
const normalizedDefault = defaultValueString !== null ? (0, log_update_1.normalizeQuotes)(defaultValueString) : null;
|
|
46
|
+
const undoPropChange = (0, format_prop_change_1.formatPropChange)({
|
|
47
|
+
key,
|
|
48
|
+
oldValueString: normalizedNew,
|
|
49
|
+
newValueString: normalizedOld,
|
|
50
|
+
defaultValueString: normalizedDefault,
|
|
51
|
+
removedProps: [],
|
|
52
|
+
addedProps: removedProps,
|
|
53
|
+
});
|
|
54
|
+
const redoPropChange = (0, format_prop_change_1.formatPropChange)({
|
|
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: 'sequence-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_update_1.logUpdate)({
|
|
79
|
+
fileRelativeToRoot,
|
|
80
|
+
line: logLine,
|
|
81
|
+
key,
|
|
82
|
+
oldValueString,
|
|
83
|
+
newValueString,
|
|
84
|
+
defaultValueString,
|
|
85
|
+
formatted,
|
|
86
|
+
logLevel,
|
|
87
|
+
removedProps,
|
|
88
|
+
addedProps: [],
|
|
89
|
+
});
|
|
90
|
+
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
91
|
+
const newStatus = (0, can_update_sequence_props_1.computeSequencePropsStatus)({
|
|
92
|
+
fileName,
|
|
93
|
+
keys: (0, get_all_schema_keys_1.getAllSchemaKeys)(schema),
|
|
94
|
+
nodePath,
|
|
95
|
+
remotionRoot,
|
|
96
|
+
});
|
|
97
|
+
return newStatus;
|
|
103
98
|
};
|
|
104
99
|
exports.saveSequencePropsHandler = saveSequencePropsHandler;
|
|
@@ -10,7 +10,7 @@ const project_info_1 = require("../project-info");
|
|
|
10
10
|
const undo_stack_1 = require("../undo-stack");
|
|
11
11
|
const watch_ignore_next_change_1 = require("../watch-ignore-next-change");
|
|
12
12
|
const can_update_default_props_1 = require("./can-update-default-props");
|
|
13
|
-
const log_update_1 = require("./log-update");
|
|
13
|
+
const log_update_1 = require("./log-updates/log-update");
|
|
14
14
|
const updateDefaultPropsHandler = async ({ input: { compositionId, defaultProps, enumPaths }, remotionRoot, entryPoint, logLevel, }) => {
|
|
15
15
|
try {
|
|
16
16
|
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[update-default-props] Received request for compositionId="${compositionId}"`);
|
|
@@ -37,8 +37,8 @@ const updateDefaultPropsHandler = async ({ input: { compositionId, defaultProps,
|
|
|
37
37
|
remotionRoot,
|
|
38
38
|
logLine,
|
|
39
39
|
description: {
|
|
40
|
-
undoMessage:
|
|
41
|
-
redoMessage:
|
|
40
|
+
undoMessage: `↩️ default props update for "${compositionId}"`,
|
|
41
|
+
redoMessage: `↪️ default props update for "${compositionId}"`,
|
|
42
42
|
},
|
|
43
43
|
entryType: 'default-props',
|
|
44
44
|
suppressHmrOnFileRestore: true,
|
|
@@ -51,7 +51,7 @@ const updateDefaultPropsHandler = async ({ input: { compositionId, defaultProps,
|
|
|
51
51
|
absolutePath: projectInfo.rootFile,
|
|
52
52
|
line: logLine,
|
|
53
53
|
});
|
|
54
|
-
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}
|
|
54
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Updated default props for "${compositionId}"`);
|
|
55
55
|
if (!formatted) {
|
|
56
56
|
(0, log_update_1.warnAboutPrettierOnce)(logLevel);
|
|
57
57
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SubscribeToSequencePropsResponse } from '@remotion/studio-shared';
|
|
2
|
+
import type { SequenceNodePath } from 'remotion';
|
|
2
3
|
export declare const subscribeToSequencePropsWatchers: ({ fileName, line, column, keys, remotionRoot, clientId, }: {
|
|
3
4
|
fileName: string;
|
|
4
5
|
line: number;
|
|
@@ -6,7 +7,7 @@ export declare const subscribeToSequencePropsWatchers: ({ fileName, line, column
|
|
|
6
7
|
keys: string[];
|
|
7
8
|
remotionRoot: string;
|
|
8
9
|
clientId: string;
|
|
9
|
-
}) =>
|
|
10
|
+
}) => SubscribeToSequencePropsResponse;
|
|
10
11
|
export declare const unsubscribeFromSequencePropsWatchers: ({ fileName, nodePath, remotionRoot, clientId, }: {
|
|
11
12
|
fileName: string;
|
|
12
13
|
nodePath: SequenceNodePath;
|
|
@@ -24,15 +24,16 @@ const getSequencePropsStatus = ({ fileName, line, column, keys, remotionRoot, })
|
|
|
24
24
|
remotionRoot,
|
|
25
25
|
});
|
|
26
26
|
if (cachedResult.canUpdate) {
|
|
27
|
-
return cachedResult;
|
|
27
|
+
return { status: cachedResult, nodePath: cachedNodePath, success: true };
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
const status = (0, can_update_sequence_props_1.computeSequencePropsStatusFromFilenameByLine)({
|
|
31
31
|
fileName,
|
|
32
32
|
line,
|
|
33
33
|
keys,
|
|
34
34
|
remotionRoot,
|
|
35
35
|
});
|
|
36
|
+
return status;
|
|
36
37
|
};
|
|
37
38
|
const subscribeToSequencePropsWatchers = ({ fileName, line, column, keys, remotionRoot, clientId, }) => {
|
|
38
39
|
var _a;
|
|
@@ -43,7 +44,7 @@ const subscribeToSequencePropsWatchers = ({ fileName, line, column, keys, remoti
|
|
|
43
44
|
keys,
|
|
44
45
|
remotionRoot,
|
|
45
46
|
});
|
|
46
|
-
if (!initialResult.
|
|
47
|
+
if (!initialResult.success) {
|
|
47
48
|
return initialResult;
|
|
48
49
|
}
|
|
49
50
|
const absolutePath = node_path_1.default.resolve(remotionRoot, fileName);
|
|
@@ -23,7 +23,6 @@ export declare const startServer: (options: {
|
|
|
23
23
|
remotionRoot: string;
|
|
24
24
|
keyboardShortcutsEnabled: boolean;
|
|
25
25
|
experimentalClientSideRenderingEnabled: boolean;
|
|
26
|
-
experimentalVisualModeEnabled: boolean;
|
|
27
26
|
publicDir: string;
|
|
28
27
|
poll: number | null;
|
|
29
28
|
staticHash: string;
|
|
@@ -42,7 +42,6 @@ const startServer = async (options) => {
|
|
|
42
42
|
remotionRoot: options.remotionRoot,
|
|
43
43
|
keyboardShortcutsEnabled: options.keyboardShortcutsEnabled,
|
|
44
44
|
experimentalClientSideRenderingEnabled: options.experimentalClientSideRenderingEnabled,
|
|
45
|
-
experimentalVisualModeEnabled: options.experimentalVisualModeEnabled,
|
|
46
45
|
poll: options.poll,
|
|
47
46
|
bufferStateDelayInMilliseconds: options.bufferStateDelayInMilliseconds,
|
|
48
47
|
askAIEnabled: options.askAIEnabled,
|
|
@@ -175,7 +175,7 @@ function logFileAction(action, filePath, logLine) {
|
|
|
175
175
|
line: logLine,
|
|
176
176
|
})
|
|
177
177
|
: `${filePath}:${logLine}`;
|
|
178
|
-
renderer_1.RenderInternals.Log.info({ indent: false, logLevel: storedLogLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}
|
|
178
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel: storedLogLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} ${action}`);
|
|
179
179
|
}
|
|
180
180
|
function popUndo() {
|
|
181
181
|
const entry = undoStack.pop();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { WatchIgnoreNextChangePlugin } from '@remotion/bundler';
|
|
2
2
|
export declare const setWatchIgnoreNextChangePlugin: (plugin: WatchIgnoreNextChangePlugin) => void;
|
|
3
3
|
export declare const suppressBundlerUpdateForFile: (absolutePath: string) => void;
|
|
4
|
+
export declare const reloadPreviouslySuppressedFiles: () => Promise<void>;
|