@revideo/cli 0.5.10 → 0.5.11-alpha.1101

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/editor.js ADDED
@@ -0,0 +1,31 @@
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.launchEditor = launchEditor;
7
+ const vite_plugin_1 = __importDefault(require("@revideo/vite-plugin"));
8
+ const vite_1 = require("vite");
9
+ async function launchEditor(projectPath, port) {
10
+ const server = await (0, vite_1.createServer)({
11
+ configFile: false,
12
+ plugins: [
13
+ (0, vite_plugin_1.default)({
14
+ project: projectPath,
15
+ buildForEditor: false,
16
+ }),
17
+ ],
18
+ build: {
19
+ minify: false,
20
+ rollupOptions: {
21
+ output: {
22
+ entryFileNames: '[name].js',
23
+ },
24
+ },
25
+ },
26
+ server: {
27
+ port: parseInt(port),
28
+ },
29
+ });
30
+ return server.listen();
31
+ }
package/dist/index.js CHANGED
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const telemetry_1 = require("@revideo/telemetry");
5
5
  const commander_1 = require("commander");
6
+ const editor_1 = require("./editor");
6
7
  const index_1 = require("./server/index");
7
- const player_1 = require("./server/player");
8
8
  const program = new commander_1.Command();
9
9
  program
10
10
  .name('revideo')
@@ -12,22 +12,26 @@ program
12
12
  .version('0.5.10');
13
13
  program
14
14
  .command('serve')
15
- .description('UNSTABLE (still WIP): Start the revideo server in development mode. Watches for changes ' +
16
- 'in the project directory and re-builds the player on each change.')
15
+ .description('Exposes a render endpoint to render videos from a project file. Automatically rebuilds the project when the project file changes. Use for local development.')
17
16
  .option('--projectFile <path>', 'Path to the project file', './src/project.ts')
18
17
  .option('--port <number>', 'Port on which to start the server', '4000')
19
- .option('--watchDir <path>', 'Directory to watch for changes', 'src')
20
18
  .action(async (options) => {
21
19
  (0, telemetry_1.sendEvent)(telemetry_1.EventName.CLICommand);
22
20
  const { projectFile, port } = options;
23
21
  process.env.PROJECT_FILE = projectFile;
24
22
  process.env.REVIDEO_PORT = port;
25
- await (0, player_1.buildProject)().catch(() => {
26
- process.exit(1);
27
- });
28
- (0, index_1.createServer)(options.watchDir).listen(port, () => {
23
+ (0, index_1.createServer)().listen(port, () => {
29
24
  console.log(`Server listening on port ${port}`);
30
25
  console.log();
31
26
  });
32
27
  });
28
+ program
29
+ .command('editor')
30
+ .description('Start the revideo editor')
31
+ .option('--projectFile <path>', 'Path to the project file', './src/project.ts')
32
+ .option('--port <number>', 'Port on which to start the server', '9000')
33
+ .action(async (options) => {
34
+ await (0, editor_1.launchEditor)(options.projectFile, options.port);
35
+ console.log(`Editor running on port ${options.port}`);
36
+ });
33
37
  program.parse(process.argv);
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.download = void 0;
6
+ exports.download = download;
7
7
  const fs_1 = require("fs");
8
8
  const path_1 = __importDefault(require("path"));
9
9
  async function download(req, res) {
@@ -23,4 +23,3 @@ async function download(req, res) {
23
23
  res.status(404).send('File not found.');
24
24
  }
25
25
  }
26
- exports.download = download;
@@ -3,22 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createServer = void 0;
6
+ exports.createServer = createServer;
7
7
  const cors_1 = __importDefault(require("cors"));
8
8
  const express_1 = __importDefault(require("express"));
9
9
  const download_1 = require("./download");
10
- const player_1 = require("./player");
11
10
  const render_1 = require("./render");
12
- function createServer(hotReloadDir) {
11
+ function createServer() {
13
12
  const app = (0, express_1.default)();
14
13
  app.use(express_1.default.json({ limit: '50mb' }));
15
14
  app.use((0, cors_1.default)());
16
15
  app.post('/render', render_1.render);
17
16
  app.get('/download/:projectName', download_1.download);
18
- app.get('/player/*', player_1.player);
19
- if (hotReloadDir) {
20
- (0, player_1.createHotReloader)(hotReloadDir);
21
- }
22
17
  return app;
23
18
  }
24
- exports.createServer = createServer;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.render = void 0;
6
+ exports.render = render;
7
7
  const renderer_1 = require("@revideo/renderer");
8
8
  const axios_1 = __importDefault(require("axios"));
9
9
  const path_1 = __importDefault(require("path"));
@@ -18,7 +18,6 @@ async function render(req, res) {
18
18
  await renderWithoutCallback(req, res);
19
19
  }
20
20
  }
21
- exports.render = render;
22
21
  async function renderWithCallback(req, res) {
23
22
  // TODO: validate request body
24
23
  const { variables, callbackUrl, settings } = req.body;
package/dist/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.scheduleCleanup = void 0;
3
+ exports.scheduleCleanup = scheduleCleanup;
4
4
  const fs_1 = require("fs");
5
5
  function scheduleCleanup(filePath) {
6
6
  const clean = async () => {
@@ -15,4 +15,3 @@ function scheduleCleanup(filePath) {
15
15
  // Wait 10 minutes before removing file.
16
16
  setTimeout(clean, 10 * 60 * 1000);
17
17
  }
18
- exports.scheduleCleanup = scheduleCleanup;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revideo/cli",
3
- "version": "0.5.10",
3
+ "version": "0.5.11-alpha.1101+8fb1cafb",
4
4
  "description": "A CLI for revideo",
5
5
  "main": "dist/index.js",
6
6
  "author": "revideo",
@@ -25,13 +25,14 @@
25
25
  "typescript": "^5.4.3"
26
26
  },
27
27
  "dependencies": {
28
- "@revideo/renderer": "0.5.10",
29
- "@revideo/telemetry": "0.5.10",
28
+ "@revideo/renderer": "^0.5.11-alpha.1101+8fb1cafb",
29
+ "@revideo/telemetry": "^0.5.11-alpha.1101+8fb1cafb",
30
+ "@revideo/vite-plugin": "^0.5.11-alpha.1101+8fb1cafb",
30
31
  "chokidar": "^3.5.3",
31
32
  "commander": "^12.0.0",
32
33
  "cors": "^2.8.5",
33
34
  "express": "^4.19.2",
34
35
  "uuid": "^9.0.1"
35
36
  },
36
- "gitHead": "56d48446d0f2dd2146bf594516b880b38a6e36a9"
37
+ "gitHead": "8fb1cafbd57314a83ad8a7adaf425f0804a039ff"
37
38
  }
@@ -1,98 +0,0 @@
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.player = exports.createHotReloader = exports.buildProject = void 0;
7
- const vite_plugin_1 = __importDefault(require("@revideo/vite-plugin"));
8
- const chokidar_1 = require("chokidar");
9
- const fs_1 = require("fs");
10
- const vite_1 = require("vite");
11
- const YELLOW_DOT = '\u001b[33m•\u001b[0m';
12
- const GREEN_CHECK = '\u001b[32m✔\u001b[0m';
13
- const RED_CROSS = '\u001b[31m✘\u001b[0m';
14
- const fileNotFoundMessage = (filePath) => `${YELLOW_DOT} File ${filePath} not found. Building project...`;
15
- const fileNotFoundAfterBuildingMessage = (filePath, padding) => `\r${RED_CROSS} File ${filePath} still not found after building project...`.padEnd(padding, ' ') + '\n';
16
- const fileChangedMessage = (filePath) => `${YELLOW_DOT} File ${filePath} has changed. Rebuilding...`;
17
- const successMessage = (time, padding) => `\r${GREEN_CHECK} Project built successfully. ${time}ms`.padEnd(padding, ' ') + '\n';
18
- async function buildProject() {
19
- try {
20
- await (0, vite_1.build)({
21
- configFile: false,
22
- plugins: [(0, vite_plugin_1.default)({ project: process.env.PROJECT_FILE })],
23
- build: {
24
- outDir: 'dist',
25
- rollupOptions: {
26
- output: {
27
- entryFileNames: '[name].js',
28
- chunkFileNames: '[name].js',
29
- assetFileNames: '[name].[ext]',
30
- },
31
- },
32
- },
33
- });
34
- }
35
- catch (error) {
36
- console.error('Error building project:', error);
37
- throw error;
38
- }
39
- }
40
- exports.buildProject = buildProject;
41
- /**
42
- * Watches the given directory for changes and rebuilds the project on each change.
43
- * @param dir - Directory to watch for changes.
44
- */
45
- async function createHotReloader(dir) {
46
- const watcher = (0, chokidar_1.watch)(dir, {
47
- ignored: ['**/*.meta'],
48
- });
49
- watcher.on('change', async (path) => {
50
- const rebuildingMessage = fileChangedMessage(path);
51
- process.stdout.write(rebuildingMessage);
52
- const start = Date.now();
53
- try {
54
- await buildProject();
55
- process.stdout.write(successMessage(Date.now() - start, rebuildingMessage.length + 1));
56
- }
57
- catch (e) {
58
- // TODO: Add more detailed error message
59
- console.error('Error building project. Try to run `npm run build` manually and check for errors.');
60
- }
61
- });
62
- }
63
- exports.createHotReloader = createHotReloader;
64
- async function player(req, res) {
65
- let path = `./dist/${req.params[0]}`;
66
- if (req.params[0] === 'project.js') {
67
- const playerFileName = (process.env.PROJECT_FILE ?? '')
68
- .split('/')
69
- .pop()
70
- ?.replace('.ts', '.js');
71
- path = `./dist/${playerFileName}`;
72
- }
73
- let buildTime = undefined;
74
- let error = false;
75
- // Check if the file exists and build the project if it doesn't.
76
- await fs_1.promises.access(path).catch(async () => {
77
- buildTime = Date.now();
78
- process.stdout.write(fileNotFoundMessage(path));
79
- await buildProject().catch(() => {
80
- res.status(500).send('Error building project');
81
- });
82
- });
83
- // If the file still doesn't exist, send an error response.
84
- await fs_1.promises.access(path).catch(() => {
85
- process.stdout.write(fileNotFoundAfterBuildingMessage(path, fileNotFoundMessage(path).length + 1));
86
- res.status(404).send(`File ${path} not found`);
87
- error = true;
88
- });
89
- if (error) {
90
- return;
91
- }
92
- // If we built the project, update the log message.
93
- if (buildTime) {
94
- process.stdout.write(successMessage(Date.now() - buildTime, fileNotFoundMessage(path).length + 1));
95
- }
96
- return res.sendFile(path, { root: './' });
97
- }
98
- exports.player = player;