@hirokisakabe/pom 5.2.0 → 5.2.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.
- package/README.md +10 -11
- package/dist/autoFit/autoFit.d.ts +2 -1
- package/dist/autoFit/autoFit.d.ts.map +1 -1
- package/dist/autoFit/autoFit.js +7 -7
- package/dist/autoFit/strategies/reduceFontSize.js +1 -1
- package/dist/autoFit/strategies/reduceGapAndPadding.js +1 -1
- package/dist/autoFit/strategies/reduceTableRowHeight.js +1 -1
- package/dist/autoFit/strategies/uniformScale.js +1 -1
- package/dist/buildContext.d.ts +12 -0
- package/dist/buildContext.d.ts.map +1 -0
- package/dist/buildContext.js +8 -0
- package/dist/buildPptx.d.ts +1 -1
- package/dist/buildPptx.d.ts.map +1 -1
- package/dist/buildPptx.js +15 -15
- package/dist/calcYogaLayout/calcYogaLayout.d.ts +3 -1
- package/dist/calcYogaLayout/calcYogaLayout.d.ts.map +1 -1
- package/dist/calcYogaLayout/calcYogaLayout.js +43 -371
- package/dist/calcYogaLayout/measureText.d.ts +1 -5
- package/dist/calcYogaLayout/measureText.d.ts.map +1 -1
- package/dist/calcYogaLayout/measureText.js +2 -10
- package/dist/icons/renderIcon.d.ts +1 -1
- package/dist/icons/renderIcon.d.ts.map +1 -1
- package/dist/icons/renderIcon.js +3 -4
- package/dist/parseXml/coercionRules.d.ts +35 -0
- package/dist/parseXml/coercionRules.d.ts.map +1 -0
- package/dist/parseXml/coercionRules.js +477 -0
- package/dist/parseXml/inputSchema.d.ts +15 -105
- package/dist/parseXml/inputSchema.d.ts.map +1 -1
- package/dist/parseXml/inputSchema.js +2 -2
- package/dist/parseXml/parseXml.d.ts.map +1 -1
- package/dist/parseXml/parseXml.js +40 -272
- package/dist/registry/definitions/box.d.ts +3 -0
- package/dist/registry/definitions/box.d.ts.map +1 -0
- package/dist/registry/definitions/box.js +6 -0
- package/dist/registry/definitions/chart.d.ts +3 -0
- package/dist/registry/definitions/chart.d.ts.map +1 -0
- package/dist/registry/definitions/chart.js +8 -0
- package/dist/registry/definitions/compositeNodes.d.ts +8 -0
- package/dist/registry/definitions/compositeNodes.d.ts.map +1 -0
- package/dist/registry/definitions/compositeNodes.js +81 -0
- package/dist/registry/definitions/icon.d.ts +3 -0
- package/dist/registry/definitions/icon.d.ts.map +1 -0
- package/dist/registry/definitions/icon.js +28 -0
- package/dist/registry/definitions/image.d.ts +3 -0
- package/dist/registry/definitions/image.d.ts.map +1 -0
- package/dist/registry/definitions/image.js +34 -0
- package/dist/registry/definitions/layer.d.ts +3 -0
- package/dist/registry/definitions/layer.d.ts.map +1 -0
- package/dist/registry/definitions/layer.js +49 -0
- package/dist/registry/definitions/line.d.ts +3 -0
- package/dist/registry/definitions/line.d.ts.map +1 -0
- package/dist/registry/definitions/line.js +26 -0
- package/dist/registry/definitions/list.d.ts +4 -0
- package/dist/registry/definitions/list.d.ts.map +1 -0
- package/dist/registry/definitions/list.js +53 -0
- package/dist/registry/definitions/shape.d.ts +3 -0
- package/dist/registry/definitions/shape.d.ts.map +1 -0
- package/dist/registry/definitions/shape.js +37 -0
- package/dist/registry/definitions/stack.d.ts +4 -0
- package/dist/registry/definitions/stack.d.ts.map +1 -0
- package/dist/registry/definitions/stack.js +78 -0
- package/dist/registry/definitions/table.d.ts +3 -0
- package/dist/registry/definitions/table.d.ts.map +1 -0
- package/dist/registry/definitions/table.js +16 -0
- package/dist/registry/definitions/text.d.ts +3 -0
- package/dist/registry/definitions/text.d.ts.map +1 -0
- package/dist/registry/definitions/text.js +35 -0
- package/dist/registry/index.d.ts +2 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +34 -0
- package/dist/registry/nodeRegistry.d.ts +7 -0
- package/dist/registry/nodeRegistry.d.ts.map +1 -0
- package/dist/registry/nodeRegistry.js +13 -0
- package/dist/registry/types.d.ts +26 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +1 -0
- package/dist/renderPptx/renderPptx.d.ts +2 -1
- package/dist/renderPptx/renderPptx.d.ts.map +1 -1
- package/dist/renderPptx/renderPptx.js +19 -60
- package/dist/renderPptx/types.d.ts +2 -0
- package/dist/renderPptx/types.d.ts.map +1 -1
- package/dist/renderPptx/utils/backgroundBorder.d.ts.map +1 -1
- package/dist/renderPptx/utils/backgroundBorder.js +1 -1
- package/dist/shared/freeYogaTree.d.ts.map +1 -0
- package/dist/shared/measureImage.d.ts +13 -3
- package/dist/shared/measureImage.d.ts.map +1 -1
- package/dist/shared/measureImage.js +14 -19
- package/dist/shared/walkTree.d.ts.map +1 -0
- package/dist/toPositioned/toPositioned.d.ts +8 -1
- package/dist/toPositioned/toPositioned.d.ts.map +1 -1
- package/dist/toPositioned/toPositioned.js +32 -189
- package/dist/types.d.ts +17 -54
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/package.json +3 -3
- package/dist/autoFit/freeYogaTree.d.ts.map +0 -1
- package/dist/autoFit/walkTree.d.ts.map +0 -1
- package/dist/renderPptx/nodes/index.d.ts +0 -15
- package/dist/renderPptx/nodes/index.d.ts.map +0 -1
- package/dist/renderPptx/nodes/index.js +0 -14
- /package/dist/{autoFit → shared}/freeYogaTree.d.ts +0 -0
- /package/dist/{autoFit → shared}/freeYogaTree.js +0 -0
- /package/dist/{autoFit → shared}/walkTree.d.ts +0 -0
- /package/dist/{autoFit → shared}/walkTree.js +0 -0
|
@@ -1,16 +1,24 @@
|
|
|
1
|
+
type ImageSizeCache = Map<string, {
|
|
2
|
+
widthPx: number;
|
|
3
|
+
heightPx: number;
|
|
4
|
+
}>;
|
|
5
|
+
type ImageDataCache = Map<string, string>;
|
|
1
6
|
/**
|
|
2
7
|
* キャッシュされた画像データ(Base64)を取得する
|
|
3
8
|
* @param src 画像のパス
|
|
9
|
+
* @param cache 画像データキャッシュ
|
|
4
10
|
* @returns Base64形式の画像データ、またはキャッシュがない場合はundefined
|
|
5
11
|
*/
|
|
6
|
-
export declare function getImageData(src: string): string | undefined;
|
|
12
|
+
export declare function getImageData(src: string, cache: ImageDataCache): string | undefined;
|
|
7
13
|
/**
|
|
8
14
|
* 画像サイズを事前取得してキャッシュする(非同期)
|
|
9
15
|
* HTTPS URLの画像を処理する際に使用
|
|
10
16
|
* @param src 画像のパス(ローカルパス、base64データ、またはHTTPS URL)
|
|
17
|
+
* @param sizeCache 画像サイズキャッシュ
|
|
18
|
+
* @param dataCache 画像データキャッシュ
|
|
11
19
|
* @returns 画像の幅と高さ(px)
|
|
12
20
|
*/
|
|
13
|
-
export declare function prefetchImageSize(src: string): Promise<{
|
|
21
|
+
export declare function prefetchImageSize(src: string, sizeCache: ImageSizeCache, dataCache: ImageDataCache): Promise<{
|
|
14
22
|
widthPx: number;
|
|
15
23
|
heightPx: number;
|
|
16
24
|
}>;
|
|
@@ -18,10 +26,12 @@ export declare function prefetchImageSize(src: string): Promise<{
|
|
|
18
26
|
* 画像ファイルのサイズを取得する(同期)
|
|
19
27
|
* 事前にprefetchImageSizeでキャッシュしておくこと
|
|
20
28
|
* @param src 画像のパス(ローカルパス、base64データ、またはHTTPS URL)
|
|
29
|
+
* @param sizeCache 画像サイズキャッシュ
|
|
21
30
|
* @returns 画像の幅と高さ(px)
|
|
22
31
|
*/
|
|
23
|
-
export declare function measureImage(src: string): {
|
|
32
|
+
export declare function measureImage(src: string, sizeCache: ImageSizeCache): {
|
|
24
33
|
widthPx: number;
|
|
25
34
|
heightPx: number;
|
|
26
35
|
};
|
|
36
|
+
export {};
|
|
27
37
|
//# sourceMappingURL=measureImage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measureImage.d.ts","sourceRoot":"","sources":["../../src/shared/measureImage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"measureImage.d.ts","sourceRoot":"","sources":["../../src/shared/measureImage.ts"],"names":[],"mappings":"AAYA,KAAK,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AACzE,KAAK,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE1C;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,cAAc,GACpB,MAAM,GAAG,SAAS,CAEpB;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,cAAc,EACzB,SAAS,EAAE,cAAc,GACxB,OAAO,CAAC;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,CA0DD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,cAAc,GACxB;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAqDA"}
|
|
@@ -6,32 +6,26 @@ const imageSizeModule = require("image-size");
|
|
|
6
6
|
// CommonJS モジュールは .default または直接エクスポートされる場合がある
|
|
7
7
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
|
|
8
8
|
const imageSize = imageSizeModule.default ?? imageSizeModule;
|
|
9
|
-
/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
|
|
10
|
-
/**
|
|
11
|
-
* 画像サイズのキャッシュ(事前取得した画像サイズを保持)
|
|
12
|
-
*/
|
|
13
|
-
const imageSizeCache = new Map();
|
|
14
|
-
/**
|
|
15
|
-
* 画像データのキャッシュ(Base64形式、リモート画像用)
|
|
16
|
-
*/
|
|
17
|
-
const imageDataCache = new Map();
|
|
18
9
|
/**
|
|
19
10
|
* キャッシュされた画像データ(Base64)を取得する
|
|
20
11
|
* @param src 画像のパス
|
|
12
|
+
* @param cache 画像データキャッシュ
|
|
21
13
|
* @returns Base64形式の画像データ、またはキャッシュがない場合はundefined
|
|
22
14
|
*/
|
|
23
|
-
export function getImageData(src) {
|
|
24
|
-
return
|
|
15
|
+
export function getImageData(src, cache) {
|
|
16
|
+
return cache.get(src);
|
|
25
17
|
}
|
|
26
18
|
/**
|
|
27
19
|
* 画像サイズを事前取得してキャッシュする(非同期)
|
|
28
20
|
* HTTPS URLの画像を処理する際に使用
|
|
29
21
|
* @param src 画像のパス(ローカルパス、base64データ、またはHTTPS URL)
|
|
22
|
+
* @param sizeCache 画像サイズキャッシュ
|
|
23
|
+
* @param dataCache 画像データキャッシュ
|
|
30
24
|
* @returns 画像の幅と高さ(px)
|
|
31
25
|
*/
|
|
32
|
-
export async function prefetchImageSize(src) {
|
|
26
|
+
export async function prefetchImageSize(src, sizeCache, dataCache) {
|
|
33
27
|
// キャッシュにあればそれを返す
|
|
34
|
-
const cached =
|
|
28
|
+
const cached = sizeCache.get(src);
|
|
35
29
|
if (cached) {
|
|
36
30
|
return cached;
|
|
37
31
|
}
|
|
@@ -53,7 +47,7 @@ export async function prefetchImageSize(src) {
|
|
|
53
47
|
// 画像データをBase64形式でキャッシュ(pptxgenjs用)
|
|
54
48
|
const contentType = response.headers.get("content-type") || "image/png";
|
|
55
49
|
const base64 = Buffer.from(arrayBuffer).toString("base64");
|
|
56
|
-
|
|
50
|
+
dataCache.set(src, `${contentType};base64,${base64}`);
|
|
57
51
|
}
|
|
58
52
|
// ローカルファイルパスの場合
|
|
59
53
|
else {
|
|
@@ -67,7 +61,7 @@ export async function prefetchImageSize(src) {
|
|
|
67
61
|
heightPx: height,
|
|
68
62
|
};
|
|
69
63
|
// キャッシュに保存
|
|
70
|
-
|
|
64
|
+
sizeCache.set(src, result);
|
|
71
65
|
return result;
|
|
72
66
|
}
|
|
73
67
|
catch (error) {
|
|
@@ -77,7 +71,7 @@ export async function prefetchImageSize(src) {
|
|
|
77
71
|
widthPx: 100,
|
|
78
72
|
heightPx: 100,
|
|
79
73
|
};
|
|
80
|
-
|
|
74
|
+
sizeCache.set(src, result);
|
|
81
75
|
return result;
|
|
82
76
|
}
|
|
83
77
|
}
|
|
@@ -85,11 +79,12 @@ export async function prefetchImageSize(src) {
|
|
|
85
79
|
* 画像ファイルのサイズを取得する(同期)
|
|
86
80
|
* 事前にprefetchImageSizeでキャッシュしておくこと
|
|
87
81
|
* @param src 画像のパス(ローカルパス、base64データ、またはHTTPS URL)
|
|
82
|
+
* @param sizeCache 画像サイズキャッシュ
|
|
88
83
|
* @returns 画像の幅と高さ(px)
|
|
89
84
|
*/
|
|
90
|
-
export function measureImage(src) {
|
|
85
|
+
export function measureImage(src, sizeCache) {
|
|
91
86
|
// キャッシュにあればそれを返す
|
|
92
|
-
const cached =
|
|
87
|
+
const cached = sizeCache.get(src);
|
|
93
88
|
if (cached) {
|
|
94
89
|
return cached;
|
|
95
90
|
}
|
|
@@ -121,7 +116,7 @@ export function measureImage(src) {
|
|
|
121
116
|
heightPx: height,
|
|
122
117
|
};
|
|
123
118
|
// キャッシュに保存
|
|
124
|
-
|
|
119
|
+
sizeCache.set(src, result);
|
|
125
120
|
return result;
|
|
126
121
|
}
|
|
127
122
|
catch (error) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walkTree.d.ts","sourceRoot":"","sources":["../../src/shared/walkTree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C;;GAEG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,GAC/B,IAAI,CAeN"}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type { POMNode, PositionedNode } from "../types.ts";
|
|
2
|
+
import type { BuildContext } from "../buildContext.ts";
|
|
3
|
+
/**
|
|
4
|
+
* POMNode から yogaNode を除外したオブジェクトを返す。
|
|
5
|
+
* PositionedNode に yogaNode 参照が残らないようにするため。
|
|
6
|
+
*/
|
|
7
|
+
export declare function omitYogaNode<T extends POMNode>(pom: T): Omit<T, "yogaNode">;
|
|
2
8
|
/**
|
|
3
9
|
* POMNode ツリーを絶対座標付きの PositionedNode ツリーに変換する
|
|
4
10
|
* @param pom 入力 POMNode
|
|
11
|
+
* @param ctx BuildContext
|
|
5
12
|
* @param parentX 親ノードの絶対X座標
|
|
6
13
|
* @param parentY 親ノードの絶対Y座標
|
|
7
14
|
* @returns PositionedNode ツリー
|
|
8
15
|
*/
|
|
9
|
-
export declare function toPositioned(pom: POMNode, parentX?: number, parentY?: number): PositionedNode;
|
|
16
|
+
export declare function toPositioned(pom: POMNode, ctx: BuildContext, parentX?: number, parentY?: number): PositionedNode;
|
|
10
17
|
//# sourceMappingURL=toPositioned.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toPositioned.d.ts","sourceRoot":"","sources":["../../src/toPositioned/toPositioned.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"toPositioned.d.ts","sourceRoot":"","sources":["../../src/toPositioned/toPositioned.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,CAI3E;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,YAAY,EACjB,OAAO,SAAI,EACX,OAAO,SAAI,GACV,cAAc,CA8DhB"}
|
|
@@ -1,224 +1,67 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { getNodeDef } from "../registry/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* POMNode から yogaNode を除外したオブジェクトを返す。
|
|
4
|
+
* PositionedNode に yogaNode 参照が残らないようにするため。
|
|
5
|
+
*/
|
|
6
|
+
export function omitYogaNode(pom) {
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8
|
+
const { yogaNode, ...rest } = pom;
|
|
9
|
+
return rest;
|
|
10
|
+
}
|
|
3
11
|
/**
|
|
4
12
|
* POMNode ツリーを絶対座標付きの PositionedNode ツリーに変換する
|
|
5
13
|
* @param pom 入力 POMNode
|
|
14
|
+
* @param ctx BuildContext
|
|
6
15
|
* @param parentX 親ノードの絶対X座標
|
|
7
16
|
* @param parentY 親ノードの絶対Y座標
|
|
8
17
|
* @returns PositionedNode ツリー
|
|
9
18
|
*/
|
|
10
|
-
export function toPositioned(pom, parentX = 0, parentY = 0) {
|
|
19
|
+
export function toPositioned(pom, ctx, parentX = 0, parentY = 0) {
|
|
11
20
|
if (!pom.yogaNode) {
|
|
12
21
|
throw new Error("yogaNode not set on POMNode");
|
|
13
22
|
}
|
|
14
23
|
const layout = pom.yogaNode.getComputedLayout();
|
|
15
24
|
const absoluteX = parentX + layout.left;
|
|
16
25
|
const absoluteY = parentY + layout.top;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
w: layout.width,
|
|
26
|
-
h: layout.height,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
case "image": {
|
|
30
|
-
const imageData = getImageData(pom.src);
|
|
31
|
-
return {
|
|
32
|
-
...pom,
|
|
33
|
-
x: absoluteX,
|
|
34
|
-
y: absoluteY,
|
|
35
|
-
w: layout.width,
|
|
36
|
-
h: layout.height,
|
|
37
|
-
imageData,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
case "table": {
|
|
41
|
-
return {
|
|
42
|
-
...pom,
|
|
43
|
-
x: absoluteX,
|
|
44
|
-
y: absoluteY,
|
|
45
|
-
w: layout.width,
|
|
46
|
-
h: layout.height,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
case "shape": {
|
|
50
|
-
return {
|
|
51
|
-
...pom,
|
|
52
|
-
x: absoluteX,
|
|
53
|
-
y: absoluteY,
|
|
54
|
-
w: layout.width,
|
|
55
|
-
h: layout.height,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
case "chart": {
|
|
59
|
-
return {
|
|
60
|
-
...pom,
|
|
61
|
-
x: absoluteX,
|
|
62
|
-
y: absoluteY,
|
|
63
|
-
w: layout.width,
|
|
64
|
-
h: layout.height,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
case "timeline": {
|
|
68
|
-
return {
|
|
69
|
-
...pom,
|
|
70
|
-
x: absoluteX,
|
|
71
|
-
y: absoluteY,
|
|
72
|
-
w: layout.width,
|
|
73
|
-
h: layout.height,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
case "matrix": {
|
|
77
|
-
return {
|
|
78
|
-
...pom,
|
|
79
|
-
x: absoluteX,
|
|
80
|
-
y: absoluteY,
|
|
81
|
-
w: layout.width,
|
|
82
|
-
h: layout.height,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
case "tree": {
|
|
86
|
-
return {
|
|
87
|
-
...pom,
|
|
88
|
-
x: absoluteX,
|
|
89
|
-
y: absoluteY,
|
|
90
|
-
w: layout.width,
|
|
91
|
-
h: layout.height,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
case "flow": {
|
|
95
|
-
return {
|
|
96
|
-
...pom,
|
|
97
|
-
x: absoluteX,
|
|
98
|
-
y: absoluteY,
|
|
99
|
-
w: layout.width,
|
|
100
|
-
h: layout.height,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
case "processArrow": {
|
|
104
|
-
return {
|
|
105
|
-
...pom,
|
|
106
|
-
x: absoluteX,
|
|
107
|
-
y: absoluteY,
|
|
108
|
-
w: layout.width,
|
|
109
|
-
h: layout.height,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
case "pyramid": {
|
|
113
|
-
return {
|
|
114
|
-
...pom,
|
|
115
|
-
x: absoluteX,
|
|
116
|
-
y: absoluteY,
|
|
117
|
-
w: layout.width,
|
|
118
|
-
h: layout.height,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
case "box": {
|
|
122
|
-
return {
|
|
123
|
-
...pom,
|
|
124
|
-
x: absoluteX,
|
|
125
|
-
y: absoluteY,
|
|
126
|
-
w: layout.width,
|
|
127
|
-
h: layout.height,
|
|
128
|
-
children: toPositioned(pom.children, absoluteX, absoluteY),
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
case "vstack": {
|
|
132
|
-
return {
|
|
133
|
-
...pom,
|
|
134
|
-
x: absoluteX,
|
|
135
|
-
y: absoluteY,
|
|
136
|
-
w: layout.width,
|
|
137
|
-
h: layout.height,
|
|
138
|
-
children: pom.children.map((child) => toPositioned(child, absoluteX, absoluteY)),
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
case "hstack": {
|
|
26
|
+
const def = getNodeDef(pom.type);
|
|
27
|
+
// ノード固有のカスタム変換がある場合はそれを使用
|
|
28
|
+
if (def.toPositioned) {
|
|
29
|
+
return def.toPositioned(pom, absoluteX, absoluteY, layout, ctx);
|
|
30
|
+
}
|
|
31
|
+
// category ベースのデフォルト処理
|
|
32
|
+
switch (def.category) {
|
|
33
|
+
case "leaf":
|
|
142
34
|
return {
|
|
143
|
-
...pom,
|
|
35
|
+
...omitYogaNode(pom),
|
|
144
36
|
x: absoluteX,
|
|
145
37
|
y: absoluteY,
|
|
146
38
|
w: layout.width,
|
|
147
39
|
h: layout.height,
|
|
148
|
-
children: pom.children.map((child) => toPositioned(child, absoluteX, absoluteY)),
|
|
149
40
|
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const rasterSize = Math.max(Math.ceil(layout.width), Math.ceil(layout.height), pom.size ?? 24);
|
|
153
|
-
const iconImageData = rasterizeIcon(pom.name, rasterSize, pom.color ?? "#000000");
|
|
41
|
+
case "single-child": {
|
|
42
|
+
const boxNode = pom;
|
|
154
43
|
return {
|
|
155
|
-
...
|
|
44
|
+
...omitYogaNode(boxNode),
|
|
156
45
|
x: absoluteX,
|
|
157
46
|
y: absoluteY,
|
|
158
47
|
w: layout.width,
|
|
159
48
|
h: layout.height,
|
|
160
|
-
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
case "line": {
|
|
164
|
-
// line ノードは絶対座標(x1, y1, x2, y2)を持つため、
|
|
165
|
-
// yogaNode の座標ではなく自身の座標からバウンディングボックスを計算
|
|
166
|
-
return {
|
|
167
|
-
...pom,
|
|
168
|
-
x: Math.min(pom.x1, pom.x2),
|
|
169
|
-
y: Math.min(pom.y1, pom.y2),
|
|
170
|
-
w: Math.abs(pom.x2 - pom.x1),
|
|
171
|
-
h: Math.abs(pom.y2 - pom.y1),
|
|
49
|
+
children: toPositioned(boxNode.children, ctx, absoluteX, absoluteY),
|
|
172
50
|
};
|
|
173
51
|
}
|
|
174
|
-
case "
|
|
175
|
-
|
|
176
|
-
// layer の絶対座標に加算してスライド上の絶対座標に変換
|
|
52
|
+
case "multi-child": {
|
|
53
|
+
const containerNode = pom;
|
|
177
54
|
return {
|
|
178
|
-
...
|
|
55
|
+
...omitYogaNode(containerNode),
|
|
179
56
|
x: absoluteX,
|
|
180
57
|
y: absoluteY,
|
|
181
58
|
w: layout.width,
|
|
182
59
|
h: layout.height,
|
|
183
|
-
children:
|
|
184
|
-
// layer 内での子要素の絶対座標(child.x, child.y がない場合は 0)
|
|
185
|
-
const childX = child.x ?? 0;
|
|
186
|
-
const childY = child.y ?? 0;
|
|
187
|
-
// line ノードは特別な処理が必要
|
|
188
|
-
// x1, y1, x2, y2 は layer 内の相対座標として扱い、layer の座標を加算
|
|
189
|
-
if (child.type === "line") {
|
|
190
|
-
const lineAbsoluteX = absoluteX + childX;
|
|
191
|
-
const lineAbsoluteY = absoluteY + childY;
|
|
192
|
-
const adjustedX1 = child.x1 + lineAbsoluteX;
|
|
193
|
-
const adjustedY1 = child.y1 + lineAbsoluteY;
|
|
194
|
-
const adjustedX2 = child.x2 + lineAbsoluteX;
|
|
195
|
-
const adjustedY2 = child.y2 + lineAbsoluteY;
|
|
196
|
-
return {
|
|
197
|
-
...child,
|
|
198
|
-
x1: adjustedX1,
|
|
199
|
-
y1: adjustedY1,
|
|
200
|
-
x2: adjustedX2,
|
|
201
|
-
y2: adjustedY2,
|
|
202
|
-
x: Math.min(adjustedX1, adjustedX2),
|
|
203
|
-
y: Math.min(adjustedY1, adjustedY2),
|
|
204
|
-
w: Math.abs(adjustedX2 - adjustedX1),
|
|
205
|
-
h: Math.abs(adjustedY2 - adjustedY1),
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
// その他のノードは通常の処理
|
|
209
|
-
// Yoga で計算された子要素の相対座標を取得
|
|
210
|
-
const childLayout = child.yogaNode.getComputedLayout();
|
|
211
|
-
// 正しい親座標を計算: layer の座標 + child.x - Yoga の相対座標
|
|
212
|
-
// こうすることで toPositioned 内で:
|
|
213
|
-
// absoluteX = adjustedParentX + childLayout.left
|
|
214
|
-
// = (absoluteX + child.x - childLayout.left) + childLayout.left
|
|
215
|
-
// = absoluteX + child.x
|
|
216
|
-
// となり、子要素とその内部の子要素が正しい座標で配置される
|
|
217
|
-
const adjustedParentX = absoluteX + childX - childLayout.left;
|
|
218
|
-
const adjustedParentY = absoluteY + childY - childLayout.top;
|
|
219
|
-
return toPositioned(child, adjustedParentX, adjustedParentY);
|
|
220
|
-
}),
|
|
60
|
+
children: containerNode.children.map((child) => toPositioned(child, ctx, absoluteX, absoluteY)),
|
|
221
61
|
};
|
|
222
62
|
}
|
|
63
|
+
case "absolute-child":
|
|
64
|
+
// absolute-child (layer) は必ずカスタム toPositioned を持つべき
|
|
65
|
+
throw new Error(`Node type "${pom.type}" with category "absolute-child" must have a custom toPositioned`);
|
|
223
66
|
}
|
|
224
67
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -108,11 +108,11 @@ export declare const alignItemsSchema: z.ZodEnum<{
|
|
|
108
108
|
stretch: "stretch";
|
|
109
109
|
}>;
|
|
110
110
|
export declare const alignSelfSchema: z.ZodEnum<{
|
|
111
|
+
auto: "auto";
|
|
111
112
|
start: "start";
|
|
112
113
|
center: "center";
|
|
113
114
|
end: "end";
|
|
114
115
|
stretch: "stretch";
|
|
115
|
-
auto: "auto";
|
|
116
116
|
}>;
|
|
117
117
|
export declare const positionTypeSchema: z.ZodEnum<{
|
|
118
118
|
relative: "relative";
|
|
@@ -378,11 +378,11 @@ declare const basePOMNodeSchema: z.ZodObject<{
|
|
|
378
378
|
bottom: z.ZodOptional<z.ZodNumber>;
|
|
379
379
|
left: z.ZodOptional<z.ZodNumber>;
|
|
380
380
|
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
381
|
+
auto: "auto";
|
|
381
382
|
start: "start";
|
|
382
383
|
center: "center";
|
|
383
384
|
end: "end";
|
|
384
385
|
stretch: "stretch";
|
|
385
|
-
auto: "auto";
|
|
386
386
|
}>>;
|
|
387
387
|
}, z.core.$strip>;
|
|
388
388
|
type BasePOMNode = z.infer<typeof basePOMNodeSchema>;
|
|
@@ -440,11 +440,11 @@ declare const textNodeSchema: z.ZodObject<{
|
|
|
440
440
|
bottom: z.ZodOptional<z.ZodNumber>;
|
|
441
441
|
left: z.ZodOptional<z.ZodNumber>;
|
|
442
442
|
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
443
|
+
auto: "auto";
|
|
443
444
|
start: "start";
|
|
444
445
|
center: "center";
|
|
445
446
|
end: "end";
|
|
446
447
|
stretch: "stretch";
|
|
447
|
-
auto: "auto";
|
|
448
448
|
}>>;
|
|
449
449
|
type: z.ZodLiteral<"text">;
|
|
450
450
|
text: z.ZodString;
|
|
@@ -566,11 +566,11 @@ declare const ulNodeSchema: z.ZodObject<{
|
|
|
566
566
|
bottom: z.ZodOptional<z.ZodNumber>;
|
|
567
567
|
left: z.ZodOptional<z.ZodNumber>;
|
|
568
568
|
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
569
|
+
auto: "auto";
|
|
569
570
|
start: "start";
|
|
570
571
|
center: "center";
|
|
571
572
|
end: "end";
|
|
572
573
|
stretch: "stretch";
|
|
573
|
-
auto: "auto";
|
|
574
574
|
}>>;
|
|
575
575
|
type: z.ZodLiteral<"ul">;
|
|
576
576
|
items: z.ZodArray<z.ZodObject<{
|
|
@@ -691,11 +691,11 @@ declare const olNodeSchema: z.ZodObject<{
|
|
|
691
691
|
bottom: z.ZodOptional<z.ZodNumber>;
|
|
692
692
|
left: z.ZodOptional<z.ZodNumber>;
|
|
693
693
|
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
694
|
+
auto: "auto";
|
|
694
695
|
start: "start";
|
|
695
696
|
center: "center";
|
|
696
697
|
end: "end";
|
|
697
698
|
stretch: "stretch";
|
|
698
|
-
auto: "auto";
|
|
699
699
|
}>>;
|
|
700
700
|
type: z.ZodLiteral<"ol">;
|
|
701
701
|
items: z.ZodArray<z.ZodObject<{
|
|
@@ -835,11 +835,11 @@ declare const imageNodeSchema: z.ZodObject<{
|
|
|
835
835
|
bottom: z.ZodOptional<z.ZodNumber>;
|
|
836
836
|
left: z.ZodOptional<z.ZodNumber>;
|
|
837
837
|
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
838
|
+
auto: "auto";
|
|
838
839
|
start: "start";
|
|
839
840
|
center: "center";
|
|
840
841
|
end: "end";
|
|
841
842
|
stretch: "stretch";
|
|
842
|
-
auto: "auto";
|
|
843
843
|
}>>;
|
|
844
844
|
type: z.ZodLiteral<"image">;
|
|
845
845
|
src: z.ZodString;
|
|
@@ -924,11 +924,11 @@ declare const iconNodeSchema: z.ZodObject<{
|
|
|
924
924
|
bottom: z.ZodOptional<z.ZodNumber>;
|
|
925
925
|
left: z.ZodOptional<z.ZodNumber>;
|
|
926
926
|
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
927
|
+
auto: "auto";
|
|
927
928
|
start: "start";
|
|
928
929
|
center: "center";
|
|
929
930
|
end: "end";
|
|
930
931
|
stretch: "stretch";
|
|
931
|
-
auto: "auto";
|
|
932
932
|
}>>;
|
|
933
933
|
type: z.ZodLiteral<"icon">;
|
|
934
934
|
name: z.ZodEnum<{
|
|
@@ -940,43 +940,6 @@ declare const iconNodeSchema: z.ZodObject<{
|
|
|
940
940
|
export type IconNode = z.infer<typeof iconNodeSchema> & {
|
|
941
941
|
yogaNode?: YogaNode;
|
|
942
942
|
};
|
|
943
|
-
export declare const tableCellSchema: z.ZodObject<{
|
|
944
|
-
text: z.ZodString;
|
|
945
|
-
fontSize: z.ZodOptional<z.ZodNumber>;
|
|
946
|
-
color: z.ZodOptional<z.ZodString>;
|
|
947
|
-
bold: z.ZodOptional<z.ZodBoolean>;
|
|
948
|
-
italic: z.ZodOptional<z.ZodBoolean>;
|
|
949
|
-
underline: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
950
|
-
style: z.ZodOptional<z.ZodEnum<{
|
|
951
|
-
dash: "dash";
|
|
952
|
-
dashHeavy: "dashHeavy";
|
|
953
|
-
dashLong: "dashLong";
|
|
954
|
-
dashLongHeavy: "dashLongHeavy";
|
|
955
|
-
dbl: "dbl";
|
|
956
|
-
dotDash: "dotDash";
|
|
957
|
-
dotDotDash: "dotDotDash";
|
|
958
|
-
dotted: "dotted";
|
|
959
|
-
dottedHeavy: "dottedHeavy";
|
|
960
|
-
heavy: "heavy";
|
|
961
|
-
none: "none";
|
|
962
|
-
sng: "sng";
|
|
963
|
-
wavy: "wavy";
|
|
964
|
-
wavyDbl: "wavyDbl";
|
|
965
|
-
wavyHeavy: "wavyHeavy";
|
|
966
|
-
}>>;
|
|
967
|
-
color: z.ZodOptional<z.ZodString>;
|
|
968
|
-
}, z.core.$strip>]>>;
|
|
969
|
-
strike: z.ZodOptional<z.ZodBoolean>;
|
|
970
|
-
highlight: z.ZodOptional<z.ZodString>;
|
|
971
|
-
textAlign: z.ZodOptional<z.ZodEnum<{
|
|
972
|
-
right: "right";
|
|
973
|
-
left: "left";
|
|
974
|
-
center: "center";
|
|
975
|
-
}>>;
|
|
976
|
-
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
977
|
-
colspan: z.ZodOptional<z.ZodNumber>;
|
|
978
|
-
rowspan: z.ZodOptional<z.ZodNumber>;
|
|
979
|
-
}, z.core.$strip>;
|
|
980
943
|
export declare const tableRowSchema: z.ZodObject<{
|
|
981
944
|
cells: z.ZodArray<z.ZodObject<{
|
|
982
945
|
text: z.ZodString;
|
|
@@ -1074,11 +1037,11 @@ export declare const tableNodeSchema: z.ZodObject<{
|
|
|
1074
1037
|
bottom: z.ZodOptional<z.ZodNumber>;
|
|
1075
1038
|
left: z.ZodOptional<z.ZodNumber>;
|
|
1076
1039
|
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
1040
|
+
auto: "auto";
|
|
1077
1041
|
start: "start";
|
|
1078
1042
|
center: "center";
|
|
1079
1043
|
end: "end";
|
|
1080
1044
|
stretch: "stretch";
|
|
1081
|
-
auto: "auto";
|
|
1082
1045
|
}>>;
|
|
1083
1046
|
type: z.ZodLiteral<"table">;
|
|
1084
1047
|
columns: z.ZodArray<z.ZodObject<{
|
|
@@ -1180,11 +1143,11 @@ declare const shapeNodeSchema: z.ZodObject<{
|
|
|
1180
1143
|
bottom: z.ZodOptional<z.ZodNumber>;
|
|
1181
1144
|
left: z.ZodOptional<z.ZodNumber>;
|
|
1182
1145
|
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
1146
|
+
auto: "auto";
|
|
1183
1147
|
start: "start";
|
|
1184
1148
|
center: "center";
|
|
1185
1149
|
end: "end";
|
|
1186
1150
|
stretch: "stretch";
|
|
1187
|
-
auto: "auto";
|
|
1188
1151
|
}>>;
|
|
1189
1152
|
type: z.ZodLiteral<"shape">;
|
|
1190
1153
|
shapeType: z.ZodEnum<{
|
|
@@ -1503,11 +1466,11 @@ declare const chartNodeSchema: z.ZodObject<{
|
|
|
1503
1466
|
bottom: z.ZodOptional<z.ZodNumber>;
|
|
1504
1467
|
left: z.ZodOptional<z.ZodNumber>;
|
|
1505
1468
|
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
1469
|
+
auto: "auto";
|
|
1506
1470
|
start: "start";
|
|
1507
1471
|
center: "center";
|
|
1508
1472
|
end: "end";
|
|
1509
1473
|
stretch: "stretch";
|
|
1510
|
-
auto: "auto";
|
|
1511
1474
|
}>>;
|
|
1512
1475
|
type: z.ZodLiteral<"chart">;
|
|
1513
1476
|
chartType: z.ZodEnum<{
|
|
@@ -1605,11 +1568,11 @@ export declare const timelineNodeSchema: z.ZodObject<{
|
|
|
1605
1568
|
bottom: z.ZodOptional<z.ZodNumber>;
|
|
1606
1569
|
left: z.ZodOptional<z.ZodNumber>;
|
|
1607
1570
|
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
1571
|
+
auto: "auto";
|
|
1608
1572
|
start: "start";
|
|
1609
1573
|
center: "center";
|
|
1610
1574
|
end: "end";
|
|
1611
1575
|
stretch: "stretch";
|
|
1612
|
-
auto: "auto";
|
|
1613
1576
|
}>>;
|
|
1614
1577
|
type: z.ZodLiteral<"timeline">;
|
|
1615
1578
|
direction: z.ZodOptional<z.ZodEnum<{
|
|
@@ -1694,11 +1657,11 @@ export declare const matrixNodeSchema: z.ZodObject<{
|
|
|
1694
1657
|
bottom: z.ZodOptional<z.ZodNumber>;
|
|
1695
1658
|
left: z.ZodOptional<z.ZodNumber>;
|
|
1696
1659
|
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
1660
|
+
auto: "auto";
|
|
1697
1661
|
start: "start";
|
|
1698
1662
|
center: "center";
|
|
1699
1663
|
end: "end";
|
|
1700
1664
|
stretch: "stretch";
|
|
1701
|
-
auto: "auto";
|
|
1702
1665
|
}>>;
|
|
1703
1666
|
type: z.ZodLiteral<"matrix">;
|
|
1704
1667
|
axes: z.ZodObject<{
|
|
@@ -1791,11 +1754,11 @@ export declare const treeNodeSchema: z.ZodObject<{
|
|
|
1791
1754
|
bottom: z.ZodOptional<z.ZodNumber>;
|
|
1792
1755
|
left: z.ZodOptional<z.ZodNumber>;
|
|
1793
1756
|
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
1757
|
+
auto: "auto";
|
|
1794
1758
|
start: "start";
|
|
1795
1759
|
center: "center";
|
|
1796
1760
|
end: "end";
|
|
1797
1761
|
stretch: "stretch";
|
|
1798
|
-
auto: "auto";
|
|
1799
1762
|
}>>;
|
|
1800
1763
|
type: z.ZodLiteral<"tree">;
|
|
1801
1764
|
layout: z.ZodOptional<z.ZodEnum<{
|
|
@@ -1883,11 +1846,11 @@ export declare const processArrowNodeSchema: z.ZodObject<{
|
|
|
1883
1846
|
bottom: z.ZodOptional<z.ZodNumber>;
|
|
1884
1847
|
left: z.ZodOptional<z.ZodNumber>;
|
|
1885
1848
|
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
1849
|
+
auto: "auto";
|
|
1886
1850
|
start: "start";
|
|
1887
1851
|
center: "center";
|
|
1888
1852
|
end: "end";
|
|
1889
1853
|
stretch: "stretch";
|
|
1890
|
-
auto: "auto";
|
|
1891
1854
|
}>>;
|
|
1892
1855
|
type: z.ZodLiteral<"processArrow">;
|
|
1893
1856
|
direction: z.ZodOptional<z.ZodEnum<{
|
|
@@ -1992,11 +1955,11 @@ export declare const pyramidNodeSchema: z.ZodObject<{
|
|
|
1992
1955
|
bottom: z.ZodOptional<z.ZodNumber>;
|
|
1993
1956
|
left: z.ZodOptional<z.ZodNumber>;
|
|
1994
1957
|
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
1958
|
+
auto: "auto";
|
|
1995
1959
|
start: "start";
|
|
1996
1960
|
center: "center";
|
|
1997
1961
|
end: "end";
|
|
1998
1962
|
stretch: "stretch";
|
|
1999
|
-
auto: "auto";
|
|
2000
1963
|
}>>;
|
|
2001
1964
|
type: z.ZodLiteral<"pyramid">;
|
|
2002
1965
|
direction: z.ZodOptional<z.ZodEnum<{
|
|
@@ -2110,11 +2073,11 @@ export declare const flowNodeSchema: z.ZodObject<{
|
|
|
2110
2073
|
bottom: z.ZodOptional<z.ZodNumber>;
|
|
2111
2074
|
left: z.ZodOptional<z.ZodNumber>;
|
|
2112
2075
|
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
2076
|
+
auto: "auto";
|
|
2113
2077
|
start: "start";
|
|
2114
2078
|
center: "center";
|
|
2115
2079
|
end: "end";
|
|
2116
2080
|
stretch: "stretch";
|
|
2117
|
-
auto: "auto";
|
|
2118
2081
|
}>>;
|
|
2119
2082
|
type: z.ZodLiteral<"flow">;
|
|
2120
2083
|
direction: z.ZodOptional<z.ZodEnum<{
|
|
@@ -2230,11 +2193,11 @@ declare const lineNodeSchema: z.ZodObject<{
|
|
|
2230
2193
|
bottom: z.ZodOptional<z.ZodNumber>;
|
|
2231
2194
|
left: z.ZodOptional<z.ZodNumber>;
|
|
2232
2195
|
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
2196
|
+
auto: "auto";
|
|
2233
2197
|
start: "start";
|
|
2234
2198
|
center: "center";
|
|
2235
2199
|
end: "end";
|
|
2236
2200
|
stretch: "stretch";
|
|
2237
|
-
auto: "auto";
|
|
2238
2201
|
}>>;
|
|
2239
2202
|
type: z.ZodLiteral<"line">;
|
|
2240
2203
|
x1: z.ZodNumber;
|