@remotion/studio-server 4.0.430 → 4.0.431
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/apply-component-visual-control.d.ts +8 -0
- package/dist/codemods/apply-component-visual-control.js +92 -0
- package/dist/preview-server/routes/apply-component-visual-control-change.d.ts +3 -0
- package/dist/preview-server/routes/apply-component-visual-control-change.js +38 -0
- package/package.json +6 -6
- package/dist/preview-server/__tests__/multiple-lockfiles.test.d.ts +0 -1
- package/dist/preview-server/__tests__/multiple-lockfiles.test.js +0 -64
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { File } from '@babel/types';
|
|
2
|
+
import { type ApplyComponentVisualControlCodemod } from '@remotion/studio-shared';
|
|
3
|
+
import type { ApplyCodeModReturnType, Change } from './recast-mods';
|
|
4
|
+
export declare const applyComponentVisualControl: ({ file, transformation, changesMade, }: {
|
|
5
|
+
file: File;
|
|
6
|
+
transformation: ApplyComponentVisualControlCodemod;
|
|
7
|
+
changesMade: Change[];
|
|
8
|
+
}) => ApplyCodeModReturnType;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.applyComponentVisualControl = void 0;
|
|
37
|
+
const studio_shared_1 = require("@remotion/studio-shared");
|
|
38
|
+
const recast = __importStar(require("recast"));
|
|
39
|
+
const parse_ast_1 = require("./parse-ast");
|
|
40
|
+
const applyComponentVisualControl = ({ file, transformation, changesMade, }) => {
|
|
41
|
+
recast.types.visit(file.program, {
|
|
42
|
+
visitJSXOpeningElement(path) {
|
|
43
|
+
var _a;
|
|
44
|
+
const { node } = path;
|
|
45
|
+
if (node.name.type !== 'JSXIdentifier' ||
|
|
46
|
+
node.name.name !== transformation.componentName) {
|
|
47
|
+
return this.traverse(path);
|
|
48
|
+
}
|
|
49
|
+
if (((_a = node.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== transformation.line) {
|
|
50
|
+
return this.traverse(path);
|
|
51
|
+
}
|
|
52
|
+
const attributes = node.attributes;
|
|
53
|
+
if (!attributes) {
|
|
54
|
+
return this.traverse(path);
|
|
55
|
+
}
|
|
56
|
+
for (const change of transformation.changes) {
|
|
57
|
+
const parsed = (0, parse_ast_1.parseAst)(`a = ${(0, studio_shared_1.stringifyDefaultProps)({ props: JSON.parse(change.newValueSerialized), enumPaths: change.enumPaths })}`).program.body[0].expression.right;
|
|
58
|
+
const existingAttr = attributes.find((attr) => attr.type === 'JSXAttribute' &&
|
|
59
|
+
attr.name.type === 'JSXIdentifier' &&
|
|
60
|
+
attr.name.name === change.propName);
|
|
61
|
+
if (existingAttr && existingAttr.type === 'JSXAttribute') {
|
|
62
|
+
existingAttr.value = {
|
|
63
|
+
type: 'JSXExpressionContainer',
|
|
64
|
+
expression: parsed,
|
|
65
|
+
};
|
|
66
|
+
changesMade.push({
|
|
67
|
+
description: `Updated prop ${change.propName} on ${transformation.componentName}`,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
attributes.push({
|
|
72
|
+
type: 'JSXAttribute',
|
|
73
|
+
name: {
|
|
74
|
+
type: 'JSXIdentifier',
|
|
75
|
+
name: change.propName,
|
|
76
|
+
},
|
|
77
|
+
value: {
|
|
78
|
+
type: 'JSXExpressionContainer',
|
|
79
|
+
expression: parsed,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
changesMade.push({
|
|
83
|
+
description: `Added prop ${change.propName} to ${transformation.componentName}`,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
return { newAst: file, changesMade };
|
|
91
|
+
};
|
|
92
|
+
exports.applyComponentVisualControl = applyComponentVisualControl;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ApplyComponentVisualControlRequest, ApplyComponentVisualControlResponse } from '@remotion/studio-shared';
|
|
2
|
+
import type { ApiHandler } from '../api-types';
|
|
3
|
+
export declare const applyComponentVisualControlHandler: ApiHandler<ApplyComponentVisualControlRequest, ApplyComponentVisualControlResponse>;
|
|
@@ -0,0 +1,38 @@
|
|
|
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.applyComponentVisualControlHandler = void 0;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const parse_ast_1 = require("../../codemods/parse-ast");
|
|
10
|
+
const recast_mods_1 = require("../../codemods/recast-mods");
|
|
11
|
+
const applyComponentVisualControlHandler = ({ input: { fileName, componentName, line, column, changes }, remotionRoot }) => {
|
|
12
|
+
const absolutePath = node_path_1.default.resolve(remotionRoot, fileName);
|
|
13
|
+
const fileRelativeToRoot = node_path_1.default.relative(remotionRoot, absolutePath);
|
|
14
|
+
if (fileRelativeToRoot.startsWith('..')) {
|
|
15
|
+
throw new Error('Cannot apply component visual control change to a file outside the project');
|
|
16
|
+
}
|
|
17
|
+
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
18
|
+
const ast = (0, parse_ast_1.parseAst)(fileContents);
|
|
19
|
+
const { newAst, changesMade } = (0, recast_mods_1.applyCodemod)({
|
|
20
|
+
file: ast,
|
|
21
|
+
codeMod: {
|
|
22
|
+
type: 'apply-component-visual-control',
|
|
23
|
+
componentName,
|
|
24
|
+
line,
|
|
25
|
+
column,
|
|
26
|
+
changes,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
if (changesMade.length === 0) {
|
|
30
|
+
throw new Error('No changes were made to the file');
|
|
31
|
+
}
|
|
32
|
+
const output = (0, parse_ast_1.serializeAst)(newAst);
|
|
33
|
+
(0, node_fs_1.writeFileSync)(absolutePath, output);
|
|
34
|
+
return Promise.resolve({
|
|
35
|
+
success: true,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
exports.applyComponentVisualControlHandler = applyComponentVisualControlHandler;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/studio-server"
|
|
4
4
|
},
|
|
5
5
|
"name": "@remotion/studio-server",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.431",
|
|
7
7
|
"description": "Run a Remotion Studio with a server backend",
|
|
8
8
|
"main": "dist",
|
|
9
9
|
"sideEffects": false,
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"@babel/parser": "7.24.1",
|
|
28
28
|
"semver": "7.5.3",
|
|
29
29
|
"prettier": "3.8.1",
|
|
30
|
-
"remotion": "4.0.
|
|
30
|
+
"remotion": "4.0.431",
|
|
31
31
|
"recast": "0.23.11",
|
|
32
|
-
"@remotion/bundler": "4.0.
|
|
33
|
-
"@remotion/renderer": "4.0.
|
|
34
|
-
"@remotion/studio-shared": "4.0.
|
|
32
|
+
"@remotion/bundler": "4.0.431",
|
|
33
|
+
"@remotion/renderer": "4.0.431",
|
|
34
|
+
"@remotion/studio-shared": "4.0.431",
|
|
35
35
|
"memfs": "3.4.3",
|
|
36
36
|
"source-map": "0.7.3",
|
|
37
37
|
"open": "^8.4.2"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"react": "19.2.3",
|
|
42
42
|
"@babel/types": "7.24.0",
|
|
43
43
|
"@types/semver": "^7.3.4",
|
|
44
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
44
|
+
"@remotion/eslint-config-internal": "4.0.431",
|
|
45
45
|
"eslint": "9.19.0",
|
|
46
46
|
"@types/node": "20.12.14",
|
|
47
47
|
"@typescript/native-preview": "7.0.0-dev.20260217.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __importDefault =
|
|
3
|
-
(this && this.__importDefault) ||
|
|
4
|
-
function (mod) {
|
|
5
|
-
return mod && mod.__esModule ? mod : {default: mod};
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, '__esModule', {value: true});
|
|
8
|
-
const bun_test_1 = require('bun:test');
|
|
9
|
-
const node_fs_1 = __importDefault(require('node:fs'));
|
|
10
|
-
const node_os_1 = __importDefault(require('node:os'));
|
|
11
|
-
const node_path_1 = __importDefault(require('node:path'));
|
|
12
|
-
const get_package_manager_1 = require('../get-package-manager');
|
|
13
|
-
(0, bun_test_1.describe)('getPackageManager multiple lockfiles', () => {
|
|
14
|
-
let tempDir;
|
|
15
|
-
(0, bun_test_1.beforeEach)(() => {
|
|
16
|
-
tempDir = node_fs_1.default.mkdtempSync(
|
|
17
|
-
node_path_1.default.join(node_os_1.default.tmpdir(), 'remotion-test-'),
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
(0, bun_test_1.afterEach)(() => {
|
|
21
|
-
node_fs_1.default.rmSync(tempDir, {recursive: true, force: true});
|
|
22
|
-
});
|
|
23
|
-
(0, bun_test_1.test)(
|
|
24
|
-
'should not throw error when multiple lockfiles are detected',
|
|
25
|
-
() => {
|
|
26
|
-
node_fs_1.default.writeFileSync(
|
|
27
|
-
node_path_1.default.join(tempDir, 'package-lock.json'),
|
|
28
|
-
'{}',
|
|
29
|
-
);
|
|
30
|
-
node_fs_1.default.writeFileSync(
|
|
31
|
-
node_path_1.default.join(tempDir, 'bun.lock'),
|
|
32
|
-
'',
|
|
33
|
-
);
|
|
34
|
-
// Should not throw
|
|
35
|
-
const manager = (0, get_package_manager_1.getPackageManager)(
|
|
36
|
-
tempDir,
|
|
37
|
-
undefined,
|
|
38
|
-
0,
|
|
39
|
-
);
|
|
40
|
-
// Should return one of them (usually the first one in the list, which is npm)
|
|
41
|
-
(0, bun_test_1.expect)(manager).not.toBe('unknown');
|
|
42
|
-
if (typeof manager !== 'string') {
|
|
43
|
-
(0, bun_test_1.expect)(['npm', 'bun']).toContain(manager.manager);
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
);
|
|
47
|
-
(0, bun_test_1.test)(
|
|
48
|
-
'should return npm if only package-lock.json exists',
|
|
49
|
-
() => {
|
|
50
|
-
node_fs_1.default.writeFileSync(
|
|
51
|
-
node_path_1.default.join(tempDir, 'package-lock.json'),
|
|
52
|
-
'{}',
|
|
53
|
-
);
|
|
54
|
-
const manager = (0, get_package_manager_1.getPackageManager)(
|
|
55
|
-
tempDir,
|
|
56
|
-
undefined,
|
|
57
|
-
0,
|
|
58
|
-
);
|
|
59
|
-
if (typeof manager !== 'string') {
|
|
60
|
-
(0, bun_test_1.expect)(manager.manager).toBe('npm');
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
);
|
|
64
|
-
});
|