@hirokisakabe/pom 5.2.0 → 5.3.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 +10 -11
- package/dist/autoFit/autoFit.d.ts +2 -1
- package/dist/autoFit/autoFit.d.ts.map +1 -1
- package/dist/autoFit/autoFit.js +7 -7
- package/dist/autoFit/strategies/reduceFontSize.js +1 -1
- package/dist/autoFit/strategies/reduceGapAndPadding.js +1 -1
- package/dist/autoFit/strategies/reduceTableRowHeight.js +1 -1
- package/dist/autoFit/strategies/uniformScale.js +1 -1
- package/dist/buildContext.d.ts +12 -0
- package/dist/buildContext.d.ts.map +1 -0
- package/dist/buildContext.js +8 -0
- package/dist/buildPptx.d.ts +1 -1
- package/dist/buildPptx.d.ts.map +1 -1
- package/dist/buildPptx.js +15 -15
- package/dist/calcYogaLayout/calcYogaLayout.d.ts +3 -1
- package/dist/calcYogaLayout/calcYogaLayout.d.ts.map +1 -1
- package/dist/calcYogaLayout/calcYogaLayout.js +43 -371
- package/dist/calcYogaLayout/measureText.d.ts +1 -5
- package/dist/calcYogaLayout/measureText.d.ts.map +1 -1
- package/dist/calcYogaLayout/measureText.js +2 -10
- package/dist/icons/renderIcon.d.ts +1 -1
- package/dist/icons/renderIcon.d.ts.map +1 -1
- package/dist/icons/renderIcon.js +3 -4
- package/dist/parseXml/coercionRules.d.ts +35 -0
- package/dist/parseXml/coercionRules.d.ts.map +1 -0
- package/dist/parseXml/coercionRules.js +479 -0
- package/dist/parseXml/inputSchema.d.ts +22 -105
- package/dist/parseXml/inputSchema.d.ts.map +1 -1
- package/dist/parseXml/inputSchema.js +5 -3
- package/dist/parseXml/parseXml.d.ts.map +1 -1
- package/dist/parseXml/parseXml.js +48 -277
- package/dist/registry/definitions/box.d.ts +3 -0
- package/dist/registry/definitions/box.d.ts.map +1 -0
- package/dist/registry/definitions/box.js +6 -0
- package/dist/registry/definitions/chart.d.ts +3 -0
- package/dist/registry/definitions/chart.d.ts.map +1 -0
- package/dist/registry/definitions/chart.js +8 -0
- package/dist/registry/definitions/compositeNodes.d.ts +8 -0
- package/dist/registry/definitions/compositeNodes.d.ts.map +1 -0
- package/dist/registry/definitions/compositeNodes.js +81 -0
- package/dist/registry/definitions/icon.d.ts +3 -0
- package/dist/registry/definitions/icon.d.ts.map +1 -0
- package/dist/registry/definitions/icon.js +50 -0
- package/dist/registry/definitions/image.d.ts +3 -0
- package/dist/registry/definitions/image.d.ts.map +1 -0
- package/dist/registry/definitions/image.js +34 -0
- package/dist/registry/definitions/layer.d.ts +3 -0
- package/dist/registry/definitions/layer.d.ts.map +1 -0
- package/dist/registry/definitions/layer.js +49 -0
- package/dist/registry/definitions/line.d.ts +3 -0
- package/dist/registry/definitions/line.d.ts.map +1 -0
- package/dist/registry/definitions/line.js +26 -0
- package/dist/registry/definitions/list.d.ts +4 -0
- package/dist/registry/definitions/list.d.ts.map +1 -0
- package/dist/registry/definitions/list.js +53 -0
- package/dist/registry/definitions/shape.d.ts +3 -0
- package/dist/registry/definitions/shape.d.ts.map +1 -0
- package/dist/registry/definitions/shape.js +37 -0
- package/dist/registry/definitions/stack.d.ts +4 -0
- package/dist/registry/definitions/stack.d.ts.map +1 -0
- package/dist/registry/definitions/stack.js +78 -0
- package/dist/registry/definitions/table.d.ts +3 -0
- package/dist/registry/definitions/table.d.ts.map +1 -0
- package/dist/registry/definitions/table.js +16 -0
- package/dist/registry/definitions/text.d.ts +3 -0
- package/dist/registry/definitions/text.d.ts.map +1 -0
- package/dist/registry/definitions/text.js +35 -0
- package/dist/registry/index.d.ts +2 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +34 -0
- package/dist/registry/nodeRegistry.d.ts +7 -0
- package/dist/registry/nodeRegistry.d.ts.map +1 -0
- package/dist/registry/nodeRegistry.js +13 -0
- package/dist/registry/types.d.ts +26 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +1 -0
- package/dist/renderPptx/nodes/icon.d.ts.map +1 -1
- package/dist/renderPptx/nodes/icon.js +22 -4
- package/dist/renderPptx/renderPptx.d.ts +2 -1
- package/dist/renderPptx/renderPptx.d.ts.map +1 -1
- package/dist/renderPptx/renderPptx.js +19 -60
- package/dist/renderPptx/types.d.ts +2 -0
- package/dist/renderPptx/types.d.ts.map +1 -1
- package/dist/renderPptx/utils/backgroundBorder.d.ts.map +1 -1
- package/dist/renderPptx/utils/backgroundBorder.js +1 -1
- package/dist/shared/freeYogaTree.d.ts.map +1 -0
- package/dist/shared/measureImage.d.ts +13 -3
- package/dist/shared/measureImage.d.ts.map +1 -1
- package/dist/shared/measureImage.js +14 -19
- package/dist/shared/walkTree.d.ts.map +1 -0
- package/dist/toPositioned/toPositioned.d.ts +8 -1
- package/dist/toPositioned/toPositioned.d.ts.map +1 -1
- package/dist/toPositioned/toPositioned.js +32 -189
- package/dist/types.d.ts +38 -54
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +11 -1
- package/package.json +3 -3
- package/dist/autoFit/freeYogaTree.d.ts.map +0 -1
- package/dist/autoFit/walkTree.d.ts.map +0 -1
- package/dist/renderPptx/nodes/index.d.ts +0 -15
- package/dist/renderPptx/nodes/index.d.ts.map +0 -1
- package/dist/renderPptx/nodes/index.js +0 -14
- /package/dist/{autoFit → shared}/freeYogaTree.d.ts +0 -0
- /package/dist/{autoFit → shared}/freeYogaTree.js +0 -0
- /package/dist/{autoFit → shared}/walkTree.d.ts +0 -0
- /package/dist/{autoFit → shared}/walkTree.js +0 -0
package/README.md
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
<p align="center">
|
|
7
7
|
<a href="https://www.npmjs.com/package/@hirokisakabe/pom"><img src="https://img.shields.io/npm/v/@hirokisakabe/pom.svg" alt="npm version"></a>
|
|
8
|
-
<a href="https://github.com/hirokisakabe/pom/actions/workflows/ci.yml"><img src="https://github.com/hirokisakabe/pom/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
9
8
|
<a href="https://github.com/hirokisakabe/pom/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@hirokisakabe/pom.svg" alt="License"></a>
|
|
10
9
|
</p>
|
|
11
10
|
|
|
@@ -14,11 +13,11 @@
|
|
|
14
13
|
</p>
|
|
15
14
|
|
|
16
15
|
<p align="center">
|
|
17
|
-
<a href="https://pom
|
|
16
|
+
<a href="https://pom.pptx.app/playground"><b>Try it online — Playground</b></a>
|
|
18
17
|
</p>
|
|
19
18
|
|
|
20
19
|
<p align="center">
|
|
21
|
-
<a href="https://pom
|
|
20
|
+
<a href="https://pom.pptx.app/playground">
|
|
22
21
|
<img src="./docs/images/playground.png" alt="Playground" width="800">
|
|
23
22
|
</a>
|
|
24
23
|
</p>
|
|
@@ -91,7 +90,7 @@ await pptx.writeFile({ fileName: "presentation.pptx" });
|
|
|
91
90
|
| VStack | Vertical stack layout |
|
|
92
91
|
| HStack | Horizontal stack layout |
|
|
93
92
|
|
|
94
|
-
For detailed node documentation, see [Nodes
|
|
93
|
+
For detailed node documentation, see [Nodes](./docs/nodes.md).
|
|
95
94
|
|
|
96
95
|
## Node Examples
|
|
97
96
|
|
|
@@ -215,13 +214,13 @@ const pptx = await buildPptx(xml, { w: 1280, h: 720 }, { autoFit: false });
|
|
|
215
214
|
|
|
216
215
|
## Documentation
|
|
217
216
|
|
|
218
|
-
| Document
|
|
219
|
-
|
|
|
220
|
-
| [Nodes
|
|
221
|
-
| [Master Slide](./docs/master-slide.md)
|
|
222
|
-
| [
|
|
223
|
-
| [LLM Integration](./docs/llm-integration.md)
|
|
224
|
-
| [Playground](https://pom
|
|
217
|
+
| Document | Description |
|
|
218
|
+
| ---------------------------------------------- | ------------------------------------- |
|
|
219
|
+
| [Nodes](./docs/nodes.md) | Complete reference for all node types |
|
|
220
|
+
| [Master Slide](./docs/master-slide.md) | Headers, footers, and page numbers |
|
|
221
|
+
| [Text Measurement](./docs/text-measurement.md) | Text measurement options and settings |
|
|
222
|
+
| [LLM Integration](./docs/llm-integration.md) | Compact XML reference for LLM prompts |
|
|
223
|
+
| [Playground](https://pom.pptx.app/playground) | Try pom XML in the browser |
|
|
225
224
|
|
|
226
225
|
## License
|
|
227
226
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { POMNode } from "../types.ts";
|
|
2
|
+
import type { BuildContext } from "../buildContext.ts";
|
|
2
3
|
/**
|
|
3
4
|
* スライドのオーバーフローを検出し、段階的に調整してスライド内に収める。
|
|
4
5
|
*
|
|
@@ -11,5 +12,5 @@ import type { POMNode } from "../types.ts";
|
|
|
11
12
|
export declare function autoFitSlide(node: POMNode, slideSize: {
|
|
12
13
|
w: number;
|
|
13
14
|
h: number;
|
|
14
|
-
}): Promise<void>;
|
|
15
|
+
}, ctx: BuildContext): Promise<void>;
|
|
15
16
|
//# sourceMappingURL=autoFit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoFit.d.ts","sourceRoot":"","sources":["../../src/autoFit/autoFit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"autoFit.d.ts","sourceRoot":"","sources":["../../src/autoFit/autoFit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAuDvD;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,OAAO,EACb,SAAS,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EACnC,GAAG,EAAE,YAAY,GAChB,OAAO,CAAC,IAAI,CAAC,CA6Bf"}
|
package/dist/autoFit/autoFit.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { calcYogaLayout } from "../calcYogaLayout/calcYogaLayout.js";
|
|
2
|
-
import { freeYogaTree } from "
|
|
2
|
+
import { freeYogaTree } from "../shared/freeYogaTree.js";
|
|
3
3
|
import { reduceTableRowHeight } from "./strategies/reduceTableRowHeight.js";
|
|
4
4
|
import { reduceFontSize } from "./strategies/reduceFontSize.js";
|
|
5
5
|
import { reduceGapAndPadding } from "./strategies/reduceGapAndPadding.js";
|
|
@@ -19,8 +19,8 @@ const strategies = [
|
|
|
19
19
|
* ルートの padding.bottom を加算してコンテンツの占有高さとする。
|
|
20
20
|
* h="max" や flexGrow の影響を受けず、正確なコンテンツ高さを返す。
|
|
21
21
|
*/
|
|
22
|
-
async function measureContentHeight(node, slideSize) {
|
|
23
|
-
await calcYogaLayout(node, slideSize);
|
|
22
|
+
async function measureContentHeight(node, slideSize, ctx) {
|
|
23
|
+
await calcYogaLayout(node, slideSize, ctx);
|
|
24
24
|
const rootYoga = node.yogaNode;
|
|
25
25
|
const childCount = rootYoga.getChildCount();
|
|
26
26
|
if (childCount === 0) {
|
|
@@ -48,10 +48,10 @@ async function measureContentHeight(node, slideSize) {
|
|
|
48
48
|
* 3. gap/padding 縮小
|
|
49
49
|
* 4. 全体スケーリング(フォールバック)
|
|
50
50
|
*/
|
|
51
|
-
export async function autoFitSlide(node, slideSize) {
|
|
51
|
+
export async function autoFitSlide(node, slideSize, ctx) {
|
|
52
52
|
for (const strategy of strategies) {
|
|
53
53
|
freeYogaTree(node);
|
|
54
|
-
const contentHeight = await measureContentHeight(node, slideSize);
|
|
54
|
+
const contentHeight = await measureContentHeight(node, slideSize, ctx);
|
|
55
55
|
if (contentHeight <= slideSize.h * OVERFLOW_TOLERANCE) {
|
|
56
56
|
break;
|
|
57
57
|
}
|
|
@@ -63,11 +63,11 @@ export async function autoFitSlide(node, slideSize) {
|
|
|
63
63
|
}
|
|
64
64
|
// 最終的にオーバーフローが解消されたか確認
|
|
65
65
|
freeYogaTree(node);
|
|
66
|
-
const finalHeight = await measureContentHeight(node, slideSize);
|
|
66
|
+
const finalHeight = await measureContentHeight(node, slideSize, ctx);
|
|
67
67
|
if (finalHeight > slideSize.h * OVERFLOW_TOLERANCE) {
|
|
68
68
|
console.warn(`[pom] autoFit: content height (${Math.round(finalHeight)}px) exceeds slide height (${slideSize.h}px) after all adjustments.`);
|
|
69
69
|
}
|
|
70
70
|
// 最終レイアウト(正しい slideSize で)
|
|
71
71
|
freeYogaTree(node);
|
|
72
|
-
await calcYogaLayout(node, slideSize);
|
|
72
|
+
await calcYogaLayout(node, slideSize, ctx);
|
|
73
73
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TextMeasurementMode } from "./calcYogaLayout/measureText.ts";
|
|
2
|
+
export interface BuildContext {
|
|
3
|
+
textMeasurementMode: TextMeasurementMode;
|
|
4
|
+
imageSizeCache: Map<string, {
|
|
5
|
+
widthPx: number;
|
|
6
|
+
heightPx: number;
|
|
7
|
+
}>;
|
|
8
|
+
imageDataCache: Map<string, string>;
|
|
9
|
+
iconRasterCache: Map<string, string>;
|
|
10
|
+
}
|
|
11
|
+
export declare function createBuildContext(textMeasurementMode?: TextMeasurementMode): BuildContext;
|
|
12
|
+
//# sourceMappingURL=buildContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildContext.d.ts","sourceRoot":"","sources":["../src/buildContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,MAAM,WAAW,YAAY;IAC3B,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnE,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED,wBAAgB,kBAAkB,CAChC,mBAAmB,GAAE,mBAA4B,GAChD,YAAY,CAOd"}
|
package/dist/buildPptx.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TextMeasurementMode } from "./calcYogaLayout/measureText.ts";
|
|
1
|
+
import type { TextMeasurementMode } from "./calcYogaLayout/measureText.ts";
|
|
2
2
|
import { SlideMasterOptions } from "./types.ts";
|
|
3
3
|
export type { TextMeasurementMode };
|
|
4
4
|
export declare function buildPptx(xml: string, slideSize: {
|
package/dist/buildPptx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildPptx.d.ts","sourceRoot":"","sources":["../src/buildPptx.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildPptx.d.ts","sourceRoot":"","sources":["../src/buildPptx.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAK3E,OAAO,EAAkB,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhE,YAAY,EAAE,mBAAmB,EAAE,CAAC;AAEpC,wBAAsB,SAAS,CAC7B,GAAG,EAAE,MAAM,EACX,SAAS,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EACnC,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACtC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,wCAwBF"}
|
package/dist/buildPptx.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { autoFitSlide } from "./autoFit/autoFit.js";
|
|
2
|
+
import { createBuildContext } from "./buildContext.js";
|
|
2
3
|
import { calcYogaLayout } from "./calcYogaLayout/calcYogaLayout.js";
|
|
3
|
-
import { setTextMeasurementMode, } from "./calcYogaLayout/measureText.js";
|
|
4
4
|
import { parseXml } from "./parseXml/parseXml.js";
|
|
5
5
|
import { renderPptx } from "./renderPptx/renderPptx.js";
|
|
6
|
+
import { freeYogaTree } from "./shared/freeYogaTree.js";
|
|
6
7
|
import { toPositioned } from "./toPositioned/toPositioned.js";
|
|
7
8
|
export async function buildPptx(xml, slideSize, options) {
|
|
8
|
-
|
|
9
|
-
if (options?.textMeasurement) {
|
|
10
|
-
setTextMeasurementMode(options.textMeasurement);
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
setTextMeasurementMode("auto");
|
|
14
|
-
}
|
|
9
|
+
const ctx = createBuildContext(options?.textMeasurement ?? "auto");
|
|
15
10
|
const nodes = parseXml(xml);
|
|
16
11
|
const positionedPages = [];
|
|
17
12
|
for (const node of nodes) {
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
try {
|
|
14
|
+
if (options?.autoFit !== false) {
|
|
15
|
+
await autoFitSlide(node, slideSize, ctx);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
await calcYogaLayout(node, slideSize, ctx);
|
|
19
|
+
}
|
|
20
|
+
const positioned = toPositioned(node, ctx);
|
|
21
|
+
positionedPages.push(positioned);
|
|
20
22
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
finally {
|
|
24
|
+
freeYogaTree(node);
|
|
23
25
|
}
|
|
24
|
-
const positioned = toPositioned(node);
|
|
25
|
-
positionedPages.push(positioned);
|
|
26
26
|
}
|
|
27
|
-
const pptx = renderPptx(positionedPages, slideSize, options?.master);
|
|
27
|
+
const pptx = renderPptx(positionedPages, slideSize, ctx, options?.master);
|
|
28
28
|
return pptx;
|
|
29
29
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { POMNode } from "../types.ts";
|
|
2
|
+
import type { BuildContext } from "../buildContext.ts";
|
|
2
3
|
/**
|
|
3
4
|
* POMNode ツリーを Yoga でレイアウト計算する
|
|
4
5
|
* POMNode ツリーの各ノードに yogaNode プロパティがセットされる
|
|
5
6
|
*
|
|
6
7
|
* @param root 入力 POMNode ツリーのルート
|
|
7
8
|
* @param slideSize スライド全体のサイズ(px)
|
|
9
|
+
* @param ctx BuildContext
|
|
8
10
|
*/
|
|
9
11
|
export declare function calcYogaLayout(root: POMNode, slideSize: {
|
|
10
12
|
w: number;
|
|
11
13
|
h: number;
|
|
12
|
-
}): Promise<void>;
|
|
14
|
+
}, ctx: BuildContext): Promise<void>;
|
|
13
15
|
//# sourceMappingURL=calcYogaLayout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calcYogaLayout.d.ts","sourceRoot":"","sources":["../../src/calcYogaLayout/calcYogaLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"calcYogaLayout.d.ts","sourceRoot":"","sources":["../../src/calcYogaLayout/calcYogaLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMvD;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,OAAO,EACb,SAAS,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EACnC,GAAG,EAAE,YAAY,iBAiBlB"}
|