@revideo/vite-plugin 0.4.7-two.1024 → 0.4.7
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 +22 -40
- package/lib/openInExplorer.js +39 -38
- package/lib/partials/assets.d.ts +3 -5
- package/lib/partials/assets.js +46 -49
- package/lib/partials/corsProxy.d.ts +22 -24
- package/lib/partials/corsProxy.js +151 -175
- package/lib/partials/editor.d.ts +5 -8
- package/lib/partials/editor.js +58 -65
- package/lib/partials/imageExporter.d.ts +3 -5
- package/lib/partials/imageExporter.js +42 -54
- package/lib/partials/meta.d.ts +1 -1
- package/lib/partials/meta.js +52 -61
- package/lib/partials/metrics.d.ts +1 -1
- package/lib/partials/metrics.js +10 -10
- package/lib/partials/projects.d.ts +7 -11
- package/lib/partials/projects.js +69 -73
- package/lib/partials/scenes.d.ts +1 -1
- package/lib/partials/scenes.js +23 -25
- package/lib/partials/settings.d.ts +1 -1
- package/lib/partials/settings.js +62 -67
- package/lib/partials/webgl.d.ts +7 -7
- package/lib/partials/webgl.js +79 -87
- 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 +40 -47
- package/lib/versions.d.ts +4 -4
- package/lib/versions.js +23 -28
- package/package.json +4 -4
- package/lib/partials/ffmpegExporter.d.ts +0 -25
- package/lib/partials/ffmpegExporter.js +0 -132
- package/lib/partials/ffmpegExporter.js.map +0 -1
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
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 });
|
|
8
6
|
exports.corsProxyPlugin = void 0;
|
|
9
|
-
const follow_redirects_1 = __importDefault(require(
|
|
7
|
+
const follow_redirects_1 = __importDefault(require("follow-redirects"));
|
|
10
8
|
/**
|
|
11
9
|
* This module provides the proxy located at
|
|
12
10
|
* /cors-proxy/...
|
|
@@ -24,78 +22,69 @@ const follow_redirects_1 = __importDefault(require('follow-redirects'));
|
|
|
24
22
|
* same host as the main app.
|
|
25
23
|
*/
|
|
26
24
|
function corsProxyPlugin(config) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
};
|
|
25
|
+
setupEnvVarsForProxy(config);
|
|
26
|
+
return {
|
|
27
|
+
name: 'revideo:cors-proxy',
|
|
28
|
+
configureServer(server) {
|
|
29
|
+
if (config !== false && config !== undefined) {
|
|
30
|
+
motionCanvasCorsProxy(server.middlewares, config === true ? {} : config);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
};
|
|
39
34
|
}
|
|
40
35
|
exports.corsProxyPlugin = corsProxyPlugin;
|
|
41
36
|
function setupEnvVarsForProxy(config) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
process.env[isEnabledKey] = String(!!config); // 'true' or 'false'
|
|
50
|
-
if (config) {
|
|
51
|
-
// These values are only configured if the Proxy is enabled
|
|
52
|
-
// You cannot access them via import.meta.env if the Proxy
|
|
53
|
-
// is set to false
|
|
54
|
-
process.env[allowList] = JSON.stringify(config.allowListHosts ?? []);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function motionCanvasCorsProxy(middleware, config) {
|
|
58
|
-
// Set the default config if no config was provided
|
|
59
|
-
config.allowedMimeTypes ??= ['image/*', 'video/*'];
|
|
60
|
-
config.allowListHosts ??= [];
|
|
61
|
-
// Check the Mime Types to have a correct structure (left/right)
|
|
62
|
-
// not having them in the correct format would crash the Middleware
|
|
63
|
-
// further down below
|
|
64
|
-
if ((config.allowedMimeTypes ?? []).some(e => e.split('/').length !== 2)) {
|
|
65
|
-
throw new Error(
|
|
66
|
-
"Invalid config for Proxy:\nAll Entries must have the following format:\n 'left/right' where left may be '*'",
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
middleware.use((req, res, next) => {
|
|
70
|
-
if (!req.url || !req.url.startsWith('/cors-proxy/')) {
|
|
71
|
-
// url does not start with /cors-proxy/, so this
|
|
72
|
-
// middleware does not care about it
|
|
73
|
-
return next();
|
|
74
|
-
}
|
|
75
|
-
// For now, only allow GET Requests
|
|
76
|
-
if (req.method !== 'GET') {
|
|
77
|
-
return writeError('Only GET Requests are allowed', res, 405);
|
|
37
|
+
// Define Keys for Env Var
|
|
38
|
+
const prefix = 'VITE_MC_PROXY_';
|
|
39
|
+
const isEnabledKey = prefix + 'ENABLED';
|
|
40
|
+
const allowList = prefix + 'ALLOW_LIST';
|
|
41
|
+
if (config === true) {
|
|
42
|
+
config = {}; // Use Default values
|
|
78
43
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
44
|
+
process.env[isEnabledKey] = String(!!config); // 'true' or 'false'
|
|
45
|
+
if (config) {
|
|
46
|
+
// These values are only configured if the Proxy is enabled
|
|
47
|
+
// You cannot access them via import.meta.env if the Proxy
|
|
48
|
+
// is set to false
|
|
49
|
+
process.env[allowList] = JSON.stringify(config.allowListHosts ?? []);
|
|
84
50
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
51
|
+
}
|
|
52
|
+
function motionCanvasCorsProxy(middleware, config) {
|
|
53
|
+
// Set the default config if no config was provided
|
|
54
|
+
config.allowedMimeTypes ??= ['image/*', 'video/*'];
|
|
55
|
+
config.allowListHosts ??= [];
|
|
56
|
+
// Check the Mime Types to have a correct structure (left/right)
|
|
57
|
+
// not having them in the correct format would crash the Middleware
|
|
58
|
+
// further down below
|
|
59
|
+
if ((config.allowedMimeTypes ?? []).some(e => e.split('/').length !== 2)) {
|
|
60
|
+
throw new Error("Invalid config for Proxy:\nAll Entries must have the following format:\n 'left/right' where left may be '*'");
|
|
92
61
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
62
|
+
middleware.use((req, res, next) => {
|
|
63
|
+
if (!req.url || !req.url.startsWith('/cors-proxy/')) {
|
|
64
|
+
// url does not start with /cors-proxy/, so this
|
|
65
|
+
// middleware does not care about it
|
|
66
|
+
return next();
|
|
67
|
+
}
|
|
68
|
+
// For now, only allow GET Requests
|
|
69
|
+
if (req.method !== 'GET') {
|
|
70
|
+
return writeError('Only GET Requests are allowed', res, 405);
|
|
71
|
+
}
|
|
72
|
+
let sourceUrl;
|
|
73
|
+
try {
|
|
74
|
+
sourceUrl = extractDestination(req.url);
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
return writeError(err, res);
|
|
78
|
+
}
|
|
79
|
+
if (!isReceivedUrlInAllowedHosts(sourceUrl.hostname, config.allowListHosts)) {
|
|
80
|
+
return writeError(`Blocked by Proxy: ${sourceUrl.hostname} is not on Hosts Allowlist`, res);
|
|
81
|
+
}
|
|
82
|
+
// Get the resource, do some checks. Throws an Error
|
|
83
|
+
// if the checks fail. The catch then writes an Error
|
|
84
|
+
return tryGetResource(res, sourceUrl, config).catch(error => {
|
|
85
|
+
writeError(error, res);
|
|
86
|
+
});
|
|
97
87
|
});
|
|
98
|
-
});
|
|
99
88
|
}
|
|
100
89
|
/**
|
|
101
90
|
* Unwrap the destination from the URL.
|
|
@@ -109,34 +98,32 @@ function motionCanvasCorsProxy(middleware, config) {
|
|
|
109
98
|
* @returns The URL that needs to be called.
|
|
110
99
|
*/
|
|
111
100
|
function extractDestination(url) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
101
|
+
const withoutPrefix = url.replace('/cors-proxy/', '');
|
|
102
|
+
const asUrl = new URL(decodeURIComponent(withoutPrefix));
|
|
103
|
+
if (asUrl.protocol !== 'http:' && asUrl.protocol !== 'https:') {
|
|
104
|
+
throw new Error('Only supported protocols are http and https');
|
|
105
|
+
}
|
|
106
|
+
return asUrl;
|
|
118
107
|
}
|
|
119
108
|
/**
|
|
120
109
|
* A simple Error Helper that will write an Error and close the response.
|
|
121
110
|
*/
|
|
122
111
|
function writeError(message, res, statusCode = 400) {
|
|
123
|
-
|
|
124
|
-
|
|
112
|
+
res.writeHead(statusCode, message);
|
|
113
|
+
res.end();
|
|
125
114
|
}
|
|
126
115
|
/**
|
|
127
116
|
* Check if the Proxy is allowed to get the requested resource based on the
|
|
128
117
|
* host.
|
|
129
118
|
*/
|
|
130
119
|
function isReceivedUrlInAllowedHosts(hostname, allowListHosts) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
e => e.toLowerCase().trim() === hostname.toLowerCase().trim(),
|
|
139
|
-
);
|
|
120
|
+
if (!allowListHosts || allowListHosts.length === 0) {
|
|
121
|
+
// if the allowListHosts is just the predefinedAllowlist, the user has not
|
|
122
|
+
// set any additional hosts. In this case, allow any hostname
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
// Check if the hostname is any of the values set in allowListHosts
|
|
126
|
+
return allowListHosts.some(e => e.toLowerCase().trim() === hostname.toLowerCase().trim());
|
|
140
127
|
}
|
|
141
128
|
/**
|
|
142
129
|
* Check if the Proxy is allowed to get the requested resource based on the
|
|
@@ -146,98 +133,87 @@ function isReceivedUrlInAllowedHosts(hostname, allowListHosts) {
|
|
|
146
133
|
* Also handles catch-All Declarations like `image/*`.
|
|
147
134
|
*/
|
|
148
135
|
function isResultOfAllowedResourceType(foundMimeType, allowedMimeTypes) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
e => e
|
|
171
|
-
);
|
|
172
|
-
// if an exact match or a catchall is found, the resource is allowed to be
|
|
173
|
-
// proxied.
|
|
174
|
-
return rightSegmentOfLeftSegmentMatches.some(
|
|
175
|
-
e => e === '*' || e === rightSegment,
|
|
176
|
-
);
|
|
136
|
+
if (!allowedMimeTypes || allowedMimeTypes.length === 0) {
|
|
137
|
+
return true; // no filters set
|
|
138
|
+
}
|
|
139
|
+
if (foundMimeType.split('/').length !== 2) {
|
|
140
|
+
return false; // invalid mime structure
|
|
141
|
+
}
|
|
142
|
+
const [leftSegment, rightSegment] = foundMimeType
|
|
143
|
+
.split('/')
|
|
144
|
+
.map(e => e.trim().toLowerCase());
|
|
145
|
+
// Get all Segments where the left Part is identical between foundMimeType and
|
|
146
|
+
// allowedMimeType.
|
|
147
|
+
const leftSegmentMatches = allowedMimeTypes.filter(e => e.trim().toLowerCase().split('/')[0] === leftSegment);
|
|
148
|
+
if (leftSegmentMatches.length === 0) {
|
|
149
|
+
// No matches at all, not even catchall - resource is rejected.
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
// This just gets the right part of the MIME Types from the
|
|
153
|
+
// configured allowList, e.g. "image/png" -> png
|
|
154
|
+
const rightSegmentOfLeftSegmentMatches = leftSegmentMatches.map(e => e.split('/')[1]);
|
|
155
|
+
// if an exact match or a catchall is found, the resource is allowed to be
|
|
156
|
+
// proxied.
|
|
157
|
+
return rightSegmentOfLeftSegmentMatches.some(e => e === '*' || e === rightSegment);
|
|
177
158
|
}
|
|
178
159
|
/**
|
|
179
160
|
* Requests a remote resource with the help of axios
|
|
180
161
|
* May throw a string in case of a bad mime-type or missing headers
|
|
181
162
|
*/
|
|
182
163
|
async function tryGetResource(res, sourceUrl, config) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
164
|
+
// Turn this callback into a Promise to avoid additional nesting
|
|
165
|
+
const result = await new Promise((res, rej) => {
|
|
166
|
+
try {
|
|
167
|
+
// We check what protocol was used and decide if we use http or https
|
|
168
|
+
const request = (sourceUrl.protocol.startsWith('https')
|
|
169
|
+
? follow_redirects_1.default.https
|
|
170
|
+
: follow_redirects_1.default.http).get(sourceUrl, data => {
|
|
171
|
+
res(data);
|
|
172
|
+
});
|
|
173
|
+
request.on('error', (err) => {
|
|
174
|
+
if (err.code && err.code === 'ENOTFOUND') {
|
|
175
|
+
// This is a bit hacky, but this basically returns as a
|
|
176
|
+
// 404 instead of crashing the Node Server with ENOTFOUND
|
|
177
|
+
res({ statusCode: 404 });
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
rej(err);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
catch (err) {
|
|
185
|
+
rej(err);
|
|
201
186
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
187
|
+
});
|
|
188
|
+
if (!result.statusCode || result.statusCode >= 300) {
|
|
189
|
+
throw 'Unexpected Status: ' + result.statusCode ?? 'NO_STATUS';
|
|
205
190
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
const contentType = result.headers['content-type'];
|
|
211
|
-
const contentLength = result.headers['content-length'];
|
|
212
|
-
if (!contentType) {
|
|
213
|
-
throw 'Proxied Response does not contain a Content Type';
|
|
214
|
-
}
|
|
215
|
-
if (!contentLength) {
|
|
216
|
-
throw 'Proxied Response does not contain a Content Length';
|
|
217
|
-
}
|
|
218
|
-
if (
|
|
219
|
-
!isResultOfAllowedResourceType(
|
|
220
|
-
contentType.toString(),
|
|
221
|
-
config.allowedMimeTypes ?? [],
|
|
222
|
-
)
|
|
223
|
-
) {
|
|
224
|
-
throw 'Proxied response has blocked content-type: ' + contentType;
|
|
225
|
-
}
|
|
226
|
-
// Prepare Response
|
|
227
|
-
for (const key in result.headers) {
|
|
228
|
-
const header = result.headers[key];
|
|
229
|
-
if (header === undefined) {
|
|
230
|
-
console.warn('Proxy: Received Header is empty. Skipping…');
|
|
231
|
-
continue;
|
|
191
|
+
const contentType = result.headers['content-type'];
|
|
192
|
+
const contentLength = result.headers['content-length'];
|
|
193
|
+
if (!contentType) {
|
|
194
|
+
throw 'Proxied Response does not contain a Content Type';
|
|
232
195
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
196
|
+
if (!contentLength) {
|
|
197
|
+
throw 'Proxied Response does not contain a Content Length';
|
|
198
|
+
}
|
|
199
|
+
if (!isResultOfAllowedResourceType(contentType.toString(), config.allowedMimeTypes ?? [])) {
|
|
200
|
+
throw 'Proxied response has blocked content-type: ' + contentType;
|
|
201
|
+
}
|
|
202
|
+
// Prepare Response
|
|
203
|
+
for (const key in result.headers) {
|
|
204
|
+
const header = result.headers[key];
|
|
205
|
+
if (header === undefined) {
|
|
206
|
+
console.warn('Proxy: Received Header is empty. Skipping…');
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
res.setHeader(key, header);
|
|
210
|
+
}
|
|
211
|
+
res.addListener('error', () => {
|
|
212
|
+
console.log('Proxy: Connection Reset');
|
|
213
|
+
});
|
|
214
|
+
res.setHeader('x-proxy-destination', sourceUrl.toString());
|
|
215
|
+
// Don't store on the server, just immediately pass on the
|
|
216
|
+
// received chunks
|
|
217
|
+
result.pipe(res);
|
|
242
218
|
}
|
|
243
|
-
//# sourceMappingURL=corsProxy.js.map
|
|
219
|
+
//# sourceMappingURL=corsProxy.js.map
|
package/lib/partials/editor.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {Plugin} from 'vite';
|
|
2
|
-
import {Projects} from '../utils';
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
import { Projects } from '../utils';
|
|
3
3
|
interface EditorPluginConfig {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
editor: string;
|
|
5
|
+
projects: Projects;
|
|
6
6
|
}
|
|
7
|
-
export declare function editorPlugin({
|
|
8
|
-
editor,
|
|
9
|
-
projects,
|
|
10
|
-
}: EditorPluginConfig): Plugin;
|
|
7
|
+
export declare function editorPlugin({ editor, projects }: EditorPluginConfig): Plugin;
|
|
11
8
|
export {};
|
package/lib/partials/editor.js
CHANGED
|
@@ -1,79 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
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 });
|
|
8
6
|
exports.editorPlugin = void 0;
|
|
9
|
-
const fs_1 = __importDefault(require(
|
|
10
|
-
const path_1 = __importDefault(require(
|
|
11
|
-
function editorPlugin({editor, projects}) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const [, query] = id.split('?');
|
|
29
|
-
if (id.startsWith(resolvedEditorId)) {
|
|
30
|
-
if (projects.list.length === 1) {
|
|
31
|
-
/* language=typescript */
|
|
32
|
-
return `\
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
function editorPlugin({ editor, projects }) {
|
|
10
|
+
const editorPath = path_1.default.dirname(require.resolve(editor));
|
|
11
|
+
const editorFile = fs_1.default.readFileSync(path_1.default.resolve(editorPath, 'editor.html'));
|
|
12
|
+
const htmlParts = editorFile
|
|
13
|
+
.toString()
|
|
14
|
+
.replace('{{style}}', `/@fs/${path_1.default.resolve(editorPath, 'style.css')}`)
|
|
15
|
+
.split('{{source}}');
|
|
16
|
+
const createHtml = (src) => htmlParts[0] + src + htmlParts[1];
|
|
17
|
+
const resolvedEditorId = '\0virtual:editor';
|
|
18
|
+
return {
|
|
19
|
+
name: 'revideo:editor',
|
|
20
|
+
async load(id) {
|
|
21
|
+
const [, query] = id.split('?');
|
|
22
|
+
if (id.startsWith(resolvedEditorId)) {
|
|
23
|
+
if (projects.list.length === 1) {
|
|
24
|
+
/* language=typescript */
|
|
25
|
+
return `\
|
|
33
26
|
import {editor} from '${editor}';
|
|
34
27
|
import project from '${projects.list[0].url}?project';
|
|
35
28
|
editor(project);
|
|
36
29
|
`;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
}
|
|
31
|
+
if (query) {
|
|
32
|
+
const params = new URLSearchParams(query);
|
|
33
|
+
const name = params.get('project');
|
|
34
|
+
if (name && projects.lookup.has(name)) {
|
|
35
|
+
/* language=typescript */
|
|
36
|
+
return `\
|
|
44
37
|
import {editor} from '${editor}';
|
|
45
38
|
import project from '${projects.lookup.get(name).url}?project';
|
|
46
39
|
editor(project);
|
|
47
40
|
`;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/* language=typescript */
|
|
44
|
+
return `\
|
|
52
45
|
import {index} from '${editor}';
|
|
53
46
|
index(${JSON.stringify(projects.list)});
|
|
54
47
|
`;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
configureServer(server) {
|
|
51
|
+
server.middlewares.use((req, res, next) => {
|
|
52
|
+
if (req.url) {
|
|
53
|
+
const url = new URL(req.url, `http://${req.headers.host}`);
|
|
54
|
+
if (url.pathname === '/') {
|
|
55
|
+
res.setHeader('Content-Type', 'text/html');
|
|
56
|
+
res.end(createHtml('/@id/__x00__virtual:editor'));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const name = url.pathname.slice(1);
|
|
60
|
+
if (name && projects.lookup.has(name)) {
|
|
61
|
+
res.setHeader('Content-Type', 'text/html');
|
|
62
|
+
res.end(createHtml(`/@id/__x00__virtual:editor?project=${name}`));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
next();
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
};
|
|
77
70
|
}
|
|
78
71
|
exports.editorPlugin = editorPlugin;
|
|
79
|
-
//# sourceMappingURL=editor.js.map
|
|
72
|
+
//# sourceMappingURL=editor.js.map
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {Plugin} from 'vite';
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
2
|
interface ExporterPluginConfig {
|
|
3
|
-
|
|
3
|
+
outputPath: string;
|
|
4
4
|
}
|
|
5
|
-
export declare function exporterPlugin({
|
|
6
|
-
outputPath,
|
|
7
|
-
}: ExporterPluginConfig): Plugin;
|
|
5
|
+
export declare function exporterPlugin({ outputPath }: ExporterPluginConfig): Plugin;
|
|
8
6
|
export {};
|
|
@@ -1,58 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
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 });
|
|
8
6
|
exports.exporterPlugin = void 0;
|
|
9
|
-
const fs_1 = __importDefault(require(
|
|
10
|
-
const mime_types_1 = __importDefault(require(
|
|
11
|
-
const path_1 = __importDefault(require(
|
|
12
|
-
const openInExplorer_1 = require(
|
|
13
|
-
function exporterPlugin({outputPath}) {
|
|
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
|
-
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});
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const mime_types_1 = __importDefault(require("mime-types"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const openInExplorer_1 = require("../openInExplorer");
|
|
11
|
+
function exporterPlugin({ outputPath }) {
|
|
12
|
+
return {
|
|
13
|
+
name: 'revideo:exporter',
|
|
14
|
+
configureServer(server) {
|
|
15
|
+
server.middlewares.use((req, res, next) => {
|
|
16
|
+
if (req.url === '/__open-output-path') {
|
|
17
|
+
if (!fs_1.default.existsSync(outputPath)) {
|
|
18
|
+
fs_1.default.mkdirSync(outputPath, { recursive: true });
|
|
19
|
+
}
|
|
20
|
+
(0, openInExplorer_1.openInExplorer)(outputPath);
|
|
21
|
+
res.end();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
next();
|
|
25
|
+
});
|
|
26
|
+
server.ws.on('revideo:export', async ({ data, frame, sceneFrame, subDirectories, mimeType, groupByScene }, client) => {
|
|
27
|
+
const name = (groupByScene ? sceneFrame : frame)
|
|
28
|
+
.toString()
|
|
29
|
+
.padStart(6, '0');
|
|
30
|
+
const extension = mime_types_1.default.extension(mimeType);
|
|
31
|
+
const outputFilePath = path_1.default.join(outputPath, ...subDirectories, `${name}.${extension}`);
|
|
32
|
+
const outputDirectory = path_1.default.dirname(outputFilePath);
|
|
33
|
+
if (!fs_1.default.existsSync(outputDirectory)) {
|
|
34
|
+
fs_1.default.mkdirSync(outputDirectory, { recursive: true });
|
|
35
|
+
}
|
|
36
|
+
const base64Data = data.slice(data.indexOf(',') + 1);
|
|
37
|
+
await fs_1.default.promises.writeFile(outputFilePath, base64Data, {
|
|
38
|
+
encoding: 'base64',
|
|
39
|
+
});
|
|
40
|
+
client.send('revideo:export-ack', { frame });
|
|
41
|
+
});
|
|
52
42
|
},
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
-
};
|
|
43
|
+
};
|
|
56
44
|
}
|
|
57
45
|
exports.exporterPlugin = exporterPlugin;
|
|
58
|
-
//# sourceMappingURL=imageExporter.js.map
|
|
46
|
+
//# sourceMappingURL=imageExporter.js.map
|