@hirokisakabe/pom 0.1.4 → 0.1.6

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.
@@ -0,0 +1,483 @@
1
+ /**
2
+ * Input schemas for LLM/external input validation
3
+ *
4
+ * These schemas do not include internal properties like `yogaNode`.
5
+ * Use these when validating JSON from OpenAI, Claude, or other LLMs.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { inputPomNodeSchema, InputPOMNode } from "@hirokisakabe/pom";
10
+ *
11
+ * // Validate and parse JSON from LLM
12
+ * const json = JSON.parse(llmResponse);
13
+ * const result = inputPomNodeSchema.safeParse(json);
14
+ * if (result.success) {
15
+ * const pptx = await buildPptx([result.data], { w: 1280, h: 720 });
16
+ * }
17
+ * ```
18
+ */
19
+ import { z } from "zod";
20
+ import { type AlignItems, type JustifyContent } from "./types";
21
+ export declare const inputBaseNodeSchema: z.ZodObject<{
22
+ w: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
23
+ h: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
24
+ minW: z.ZodOptional<z.ZodNumber>;
25
+ maxW: z.ZodOptional<z.ZodNumber>;
26
+ minH: z.ZodOptional<z.ZodNumber>;
27
+ maxH: z.ZodOptional<z.ZodNumber>;
28
+ padding: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
29
+ top: z.ZodOptional<z.ZodNumber>;
30
+ right: z.ZodOptional<z.ZodNumber>;
31
+ bottom: z.ZodOptional<z.ZodNumber>;
32
+ left: z.ZodOptional<z.ZodNumber>;
33
+ }, z.core.$strip>]>>;
34
+ backgroundColor: z.ZodOptional<z.ZodString>;
35
+ border: z.ZodOptional<z.ZodObject<{
36
+ color: z.ZodOptional<z.ZodString>;
37
+ width: z.ZodOptional<z.ZodNumber>;
38
+ dashType: z.ZodOptional<z.ZodEnum<{
39
+ solid: "solid";
40
+ dash: "dash";
41
+ dashDot: "dashDot";
42
+ lgDash: "lgDash";
43
+ lgDashDot: "lgDashDot";
44
+ lgDashDotDot: "lgDashDotDot";
45
+ sysDash: "sysDash";
46
+ sysDot: "sysDot";
47
+ }>>;
48
+ }, z.core.$strip>>;
49
+ }, z.core.$strip>;
50
+ type InputBaseNode = z.infer<typeof inputBaseNodeSchema>;
51
+ export declare const inputTextNodeSchema: z.ZodObject<{
52
+ w: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
53
+ h: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
54
+ minW: z.ZodOptional<z.ZodNumber>;
55
+ maxW: z.ZodOptional<z.ZodNumber>;
56
+ minH: z.ZodOptional<z.ZodNumber>;
57
+ maxH: z.ZodOptional<z.ZodNumber>;
58
+ padding: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
59
+ top: z.ZodOptional<z.ZodNumber>;
60
+ right: z.ZodOptional<z.ZodNumber>;
61
+ bottom: z.ZodOptional<z.ZodNumber>;
62
+ left: z.ZodOptional<z.ZodNumber>;
63
+ }, z.core.$strip>]>>;
64
+ backgroundColor: z.ZodOptional<z.ZodString>;
65
+ border: z.ZodOptional<z.ZodObject<{
66
+ color: z.ZodOptional<z.ZodString>;
67
+ width: z.ZodOptional<z.ZodNumber>;
68
+ dashType: z.ZodOptional<z.ZodEnum<{
69
+ solid: "solid";
70
+ dash: "dash";
71
+ dashDot: "dashDot";
72
+ lgDash: "lgDash";
73
+ lgDashDot: "lgDashDot";
74
+ lgDashDotDot: "lgDashDotDot";
75
+ sysDash: "sysDash";
76
+ sysDot: "sysDot";
77
+ }>>;
78
+ }, z.core.$strip>>;
79
+ type: z.ZodLiteral<"text">;
80
+ text: z.ZodString;
81
+ fontPx: z.ZodOptional<z.ZodNumber>;
82
+ color: z.ZodOptional<z.ZodString>;
83
+ alignText: z.ZodOptional<z.ZodEnum<{
84
+ right: "right";
85
+ left: "left";
86
+ center: "center";
87
+ }>>;
88
+ bold: z.ZodOptional<z.ZodBoolean>;
89
+ fontFamily: z.ZodOptional<z.ZodString>;
90
+ lineSpacingMultiple: z.ZodOptional<z.ZodNumber>;
91
+ }, z.core.$strip>;
92
+ export declare const inputImageNodeSchema: z.ZodObject<{
93
+ w: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
94
+ h: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
95
+ minW: z.ZodOptional<z.ZodNumber>;
96
+ maxW: z.ZodOptional<z.ZodNumber>;
97
+ minH: z.ZodOptional<z.ZodNumber>;
98
+ maxH: z.ZodOptional<z.ZodNumber>;
99
+ padding: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
100
+ top: z.ZodOptional<z.ZodNumber>;
101
+ right: z.ZodOptional<z.ZodNumber>;
102
+ bottom: z.ZodOptional<z.ZodNumber>;
103
+ left: z.ZodOptional<z.ZodNumber>;
104
+ }, z.core.$strip>]>>;
105
+ backgroundColor: z.ZodOptional<z.ZodString>;
106
+ border: z.ZodOptional<z.ZodObject<{
107
+ color: z.ZodOptional<z.ZodString>;
108
+ width: z.ZodOptional<z.ZodNumber>;
109
+ dashType: z.ZodOptional<z.ZodEnum<{
110
+ solid: "solid";
111
+ dash: "dash";
112
+ dashDot: "dashDot";
113
+ lgDash: "lgDash";
114
+ lgDashDot: "lgDashDot";
115
+ lgDashDotDot: "lgDashDotDot";
116
+ sysDash: "sysDash";
117
+ sysDot: "sysDot";
118
+ }>>;
119
+ }, z.core.$strip>>;
120
+ type: z.ZodLiteral<"image">;
121
+ src: z.ZodString;
122
+ }, z.core.$strip>;
123
+ export declare const inputTableNodeSchema: z.ZodObject<{
124
+ w: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
125
+ h: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
126
+ minW: z.ZodOptional<z.ZodNumber>;
127
+ maxW: z.ZodOptional<z.ZodNumber>;
128
+ minH: z.ZodOptional<z.ZodNumber>;
129
+ maxH: z.ZodOptional<z.ZodNumber>;
130
+ padding: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
131
+ top: z.ZodOptional<z.ZodNumber>;
132
+ right: z.ZodOptional<z.ZodNumber>;
133
+ bottom: z.ZodOptional<z.ZodNumber>;
134
+ left: z.ZodOptional<z.ZodNumber>;
135
+ }, z.core.$strip>]>>;
136
+ backgroundColor: z.ZodOptional<z.ZodString>;
137
+ border: z.ZodOptional<z.ZodObject<{
138
+ color: z.ZodOptional<z.ZodString>;
139
+ width: z.ZodOptional<z.ZodNumber>;
140
+ dashType: z.ZodOptional<z.ZodEnum<{
141
+ solid: "solid";
142
+ dash: "dash";
143
+ dashDot: "dashDot";
144
+ lgDash: "lgDash";
145
+ lgDashDot: "lgDashDot";
146
+ lgDashDotDot: "lgDashDotDot";
147
+ sysDash: "sysDash";
148
+ sysDot: "sysDot";
149
+ }>>;
150
+ }, z.core.$strip>>;
151
+ type: z.ZodLiteral<"table">;
152
+ columns: z.ZodArray<z.ZodObject<{
153
+ width: z.ZodNumber;
154
+ }, z.core.$strip>>;
155
+ rows: z.ZodArray<z.ZodObject<{
156
+ cells: z.ZodArray<z.ZodObject<{
157
+ text: z.ZodString;
158
+ fontPx: z.ZodOptional<z.ZodNumber>;
159
+ color: z.ZodOptional<z.ZodString>;
160
+ bold: z.ZodOptional<z.ZodBoolean>;
161
+ alignText: z.ZodOptional<z.ZodEnum<{
162
+ right: "right";
163
+ left: "left";
164
+ center: "center";
165
+ }>>;
166
+ backgroundColor: z.ZodOptional<z.ZodString>;
167
+ }, z.core.$strip>>;
168
+ height: z.ZodOptional<z.ZodNumber>;
169
+ }, z.core.$strip>>;
170
+ defaultRowHeight: z.ZodOptional<z.ZodNumber>;
171
+ }, z.core.$strip>;
172
+ export declare const inputShapeNodeSchema: z.ZodObject<{
173
+ w: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
174
+ h: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
175
+ minW: z.ZodOptional<z.ZodNumber>;
176
+ maxW: z.ZodOptional<z.ZodNumber>;
177
+ minH: z.ZodOptional<z.ZodNumber>;
178
+ maxH: z.ZodOptional<z.ZodNumber>;
179
+ padding: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
180
+ top: z.ZodOptional<z.ZodNumber>;
181
+ right: z.ZodOptional<z.ZodNumber>;
182
+ bottom: z.ZodOptional<z.ZodNumber>;
183
+ left: z.ZodOptional<z.ZodNumber>;
184
+ }, z.core.$strip>]>>;
185
+ backgroundColor: z.ZodOptional<z.ZodString>;
186
+ border: z.ZodOptional<z.ZodObject<{
187
+ color: z.ZodOptional<z.ZodString>;
188
+ width: z.ZodOptional<z.ZodNumber>;
189
+ dashType: z.ZodOptional<z.ZodEnum<{
190
+ solid: "solid";
191
+ dash: "dash";
192
+ dashDot: "dashDot";
193
+ lgDash: "lgDash";
194
+ lgDashDot: "lgDashDot";
195
+ lgDashDotDot: "lgDashDotDot";
196
+ sysDash: "sysDash";
197
+ sysDot: "sysDot";
198
+ }>>;
199
+ }, z.core.$strip>>;
200
+ type: z.ZodLiteral<"shape">;
201
+ shapeType: z.ZodEnum<{
202
+ accentBorderCallout1: "accentBorderCallout1";
203
+ accentBorderCallout2: "accentBorderCallout2";
204
+ accentBorderCallout3: "accentBorderCallout3";
205
+ accentCallout1: "accentCallout1";
206
+ accentCallout2: "accentCallout2";
207
+ accentCallout3: "accentCallout3";
208
+ actionButtonBackPrevious: "actionButtonBackPrevious";
209
+ actionButtonBeginning: "actionButtonBeginning";
210
+ actionButtonBlank: "actionButtonBlank";
211
+ actionButtonDocument: "actionButtonDocument";
212
+ actionButtonEnd: "actionButtonEnd";
213
+ actionButtonForwardNext: "actionButtonForwardNext";
214
+ actionButtonHelp: "actionButtonHelp";
215
+ actionButtonHome: "actionButtonHome";
216
+ actionButtonInformation: "actionButtonInformation";
217
+ actionButtonMovie: "actionButtonMovie";
218
+ actionButtonReturn: "actionButtonReturn";
219
+ actionButtonSound: "actionButtonSound";
220
+ arc: "arc";
221
+ bentArrow: "bentArrow";
222
+ bentUpArrow: "bentUpArrow";
223
+ bevel: "bevel";
224
+ blockArc: "blockArc";
225
+ borderCallout1: "borderCallout1";
226
+ borderCallout2: "borderCallout2";
227
+ borderCallout3: "borderCallout3";
228
+ bracePair: "bracePair";
229
+ bracketPair: "bracketPair";
230
+ callout1: "callout1";
231
+ callout2: "callout2";
232
+ callout3: "callout3";
233
+ can: "can";
234
+ chartPlus: "chartPlus";
235
+ chartStar: "chartStar";
236
+ chartX: "chartX";
237
+ chevron: "chevron";
238
+ chord: "chord";
239
+ circularArrow: "circularArrow";
240
+ cloud: "cloud";
241
+ cloudCallout: "cloudCallout";
242
+ corner: "corner";
243
+ cornerTabs: "cornerTabs";
244
+ cube: "cube";
245
+ curvedDownArrow: "curvedDownArrow";
246
+ curvedLeftArrow: "curvedLeftArrow";
247
+ curvedRightArrow: "curvedRightArrow";
248
+ curvedUpArrow: "curvedUpArrow";
249
+ decagon: "decagon";
250
+ diagStripe: "diagStripe";
251
+ diamond: "diamond";
252
+ dodecagon: "dodecagon";
253
+ donut: "donut";
254
+ doubleWave: "doubleWave";
255
+ downArrow: "downArrow";
256
+ downArrowCallout: "downArrowCallout";
257
+ ellipse: "ellipse";
258
+ ellipseRibbon: "ellipseRibbon";
259
+ ellipseRibbon2: "ellipseRibbon2";
260
+ flowChartAlternateProcess: "flowChartAlternateProcess";
261
+ flowChartCollate: "flowChartCollate";
262
+ flowChartConnector: "flowChartConnector";
263
+ flowChartDecision: "flowChartDecision";
264
+ flowChartDelay: "flowChartDelay";
265
+ flowChartDisplay: "flowChartDisplay";
266
+ flowChartDocument: "flowChartDocument";
267
+ flowChartExtract: "flowChartExtract";
268
+ flowChartInputOutput: "flowChartInputOutput";
269
+ flowChartInternalStorage: "flowChartInternalStorage";
270
+ flowChartMagneticDisk: "flowChartMagneticDisk";
271
+ flowChartMagneticDrum: "flowChartMagneticDrum";
272
+ flowChartMagneticTape: "flowChartMagneticTape";
273
+ flowChartManualInput: "flowChartManualInput";
274
+ flowChartManualOperation: "flowChartManualOperation";
275
+ flowChartMerge: "flowChartMerge";
276
+ flowChartMultidocument: "flowChartMultidocument";
277
+ flowChartOfflineStorage: "flowChartOfflineStorage";
278
+ flowChartOffpageConnector: "flowChartOffpageConnector";
279
+ flowChartOnlineStorage: "flowChartOnlineStorage";
280
+ flowChartOr: "flowChartOr";
281
+ flowChartPredefinedProcess: "flowChartPredefinedProcess";
282
+ flowChartPreparation: "flowChartPreparation";
283
+ flowChartProcess: "flowChartProcess";
284
+ flowChartPunchedCard: "flowChartPunchedCard";
285
+ flowChartPunchedTape: "flowChartPunchedTape";
286
+ flowChartSort: "flowChartSort";
287
+ flowChartSummingJunction: "flowChartSummingJunction";
288
+ flowChartTerminator: "flowChartTerminator";
289
+ folderCorner: "folderCorner";
290
+ frame: "frame";
291
+ funnel: "funnel";
292
+ gear6: "gear6";
293
+ gear9: "gear9";
294
+ halfFrame: "halfFrame";
295
+ heart: "heart";
296
+ heptagon: "heptagon";
297
+ hexagon: "hexagon";
298
+ homePlate: "homePlate";
299
+ horizontalScroll: "horizontalScroll";
300
+ irregularSeal1: "irregularSeal1";
301
+ irregularSeal2: "irregularSeal2";
302
+ leftArrow: "leftArrow";
303
+ leftArrowCallout: "leftArrowCallout";
304
+ leftBrace: "leftBrace";
305
+ leftBracket: "leftBracket";
306
+ leftCircularArrow: "leftCircularArrow";
307
+ leftRightArrow: "leftRightArrow";
308
+ leftRightArrowCallout: "leftRightArrowCallout";
309
+ leftRightCircularArrow: "leftRightCircularArrow";
310
+ leftRightRibbon: "leftRightRibbon";
311
+ leftRightUpArrow: "leftRightUpArrow";
312
+ leftUpArrow: "leftUpArrow";
313
+ lightningBolt: "lightningBolt";
314
+ line: "line";
315
+ lineInv: "lineInv";
316
+ mathDivide: "mathDivide";
317
+ mathEqual: "mathEqual";
318
+ mathMinus: "mathMinus";
319
+ mathMultiply: "mathMultiply";
320
+ mathNotEqual: "mathNotEqual";
321
+ mathPlus: "mathPlus";
322
+ moon: "moon";
323
+ noSmoking: "noSmoking";
324
+ nonIsoscelesTrapezoid: "nonIsoscelesTrapezoid";
325
+ notchedRightArrow: "notchedRightArrow";
326
+ octagon: "octagon";
327
+ parallelogram: "parallelogram";
328
+ pentagon: "pentagon";
329
+ pie: "pie";
330
+ pieWedge: "pieWedge";
331
+ plaque: "plaque";
332
+ plaqueTabs: "plaqueTabs";
333
+ plus: "plus";
334
+ quadArrow: "quadArrow";
335
+ quadArrowCallout: "quadArrowCallout";
336
+ rect: "rect";
337
+ ribbon: "ribbon";
338
+ ribbon2: "ribbon2";
339
+ rightArrow: "rightArrow";
340
+ rightArrowCallout: "rightArrowCallout";
341
+ rightBrace: "rightBrace";
342
+ rightBracket: "rightBracket";
343
+ round1Rect: "round1Rect";
344
+ round2DiagRect: "round2DiagRect";
345
+ round2SameRect: "round2SameRect";
346
+ roundRect: "roundRect";
347
+ rtTriangle: "rtTriangle";
348
+ smileyFace: "smileyFace";
349
+ snip1Rect: "snip1Rect";
350
+ snip2DiagRect: "snip2DiagRect";
351
+ snip2SameRect: "snip2SameRect";
352
+ snipRoundRect: "snipRoundRect";
353
+ squareTabs: "squareTabs";
354
+ star10: "star10";
355
+ star12: "star12";
356
+ star16: "star16";
357
+ star24: "star24";
358
+ star32: "star32";
359
+ star4: "star4";
360
+ star5: "star5";
361
+ star6: "star6";
362
+ star7: "star7";
363
+ star8: "star8";
364
+ stripedRightArrow: "stripedRightArrow";
365
+ sun: "sun";
366
+ swooshArrow: "swooshArrow";
367
+ teardrop: "teardrop";
368
+ trapezoid: "trapezoid";
369
+ triangle: "triangle";
370
+ upArrow: "upArrow";
371
+ upArrowCallout: "upArrowCallout";
372
+ upDownArrow: "upDownArrow";
373
+ upDownArrowCallout: "upDownArrowCallout";
374
+ uturnArrow: "uturnArrow";
375
+ verticalScroll: "verticalScroll";
376
+ wave: "wave";
377
+ wedgeEllipseCallout: "wedgeEllipseCallout";
378
+ wedgeRectCallout: "wedgeRectCallout";
379
+ wedgeRoundRectCallout: "wedgeRoundRectCallout";
380
+ }>;
381
+ text: z.ZodOptional<z.ZodString>;
382
+ fill: z.ZodOptional<z.ZodObject<{
383
+ color: z.ZodOptional<z.ZodString>;
384
+ transparency: z.ZodOptional<z.ZodNumber>;
385
+ }, z.core.$strip>>;
386
+ line: z.ZodOptional<z.ZodObject<{
387
+ color: z.ZodOptional<z.ZodString>;
388
+ width: z.ZodOptional<z.ZodNumber>;
389
+ dashType: z.ZodOptional<z.ZodEnum<{
390
+ solid: "solid";
391
+ dash: "dash";
392
+ dashDot: "dashDot";
393
+ lgDash: "lgDash";
394
+ lgDashDot: "lgDashDot";
395
+ lgDashDotDot: "lgDashDotDot";
396
+ sysDash: "sysDash";
397
+ sysDot: "sysDot";
398
+ }>>;
399
+ }, z.core.$strip>>;
400
+ shadow: z.ZodOptional<z.ZodObject<{
401
+ type: z.ZodOptional<z.ZodEnum<{
402
+ outer: "outer";
403
+ inner: "inner";
404
+ }>>;
405
+ opacity: z.ZodOptional<z.ZodNumber>;
406
+ blur: z.ZodOptional<z.ZodNumber>;
407
+ angle: z.ZodOptional<z.ZodNumber>;
408
+ offset: z.ZodOptional<z.ZodNumber>;
409
+ color: z.ZodOptional<z.ZodString>;
410
+ }, z.core.$strip>>;
411
+ fontPx: z.ZodOptional<z.ZodNumber>;
412
+ fontColor: z.ZodOptional<z.ZodString>;
413
+ alignText: z.ZodOptional<z.ZodEnum<{
414
+ right: "right";
415
+ left: "left";
416
+ center: "center";
417
+ }>>;
418
+ }, z.core.$strip>;
419
+ export type InputTextNode = z.infer<typeof inputTextNodeSchema>;
420
+ export type InputImageNode = z.infer<typeof inputImageNodeSchema>;
421
+ export type InputTableNode = z.infer<typeof inputTableNodeSchema>;
422
+ export type InputShapeNode = z.infer<typeof inputShapeNodeSchema>;
423
+ export type InputBoxNode = InputBaseNode & {
424
+ type: "box";
425
+ children: InputPOMNode;
426
+ };
427
+ export type InputVStackNode = InputBaseNode & {
428
+ type: "vstack";
429
+ children: InputPOMNode[];
430
+ gap?: number;
431
+ alignItems?: AlignItems;
432
+ justifyContent?: JustifyContent;
433
+ };
434
+ export type InputHStackNode = InputBaseNode & {
435
+ type: "hstack";
436
+ children: InputPOMNode[];
437
+ gap?: number;
438
+ alignItems?: AlignItems;
439
+ justifyContent?: JustifyContent;
440
+ };
441
+ export type InputPOMNode = InputTextNode | InputImageNode | InputTableNode | InputBoxNode | InputVStackNode | InputHStackNode | InputShapeNode;
442
+ export declare const inputBoxNodeSchema: z.ZodType<InputBoxNode>;
443
+ export declare const inputVStackNodeSchema: z.ZodType<InputVStackNode>;
444
+ export declare const inputHStackNodeSchema: z.ZodType<InputHStackNode>;
445
+ /**
446
+ * Input schema for POM nodes (for LLM/external input validation)
447
+ *
448
+ * @example
449
+ * ```typescript
450
+ * import { inputPomNodeSchema, buildPptx } from "@hirokisakabe/pom";
451
+ *
452
+ * const json = JSON.parse(llmResponse);
453
+ * const result = inputPomNodeSchema.safeParse(json);
454
+ *
455
+ * if (result.success) {
456
+ * const pptx = await buildPptx([result.data], { w: 1280, h: 720 });
457
+ * await pptx.writeFile({ fileName: "output.pptx" });
458
+ * } else {
459
+ * console.error("Validation failed:", result.error);
460
+ * }
461
+ * ```
462
+ */
463
+ export declare const inputPomNodeSchema: z.ZodType<InputPOMNode>;
464
+ export declare const inputMasterSlideOptionsSchema: z.ZodObject<{
465
+ header: z.ZodOptional<z.ZodLazy<z.ZodType<InputPOMNode, unknown, z.core.$ZodTypeInternals<InputPOMNode, unknown>>>>;
466
+ footer: z.ZodOptional<z.ZodLazy<z.ZodType<InputPOMNode, unknown, z.core.$ZodTypeInternals<InputPOMNode, unknown>>>>;
467
+ pageNumber: z.ZodOptional<z.ZodObject<{
468
+ position: z.ZodEnum<{
469
+ right: "right";
470
+ left: "left";
471
+ center: "center";
472
+ }>;
473
+ }, z.core.$strip>>;
474
+ date: z.ZodOptional<z.ZodObject<{
475
+ format: z.ZodEnum<{
476
+ "YYYY/MM/DD": "YYYY/MM/DD";
477
+ locale: "locale";
478
+ }>;
479
+ }, z.core.$strip>>;
480
+ }, z.core.$strip>;
481
+ export type InputMasterSlideOptions = z.infer<typeof inputMasterSlideOptionsSchema>;
482
+ export {};
483
+ //# sourceMappingURL=inputSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputSchema.d.ts","sourceRoot":"","sources":["../src/inputSchema.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Input schemas for LLM/external input validation
3
+ *
4
+ * These schemas do not include internal properties like `yogaNode`.
5
+ * Use these when validating JSON from OpenAI, Claude, or other LLMs.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { inputPomNodeSchema, InputPOMNode } from "@hirokisakabe/pom";
10
+ *
11
+ * // Validate and parse JSON from LLM
12
+ * const json = JSON.parse(llmResponse);
13
+ * const result = inputPomNodeSchema.safeParse(json);
14
+ * if (result.success) {
15
+ * const pptx = await buildPptx([result.data], { w: 1280, h: 720 });
16
+ * }
17
+ * ```
18
+ */
19
+ import { z } from "zod";
20
+ import { lengthSchema, paddingSchema, borderStyleSchema, fillStyleSchema, shadowStyleSchema, alignItemsSchema, justifyContentSchema, shapeTypeSchema, tableColumnSchema, tableRowSchema, pageNumberPositionSchema, dateFormatSchema, } from "./types";
21
+ // ===== Base Node Schema =====
22
+ export const inputBaseNodeSchema = z.object({
23
+ w: lengthSchema.optional(),
24
+ h: lengthSchema.optional(),
25
+ minW: z.number().optional(),
26
+ maxW: z.number().optional(),
27
+ minH: z.number().optional(),
28
+ maxH: z.number().optional(),
29
+ padding: paddingSchema.optional(),
30
+ backgroundColor: z.string().optional(),
31
+ border: borderStyleSchema.optional(),
32
+ });
33
+ // ===== Node Schemas =====
34
+ export const inputTextNodeSchema = inputBaseNodeSchema.extend({
35
+ type: z.literal("text"),
36
+ text: z.string(),
37
+ fontPx: z.number().optional(),
38
+ color: z.string().optional(),
39
+ alignText: z.enum(["left", "center", "right"]).optional(),
40
+ bold: z.boolean().optional(),
41
+ fontFamily: z.string().optional(),
42
+ lineSpacingMultiple: z.number().optional(),
43
+ });
44
+ export const inputImageNodeSchema = inputBaseNodeSchema.extend({
45
+ type: z.literal("image"),
46
+ src: z.string(),
47
+ });
48
+ export const inputTableNodeSchema = inputBaseNodeSchema.extend({
49
+ type: z.literal("table"),
50
+ columns: z.array(tableColumnSchema),
51
+ rows: z.array(tableRowSchema),
52
+ defaultRowHeight: z.number().optional(),
53
+ });
54
+ export const inputShapeNodeSchema = inputBaseNodeSchema.extend({
55
+ type: z.literal("shape"),
56
+ shapeType: shapeTypeSchema,
57
+ text: z.string().optional(),
58
+ fill: fillStyleSchema.optional(),
59
+ line: borderStyleSchema.optional(),
60
+ shadow: shadowStyleSchema.optional(),
61
+ fontPx: z.number().optional(),
62
+ fontColor: z.string().optional(),
63
+ alignText: z.enum(["left", "center", "right"]).optional(),
64
+ });
65
+ // ===== Recursive Node Schemas =====
66
+ const inputBoxNodeSchemaBase = inputBaseNodeSchema.extend({
67
+ type: z.literal("box"),
68
+ children: z.lazy(() => inputPomNodeSchema),
69
+ });
70
+ const inputVStackNodeSchemaBase = inputBaseNodeSchema.extend({
71
+ type: z.literal("vstack"),
72
+ children: z.array(z.lazy(() => inputPomNodeSchema)),
73
+ gap: z.number().optional(),
74
+ alignItems: alignItemsSchema.optional(),
75
+ justifyContent: justifyContentSchema.optional(),
76
+ });
77
+ const inputHStackNodeSchemaBase = inputBaseNodeSchema.extend({
78
+ type: z.literal("hstack"),
79
+ children: z.array(z.lazy(() => inputPomNodeSchema)),
80
+ gap: z.number().optional(),
81
+ alignItems: alignItemsSchema.optional(),
82
+ justifyContent: justifyContentSchema.optional(),
83
+ });
84
+ export const inputBoxNodeSchema = inputBoxNodeSchemaBase;
85
+ export const inputVStackNodeSchema = inputVStackNodeSchemaBase;
86
+ export const inputHStackNodeSchema = inputHStackNodeSchemaBase;
87
+ /**
88
+ * Input schema for POM nodes (for LLM/external input validation)
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * import { inputPomNodeSchema, buildPptx } from "@hirokisakabe/pom";
93
+ *
94
+ * const json = JSON.parse(llmResponse);
95
+ * const result = inputPomNodeSchema.safeParse(json);
96
+ *
97
+ * if (result.success) {
98
+ * const pptx = await buildPptx([result.data], { w: 1280, h: 720 });
99
+ * await pptx.writeFile({ fileName: "output.pptx" });
100
+ * } else {
101
+ * console.error("Validation failed:", result.error);
102
+ * }
103
+ * ```
104
+ */
105
+ export const inputPomNodeSchema = z.lazy(() => z.discriminatedUnion("type", [
106
+ inputTextNodeSchema,
107
+ inputImageNodeSchema,
108
+ inputTableNodeSchema,
109
+ inputBoxNodeSchemaBase,
110
+ inputVStackNodeSchemaBase,
111
+ inputHStackNodeSchemaBase,
112
+ inputShapeNodeSchema,
113
+ ]));
114
+ // ===== Master Slide Options Schema =====
115
+ export const inputMasterSlideOptionsSchema = z.object({
116
+ header: z.lazy(() => inputPomNodeSchema).optional(),
117
+ footer: z.lazy(() => inputPomNodeSchema).optional(),
118
+ pageNumber: z
119
+ .object({
120
+ position: pageNumberPositionSchema,
121
+ })
122
+ .optional(),
123
+ date: z
124
+ .object({
125
+ format: dateFormatSchema,
126
+ })
127
+ .optional(),
128
+ });
@@ -1,12 +1,11 @@
1
1
  import type PptxGenJSType from "pptxgenjs";
2
2
  import type { PositionedNode } from "../types";
3
- export declare const PX_PER_IN = 96;
4
- export declare const pxToIn: (px: number) => number;
5
- export declare const pxToPt: (px: number) => number;
6
3
  type SlidePx = {
7
4
  w: number;
8
5
  h: number;
9
6
  };
7
+ export { createTextOptions } from "./textOptions";
8
+ export { PX_PER_IN, pxToIn, pxToPt } from "./units";
10
9
  /**
11
10
  * PositionedNode ツリーを PptxGenJS スライドに変換する
12
11
  * @param pages PositionedNode ツリーの配列(各要素が1ページ)
@@ -14,5 +13,4 @@ type SlidePx = {
14
13
  * @returns PptxGenJS インスタンス
15
14
  */
16
15
  export declare function renderPptx(pages: PositionedNode[], slidePx: SlidePx): PptxGenJSType;
17
- export {};
18
16
  //# sourceMappingURL=renderPptx.d.ts.map
@@ -1 +1 @@
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
+ {"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;AAK/C,KAAK,OAAO,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE,OAAO,EAAE,OAAO,iBAsLnE"}
@@ -2,9 +2,10 @@ import { createRequire } from "module";
2
2
  const require = createRequire(import.meta.url);
3
3
  const PptxGenJS = require("pptxgenjs");
4
4
  import { resolveRowHeights } from "../table/utils";
5
- export const PX_PER_IN = 96;
6
- export const pxToIn = (px) => px / PX_PER_IN;
7
- export const pxToPt = (px) => (px * 72) / PX_PER_IN;
5
+ import { createTextOptions } from "./textOptions";
6
+ import { pxToIn, pxToPt } from "./units";
7
+ export { createTextOptions } from "./textOptions";
8
+ export { PX_PER_IN, pxToIn, pxToPt } from "./units";
8
9
  /**
9
10
  * PositionedNode ツリーを PptxGenJS スライドに変換する
10
11
  * @param pages PositionedNode ツリーの配列(各要素が1ページ)
@@ -55,21 +56,8 @@ export function renderPptx(pages, slidePx) {
55
56
  renderBackgroundAndBorder(node);
56
57
  switch (node.type) {
57
58
  case "text": {
58
- const fontSizePx = node.fontPx ?? 24;
59
- const fontFamily = "Noto Sans JP";
60
- const opts = {
61
- x: pxToIn(node.x),
62
- y: pxToIn(node.y),
63
- w: pxToIn(node.w),
64
- h: pxToIn(node.h),
65
- fontSize: pxToPt(fontSizePx),
66
- fontFace: fontFamily,
67
- align: "left",
68
- valign: "top",
69
- margin: 0,
70
- lineSpacingMultiple: 1.3,
71
- };
72
- slide.addText(node.text ?? "", opts);
59
+ const textOptions = createTextOptions(node);
60
+ slide.addText(node.text ?? "", textOptions);
73
61
  break;
74
62
  }
75
63
  case "image": {