@revideo/cli 0.3.7-beta.987 → 0.3.7-red.988
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/server/player.js +73 -136
- package/dist/server/render.js +3 -3
- package/package.json +4 -4
package/dist/server/player.js
CHANGED
|
@@ -1,91 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
-
if (
|
|
9
|
-
!desc ||
|
|
10
|
-
('get' in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
11
|
-
) {
|
|
12
|
-
desc = {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return m[k];
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}
|
|
21
|
-
: function (o, m, k, k2) {
|
|
22
|
-
if (k2 === undefined) k2 = k;
|
|
23
|
-
o[k2] = m[k];
|
|
24
|
-
});
|
|
25
|
-
var __setModuleDefault =
|
|
26
|
-
(this && this.__setModuleDefault) ||
|
|
27
|
-
(Object.create
|
|
28
|
-
? function (o, v) {
|
|
29
|
-
Object.defineProperty(o, 'default', {enumerable: true, value: v});
|
|
30
|
-
}
|
|
31
|
-
: function (o, v) {
|
|
32
|
-
o['default'] = v;
|
|
33
|
-
});
|
|
34
|
-
var __importStar =
|
|
35
|
-
(this && this.__importStar) ||
|
|
36
|
-
function (mod) {
|
|
37
|
-
if (mod && mod.__esModule) return mod;
|
|
38
|
-
var result = {};
|
|
39
|
-
if (mod != null)
|
|
40
|
-
for (var k in mod)
|
|
41
|
-
if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k))
|
|
42
|
-
__createBinding(result, mod, k);
|
|
43
|
-
__setModuleDefault(result, mod);
|
|
44
|
-
return result;
|
|
45
|
-
};
|
|
46
|
-
Object.defineProperty(exports, '__esModule', {value: true});
|
|
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 });
|
|
47
6
|
exports.player = exports.createHotReloader = exports.buildProject = void 0;
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const vite_1 = require(
|
|
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");
|
|
52
11
|
const YELLOW_DOT = '\u001b[33m•\u001b[0m';
|
|
53
12
|
const GREEN_CHECK = '\u001b[32m✔\u001b[0m';
|
|
54
13
|
const RED_CROSS = '\u001b[31m✘\u001b[0m';
|
|
55
|
-
const fileNotFoundMessage = filePath =>
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
padding,
|
|
60
|
-
' ',
|
|
61
|
-
) + '\n';
|
|
62
|
-
const fileChangedMessage = filePath =>
|
|
63
|
-
`${YELLOW_DOT} File ${filePath} has changed. Rebuilding...`;
|
|
64
|
-
const successMessage = (time, padding) =>
|
|
65
|
-
`\r${GREEN_CHECK} Project built successfully. ${time}ms`.padEnd(
|
|
66
|
-
padding,
|
|
67
|
-
' ',
|
|
68
|
-
) + '\n';
|
|
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';
|
|
69
18
|
async function buildProject() {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
19
|
+
try {
|
|
20
|
+
await (0, vite_1.build)({
|
|
21
|
+
configFile: false,
|
|
22
|
+
plugins: [(0, vite_plugin_1.default)()],
|
|
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
|
+
}
|
|
89
39
|
}
|
|
90
40
|
exports.buildProject = buildProject;
|
|
91
41
|
/**
|
|
@@ -93,62 +43,49 @@ exports.buildProject = buildProject;
|
|
|
93
43
|
* @param dir - Directory to watch for changes.
|
|
94
44
|
*/
|
|
95
45
|
async function createHotReloader(dir) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
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
|
+
});
|
|
115
62
|
}
|
|
116
63
|
exports.createHotReloader = createHotReloader;
|
|
117
64
|
async function player(req, res) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
65
|
+
const path = `./dist/${req.params.file}`;
|
|
66
|
+
let buildTime = undefined;
|
|
67
|
+
let error = false;
|
|
68
|
+
// Check if the file exists and build the project if it doesn't.
|
|
69
|
+
await fs_1.promises.access(path).catch(async () => {
|
|
70
|
+
buildTime = Date.now();
|
|
71
|
+
process.stdout.write(fileNotFoundMessage(path));
|
|
72
|
+
await buildProject().catch(() => {
|
|
73
|
+
res.status(500).send('Error building project');
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
// If the file still doesn't exist, send an error response.
|
|
77
|
+
await fs_1.promises.access(path).catch(() => {
|
|
78
|
+
process.stdout.write(fileNotFoundAfterBuildingMessage(path, fileNotFoundMessage(path).length + 1));
|
|
79
|
+
res.status(404).send(`File ${path} not found`);
|
|
80
|
+
error = true;
|
|
127
81
|
});
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
path
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
);
|
|
137
|
-
res.status(404).send(`File ${path} not found`);
|
|
138
|
-
error = true;
|
|
139
|
-
});
|
|
140
|
-
if (error) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
// If we built the project, update the log message.
|
|
144
|
-
if (buildTime) {
|
|
145
|
-
process.stdout.write(
|
|
146
|
-
successMessage(
|
|
147
|
-
Date.now() - buildTime,
|
|
148
|
-
fileNotFoundMessage(path).length + 1,
|
|
149
|
-
),
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
return res.sendFile(path, {root: './'});
|
|
82
|
+
if (error) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// If we built the project, update the log message.
|
|
86
|
+
if (buildTime) {
|
|
87
|
+
process.stdout.write(successMessage(Date.now() - buildTime, fileNotFoundMessage(path).length + 1));
|
|
88
|
+
}
|
|
89
|
+
return res.sendFile(path, { root: './' });
|
|
153
90
|
}
|
|
154
91
|
exports.player = player;
|
package/dist/server/render.js
CHANGED
|
@@ -68,7 +68,7 @@ async function renderWithoutCallback(req, res) {
|
|
|
68
68
|
// TODO: validate request body
|
|
69
69
|
const { variables, streamProgress, settings } = req.body;
|
|
70
70
|
const tempProjectName = `${(0, uuid_1.v4)()}.mp4`;
|
|
71
|
-
const resultFilePath = path_1.default.join(process.cwd(), `output/${tempProjectName}
|
|
71
|
+
const resultFilePath = path_1.default.join(process.cwd(), `output/${tempProjectName}`);
|
|
72
72
|
if (streamProgress) {
|
|
73
73
|
res.writeHead(200, {
|
|
74
74
|
// eslint-disable-next-line
|
|
@@ -92,7 +92,7 @@ async function renderWithoutCallback(req, res) {
|
|
|
92
92
|
progressCallback: sendProgress,
|
|
93
93
|
},
|
|
94
94
|
});
|
|
95
|
-
const downloadLink = `${req.protocol}://${req.get('host')}/download/${tempProjectName}
|
|
95
|
+
const downloadLink = `${req.protocol}://${req.get('host')}/download/${tempProjectName}`;
|
|
96
96
|
res.write(`event: completed\n`);
|
|
97
97
|
res.write(`data: ${JSON.stringify({ status: 'success', downloadLink })}\n\n`);
|
|
98
98
|
res.end();
|
|
@@ -115,7 +115,7 @@ async function renderWithoutCallback(req, res) {
|
|
|
115
115
|
outFile: tempProjectName,
|
|
116
116
|
},
|
|
117
117
|
});
|
|
118
|
-
const downloadLink = `${req.protocol}://${req.get('host')}/download/${tempProjectName}
|
|
118
|
+
const downloadLink = `${req.protocol}://${req.get('host')}/download/${tempProjectName}`;
|
|
119
119
|
res.json({
|
|
120
120
|
status: 'success',
|
|
121
121
|
downloadLink: downloadLink,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revideo/cli",
|
|
3
|
-
"version": "0.3.7-
|
|
3
|
+
"version": "0.3.7-red.988+3bfa488",
|
|
4
4
|
"description": "A CLI for revideo",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "revideo",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"typescript": "^5.4.3"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@revideo/renderer": "^0.3.7-
|
|
29
|
-
"@revideo/telemetry": "^0.3.7-
|
|
28
|
+
"@revideo/renderer": "^0.3.7-red.988+3bfa488",
|
|
29
|
+
"@revideo/telemetry": "^0.3.7-red.988+3bfa488",
|
|
30
30
|
"chokidar": "^3.5.3",
|
|
31
31
|
"commander": "^12.0.0",
|
|
32
32
|
"cors": "^2.8.5",
|
|
33
33
|
"express": "^4.19.2",
|
|
34
34
|
"uuid": "^9.0.1"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "3bfa488e0c9aec2e5344650fc8d6df959a668a4c"
|
|
37
37
|
}
|