@pep/term-deck 1.0.26 → 1.0.28
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/bin/term-deck.js +136 -45
- package/dist/bin/term-deck.js.map +1 -1
- package/package.json +3 -1
package/dist/bin/term-deck.js
CHANGED
|
@@ -12,8 +12,10 @@ import 'deepmerge';
|
|
|
12
12
|
import { mermaidToAscii as mermaidToAscii$1 } from 'mermaid-ascii';
|
|
13
13
|
import figlet from 'figlet';
|
|
14
14
|
import { Command } from 'commander';
|
|
15
|
+
import { intro, log, outro, spinner } from '@clack/prompts';
|
|
15
16
|
import { tmpdir } from 'os';
|
|
16
17
|
import { execa } from 'execa';
|
|
18
|
+
import pc from 'picocolors';
|
|
17
19
|
|
|
18
20
|
var __defProp = Object.defineProperty;
|
|
19
21
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -1397,7 +1399,7 @@ var init_main = __esm({
|
|
|
1397
1399
|
init_esm_shims();
|
|
1398
1400
|
|
|
1399
1401
|
// package.json
|
|
1400
|
-
var version = "1.0.
|
|
1402
|
+
var version = "1.0.28";
|
|
1401
1403
|
|
|
1402
1404
|
// src/cli/commands/present.ts
|
|
1403
1405
|
init_esm_shims();
|
|
@@ -1409,56 +1411,52 @@ init_validation();
|
|
|
1409
1411
|
init_slide2();
|
|
1410
1412
|
init_deck_loader();
|
|
1411
1413
|
init_theme2();
|
|
1412
|
-
function handleError(
|
|
1413
|
-
if (
|
|
1414
|
-
|
|
1415
|
-
${error.message}`);
|
|
1414
|
+
function handleError(errorObj) {
|
|
1415
|
+
if (errorObj instanceof ValidationError) {
|
|
1416
|
+
log.error(errorObj.message);
|
|
1416
1417
|
process.exit(1);
|
|
1417
1418
|
}
|
|
1418
|
-
if (
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
console.error(` Caused by: ${causeMessage}`);
|
|
1419
|
+
if (errorObj instanceof SlideParseError) {
|
|
1420
|
+
log.error(`Slide error in ${errorObj.filePath}`);
|
|
1421
|
+
log.message(` ${errorObj.message}`);
|
|
1422
|
+
if (errorObj.cause) {
|
|
1423
|
+
const causeMessage = errorObj.cause instanceof Error ? errorObj.cause.message : String(errorObj.cause);
|
|
1424
|
+
log.message(` \u2192 ${causeMessage}`);
|
|
1425
1425
|
}
|
|
1426
1426
|
process.exit(1);
|
|
1427
1427
|
}
|
|
1428
|
-
if (
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
console.error(` ${error.message}`);
|
|
1428
|
+
if (errorObj instanceof DeckLoadError) {
|
|
1429
|
+
log.error(`Failed to load deck from ${errorObj.slidesDir}`);
|
|
1430
|
+
log.message(` ${errorObj.message}`);
|
|
1432
1431
|
process.exit(1);
|
|
1433
1432
|
}
|
|
1434
|
-
if (
|
|
1435
|
-
|
|
1436
|
-
|
|
1433
|
+
if (errorObj instanceof ThemeError) {
|
|
1434
|
+
log.error("Theme error");
|
|
1435
|
+
log.message(` ${errorObj.message}`);
|
|
1437
1436
|
process.exit(1);
|
|
1438
1437
|
}
|
|
1439
|
-
if (
|
|
1440
|
-
if (
|
|
1441
|
-
|
|
1442
|
-
|
|
1438
|
+
if (errorObj instanceof Error) {
|
|
1439
|
+
if (errorObj.message.includes("ENOENT")) {
|
|
1440
|
+
log.error("File not found");
|
|
1441
|
+
log.message(` ${errorObj.message}`);
|
|
1443
1442
|
process.exit(1);
|
|
1444
1443
|
}
|
|
1445
|
-
if (
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1444
|
+
if (errorObj.message.includes("ffmpeg")) {
|
|
1445
|
+
log.error("ffmpeg not found");
|
|
1446
|
+
log.message(` ${errorObj.message}`);
|
|
1447
|
+
log.info("Installation:");
|
|
1448
|
+
log.message(" macOS: brew install ffmpeg");
|
|
1449
|
+
log.message(" Ubuntu: sudo apt install ffmpeg");
|
|
1451
1450
|
process.exit(1);
|
|
1452
1451
|
}
|
|
1453
|
-
|
|
1454
|
-
Error: ${error.message}`);
|
|
1452
|
+
log.error(errorObj.message);
|
|
1455
1453
|
if (process.env.DEBUG) {
|
|
1456
|
-
console.error(
|
|
1454
|
+
console.error("\n" + errorObj.stack);
|
|
1457
1455
|
}
|
|
1458
1456
|
process.exit(1);
|
|
1459
1457
|
}
|
|
1460
|
-
|
|
1461
|
-
console.error(
|
|
1458
|
+
log.error("Unknown error occurred");
|
|
1459
|
+
console.error(String(errorObj));
|
|
1462
1460
|
process.exit(1);
|
|
1463
1461
|
}
|
|
1464
1462
|
|
|
@@ -1763,11 +1761,13 @@ async function encodeFramesToVideo(tempDir, output, format, fps, quality) {
|
|
|
1763
1761
|
});
|
|
1764
1762
|
}
|
|
1765
1763
|
async function exportPresentation(slidesDir, options) {
|
|
1764
|
+
intro("term-deck export");
|
|
1766
1765
|
await checkFfmpeg();
|
|
1767
1766
|
const format = detectFormat(options.output);
|
|
1768
1767
|
const deck = await loadDeck(slidesDir);
|
|
1769
1768
|
if (deck.slides.length === 0) {
|
|
1770
|
-
|
|
1769
|
+
log.error(`No slides found in ${slidesDir}`);
|
|
1770
|
+
process.exit(1);
|
|
1771
1771
|
}
|
|
1772
1772
|
const session = await createRecordingSession(options);
|
|
1773
1773
|
const vt = new VirtualTerminal(session.width, session.height);
|
|
@@ -1775,11 +1775,12 @@ async function exportPresentation(slidesDir, options) {
|
|
|
1775
1775
|
setScreenDimensions(renderer.screen, session.width, session.height);
|
|
1776
1776
|
const slideTime = options.slideTime ?? 3;
|
|
1777
1777
|
const framesPerSlide = session.fps * slideTime;
|
|
1778
|
-
|
|
1778
|
+
const s = spinner();
|
|
1779
|
+
s.start(`Exporting ${deck.slides.length} slides`);
|
|
1779
1780
|
try {
|
|
1780
1781
|
for (let i = 0; i < deck.slides.length; i++) {
|
|
1781
1782
|
const slide = deck.slides[i];
|
|
1782
|
-
|
|
1783
|
+
s.message(`Slide ${i + 1}/${deck.slides.length}: ${slide.frontmatter.title}`);
|
|
1783
1784
|
await renderSlide2(renderer, slide);
|
|
1784
1785
|
for (let f = 0; f < framesPerSlide; f++) {
|
|
1785
1786
|
renderer.screen.render();
|
|
@@ -1788,7 +1789,9 @@ async function exportPresentation(slidesDir, options) {
|
|
|
1788
1789
|
await saveFrame(session, png);
|
|
1789
1790
|
}
|
|
1790
1791
|
}
|
|
1791
|
-
|
|
1792
|
+
s.stop("Slides processed");
|
|
1793
|
+
const encodeSpinner = spinner();
|
|
1794
|
+
encodeSpinner.start("Encoding video");
|
|
1792
1795
|
await encodeFramesToVideo(
|
|
1793
1796
|
session.tempDir,
|
|
1794
1797
|
options.output,
|
|
@@ -1796,7 +1799,8 @@ async function exportPresentation(slidesDir, options) {
|
|
|
1796
1799
|
session.fps,
|
|
1797
1800
|
options.quality
|
|
1798
1801
|
);
|
|
1799
|
-
|
|
1802
|
+
encodeSpinner.stop(`Exported to ${options.output}`);
|
|
1803
|
+
outro("Export complete");
|
|
1800
1804
|
} finally {
|
|
1801
1805
|
destroyRenderer(renderer);
|
|
1802
1806
|
await cleanupSession(session);
|
|
@@ -1828,11 +1832,12 @@ var exportCommand = new Command("export").description("Export presentation to GI
|
|
|
1828
1832
|
init_esm_shims();
|
|
1829
1833
|
var initCommand = new Command("init").description("Create a new presentation deck").argument("<name>", "Deck name (will create directory)").option("-t, --theme <name>", "Theme to use", "matrix").action(async (name, options) => {
|
|
1830
1834
|
try {
|
|
1835
|
+
intro(`Creating ${name}`);
|
|
1831
1836
|
await initDeck(name, options.theme);
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1837
|
+
log.success(`Created ${name}/`);
|
|
1838
|
+
log.step("cd " + name);
|
|
1839
|
+
log.step("term-deck present .");
|
|
1840
|
+
outro("Ready to present!");
|
|
1836
1841
|
} catch (error) {
|
|
1837
1842
|
handleError(error);
|
|
1838
1843
|
}
|
|
@@ -1937,9 +1942,95 @@ term-deck export . -o ${name}.gif
|
|
|
1937
1942
|
await writeFile(join(deckDir, "README.md"), readme);
|
|
1938
1943
|
}
|
|
1939
1944
|
|
|
1945
|
+
// src/cli/help.ts
|
|
1946
|
+
init_esm_shims();
|
|
1947
|
+
function showHelp() {
|
|
1948
|
+
console.log("");
|
|
1949
|
+
const boxTop = pc.bold(pc.green("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"));
|
|
1950
|
+
const boxTitle = pc.bold(pc.green("\u2502")) + pc.bold(" ") + pc.bold(pc.cyan("term-deck")) + pc.bold(" ") + pc.bold(pc.green("\u2502"));
|
|
1951
|
+
const boxLine1 = `${pc.bold(pc.green("\u2502"))} ${pc.dim("Terminal presentation tool with a cyberpunk aesthetic")} ${pc.bold(pc.green("\u2502"))}`;
|
|
1952
|
+
const boxBottom = pc.bold(pc.green("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"));
|
|
1953
|
+
console.log(boxTop);
|
|
1954
|
+
console.log(boxTitle);
|
|
1955
|
+
console.log(boxLine1);
|
|
1956
|
+
console.log(boxBottom);
|
|
1957
|
+
console.log("");
|
|
1958
|
+
console.log(pc.bold(pc.magenta("\u25B6 QUICK START:")));
|
|
1959
|
+
console.log("");
|
|
1960
|
+
console.log(pc.cyan(" \u26A1 Create a new deck"));
|
|
1961
|
+
console.log(pc.dim(" term-deck init my-talk"));
|
|
1962
|
+
console.log("");
|
|
1963
|
+
console.log(pc.cyan(" \u{1F3AC} Start presenting"));
|
|
1964
|
+
console.log(pc.dim(" cd my-talk && term-deck present ."));
|
|
1965
|
+
console.log("");
|
|
1966
|
+
console.log(pc.cyan(" \u{1F4F9} Export to video"));
|
|
1967
|
+
console.log(pc.dim(" term-deck export . -o presentation.mp4"));
|
|
1968
|
+
console.log("");
|
|
1969
|
+
console.log(pc.bold(pc.yellow("\u25B6 COMMANDS:")));
|
|
1970
|
+
console.log("");
|
|
1971
|
+
console.log(pc.green(" present") + pc.dim(" <dir> ") + pc.white("Start a presentation"));
|
|
1972
|
+
console.log(pc.dim(" -s, --start <n> ") + pc.white("Start at slide number"));
|
|
1973
|
+
console.log(pc.dim(" -n, --notes ") + pc.white("Show presenter notes"));
|
|
1974
|
+
console.log(pc.dim(" -l, --loop ") + pc.white("Loop back after last slide"));
|
|
1975
|
+
console.log("");
|
|
1976
|
+
console.log(pc.green(" export") + pc.dim(" <dir> ") + pc.white("Export to GIF or MP4"));
|
|
1977
|
+
console.log(pc.dim(" -o, --output <file> ") + pc.white("Output file (.mp4 or .gif)"));
|
|
1978
|
+
console.log(pc.dim(" -w, --width <n> ") + pc.white("Terminal width (default: 120)"));
|
|
1979
|
+
console.log(pc.dim(" -h, --height <n> ") + pc.white("Terminal height (default: 40)"));
|
|
1980
|
+
console.log(pc.dim(" --fps <n> ") + pc.white("Frames per second (default: 30)"));
|
|
1981
|
+
console.log(pc.dim(" -t, --slide-time <n> ") + pc.white("Seconds per slide (default: 3)"));
|
|
1982
|
+
console.log(pc.dim(" -q, --quality <n> ") + pc.white("Quality 1-100 (default: 80)"));
|
|
1983
|
+
console.log("");
|
|
1984
|
+
console.log(pc.green(" init") + pc.dim(" <name> ") + pc.white("Create a new presentation deck"));
|
|
1985
|
+
console.log(pc.dim(" -t, --theme <name> ") + pc.white("Theme preset (default: matrix)"));
|
|
1986
|
+
console.log("");
|
|
1987
|
+
console.log(pc.bold(pc.cyan("\u25B6 HOTKEYS:")));
|
|
1988
|
+
console.log("");
|
|
1989
|
+
console.log(pc.dim(" Space / \u2192 ") + pc.white("Next slide"));
|
|
1990
|
+
console.log(pc.dim(" \u2190 ") + pc.white("Previous slide"));
|
|
1991
|
+
console.log(pc.dim(" 0-9 ") + pc.white("Jump to slide"));
|
|
1992
|
+
console.log(pc.dim(" l ") + pc.white("Show slide list"));
|
|
1993
|
+
console.log(pc.dim(" q ") + pc.white("Quit"));
|
|
1994
|
+
console.log("");
|
|
1995
|
+
console.log(pc.bold(pc.blue("\u25B6 SLIDE FORMAT:")));
|
|
1996
|
+
console.log("");
|
|
1997
|
+
console.log(pc.dim(" Slides are Markdown files with YAML frontmatter:"));
|
|
1998
|
+
console.log("");
|
|
1999
|
+
console.log(pc.green(" ---"));
|
|
2000
|
+
console.log(pc.yellow(" title: ") + pc.white("MY SLIDE"));
|
|
2001
|
+
console.log(pc.yellow(" bigText: ") + pc.white("HELLO"));
|
|
2002
|
+
console.log(pc.yellow(" gradient: ") + pc.white("fire"));
|
|
2003
|
+
console.log(pc.green(" ---"));
|
|
2004
|
+
console.log(pc.dim(" Your slide content here..."));
|
|
2005
|
+
console.log("");
|
|
2006
|
+
console.log(pc.bold(pc.red("\u25B6 TEXT COLORS:")));
|
|
2007
|
+
console.log("");
|
|
2008
|
+
console.log(pc.dim(" Use tags in your slides:"));
|
|
2009
|
+
console.log(` ${pc.green("{GREEN}")}text${pc.green("{/}")} ${pc.cyan("{CYAN}")}text${pc.cyan("{/}")} ${pc.red("{RED}")}text${pc.red("{/}")} ${pc.yellow("{ORANGE}")}text${pc.yellow("{/}")}`);
|
|
2010
|
+
console.log("");
|
|
2011
|
+
console.log(pc.green("\u2728") + pc.dim(" Happy presenting!"));
|
|
2012
|
+
console.log("");
|
|
2013
|
+
}
|
|
2014
|
+
function showVersion(version2) {
|
|
2015
|
+
console.log("");
|
|
2016
|
+
console.log(pc.bold(pc.cyan("term-deck")) + pc.dim(` v${version2}`));
|
|
2017
|
+
console.log("");
|
|
2018
|
+
}
|
|
2019
|
+
|
|
1940
2020
|
// bin/term-deck.ts
|
|
2021
|
+
var args = process.argv.slice(2);
|
|
2022
|
+
if (args.includes("-h") || args.includes("--help") || args.length === 0) {
|
|
2023
|
+
if (!args.some((arg) => ["present", "export", "init"].includes(arg))) {
|
|
2024
|
+
showHelp();
|
|
2025
|
+
process.exit(0);
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
if (args.includes("-V") || args.includes("--version")) {
|
|
2029
|
+
showVersion(version);
|
|
2030
|
+
process.exit(0);
|
|
2031
|
+
}
|
|
1941
2032
|
var program = new Command();
|
|
1942
|
-
program.name("term-deck").description("Terminal presentation tool with a cyberpunk aesthetic").version(version);
|
|
2033
|
+
program.name("term-deck").description("Terminal presentation tool with a cyberpunk aesthetic").version(version, "-V, --version", "output the version number").helpOption("-h, --help", "display help for command");
|
|
1943
2034
|
program.addCommand(presentCommand);
|
|
1944
2035
|
program.addCommand(exportCommand);
|
|
1945
2036
|
program.addCommand(initCommand);
|
|
@@ -1952,7 +2043,7 @@ program.argument("[dir]", "Slides directory to present").action(async (dir) => {
|
|
|
1952
2043
|
handleError(error);
|
|
1953
2044
|
}
|
|
1954
2045
|
} else {
|
|
1955
|
-
|
|
2046
|
+
showHelp();
|
|
1956
2047
|
}
|
|
1957
2048
|
});
|
|
1958
2049
|
program.parse();
|