@hirokisakabe/pom 0.2.0 → 1.0.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 +3 -2
- package/dist/buildPptx.d.ts +2 -2
- package/dist/buildPptx.d.ts.map +1 -1
- package/dist/buildPptx.js +4 -66
- package/dist/calcYogaLayout/calcYogaLayout.d.ts.map +1 -1
- package/dist/calcYogaLayout/calcYogaLayout.js +49 -84
- package/dist/calcYogaLayout/fontLoader.d.ts +20 -0
- package/dist/calcYogaLayout/fontLoader.d.ts.map +1 -0
- package/dist/calcYogaLayout/fontLoader.js +59 -0
- package/dist/calcYogaLayout/fonts/notoSansJPBold.d.ts +7 -0
- package/dist/calcYogaLayout/fonts/notoSansJPBold.d.ts.map +1 -0
- package/dist/calcYogaLayout/fonts/notoSansJPBold.js +6 -0
- package/dist/calcYogaLayout/fonts/notoSansJPRegular.d.ts +7 -0
- package/dist/calcYogaLayout/fonts/notoSansJPRegular.d.ts.map +1 -0
- package/dist/calcYogaLayout/fonts/notoSansJPRegular.js +6 -0
- package/dist/calcYogaLayout/measureText.d.ts +1 -1
- package/dist/calcYogaLayout/measureText.d.ts.map +1 -1
- package/dist/calcYogaLayout/measureText.js +65 -114
- package/dist/inputSchema.d.ts +269 -10
- package/dist/inputSchema.d.ts.map +1 -1
- package/dist/inputSchema.js +94 -15
- package/dist/renderPptx/nodes/box.d.ts +1 -0
- package/dist/renderPptx/nodes/box.d.ts.map +1 -0
- package/dist/renderPptx/nodes/box.js +2 -0
- package/dist/renderPptx/nodes/chart.d.ts +8 -0
- package/dist/renderPptx/nodes/chart.d.ts.map +1 -0
- package/dist/renderPptx/nodes/chart.js +23 -0
- package/dist/renderPptx/nodes/flow.d.ts +8 -0
- package/dist/renderPptx/nodes/flow.d.ts.map +1 -0
- package/dist/renderPptx/nodes/flow.js +208 -0
- package/dist/renderPptx/nodes/image.d.ts +8 -0
- package/dist/renderPptx/nodes/image.d.ts.map +1 -0
- package/dist/renderPptx/nodes/image.js +17 -0
- package/dist/renderPptx/nodes/index.d.ts +11 -0
- package/dist/renderPptx/nodes/index.d.ts.map +1 -0
- package/dist/renderPptx/nodes/index.js +10 -0
- package/dist/renderPptx/nodes/matrix.d.ts +8 -0
- package/dist/renderPptx/nodes/matrix.d.ts.map +1 -0
- package/dist/renderPptx/nodes/matrix.js +150 -0
- package/dist/renderPptx/nodes/processArrow.d.ts +8 -0
- package/dist/renderPptx/nodes/processArrow.d.ts.map +1 -0
- package/dist/renderPptx/nodes/processArrow.js +75 -0
- package/dist/renderPptx/nodes/shape.d.ts +8 -0
- package/dist/renderPptx/nodes/shape.d.ts.map +1 -0
- package/dist/renderPptx/nodes/shape.js +49 -0
- package/dist/renderPptx/nodes/table.d.ts +8 -0
- package/dist/renderPptx/nodes/table.d.ts.map +1 -0
- package/dist/renderPptx/nodes/table.js +29 -0
- package/dist/renderPptx/nodes/text.d.ts +8 -0
- package/dist/renderPptx/nodes/text.d.ts.map +1 -0
- package/dist/renderPptx/nodes/text.js +5 -0
- package/dist/renderPptx/nodes/timeline.d.ts +8 -0
- package/dist/renderPptx/nodes/timeline.d.ts.map +1 -0
- package/dist/renderPptx/nodes/timeline.js +157 -0
- package/dist/renderPptx/nodes/tree.d.ts +8 -0
- package/dist/renderPptx/nodes/tree.d.ts.map +1 -0
- package/dist/renderPptx/nodes/tree.js +223 -0
- package/dist/renderPptx/renderPptx.d.ts +3 -2
- package/dist/renderPptx/renderPptx.d.ts.map +1 -1
- package/dist/renderPptx/renderPptx.js +204 -945
- package/dist/renderPptx/types.d.ts +10 -0
- package/dist/renderPptx/types.d.ts.map +1 -0
- package/dist/renderPptx/types.js +1 -0
- package/dist/renderPptx/utils/backgroundBorder.d.ts +8 -0
- package/dist/renderPptx/utils/backgroundBorder.d.ts.map +1 -0
- package/dist/renderPptx/utils/backgroundBorder.js +44 -0
- package/dist/renderPptx/utils/index.d.ts +6 -0
- package/dist/renderPptx/utils/index.d.ts.map +1 -0
- package/dist/renderPptx/utils/index.js +3 -0
- package/dist/renderPptx/utils/shapeDrawing.d.ts +27 -0
- package/dist/renderPptx/utils/shapeDrawing.d.ts.map +1 -0
- package/dist/renderPptx/utils/shapeDrawing.js +36 -0
- package/dist/renderPptx/utils/textDrawing.d.ts +20 -0
- package/dist/renderPptx/utils/textDrawing.d.ts.map +1 -0
- package/dist/renderPptx/utils/textDrawing.js +20 -0
- package/dist/schema.d.ts +2 -2
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +2 -2
- package/dist/types.d.ts +258 -16
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +74 -15
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measureText.d.ts","sourceRoot":"","sources":["../../src/calcYogaLayout/measureText.ts"],"names":[],"mappings":"AAEA,KAAK,cAAc,GAAG;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,
|
|
1
|
+
{"version":3,"file":"measureText.d.ts","sourceRoot":"","sources":["../../src/calcYogaLayout/measureText.ts"],"names":[],"mappings":"AAEA,KAAK,cAAc,GAAG;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;AAoHnE;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAEtE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,mBAAmB,CAE5D;AAcD;;GAEG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,cAAc,GACnB;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAmBA"}
|
|
@@ -1,32 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const canvas = createCanvas(1, 1);
|
|
3
|
-
const ctx = canvas.getContext("2d");
|
|
4
|
-
// フォント利用可否のキャッシュ
|
|
5
|
-
const fontAvailabilityCache = new Map();
|
|
6
|
-
/**
|
|
7
|
-
* 指定されたフォントが利用可能かどうかをチェックする
|
|
8
|
-
* 既知のフォントと未知のフォントで同じ幅になるかチェックし、
|
|
9
|
-
* 同じなら「フォントが利用できない」と判定する
|
|
10
|
-
*/
|
|
11
|
-
function isFontAvailable(fontFamily, fontSizePx) {
|
|
12
|
-
const cacheKey = `${fontFamily}:${fontSizePx}`;
|
|
13
|
-
const cached = fontAvailabilityCache.get(cacheKey);
|
|
14
|
-
if (cached !== undefined) {
|
|
15
|
-
return cached;
|
|
16
|
-
}
|
|
17
|
-
// テスト文字列(日本語と英語を含む)
|
|
18
|
-
const testString = "あいうABC123";
|
|
19
|
-
// 存在しないフォント名でテスト
|
|
20
|
-
const nonExistentFont = "NonExistentFont_12345_XYZ";
|
|
21
|
-
ctx.font = `${fontSizePx}px "${fontFamily}"`;
|
|
22
|
-
const targetWidth = ctx.measureText(testString).width;
|
|
23
|
-
ctx.font = `${fontSizePx}px "${nonExistentFont}"`;
|
|
24
|
-
const fallbackWidth = ctx.measureText(testString).width;
|
|
25
|
-
// 幅が同じなら、フォントが利用できない(フォールバックされている)
|
|
26
|
-
const isAvailable = Math.abs(targetWidth - fallbackWidth) > 0.1;
|
|
27
|
-
fontAvailabilityCache.set(cacheKey, isAvailable);
|
|
28
|
-
return isAvailable;
|
|
29
|
-
}
|
|
1
|
+
import { measureTextWidth as measureTextWidthOpentype } from "./fontLoader.js";
|
|
30
2
|
/**
|
|
31
3
|
* 文字がCJK(日本語・中国語・韓国語)文字かどうかを判定する
|
|
32
4
|
*/
|
|
@@ -78,51 +50,13 @@ function estimateTextWidth(text, fontSizePx) {
|
|
|
78
50
|
}
|
|
79
51
|
return width;
|
|
80
52
|
}
|
|
81
|
-
// 現在のテキスト計測モード
|
|
82
|
-
let currentMode = "auto";
|
|
83
|
-
/**
|
|
84
|
-
* テキスト計測モードを設定する
|
|
85
|
-
*/
|
|
86
|
-
export function setTextMeasurementMode(mode) {
|
|
87
|
-
currentMode = mode;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* 現在のテキスト計測モードを取得する
|
|
91
|
-
*/
|
|
92
|
-
export function getTextMeasurementMode() {
|
|
93
|
-
return currentMode;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* テキストを折り返し付きでレイアウトし、そのサイズを測定する
|
|
97
|
-
*/
|
|
98
|
-
export function measureText(text, maxWidthPx, opts) {
|
|
99
|
-
const { fontFamily, fontSizePx } = opts;
|
|
100
|
-
// 計測方法を決定
|
|
101
|
-
const shouldUseFallback = (() => {
|
|
102
|
-
switch (currentMode) {
|
|
103
|
-
case "canvas":
|
|
104
|
-
return false;
|
|
105
|
-
case "fallback":
|
|
106
|
-
return true;
|
|
107
|
-
case "auto":
|
|
108
|
-
return !isFontAvailable(fontFamily, fontSizePx);
|
|
109
|
-
}
|
|
110
|
-
})();
|
|
111
|
-
if (shouldUseFallback) {
|
|
112
|
-
return measureTextFallback(text, maxWidthPx, opts);
|
|
113
|
-
}
|
|
114
|
-
return measureTextCanvas(text, maxWidthPx, opts);
|
|
115
|
-
}
|
|
116
53
|
/**
|
|
117
|
-
*
|
|
54
|
+
* テキストを折り返して行ごとの幅を計算する
|
|
118
55
|
*/
|
|
119
|
-
function
|
|
120
|
-
applyFontStyle(opts);
|
|
121
|
-
// まず改行で段落に分割
|
|
56
|
+
function wrapText(text, maxWidthPx, measureWidth) {
|
|
122
57
|
const paragraphs = text.split("\n");
|
|
123
58
|
const lines = [];
|
|
124
59
|
for (const paragraph of paragraphs) {
|
|
125
|
-
// 空の段落(連続した改行)も1行としてカウント
|
|
126
60
|
if (paragraph === "") {
|
|
127
61
|
lines.push({ widthPx: 0 });
|
|
128
62
|
continue;
|
|
@@ -132,23 +66,27 @@ function measureTextCanvas(text, maxWidthPx, opts) {
|
|
|
132
66
|
let currentWidth = 0;
|
|
133
67
|
for (const word of words) {
|
|
134
68
|
const candidate = current ? current + word : word;
|
|
135
|
-
const w =
|
|
69
|
+
const w = measureWidth(candidate);
|
|
136
70
|
if (w <= maxWidthPx || !current) {
|
|
137
|
-
// まだ詰められる
|
|
138
71
|
current = candidate;
|
|
139
72
|
currentWidth = w;
|
|
140
73
|
}
|
|
141
74
|
else {
|
|
142
|
-
// 折り返す
|
|
143
75
|
lines.push({ widthPx: currentWidth });
|
|
144
76
|
current = word;
|
|
145
|
-
currentWidth =
|
|
77
|
+
currentWidth = measureWidth(word);
|
|
146
78
|
}
|
|
147
79
|
}
|
|
148
80
|
if (current) {
|
|
149
81
|
lines.push({ widthPx: currentWidth });
|
|
150
82
|
}
|
|
151
83
|
}
|
|
84
|
+
return lines;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* 行情報から最終的なサイズを計算する
|
|
88
|
+
*/
|
|
89
|
+
function calculateResult(lines, opts) {
|
|
152
90
|
const lineHeightRatio = opts.lineHeight ?? 1.3;
|
|
153
91
|
const lineHeightPx = opts.fontSizePx * lineHeightRatio;
|
|
154
92
|
const widthPx = lines.length ? Math.max(...lines.map((l) => l.widthPx)) : 0;
|
|
@@ -156,52 +94,65 @@ function measureTextCanvas(text, maxWidthPx, opts) {
|
|
|
156
94
|
// 端数切り上げ+余裕分 10px を足す
|
|
157
95
|
return { widthPx: widthPx + 10, heightPx };
|
|
158
96
|
}
|
|
97
|
+
// 現在のテキスト計測モード
|
|
98
|
+
let currentMode = "auto";
|
|
159
99
|
/**
|
|
160
|
-
*
|
|
100
|
+
* テキスト計測モードを設定する
|
|
161
101
|
*/
|
|
162
|
-
function
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
102
|
+
export function setTextMeasurementMode(mode) {
|
|
103
|
+
currentMode = mode;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 現在のテキスト計測モードを取得する
|
|
107
|
+
*/
|
|
108
|
+
export function getTextMeasurementMode() {
|
|
109
|
+
return currentMode;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* fontWeight を "normal" | "bold" に正規化する
|
|
113
|
+
*/
|
|
114
|
+
function normalizeFontWeight(weight) {
|
|
115
|
+
if (weight === "bold" || weight === 700) {
|
|
116
|
+
return "bold";
|
|
117
|
+
}
|
|
118
|
+
return "normal";
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* テキストを折り返し付きでレイアウトし、そのサイズを測定する
|
|
122
|
+
*/
|
|
123
|
+
export function measureText(text, maxWidthPx, opts) {
|
|
124
|
+
// 計測方法を決定
|
|
125
|
+
const shouldUseFallback = (() => {
|
|
126
|
+
switch (currentMode) {
|
|
127
|
+
case "opentype":
|
|
128
|
+
return false;
|
|
129
|
+
case "fallback":
|
|
130
|
+
return true;
|
|
131
|
+
case "auto":
|
|
132
|
+
// opentype.js はバンドルされたフォントを使うため常に利用可能
|
|
133
|
+
return false;
|
|
193
134
|
}
|
|
135
|
+
})();
|
|
136
|
+
if (shouldUseFallback) {
|
|
137
|
+
return measureTextFallback(text, maxWidthPx, opts);
|
|
194
138
|
}
|
|
195
|
-
|
|
196
|
-
const lineHeightPx = fontSizePx * lineHeightRatio;
|
|
197
|
-
const widthPx = lines.length ? Math.max(...lines.map((l) => l.widthPx)) : 0;
|
|
198
|
-
const heightPx = lines.length * lineHeightPx;
|
|
199
|
-
// 端数切り上げ+余裕分 10px を足す
|
|
200
|
-
return { widthPx: widthPx + 10, heightPx };
|
|
139
|
+
return measureTextWithOpentype(text, maxWidthPx, opts);
|
|
201
140
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
141
|
+
/**
|
|
142
|
+
* opentype.js を使ったテキスト計測
|
|
143
|
+
*/
|
|
144
|
+
function measureTextWithOpentype(text, maxWidthPx, opts) {
|
|
145
|
+
const fontWeight = normalizeFontWeight(opts.fontWeight);
|
|
146
|
+
const lines = wrapText(text, maxWidthPx, (t) => measureTextWidthOpentype(t, opts.fontSizePx, fontWeight));
|
|
147
|
+
return calculateResult(lines, opts);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* フォールバック計算を使ったテキスト計測
|
|
151
|
+
*/
|
|
152
|
+
function measureTextFallback(text, maxWidthPx, opts) {
|
|
153
|
+
const { fontSizePx } = opts;
|
|
154
|
+
const lines = wrapText(text, maxWidthPx, (t) => estimateTextWidth(t, fontSizePx));
|
|
155
|
+
return calculateResult(lines, opts);
|
|
205
156
|
}
|
|
206
157
|
// ラップ用の分割ロジック
|
|
207
158
|
// - 英文: 空白で分割しつつ、空白も行末に残す
|
package/dist/inputSchema.d.ts
CHANGED
|
@@ -812,20 +812,279 @@ export declare const inputHStackNodeSchema: z.ZodType<InputHStackNode>;
|
|
|
812
812
|
* ```
|
|
813
813
|
*/
|
|
814
814
|
export declare const inputPomNodeSchema: z.ZodType<InputPOMNode>;
|
|
815
|
-
export declare const
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
815
|
+
export declare const inputMasterTextObjectSchema: z.ZodObject<{
|
|
816
|
+
type: z.ZodLiteral<"text">;
|
|
817
|
+
text: z.ZodString;
|
|
818
|
+
x: z.ZodNumber;
|
|
819
|
+
y: z.ZodNumber;
|
|
820
|
+
w: z.ZodNumber;
|
|
821
|
+
h: z.ZodNumber;
|
|
822
|
+
fontPx: z.ZodOptional<z.ZodNumber>;
|
|
823
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
824
|
+
color: z.ZodOptional<z.ZodString>;
|
|
825
|
+
bold: z.ZodOptional<z.ZodBoolean>;
|
|
826
|
+
alignText: z.ZodOptional<z.ZodEnum<{
|
|
827
|
+
right: "right";
|
|
828
|
+
left: "left";
|
|
829
|
+
center: "center";
|
|
830
|
+
}>>;
|
|
831
|
+
}, z.core.$strip>;
|
|
832
|
+
export declare const inputMasterImageObjectSchema: z.ZodObject<{
|
|
833
|
+
type: z.ZodLiteral<"image">;
|
|
834
|
+
src: z.ZodString;
|
|
835
|
+
x: z.ZodNumber;
|
|
836
|
+
y: z.ZodNumber;
|
|
837
|
+
w: z.ZodNumber;
|
|
838
|
+
h: z.ZodNumber;
|
|
839
|
+
}, z.core.$strip>;
|
|
840
|
+
export declare const inputMasterRectObjectSchema: z.ZodObject<{
|
|
841
|
+
type: z.ZodLiteral<"rect">;
|
|
842
|
+
x: z.ZodNumber;
|
|
843
|
+
y: z.ZodNumber;
|
|
844
|
+
w: z.ZodNumber;
|
|
845
|
+
h: z.ZodNumber;
|
|
846
|
+
fill: z.ZodOptional<z.ZodObject<{
|
|
847
|
+
color: z.ZodOptional<z.ZodString>;
|
|
848
|
+
transparency: z.ZodOptional<z.ZodNumber>;
|
|
849
|
+
}, z.core.$strip>>;
|
|
850
|
+
border: z.ZodOptional<z.ZodObject<{
|
|
851
|
+
color: z.ZodOptional<z.ZodString>;
|
|
852
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
853
|
+
dashType: z.ZodOptional<z.ZodEnum<{
|
|
854
|
+
solid: "solid";
|
|
855
|
+
dash: "dash";
|
|
856
|
+
dashDot: "dashDot";
|
|
857
|
+
lgDash: "lgDash";
|
|
858
|
+
lgDashDot: "lgDashDot";
|
|
859
|
+
lgDashDotDot: "lgDashDotDot";
|
|
860
|
+
sysDash: "sysDash";
|
|
861
|
+
sysDot: "sysDot";
|
|
862
|
+
}>>;
|
|
863
|
+
}, z.core.$strip>>;
|
|
864
|
+
}, z.core.$strip>;
|
|
865
|
+
export declare const inputMasterLineObjectSchema: z.ZodObject<{
|
|
866
|
+
type: z.ZodLiteral<"line">;
|
|
867
|
+
x: z.ZodNumber;
|
|
868
|
+
y: z.ZodNumber;
|
|
869
|
+
w: z.ZodNumber;
|
|
870
|
+
h: z.ZodNumber;
|
|
871
|
+
line: z.ZodOptional<z.ZodObject<{
|
|
872
|
+
color: z.ZodOptional<z.ZodString>;
|
|
873
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
874
|
+
dashType: z.ZodOptional<z.ZodEnum<{
|
|
875
|
+
solid: "solid";
|
|
876
|
+
dash: "dash";
|
|
877
|
+
dashDot: "dashDot";
|
|
878
|
+
lgDash: "lgDash";
|
|
879
|
+
lgDashDot: "lgDashDot";
|
|
880
|
+
lgDashDotDot: "lgDashDotDot";
|
|
881
|
+
sysDash: "sysDash";
|
|
882
|
+
sysDot: "sysDot";
|
|
883
|
+
}>>;
|
|
884
|
+
}, z.core.$strip>>;
|
|
885
|
+
}, z.core.$strip>;
|
|
886
|
+
export declare const inputMasterObjectSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
887
|
+
type: z.ZodLiteral<"text">;
|
|
888
|
+
text: z.ZodString;
|
|
889
|
+
x: z.ZodNumber;
|
|
890
|
+
y: z.ZodNumber;
|
|
891
|
+
w: z.ZodNumber;
|
|
892
|
+
h: z.ZodNumber;
|
|
893
|
+
fontPx: z.ZodOptional<z.ZodNumber>;
|
|
894
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
895
|
+
color: z.ZodOptional<z.ZodString>;
|
|
896
|
+
bold: z.ZodOptional<z.ZodBoolean>;
|
|
897
|
+
alignText: z.ZodOptional<z.ZodEnum<{
|
|
898
|
+
right: "right";
|
|
899
|
+
left: "left";
|
|
900
|
+
center: "center";
|
|
901
|
+
}>>;
|
|
902
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
903
|
+
type: z.ZodLiteral<"image">;
|
|
904
|
+
src: z.ZodString;
|
|
905
|
+
x: z.ZodNumber;
|
|
906
|
+
y: z.ZodNumber;
|
|
907
|
+
w: z.ZodNumber;
|
|
908
|
+
h: z.ZodNumber;
|
|
909
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
910
|
+
type: z.ZodLiteral<"rect">;
|
|
911
|
+
x: z.ZodNumber;
|
|
912
|
+
y: z.ZodNumber;
|
|
913
|
+
w: z.ZodNumber;
|
|
914
|
+
h: z.ZodNumber;
|
|
915
|
+
fill: z.ZodOptional<z.ZodObject<{
|
|
916
|
+
color: z.ZodOptional<z.ZodString>;
|
|
917
|
+
transparency: z.ZodOptional<z.ZodNumber>;
|
|
918
|
+
}, z.core.$strip>>;
|
|
919
|
+
border: z.ZodOptional<z.ZodObject<{
|
|
920
|
+
color: z.ZodOptional<z.ZodString>;
|
|
921
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
922
|
+
dashType: z.ZodOptional<z.ZodEnum<{
|
|
923
|
+
solid: "solid";
|
|
924
|
+
dash: "dash";
|
|
925
|
+
dashDot: "dashDot";
|
|
926
|
+
lgDash: "lgDash";
|
|
927
|
+
lgDashDot: "lgDashDot";
|
|
928
|
+
lgDashDotDot: "lgDashDotDot";
|
|
929
|
+
sysDash: "sysDash";
|
|
930
|
+
sysDot: "sysDot";
|
|
931
|
+
}>>;
|
|
932
|
+
}, z.core.$strip>>;
|
|
933
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
934
|
+
type: z.ZodLiteral<"line">;
|
|
935
|
+
x: z.ZodNumber;
|
|
936
|
+
y: z.ZodNumber;
|
|
937
|
+
w: z.ZodNumber;
|
|
938
|
+
h: z.ZodNumber;
|
|
939
|
+
line: z.ZodOptional<z.ZodObject<{
|
|
940
|
+
color: z.ZodOptional<z.ZodString>;
|
|
941
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
942
|
+
dashType: z.ZodOptional<z.ZodEnum<{
|
|
943
|
+
solid: "solid";
|
|
944
|
+
dash: "dash";
|
|
945
|
+
dashDot: "dashDot";
|
|
946
|
+
lgDash: "lgDash";
|
|
947
|
+
lgDashDot: "lgDashDot";
|
|
948
|
+
lgDashDotDot: "lgDashDotDot";
|
|
949
|
+
sysDash: "sysDash";
|
|
950
|
+
sysDot: "sysDot";
|
|
951
|
+
}>>;
|
|
952
|
+
}, z.core.$strip>>;
|
|
953
|
+
}, z.core.$strip>], "type">;
|
|
954
|
+
export declare const inputSlideNumberOptionsSchema: z.ZodObject<{
|
|
955
|
+
x: z.ZodNumber;
|
|
956
|
+
y: z.ZodNumber;
|
|
957
|
+
w: z.ZodOptional<z.ZodNumber>;
|
|
958
|
+
h: z.ZodOptional<z.ZodNumber>;
|
|
959
|
+
fontPx: z.ZodOptional<z.ZodNumber>;
|
|
960
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
961
|
+
color: z.ZodOptional<z.ZodString>;
|
|
962
|
+
}, z.core.$strip>;
|
|
963
|
+
export declare const inputSlideMasterBackgroundSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
964
|
+
color: z.ZodString;
|
|
965
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
966
|
+
path: z.ZodString;
|
|
967
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
968
|
+
data: z.ZodString;
|
|
969
|
+
}, z.core.$strip>]>;
|
|
970
|
+
export declare const inputSlideMasterMarginSchema: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
|
|
971
|
+
top: z.ZodOptional<z.ZodNumber>;
|
|
972
|
+
right: z.ZodOptional<z.ZodNumber>;
|
|
973
|
+
bottom: z.ZodOptional<z.ZodNumber>;
|
|
974
|
+
left: z.ZodOptional<z.ZodNumber>;
|
|
975
|
+
}, z.core.$strip>]>;
|
|
976
|
+
/**
|
|
977
|
+
* Input schema for slide master options (for LLM/external input validation)
|
|
978
|
+
*
|
|
979
|
+
* @example
|
|
980
|
+
* ```typescript
|
|
981
|
+
* import { inputSlideMasterOptionsSchema, buildPptx } from "@hirokisakabe/pom";
|
|
982
|
+
*
|
|
983
|
+
* const masterOptions = inputSlideMasterOptionsSchema.parse({
|
|
984
|
+
* title: "MY_MASTER",
|
|
985
|
+
* background: { color: "F0F0F0" },
|
|
986
|
+
* objects: [
|
|
987
|
+
* { type: "text", text: "Header", x: 48, y: 12, w: 200, h: 28, fontPx: 14 },
|
|
988
|
+
* ],
|
|
989
|
+
* slideNumber: { x: 1100, y: 680, fontPx: 10 },
|
|
990
|
+
* });
|
|
991
|
+
*
|
|
992
|
+
* const pptx = await buildPptx([page], { w: 1280, h: 720 }, { master: masterOptions });
|
|
993
|
+
* ```
|
|
994
|
+
*/
|
|
995
|
+
export declare const inputSlideMasterOptionsSchema: z.ZodObject<{
|
|
996
|
+
title: z.ZodOptional<z.ZodString>;
|
|
997
|
+
background: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
998
|
+
color: z.ZodString;
|
|
999
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1000
|
+
path: z.ZodString;
|
|
1001
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1002
|
+
data: z.ZodString;
|
|
1003
|
+
}, z.core.$strip>]>>;
|
|
1004
|
+
margin: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
|
|
1005
|
+
top: z.ZodOptional<z.ZodNumber>;
|
|
1006
|
+
right: z.ZodOptional<z.ZodNumber>;
|
|
1007
|
+
bottom: z.ZodOptional<z.ZodNumber>;
|
|
1008
|
+
left: z.ZodOptional<z.ZodNumber>;
|
|
1009
|
+
}, z.core.$strip>]>>;
|
|
1010
|
+
objects: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1011
|
+
type: z.ZodLiteral<"text">;
|
|
1012
|
+
text: z.ZodString;
|
|
1013
|
+
x: z.ZodNumber;
|
|
1014
|
+
y: z.ZodNumber;
|
|
1015
|
+
w: z.ZodNumber;
|
|
1016
|
+
h: z.ZodNumber;
|
|
1017
|
+
fontPx: z.ZodOptional<z.ZodNumber>;
|
|
1018
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
1019
|
+
color: z.ZodOptional<z.ZodString>;
|
|
1020
|
+
bold: z.ZodOptional<z.ZodBoolean>;
|
|
1021
|
+
alignText: z.ZodOptional<z.ZodEnum<{
|
|
820
1022
|
right: "right";
|
|
821
1023
|
left: "left";
|
|
822
1024
|
center: "center";
|
|
823
|
-
}
|
|
824
|
-
}, z.core.$strip
|
|
825
|
-
|
|
826
|
-
|
|
1025
|
+
}>>;
|
|
1026
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1027
|
+
type: z.ZodLiteral<"image">;
|
|
1028
|
+
src: z.ZodString;
|
|
1029
|
+
x: z.ZodNumber;
|
|
1030
|
+
y: z.ZodNumber;
|
|
1031
|
+
w: z.ZodNumber;
|
|
1032
|
+
h: z.ZodNumber;
|
|
1033
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1034
|
+
type: z.ZodLiteral<"rect">;
|
|
1035
|
+
x: z.ZodNumber;
|
|
1036
|
+
y: z.ZodNumber;
|
|
1037
|
+
w: z.ZodNumber;
|
|
1038
|
+
h: z.ZodNumber;
|
|
1039
|
+
fill: z.ZodOptional<z.ZodObject<{
|
|
1040
|
+
color: z.ZodOptional<z.ZodString>;
|
|
1041
|
+
transparency: z.ZodOptional<z.ZodNumber>;
|
|
1042
|
+
}, z.core.$strip>>;
|
|
1043
|
+
border: z.ZodOptional<z.ZodObject<{
|
|
1044
|
+
color: z.ZodOptional<z.ZodString>;
|
|
1045
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
1046
|
+
dashType: z.ZodOptional<z.ZodEnum<{
|
|
1047
|
+
solid: "solid";
|
|
1048
|
+
dash: "dash";
|
|
1049
|
+
dashDot: "dashDot";
|
|
1050
|
+
lgDash: "lgDash";
|
|
1051
|
+
lgDashDot: "lgDashDot";
|
|
1052
|
+
lgDashDotDot: "lgDashDotDot";
|
|
1053
|
+
sysDash: "sysDash";
|
|
1054
|
+
sysDot: "sysDot";
|
|
1055
|
+
}>>;
|
|
1056
|
+
}, z.core.$strip>>;
|
|
1057
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1058
|
+
type: z.ZodLiteral<"line">;
|
|
1059
|
+
x: z.ZodNumber;
|
|
1060
|
+
y: z.ZodNumber;
|
|
1061
|
+
w: z.ZodNumber;
|
|
1062
|
+
h: z.ZodNumber;
|
|
1063
|
+
line: z.ZodOptional<z.ZodObject<{
|
|
1064
|
+
color: z.ZodOptional<z.ZodString>;
|
|
1065
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
1066
|
+
dashType: z.ZodOptional<z.ZodEnum<{
|
|
1067
|
+
solid: "solid";
|
|
1068
|
+
dash: "dash";
|
|
1069
|
+
dashDot: "dashDot";
|
|
1070
|
+
lgDash: "lgDash";
|
|
1071
|
+
lgDashDot: "lgDashDot";
|
|
1072
|
+
lgDashDotDot: "lgDashDotDot";
|
|
1073
|
+
sysDash: "sysDash";
|
|
1074
|
+
sysDot: "sysDot";
|
|
1075
|
+
}>>;
|
|
1076
|
+
}, z.core.$strip>>;
|
|
1077
|
+
}, z.core.$strip>], "type">>>;
|
|
1078
|
+
slideNumber: z.ZodOptional<z.ZodObject<{
|
|
1079
|
+
x: z.ZodNumber;
|
|
1080
|
+
y: z.ZodNumber;
|
|
1081
|
+
w: z.ZodOptional<z.ZodNumber>;
|
|
1082
|
+
h: z.ZodOptional<z.ZodNumber>;
|
|
1083
|
+
fontPx: z.ZodOptional<z.ZodNumber>;
|
|
1084
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
1085
|
+
color: z.ZodOptional<z.ZodString>;
|
|
827
1086
|
}, z.core.$strip>>;
|
|
828
1087
|
}, z.core.$strip>;
|
|
829
|
-
export type
|
|
1088
|
+
export type InputSlideMasterOptions = z.infer<typeof inputSlideMasterOptionsSchema>;
|
|
830
1089
|
export {};
|
|
831
1090
|
//# sourceMappingURL=inputSchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputSchema.d.ts","sourceRoot":"","sources":["../src/inputSchema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"inputSchema.d.ts","sourceRoot":"","sources":["../src/inputSchema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EA6BL,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAW9B,CAAC;AAEH,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAGzD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAU9B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAG/B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAK/B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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, paddingSchema, borderStyleSchema, fillStyleSchema, shadowStyleSchema, alignItemsSchema, justifyContentSchema, shapeTypeSchema, tableColumnSchema, tableRowSchema,
|
|
20
|
+
import { lengthSchema, paddingSchema, borderStyleSchema, fillStyleSchema, shadowStyleSchema, alignItemsSchema, justifyContentSchema, shapeTypeSchema, tableColumnSchema, tableRowSchema, chartTypeSchema, chartDataSchema, bulletOptionsSchema, radarStyleSchema, timelineDirectionSchema, timelineItemSchema, matrixAxisSchema, matrixQuadrantsSchema, matrixItemSchema, treeLayoutSchema, treeNodeShapeSchema, treeConnectorStyleSchema, flowDirectionSchema, flowNodeItemSchema, flowConnectionSchema, flowConnectorStyleSchema, processArrowDirectionSchema, processArrowStepSchema, } from "./types";
|
|
21
21
|
// ===== Base Node Schema =====
|
|
22
22
|
export const inputBaseNodeSchema = z.object({
|
|
23
23
|
w: lengthSchema.optional(),
|
|
@@ -177,18 +177,97 @@ export const inputPomNodeSchema = z.lazy(() => z.discriminatedUnion("type", [
|
|
|
177
177
|
inputFlowNodeSchema,
|
|
178
178
|
inputProcessArrowNodeSchema,
|
|
179
179
|
]));
|
|
180
|
-
// ===== Master
|
|
181
|
-
export const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
180
|
+
// ===== Slide Master Options Schema =====
|
|
181
|
+
export const inputMasterTextObjectSchema = z.object({
|
|
182
|
+
type: z.literal("text"),
|
|
183
|
+
text: z.string(),
|
|
184
|
+
x: z.number(),
|
|
185
|
+
y: z.number(),
|
|
186
|
+
w: z.number(),
|
|
187
|
+
h: z.number(),
|
|
188
|
+
fontPx: z.number().optional(),
|
|
189
|
+
fontFamily: z.string().optional(),
|
|
190
|
+
color: z.string().optional(),
|
|
191
|
+
bold: z.boolean().optional(),
|
|
192
|
+
alignText: z.enum(["left", "center", "right"]).optional(),
|
|
193
|
+
});
|
|
194
|
+
export const inputMasterImageObjectSchema = z.object({
|
|
195
|
+
type: z.literal("image"),
|
|
196
|
+
src: z.string(),
|
|
197
|
+
x: z.number(),
|
|
198
|
+
y: z.number(),
|
|
199
|
+
w: z.number(),
|
|
200
|
+
h: z.number(),
|
|
201
|
+
});
|
|
202
|
+
export const inputMasterRectObjectSchema = z.object({
|
|
203
|
+
type: z.literal("rect"),
|
|
204
|
+
x: z.number(),
|
|
205
|
+
y: z.number(),
|
|
206
|
+
w: z.number(),
|
|
207
|
+
h: z.number(),
|
|
208
|
+
fill: fillStyleSchema.optional(),
|
|
209
|
+
border: borderStyleSchema.optional(),
|
|
210
|
+
});
|
|
211
|
+
export const inputMasterLineObjectSchema = z.object({
|
|
212
|
+
type: z.literal("line"),
|
|
213
|
+
x: z.number(),
|
|
214
|
+
y: z.number(),
|
|
215
|
+
w: z.number(),
|
|
216
|
+
h: z.number(),
|
|
217
|
+
line: borderStyleSchema.optional(),
|
|
218
|
+
});
|
|
219
|
+
export const inputMasterObjectSchema = z.discriminatedUnion("type", [
|
|
220
|
+
inputMasterTextObjectSchema,
|
|
221
|
+
inputMasterImageObjectSchema,
|
|
222
|
+
inputMasterRectObjectSchema,
|
|
223
|
+
inputMasterLineObjectSchema,
|
|
224
|
+
]);
|
|
225
|
+
export const inputSlideNumberOptionsSchema = z.object({
|
|
226
|
+
x: z.number(),
|
|
227
|
+
y: z.number(),
|
|
228
|
+
w: z.number().optional(),
|
|
229
|
+
h: z.number().optional(),
|
|
230
|
+
fontPx: z.number().optional(),
|
|
231
|
+
fontFamily: z.string().optional(),
|
|
232
|
+
color: z.string().optional(),
|
|
233
|
+
});
|
|
234
|
+
export const inputSlideMasterBackgroundSchema = z.union([
|
|
235
|
+
z.object({ color: z.string() }),
|
|
236
|
+
z.object({ path: z.string() }),
|
|
237
|
+
z.object({ data: z.string() }),
|
|
238
|
+
]);
|
|
239
|
+
export const inputSlideMasterMarginSchema = z.union([
|
|
240
|
+
z.number(),
|
|
241
|
+
z.object({
|
|
242
|
+
top: z.number().optional(),
|
|
243
|
+
right: z.number().optional(),
|
|
244
|
+
bottom: z.number().optional(),
|
|
245
|
+
left: z.number().optional(),
|
|
246
|
+
}),
|
|
247
|
+
]);
|
|
248
|
+
/**
|
|
249
|
+
* Input schema for slide master options (for LLM/external input validation)
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* import { inputSlideMasterOptionsSchema, buildPptx } from "@hirokisakabe/pom";
|
|
254
|
+
*
|
|
255
|
+
* const masterOptions = inputSlideMasterOptionsSchema.parse({
|
|
256
|
+
* title: "MY_MASTER",
|
|
257
|
+
* background: { color: "F0F0F0" },
|
|
258
|
+
* objects: [
|
|
259
|
+
* { type: "text", text: "Header", x: 48, y: 12, w: 200, h: 28, fontPx: 14 },
|
|
260
|
+
* ],
|
|
261
|
+
* slideNumber: { x: 1100, y: 680, fontPx: 10 },
|
|
262
|
+
* });
|
|
263
|
+
*
|
|
264
|
+
* const pptx = await buildPptx([page], { w: 1280, h: 720 }, { master: masterOptions });
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
export const inputSlideMasterOptionsSchema = z.object({
|
|
268
|
+
title: z.string().optional(),
|
|
269
|
+
background: inputSlideMasterBackgroundSchema.optional(),
|
|
270
|
+
margin: inputSlideMasterMarginSchema.optional(),
|
|
271
|
+
objects: z.array(inputMasterObjectSchema).optional(),
|
|
272
|
+
slideNumber: inputSlideNumberOptionsSchema.optional(),
|
|
194
273
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=box.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/box.ts"],"names":[],"mappings":""}
|