@hirokisakabe/pom 0.1.0 → 0.1.1

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.
@@ -24,7 +24,7 @@ export async function calcYogaLayout(root, slideSize) {
24
24
  */
25
25
  let yogaP = null;
26
26
  async function getYoga() {
27
- if (!yogaP)
27
+ if (yogaP === null)
28
28
  yogaP = loadYoga();
29
29
  return yogaP;
30
30
  }
@@ -1,3 +1,4 @@
1
+ import PptxGenJS from "pptxgenjs";
1
2
  import type { PositionedNode } from "../types";
2
3
  export declare const PX_PER_IN = 96;
3
4
  export declare const pxToIn: (px: number) => number;
@@ -12,6 +13,6 @@ type SlidePx = {
12
13
  * @param slidePx スライド全体のサイズ(px)
13
14
  * @returns PptxGenJS インスタンス
14
15
  */
15
- export declare function renderPptx(pages: PositionedNode[], slidePx: SlidePx): any;
16
+ export declare function renderPptx(pages: PositionedNode[], slidePx: SlidePx): PptxGenJS;
16
17
  export {};
17
18
  //# sourceMappingURL=renderPptx.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderPptx.d.ts","sourceRoot":"","sources":["../../src/renderPptx/renderPptx.ts"],"names":[],"mappings":"AACA,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,OAoMnE"}
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"}
@@ -12,6 +12,7 @@ export const pxToPt = (px) => (px * 72) / PX_PER_IN;
12
12
  export function renderPptx(pages, slidePx) {
13
13
  const slideIn = { w: pxToIn(slidePx.w), h: pxToIn(slidePx.h) }; // layout(=px) → PptxGenJS(=inch) への最終変換
14
14
  // @ts-expect-error: PptxGenJS の型定義が不完全なため、一時的にエラーを無視
15
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
15
16
  const pptx = new PptxGenJS.default();
16
17
  pptx.defineLayout({ name: "custom", width: slideIn.w, height: slideIn.h });
17
18
  pptx.layout = "custom";
package/dist/types.d.ts CHANGED
@@ -1,76 +1,336 @@
1
1
  import type { Node as YogaNode } from "yoga-layout";
2
2
  import type PptxGenJS from "pptxgenjs";
3
- export type Length = number | "max" | `${number}%`;
4
- export type Padding = number | {
5
- top?: number;
6
- right?: number;
7
- bottom?: number;
8
- left?: number;
9
- };
10
- export type BorderDash = "solid" | "dash" | "dashDot" | "lgDash" | "lgDashDot" | "lgDashDotDot" | "sysDash" | "sysDot";
11
- export type BorderStyle = {
12
- color?: string;
13
- width?: number;
14
- dashType?: BorderDash;
15
- };
16
- export type FillStyle = {
17
- color?: string;
18
- transparency?: number;
19
- };
20
- export type ShadowStyle = {
21
- type?: "outer" | "inner";
22
- opacity?: number;
23
- blur?: number;
24
- angle?: number;
25
- offset?: number;
26
- color?: string;
27
- };
28
- export type AlignItems = "start" | "center" | "end" | "stretch";
29
- export type JustifyContent = "start" | "center" | "end" | "spaceBetween" | "spaceAround" | "spaceEvenly";
30
- export type FlexDirection = "row" | "column";
31
- type BasePOMNode = {
32
- yogaNode?: YogaNode;
33
- w?: Length;
34
- h?: Length;
35
- minW?: number;
36
- maxW?: number;
37
- minH?: number;
38
- maxH?: number;
39
- padding?: Padding;
40
- backgroundColor?: string;
41
- border?: BorderStyle;
42
- };
43
- export type TextNode = BasePOMNode & {
44
- type: "text";
45
- text: string;
46
- fontPx?: number;
47
- alignText?: "left" | "center" | "right";
48
- };
49
- export type ImageNode = BasePOMNode & {
50
- type: "image";
51
- src: string;
52
- };
53
- export type TableCell = {
54
- text: string;
55
- fontPx?: number;
56
- color?: string;
57
- bold?: boolean;
58
- alignText?: "left" | "center" | "right";
59
- backgroundColor?: string;
60
- };
61
- export type TableRow = {
62
- cells: TableCell[];
63
- height?: number;
64
- };
65
- export type TableColumn = {
66
- width: number;
67
- };
68
- export type TableNode = BasePOMNode & {
69
- type: "table";
70
- columns: TableColumn[];
71
- rows: TableRow[];
72
- defaultRowHeight?: number;
73
- };
3
+ import { z } from "zod";
4
+ export declare const lengthSchema: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>;
5
+ export declare const paddingSchema: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
6
+ top: z.ZodOptional<z.ZodNumber>;
7
+ right: z.ZodOptional<z.ZodNumber>;
8
+ bottom: z.ZodOptional<z.ZodNumber>;
9
+ left: z.ZodOptional<z.ZodNumber>;
10
+ }, z.core.$strip>]>;
11
+ export declare const borderDashSchema: z.ZodEnum<{
12
+ solid: "solid";
13
+ dash: "dash";
14
+ dashDot: "dashDot";
15
+ lgDash: "lgDash";
16
+ lgDashDot: "lgDashDot";
17
+ lgDashDotDot: "lgDashDotDot";
18
+ sysDash: "sysDash";
19
+ sysDot: "sysDot";
20
+ }>;
21
+ export declare const borderStyleSchema: z.ZodObject<{
22
+ color: z.ZodOptional<z.ZodString>;
23
+ width: z.ZodOptional<z.ZodNumber>;
24
+ dashType: z.ZodOptional<z.ZodEnum<{
25
+ solid: "solid";
26
+ dash: "dash";
27
+ dashDot: "dashDot";
28
+ lgDash: "lgDash";
29
+ lgDashDot: "lgDashDot";
30
+ lgDashDotDot: "lgDashDotDot";
31
+ sysDash: "sysDash";
32
+ sysDot: "sysDot";
33
+ }>>;
34
+ }, z.core.$strip>;
35
+ export declare const fillStyleSchema: z.ZodObject<{
36
+ color: z.ZodOptional<z.ZodString>;
37
+ transparency: z.ZodOptional<z.ZodNumber>;
38
+ }, z.core.$strip>;
39
+ export declare const shadowStyleSchema: z.ZodObject<{
40
+ type: z.ZodOptional<z.ZodEnum<{
41
+ outer: "outer";
42
+ inner: "inner";
43
+ }>>;
44
+ opacity: z.ZodOptional<z.ZodNumber>;
45
+ blur: z.ZodOptional<z.ZodNumber>;
46
+ angle: z.ZodOptional<z.ZodNumber>;
47
+ offset: z.ZodOptional<z.ZodNumber>;
48
+ color: z.ZodOptional<z.ZodString>;
49
+ }, z.core.$strip>;
50
+ export declare const alignItemsSchema: z.ZodEnum<{
51
+ start: "start";
52
+ center: "center";
53
+ end: "end";
54
+ stretch: "stretch";
55
+ }>;
56
+ export declare const justifyContentSchema: z.ZodEnum<{
57
+ start: "start";
58
+ center: "center";
59
+ end: "end";
60
+ spaceBetween: "spaceBetween";
61
+ spaceAround: "spaceAround";
62
+ spaceEvenly: "spaceEvenly";
63
+ }>;
64
+ export declare const flexDirectionSchema: z.ZodEnum<{
65
+ row: "row";
66
+ column: "column";
67
+ }>;
68
+ export type Length = z.infer<typeof lengthSchema>;
69
+ export type Padding = z.infer<typeof paddingSchema>;
70
+ export type BorderDash = z.infer<typeof borderDashSchema>;
71
+ export type BorderStyle = z.infer<typeof borderStyleSchema>;
72
+ export type FillStyle = z.infer<typeof fillStyleSchema>;
73
+ export type ShadowStyle = z.infer<typeof shadowStyleSchema>;
74
+ export type AlignItems = z.infer<typeof alignItemsSchema>;
75
+ export type JustifyContent = z.infer<typeof justifyContentSchema>;
76
+ export type FlexDirection = z.infer<typeof flexDirectionSchema>;
77
+ declare const basePOMNodeSchema: z.ZodObject<{
78
+ yogaNode: z.ZodOptional<z.ZodCustom<YogaNode, YogaNode>>;
79
+ w: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
80
+ h: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
81
+ minW: z.ZodOptional<z.ZodNumber>;
82
+ maxW: z.ZodOptional<z.ZodNumber>;
83
+ minH: z.ZodOptional<z.ZodNumber>;
84
+ maxH: z.ZodOptional<z.ZodNumber>;
85
+ padding: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
86
+ top: z.ZodOptional<z.ZodNumber>;
87
+ right: z.ZodOptional<z.ZodNumber>;
88
+ bottom: z.ZodOptional<z.ZodNumber>;
89
+ left: z.ZodOptional<z.ZodNumber>;
90
+ }, z.core.$strip>]>>;
91
+ backgroundColor: z.ZodOptional<z.ZodString>;
92
+ border: z.ZodOptional<z.ZodObject<{
93
+ color: z.ZodOptional<z.ZodString>;
94
+ width: z.ZodOptional<z.ZodNumber>;
95
+ dashType: z.ZodOptional<z.ZodEnum<{
96
+ solid: "solid";
97
+ dash: "dash";
98
+ dashDot: "dashDot";
99
+ lgDash: "lgDash";
100
+ lgDashDot: "lgDashDot";
101
+ lgDashDotDot: "lgDashDotDot";
102
+ sysDash: "sysDash";
103
+ sysDot: "sysDot";
104
+ }>>;
105
+ }, z.core.$strip>>;
106
+ }, z.core.$strip>;
107
+ type BasePOMNode = z.infer<typeof basePOMNodeSchema>;
108
+ export declare const textNodeSchema: z.ZodObject<{
109
+ yogaNode: z.ZodOptional<z.ZodCustom<YogaNode, YogaNode>>;
110
+ w: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
111
+ h: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
112
+ minW: z.ZodOptional<z.ZodNumber>;
113
+ maxW: z.ZodOptional<z.ZodNumber>;
114
+ minH: z.ZodOptional<z.ZodNumber>;
115
+ maxH: z.ZodOptional<z.ZodNumber>;
116
+ padding: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
117
+ top: z.ZodOptional<z.ZodNumber>;
118
+ right: z.ZodOptional<z.ZodNumber>;
119
+ bottom: z.ZodOptional<z.ZodNumber>;
120
+ left: z.ZodOptional<z.ZodNumber>;
121
+ }, z.core.$strip>]>>;
122
+ backgroundColor: z.ZodOptional<z.ZodString>;
123
+ border: z.ZodOptional<z.ZodObject<{
124
+ color: z.ZodOptional<z.ZodString>;
125
+ width: z.ZodOptional<z.ZodNumber>;
126
+ dashType: z.ZodOptional<z.ZodEnum<{
127
+ solid: "solid";
128
+ dash: "dash";
129
+ dashDot: "dashDot";
130
+ lgDash: "lgDash";
131
+ lgDashDot: "lgDashDot";
132
+ lgDashDotDot: "lgDashDotDot";
133
+ sysDash: "sysDash";
134
+ sysDot: "sysDot";
135
+ }>>;
136
+ }, z.core.$strip>>;
137
+ type: z.ZodLiteral<"text">;
138
+ text: z.ZodString;
139
+ fontPx: z.ZodOptional<z.ZodNumber>;
140
+ alignText: z.ZodOptional<z.ZodEnum<{
141
+ right: "right";
142
+ left: "left";
143
+ center: "center";
144
+ }>>;
145
+ }, z.core.$strip>;
146
+ export declare const imageNodeSchema: z.ZodObject<{
147
+ yogaNode: z.ZodOptional<z.ZodCustom<YogaNode, YogaNode>>;
148
+ w: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
149
+ h: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
150
+ minW: z.ZodOptional<z.ZodNumber>;
151
+ maxW: z.ZodOptional<z.ZodNumber>;
152
+ minH: z.ZodOptional<z.ZodNumber>;
153
+ maxH: z.ZodOptional<z.ZodNumber>;
154
+ padding: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
155
+ top: z.ZodOptional<z.ZodNumber>;
156
+ right: z.ZodOptional<z.ZodNumber>;
157
+ bottom: z.ZodOptional<z.ZodNumber>;
158
+ left: z.ZodOptional<z.ZodNumber>;
159
+ }, z.core.$strip>]>>;
160
+ backgroundColor: z.ZodOptional<z.ZodString>;
161
+ border: z.ZodOptional<z.ZodObject<{
162
+ color: z.ZodOptional<z.ZodString>;
163
+ width: z.ZodOptional<z.ZodNumber>;
164
+ dashType: z.ZodOptional<z.ZodEnum<{
165
+ solid: "solid";
166
+ dash: "dash";
167
+ dashDot: "dashDot";
168
+ lgDash: "lgDash";
169
+ lgDashDot: "lgDashDot";
170
+ lgDashDotDot: "lgDashDotDot";
171
+ sysDash: "sysDash";
172
+ sysDot: "sysDot";
173
+ }>>;
174
+ }, z.core.$strip>>;
175
+ type: z.ZodLiteral<"image">;
176
+ src: z.ZodString;
177
+ }, z.core.$strip>;
178
+ export declare const tableCellSchema: z.ZodObject<{
179
+ text: z.ZodString;
180
+ fontPx: z.ZodOptional<z.ZodNumber>;
181
+ color: z.ZodOptional<z.ZodString>;
182
+ bold: z.ZodOptional<z.ZodBoolean>;
183
+ alignText: z.ZodOptional<z.ZodEnum<{
184
+ right: "right";
185
+ left: "left";
186
+ center: "center";
187
+ }>>;
188
+ backgroundColor: z.ZodOptional<z.ZodString>;
189
+ }, z.core.$strip>;
190
+ export declare const tableRowSchema: z.ZodObject<{
191
+ cells: z.ZodArray<z.ZodObject<{
192
+ text: z.ZodString;
193
+ fontPx: z.ZodOptional<z.ZodNumber>;
194
+ color: z.ZodOptional<z.ZodString>;
195
+ bold: z.ZodOptional<z.ZodBoolean>;
196
+ alignText: z.ZodOptional<z.ZodEnum<{
197
+ right: "right";
198
+ left: "left";
199
+ center: "center";
200
+ }>>;
201
+ backgroundColor: z.ZodOptional<z.ZodString>;
202
+ }, z.core.$strip>>;
203
+ height: z.ZodOptional<z.ZodNumber>;
204
+ }, z.core.$strip>;
205
+ export declare const tableColumnSchema: z.ZodObject<{
206
+ width: z.ZodNumber;
207
+ }, z.core.$strip>;
208
+ export declare const tableNodeSchema: z.ZodObject<{
209
+ yogaNode: z.ZodOptional<z.ZodCustom<YogaNode, YogaNode>>;
210
+ w: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
211
+ h: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
212
+ minW: z.ZodOptional<z.ZodNumber>;
213
+ maxW: z.ZodOptional<z.ZodNumber>;
214
+ minH: z.ZodOptional<z.ZodNumber>;
215
+ maxH: z.ZodOptional<z.ZodNumber>;
216
+ padding: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
217
+ top: z.ZodOptional<z.ZodNumber>;
218
+ right: z.ZodOptional<z.ZodNumber>;
219
+ bottom: z.ZodOptional<z.ZodNumber>;
220
+ left: z.ZodOptional<z.ZodNumber>;
221
+ }, z.core.$strip>]>>;
222
+ backgroundColor: z.ZodOptional<z.ZodString>;
223
+ border: z.ZodOptional<z.ZodObject<{
224
+ color: z.ZodOptional<z.ZodString>;
225
+ width: z.ZodOptional<z.ZodNumber>;
226
+ dashType: z.ZodOptional<z.ZodEnum<{
227
+ solid: "solid";
228
+ dash: "dash";
229
+ dashDot: "dashDot";
230
+ lgDash: "lgDash";
231
+ lgDashDot: "lgDashDot";
232
+ lgDashDotDot: "lgDashDotDot";
233
+ sysDash: "sysDash";
234
+ sysDot: "sysDot";
235
+ }>>;
236
+ }, z.core.$strip>>;
237
+ type: z.ZodLiteral<"table">;
238
+ columns: z.ZodArray<z.ZodObject<{
239
+ width: z.ZodNumber;
240
+ }, z.core.$strip>>;
241
+ rows: z.ZodArray<z.ZodObject<{
242
+ cells: z.ZodArray<z.ZodObject<{
243
+ text: z.ZodString;
244
+ fontPx: z.ZodOptional<z.ZodNumber>;
245
+ color: z.ZodOptional<z.ZodString>;
246
+ bold: z.ZodOptional<z.ZodBoolean>;
247
+ alignText: z.ZodOptional<z.ZodEnum<{
248
+ right: "right";
249
+ left: "left";
250
+ center: "center";
251
+ }>>;
252
+ backgroundColor: z.ZodOptional<z.ZodString>;
253
+ }, z.core.$strip>>;
254
+ height: z.ZodOptional<z.ZodNumber>;
255
+ }, z.core.$strip>>;
256
+ defaultRowHeight: z.ZodOptional<z.ZodNumber>;
257
+ }, z.core.$strip>;
258
+ export declare const shapeNodeSchema: z.ZodObject<{
259
+ yogaNode: z.ZodOptional<z.ZodCustom<YogaNode, YogaNode>>;
260
+ w: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
261
+ h: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
262
+ minW: z.ZodOptional<z.ZodNumber>;
263
+ maxW: z.ZodOptional<z.ZodNumber>;
264
+ minH: z.ZodOptional<z.ZodNumber>;
265
+ maxH: z.ZodOptional<z.ZodNumber>;
266
+ padding: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
267
+ top: z.ZodOptional<z.ZodNumber>;
268
+ right: z.ZodOptional<z.ZodNumber>;
269
+ bottom: z.ZodOptional<z.ZodNumber>;
270
+ left: z.ZodOptional<z.ZodNumber>;
271
+ }, z.core.$strip>]>>;
272
+ backgroundColor: z.ZodOptional<z.ZodString>;
273
+ border: z.ZodOptional<z.ZodObject<{
274
+ color: z.ZodOptional<z.ZodString>;
275
+ width: z.ZodOptional<z.ZodNumber>;
276
+ dashType: z.ZodOptional<z.ZodEnum<{
277
+ solid: "solid";
278
+ dash: "dash";
279
+ dashDot: "dashDot";
280
+ lgDash: "lgDash";
281
+ lgDashDot: "lgDashDot";
282
+ lgDashDotDot: "lgDashDotDot";
283
+ sysDash: "sysDash";
284
+ sysDot: "sysDot";
285
+ }>>;
286
+ }, z.core.$strip>>;
287
+ type: z.ZodLiteral<"shape">;
288
+ shapeType: z.ZodCustom<PptxGenJS.SHAPE_NAME, PptxGenJS.SHAPE_NAME>;
289
+ text: z.ZodOptional<z.ZodString>;
290
+ fill: z.ZodOptional<z.ZodObject<{
291
+ color: z.ZodOptional<z.ZodString>;
292
+ transparency: z.ZodOptional<z.ZodNumber>;
293
+ }, z.core.$strip>>;
294
+ line: z.ZodOptional<z.ZodObject<{
295
+ color: z.ZodOptional<z.ZodString>;
296
+ width: z.ZodOptional<z.ZodNumber>;
297
+ dashType: z.ZodOptional<z.ZodEnum<{
298
+ solid: "solid";
299
+ dash: "dash";
300
+ dashDot: "dashDot";
301
+ lgDash: "lgDash";
302
+ lgDashDot: "lgDashDot";
303
+ lgDashDotDot: "lgDashDotDot";
304
+ sysDash: "sysDash";
305
+ sysDot: "sysDot";
306
+ }>>;
307
+ }, z.core.$strip>>;
308
+ shadow: z.ZodOptional<z.ZodObject<{
309
+ type: z.ZodOptional<z.ZodEnum<{
310
+ outer: "outer";
311
+ inner: "inner";
312
+ }>>;
313
+ opacity: z.ZodOptional<z.ZodNumber>;
314
+ blur: z.ZodOptional<z.ZodNumber>;
315
+ angle: z.ZodOptional<z.ZodNumber>;
316
+ offset: z.ZodOptional<z.ZodNumber>;
317
+ color: z.ZodOptional<z.ZodString>;
318
+ }, z.core.$strip>>;
319
+ fontPx: z.ZodOptional<z.ZodNumber>;
320
+ fontColor: z.ZodOptional<z.ZodString>;
321
+ alignText: z.ZodOptional<z.ZodEnum<{
322
+ right: "right";
323
+ left: "left";
324
+ center: "center";
325
+ }>>;
326
+ }, z.core.$strip>;
327
+ export type TextNode = z.infer<typeof textNodeSchema>;
328
+ export type ImageNode = z.infer<typeof imageNodeSchema>;
329
+ export type TableCell = z.infer<typeof tableCellSchema>;
330
+ export type TableRow = z.infer<typeof tableRowSchema>;
331
+ export type TableColumn = z.infer<typeof tableColumnSchema>;
332
+ export type TableNode = z.infer<typeof tableNodeSchema>;
333
+ export type ShapeNode = z.infer<typeof shapeNodeSchema>;
74
334
  export type BoxNode = BasePOMNode & {
75
335
  type: "box";
76
336
  children: POMNode;
@@ -89,24 +349,18 @@ export type HStackNode = BasePOMNode & {
89
349
  alignItems?: AlignItems;
90
350
  justifyContent?: JustifyContent;
91
351
  };
92
- export type ShapeNode = BasePOMNode & {
93
- type: "shape";
94
- shapeType: PptxGenJS.SHAPE_NAME;
95
- text?: string;
96
- fill?: FillStyle;
97
- line?: BorderStyle;
98
- shadow?: ShadowStyle;
99
- fontPx?: number;
100
- fontColor?: string;
101
- alignText?: "left" | "center" | "right";
102
- };
103
352
  export type POMNode = TextNode | ImageNode | TableNode | BoxNode | VStackNode | HStackNode | ShapeNode;
104
- type PositionedBase = {
105
- x: number;
106
- y: number;
107
- w: number;
108
- h: number;
109
- };
353
+ export declare const boxNodeSchema: z.ZodType<BoxNode>;
354
+ export declare const vStackNodeSchema: z.ZodType<VStackNode>;
355
+ export declare const hStackNodeSchema: z.ZodType<HStackNode>;
356
+ export declare const pomNodeSchema: z.ZodType<POMNode>;
357
+ declare const positionedBaseSchema: z.ZodObject<{
358
+ x: z.ZodNumber;
359
+ y: z.ZodNumber;
360
+ w: z.ZodNumber;
361
+ h: z.ZodNumber;
362
+ }, z.core.$strip>;
363
+ type PositionedBase = z.infer<typeof positionedBaseSchema>;
110
364
  export type PositionedNode = (TextNode & PositionedBase) | (ImageNode & PositionedBase) | (TableNode & PositionedBase) | (BoxNode & PositionedBase & {
111
365
  children: PositionedNode;
112
366
  }) | (VStackNode & PositionedBase & {
@@ -114,5 +368,6 @@ export type PositionedNode = (TextNode & PositionedBase) | (ImageNode & Position
114
368
  }) | (HStackNode & PositionedBase & {
115
369
  children: PositionedNode[];
116
370
  }) | (ShapeNode & PositionedBase);
371
+ export declare const positionedNodeSchema: z.ZodType<PositionedNode>;
117
372
  export {};
118
373
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AAEvC,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,GAAG,MAAM,GAAG,CAAC;AAEnD,MAAM,MAAM,OAAO,GACf,MAAM,GACN;IACE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEN,MAAM,MAAM,UAAU,GAClB,OAAO,GACP,MAAM,GACN,SAAS,GACT,QAAQ,GACR,WAAW,GACX,cAAc,GACd,SAAS,GACT,QAAQ,CAAC;AAEb,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,G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AAO,CAAC,cAAc,CAgB7B,CAAC"}
package/dist/types.js CHANGED
@@ -1 +1,163 @@
1
- export {};
1
+ import { z } from "zod";
2
+ // ===== Basic Types =====
3
+ export const lengthSchema = z.union([
4
+ z.number(),
5
+ z.literal("max"),
6
+ z.string().regex(/^\d+%$/),
7
+ ]);
8
+ export const paddingSchema = z.union([
9
+ z.number(),
10
+ z.object({
11
+ top: z.number().optional(),
12
+ right: z.number().optional(),
13
+ bottom: z.number().optional(),
14
+ left: z.number().optional(),
15
+ }),
16
+ ]);
17
+ export const borderDashSchema = z.enum([
18
+ "solid",
19
+ "dash",
20
+ "dashDot",
21
+ "lgDash",
22
+ "lgDashDot",
23
+ "lgDashDotDot",
24
+ "sysDash",
25
+ "sysDot",
26
+ ]);
27
+ export const borderStyleSchema = z.object({
28
+ color: z.string().optional(),
29
+ width: z.number().optional(),
30
+ dashType: borderDashSchema.optional(),
31
+ });
32
+ export const fillStyleSchema = z.object({
33
+ color: z.string().optional(),
34
+ transparency: z.number().optional(),
35
+ });
36
+ export const shadowStyleSchema = z.object({
37
+ type: z.enum(["outer", "inner"]).optional(),
38
+ opacity: z.number().optional(),
39
+ blur: z.number().optional(),
40
+ angle: z.number().optional(),
41
+ offset: z.number().optional(),
42
+ color: z.string().optional(),
43
+ });
44
+ export const alignItemsSchema = z.enum(["start", "center", "end", "stretch"]);
45
+ export const justifyContentSchema = z.enum([
46
+ "start",
47
+ "center",
48
+ "end",
49
+ "spaceBetween",
50
+ "spaceAround",
51
+ "spaceEvenly",
52
+ ]);
53
+ export const flexDirectionSchema = z.enum(["row", "column"]);
54
+ // ===== Base Node =====
55
+ const basePOMNodeSchema = z.object({
56
+ yogaNode: z.custom().optional(),
57
+ w: lengthSchema.optional(),
58
+ h: lengthSchema.optional(),
59
+ minW: z.number().optional(),
60
+ maxW: z.number().optional(),
61
+ minH: z.number().optional(),
62
+ maxH: z.number().optional(),
63
+ padding: paddingSchema.optional(),
64
+ backgroundColor: z.string().optional(),
65
+ border: borderStyleSchema.optional(),
66
+ });
67
+ // ===== Non-recursive Node Types =====
68
+ export const textNodeSchema = basePOMNodeSchema.extend({
69
+ type: z.literal("text"),
70
+ text: z.string(),
71
+ fontPx: z.number().optional(),
72
+ alignText: z.enum(["left", "center", "right"]).optional(),
73
+ });
74
+ export const imageNodeSchema = basePOMNodeSchema.extend({
75
+ type: z.literal("image"),
76
+ src: z.string(),
77
+ });
78
+ export const tableCellSchema = z.object({
79
+ text: z.string(),
80
+ fontPx: z.number().optional(),
81
+ color: z.string().optional(),
82
+ bold: z.boolean().optional(),
83
+ alignText: z.enum(["left", "center", "right"]).optional(),
84
+ backgroundColor: z.string().optional(),
85
+ });
86
+ export const tableRowSchema = z.object({
87
+ cells: z.array(tableCellSchema),
88
+ height: z.number().optional(),
89
+ });
90
+ export const tableColumnSchema = z.object({
91
+ width: z.number(),
92
+ });
93
+ export const tableNodeSchema = basePOMNodeSchema.extend({
94
+ type: z.literal("table"),
95
+ columns: z.array(tableColumnSchema),
96
+ rows: z.array(tableRowSchema),
97
+ defaultRowHeight: z.number().optional(),
98
+ });
99
+ export const shapeNodeSchema = basePOMNodeSchema.extend({
100
+ type: z.literal("shape"),
101
+ shapeType: z.custom(),
102
+ text: z.string().optional(),
103
+ fill: fillStyleSchema.optional(),
104
+ line: borderStyleSchema.optional(),
105
+ shadow: shadowStyleSchema.optional(),
106
+ fontPx: z.number().optional(),
107
+ fontColor: z.string().optional(),
108
+ alignText: z.enum(["left", "center", "right"]).optional(),
109
+ });
110
+ // Define schemas using passthrough to maintain type safety
111
+ const boxNodeSchemaBase = basePOMNodeSchema.extend({
112
+ type: z.literal("box"),
113
+ children: z.lazy(() => pomNodeSchema),
114
+ });
115
+ const vStackNodeSchemaBase = basePOMNodeSchema.extend({
116
+ type: z.literal("vstack"),
117
+ children: z.array(z.lazy(() => pomNodeSchema)),
118
+ gap: z.number().optional(),
119
+ alignItems: alignItemsSchema.optional(),
120
+ justifyContent: justifyContentSchema.optional(),
121
+ });
122
+ const hStackNodeSchemaBase = basePOMNodeSchema.extend({
123
+ type: z.literal("hstack"),
124
+ children: z.array(z.lazy(() => pomNodeSchema)),
125
+ gap: z.number().optional(),
126
+ alignItems: alignItemsSchema.optional(),
127
+ justifyContent: justifyContentSchema.optional(),
128
+ });
129
+ // Export with proper type annotations using z.ZodType
130
+ export const boxNodeSchema = boxNodeSchemaBase;
131
+ export const vStackNodeSchema = vStackNodeSchemaBase;
132
+ export const hStackNodeSchema = hStackNodeSchemaBase;
133
+ export const pomNodeSchema = z.lazy(() => z.discriminatedUnion("type", [
134
+ textNodeSchema,
135
+ imageNodeSchema,
136
+ tableNodeSchema,
137
+ boxNodeSchemaBase,
138
+ vStackNodeSchemaBase,
139
+ hStackNodeSchemaBase,
140
+ shapeNodeSchema,
141
+ ]));
142
+ // ===== Positioned Node Types =====
143
+ const positionedBaseSchema = z.object({
144
+ x: z.number(),
145
+ y: z.number(),
146
+ w: z.number(),
147
+ h: z.number(),
148
+ });
149
+ export const positionedNodeSchema = z.lazy(() => z.union([
150
+ textNodeSchema.merge(positionedBaseSchema),
151
+ imageNodeSchema.merge(positionedBaseSchema),
152
+ tableNodeSchema.merge(positionedBaseSchema),
153
+ boxNodeSchemaBase.merge(positionedBaseSchema).extend({
154
+ children: z.lazy(() => positionedNodeSchema),
155
+ }),
156
+ vStackNodeSchemaBase.merge(positionedBaseSchema).extend({
157
+ children: z.array(z.lazy(() => positionedNodeSchema)),
158
+ }),
159
+ hStackNodeSchemaBase.merge(positionedBaseSchema).extend({
160
+ children: z.array(z.lazy(() => positionedNodeSchema)),
161
+ }),
162
+ shapeNodeSchema.merge(positionedBaseSchema),
163
+ ]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hirokisakabe/pom",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "PowerPoint Object Model - A declarative TypeScript library for creating PowerPoint presentations",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -53,6 +53,7 @@
53
53
  "canvas": "3.2.0",
54
54
  "image-size": "2.0.2",
55
55
  "pptxgenjs": "4.0.1",
56
- "yoga-layout": "3.2.1"
56
+ "yoga-layout": "3.2.1",
57
+ "zod": "4.1.12"
57
58
  }
58
59
  }