@editframe/cli 0.16.8-beta.0 → 0.18.3-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/VERSION.d.ts +1 -1
- package/dist/VERSION.js +2 -4
- package/dist/commands/auth.js +16 -25
- package/dist/commands/check.js +81 -108
- package/dist/commands/mux.d.ts +1 -0
- package/dist/commands/preview.js +4 -1
- package/dist/commands/process-file.js +18 -34
- package/dist/commands/process.js +28 -31
- package/dist/commands/render.js +117 -157
- package/dist/commands/sync.js +3 -5
- package/dist/commands/webhook.js +48 -52
- package/dist/index.js +3 -7
- package/dist/operations/processRenderInfo.js +25 -31
- package/dist/operations/syncAssetsDirectory/SubAssetSync.js +11 -18
- package/dist/operations/syncAssetsDirectory/SyncCaption.js +46 -73
- package/dist/operations/syncAssetsDirectory/SyncFragmentIndex.js +53 -83
- package/dist/operations/syncAssetsDirectory/SyncImage.js +72 -99
- package/dist/operations/syncAssetsDirectory/SyncStatus.js +30 -37
- package/dist/operations/syncAssetsDirectory/SyncTrack.js +107 -143
- package/dist/operations/syncAssetsDirectory/doAssetSync.js +42 -46
- package/dist/operations/syncAssetsDirectory.js +55 -78
- package/dist/utils/createReadableStreamFromReadable.js +61 -78
- package/dist/utils/index.js +10 -16
- package/dist/utils/launchBrowserAndWaitForSDK.js +31 -43
- package/dist/utils/startDevServer.d.ts +1 -1
- package/dist/utils/startPreviewServer.d.ts +1 -1
- package/dist/utils/startPreviewServer.js +28 -34
- package/dist/utils/validateVideoResolution.js +19 -23
- package/dist/utils/withSpinner.js +10 -12
- package/package.json +8 -8
- package/src/commands/check.ts +2 -2
- package/src/commands/mux.ts +10 -0
- package/src/operations/syncAssetsDirectory/SyncCaption.test.ts +12 -3
- package/src/operations/syncAssetsDirectory/SyncFragmentIndex.test.ts +11 -3
- package/src/operations/syncAssetsDirectory/SyncImage.test.ts +12 -3
- package/src/operations/syncAssetsDirectory/SyncImage.ts +3 -2
- package/src/operations/syncAssetsDirectory/SyncTrack.test.ts +11 -3
- package/src/operations/syncAssetsDirectory.test.ts +12 -5
- package/src/utils/createReadableStreamFromReadable.ts +3 -7
- package/src/utils/startDevServer.ts +5 -5
- package/src/utils/startPreviewServer.ts +1 -1
- package/test-fixtures/network.ts +38 -9
package/dist/utils/index.js
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import { program } from "commander";
|
|
2
1
|
import "dotenv/config";
|
|
2
|
+
import { program } from "commander";
|
|
3
3
|
import { Client } from "@editframe/api";
|
|
4
4
|
let client;
|
|
5
5
|
const getClient = () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
client = new Client(token, efHost);
|
|
16
|
-
}
|
|
17
|
-
return client;
|
|
18
|
-
};
|
|
19
|
-
export {
|
|
20
|
-
getClient
|
|
6
|
+
if (!client) {
|
|
7
|
+
const programOpts = program.opts();
|
|
8
|
+
const token = programOpts.token || process.env.EF_TOKEN;
|
|
9
|
+
const efHost = programOpts.efHost || process.env.EF_HOST;
|
|
10
|
+
if (!token) throw new Error("EF_TOKEN must be set or supplied as command line argument");
|
|
11
|
+
client = new Client(token, efHost);
|
|
12
|
+
}
|
|
13
|
+
return client;
|
|
21
14
|
};
|
|
15
|
+
export { getClient };
|
|
@@ -1,49 +1,37 @@
|
|
|
1
|
+
import { withSpinner } from "./withSpinner.js";
|
|
1
2
|
import chalk from "chalk";
|
|
2
3
|
import debug from "debug";
|
|
3
4
|
import { chromium } from "playwright";
|
|
4
|
-
import { withSpinner } from "./withSpinner.js";
|
|
5
5
|
const browserLog = debug("ef:cli::browser");
|
|
6
6
|
async function launchBrowserAndWaitForSDK(options, fn) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
{ timeout: 1e4 }
|
|
38
|
-
);
|
|
39
|
-
return page2;
|
|
40
|
-
});
|
|
41
|
-
await fn(page);
|
|
42
|
-
if (options.interactive !== true) {
|
|
43
|
-
await browser.close();
|
|
44
|
-
process.exit(0);
|
|
45
|
-
}
|
|
7
|
+
const browser = await withSpinner("Launching chrome", async () => {
|
|
8
|
+
return chromium.launch({
|
|
9
|
+
channel: "chrome",
|
|
10
|
+
headless: options.headless ?? true,
|
|
11
|
+
devtools: options.interactive === true
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
const page = await withSpinner("Loading Editframe SDK", async () => {
|
|
15
|
+
const pageOptions = {};
|
|
16
|
+
if (options.interactive === true) pageOptions.viewport = null;
|
|
17
|
+
const page$1 = await browser.newPage(pageOptions);
|
|
18
|
+
page$1.on("console", (msg) => {
|
|
19
|
+
browserLog(chalk.blue(`browser (${msg.type()}) |`), msg.text());
|
|
20
|
+
});
|
|
21
|
+
const url = options.url + (options.efInteractive ? "" : "?EF_NONINTERACTIVE=1");
|
|
22
|
+
process.stderr.write("\nLoading url: ");
|
|
23
|
+
process.stderr.write(url);
|
|
24
|
+
process.stderr.write("\n");
|
|
25
|
+
await page$1.goto(url);
|
|
26
|
+
await page$1.waitForFunction(() => {
|
|
27
|
+
return window.EF_REGISTERED;
|
|
28
|
+
}, [], { timeout: 1e4 });
|
|
29
|
+
return page$1;
|
|
30
|
+
});
|
|
31
|
+
await fn(page);
|
|
32
|
+
if (options.interactive !== true) {
|
|
33
|
+
await browser.close();
|
|
34
|
+
process.exit(0);
|
|
35
|
+
}
|
|
46
36
|
}
|
|
47
|
-
export {
|
|
48
|
-
launchBrowserAndWaitForSDK
|
|
49
|
-
};
|
|
37
|
+
export { launchBrowserAndWaitForSDK };
|
|
@@ -1,38 +1,32 @@
|
|
|
1
|
+
import { withSpinner } from "./withSpinner.js";
|
|
1
2
|
import path from "node:path";
|
|
2
|
-
import { createServer } from "vite";
|
|
3
|
+
import { createServer } from "rolldown-vite";
|
|
3
4
|
import { vitePluginEditframe } from "@editframe/vite-plugin";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
const startPreviewServer = async (directory) => {
|
|
17
|
-
return await withSpinner("Starting vite...", async () => {
|
|
18
|
-
const resolvedDirectory = path.resolve(process.cwd(), directory);
|
|
19
|
-
const cacheRoot = path.join(resolvedDirectory, "assets");
|
|
20
|
-
const devServer = await createServer({
|
|
21
|
-
server: {
|
|
22
|
-
watch: null
|
|
23
|
-
},
|
|
24
|
-
root: resolvedDirectory,
|
|
25
|
-
plugins: [
|
|
26
|
-
vitePluginEditframe({
|
|
27
|
-
root: resolvedDirectory,
|
|
28
|
-
cacheRoot
|
|
29
|
-
})
|
|
30
|
-
]
|
|
31
|
-
});
|
|
32
|
-
await devServer.listen();
|
|
33
|
-
return devServer;
|
|
34
|
-
});
|
|
5
|
+
var PreviewServer = class PreviewServer {
|
|
6
|
+
static async start(directory) {
|
|
7
|
+
return new PreviewServer(await startPreviewServer(directory));
|
|
8
|
+
}
|
|
9
|
+
constructor(previewServer) {
|
|
10
|
+
this.previewServer = previewServer;
|
|
11
|
+
}
|
|
12
|
+
get url() {
|
|
13
|
+
return `http://localhost:${this.previewServer.config.server.port}`;
|
|
14
|
+
}
|
|
35
15
|
};
|
|
36
|
-
|
|
37
|
-
|
|
16
|
+
const startPreviewServer = async (directory) => {
|
|
17
|
+
return await withSpinner("Starting vite...", async () => {
|
|
18
|
+
const resolvedDirectory = path.resolve(process.cwd(), directory);
|
|
19
|
+
const cacheRoot = path.join(resolvedDirectory, "assets");
|
|
20
|
+
const devServer = await createServer({
|
|
21
|
+
server: { watch: null },
|
|
22
|
+
root: resolvedDirectory,
|
|
23
|
+
plugins: [vitePluginEditframe({
|
|
24
|
+
root: resolvedDirectory,
|
|
25
|
+
cacheRoot
|
|
26
|
+
})]
|
|
27
|
+
});
|
|
28
|
+
await devServer.listen();
|
|
29
|
+
return devServer;
|
|
30
|
+
});
|
|
38
31
|
};
|
|
32
|
+
export { PreviewServer };
|
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import ora from "ora";
|
|
3
1
|
import debug from "debug";
|
|
2
|
+
import ora from "ora";
|
|
3
|
+
import { z } from "zod";
|
|
4
4
|
const log = debug("ef:cli:validateVideoResolution");
|
|
5
5
|
const schema = z.object({
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
width: z.number().int(),
|
|
7
|
+
height: z.number().int()
|
|
8
8
|
}).refine((data) => data.width % 2 === 0, {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}).refine((data) => data.height % 2 === 0, {
|
|
12
|
-
message: "Height must be divisible by 2"
|
|
13
|
-
});
|
|
9
|
+
message: "Width must be divisible by 2",
|
|
10
|
+
path: ["width"]
|
|
11
|
+
}).refine((data) => data.height % 2 === 0, { message: "Height must be divisible by 2" });
|
|
14
12
|
const validateVideoResolution = async (rawPayload) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
export {
|
|
28
|
-
validateVideoResolution
|
|
13
|
+
const spinner = ora("Validating video resolution").start();
|
|
14
|
+
const result = schema.safeParse(rawPayload);
|
|
15
|
+
if (result.success) {
|
|
16
|
+
spinner.succeed("Video resolution is valid");
|
|
17
|
+
return result.data;
|
|
18
|
+
}
|
|
19
|
+
spinner.fail("Invalid video resolution");
|
|
20
|
+
process.stderr.write(result.error?.errors.map((e) => e.message).join("\n"));
|
|
21
|
+
process.stderr.write("\n");
|
|
22
|
+
log("Error:", result.error?.errors.map((e) => e.message).join("\n"));
|
|
23
|
+
process.exit(1);
|
|
29
24
|
};
|
|
25
|
+
export { validateVideoResolution };
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import ora from "ora";
|
|
2
2
|
const withSpinner = async (label, fn) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
withSpinner
|
|
3
|
+
const spinner = ora(label).start();
|
|
4
|
+
try {
|
|
5
|
+
const result = await fn();
|
|
6
|
+
spinner.succeed();
|
|
7
|
+
return result;
|
|
8
|
+
} catch (error) {
|
|
9
|
+
spinner.fail();
|
|
10
|
+
throw error;
|
|
11
|
+
}
|
|
15
12
|
};
|
|
13
|
+
export { withSpinner };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editframe/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.3-beta.0",
|
|
4
4
|
"description": "Command line interface for EditFrame",
|
|
5
5
|
"bin": {
|
|
6
6
|
"editframe": "./dist/index.js"
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
"@types/promptly": "^3.0.5",
|
|
20
20
|
"@types/tar": "^6.1.13",
|
|
21
21
|
"typescript": "^5.5.4",
|
|
22
|
-
"vite-plugin-dts": "^4.
|
|
22
|
+
"vite-plugin-dts": "^4.5.4",
|
|
23
23
|
"vite-tsconfig-paths": "^4.3.2"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@editframe/api": "0.
|
|
27
|
-
"@editframe/assets": "0.
|
|
28
|
-
"@editframe/elements": "0.
|
|
29
|
-
"@editframe/vite-plugin": "0.
|
|
26
|
+
"@editframe/api": "0.18.3-beta.0",
|
|
27
|
+
"@editframe/assets": "0.18.3-beta.0",
|
|
28
|
+
"@editframe/elements": "0.18.3-beta.0",
|
|
29
|
+
"@editframe/vite-plugin": "0.18.3-beta.0",
|
|
30
30
|
"@inquirer/prompts": "^5.3.8",
|
|
31
31
|
"axios": "^1.6.8",
|
|
32
32
|
"chalk": "^5.3.0",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"node-html-parser": "^6.1.13",
|
|
40
40
|
"ora": "^8.0.1",
|
|
41
41
|
"parse5-html-rewriting-stream": "^7.0.0",
|
|
42
|
-
"playwright": "^1.
|
|
42
|
+
"playwright": "^1.53.0",
|
|
43
43
|
"promptly": "^3.2.0",
|
|
44
|
+
"rolldown-vite": "^6.3.21",
|
|
44
45
|
"tailwindcss": "^3.4.3",
|
|
45
46
|
"tar": "^7.1.0",
|
|
46
|
-
"vite": "^6.3.5",
|
|
47
47
|
"zod": "^3.23.8"
|
|
48
48
|
}
|
|
49
49
|
}
|
package/src/commands/check.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { exec } from "node:child_process";
|
|
2
2
|
import os from "node:os";
|
|
3
|
+
import chalk from "chalk";
|
|
3
4
|
import { program } from "commander";
|
|
4
5
|
import ora from "ora";
|
|
5
|
-
import chalk from "chalk";
|
|
6
6
|
|
|
7
7
|
interface CheckDescriptor {
|
|
8
8
|
check(): Promise<boolean>;
|
|
@@ -120,7 +120,7 @@ program
|
|
|
120
120
|
spinner.succeed(
|
|
121
121
|
chalk.white.bgGreen(` Check for ${checkName} passed `),
|
|
122
122
|
);
|
|
123
|
-
} catch (
|
|
123
|
+
} catch (_error) {
|
|
124
124
|
spinner.fail(chalk.white.bgRed(` Check for ${checkName} failed `));
|
|
125
125
|
process.stderr.write(chalk.red(check.message().join("\n\n")));
|
|
126
126
|
process.stderr.write("\n");
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Probe } from "@editframe/assets";
|
|
2
|
+
import { program } from "commander";
|
|
3
|
+
|
|
4
|
+
program
|
|
5
|
+
.command("mux <path>")
|
|
6
|
+
.description("Mux a file into multiple audio/video tracks.")
|
|
7
|
+
.action(async (path: string) => {
|
|
8
|
+
const probe = await Probe.probePath(path);
|
|
9
|
+
console.log(probe);
|
|
10
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { describe, expect, test } from "vitest";
|
|
1
|
+
import { setupServer } from "msw/node";
|
|
2
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from "vitest";
|
|
3
3
|
import { fixture, withFixtures } from "../../../test-fixtures/fixture.js";
|
|
4
4
|
import {
|
|
5
5
|
mockCreateCaptionFile,
|
|
@@ -8,8 +8,17 @@ import {
|
|
|
8
8
|
mockUploadCaptionFile,
|
|
9
9
|
} from "../../../test-fixtures/network.js";
|
|
10
10
|
import { SyncCaption } from "./SyncCaption.js";
|
|
11
|
+
|
|
12
|
+
const server = setupServer();
|
|
13
|
+
|
|
11
14
|
describe("SyncCaption", async () => {
|
|
12
|
-
|
|
15
|
+
beforeAll(() => {
|
|
16
|
+
server.listen();
|
|
17
|
+
process.env.EF_TOKEN = "ef_SECRET_TOKEN";
|
|
18
|
+
process.env.EF_HOST = "http://localhost:3000";
|
|
19
|
+
});
|
|
20
|
+
afterAll(() => server.close());
|
|
21
|
+
afterEach(() => server.resetHandlers());
|
|
13
22
|
await withFixtures(
|
|
14
23
|
[fixture("test.mp4", "test.mp4")],
|
|
15
24
|
async ({ files: [video], generateCaptions }) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { describe, expect, test } from "vitest";
|
|
1
|
+
import { setupServer } from "msw/node";
|
|
2
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from "vitest";
|
|
3
3
|
import { fixture, withFixtures } from "../../../test-fixtures/fixture.js";
|
|
4
4
|
import {
|
|
5
5
|
mockCreateIsobmffFile,
|
|
@@ -9,8 +9,16 @@ import {
|
|
|
9
9
|
} from "../../../test-fixtures/network.js";
|
|
10
10
|
import { SyncFragmentIndex } from "./SyncFragmentIndex.js";
|
|
11
11
|
|
|
12
|
+
const server = setupServer();
|
|
13
|
+
|
|
12
14
|
describe("SyncFragmentIndex", async () => {
|
|
13
|
-
|
|
15
|
+
beforeAll(() => {
|
|
16
|
+
server.listen();
|
|
17
|
+
process.env.EF_TOKEN = "ef_SECRET_TOKEN";
|
|
18
|
+
process.env.EF_HOST = "http://localhost:3000";
|
|
19
|
+
});
|
|
20
|
+
afterAll(() => server.close());
|
|
21
|
+
afterEach(() => server.resetHandlers());
|
|
14
22
|
await withFixtures(
|
|
15
23
|
[fixture("test.mp4", "test.mp4")],
|
|
16
24
|
async ({ files: [video], generateTrackFragmentIndex }) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { describe, expect, test } from "vitest";
|
|
1
|
+
import { setupServer } from "msw/node";
|
|
2
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from "vitest";
|
|
3
3
|
import { fixture, withFixtures } from "../../../test-fixtures/fixture.js";
|
|
4
4
|
import {
|
|
5
5
|
mockCreateImageFile,
|
|
@@ -8,8 +8,17 @@ import {
|
|
|
8
8
|
mockLookupImageFileByMd5NotFound,
|
|
9
9
|
} from "../../../test-fixtures/network.js";
|
|
10
10
|
import { SyncImage } from "./SyncImage.js";
|
|
11
|
+
|
|
12
|
+
const server = setupServer();
|
|
13
|
+
|
|
11
14
|
describe("SyncImage", async () => {
|
|
12
|
-
|
|
15
|
+
beforeAll(() => {
|
|
16
|
+
server.listen();
|
|
17
|
+
process.env.EF_TOKEN = "ef_SECRET_TOKEN";
|
|
18
|
+
process.env.EF_HOST = "http://localhost:3000";
|
|
19
|
+
});
|
|
20
|
+
afterAll(() => server.close());
|
|
21
|
+
afterEach(() => server.resetHandlers());
|
|
13
22
|
await withFixtures(
|
|
14
23
|
[fixture("test.png", "test.png")],
|
|
15
24
|
async ({ files: [image], cacheImage }) => {
|
|
@@ -4,8 +4,8 @@ import path, { basename } from "node:path";
|
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
type CreateImageFileResult,
|
|
7
|
-
type LookupImageFileByMd5Result,
|
|
8
7
|
createImageFile,
|
|
8
|
+
type LookupImageFileByMd5Result,
|
|
9
9
|
lookupImageFileByMd5,
|
|
10
10
|
uploadImageFile,
|
|
11
11
|
} from "@editframe/api";
|
|
@@ -81,7 +81,8 @@ export class SyncImage implements SubAssetSync<CreateImageFileResult> {
|
|
|
81
81
|
| "image/jpeg"
|
|
82
82
|
| "image/png"
|
|
83
83
|
| "image/jpg"
|
|
84
|
-
| "image/webp"
|
|
84
|
+
| "image/webp"
|
|
85
|
+
| "image/svg+xml",
|
|
85
86
|
byte_size: byteSize,
|
|
86
87
|
});
|
|
87
88
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { describe, expect, test } from "vitest";
|
|
1
|
+
import { setupServer } from "msw/node";
|
|
2
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from "vitest";
|
|
3
3
|
import { fixture, withFixtures } from "../../../test-fixtures/fixture.js";
|
|
4
4
|
import {
|
|
5
5
|
mockCreateIsobmffFile,
|
|
@@ -10,8 +10,16 @@ import {
|
|
|
10
10
|
} from "../../../test-fixtures/network.js";
|
|
11
11
|
import { SyncTrack } from "./SyncTrack.js";
|
|
12
12
|
|
|
13
|
+
const server = setupServer();
|
|
14
|
+
|
|
13
15
|
describe("SyncTrack", async () => {
|
|
14
|
-
|
|
16
|
+
beforeAll(() => {
|
|
17
|
+
server.listen();
|
|
18
|
+
process.env.EF_TOKEN = "ef_SECRET_TOKEN";
|
|
19
|
+
process.env.EF_HOST = "http://localhost:3000";
|
|
20
|
+
});
|
|
21
|
+
afterAll(() => server.close());
|
|
22
|
+
afterEach(() => server.resetHandlers());
|
|
15
23
|
await withFixtures(
|
|
16
24
|
[fixture("test.mp4", "test.mp4")],
|
|
17
25
|
async ({ files: [video], generateTrack }) => {
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { useMSW } from "TEST/useMSW.js";
|
|
1
|
+
import { setupServer } from "msw/node";
|
|
2
|
+
import { afterAll, afterEach, beforeAll, describe, it } from "vitest";
|
|
4
3
|
import { fixture, withFixtures } from "../../test-fixtures/fixture.js";
|
|
5
4
|
import {
|
|
6
5
|
mockCreateImageFile,
|
|
7
6
|
mockCreateIsobmffFile,
|
|
8
7
|
mockCreateIsobmffTrack,
|
|
9
8
|
mockGetUploadImageFile,
|
|
10
|
-
mockLookupISOBMFFFileByMd5NotFound,
|
|
11
9
|
mockLookupImageFileByMd5NotFound,
|
|
10
|
+
mockLookupISOBMFFFileByMd5NotFound,
|
|
12
11
|
mockUploadIsobmffFileIndex,
|
|
13
12
|
} from "../../test-fixtures/network.js";
|
|
14
13
|
|
|
14
|
+
const server = setupServer();
|
|
15
|
+
|
|
15
16
|
describe("syncAssetsDirectory", () => {
|
|
16
|
-
|
|
17
|
+
beforeAll(() => {
|
|
18
|
+
server.listen();
|
|
19
|
+
process.env.EF_TOKEN = "ef_SECRET_TOKEN";
|
|
20
|
+
process.env.EF_HOST = "http://localhost:3000";
|
|
21
|
+
});
|
|
22
|
+
afterAll(() => server.close());
|
|
23
|
+
afterEach(() => server.resetHandlers());
|
|
17
24
|
|
|
18
25
|
describe("Image sync", () => {
|
|
19
26
|
it("Syncs assets directory when file is already uploaded", async () => {
|
|
@@ -69,14 +69,12 @@ class StreamPump {
|
|
|
69
69
|
enqueue(chunk: Uint8Array | string) {
|
|
70
70
|
if (this.controller) {
|
|
71
71
|
try {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
const available = (this.controller.desiredSize || 0) - bytes.byteLength;
|
|
75
|
-
this.controller.enqueue(bytes);
|
|
72
|
+
const available = (this.controller.desiredSize || 0) - chunk.length;
|
|
73
|
+
this.controller.enqueue(chunk as Uint8Array);
|
|
76
74
|
if (available <= 0) {
|
|
77
75
|
this.pause();
|
|
78
76
|
}
|
|
79
|
-
} catch (
|
|
77
|
+
} catch (_error: any) {
|
|
80
78
|
this.controller.error(
|
|
81
79
|
new Error(
|
|
82
80
|
"Could not create Buffer, chunk must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object",
|
|
@@ -102,7 +100,6 @@ class StreamPump {
|
|
|
102
100
|
close() {
|
|
103
101
|
if (this.controller) {
|
|
104
102
|
this.controller.close();
|
|
105
|
-
// biome-ignore lint/performance/noDelete: infrequent use
|
|
106
103
|
delete this.controller;
|
|
107
104
|
}
|
|
108
105
|
}
|
|
@@ -110,7 +107,6 @@ class StreamPump {
|
|
|
110
107
|
error(error: Error) {
|
|
111
108
|
if (this.controller) {
|
|
112
109
|
this.controller.error(error);
|
|
113
|
-
// biome-ignore lint/performance/noDelete: infrequent use
|
|
114
110
|
delete this.controller;
|
|
115
111
|
}
|
|
116
112
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
|
|
3
|
-
import tailwindcss from "tailwindcss";
|
|
4
|
-
import { type ViteDevServer, createServer } from "vite";
|
|
5
|
-
|
|
6
2
|
import { vitePluginEditframe as editframe } from "@editframe/vite-plugin";
|
|
3
|
+
import { createServer, type ViteDevServer } from "rolldown-vite";
|
|
4
|
+
import tailwindcss from "tailwindcss";
|
|
7
5
|
|
|
8
6
|
import { withSpinner } from "./withSpinner.js";
|
|
9
7
|
|
|
@@ -51,7 +49,9 @@ const startDevServer = async (directory: string) => {
|
|
|
51
49
|
build: {
|
|
52
50
|
target: "es2022",
|
|
53
51
|
rollupOptions: {
|
|
54
|
-
treeshake:
|
|
52
|
+
treeshake: {
|
|
53
|
+
moduleSideEffects: false,
|
|
54
|
+
},
|
|
55
55
|
},
|
|
56
56
|
},
|
|
57
57
|
});
|