@hirokisakabe/pom 0.1.12 → 0.3.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 +31 -584
- package/dist/calcYogaLayout/calcYogaLayout.d.ts.map +1 -1
- package/dist/calcYogaLayout/calcYogaLayout.js +61 -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 +268 -2
- package/dist/inputSchema.d.ts.map +1 -1
- package/dist/inputSchema.js +53 -1
- 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.map +1 -1
- package/dist/renderPptx/renderPptx.js +32 -166
- package/dist/renderPptx/types.d.ts +10 -0
- package/dist/renderPptx/types.d.ts.map +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/toPositioned/toPositioned.d.ts.map +1 -1
- package/dist/toPositioned/toPositioned.js +45 -0
- package/dist/types.d.ts +399 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +134 -0
- package/package.json +13 -3
- package/dist/parsePptx/convertChart.d.ts +0 -8
- package/dist/parsePptx/convertChart.d.ts.map +0 -1
- package/dist/parsePptx/convertChart.js +0 -78
- package/dist/parsePptx/convertImage.d.ts +0 -8
- package/dist/parsePptx/convertImage.d.ts.map +0 -1
- package/dist/parsePptx/convertImage.js +0 -13
- package/dist/parsePptx/convertShape.d.ts +0 -7
- package/dist/parsePptx/convertShape.d.ts.map +0 -1
- package/dist/parsePptx/convertShape.js +0 -137
- package/dist/parsePptx/convertTable.d.ts +0 -7
- package/dist/parsePptx/convertTable.d.ts.map +0 -1
- package/dist/parsePptx/convertTable.js +0 -46
- package/dist/parsePptx/convertText.d.ts +0 -7
- package/dist/parsePptx/convertText.d.ts.map +0 -1
- package/dist/parsePptx/convertText.js +0 -32
- package/dist/parsePptx/index.d.ts +0 -23
- package/dist/parsePptx/index.d.ts.map +0 -1
- package/dist/parsePptx/index.js +0 -114
- package/dist/parsePptx/parseHtml.d.ts +0 -22
- package/dist/parsePptx/parseHtml.d.ts.map +0 -1
- package/dist/parsePptx/parseHtml.js +0 -53
- package/dist/parsePptx/types.d.ts +0 -15
- package/dist/parsePptx/types.d.ts.map +0 -1
- package/dist/parsePptx/units.d.ts +0 -13
- package/dist/parsePptx/units.d.ts.map +0 -1
- package/dist/parsePptx/units.js +0 -19
- /package/dist/{parsePptx → renderPptx}/types.js +0 -0
|
@@ -88,6 +88,11 @@ async function buildPomWithYogaTree(node, parentYoga, parentNode) {
|
|
|
88
88
|
case "image":
|
|
89
89
|
case "table":
|
|
90
90
|
case "shape":
|
|
91
|
+
case "timeline":
|
|
92
|
+
case "matrix":
|
|
93
|
+
case "tree":
|
|
94
|
+
case "flow":
|
|
95
|
+
case "processArrow":
|
|
91
96
|
// 子要素なし
|
|
92
97
|
break;
|
|
93
98
|
}
|
|
@@ -167,94 +172,12 @@ async function applyStyleToYogaNode(node, yn) {
|
|
|
167
172
|
break;
|
|
168
173
|
case "vstack": {
|
|
169
174
|
yn.setFlexDirection(yoga.FLEX_DIRECTION_COLUMN);
|
|
170
|
-
|
|
171
|
-
yn.setGap(yoga.GUTTER_ROW, node.gap);
|
|
172
|
-
yn.setGap(yoga.GUTTER_COLUMN, node.gap);
|
|
173
|
-
}
|
|
174
|
-
if (node.alignItems !== undefined) {
|
|
175
|
-
switch (node.alignItems) {
|
|
176
|
-
case "start":
|
|
177
|
-
yn.setAlignItems(yoga.ALIGN_FLEX_START);
|
|
178
|
-
break;
|
|
179
|
-
case "center":
|
|
180
|
-
yn.setAlignItems(yoga.ALIGN_CENTER);
|
|
181
|
-
break;
|
|
182
|
-
case "end":
|
|
183
|
-
yn.setAlignItems(yoga.ALIGN_FLEX_END);
|
|
184
|
-
break;
|
|
185
|
-
case "stretch":
|
|
186
|
-
yn.setAlignItems(yoga.ALIGN_STRETCH);
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (node.justifyContent !== undefined) {
|
|
191
|
-
switch (node.justifyContent) {
|
|
192
|
-
case "start":
|
|
193
|
-
yn.setJustifyContent(yoga.JUSTIFY_FLEX_START);
|
|
194
|
-
break;
|
|
195
|
-
case "center":
|
|
196
|
-
yn.setJustifyContent(yoga.JUSTIFY_CENTER);
|
|
197
|
-
break;
|
|
198
|
-
case "end":
|
|
199
|
-
yn.setJustifyContent(yoga.JUSTIFY_FLEX_END);
|
|
200
|
-
break;
|
|
201
|
-
case "spaceBetween":
|
|
202
|
-
yn.setJustifyContent(yoga.JUSTIFY_SPACE_BETWEEN);
|
|
203
|
-
break;
|
|
204
|
-
case "spaceAround":
|
|
205
|
-
yn.setJustifyContent(yoga.JUSTIFY_SPACE_AROUND);
|
|
206
|
-
break;
|
|
207
|
-
case "spaceEvenly":
|
|
208
|
-
yn.setJustifyContent(yoga.JUSTIFY_SPACE_EVENLY);
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
175
|
+
applyFlexProperties(node, yn, yoga);
|
|
212
176
|
break;
|
|
213
177
|
}
|
|
214
178
|
case "hstack": {
|
|
215
179
|
yn.setFlexDirection(yoga.FLEX_DIRECTION_ROW);
|
|
216
|
-
|
|
217
|
-
yn.setGap(yoga.GUTTER_ROW, node.gap);
|
|
218
|
-
yn.setGap(yoga.GUTTER_COLUMN, node.gap);
|
|
219
|
-
}
|
|
220
|
-
if (node.alignItems !== undefined) {
|
|
221
|
-
switch (node.alignItems) {
|
|
222
|
-
case "start":
|
|
223
|
-
yn.setAlignItems(yoga.ALIGN_FLEX_START);
|
|
224
|
-
break;
|
|
225
|
-
case "center":
|
|
226
|
-
yn.setAlignItems(yoga.ALIGN_CENTER);
|
|
227
|
-
break;
|
|
228
|
-
case "end":
|
|
229
|
-
yn.setAlignItems(yoga.ALIGN_FLEX_END);
|
|
230
|
-
break;
|
|
231
|
-
case "stretch":
|
|
232
|
-
yn.setAlignItems(yoga.ALIGN_STRETCH);
|
|
233
|
-
break;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
if (node.justifyContent !== undefined) {
|
|
237
|
-
switch (node.justifyContent) {
|
|
238
|
-
case "start":
|
|
239
|
-
yn.setJustifyContent(yoga.JUSTIFY_FLEX_START);
|
|
240
|
-
break;
|
|
241
|
-
case "center":
|
|
242
|
-
yn.setJustifyContent(yoga.JUSTIFY_CENTER);
|
|
243
|
-
break;
|
|
244
|
-
case "end":
|
|
245
|
-
yn.setJustifyContent(yoga.JUSTIFY_FLEX_END);
|
|
246
|
-
break;
|
|
247
|
-
case "spaceBetween":
|
|
248
|
-
yn.setJustifyContent(yoga.JUSTIFY_SPACE_BETWEEN);
|
|
249
|
-
break;
|
|
250
|
-
case "spaceAround":
|
|
251
|
-
yn.setJustifyContent(yoga.JUSTIFY_SPACE_AROUND);
|
|
252
|
-
break;
|
|
253
|
-
case "spaceEvenly":
|
|
254
|
-
yn.setJustifyContent(yoga.JUSTIFY_SPACE_EVENLY);
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
180
|
+
applyFlexProperties(node, yn, yoga);
|
|
258
181
|
break;
|
|
259
182
|
}
|
|
260
183
|
case "text":
|
|
@@ -345,5 +268,59 @@ async function applyStyleToYogaNode(node, yn) {
|
|
|
345
268
|
// テキストがない場合は、明示的にサイズが指定されていることを期待
|
|
346
269
|
}
|
|
347
270
|
break;
|
|
271
|
+
case "timeline":
|
|
272
|
+
case "matrix":
|
|
273
|
+
case "tree":
|
|
274
|
+
case "flow":
|
|
275
|
+
case "processArrow":
|
|
276
|
+
// 明示的にサイズが指定されていることを期待
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* vstack/hstack 共通の Flex プロパティを適用する
|
|
282
|
+
*/
|
|
283
|
+
function applyFlexProperties(node, yn, yoga) {
|
|
284
|
+
if (node.gap !== undefined) {
|
|
285
|
+
yn.setGap(yoga.GUTTER_ROW, node.gap);
|
|
286
|
+
yn.setGap(yoga.GUTTER_COLUMN, node.gap);
|
|
287
|
+
}
|
|
288
|
+
if (node.alignItems !== undefined) {
|
|
289
|
+
switch (node.alignItems) {
|
|
290
|
+
case "start":
|
|
291
|
+
yn.setAlignItems(yoga.ALIGN_FLEX_START);
|
|
292
|
+
break;
|
|
293
|
+
case "center":
|
|
294
|
+
yn.setAlignItems(yoga.ALIGN_CENTER);
|
|
295
|
+
break;
|
|
296
|
+
case "end":
|
|
297
|
+
yn.setAlignItems(yoga.ALIGN_FLEX_END);
|
|
298
|
+
break;
|
|
299
|
+
case "stretch":
|
|
300
|
+
yn.setAlignItems(yoga.ALIGN_STRETCH);
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (node.justifyContent !== undefined) {
|
|
305
|
+
switch (node.justifyContent) {
|
|
306
|
+
case "start":
|
|
307
|
+
yn.setJustifyContent(yoga.JUSTIFY_FLEX_START);
|
|
308
|
+
break;
|
|
309
|
+
case "center":
|
|
310
|
+
yn.setJustifyContent(yoga.JUSTIFY_CENTER);
|
|
311
|
+
break;
|
|
312
|
+
case "end":
|
|
313
|
+
yn.setJustifyContent(yoga.JUSTIFY_FLEX_END);
|
|
314
|
+
break;
|
|
315
|
+
case "spaceBetween":
|
|
316
|
+
yn.setJustifyContent(yoga.JUSTIFY_SPACE_BETWEEN);
|
|
317
|
+
break;
|
|
318
|
+
case "spaceAround":
|
|
319
|
+
yn.setJustifyContent(yoga.JUSTIFY_SPACE_AROUND);
|
|
320
|
+
break;
|
|
321
|
+
case "spaceEvenly":
|
|
322
|
+
yn.setJustifyContent(yoga.JUSTIFY_SPACE_EVENLY);
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
348
325
|
}
|
|
349
326
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* opentype.js を使用したフォント読み込みモジュール
|
|
3
|
+
* Node.js とブラウザ両方で動作する
|
|
4
|
+
*/
|
|
5
|
+
import { Font } from "opentype.js";
|
|
6
|
+
/**
|
|
7
|
+
* フォントを取得する(キャッシュ付き)
|
|
8
|
+
* @param weight フォントウェイト ("normal" or "bold")
|
|
9
|
+
* @returns opentype.js の Font オブジェクト
|
|
10
|
+
*/
|
|
11
|
+
export declare function getFont(weight: "normal" | "bold"): Font;
|
|
12
|
+
/**
|
|
13
|
+
* 指定したテキストの幅を計測する
|
|
14
|
+
* @param text 計測するテキスト
|
|
15
|
+
* @param fontSizePx フォントサイズ(ピクセル)
|
|
16
|
+
* @param weight フォントウェイト
|
|
17
|
+
* @returns テキスト幅(ピクセル)
|
|
18
|
+
*/
|
|
19
|
+
export declare function measureTextWidth(text: string, fontSizePx: number, weight: "normal" | "bold"): number;
|
|
20
|
+
//# sourceMappingURL=fontLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fontLoader.d.ts","sourceRoot":"","sources":["../../src/calcYogaLayout/fontLoader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAiB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AA6B7C;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAqBvD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,QAAQ,GAAG,MAAM,GACxB,MAAM,CAGR"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* opentype.js を使用したフォント読み込みモジュール
|
|
3
|
+
* Node.js とブラウザ両方で動作する
|
|
4
|
+
*/
|
|
5
|
+
import opentype from "opentype.js";
|
|
6
|
+
import { NOTO_SANS_JP_REGULAR_BASE64 } from "./fonts/notoSansJPRegular.js";
|
|
7
|
+
import { NOTO_SANS_JP_BOLD_BASE64 } from "./fonts/notoSansJPBold.js";
|
|
8
|
+
// フォントキャッシュ
|
|
9
|
+
const fontCache = new Map();
|
|
10
|
+
/**
|
|
11
|
+
* Base64 文字列を ArrayBuffer に変換する
|
|
12
|
+
* Node.js とブラウザ両方で動作する
|
|
13
|
+
*/
|
|
14
|
+
function base64ToArrayBuffer(base64) {
|
|
15
|
+
// Node.js 環境
|
|
16
|
+
if (typeof Buffer !== "undefined") {
|
|
17
|
+
const buffer = Buffer.from(base64, "base64");
|
|
18
|
+
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
19
|
+
}
|
|
20
|
+
// ブラウザ環境
|
|
21
|
+
const binaryString = atob(base64);
|
|
22
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
23
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
24
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
25
|
+
}
|
|
26
|
+
return bytes.buffer;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* フォントを取得する(キャッシュ付き)
|
|
30
|
+
* @param weight フォントウェイト ("normal" or "bold")
|
|
31
|
+
* @returns opentype.js の Font オブジェクト
|
|
32
|
+
*/
|
|
33
|
+
export function getFont(weight) {
|
|
34
|
+
const cacheKey = weight;
|
|
35
|
+
// キャッシュがあればそれを返す
|
|
36
|
+
const cached = fontCache.get(cacheKey);
|
|
37
|
+
if (cached) {
|
|
38
|
+
return cached;
|
|
39
|
+
}
|
|
40
|
+
// Base64 データを選択
|
|
41
|
+
const base64 = weight === "bold" ? NOTO_SANS_JP_BOLD_BASE64 : NOTO_SANS_JP_REGULAR_BASE64;
|
|
42
|
+
// ArrayBuffer に変換してパース
|
|
43
|
+
const buffer = base64ToArrayBuffer(base64);
|
|
44
|
+
const font = opentype.parse(buffer);
|
|
45
|
+
// キャッシュに保存
|
|
46
|
+
fontCache.set(cacheKey, font);
|
|
47
|
+
return font;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 指定したテキストの幅を計測する
|
|
51
|
+
* @param text 計測するテキスト
|
|
52
|
+
* @param fontSizePx フォントサイズ(ピクセル)
|
|
53
|
+
* @param weight フォントウェイト
|
|
54
|
+
* @returns テキスト幅(ピクセル)
|
|
55
|
+
*/
|
|
56
|
+
export function measureTextWidth(text, fontSizePx, weight) {
|
|
57
|
+
const font = getFont(weight);
|
|
58
|
+
return font.getAdvanceWidth(text, fontSizePx, { kerning: true });
|
|
59
|
+
}
|