@hirokisakabe/pom 0.1.1 → 0.1.3

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.
@@ -2,5 +2,5 @@ import { POMNode } from "./types";
2
2
  export declare function buildPptx(nodes: POMNode[], slideSize: {
3
3
  w: number;
4
4
  h: number;
5
- }, fileName: string): Promise<void>;
5
+ }): Promise<import("pptxgenjs").default>;
6
6
  //# sourceMappingURL=buildPptx.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildPptx.d.ts","sourceRoot":"","sources":["../src/buildPptx.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAElD,wBAAsB,SAAS,CAC7B,KAAK,EAAE,OAAO,EAAE,EAChB,SAAS,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EACnC,QAAQ,EAAE,MAAM,iBAajB"}
1
+ {"version":3,"file":"buildPptx.d.ts","sourceRoot":"","sources":["../src/buildPptx.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAElD,wBAAsB,SAAS,CAC7B,KAAK,EAAE,OAAO,EAAE,EAChB,SAAS,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,wCAapC"}
package/dist/buildPptx.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { calcYogaLayout } from "./calcYogaLayout/calcYogaLayout";
2
2
  import { renderPptx } from "./renderPptx/renderPptx";
3
3
  import { toPositioned } from "./toPositioned/toPositioned";
4
- export async function buildPptx(nodes, slideSize, fileName) {
4
+ export async function buildPptx(nodes, slideSize) {
5
5
  const positionedPages = [];
6
6
  for (const node of nodes) {
7
7
  await calcYogaLayout(node, slideSize);
@@ -9,5 +9,5 @@ export async function buildPptx(nodes, slideSize, fileName) {
9
9
  positionedPages.push(positioned);
10
10
  }
11
11
  const pptx = renderPptx(positionedPages, slideSize);
12
- await pptx.writeFile({ fileName });
12
+ return pptx;
13
13
  }
@@ -1,4 +1,4 @@
1
- import PptxGenJS from "pptxgenjs";
1
+ import type PptxGenJSType from "pptxgenjs";
2
2
  import type { PositionedNode } from "../types";
3
3
  export declare const PX_PER_IN = 96;
4
4
  export declare const pxToIn: (px: number) => number;
@@ -13,6 +13,6 @@ type SlidePx = {
13
13
  * @param slidePx スライド全体のサイズ(px)
14
14
  * @returns PptxGenJS インスタンス
15
15
  */
16
- export declare function renderPptx(pages: PositionedNode[], slidePx: SlidePx): PptxGenJS;
16
+ export declare function renderPptx(pages: PositionedNode[], slidePx: SlidePx): PptxGenJSType;
17
17
  export {};
18
18
  //# sourceMappingURL=renderPptx.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderPptx.d.ts","sourceRoot":"","sources":["../../src/renderPptx/renderPptx.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,MAAM,GAAI,IAAI,MAAM,WAAmB,CAAC;AACrD,eAAO,MAAM,MAAM,GAAI,IAAI,MAAM,WAA0B,CAAC;AAE5D,KAAK,OAAO,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE,OAAO,EAAE,OAAO,aAqMnE"}
1
+ {"version":3,"file":"renderPptx.d.ts","sourceRoot":"","sources":["../../src/renderPptx/renderPptx.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,aAAa,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,MAAM,GAAI,IAAI,MAAM,WAAmB,CAAC;AACrD,eAAO,MAAM,MAAM,GAAI,IAAI,MAAM,WAA0B,CAAC;AAE5D,KAAK,OAAO,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE,OAAO,EAAE,OAAO,iBAqMnE"}
@@ -1,4 +1,6 @@
1
- import PptxGenJS from "pptxgenjs";
1
+ import { createRequire } from "module";
2
+ const require = createRequire(import.meta.url);
3
+ const PptxGenJS = require("pptxgenjs");
2
4
  import { resolveRowHeights } from "../table/utils";
3
5
  export const PX_PER_IN = 96;
4
6
  export const pxToIn = (px) => px / PX_PER_IN;
@@ -11,9 +13,7 @@ export const pxToPt = (px) => (px * 72) / PX_PER_IN;
11
13
  */
12
14
  export function renderPptx(pages, slidePx) {
13
15
  const slideIn = { w: pxToIn(slidePx.w), h: pxToIn(slidePx.h) }; // layout(=px) → PptxGenJS(=inch) への最終変換
14
- // @ts-expect-error: PptxGenJS の型定義が不完全なため、一時的にエラーを無視
15
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
16
- const pptx = new PptxGenJS.default();
16
+ const pptx = new PptxGenJS();
17
17
  pptx.defineLayout({ name: "custom", width: slideIn.w, height: slideIn.h });
18
18
  pptx.layout = "custom";
19
19
  for (const data of pages) {
@@ -67,6 +67,7 @@ export function renderPptx(pages, slidePx) {
67
67
  align: "left",
68
68
  valign: "top",
69
69
  margin: 0,
70
+ lineSpacingMultiple: 1.3,
70
71
  };
71
72
  slide.addText(node.text ?? "", opts);
72
73
  break;
@@ -164,6 +165,7 @@ export function renderPptx(pages, slidePx) {
164
165
  color: node.fontColor,
165
166
  align: node.alignText ?? "center",
166
167
  valign: "middle",
168
+ lineSpacingMultiple: 1.3,
167
169
  });
168
170
  }
169
171
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hirokisakabe/pom",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "PowerPoint Object Model - A declarative TypeScript library for creating PowerPoint presentations",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",