@editframe/vite-plugin 0.20.4-beta.0 → 0.21.0-beta.0
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/index.d.ts +1 -1
- package/dist/index.js +6 -11
- package/dist/sendTaskResult.js +3 -5
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ interface VitePluginEditframeOptions {
|
|
|
4
4
|
}
|
|
5
5
|
export declare const vitePluginEditframe: (options: VitePluginEditframeOptions) => {
|
|
6
6
|
name: string;
|
|
7
|
-
configureServer(this:
|
|
7
|
+
configureServer(this: import('rolldown-vite').MinimalPluginContextWithoutEnvironment, server: import('rolldown-vite').ViteDevServer): void;
|
|
8
8
|
};
|
|
9
9
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import path, { join } from "node:path";
|
|
|
5
5
|
import { Client, createURLToken } from "@editframe/api";
|
|
6
6
|
import { cacheImage, findOrCreateCaptions, generateTrack, generateTrackFragmentIndex, md5FilePath } from "@editframe/assets";
|
|
7
7
|
import debug from "debug";
|
|
8
|
-
|
|
8
|
+
var getEditframeClient = () => {
|
|
9
9
|
const token = process.env.EF_TOKEN;
|
|
10
10
|
const efHost = process.env.EF_HOST;
|
|
11
11
|
if (!token) throw new Error("EF_TOKEN environment variable must be set");
|
|
@@ -20,13 +20,12 @@ const vitePluginEditframe = (options) => {
|
|
|
20
20
|
if (req.url?.startsWith("/@ef")) forbidRelativePaths(req);
|
|
21
21
|
else return next();
|
|
22
22
|
log(`Handling ${req.url}`);
|
|
23
|
-
const
|
|
24
|
-
const assetPath = requestPath.replace(/\?.*$/, "");
|
|
23
|
+
const assetPath = req.url.replace(/^\/@ef-[^/]+\//, "").replace(/\?.*$/, "");
|
|
25
24
|
const absolutePath = assetPath.startsWith("http") ? assetPath : path.join(options.root, assetPath).replace("dist/", "src/");
|
|
26
25
|
options.cacheRoot = options.cacheRoot.replace("dist/", "src/");
|
|
27
26
|
const efPrefix = req.url.split("/")[1];
|
|
28
27
|
switch (efPrefix) {
|
|
29
|
-
case "@ef-clear-cache":
|
|
28
|
+
case "@ef-clear-cache":
|
|
30
29
|
if (req.method !== "DELETE") {
|
|
31
30
|
res.writeHead(405, { Allow: "DELETE" });
|
|
32
31
|
res.end();
|
|
@@ -40,8 +39,7 @@ const vitePluginEditframe = (options) => {
|
|
|
40
39
|
res.writeHead(200, { "Content-Type": "text/plain" });
|
|
41
40
|
res.end("Cache cleared");
|
|
42
41
|
break;
|
|
43
|
-
|
|
44
|
-
case "@ef-asset": {
|
|
42
|
+
case "@ef-asset":
|
|
45
43
|
if (req.method !== "HEAD") {
|
|
46
44
|
res.writeHead(405, { Allow: "HEAD" });
|
|
47
45
|
res.end();
|
|
@@ -51,17 +49,14 @@ const vitePluginEditframe = (options) => {
|
|
|
51
49
|
res.end();
|
|
52
50
|
}).catch(next);
|
|
53
51
|
break;
|
|
54
|
-
|
|
55
|
-
case "@ef-track-fragment-index": {
|
|
52
|
+
case "@ef-track-fragment-index":
|
|
56
53
|
log(`Serving track fragment index for ${absolutePath}`);
|
|
57
54
|
generateTrackFragmentIndex(options.cacheRoot, absolutePath).then((taskResult) => sendTaskResult(req, res, taskResult)).catch(next);
|
|
58
55
|
break;
|
|
59
|
-
|
|
60
|
-
case "@ef-track": {
|
|
56
|
+
case "@ef-track":
|
|
61
57
|
log(`Serving track for ${absolutePath}`);
|
|
62
58
|
generateTrack(options.cacheRoot, absolutePath, req.url).then((taskResult) => sendTaskResult(req, res, taskResult)).catch(next);
|
|
63
59
|
break;
|
|
64
|
-
}
|
|
65
60
|
case "@ef-captions":
|
|
66
61
|
log(`Serving captions for ${absolutePath}`);
|
|
67
62
|
findOrCreateCaptions(options.cacheRoot, absolutePath).then((taskResult) => sendTaskResult(req, res, taskResult)).catch(next);
|
package/dist/sendTaskResult.js
CHANGED
|
@@ -29,11 +29,10 @@ const sendTaskResult = (req, res, taskResult) => {
|
|
|
29
29
|
"Accept-Ranges": "bytes"
|
|
30
30
|
});
|
|
31
31
|
log(`Sending ${filePath} range ${start}-${end}/${stats.size}`);
|
|
32
|
-
|
|
32
|
+
createReadStream(filePath, {
|
|
33
33
|
start,
|
|
34
34
|
end
|
|
35
|
-
});
|
|
36
|
-
readStream.pipe(res);
|
|
35
|
+
}).pipe(res);
|
|
37
36
|
} else {
|
|
38
37
|
res.writeHead(200, {
|
|
39
38
|
...headers,
|
|
@@ -42,8 +41,7 @@ const sendTaskResult = (req, res, taskResult) => {
|
|
|
42
41
|
"Content-Length": stats.size
|
|
43
42
|
});
|
|
44
43
|
log(`Sending ${filePath}`);
|
|
45
|
-
|
|
46
|
-
readStream.pipe(res);
|
|
44
|
+
createReadStream(filePath).pipe(res);
|
|
47
45
|
}
|
|
48
46
|
} catch (error) {
|
|
49
47
|
log("Error sending file", error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editframe/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0-beta.0",
|
|
4
4
|
"description": "Editframe vite plugin",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"author": "",
|
|
20
20
|
"license": "UNLICENSED",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@editframe/api": "0.
|
|
23
|
-
"@editframe/assets": "0.
|
|
22
|
+
"@editframe/api": "0.21.0-beta.0",
|
|
23
|
+
"@editframe/assets": "0.21.0-beta.0",
|
|
24
24
|
"connect": "^3.7.0",
|
|
25
25
|
"debug": "^4.3.5",
|
|
26
26
|
"mime": "^4.0.3",
|
|
27
27
|
"node-html-parser": "^6.1.13",
|
|
28
|
-
"rolldown-vite": "^
|
|
28
|
+
"rolldown-vite": "^7.1.15"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/dom-webcodecs": "^0.1.11",
|