import { resolve } from "node:path";
import { LocalEditorServer } from "@zuplo/editor";
import { logger } from "../common/logger.js";
import { printDiagnosticsToConsole } from "../common/output.js";
export async function editor(argv) {
    const sourceDirectory = resolve(argv.dir);
    const server = new LocalEditorServer({
        sourceDirectory,
        deploymentUrl: `http://localhost:9000`,
        port: argv.port,
        logger,
    });
    server.start().catch((err) => logger.error(err));
    printDiagnosticsToConsole("Started route designer");
    printDiagnosticsToConsole("Ctrl+C to exit");
    printDiagnosticsToConsole("");
    printDiagnosticsToConsole(`📘 Route Designer: http://localhost:${argv.port}`);
    printDiagnosticsToConsole("");
    printDiagnosticsToConsole("");
    return new Promise((resolve) => {
        async function exit() {
            printDiagnosticsToConsole("");
            printDiagnosticsToConsole("Stopping route designer...");
            await server.close();
            resolve();
        }
        process.on("SIGTERM", exit);
        process.on("SIGINT", exit);
    });
}
//# sourceMappingURL=handler.js.map