@hirokisakabe/pom-cli 0.2.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/LICENSE +21 -0
- package/README.md +39 -0
- package/dist/build.d.ts +2 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +47 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +38 -0
- package/dist/preview.d.ts +2 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +302 -0
- package/fonts/Carlito-Bold.ttf +0 -0
- package/fonts/Carlito-OFL.txt +94 -0
- package/fonts/Carlito-Regular.ttf +0 -0
- package/fonts/NotoSansCJKjp-OFL.txt +92 -0
- package/fonts/NotoSansCJKjp-Regular.otf +0 -0
- package/fonts/NotoSansJP-OFL.txt +93 -0
- package/fonts/NotoSansJP-Regular.ttf +0 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 hirokisakabe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @hirokisakabe/pom-cli
|
|
2
|
+
|
|
3
|
+
CLI tool for [pom](https://github.com/hirokisakabe/pom) — preview and build presentations from pom XML / Markdown.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @hirokisakabe/pom-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Preview
|
|
14
|
+
|
|
15
|
+
Starts a local preview server with live reload on file changes.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pom preview slides.pom.xml
|
|
19
|
+
pom preview slides.pom.md
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Open http://localhost:3000 in your browser. The page updates automatically when the file is saved.
|
|
23
|
+
|
|
24
|
+
### Build
|
|
25
|
+
|
|
26
|
+
Converts a pom file to a PPTX file.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pom build slides.pom.xml -o output.pptx
|
|
30
|
+
pom build slides.pom.md -o output.pptx
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Fonts
|
|
34
|
+
|
|
35
|
+
This package bundles Carlito and Noto Sans CJK JP fonts for SVG rendering. These fonts are used when converting slides to SVG in the preview server. System fonts are not scanned.
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
MIT
|
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAKA,wBAAsB,QAAQ,CAC5B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAsDf"}
|
package/dist/build.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { buildPptx } from "@hirokisakabe/pom";
|
|
4
|
+
import { parseMd } from "@hirokisakabe/pom-md";
|
|
5
|
+
export async function runBuild(inputFile, outputFile) {
|
|
6
|
+
const absInput = path.resolve(inputFile);
|
|
7
|
+
const absOutput = path.resolve(outputFile);
|
|
8
|
+
if (!fs.existsSync(absInput)) {
|
|
9
|
+
throw new Error(`Input file not found: ${absInput}`);
|
|
10
|
+
}
|
|
11
|
+
const content = fs.readFileSync(absInput, "utf-8");
|
|
12
|
+
const ext = path.extname(absInput);
|
|
13
|
+
let xml;
|
|
14
|
+
let slideWidth = 1280;
|
|
15
|
+
let slideHeight = 720;
|
|
16
|
+
let masterPptxData;
|
|
17
|
+
if (ext === ".md") {
|
|
18
|
+
const result = parseMd(content);
|
|
19
|
+
xml = result.xml;
|
|
20
|
+
slideWidth = result.meta.size.w;
|
|
21
|
+
slideHeight = result.meta.size.h;
|
|
22
|
+
if (result.meta.masterPptx) {
|
|
23
|
+
const masterPath = path.resolve(path.dirname(absInput), result.meta.masterPptx);
|
|
24
|
+
try {
|
|
25
|
+
masterPptxData = new Uint8Array(fs.readFileSync(masterPath));
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
if (e instanceof Error && "code" in e && e.code === "ENOENT") {
|
|
29
|
+
console.warn(`Warning: masterPptx not found: ${masterPath}`);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
throw e;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
xml = content;
|
|
39
|
+
}
|
|
40
|
+
const { pptx } = await buildPptx(xml, { w: slideWidth, h: slideHeight }, masterPptxData ? { masterPptx: masterPptxData } : undefined);
|
|
41
|
+
const buffer = await pptx.write({ outputType: "uint8array" });
|
|
42
|
+
if (!(buffer instanceof Uint8Array)) {
|
|
43
|
+
throw new Error("Unexpected output type from pptx.write");
|
|
44
|
+
}
|
|
45
|
+
fs.writeFileSync(absOutput, buffer);
|
|
46
|
+
console.log(`PPTX saved: ${absOutput}`);
|
|
47
|
+
}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { runBuild } from "./build.js";
|
|
3
|
+
import { runPreview } from "./preview.js";
|
|
4
|
+
const args = process.argv.slice(2);
|
|
5
|
+
const command = args[0];
|
|
6
|
+
if (command === "preview") {
|
|
7
|
+
const inputFile = args[1];
|
|
8
|
+
if (!inputFile) {
|
|
9
|
+
console.error("Usage: pom preview <input.pom.xml|input.pom.md>");
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
runPreview(inputFile);
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else if (command === "build") {
|
|
21
|
+
const inputFile = args[1];
|
|
22
|
+
const outputIndex = args.indexOf("-o");
|
|
23
|
+
const outputFile = outputIndex !== -1 ? args[outputIndex + 1] : undefined;
|
|
24
|
+
if (!inputFile || !outputFile) {
|
|
25
|
+
console.error("Usage: pom build <input.pom.xml|input.pom.md> -o <output.pptx>");
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
runBuild(inputFile, outputFile).catch((err) => {
|
|
29
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
30
|
+
process.exit(1);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.error("Usage:");
|
|
35
|
+
console.error(" pom preview <input.pom.xml|input.pom.md>");
|
|
36
|
+
console.error(" pom build <input.pom.xml|input.pom.md> -o <output.pptx>");
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../src/preview.ts"],"names":[],"mappings":"AA2OA,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAyGlD"}
|
package/dist/preview.js
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import http from "http";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { buildPptx } from "@hirokisakabe/pom";
|
|
6
|
+
import { parseMd } from "@hirokisakabe/pom-md";
|
|
7
|
+
import { convertPptxToSvg } from "pptx-glimpse";
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const DEFAULT_PORT = 3000;
|
|
10
|
+
const EXTRA_FONT_MAPPING = {
|
|
11
|
+
"游ゴシック Light": "Noto Sans CJK JP",
|
|
12
|
+
"Yu Gothic Light": "Noto Sans CJK JP",
|
|
13
|
+
};
|
|
14
|
+
async function generateSvgs(inputFile) {
|
|
15
|
+
const content = fs.readFileSync(inputFile, "utf-8");
|
|
16
|
+
const ext = path.extname(inputFile);
|
|
17
|
+
let xml;
|
|
18
|
+
let slideWidth = 1280;
|
|
19
|
+
let slideHeight = 720;
|
|
20
|
+
let masterPptxData;
|
|
21
|
+
if (ext === ".md") {
|
|
22
|
+
const result = parseMd(content);
|
|
23
|
+
xml = result.xml;
|
|
24
|
+
slideWidth = result.meta.size.w;
|
|
25
|
+
slideHeight = result.meta.size.h;
|
|
26
|
+
if (result.meta.masterPptx) {
|
|
27
|
+
const masterPath = path.resolve(path.dirname(inputFile), result.meta.masterPptx);
|
|
28
|
+
try {
|
|
29
|
+
masterPptxData = new Uint8Array(fs.readFileSync(masterPath));
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
if (e instanceof Error && "code" in e && e.code === "ENOENT") {
|
|
33
|
+
process.stderr.write(`Warning: masterPptx not found: ${masterPath}\n`);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
throw e;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
xml = content;
|
|
43
|
+
}
|
|
44
|
+
if (!xml.trim()) {
|
|
45
|
+
return { type: "empty" };
|
|
46
|
+
}
|
|
47
|
+
const { pptx } = await buildPptx(xml, { w: slideWidth, h: slideHeight }, {
|
|
48
|
+
textMeasurement: "fallback",
|
|
49
|
+
...(masterPptxData ? { masterPptx: masterPptxData } : {}),
|
|
50
|
+
});
|
|
51
|
+
const buffer = await pptx.write({ outputType: "uint8array" });
|
|
52
|
+
if (!(buffer instanceof Uint8Array)) {
|
|
53
|
+
throw new Error("Unexpected output type from pptx.write");
|
|
54
|
+
}
|
|
55
|
+
const fontsDir = path.resolve(__dirname, "../fonts");
|
|
56
|
+
if (!fs.existsSync(fontsDir)) {
|
|
57
|
+
throw new Error(`Bundled fonts directory not found: ${fontsDir}. The package may be corrupted.`);
|
|
58
|
+
}
|
|
59
|
+
const fontDirs = [fontsDir];
|
|
60
|
+
const slides = await convertPptxToSvg(buffer, {
|
|
61
|
+
width: slideWidth,
|
|
62
|
+
fontDirs,
|
|
63
|
+
fontMapping: EXTRA_FONT_MAPPING,
|
|
64
|
+
skipSystemFonts: true,
|
|
65
|
+
});
|
|
66
|
+
const svgs = slides.map((s) => s.svg);
|
|
67
|
+
return { type: "success", svgs, slideWidth };
|
|
68
|
+
}
|
|
69
|
+
function buildPreviewHtml() {
|
|
70
|
+
return `<!DOCTYPE html>
|
|
71
|
+
<html>
|
|
72
|
+
<head>
|
|
73
|
+
<meta charset="UTF-8">
|
|
74
|
+
<title>pom preview</title>
|
|
75
|
+
<style>
|
|
76
|
+
* { box-sizing: border-box; }
|
|
77
|
+
body { margin: 0; padding: 0; background: #f5f5f5; font-family: sans-serif; }
|
|
78
|
+
.toolbar {
|
|
79
|
+
position: sticky; top: 0; z-index: 100;
|
|
80
|
+
display: flex; align-items: center; gap: 4px;
|
|
81
|
+
padding: 6px 16px; background: #fff;
|
|
82
|
+
border-bottom: 1px solid #ddd;
|
|
83
|
+
}
|
|
84
|
+
.zoom-btn {
|
|
85
|
+
padding: 3px 10px; font-size: 12px;
|
|
86
|
+
border: 1px solid #ccc; border-radius: 3px;
|
|
87
|
+
background: #fff; color: #333; cursor: pointer;
|
|
88
|
+
}
|
|
89
|
+
.zoom-btn:hover { background: #e8e8e8; }
|
|
90
|
+
.zoom-btn.active { background: #007acc; color: #fff; border-color: #007acc; }
|
|
91
|
+
.status { margin-left: auto; font-size: 12px; color: #888; }
|
|
92
|
+
.slides-container { padding: 16px; }
|
|
93
|
+
.slide-wrapper { margin-bottom: 24px; }
|
|
94
|
+
.slide-label { font-size: 12px; color: #888; margin-bottom: 4px; }
|
|
95
|
+
.slide-frame {
|
|
96
|
+
border: 1px solid #ddd; border-radius: 4px;
|
|
97
|
+
overflow: hidden; background: #fff; display: inline-block;
|
|
98
|
+
}
|
|
99
|
+
.slide-frame svg { display: block; }
|
|
100
|
+
.error-banner {
|
|
101
|
+
background: #fee; border: 1px solid #fcc;
|
|
102
|
+
border-radius: 4px; padding: 12px; margin: 16px; color: #c00;
|
|
103
|
+
}
|
|
104
|
+
.loading-message, .empty-message {
|
|
105
|
+
display: flex; align-items: center; justify-content: center;
|
|
106
|
+
height: calc(100vh - 40px); color: #888; flex-direction: column; gap: 8px;
|
|
107
|
+
}
|
|
108
|
+
</style>
|
|
109
|
+
</head>
|
|
110
|
+
<body>
|
|
111
|
+
<div class="toolbar">
|
|
112
|
+
<button class="zoom-btn" data-zoom="fit">Fit to Width</button>
|
|
113
|
+
<button class="zoom-btn" data-zoom="50">50%</button>
|
|
114
|
+
<button class="zoom-btn" data-zoom="75">75%</button>
|
|
115
|
+
<button class="zoom-btn" data-zoom="100">100%</button>
|
|
116
|
+
<button class="zoom-btn" data-zoom="150">150%</button>
|
|
117
|
+
<span class="status" id="status">Connecting...</span>
|
|
118
|
+
</div>
|
|
119
|
+
<div id="content"><div class="loading-message"><span>Building preview...</span></div></div>
|
|
120
|
+
|
|
121
|
+
<script>
|
|
122
|
+
(function() {
|
|
123
|
+
var VALID_ZOOMS = ['fit', '50', '75', '100', '150'];
|
|
124
|
+
var currentZoom = localStorage.getItem('pom-zoom') || 'fit';
|
|
125
|
+
var currentSlideWidth = 1280;
|
|
126
|
+
|
|
127
|
+
applyZoom(currentZoom);
|
|
128
|
+
|
|
129
|
+
document.querySelectorAll('.zoom-btn').forEach(function(btn) {
|
|
130
|
+
btn.addEventListener('click', function() {
|
|
131
|
+
var zoom = this.getAttribute('data-zoom');
|
|
132
|
+
applyZoom(zoom);
|
|
133
|
+
localStorage.setItem('pom-zoom', zoom);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
function applyZoom(zoom) {
|
|
138
|
+
if (VALID_ZOOMS.indexOf(zoom) === -1) zoom = 'fit';
|
|
139
|
+
currentZoom = zoom;
|
|
140
|
+
document.body.setAttribute('data-zoom', zoom);
|
|
141
|
+
document.querySelectorAll('.zoom-btn').forEach(function(b) {
|
|
142
|
+
b.classList.toggle('active', b.getAttribute('data-zoom') === zoom);
|
|
143
|
+
});
|
|
144
|
+
document.querySelectorAll('.slide-frame svg').forEach(function(svg) {
|
|
145
|
+
applySvgZoom(svg, zoom, currentSlideWidth);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function applySvgZoom(svg, zoom, slideWidth) {
|
|
150
|
+
var frame = svg.closest('.slide-frame');
|
|
151
|
+
if (zoom === 'fit') {
|
|
152
|
+
svg.style.width = '100%';
|
|
153
|
+
svg.style.height = 'auto';
|
|
154
|
+
frame.style.display = 'block';
|
|
155
|
+
} else {
|
|
156
|
+
var scale = parseInt(zoom) / 100;
|
|
157
|
+
svg.style.width = (slideWidth * scale) + 'px';
|
|
158
|
+
svg.style.height = 'auto';
|
|
159
|
+
frame.style.display = 'inline-block';
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
var status = document.getElementById('status');
|
|
164
|
+
var content = document.getElementById('content');
|
|
165
|
+
|
|
166
|
+
var es = new EventSource('/_sse');
|
|
167
|
+
|
|
168
|
+
es.addEventListener('open', function() {
|
|
169
|
+
status.textContent = 'Connected';
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
es.addEventListener('update', function(e) {
|
|
173
|
+
var data = JSON.parse(e.data);
|
|
174
|
+
if (data.type === 'success') {
|
|
175
|
+
currentSlideWidth = data.slideWidth;
|
|
176
|
+
status.textContent = 'Updated ' + new Date().toLocaleTimeString();
|
|
177
|
+
var slideHtml = data.svgs.map(function(svg, i) {
|
|
178
|
+
return '<div class="slide-wrapper">' +
|
|
179
|
+
'<div class="slide-label">Slide ' + (i + 1) + '</div>' +
|
|
180
|
+
'<div class="slide-frame">' + svg + '</div>' +
|
|
181
|
+
'</div>';
|
|
182
|
+
}).join('');
|
|
183
|
+
content.innerHTML = '<div class="slides-container">' + slideHtml + '</div>';
|
|
184
|
+
document.querySelectorAll('.slide-frame svg').forEach(function(svgEl) {
|
|
185
|
+
applySvgZoom(svgEl, currentZoom, currentSlideWidth);
|
|
186
|
+
});
|
|
187
|
+
} else if (data.type === 'error') {
|
|
188
|
+
status.textContent = 'Error';
|
|
189
|
+
var escaped = data.message
|
|
190
|
+
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
191
|
+
content.innerHTML = '<div class="error-banner"><strong>Error:</strong> ' + escaped + '</div>';
|
|
192
|
+
} else if (data.type === 'empty') {
|
|
193
|
+
status.textContent = 'No slides';
|
|
194
|
+
content.innerHTML = '<div class="empty-message">No slides to preview</div>';
|
|
195
|
+
} else if (data.type === 'building') {
|
|
196
|
+
status.textContent = 'Building...';
|
|
197
|
+
content.innerHTML = '<div class="loading-message"><span>Building preview...</span></div>';
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
es.addEventListener('error', function() {
|
|
202
|
+
status.textContent = 'Disconnected — retrying...';
|
|
203
|
+
});
|
|
204
|
+
})();
|
|
205
|
+
</script>
|
|
206
|
+
</body>
|
|
207
|
+
</html>`;
|
|
208
|
+
}
|
|
209
|
+
export function runPreview(inputFile) {
|
|
210
|
+
const absInput = path.resolve(inputFile);
|
|
211
|
+
if (!fs.existsSync(absInput)) {
|
|
212
|
+
throw new Error(`Input file not found: ${absInput}`);
|
|
213
|
+
}
|
|
214
|
+
const clients = [];
|
|
215
|
+
let currentResult = { type: "empty" };
|
|
216
|
+
let initialBuildDone = false;
|
|
217
|
+
function broadcast(result) {
|
|
218
|
+
currentResult = result;
|
|
219
|
+
const data = JSON.stringify(result);
|
|
220
|
+
for (const client of clients) {
|
|
221
|
+
client.write(`event: update\ndata: ${data}\n\n`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function broadcastBuilding() {
|
|
225
|
+
const data = JSON.stringify({ type: "building" });
|
|
226
|
+
for (const client of clients) {
|
|
227
|
+
client.write(`event: update\ndata: ${data}\n\n`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function refresh() {
|
|
231
|
+
broadcastBuilding();
|
|
232
|
+
generateSvgs(absInput)
|
|
233
|
+
.then(broadcast)
|
|
234
|
+
.catch((err) => {
|
|
235
|
+
broadcast({
|
|
236
|
+
type: "error",
|
|
237
|
+
message: err instanceof Error ? err.message : String(err),
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
generateSvgs(absInput)
|
|
242
|
+
.then((result) => {
|
|
243
|
+
currentResult = result;
|
|
244
|
+
initialBuildDone = true;
|
|
245
|
+
broadcast(result);
|
|
246
|
+
})
|
|
247
|
+
.catch((err) => {
|
|
248
|
+
initialBuildDone = true;
|
|
249
|
+
broadcast({
|
|
250
|
+
type: "error",
|
|
251
|
+
message: err instanceof Error ? err.message : String(err),
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
let debounceTimer = null;
|
|
255
|
+
fs.watch(absInput, () => {
|
|
256
|
+
if (debounceTimer)
|
|
257
|
+
clearTimeout(debounceTimer);
|
|
258
|
+
debounceTimer = setTimeout(refresh, 100);
|
|
259
|
+
});
|
|
260
|
+
const html = buildPreviewHtml();
|
|
261
|
+
const server = http.createServer((req, res) => {
|
|
262
|
+
if (req.url === "/_sse") {
|
|
263
|
+
res.writeHead(200, {
|
|
264
|
+
"Content-Type": "text/event-stream",
|
|
265
|
+
"Cache-Control": "no-cache",
|
|
266
|
+
Connection: "keep-alive",
|
|
267
|
+
"Access-Control-Allow-Origin": "*",
|
|
268
|
+
});
|
|
269
|
+
res.write(": connected\n\n");
|
|
270
|
+
if (!initialBuildDone) {
|
|
271
|
+
res.write(`event: update\ndata: ${JSON.stringify({ type: "building" })}\n\n`);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
res.write(`event: update\ndata: ${JSON.stringify(currentResult)}\n\n`);
|
|
275
|
+
}
|
|
276
|
+
clients.push(res);
|
|
277
|
+
req.on("close", () => {
|
|
278
|
+
const idx = clients.indexOf(res);
|
|
279
|
+
if (idx !== -1)
|
|
280
|
+
clients.splice(idx, 1);
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
285
|
+
res.end(html);
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
server.on("error", (err) => {
|
|
289
|
+
if (err.code === "EADDRINUSE") {
|
|
290
|
+
console.error(`Port ${DEFAULT_PORT} is already in use. Is another pom preview running?`);
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
console.error(`Server error: ${err.message}`);
|
|
294
|
+
}
|
|
295
|
+
process.exit(1);
|
|
296
|
+
});
|
|
297
|
+
server.listen(DEFAULT_PORT, () => {
|
|
298
|
+
console.log(`Preview server: http://localhost:${DEFAULT_PORT}`);
|
|
299
|
+
console.log(`Watching: ${absInput}`);
|
|
300
|
+
console.log("Press Ctrl+C to stop");
|
|
301
|
+
});
|
|
302
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Copyright 2013 The Carlito Project Authors (https://github.com/googlefonts/carlito), with Reserved Font Name "Carlito"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
5
|
+
This license is copied below, and is also available with a FAQ at:
|
|
6
|
+
https://scripts.sil.org/OFL
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
-----------------------------------------------------------
|
|
10
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
11
|
+
-----------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
PREAMBLE
|
|
14
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
15
|
+
development of collaborative font projects, to support the font creation
|
|
16
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
17
|
+
open framework in which fonts may be shared and improved in partnership
|
|
18
|
+
with others.
|
|
19
|
+
|
|
20
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
21
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
22
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
23
|
+
redistributed and/or sold with any software provided that any reserved
|
|
24
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
25
|
+
however, cannot be released under any other type of license. The
|
|
26
|
+
requirement for fonts to remain under this license does not apply
|
|
27
|
+
to any document created using the fonts or their derivatives.
|
|
28
|
+
|
|
29
|
+
DEFINITIONS
|
|
30
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
31
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
32
|
+
include source files, build scripts and documentation.
|
|
33
|
+
|
|
34
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
35
|
+
copyright statement(s).
|
|
36
|
+
|
|
37
|
+
"Original Version" refers to the collection of Font Software components as
|
|
38
|
+
distributed by the Copyright Holder(s).
|
|
39
|
+
|
|
40
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
41
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
42
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
43
|
+
new environment.
|
|
44
|
+
|
|
45
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
46
|
+
writer or other person who contributed to the Font Software.
|
|
47
|
+
|
|
48
|
+
PERMISSION & CONDITIONS
|
|
49
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
50
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
51
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
52
|
+
Software, subject to the following conditions:
|
|
53
|
+
|
|
54
|
+
1) Neither the Font Software nor any of its individual components,
|
|
55
|
+
in Original or Modified Versions, may be sold by itself.
|
|
56
|
+
|
|
57
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
58
|
+
redistributed and/or sold with any software, provided that each copy
|
|
59
|
+
contains the above copyright notice and this license. These can be
|
|
60
|
+
included either as stand-alone text files, human-readable headers or
|
|
61
|
+
in the appropriate machine-readable metadata fields within text or
|
|
62
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
63
|
+
|
|
64
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
65
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
66
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
67
|
+
presented to the users.
|
|
68
|
+
|
|
69
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
70
|
+
Software shall not be used to promote, endorse or advertise any
|
|
71
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
72
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
73
|
+
permission.
|
|
74
|
+
|
|
75
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
76
|
+
must be distributed entirely under this license, and must not be
|
|
77
|
+
distributed under any other license. The requirement for fonts to
|
|
78
|
+
remain under this license does not apply to any document created
|
|
79
|
+
using the Font Software.
|
|
80
|
+
|
|
81
|
+
TERMINATION
|
|
82
|
+
This license becomes null and void if any of the above conditions are
|
|
83
|
+
not met.
|
|
84
|
+
|
|
85
|
+
DISCLAIMER
|
|
86
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
87
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
88
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
89
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
90
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
91
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
92
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
93
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
94
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
This Font Software is licensed under the SIL Open Font License,
|
|
2
|
+
Version 1.1.
|
|
3
|
+
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
-----------------------------------------------------------
|
|
8
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
9
|
+
-----------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
PREAMBLE
|
|
12
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
13
|
+
development of collaborative font projects, to support the font
|
|
14
|
+
creation efforts of academic and linguistic communities, and to
|
|
15
|
+
provide a free and open framework in which fonts may be shared and
|
|
16
|
+
improved in partnership with others.
|
|
17
|
+
|
|
18
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
19
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
20
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
21
|
+
redistributed and/or sold with any software provided that any reserved
|
|
22
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
23
|
+
however, cannot be released under any other type of license. The
|
|
24
|
+
requirement for fonts to remain under this license does not apply to
|
|
25
|
+
any document created using the fonts or their derivatives.
|
|
26
|
+
|
|
27
|
+
DEFINITIONS
|
|
28
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
29
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
30
|
+
include source files, build scripts and documentation.
|
|
31
|
+
|
|
32
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
33
|
+
copyright statement(s).
|
|
34
|
+
|
|
35
|
+
"Original Version" refers to the collection of Font Software
|
|
36
|
+
components as distributed by the Copyright Holder(s).
|
|
37
|
+
|
|
38
|
+
"Modified Version" refers to any derivative made by adding to,
|
|
39
|
+
deleting, or substituting -- in part or in whole -- any of the
|
|
40
|
+
components of the Original Version, by changing formats or by porting
|
|
41
|
+
the Font Software to a new environment.
|
|
42
|
+
|
|
43
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
44
|
+
writer or other person who contributed to the Font Software.
|
|
45
|
+
|
|
46
|
+
PERMISSION & CONDITIONS
|
|
47
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
48
|
+
a copy of the Font Software, to use, study, copy, merge, embed,
|
|
49
|
+
modify, redistribute, and sell modified and unmodified copies of the
|
|
50
|
+
Font Software, subject to the following conditions:
|
|
51
|
+
|
|
52
|
+
1) Neither the Font Software nor any of its individual components, in
|
|
53
|
+
Original or Modified Versions, may be sold by itself.
|
|
54
|
+
|
|
55
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
56
|
+
redistributed and/or sold with any software, provided that each copy
|
|
57
|
+
contains the above copyright notice and this license. These can be
|
|
58
|
+
included either as stand-alone text files, human-readable headers or
|
|
59
|
+
in the appropriate machine-readable metadata fields within text or
|
|
60
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
61
|
+
|
|
62
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
63
|
+
Name(s) unless explicit written permission is granted by the
|
|
64
|
+
corresponding Copyright Holder. This restriction only applies to the
|
|
65
|
+
primary font name as presented to the users.
|
|
66
|
+
|
|
67
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
68
|
+
Software shall not be used to promote, endorse or advertise any
|
|
69
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
70
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
71
|
+
permission.
|
|
72
|
+
|
|
73
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
74
|
+
must be distributed entirely under this license, and must not be
|
|
75
|
+
distributed under any other license. The requirement for fonts to
|
|
76
|
+
remain under this license does not apply to any document created using
|
|
77
|
+
the Font Software.
|
|
78
|
+
|
|
79
|
+
TERMINATION
|
|
80
|
+
This license becomes null and void if any of the above conditions are
|
|
81
|
+
not met.
|
|
82
|
+
|
|
83
|
+
DISCLAIMER
|
|
84
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
85
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
86
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
87
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
88
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
89
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
90
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
91
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
92
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
https://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hirokisakabe/pom-cli",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "CLI tool for pom — preview and build presentations",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"pom": "./dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"fonts",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/hirokisakabe/pom#readme",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/hirokisakabe/pom/issues"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/hirokisakabe/pom.git",
|
|
25
|
+
"directory": "packages/pom-cli"
|
|
26
|
+
},
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"author": "Hiroki Sakabe",
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc && node -e \"require('fs').chmodSync('dist/cli.js', '755')\"",
|
|
34
|
+
"prepublishOnly": "pnpm run build",
|
|
35
|
+
"fmt": "prettier --write .",
|
|
36
|
+
"fmt:check": "prettier --check .",
|
|
37
|
+
"lint": "eslint",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"knip": "knip"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@hirokisakabe/pom": "workspace:*",
|
|
43
|
+
"@hirokisakabe/pom-md": "workspace:*",
|
|
44
|
+
"pptx-glimpse": "^0.11.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^25.9.1",
|
|
48
|
+
"typescript-eslint": "^8.59.4"
|
|
49
|
+
}
|
|
50
|
+
}
|