@revideo/vite-plugin 0.4.7-alpha.1027 → 0.4.7-five.1022
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/lib/index.js +40 -22
- package/lib/openInExplorer.js +38 -39
- package/lib/partials/assets.d.ts +5 -3
- package/lib/partials/assets.js +49 -46
- package/lib/partials/corsProxy.d.ts +24 -22
- package/lib/partials/corsProxy.js +175 -151
- package/lib/partials/editor.d.ts +8 -5
- package/lib/partials/editor.js +65 -58
- package/lib/partials/ffmpegExporter.d.ts +25 -0
- package/lib/partials/ffmpegExporter.js +132 -0
- package/lib/partials/ffmpegExporter.js.map +1 -0
- package/lib/partials/imageExporter.d.ts +5 -3
- package/lib/partials/imageExporter.js +54 -42
- package/lib/partials/meta.d.ts +1 -1
- package/lib/partials/meta.js +61 -52
- package/lib/partials/metrics.d.ts +1 -1
- package/lib/partials/metrics.js +10 -10
- package/lib/partials/projects.d.ts +11 -7
- package/lib/partials/projects.js +73 -69
- package/lib/partials/scenes.d.ts +1 -1
- package/lib/partials/scenes.js +25 -23
- package/lib/partials/settings.d.ts +1 -1
- package/lib/partials/settings.js +67 -62
- package/lib/partials/webgl.d.ts +7 -7
- package/lib/partials/webgl.js +87 -79
- package/lib/plugins.d.ts +76 -76
- package/lib/plugins.js +4 -4
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils.d.ts +3 -3
- package/lib/utils.js +47 -40
- package/lib/versions.d.ts +4 -4
- package/lib/versions.js +28 -23
- package/package.json +4 -4
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FFmpegBridge = exports.ffmpegExporterPlugin = void 0;
|
|
4
|
+
const ffmpeg_1 = require("@revideo/ffmpeg");
|
|
5
|
+
function ffmpegExporterPlugin({ output }) {
|
|
6
|
+
return {
|
|
7
|
+
name: 'revideo/ffmpeg',
|
|
8
|
+
configureServer(server) {
|
|
9
|
+
new FFmpegBridge(server.ws, { output });
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
exports.ffmpegExporterPlugin = ffmpegExporterPlugin;
|
|
14
|
+
/**
|
|
15
|
+
* A simple bridge between the FFmpegExporterServer and FFmpegExporterClient.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* This class lets the client exporter invoke methods on the server and receive
|
|
19
|
+
* responses using a simple Promise-based API.
|
|
20
|
+
*/
|
|
21
|
+
class FFmpegBridge {
|
|
22
|
+
constructor(ws, config) {
|
|
23
|
+
this.ws = ws;
|
|
24
|
+
this.config = config;
|
|
25
|
+
this.process = null;
|
|
26
|
+
this.handleMessage = async ({ method, data }) => {
|
|
27
|
+
if (method === 'start') {
|
|
28
|
+
try {
|
|
29
|
+
this.process = new ffmpeg_1.FFmpegExporterServer({
|
|
30
|
+
...data,
|
|
31
|
+
...this.config,
|
|
32
|
+
});
|
|
33
|
+
this.respondSuccess(method, await this.process.start());
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
this.respondError(method, e?.message);
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!this.process) {
|
|
41
|
+
this.respondError(method, 'The exporting process has not been started.');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!(method in this.process)) {
|
|
45
|
+
this.respondError(method, `Unknown method: "${method}".`);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
this.respondSuccess(method, await this.process[method](data));
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
this.respondError(method, e?.message);
|
|
53
|
+
}
|
|
54
|
+
if (method === 'kill') {
|
|
55
|
+
this.process = null;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
// List of VideoFrameExtractors
|
|
60
|
+
this.videoFrameExtractors = new Map();
|
|
61
|
+
this.handleVideoFrameMessage = async ({ data }) => {
|
|
62
|
+
const typedData = data;
|
|
63
|
+
// Check if we already have a VideoFrameExtractor for this video
|
|
64
|
+
const id = typedData.filePath + '-' + typedData.id;
|
|
65
|
+
let extractor = this.videoFrameExtractors.get(id);
|
|
66
|
+
const frameDuration = 1 / typedData.fps;
|
|
67
|
+
const isOldFrame = extractor &&
|
|
68
|
+
Math.abs(typedData.startTime - extractor.getLastTime()) <
|
|
69
|
+
frameDuration / 2;
|
|
70
|
+
// If time has not changed, return the last frame
|
|
71
|
+
if (isOldFrame) {
|
|
72
|
+
const frame = extractor.getLastFrame();
|
|
73
|
+
this.ws.send('revideo:ffmpeg-video-frame-res', {
|
|
74
|
+
status: 'success',
|
|
75
|
+
data: {
|
|
76
|
+
frame,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
// If the video has skipped back we need to create a new extractor
|
|
82
|
+
if (extractor &&
|
|
83
|
+
typedData.startTime + frameDuration < extractor.getTime()) {
|
|
84
|
+
extractor.destroy();
|
|
85
|
+
this.videoFrameExtractors.delete(id);
|
|
86
|
+
extractor = undefined;
|
|
87
|
+
}
|
|
88
|
+
// If the video has skipped forward we need to create a new extractor
|
|
89
|
+
if (extractor &&
|
|
90
|
+
typedData.startTime > extractor.getTime() + frameDuration) {
|
|
91
|
+
extractor.destroy();
|
|
92
|
+
this.videoFrameExtractors.delete(id);
|
|
93
|
+
extractor = undefined;
|
|
94
|
+
}
|
|
95
|
+
if (!extractor) {
|
|
96
|
+
extractor = new ffmpeg_1.VideoFrameExtractor(typedData.filePath, typedData.startTime, typedData.fps, typedData.duration, typedData.png);
|
|
97
|
+
this.videoFrameExtractors.set(id, extractor);
|
|
98
|
+
}
|
|
99
|
+
// Go to the frame that is closest to the requested time
|
|
100
|
+
const frame = await extractor.popImage();
|
|
101
|
+
this.ws.send('revideo:ffmpeg-video-frame-res', {
|
|
102
|
+
status: 'success',
|
|
103
|
+
data: {
|
|
104
|
+
frame,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
this.handleRenderFinished = async () => {
|
|
109
|
+
this.videoFrameExtractors.forEach(extractor => extractor.destroy());
|
|
110
|
+
this.videoFrameExtractors.clear();
|
|
111
|
+
};
|
|
112
|
+
ws.on('revideo:ffmpeg-exporter', this.handleMessage);
|
|
113
|
+
ws.on('revideo:ffmpeg-video-frame', this.handleVideoFrameMessage);
|
|
114
|
+
ws.on('revideo:render-finished', this.handleRenderFinished);
|
|
115
|
+
}
|
|
116
|
+
respondSuccess(method, data = {}) {
|
|
117
|
+
this.ws.send('revideo:ffmpeg-exporter-ack', {
|
|
118
|
+
status: 'success',
|
|
119
|
+
method,
|
|
120
|
+
data,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
respondError(method, message = 'Unknown error.') {
|
|
124
|
+
this.ws.send('revideo:ffmpeg-exporter-ack', {
|
|
125
|
+
status: 'error',
|
|
126
|
+
method,
|
|
127
|
+
message,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.FFmpegBridge = FFmpegBridge;
|
|
132
|
+
//# sourceMappingURL=ffmpegExporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ffmpegExporter.js","sourceRoot":"","sources":["../../src/partials/ffmpegExporter.ts"],"names":[],"mappings":";;;AAAA,4CAIyB;AAYzB,SAAgB,oBAAoB,CAAC,EAAC,MAAM,EAAuB;IACjE,OAAO;QACL,IAAI,EAAE,gBAAgB;QAEtB,eAAe,CAAC,MAAM;YACpB,IAAI,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,EAAC,MAAM,EAAC,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;AACJ,CAAC;AARD,oDAQC;AAED;;;;;;GAMG;AACH,MAAa,YAAY;IAGvB,YACmB,EAAmB,EACnB,MAA4B;QAD5B,OAAE,GAAF,EAAE,CAAiB;QACnB,WAAM,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AAC,CAAC;IACL,CAAC;IAEO,YAAY,CAAC,MAAc,EAAE,OAAO,GAAG,gBAAgB;QAC7D,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,6BAA6B,EAAE;YAC1C,MAAM,EAAE,OAAO;YACf,MAAM;YACN,OAAO;SACR,CAAC,CAAC;IACL,CAAC;CAoFF;AAlJD,oCAkJC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Plugin} from 'vite';
|
|
2
2
|
interface ExporterPluginConfig {
|
|
3
|
-
|
|
3
|
+
outputPath: string;
|
|
4
4
|
}
|
|
5
|
-
export declare function exporterPlugin({
|
|
5
|
+
export declare function exporterPlugin({
|
|
6
|
+
outputPath,
|
|
7
|
+
}: ExporterPluginConfig): Plugin;
|
|
6
8
|
export {};
|
|
@@ -1,46 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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});
|
|
6
8
|
exports.exporterPlugin = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require(
|
|
8
|
-
const mime_types_1 = __importDefault(require(
|
|
9
|
-
const path_1 = __importDefault(require(
|
|
10
|
-
const openInExplorer_1 = require(
|
|
11
|
-
function exporterPlugin({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
9
|
+
const fs_1 = __importDefault(require('fs'));
|
|
10
|
+
const mime_types_1 = __importDefault(require('mime-types'));
|
|
11
|
+
const path_1 = __importDefault(require('path'));
|
|
12
|
+
const openInExplorer_1 = require('../openInExplorer');
|
|
13
|
+
function exporterPlugin({outputPath}) {
|
|
14
|
+
return {
|
|
15
|
+
name: 'revideo:exporter',
|
|
16
|
+
configureServer(server) {
|
|
17
|
+
server.middlewares.use((req, res, next) => {
|
|
18
|
+
if (req.url === '/__open-output-path') {
|
|
19
|
+
if (!fs_1.default.existsSync(outputPath)) {
|
|
20
|
+
fs_1.default.mkdirSync(outputPath, {recursive: true});
|
|
21
|
+
}
|
|
22
|
+
(0, openInExplorer_1.openInExplorer)(outputPath);
|
|
23
|
+
res.end();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
next();
|
|
27
|
+
});
|
|
28
|
+
server.ws.on(
|
|
29
|
+
'revideo:export',
|
|
30
|
+
async (
|
|
31
|
+
{data, frame, sceneFrame, subDirectories, mimeType, groupByScene},
|
|
32
|
+
client,
|
|
33
|
+
) => {
|
|
34
|
+
const name = (groupByScene ? sceneFrame : frame)
|
|
35
|
+
.toString()
|
|
36
|
+
.padStart(6, '0');
|
|
37
|
+
const extension = mime_types_1.default.extension(mimeType);
|
|
38
|
+
const outputFilePath = path_1.default.join(
|
|
39
|
+
outputPath,
|
|
40
|
+
...subDirectories,
|
|
41
|
+
`${name}.${extension}`,
|
|
42
|
+
);
|
|
43
|
+
const outputDirectory = path_1.default.dirname(outputFilePath);
|
|
44
|
+
if (!fs_1.default.existsSync(outputDirectory)) {
|
|
45
|
+
fs_1.default.mkdirSync(outputDirectory, {recursive: true});
|
|
46
|
+
}
|
|
47
|
+
const base64Data = data.slice(data.indexOf(',') + 1);
|
|
48
|
+
await fs_1.default.promises.writeFile(outputFilePath, base64Data, {
|
|
49
|
+
encoding: 'base64',
|
|
50
|
+
});
|
|
51
|
+
client.send('revideo:export-ack', {frame});
|
|
42
52
|
},
|
|
43
|
-
|
|
53
|
+
);
|
|
54
|
+
},
|
|
55
|
+
};
|
|
44
56
|
}
|
|
45
57
|
exports.exporterPlugin = exporterPlugin;
|
|
46
|
-
//# sourceMappingURL=imageExporter.js.map
|
|
58
|
+
//# sourceMappingURL=imageExporter.js.map
|
package/lib/partials/meta.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Plugin} from 'vite';
|
|
2
2
|
export declare function metaPlugin(): Plugin;
|
package/lib/partials/meta.js
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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});
|
|
6
8
|
exports.metaPlugin = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require(
|
|
8
|
-
const path_1 = __importDefault(require(
|
|
9
|
+
const fs_1 = __importDefault(require('fs'));
|
|
10
|
+
const path_1 = __importDefault(require('path'));
|
|
9
11
|
function metaPlugin() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
const timeStamps = {};
|
|
13
|
+
let config;
|
|
14
|
+
return {
|
|
15
|
+
name: 'revideo:meta',
|
|
16
|
+
configResolved(resolvedConfig) {
|
|
17
|
+
config = resolvedConfig;
|
|
18
|
+
},
|
|
19
|
+
async transform(code, id) {
|
|
20
|
+
const [base] = id.split('?');
|
|
21
|
+
const {name, ext} = path_1.default.posix.parse(base);
|
|
22
|
+
if (ext !== '.meta') {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const sourceFile =
|
|
26
|
+
config.command === 'build' ? false : JSON.stringify(id);
|
|
27
|
+
/* language=typescript */
|
|
28
|
+
return `\
|
|
26
29
|
import {MetaFile} from '@revideo/core';
|
|
27
30
|
let meta;
|
|
28
31
|
if (import.meta.hot) {
|
|
@@ -36,34 +39,40 @@ if (import.meta.hot) {
|
|
|
36
39
|
meta.loadData(${code});
|
|
37
40
|
export default meta;
|
|
38
41
|
`;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
42
|
+
},
|
|
43
|
+
configureServer(server) {
|
|
44
|
+
server.ws.on('revideo:meta', async ({source, data}, client) => {
|
|
45
|
+
// Ignore virtual meta files.
|
|
46
|
+
if (source.startsWith('\0')) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
timeStamps[source] = Date.now();
|
|
50
|
+
if (!process.env.DONT_WRITE_TO_META_FILES) {
|
|
51
|
+
await fs_1.default.promises.writeFile(
|
|
52
|
+
source,
|
|
53
|
+
JSON.stringify(data, undefined, 2),
|
|
54
|
+
'utf8',
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
client.send('revideo:meta-ack', {source});
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
handleHotUpdate(ctx) {
|
|
61
|
+
const now = Date.now();
|
|
62
|
+
const modules = [];
|
|
63
|
+
for (const module of ctx.modules) {
|
|
64
|
+
if (
|
|
65
|
+
module.file !== null &&
|
|
66
|
+
timeStamps[module.file] &&
|
|
67
|
+
timeStamps[module.file] + 1000 > now
|
|
68
|
+
) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
modules.push(module);
|
|
72
|
+
}
|
|
73
|
+
return modules;
|
|
74
|
+
},
|
|
75
|
+
};
|
|
67
76
|
}
|
|
68
77
|
exports.metaPlugin = metaPlugin;
|
|
69
|
-
//# sourceMappingURL=meta.js.map
|
|
78
|
+
//# sourceMappingURL=meta.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Plugin} from 'vite';
|
|
2
2
|
export declare function metricsPlugin(): Plugin;
|
package/lib/partials/metrics.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true});
|
|
3
3
|
exports.metricsPlugin = void 0;
|
|
4
|
-
const telemetry_1 = require(
|
|
4
|
+
const telemetry_1 = require('@revideo/telemetry');
|
|
5
5
|
function metricsPlugin() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
return {
|
|
7
|
+
name: 'revideo:metrics',
|
|
8
|
+
async configResolved() {
|
|
9
|
+
(0, telemetry_1.sendEvent)(telemetry_1.EventName.ServerStarted);
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
12
|
}
|
|
13
13
|
exports.metricsPlugin = metricsPlugin;
|
|
14
|
-
//# sourceMappingURL=metrics.js.map
|
|
14
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import {Plugin} from 'vite';
|
|
2
|
+
import {PluginOptions} from '../plugins';
|
|
3
|
+
import {Projects} from '../utils';
|
|
4
4
|
interface ProjectPluginConfig {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
buildForEditor?: boolean;
|
|
6
|
+
plugins: PluginOptions[];
|
|
7
|
+
projects: Projects;
|
|
8
8
|
}
|
|
9
|
-
export declare function projectsPlugin({
|
|
9
|
+
export declare function projectsPlugin({
|
|
10
|
+
buildForEditor,
|
|
11
|
+
plugins,
|
|
12
|
+
projects,
|
|
13
|
+
}: ProjectPluginConfig): Plugin;
|
|
10
14
|
export {};
|
package/lib/partials/projects.js
CHANGED
|
@@ -1,47 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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});
|
|
6
8
|
exports.projectsPlugin = void 0;
|
|
7
|
-
const path_1 = __importDefault(require(
|
|
8
|
-
const utils_1 = require(
|
|
9
|
-
const versions_1 = require(
|
|
9
|
+
const path_1 = __importDefault(require('path'));
|
|
10
|
+
const utils_1 = require('../utils');
|
|
11
|
+
const versions_1 = require('../versions');
|
|
10
12
|
const PROJECT_QUERY_REGEX = /[?&]project\b/;
|
|
11
|
-
function projectsPlugin({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
13
|
+
function projectsPlugin({buildForEditor, plugins, projects}) {
|
|
14
|
+
const versions = JSON.stringify((0, versions_1.getVersions)());
|
|
15
|
+
let config;
|
|
16
|
+
return {
|
|
17
|
+
name: 'revideo:project',
|
|
18
|
+
configResolved(resolvedConfig) {
|
|
19
|
+
config = resolvedConfig;
|
|
20
|
+
},
|
|
21
|
+
async load(id) {
|
|
22
|
+
if (!PROJECT_QUERY_REGEX.test(id)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const [base] = id.split('?');
|
|
26
|
+
const {name, dir} = path_1.default.posix.parse(base);
|
|
27
|
+
const runsInEditor = buildForEditor || config.command === 'serve';
|
|
28
|
+
const metaFile = `${name}.meta`;
|
|
29
|
+
await (0, utils_1.createMeta)(path_1.default.join(dir, metaFile));
|
|
30
|
+
const imports = [];
|
|
31
|
+
const pluginNames = [];
|
|
32
|
+
let index = 0;
|
|
33
|
+
for (const plugin of plugins) {
|
|
34
|
+
if (plugin.entryPoint) {
|
|
35
|
+
const pluginName = `plugin${index}`;
|
|
36
|
+
let options = (await plugin.runtimeConfig?.()) ?? '';
|
|
37
|
+
if (typeof options !== 'string') {
|
|
38
|
+
options = JSON.stringify(options);
|
|
39
|
+
}
|
|
40
|
+
imports.push(`import ${pluginName} from '${plugin.entryPoint}'`);
|
|
41
|
+
pluginNames.push(`${pluginName}(${options})`);
|
|
42
|
+
index++;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/* language=typescript */
|
|
46
|
+
return `\
|
|
45
47
|
${imports.join('\n')}
|
|
46
48
|
import {${runsInEditor ? 'editorBootstrap' : 'bootstrap'}} from '@revideo/core';
|
|
47
49
|
import {MetaFile} from '@revideo/core';
|
|
@@ -56,34 +58,36 @@ import {MetaFile} from '@revideo/core';
|
|
|
56
58
|
metaFile,
|
|
57
59
|
settings,
|
|
58
60
|
);`;
|
|
61
|
+
},
|
|
62
|
+
config(config) {
|
|
63
|
+
return {
|
|
64
|
+
build: {
|
|
65
|
+
target: buildForEditor ? 'esnext' : 'modules',
|
|
66
|
+
assetsDir: './',
|
|
67
|
+
rollupOptions: {
|
|
68
|
+
preserveEntrySignatures: 'strict',
|
|
69
|
+
input: Object.fromEntries(
|
|
70
|
+
projects.list.map(project => [
|
|
71
|
+
project.name,
|
|
72
|
+
project.url + '?project',
|
|
73
|
+
]),
|
|
74
|
+
),
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
server: {
|
|
78
|
+
port: config?.server?.port ?? 9000,
|
|
79
|
+
},
|
|
80
|
+
esbuild: {
|
|
81
|
+
jsx: 'automatic',
|
|
82
|
+
jsxImportSource: '@revideo/2d/lib',
|
|
59
83
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
target: buildForEditor ? 'esnext' : 'modules',
|
|
64
|
-
assetsDir: './',
|
|
65
|
-
rollupOptions: {
|
|
66
|
-
preserveEntrySignatures: 'strict',
|
|
67
|
-
input: Object.fromEntries(projects.list.map(project => [
|
|
68
|
-
project.name,
|
|
69
|
-
project.url + '?project',
|
|
70
|
-
])),
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
server: {
|
|
74
|
-
port: config?.server?.port ?? 9000,
|
|
75
|
-
},
|
|
76
|
-
esbuild: {
|
|
77
|
-
jsx: 'automatic',
|
|
78
|
-
jsxImportSource: '@revideo/2d/lib',
|
|
79
|
-
},
|
|
80
|
-
optimizeDeps: {
|
|
81
|
-
entries: projects.list.map(project => project.url),
|
|
82
|
-
exclude: ['preact', 'preact/*', '@preact/signals'],
|
|
83
|
-
},
|
|
84
|
-
};
|
|
84
|
+
optimizeDeps: {
|
|
85
|
+
entries: projects.list.map(project => project.url),
|
|
86
|
+
exclude: ['preact', 'preact/*', '@preact/signals'],
|
|
85
87
|
},
|
|
86
|
-
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
};
|
|
87
91
|
}
|
|
88
92
|
exports.projectsPlugin = projectsPlugin;
|
|
89
|
-
//# sourceMappingURL=projects.js.map
|
|
93
|
+
//# sourceMappingURL=projects.js.map
|
package/lib/partials/scenes.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Plugin} from 'vite';
|
|
2
2
|
export declare function scenesPlugin(): Plugin;
|