Rewrite frontend as single self-contained HTML file — all CSS/JS inline, no external files to fail loading
This commit is contained in:
3
dist/server/db/index.d.ts
vendored
Normal file
3
dist/server/db/index.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import Database from 'better-sqlite3';
|
||||
export declare function getDb(): Database.Database;
|
||||
export declare function closeDb(): void;
|
||||
62
dist/server/db/index.js
vendored
Normal file
62
dist/server/db/index.js
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getDb = getDb;
|
||||
exports.closeDb = closeDb;
|
||||
const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const DB_PATH = path_1.default.resolve('./data/server.db');
|
||||
let db;
|
||||
function getDb() {
|
||||
if (!db) {
|
||||
const dir = path_1.default.dirname(DB_PATH);
|
||||
if (!fs_1.default.existsSync(dir)) {
|
||||
fs_1.default.mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
db = new better_sqlite3_1.default(DB_PATH);
|
||||
db.pragma('journal_mode = WAL');
|
||||
db.pragma('foreign_keys = ON');
|
||||
migrate();
|
||||
}
|
||||
return db;
|
||||
}
|
||||
function migrate() {
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS jobs (
|
||||
id TEXT PRIMARY KEY,
|
||||
video_path TEXT NOT NULL,
|
||||
video_filename TEXT NOT NULL,
|
||||
status TEXT NOT NULL DEFAULT 'pending',
|
||||
config TEXT NOT NULL,
|
||||
progress REAL DEFAULT 0,
|
||||
current_index INTEGER DEFAULT 0,
|
||||
total_units INTEGER DEFAULT 0,
|
||||
segments TEXT DEFAULT '[]',
|
||||
last_context TEXT DEFAULT '{}',
|
||||
current_time_position REAL DEFAULT 0,
|
||||
error TEXT,
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL,
|
||||
completed_at TEXT,
|
||||
output_audio TEXT,
|
||||
output_subtitles_srt TEXT,
|
||||
output_subtitles_vtt TEXT,
|
||||
output_muxed TEXT,
|
||||
output_options TEXT DEFAULT '{}'
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS config (
|
||||
key TEXT PRIMARY KEY,
|
||||
value TEXT NOT NULL
|
||||
);
|
||||
`);
|
||||
}
|
||||
function closeDb() {
|
||||
if (db) {
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
dist/server/db/index.js.map
vendored
Normal file
1
dist/server/db/index.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/db/index.ts"],"names":[],"mappings":";;;;;AAQA,sBAYC;AAkCD,0BAIC;AA1DD,oEAAsC;AACtC,gDAAwB;AACxB,4CAAoB;AAEpB,MAAM,OAAO,GAAG,cAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAEjD,IAAI,EAAqB,CAAC;AAE1B,SAAgB,KAAK;IACnB,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,MAAM,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAClC,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,YAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,CAAC;QACD,EAAE,GAAG,IAAI,wBAAQ,CAAC,OAAO,CAAC,CAAC;QAC3B,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;QAChC,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;QAC/B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,OAAO;IACd,EAAE,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BP,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,OAAO;IACrB,IAAI,EAAE,EAAE,CAAC;QACP,EAAE,CAAC,KAAK,EAAE,CAAC;IACb,CAAC;AACH,CAAC"}
|
||||
42
dist/server/db/jobStore.d.ts
vendored
Normal file
42
dist/server/db/jobStore.d.ts
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
export interface OutputOptions {
|
||||
audio: boolean;
|
||||
subtitles: boolean;
|
||||
muxed: boolean;
|
||||
}
|
||||
export interface Job {
|
||||
id: string;
|
||||
video_path: string;
|
||||
video_filename: string;
|
||||
status: 'pending' | 'queued' | 'processing' | 'paused' | 'completed' | 'failed' | 'cancelled';
|
||||
config: string;
|
||||
progress: number;
|
||||
current_index: number;
|
||||
total_units: number;
|
||||
segments: string;
|
||||
last_context: string;
|
||||
current_time_position: number;
|
||||
error: string | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
completed_at: string | null;
|
||||
output_audio: string | null;
|
||||
output_subtitles_srt: string | null;
|
||||
output_subtitles_vtt: string | null;
|
||||
output_muxed: string | null;
|
||||
output_options: string;
|
||||
}
|
||||
export declare function getAllJobs(): Job[];
|
||||
export declare function getJob(id: string): Job | undefined;
|
||||
export declare function createJob(videoPath: string, filename: string, config: object, outputOptions: OutputOptions): Job;
|
||||
export declare function updateJobStatus(id: string, status: Job['status'], error?: string): void;
|
||||
export declare function saveCheckpoint(id: string, segments: string, currentIndex: number, totalUnits: number, currentTimePosition: number, lastContext: string, progress: number): void;
|
||||
export declare function saveJobOutputs(id: string, outputs: {
|
||||
audio?: string;
|
||||
subtitlesSrt?: string;
|
||||
subtitlesVtt?: string;
|
||||
muxed?: string;
|
||||
}): void;
|
||||
export declare function deleteJob(id: string): void;
|
||||
export declare function getConfigValue(key: string): string | undefined;
|
||||
export declare function setConfigValue(key: string, value: string): void;
|
||||
export declare function getAllConfig(): Record<string, string>;
|
||||
77
dist/server/db/jobStore.js
vendored
Normal file
77
dist/server/db/jobStore.js
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getAllJobs = getAllJobs;
|
||||
exports.getJob = getJob;
|
||||
exports.createJob = createJob;
|
||||
exports.updateJobStatus = updateJobStatus;
|
||||
exports.saveCheckpoint = saveCheckpoint;
|
||||
exports.saveJobOutputs = saveJobOutputs;
|
||||
exports.deleteJob = deleteJob;
|
||||
exports.getConfigValue = getConfigValue;
|
||||
exports.setConfigValue = setConfigValue;
|
||||
exports.getAllConfig = getAllConfig;
|
||||
const db_1 = require("../db");
|
||||
const uuid_1 = require("uuid");
|
||||
function getAllJobs() {
|
||||
const db = (0, db_1.getDb)();
|
||||
return db.prepare('SELECT * FROM jobs ORDER BY created_at DESC').all();
|
||||
}
|
||||
function getJob(id) {
|
||||
const db = (0, db_1.getDb)();
|
||||
return db.prepare('SELECT * FROM jobs WHERE id = ?').get(id);
|
||||
}
|
||||
function createJob(videoPath, filename, config, outputOptions) {
|
||||
const db = (0, db_1.getDb)();
|
||||
const id = (0, uuid_1.v4)();
|
||||
const now = new Date().toISOString();
|
||||
db.prepare(`
|
||||
INSERT INTO jobs (id, video_path, video_filename, config, output_options, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
`).run(id, videoPath, filename, JSON.stringify(config), JSON.stringify(outputOptions), now, now);
|
||||
return getJob(id);
|
||||
}
|
||||
function updateJobStatus(id, status, error) {
|
||||
const db = (0, db_1.getDb)();
|
||||
const now = new Date().toISOString();
|
||||
const completedAt = status === 'completed' ? now : null;
|
||||
db.prepare(`
|
||||
UPDATE jobs SET status = ?, error = ?, updated_at = ?, completed_at = ? WHERE id = ?
|
||||
`).run(status, error || null, now, completedAt, id);
|
||||
}
|
||||
function saveCheckpoint(id, segments, currentIndex, totalUnits, currentTimePosition, lastContext, progress) {
|
||||
const db = (0, db_1.getDb)();
|
||||
const now = new Date().toISOString();
|
||||
db.prepare(`
|
||||
UPDATE jobs SET segments = ?, current_index = ?, total_units = ?, current_time_position = ?, last_context = ?, progress = ?, updated_at = ? WHERE id = ?
|
||||
`).run(segments, currentIndex, totalUnits, currentTimePosition, lastContext, progress, now, id);
|
||||
}
|
||||
function saveJobOutputs(id, outputs) {
|
||||
const db = (0, db_1.getDb)();
|
||||
const now = new Date().toISOString();
|
||||
db.prepare(`
|
||||
UPDATE jobs SET output_audio = ?, output_subtitles_srt = ?, output_subtitles_vtt = ?, output_muxed = ?, updated_at = ? WHERE id = ?
|
||||
`).run(outputs.audio || null, outputs.subtitlesSrt || null, outputs.subtitlesVtt || null, outputs.muxed || null, now, id);
|
||||
}
|
||||
function deleteJob(id) {
|
||||
const db = (0, db_1.getDb)();
|
||||
db.prepare('DELETE FROM jobs WHERE id = ?').run(id);
|
||||
}
|
||||
function getConfigValue(key) {
|
||||
const db = (0, db_1.getDb)();
|
||||
const row = db.prepare('SELECT value FROM config WHERE key = ?').get(key);
|
||||
return row?.value;
|
||||
}
|
||||
function setConfigValue(key, value) {
|
||||
const db = (0, db_1.getDb)();
|
||||
db.prepare('INSERT OR REPLACE INTO config (key, value) VALUES (?, ?)').run(key, value);
|
||||
}
|
||||
function getAllConfig() {
|
||||
const db = (0, db_1.getDb)();
|
||||
const rows = db.prepare('SELECT key, value FROM config').all();
|
||||
const config = {};
|
||||
for (const row of rows) {
|
||||
config[row.key] = row.value;
|
||||
}
|
||||
return config;
|
||||
}
|
||||
//# sourceMappingURL=jobStore.js.map
|
||||
1
dist/server/db/jobStore.js.map
vendored
Normal file
1
dist/server/db/jobStore.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"jobStore.js","sourceRoot":"","sources":["../../../src/server/db/jobStore.ts"],"names":[],"mappings":";;AAgCA,gCAGC;AAED,wBAGC;AAED,8BAWC;AAED,0CAOC;AAED,wCAcC;AAED,wCAgBC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