mirror of
https://github.com/ilyhalight/voice-over-translation.git
synced 2026-04-28 03:20:22 +00:00
Switch Chrome extension packaging to .zip in CI and release workflows and add 1.11.4 distribution artifacts (chrome .zip, firefox .xpi, updated user scripts). Large source changes include a refactor/extension of the subtitles subsystem (new inlineStyle, activeCues, textSpacing, etc.), new video lifecycle host and auth refresh messaging, added background notifications/storage and bridge XHR/runtime modules, translation playback and smart-ducking runtime modules, multiple type additions and a Node crypto shim, plus numerous UI and localization updates. Also update build and Vite configs and other miscellaneous fixes across the codebase to prepare the release.
65 lines
1.4 KiB
TypeScript
65 lines
1.4 KiB
TypeScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
|
|
import { defineConfig } from "vite";
|
|
import {
|
|
createViteConfig,
|
|
defineConstants,
|
|
distDir,
|
|
testsDir,
|
|
} from "./vite.base.config";
|
|
|
|
const headersPath = path.resolve(testsDir, "headers.json");
|
|
|
|
type UserscriptHeader = Record<string, unknown>;
|
|
|
|
const testMeta = JSON.parse(
|
|
fs.readFileSync(headersPath, "utf8"),
|
|
) as UserscriptHeader;
|
|
|
|
function formatUserscriptHeader(header: UserscriptHeader): string {
|
|
const lines = ["// ==UserScript=="];
|
|
|
|
for (const [key, value] of Object.entries(header)) {
|
|
if (value === undefined) continue;
|
|
if (Array.isArray(value)) {
|
|
for (const item of value) {
|
|
lines.push(`// @${key} ${item}`);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
lines.push(`// @${key} ${value}`);
|
|
}
|
|
|
|
lines.push("// ==/UserScript==\n");
|
|
return lines.join("\n");
|
|
}
|
|
|
|
export default defineConfig(() => {
|
|
return createViteConfig({
|
|
define: {
|
|
...defineConstants({
|
|
DEBUG_MODE: true,
|
|
REPO_BRANCH: "master",
|
|
}),
|
|
},
|
|
build: {
|
|
outDir: distDir,
|
|
emptyOutDir: false,
|
|
lib: {
|
|
entry: path.resolve(testsDir, "ui.js"),
|
|
name: "testUi",
|
|
formats: ["iife"],
|
|
fileName: () => "test-ui.user.js",
|
|
},
|
|
minify: false,
|
|
sourcemap: false,
|
|
rolldownOptions: {
|
|
output: {
|
|
postBanner: formatUserscriptHeader(testMeta),
|
|
},
|
|
},
|
|
},
|
|
});
|
|
});
|