@hirokisakabe/pom-cli 0.6.6 → 0.8.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/README.md +14 -1
- package/dist/cli.js +12 -0
- package/dist/preview.js +1 -1
- package/dist/render.js +2 -2
- package/dist/theme.d.ts +2 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +12 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -15,13 +15,14 @@
|
|
|
15
15
|
- **Live Preview Server** — `pom preview` opens a browser, watches the source file, and rebuilds + reloads on every save (handles editor atomic writes like Vim).
|
|
16
16
|
- **PPTX Build** — `pom build` converts `.pom.xml` / `.pom.md` to a `.pptx` file, with optional `--watch` mode for incremental rebuilds.
|
|
17
17
|
- **PNG / SVG Render** — `pom render` rasterizes each slide to PNG (default) or SVG without LibreOffice, useful for slide-image previews in docs.
|
|
18
|
+
- **Theme Extraction** — `pom theme extract` reads an existing `.pptx` and prints its theme colors as pom `ThemeTokens` JSON, for onboarding brand assets.
|
|
18
19
|
- **Diagnostic Surfacing** — Layout, image, master, and auto-fit diagnostics from `buildPptx` fail the run on stderr with a non-zero exit (`pom build` / `pom render`), while `pom preview` keeps updating so issues can be fixed interactively.
|
|
19
20
|
- **Bundled Fonts** — Carlito and Noto Sans CJK JP are bundled for SVG / PNG rendering, so output looks the same on machines without those fonts installed.
|
|
20
21
|
- **Configurable Output** — Choose port, target slides, output format, text rendering mode (`path` outlines vs native `<text>`), and verbose per-step timing.
|
|
21
22
|
|
|
22
23
|
## Installation
|
|
23
24
|
|
|
24
|
-
> Requires Node.js
|
|
25
|
+
> Requires Node.js 22+
|
|
25
26
|
|
|
26
27
|
```bash
|
|
27
28
|
npm install -g @hirokisakabe/pom-cli
|
|
@@ -113,6 +114,8 @@ pom render slides.pom.md -o ./images
|
|
|
113
114
|
|
|
114
115
|
The images are written to the output directory as `slide-01.png`, `slide-02.png`, ... The directory is created if it does not exist. The rendering pipeline is the same as the preview server, so the images match what you see in `pom preview`.
|
|
115
116
|
|
|
117
|
+
> **LibreOffice fallback caveat:** Current `pom render` uses `pptx-glimpse` directly and does not require LibreOffice. If you are using an older `pom-cli` / `pptx-glimpse` version or a fallback workflow that converts PPTX through LibreOffice before PNG output, pure numeric text with leading zeros (for example `01` / `001`) may be displayed without those zeros in the PNG (`01` -> `1`). The generated PPTX keeps the original text (`<a:t>01</a:t>`), so it displays as intended when opened in PowerPoint. For decorative numbering that must survive both paths, mix in one non-numeric character such as `01.` or `#01`.
|
|
118
|
+
|
|
116
119
|
To output SVG instead of PNG:
|
|
117
120
|
|
|
118
121
|
```bash
|
|
@@ -137,6 +140,16 @@ To print per-step timing on stderr:
|
|
|
137
140
|
pom render slides.pom.xml -o ./images --verbose
|
|
138
141
|
```
|
|
139
142
|
|
|
143
|
+
### Theme Extract
|
|
144
|
+
|
|
145
|
+
Extracts PowerPoint theme colors from an existing `.pptx` as pom `ThemeTokens` JSON — useful for onboarding brand assets (e.g. the `pom-theme` agent skill).
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
pom theme extract brand-master.pptx
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Prints a JSON array to stdout with one entry per visible slide layout (`text` / `background` / `primary` / `secondary` / `accent3`–`accent6`, all 6-digit uppercase hex prefixed with `#`), preserving the source master/layout order.
|
|
152
|
+
|
|
140
153
|
## Diagnostics
|
|
141
154
|
|
|
142
155
|
`pom build` and `pom render` invoke `buildPptx` with `strict: true`, so any diagnostic collected during the build — layout problems (`NODE_OUT_OF_BOUNDS`, `NODE_OVERLAP`, `ARROW_REF_NOT_FOUND`, `PER_SIDE_BORDER_WITH_RADIUS`), image / master issues (`IMAGE_MEASURE_FAILED`, `IMAGE_NOT_PREFETCHED`, `MASTER_PPTX_PARSE_FAILED`), or `AUTOFIT_OVERFLOW` — fails the run with a non-zero exit code and prints the diagnostic codes / messages to stderr. Fix the offending XML or input and re-run to proceed. The `pom preview` server continues to update even when diagnostics are emitted, so you can iterate on the file interactively.
|
package/dist/cli.js
CHANGED
|
@@ -5,6 +5,7 @@ import { DiagnosticsError } from "@hirokisakabe/pom";
|
|
|
5
5
|
import { runBuild, runBuildWatch } from "./build.js";
|
|
6
6
|
import { runPreview } from "./preview.js";
|
|
7
7
|
import { runRender } from "./render.js";
|
|
8
|
+
import { runThemeExtract } from "./theme.js";
|
|
8
9
|
const require = createRequire(import.meta.url);
|
|
9
10
|
const { version } = require("../package.json");
|
|
10
11
|
const program = new Command();
|
|
@@ -117,4 +118,15 @@ program
|
|
|
117
118
|
process.exit(1);
|
|
118
119
|
});
|
|
119
120
|
});
|
|
121
|
+
const theme = program.command("theme").description("Theme-related utilities");
|
|
122
|
+
theme
|
|
123
|
+
.command("extract")
|
|
124
|
+
.description("Extract PowerPoint theme colors as pom ThemeTokens JSON (one entry per visible slide layout)")
|
|
125
|
+
.argument("<pptx>", "Input PPTX file")
|
|
126
|
+
.action((pptx) => {
|
|
127
|
+
runThemeExtract(pptx).catch((err) => {
|
|
128
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
129
|
+
process.exit(1);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
120
132
|
program.parse();
|
package/dist/preview.js
CHANGED
|
@@ -55,7 +55,7 @@ async function generateSvgs(inputFile, verbose = false) {
|
|
|
55
55
|
const t2 = Date.now();
|
|
56
56
|
// インライン SVG なのでネイティブ <text> + サブセットフォント埋め込みが使える。
|
|
57
57
|
// ブラウザのテキスト描画 (ヒンティング等) が効き、テキスト選択も可能になる
|
|
58
|
-
const slides = await convertPptxToSvg(buffer, {
|
|
58
|
+
const { slides } = await convertPptxToSvg(buffer, {
|
|
59
59
|
width: slideWidth,
|
|
60
60
|
fontDirs,
|
|
61
61
|
fontMapping: EXTRA_FONT_MAPPING,
|
package/dist/render.js
CHANGED
|
@@ -42,14 +42,14 @@ export async function runRender(inputFile, outputDir, options = {}) {
|
|
|
42
42
|
const t2 = Date.now();
|
|
43
43
|
let outputs;
|
|
44
44
|
if (format === "svg") {
|
|
45
|
-
const slides = await convertPptxToSvg(buffer, {
|
|
45
|
+
const { slides } = await convertPptxToSvg(buffer, {
|
|
46
46
|
...convertOptions,
|
|
47
47
|
...(options.textOutput ? { textOutput: options.textOutput } : {}),
|
|
48
48
|
});
|
|
49
49
|
outputs = slides.map((s) => ({ slideNumber: s.slideNumber, data: s.svg }));
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
|
-
const slides = await convertPptxToPng(buffer, convertOptions);
|
|
52
|
+
const { slides } = await convertPptxToPng(buffer, convertOptions);
|
|
53
53
|
outputs = slides.map((s) => ({ slideNumber: s.slideNumber, data: s.png }));
|
|
54
54
|
}
|
|
55
55
|
log(`Rendering ${format.toUpperCase()}... done (${Date.now() - t2}ms)`);
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAIA,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUtE"}
|
package/dist/theme.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { extractThemeTokensFromPptx } from "@hirokisakabe/pom";
|
|
4
|
+
export async function runThemeExtract(inputFile) {
|
|
5
|
+
const absInput = path.resolve(inputFile);
|
|
6
|
+
if (!fs.existsSync(absInput)) {
|
|
7
|
+
throw new Error(`Input file not found: ${absInput}`);
|
|
8
|
+
}
|
|
9
|
+
const buffer = fs.readFileSync(absInput);
|
|
10
|
+
const tokens = await extractThemeTokensFromPptx(buffer);
|
|
11
|
+
console.log(JSON.stringify(tokens, null, 2));
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hirokisakabe/pom-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "CLI tool for pom — preview, build, and render presentations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -27,16 +27,16 @@
|
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"author": "Hiroki Sakabe",
|
|
29
29
|
"engines": {
|
|
30
|
-
"node": ">=
|
|
30
|
+
"node": ">=22"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@hirokisakabe/pom": "^
|
|
34
|
-
"@hirokisakabe/pom-md": "^
|
|
33
|
+
"@hirokisakabe/pom": "^9.1.0",
|
|
34
|
+
"@hirokisakabe/pom-md": "^4.0.0",
|
|
35
35
|
"commander": "^15.0.0",
|
|
36
|
-
"pptx-glimpse": "^
|
|
36
|
+
"pptx-glimpse": "^2.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@types/node": "^
|
|
39
|
+
"@types/node": "^26.1.0"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "tsc && node -e \"require('fs').chmodSync('dist/cli.js', '755')\"",
|