@hirokisakabe/pom 5.4.0 → 5.5.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.
Files changed (81) hide show
  1. package/README.md +6 -5
  2. package/dist/autoFit/autoFit.d.ts +2 -1
  3. package/dist/autoFit/autoFit.d.ts.map +1 -1
  4. package/dist/autoFit/autoFit.js +33 -17
  5. package/dist/buildContext.d.ts +2 -0
  6. package/dist/buildContext.d.ts.map +1 -1
  7. package/dist/buildContext.js +2 -0
  8. package/dist/buildPptx.d.ts +7 -1
  9. package/dist/buildPptx.d.ts.map +1 -1
  10. package/dist/buildPptx.js +14 -5
  11. package/dist/calcYogaLayout/calcYogaLayout.d.ts +4 -2
  12. package/dist/calcYogaLayout/calcYogaLayout.d.ts.map +1 -1
  13. package/dist/calcYogaLayout/calcYogaLayout.js +29 -15
  14. package/dist/calcYogaLayout/types.d.ts +16 -0
  15. package/dist/calcYogaLayout/types.d.ts.map +1 -0
  16. package/dist/calcYogaLayout/types.js +14 -0
  17. package/dist/diagnostics.d.ts +14 -0
  18. package/dist/diagnostics.d.ts.map +1 -0
  19. package/dist/diagnostics.js +17 -0
  20. package/dist/index.d.ts +3 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +1 -0
  23. package/dist/parseXml/parseXml.d.ts +1 -1
  24. package/dist/parseXml/parseXml.d.ts.map +1 -1
  25. package/dist/parseXml/parseXml.js +16 -16
  26. package/dist/registry/definitions/icon.d.ts.map +1 -1
  27. package/dist/registry/definitions/icon.js +26 -14
  28. package/dist/registry/definitions/image.d.ts.map +1 -1
  29. package/dist/registry/definitions/image.js +2 -3
  30. package/dist/registry/definitions/layer.d.ts.map +1 -1
  31. package/dist/registry/definitions/layer.js +9 -6
  32. package/dist/registry/definitions/line.d.ts.map +1 -1
  33. package/dist/registry/definitions/line.js +1 -2
  34. package/dist/registry/types.d.ts +2 -1
  35. package/dist/registry/types.d.ts.map +1 -1
  36. package/dist/renderPptx/nodes/chart.d.ts.map +1 -1
  37. package/dist/renderPptx/nodes/chart.js +6 -4
  38. package/dist/renderPptx/nodes/flow.d.ts.map +1 -1
  39. package/dist/renderPptx/nodes/flow.js +14 -4
  40. package/dist/renderPptx/nodes/image.d.ts.map +1 -1
  41. package/dist/renderPptx/nodes/image.js +8 -6
  42. package/dist/renderPptx/nodes/list.d.ts.map +1 -1
  43. package/dist/renderPptx/nodes/list.js +19 -16
  44. package/dist/renderPptx/nodes/matrix.d.ts.map +1 -1
  45. package/dist/renderPptx/nodes/matrix.js +11 -9
  46. package/dist/renderPptx/nodes/processArrow.d.ts.map +1 -1
  47. package/dist/renderPptx/nodes/processArrow.js +14 -4
  48. package/dist/renderPptx/nodes/pyramid.d.ts.map +1 -1
  49. package/dist/renderPptx/nodes/pyramid.js +6 -4
  50. package/dist/renderPptx/nodes/shape.d.ts.map +1 -1
  51. package/dist/renderPptx/nodes/shape.js +6 -4
  52. package/dist/renderPptx/nodes/table.d.ts.map +1 -1
  53. package/dist/renderPptx/nodes/table.js +7 -5
  54. package/dist/renderPptx/nodes/timeline.d.ts.map +1 -1
  55. package/dist/renderPptx/nodes/timeline.js +14 -4
  56. package/dist/renderPptx/nodes/tree.d.ts.map +1 -1
  57. package/dist/renderPptx/nodes/tree.js +6 -4
  58. package/dist/renderPptx/textOptions.d.ts.map +1 -1
  59. package/dist/renderPptx/textOptions.js +6 -4
  60. package/dist/renderPptx/utils/contentArea.d.ts +26 -0
  61. package/dist/renderPptx/utils/contentArea.d.ts.map +1 -0
  62. package/dist/renderPptx/utils/contentArea.js +26 -0
  63. package/dist/renderPptx/utils/scaleToFit.d.ts +3 -2
  64. package/dist/renderPptx/utils/scaleToFit.d.ts.map +1 -1
  65. package/dist/renderPptx/utils/scaleToFit.js +3 -3
  66. package/dist/shared/freeYogaTree.d.ts +3 -3
  67. package/dist/shared/freeYogaTree.d.ts.map +1 -1
  68. package/dist/shared/freeYogaTree.js +16 -21
  69. package/dist/shared/measureImage.d.ts +3 -2
  70. package/dist/shared/measureImage.d.ts.map +1 -1
  71. package/dist/shared/measureImage.js +5 -5
  72. package/dist/toPositioned/toPositioned.d.ts +3 -6
  73. package/dist/toPositioned/toPositioned.d.ts.map +1 -1
  74. package/dist/toPositioned/toPositioned.js +11 -19
  75. package/dist/types.d.ts +12 -445
  76. package/dist/types.d.ts.map +1 -1
  77. package/dist/types.js +43 -50
  78. package/package.json +5 -2
  79. package/dist/parseXml/inputSchema.d.ts +0 -1622
  80. package/dist/parseXml/inputSchema.d.ts.map +0 -1
  81. package/dist/parseXml/inputSchema.js +0 -257
package/dist/types.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { z } from "zod";
2
2
  import { ICON_DATA } from "./icons/iconData.js";
3
3
  // ===== Basic Types =====
4
- export const lengthSchema = z.union([
4
+ const lengthSchema = z.union([
5
5
  z.number(),
6
6
  z.literal("max"),
7
7
  z.string().regex(/^\d+%$/),
8
8
  ]);
9
- export const paddingSchema = z.union([
9
+ const paddingSchema = z.union([
10
10
  z.number(),
11
11
  z.object({
12
12
  top: z.number().optional(),
@@ -15,7 +15,7 @@ export const paddingSchema = z.union([
15
15
  left: z.number().optional(),
16
16
  }),
17
17
  ]);
18
- export const borderDashSchema = z.enum([
18
+ const borderDashSchema = z.enum([
19
19
  "solid",
20
20
  "dash",
21
21
  "dashDot",
@@ -25,12 +25,12 @@ export const borderDashSchema = z.enum([
25
25
  "sysDash",
26
26
  "sysDot",
27
27
  ]);
28
- export const borderStyleSchema = z.object({
28
+ const borderStyleSchema = z.object({
29
29
  color: z.string().optional(),
30
30
  width: z.number().optional(),
31
31
  dashType: borderDashSchema.optional(),
32
32
  });
33
- export const fillStyleSchema = z.object({
33
+ const fillStyleSchema = z.object({
34
34
  color: z.string().optional(),
35
35
  transparency: z.number().optional(),
36
36
  });
@@ -42,7 +42,7 @@ export const shadowStyleSchema = z.object({
42
42
  offset: z.number().optional(),
43
43
  color: z.string().optional(),
44
44
  });
45
- export const bulletNumberTypeSchema = z.enum([
45
+ const bulletNumberTypeSchema = z.enum([
46
46
  "alphaLcParenBoth",
47
47
  "alphaLcParenR",
48
48
  "alphaLcPeriod",
@@ -84,17 +84,11 @@ export const underlineSchema = z.union([
84
84
  color: z.string().optional(),
85
85
  }),
86
86
  ]);
87
- export const alignItemsSchema = z.enum(["start", "center", "end", "stretch"]);
88
- export const alignSelfSchema = z.enum([
89
- "auto",
90
- "start",
91
- "center",
92
- "end",
93
- "stretch",
94
- ]);
95
- export const positionTypeSchema = z.enum(["relative", "absolute"]);
96
- export const flexWrapSchema = z.enum(["nowrap", "wrap", "wrapReverse"]);
97
- export const justifyContentSchema = z.enum([
87
+ const alignItemsSchema = z.enum(["start", "center", "end", "stretch"]);
88
+ const alignSelfSchema = z.enum(["auto", "start", "center", "end", "stretch"]);
89
+ const positionTypeSchema = z.enum(["relative", "absolute"]);
90
+ const flexWrapSchema = z.enum(["nowrap", "wrap", "wrapReverse"]);
91
+ const justifyContentSchema = z.enum([
98
92
  "start",
99
93
  "center",
100
94
  "end",
@@ -102,7 +96,7 @@ export const justifyContentSchema = z.enum([
102
96
  "spaceAround",
103
97
  "spaceEvenly",
104
98
  ]);
105
- export const shapeTypeSchema = z.enum([
99
+ const shapeTypeSchema = z.enum([
106
100
  "accentBorderCallout1",
107
101
  "accentBorderCallout2",
108
102
  "accentBorderCallout3",
@@ -284,13 +278,12 @@ export const shapeTypeSchema = z.enum([
284
278
  ]);
285
279
  // ===== Background Image =====
286
280
  const backgroundImageSizingSchema = z.enum(["cover", "contain"]);
287
- export const backgroundImageSchema = z.object({
281
+ const backgroundImageSchema = z.object({
288
282
  src: z.string(),
289
283
  sizing: backgroundImageSizingSchema.optional(),
290
284
  });
291
285
  // ===== Base Node =====
292
286
  const basePOMNodeSchema = z.object({
293
- yogaNode: z.custom().optional(),
294
287
  w: lengthSchema.optional(),
295
288
  h: lengthSchema.optional(),
296
289
  minW: z.number().optional(),
@@ -313,7 +306,7 @@ const basePOMNodeSchema = z.object({
313
306
  alignSelf: alignSelfSchema.optional(),
314
307
  });
315
308
  // ===== Non-recursive Node Types =====
316
- const textNodeSchema = basePOMNodeSchema.extend({
309
+ export const textNodeSchema = basePOMNodeSchema.extend({
317
310
  type: z.literal("text"),
318
311
  text: z.string(),
319
312
  fontSize: z.number().optional(),
@@ -338,7 +331,7 @@ export const liNodeSchema = z.object({
338
331
  fontSize: z.number().optional(),
339
332
  fontFamily: z.string().optional(),
340
333
  });
341
- const ulNodeSchema = basePOMNodeSchema.extend({
334
+ export const ulNodeSchema = basePOMNodeSchema.extend({
342
335
  type: z.literal("ul"),
343
336
  items: z.array(liNodeSchema),
344
337
  fontSize: z.number().optional(),
@@ -352,7 +345,7 @@ const ulNodeSchema = basePOMNodeSchema.extend({
352
345
  fontFamily: z.string().optional(),
353
346
  lineHeight: z.number().optional(),
354
347
  });
355
- const olNodeSchema = basePOMNodeSchema.extend({
348
+ export const olNodeSchema = basePOMNodeSchema.extend({
356
349
  type: z.literal("ol"),
357
350
  items: z.array(liNodeSchema),
358
351
  fontSize: z.number().optional(),
@@ -375,18 +368,18 @@ const imageSizingSchema = z.object({
375
368
  x: z.number().optional(),
376
369
  y: z.number().optional(),
377
370
  });
378
- const imageNodeSchema = basePOMNodeSchema.extend({
371
+ export const imageNodeSchema = basePOMNodeSchema.extend({
379
372
  type: z.literal("image"),
380
373
  src: z.string(),
381
374
  sizing: imageSizingSchema.optional(),
382
375
  shadow: shadowStyleSchema.optional(),
383
376
  });
384
- export const iconNameSchema = z.enum(Object.keys(ICON_DATA));
385
- export const iconColorSchema = z
377
+ const iconNameSchema = z.enum(Object.keys(ICON_DATA));
378
+ const iconColorSchema = z
386
379
  .string()
387
380
  .regex(/^#?[0-9a-fA-F]{3,8}$/)
388
381
  .optional();
389
- export const iconVariantSchema = z
382
+ const iconVariantSchema = z
390
383
  .enum([
391
384
  "circle-filled",
392
385
  "circle-outlined",
@@ -394,7 +387,7 @@ export const iconVariantSchema = z
394
387
  "square-outlined",
395
388
  ])
396
389
  .optional();
397
- const iconNodeSchema = basePOMNodeSchema.extend({
390
+ export const iconNodeSchema = basePOMNodeSchema.extend({
398
391
  type: z.literal("icon"),
399
392
  name: iconNameSchema,
400
393
  size: z.number().positive().max(1024).optional(),
@@ -416,11 +409,11 @@ const tableCellSchema = z.object({
416
409
  colspan: z.number().int().min(1).optional(),
417
410
  rowspan: z.number().int().min(1).optional(),
418
411
  });
419
- export const tableRowSchema = z.object({
412
+ const tableRowSchema = z.object({
420
413
  cells: z.array(tableCellSchema),
421
414
  height: z.number().optional(),
422
415
  });
423
- export const tableColumnSchema = z.object({
416
+ const tableColumnSchema = z.object({
424
417
  width: z.number().optional(),
425
418
  });
426
419
  export const tableNodeSchema = basePOMNodeSchema.extend({
@@ -429,7 +422,7 @@ export const tableNodeSchema = basePOMNodeSchema.extend({
429
422
  rows: z.array(tableRowSchema),
430
423
  defaultRowHeight: z.number().optional(),
431
424
  });
432
- const shapeNodeSchema = basePOMNodeSchema.extend({
425
+ export const shapeNodeSchema = basePOMNodeSchema.extend({
433
426
  type: z.literal("shape"),
434
427
  shapeType: shapeTypeSchema,
435
428
  text: z.string().optional(),
@@ -447,7 +440,7 @@ const shapeNodeSchema = basePOMNodeSchema.extend({
447
440
  fontFamily: z.string().optional(),
448
441
  lineHeight: z.number().optional(),
449
442
  });
450
- export const chartTypeSchema = z.enum([
443
+ const chartTypeSchema = z.enum([
451
444
  "bar",
452
445
  "line",
453
446
  "pie",
@@ -455,13 +448,13 @@ export const chartTypeSchema = z.enum([
455
448
  "doughnut",
456
449
  "radar",
457
450
  ]);
458
- export const radarStyleSchema = z.enum(["standard", "marker", "filled"]);
459
- export const chartDataSchema = z.object({
451
+ const radarStyleSchema = z.enum(["standard", "marker", "filled"]);
452
+ const chartDataSchema = z.object({
460
453
  name: z.string().optional(),
461
454
  labels: z.array(z.string()),
462
455
  values: z.array(z.number()),
463
456
  });
464
- const chartNodeSchema = basePOMNodeSchema.extend({
457
+ export const chartNodeSchema = basePOMNodeSchema.extend({
465
458
  type: z.literal("chart"),
466
459
  chartType: chartTypeSchema,
467
460
  data: z.array(chartDataSchema),
@@ -473,8 +466,8 @@ const chartNodeSchema = basePOMNodeSchema.extend({
473
466
  radarStyle: radarStyleSchema.optional(),
474
467
  });
475
468
  // ===== Timeline Node =====
476
- export const timelineDirectionSchema = z.enum(["horizontal", "vertical"]);
477
- export const timelineItemSchema = z.object({
469
+ const timelineDirectionSchema = z.enum(["horizontal", "vertical"]);
470
+ const timelineItemSchema = z.object({
478
471
  date: z.string(),
479
472
  title: z.string(),
480
473
  description: z.string().optional(),
@@ -486,17 +479,17 @@ export const timelineNodeSchema = basePOMNodeSchema.extend({
486
479
  items: z.array(timelineItemSchema),
487
480
  });
488
481
  // ===== Matrix Node =====
489
- export const matrixAxisSchema = z.object({
482
+ const matrixAxisSchema = z.object({
490
483
  x: z.string(),
491
484
  y: z.string(),
492
485
  });
493
- export const matrixQuadrantsSchema = z.object({
486
+ const matrixQuadrantsSchema = z.object({
494
487
  topLeft: z.string(),
495
488
  topRight: z.string(),
496
489
  bottomLeft: z.string(),
497
490
  bottomRight: z.string(),
498
491
  });
499
- export const matrixItemSchema = z.object({
492
+ const matrixItemSchema = z.object({
500
493
  label: z.string(),
501
494
  x: z.number().min(0).max(1),
502
495
  y: z.number().min(0).max(1),
@@ -509,7 +502,7 @@ export const matrixNodeSchema = basePOMNodeSchema.extend({
509
502
  items: z.array(matrixItemSchema),
510
503
  });
511
504
  // ===== Tree Node =====
512
- export const treeLayoutSchema = z.enum(["vertical", "horizontal"]);
505
+ const treeLayoutSchema = z.enum(["vertical", "horizontal"]);
513
506
  export const treeNodeShapeSchema = z.enum(["rect", "roundRect", "ellipse"]);
514
507
  export const treeConnectorStyleSchema = z.object({
515
508
  color: z.string().optional(),
@@ -532,8 +525,8 @@ export const treeNodeSchema = basePOMNodeSchema.extend({
532
525
  siblingGap: z.number().optional(),
533
526
  });
534
527
  // ===== ProcessArrow Node =====
535
- export const processArrowDirectionSchema = z.enum(["horizontal", "vertical"]);
536
- export const processArrowStepSchema = z.object({
528
+ const processArrowDirectionSchema = z.enum(["horizontal", "vertical"]);
529
+ const processArrowStepSchema = z.object({
537
530
  label: z.string(),
538
531
  color: z.string().optional(),
539
532
  textColor: z.string().optional(),
@@ -553,8 +546,8 @@ export const processArrowNodeSchema = basePOMNodeSchema.extend({
553
546
  highlight: z.string().optional(),
554
547
  });
555
548
  // ===== Pyramid Node =====
556
- export const pyramidDirectionSchema = z.enum(["up", "down"]);
557
- export const pyramidLevelSchema = z.object({
549
+ const pyramidDirectionSchema = z.enum(["up", "down"]);
550
+ const pyramidLevelSchema = z.object({
558
551
  label: z.string(),
559
552
  color: z.string().optional(),
560
553
  textColor: z.string().optional(),
@@ -567,7 +560,7 @@ export const pyramidNodeSchema = basePOMNodeSchema.extend({
567
560
  bold: z.boolean().optional(),
568
561
  });
569
562
  // ===== Flow Node =====
570
- export const flowDirectionSchema = z.enum(["horizontal", "vertical"]);
563
+ const flowDirectionSchema = z.enum(["horizontal", "vertical"]);
571
564
  const flowNodeShapeSchema = z.enum([
572
565
  "flowChartTerminator",
573
566
  "flowChartProcess",
@@ -582,7 +575,7 @@ const flowNodeShapeSchema = z.enum([
582
575
  "flowChartDelay",
583
576
  "flowChartMagneticDisk",
584
577
  ]);
585
- export const flowNodeItemSchema = z.object({
578
+ const flowNodeItemSchema = z.object({
586
579
  id: z.string(),
587
580
  shape: flowNodeShapeSchema,
588
581
  text: z.string(),
@@ -591,13 +584,13 @@ export const flowNodeItemSchema = z.object({
591
584
  width: z.number().optional(),
592
585
  height: z.number().optional(),
593
586
  });
594
- export const flowConnectionSchema = z.object({
587
+ const flowConnectionSchema = z.object({
595
588
  from: z.string(),
596
589
  to: z.string(),
597
590
  label: z.string().optional(),
598
591
  color: z.string().optional(),
599
592
  });
600
- export const flowConnectorStyleSchema = z.object({
593
+ const flowConnectorStyleSchema = z.object({
601
594
  color: z.string().optional(),
602
595
  width: z.number().optional(),
603
596
  arrowType: z
@@ -627,7 +620,7 @@ const lineArrowOptionsSchema = z.object({
627
620
  type: lineArrowTypeSchema.optional(),
628
621
  });
629
622
  export const lineArrowSchema = z.union([z.boolean(), lineArrowOptionsSchema]);
630
- const lineNodeSchema = basePOMNodeSchema.extend({
623
+ export const lineNodeSchema = basePOMNodeSchema.extend({
631
624
  type: z.literal("line"),
632
625
  x1: z.number(),
633
626
  y1: z.number(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hirokisakabe/pom",
3
- "version": "5.4.0",
3
+ "version": "5.5.0",
4
4
  "description": "AI-friendly PowerPoint generation with a Flexbox layout engine.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -63,7 +63,8 @@
63
63
  "docs:images:docker:update": "docker compose build docs-images && docker compose run --rm docs-images",
64
64
  "docs:images:vrt": "tsx scripts/docs-images/generateNodeImages.ts --check",
65
65
  "docs:images:vrt:docker": "docker compose build docs-images-vrt && docker compose run --rm docs-images-vrt",
66
- "release": "changeset publish"
66
+ "release": "changeset publish",
67
+ "size": "size-limit"
67
68
  },
68
69
  "publishConfig": {
69
70
  "access": "public"
@@ -72,6 +73,7 @@
72
73
  "@changesets/changelog-github": "^0.5.2",
73
74
  "@changesets/cli": "^2.29.8",
74
75
  "@eslint/js": "^9.39.1",
76
+ "@size-limit/file": "^12.0.1",
75
77
  "@types/opentype.js": "^1.3.8",
76
78
  "@types/pngjs": "6.0.5",
77
79
  "@vitest/coverage-v8": "^4.1.0",
@@ -84,6 +86,7 @@
84
86
  "pixelmatch": "7.1.0",
85
87
  "pngjs": "7.0.0",
86
88
  "prettier": "3.6.2",
89
+ "size-limit": "^12.0.1",
87
90
  "tsx": "4.21.0",
88
91
  "typescript": "5.9.3",
89
92
  "typescript-eslint": "^8.47.0",