@hirokisakabe/pom 7.1.0 → 7.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 +3 -1
- package/dist/icons/renderIcon.d.ts +1 -1
- package/dist/icons/renderIcon.d.ts.map +1 -1
- package/dist/icons/renderIcon.js +5 -4
- package/dist/parseXml/coercionRules.d.ts +18 -0
- package/dist/parseXml/coercionRules.d.ts.map +1 -1
- package/dist/parseXml/coercionRules.js +50 -0
- package/dist/parseXml/parseXml.d.ts.map +1 -1
- package/dist/parseXml/parseXml.js +41 -30
- package/dist/registry/definitions/icon.d.ts.map +1 -1
- package/dist/registry/definitions/icon.js +2 -4
- package/dist/registry/definitions/svg.d.ts +3 -0
- package/dist/registry/definitions/svg.d.ts.map +1 -0
- package/dist/registry/definitions/svg.js +29 -0
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +2 -0
- package/dist/renderPptx/nodes/svg.d.ts +8 -0
- package/dist/renderPptx/nodes/svg.d.ts.map +1 -0
- package/dist/renderPptx/nodes/svg.js +10 -0
- package/dist/types.d.ts +80 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +12 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
- **AI Friendly** — Simple XML structure designed for LLM code generation. Include [llm.txt](./website/public/llm.txt) in your system prompt for XML reference. Also available at `https://pom.pptx.app/llm.txt`.
|
|
39
39
|
- **Declarative** — Describe slides as XML. No imperative API calls needed — just data in, PPTX out.
|
|
40
40
|
- **Flexible Layout** — Flexbox-style layout with VStack / HStack, powered by yoga-layout.
|
|
41
|
+
- **Shorthand + Dot Notation** — Layout/style attributes (e.g. `padding`, `margin`, `border`, `fill`, `shadow`) can mix shorthand and dot notation on the same node. Shorthand sets defaults and dot notation overrides specific keys.
|
|
41
42
|
- **Rich Nodes** — 18 built-in node types: charts, flowcharts, tables, timelines, org trees, and more.
|
|
42
43
|
- **Schema-validated** — XML input is validated with Zod schemas at runtime with clear error messages.
|
|
43
44
|
- **PowerPoint Native** — Generates real editable PowerPoint shapes — not images. Recipients can modify everything.
|
|
@@ -88,7 +89,8 @@ await pptx.writeFile({ fileName: "presentation.pptx" });
|
|
|
88
89
|
| Layer | Absolute-positioned overlay container |
|
|
89
90
|
| VStack | Vertical stack layout |
|
|
90
91
|
| HStack | Horizontal stack layout |
|
|
91
|
-
| Icon | Lucide icons
|
|
92
|
+
| Icon | Lucide icons |
|
|
93
|
+
| Svg | Inline SVG graphics |
|
|
92
94
|
|
|
93
95
|
For detailed node documentation, see [Nodes](./docs/nodes.md).
|
|
94
96
|
|
|
@@ -3,5 +3,5 @@ export declare function rasterizeIcon(name: string, size: number, color: string,
|
|
|
3
3
|
* インライン SVG 文字列を指定サイズでラスタライズし、base64 PNG を返す。
|
|
4
4
|
* color が指定された場合、SVG ルートに stroke / fill 属性を設定する。
|
|
5
5
|
*/
|
|
6
|
-
export declare function rasterizeSvgContent(svgContent: string,
|
|
6
|
+
export declare function rasterizeSvgContent(svgContent: string, width: number, color: string | undefined, cache: Map<string, string>, height?: number): Promise<string>;
|
|
7
7
|
//# sourceMappingURL=renderIcon.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderIcon.d.ts","sourceRoot":"","sources":["../../src/icons/renderIcon.ts"],"names":[],"mappings":"AA2DA,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACzB,OAAO,CAAC,MAAM,CAAC,CAcjB;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,
|
|
1
|
+
{"version":3,"file":"renderIcon.d.ts","sourceRoot":"","sources":["../../src/icons/renderIcon.ts"],"names":[],"mappings":"AA2DA,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACzB,OAAO,CAAC,MAAM,CAAC,CAcjB;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC1B,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CA0CjB"}
|
package/dist/icons/renderIcon.js
CHANGED
|
@@ -68,8 +68,9 @@ export async function rasterizeIcon(name, size, color, cache) {
|
|
|
68
68
|
* インライン SVG 文字列を指定サイズでラスタライズし、base64 PNG を返す。
|
|
69
69
|
* color が指定された場合、SVG ルートに stroke / fill 属性を設定する。
|
|
70
70
|
*/
|
|
71
|
-
export async function rasterizeSvgContent(svgContent,
|
|
72
|
-
const
|
|
71
|
+
export async function rasterizeSvgContent(svgContent, width, color, cache, height) {
|
|
72
|
+
const h = height ?? width;
|
|
73
|
+
const key = `svg:${svgContent}|${width}|${h}|${color ?? ""}`;
|
|
73
74
|
const cached = cache.get(key);
|
|
74
75
|
if (cached)
|
|
75
76
|
return cached;
|
|
@@ -84,7 +85,7 @@ export async function rasterizeSvgContent(svgContent, size, color, cache) {
|
|
|
84
85
|
let newAttrs = attrs
|
|
85
86
|
.replace(/\bwidth\s*=\s*"[^"]*"/g, "")
|
|
86
87
|
.replace(/\bheight\s*=\s*"[^"]*"/g, "");
|
|
87
|
-
newAttrs += ` width="${
|
|
88
|
+
newAttrs += ` width="${width}" height="${h}"`;
|
|
88
89
|
// color 指定時は stroke / fill を設定(プリセットアイコンとの一貫性)
|
|
89
90
|
if (color) {
|
|
90
91
|
if (!attrs.includes("stroke=")) {
|
|
@@ -98,7 +99,7 @@ export async function rasterizeSvgContent(svgContent, size, color, cache) {
|
|
|
98
99
|
});
|
|
99
100
|
await ensureWasmInitialized();
|
|
100
101
|
const Resvg = getResvg();
|
|
101
|
-
const resvg = new Resvg(svg, { fitTo: { mode: "width", value:
|
|
102
|
+
const resvg = new Resvg(svg, { fitTo: { mode: "width", value: width } });
|
|
102
103
|
const pngData = resvg.render();
|
|
103
104
|
const pngBuffer = pngData.asPng();
|
|
104
105
|
const result = `image/png;base64,${Buffer.from(pngBuffer).toString("base64")}`;
|
|
@@ -30,6 +30,24 @@ export declare function getObjectShapeFromRule(rule: CoercionRule): Record<strin
|
|
|
30
30
|
* endArrow="true" と endArrow.type="triangle" の共存を許可するために使用。
|
|
31
31
|
*/
|
|
32
32
|
export declare function isBooleanObjectUnionRule(rule: CoercionRule): boolean;
|
|
33
|
+
type ResolvedMixedNotationShorthand = {
|
|
34
|
+
mode: "merge";
|
|
35
|
+
value: Record<string, unknown>;
|
|
36
|
+
} | {
|
|
37
|
+
mode: "ignore";
|
|
38
|
+
} | {
|
|
39
|
+
mode: "conflict";
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* 同一属性で shorthand と dot notation を併用したときに、
|
|
43
|
+
* shorthand 側をどのように扱うかを解決する。
|
|
44
|
+
*
|
|
45
|
+
* - merge: shorthand をオブジェクト化して dot notation 側で上書き
|
|
46
|
+
* - ignore: boolean shorthand を無視して dot notation を優先
|
|
47
|
+
* - conflict: 併用不可(従来どおりエラー)
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveMixedNotationShorthand(value: string, rule: CoercionRule): ResolvedMixedNotationShorthand;
|
|
33
50
|
export declare const NODE_COERCION_MAP: Record<string, Record<string, CoercionRule>>;
|
|
34
51
|
export declare const CHILD_ELEMENT_COERCION_MAP: Record<string, Record<string, CoercionRule>>;
|
|
52
|
+
export {};
|
|
35
53
|
//# sourceMappingURL=coercionRules.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coercionRules.d.ts","sourceRoot":"","sources":["../../src/parseXml/coercionRules.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,MAAM,GACN;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,YAAY,EAAE,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;CAAE,CAAC;AAI5D,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,YAAY,GACjB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAyD1C;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,YAAY,EAAE,GACtB,OAAO,CAuCT;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAarD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,YAAY,GACjB,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,SAAS,CAY1C;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAQpE;AA8HD,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"coercionRules.d.ts","sourceRoot":"","sources":["../../src/parseXml/coercionRules.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,MAAM,GACN;IAAE,IAAI,EAAE,SAAS,CAAC;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E,MAAM,CAC7C,MAAM,EACN,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAgF7B,CAAC"}
|
|
@@ -143,6 +143,52 @@ export function isBooleanObjectUnionRule(rule) {
|
|
|
143
143
|
const hasObject = rule.options.some((opt) => typeof opt === "object" && opt.type === "object");
|
|
144
144
|
return hasBoolean && hasObject;
|
|
145
145
|
}
|
|
146
|
+
function isPlainObject(value) {
|
|
147
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
148
|
+
}
|
|
149
|
+
function isDirectionalBoxShape(shape) {
|
|
150
|
+
const keys = Object.keys(shape).sort();
|
|
151
|
+
return (keys.length === 4 &&
|
|
152
|
+
keys[0] === "bottom" &&
|
|
153
|
+
keys[1] === "left" &&
|
|
154
|
+
keys[2] === "right" &&
|
|
155
|
+
keys[3] === "top");
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* 同一属性で shorthand と dot notation を併用したときに、
|
|
159
|
+
* shorthand 側をどのように扱うかを解決する。
|
|
160
|
+
*
|
|
161
|
+
* - merge: shorthand をオブジェクト化して dot notation 側で上書き
|
|
162
|
+
* - ignore: boolean shorthand を無視して dot notation を優先
|
|
163
|
+
* - conflict: 併用不可(従来どおりエラー)
|
|
164
|
+
*/
|
|
165
|
+
export function resolveMixedNotationShorthand(value, rule) {
|
|
166
|
+
const objectShape = getObjectShapeFromRule(rule);
|
|
167
|
+
if (!objectShape)
|
|
168
|
+
return { mode: "conflict" };
|
|
169
|
+
if (isBooleanObjectUnionRule(rule) &&
|
|
170
|
+
(value === "true" || value === "false")) {
|
|
171
|
+
return { mode: "ignore" };
|
|
172
|
+
}
|
|
173
|
+
const coerced = coerceWithRule(value, rule);
|
|
174
|
+
if (coerced.error !== null)
|
|
175
|
+
return { mode: "conflict" };
|
|
176
|
+
if (isPlainObject(coerced.value)) {
|
|
177
|
+
return { mode: "merge", value: coerced.value };
|
|
178
|
+
}
|
|
179
|
+
if (typeof coerced.value === "number" && isDirectionalBoxShape(objectShape)) {
|
|
180
|
+
return {
|
|
181
|
+
mode: "merge",
|
|
182
|
+
value: {
|
|
183
|
+
top: coerced.value,
|
|
184
|
+
right: coerced.value,
|
|
185
|
+
bottom: coerced.value,
|
|
186
|
+
left: coerced.value,
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
return { mode: "conflict" };
|
|
191
|
+
}
|
|
146
192
|
// ===== 共通変換ルール =====
|
|
147
193
|
const LENGTH_RULE = {
|
|
148
194
|
type: "union",
|
|
@@ -284,6 +330,10 @@ export const NODE_COERCION_MAP = {
|
|
|
284
330
|
variant: "string",
|
|
285
331
|
bgColor: "string",
|
|
286
332
|
},
|
|
333
|
+
svg: {
|
|
334
|
+
...BASE_RULES,
|
|
335
|
+
color: "string",
|
|
336
|
+
},
|
|
287
337
|
table: {
|
|
288
338
|
...BASE_RULES,
|
|
289
339
|
columns: "json",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseXml.d.ts","sourceRoot":"","sources":["../../src/parseXml/parseXml.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,OAAO,EAgBb,MAAM,aAAa,CAAC;AAYrB,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAgB,MAAM,EAAE,MAAM,EAAE,CAAC;gBACrB,MAAM,EAAE,MAAM,EAAE;CAM7B;AAGD,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"parseXml.d.ts","sourceRoot":"","sources":["../../src/parseXml/parseXml.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,OAAO,EAgBb,MAAM,aAAa,CAAC;AAYrB,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAgB,MAAM,EAAE,MAAM,EAAE,CAAC;gBACrB,MAAM,EAAE,MAAM,EAAE;CAM7B;AAGD,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAoB9C,CAAC;AA6oCF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,EAAE,CAiCrD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { XMLBuilder, XMLParser } from "fast-xml-parser";
|
|
2
2
|
import { textNodeSchema, ulNodeSchema, olNodeSchema, imageNodeSchema, tableNodeSchema, shapeNodeSchema, chartNodeSchema, timelineNodeSchema, matrixNodeSchema, treeNodeSchema, flowNodeSchema, processArrowNodeSchema, pyramidNodeSchema, lineNodeSchema, iconNodeSchema, } from "../types.js";
|
|
3
|
-
import { NODE_COERCION_MAP, CHILD_ELEMENT_COERCION_MAP, coerceWithRule, coerceFallback, getObjectShapeFromRule,
|
|
3
|
+
import { NODE_COERCION_MAP, CHILD_ELEMENT_COERCION_MAP, coerceWithRule, coerceFallback, getObjectShapeFromRule, resolveMixedNotationShorthand, } from "./coercionRules.js";
|
|
4
4
|
// ===== ParseXmlError =====
|
|
5
5
|
export class ParseXmlError extends Error {
|
|
6
6
|
errors;
|
|
@@ -31,6 +31,7 @@ export const TAG_TO_TYPE = {
|
|
|
31
31
|
HStack: "hstack",
|
|
32
32
|
Layer: "layer",
|
|
33
33
|
Icon: "icon",
|
|
34
|
+
Svg: "svg",
|
|
34
35
|
};
|
|
35
36
|
// Reverse mapping: node type → tag name
|
|
36
37
|
const TYPE_TO_TAG = Object.fromEntries(Object.entries(TAG_TO_TYPE).map(([tag, type]) => [type, tag]));
|
|
@@ -159,7 +160,8 @@ const CHILD_ELEMENT_PROPS = {
|
|
|
159
160
|
tree: new Set(["data"]),
|
|
160
161
|
ul: new Set(["items"]),
|
|
161
162
|
ol: new Set(["items"]),
|
|
162
|
-
icon: new Set(["name"
|
|
163
|
+
icon: new Set(["name"]),
|
|
164
|
+
svg: new Set(["svgContent"]),
|
|
163
165
|
};
|
|
164
166
|
function validateLeafNode(nodeType, result, errors) {
|
|
165
167
|
const schema = leafNodeValidationSchemas[nodeType];
|
|
@@ -381,14 +383,18 @@ function coerceChildAttrs(parentTagName, tagName, attrs, errors) {
|
|
|
381
383
|
// Process regular attributes
|
|
382
384
|
for (const [key, value] of Object.entries(regularAttrs)) {
|
|
383
385
|
if (key in dotGroups) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
(
|
|
390
|
-
|
|
391
|
-
|
|
386
|
+
if (rules && rules[key]) {
|
|
387
|
+
const resolved = resolveMixedNotationShorthand(value, rules[key]);
|
|
388
|
+
if (resolved.mode === "ignore") {
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
if (resolved.mode === "merge") {
|
|
392
|
+
result[key] = {
|
|
393
|
+
...resolved.value,
|
|
394
|
+
...result[key],
|
|
395
|
+
};
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
392
398
|
}
|
|
393
399
|
errors.push(`<${parentTagName}>.<${tagName}>: Attribute "${key}" conflicts with dot-notation attributes. Use one or the other, not both`);
|
|
394
400
|
continue;
|
|
@@ -674,20 +680,15 @@ const svgBuilder = new XMLBuilder({
|
|
|
674
680
|
function serializeSvgElement(svgElement) {
|
|
675
681
|
return String(svgBuilder.build([svgElement]));
|
|
676
682
|
}
|
|
677
|
-
function
|
|
683
|
+
function convertSvgChildren(childElements, result, errors) {
|
|
678
684
|
if (childElements.length !== 1) {
|
|
679
|
-
errors.push(`<
|
|
685
|
+
errors.push(`<Svg>: Expected exactly one <svg> child element, but found ${childElements.length} child element(s)`);
|
|
680
686
|
return;
|
|
681
687
|
}
|
|
682
688
|
const child = childElements[0];
|
|
683
689
|
const tag = getTagName(child);
|
|
684
690
|
if (tag !== "svg") {
|
|
685
|
-
errors.push(`<
|
|
686
|
-
return;
|
|
687
|
-
}
|
|
688
|
-
// name と svg の排他バリデーション
|
|
689
|
-
if (result.name !== undefined) {
|
|
690
|
-
errors.push('<Icon>: Cannot specify both "name" attribute and <svg> child element');
|
|
691
|
+
errors.push(`<Svg>: Expected <svg> child element, but found <${tag}>`);
|
|
691
692
|
return;
|
|
692
693
|
}
|
|
693
694
|
result.svgContent = serializeSvgElement(child);
|
|
@@ -721,7 +722,7 @@ const CHILD_ELEMENT_CONVERTERS = {
|
|
|
721
722
|
chart: convertChartChildren,
|
|
722
723
|
table: convertTableChildren,
|
|
723
724
|
tree: convertTreeChildren,
|
|
724
|
-
|
|
725
|
+
svg: convertSvgChildren,
|
|
725
726
|
};
|
|
726
727
|
// ===== Node conversion =====
|
|
727
728
|
function convertElement(node, errors) {
|
|
@@ -765,14 +766,19 @@ function convertPomNode(nodeType, tagName, attrs, childElements, textContent, er
|
|
|
765
766
|
continue;
|
|
766
767
|
// Conflict check: dot-notation and regular attribute for the same key
|
|
767
768
|
if (key in dotGroups) {
|
|
768
|
-
// When the rule is a union of boolean and object (e.g., endArrow),
|
|
769
|
-
// allow boolean shorthand to coexist with dot-notation by ignoring the boolean value.
|
|
770
769
|
const ruleForConflict = getCoercionRule(nodeType, key);
|
|
771
|
-
if (ruleForConflict
|
|
772
|
-
|
|
773
|
-
(
|
|
774
|
-
|
|
775
|
-
|
|
770
|
+
if (ruleForConflict) {
|
|
771
|
+
const resolved = resolveMixedNotationShorthand(value, ruleForConflict);
|
|
772
|
+
if (resolved.mode === "ignore") {
|
|
773
|
+
continue;
|
|
774
|
+
}
|
|
775
|
+
if (resolved.mode === "merge") {
|
|
776
|
+
result[key] = {
|
|
777
|
+
...resolved.value,
|
|
778
|
+
...result[key],
|
|
779
|
+
};
|
|
780
|
+
continue;
|
|
781
|
+
}
|
|
776
782
|
}
|
|
777
783
|
errors.push(`<${tagName}>: Attribute "${key}" conflicts with dot-notation attributes (e.g., "${key}.xxx"). Use one or the other, not both`);
|
|
778
784
|
continue;
|
|
@@ -831,7 +837,7 @@ function convertPomNode(nodeType, tagName, attrs, childElements, textContent, er
|
|
|
831
837
|
if (!CONTAINER_TYPES.has(nodeType)) {
|
|
832
838
|
validateLeafNode(nodeType, result, errors);
|
|
833
839
|
}
|
|
834
|
-
// Icon: normalize color / bgColor
|
|
840
|
+
// Icon: normalize color / bgColor
|
|
835
841
|
if (nodeType === "icon") {
|
|
836
842
|
if (typeof result.color === "string" && !result.color.startsWith("#")) {
|
|
837
843
|
result.color = `#${result.color}`;
|
|
@@ -839,9 +845,14 @@ function convertPomNode(nodeType, tagName, attrs, childElements, textContent, er
|
|
|
839
845
|
if (typeof result.bgColor === "string" && !result.bgColor.startsWith("#")) {
|
|
840
846
|
result.bgColor = `#${result.bgColor}`;
|
|
841
847
|
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
848
|
+
}
|
|
849
|
+
// Svg: normalize color and validate svgContent
|
|
850
|
+
if (nodeType === "svg") {
|
|
851
|
+
if (typeof result.color === "string" && !result.color.startsWith("#")) {
|
|
852
|
+
result.color = `#${result.color}`;
|
|
853
|
+
}
|
|
854
|
+
if (result.svgContent === undefined) {
|
|
855
|
+
errors.push("<Svg>: A <svg> child element is required");
|
|
845
856
|
}
|
|
846
857
|
}
|
|
847
858
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../src/registry/definitions/icon.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKlD,eAAO,MAAM,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../src/registry/definitions/icon.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKlD,eAAO,MAAM,WAAW,EAAE,cAqEzB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { rasterizeIcon
|
|
1
|
+
import { rasterizeIcon } from "../../icons/index.js";
|
|
2
2
|
import { renderIconNode } from "../../renderPptx/nodes/icon.js";
|
|
3
3
|
import { getContentArea } from "../../renderPptx/utils/contentArea.js";
|
|
4
4
|
export const iconNodeDef = {
|
|
@@ -24,9 +24,7 @@ export const iconNodeDef = {
|
|
|
24
24
|
});
|
|
25
25
|
// 実描画サイズに合わせてラスタライズ(不要に大きい PNG を防ぐ)
|
|
26
26
|
const rasterSize = Math.max(Math.ceil(n.variant ? iconSize : Math.min(content.w, content.h)), iconSize);
|
|
27
|
-
const iconImageData = n.
|
|
28
|
-
? await rasterizeSvgContent(n.svgContent, rasterSize, n.color, ctx.iconRasterCache)
|
|
29
|
-
: await rasterizeIcon(n.name, rasterSize, n.color ?? "#000000", ctx.iconRasterCache);
|
|
27
|
+
const iconImageData = await rasterizeIcon(n.name, rasterSize, n.color ?? "#000000", ctx.iconRasterCache);
|
|
30
28
|
const positioned = {
|
|
31
29
|
...n,
|
|
32
30
|
x: absoluteX,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../../../src/registry/definitions/svg.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIlD,eAAO,MAAM,UAAU,EAAE,cAiCxB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { rasterizeSvgContent } from "../../icons/index.js";
|
|
2
|
+
import { renderSvgNode } from "../../renderPptx/nodes/svg.js";
|
|
3
|
+
export const svgNodeDef = {
|
|
4
|
+
type: "svg",
|
|
5
|
+
category: "leaf",
|
|
6
|
+
applyYogaStyle(node, yn) {
|
|
7
|
+
const n = node;
|
|
8
|
+
const width = n.w ?? 24;
|
|
9
|
+
const height = n.h ?? 24;
|
|
10
|
+
yn.setMeasureFunc(() => ({ width, height }));
|
|
11
|
+
},
|
|
12
|
+
async toPositioned(pom, absoluteX, absoluteY, layout, ctx) {
|
|
13
|
+
const n = pom;
|
|
14
|
+
const rasterWidth = Math.ceil(layout.width);
|
|
15
|
+
const rasterHeight = Math.ceil(layout.height);
|
|
16
|
+
const iconImageData = await rasterizeSvgContent(n.svgContent, rasterWidth, n.color, ctx.iconRasterCache, rasterHeight);
|
|
17
|
+
return {
|
|
18
|
+
...n,
|
|
19
|
+
x: absoluteX,
|
|
20
|
+
y: absoluteY,
|
|
21
|
+
w: layout.width,
|
|
22
|
+
h: layout.height,
|
|
23
|
+
iconImageData,
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
render(node, ctx) {
|
|
27
|
+
renderSvgNode(node, ctx);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AA0CA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/registry/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { lineNodeDef } from "./definitions/line.js";
|
|
|
10
10
|
import { timelineNodeDef, matrixNodeDef, treeNodeDef, flowNodeDef, processArrowNodeDef, pyramidNodeDef, } from "./definitions/compositeNodes.js";
|
|
11
11
|
import { vstackNodeDef, hstackNodeDef } from "./definitions/stack.js";
|
|
12
12
|
import { layerNodeDef } from "./definitions/layer.js";
|
|
13
|
+
import { svgNodeDef } from "./definitions/svg.js";
|
|
13
14
|
// 全ノード定義を登録
|
|
14
15
|
registerNode(textNodeDef);
|
|
15
16
|
registerNode(ulNodeDef);
|
|
@@ -29,4 +30,5 @@ registerNode(pyramidNodeDef);
|
|
|
29
30
|
registerNode(vstackNodeDef);
|
|
30
31
|
registerNode(hstackNodeDef);
|
|
31
32
|
registerNode(layerNodeDef);
|
|
33
|
+
registerNode(svgNodeDef);
|
|
32
34
|
export { getNodeDef } from "./nodeRegistry.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PositionedNode } from "../../types.ts";
|
|
2
|
+
import type { RenderContext } from "../types.ts";
|
|
3
|
+
type SvgPositionedNode = Extract<PositionedNode, {
|
|
4
|
+
type: "svg";
|
|
5
|
+
}>;
|
|
6
|
+
export declare function renderSvgNode(node: SvgPositionedNode, ctx: RenderContext): void;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=svg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/svg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,KAAK,iBAAiB,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC;AAElE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,iBAAiB,EACvB,GAAG,EAAE,aAAa,GACjB,IAAI,CAQN"}
|
package/dist/types.d.ts
CHANGED
|
@@ -764,10 +764,9 @@ export declare const iconNodeSchema: z.ZodObject<{
|
|
|
764
764
|
color: z.ZodOptional<z.ZodString>;
|
|
765
765
|
}, z.core.$strip>>;
|
|
766
766
|
type: z.ZodLiteral<"icon">;
|
|
767
|
-
name: z.
|
|
767
|
+
name: z.ZodEnum<{
|
|
768
768
|
[x: string]: string;
|
|
769
|
-
}
|
|
770
|
-
svgContent: z.ZodOptional<z.ZodString>;
|
|
769
|
+
}>;
|
|
771
770
|
size: z.ZodOptional<z.ZodNumber>;
|
|
772
771
|
color: z.ZodOptional<z.ZodString>;
|
|
773
772
|
variant: z.ZodOptional<z.ZodEnum<{
|
|
@@ -779,6 +778,81 @@ export declare const iconNodeSchema: z.ZodObject<{
|
|
|
779
778
|
bgColor: z.ZodOptional<z.ZodString>;
|
|
780
779
|
}, z.core.$strip>;
|
|
781
780
|
export type IconNode = z.infer<typeof iconNodeSchema>;
|
|
781
|
+
export declare const svgNodeSchema: z.ZodObject<{
|
|
782
|
+
minW: z.ZodOptional<z.ZodNumber>;
|
|
783
|
+
maxW: z.ZodOptional<z.ZodNumber>;
|
|
784
|
+
minH: z.ZodOptional<z.ZodNumber>;
|
|
785
|
+
maxH: z.ZodOptional<z.ZodNumber>;
|
|
786
|
+
padding: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
|
|
787
|
+
top: z.ZodOptional<z.ZodNumber>;
|
|
788
|
+
right: z.ZodOptional<z.ZodNumber>;
|
|
789
|
+
bottom: z.ZodOptional<z.ZodNumber>;
|
|
790
|
+
left: z.ZodOptional<z.ZodNumber>;
|
|
791
|
+
}, z.core.$strip>]>>;
|
|
792
|
+
margin: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
|
|
793
|
+
top: z.ZodOptional<z.ZodNumber>;
|
|
794
|
+
right: z.ZodOptional<z.ZodNumber>;
|
|
795
|
+
bottom: z.ZodOptional<z.ZodNumber>;
|
|
796
|
+
left: z.ZodOptional<z.ZodNumber>;
|
|
797
|
+
}, z.core.$strip>]>>;
|
|
798
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
799
|
+
backgroundImage: z.ZodOptional<z.ZodObject<{
|
|
800
|
+
src: z.ZodString;
|
|
801
|
+
sizing: z.ZodOptional<z.ZodEnum<{
|
|
802
|
+
cover: "cover";
|
|
803
|
+
contain: "contain";
|
|
804
|
+
}>>;
|
|
805
|
+
}, z.core.$strip>>;
|
|
806
|
+
border: z.ZodOptional<z.ZodObject<{
|
|
807
|
+
color: z.ZodOptional<z.ZodString>;
|
|
808
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
809
|
+
dashType: z.ZodOptional<z.ZodEnum<{
|
|
810
|
+
solid: "solid";
|
|
811
|
+
dash: "dash";
|
|
812
|
+
dashDot: "dashDot";
|
|
813
|
+
lgDash: "lgDash";
|
|
814
|
+
lgDashDot: "lgDashDot";
|
|
815
|
+
lgDashDotDot: "lgDashDotDot";
|
|
816
|
+
sysDash: "sysDash";
|
|
817
|
+
sysDot: "sysDot";
|
|
818
|
+
}>>;
|
|
819
|
+
}, z.core.$strip>>;
|
|
820
|
+
borderRadius: z.ZodOptional<z.ZodNumber>;
|
|
821
|
+
opacity: z.ZodOptional<z.ZodNumber>;
|
|
822
|
+
zIndex: z.ZodOptional<z.ZodNumber>;
|
|
823
|
+
position: z.ZodOptional<z.ZodEnum<{
|
|
824
|
+
relative: "relative";
|
|
825
|
+
absolute: "absolute";
|
|
826
|
+
}>>;
|
|
827
|
+
top: z.ZodOptional<z.ZodNumber>;
|
|
828
|
+
right: z.ZodOptional<z.ZodNumber>;
|
|
829
|
+
bottom: z.ZodOptional<z.ZodNumber>;
|
|
830
|
+
left: z.ZodOptional<z.ZodNumber>;
|
|
831
|
+
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
832
|
+
auto: "auto";
|
|
833
|
+
start: "start";
|
|
834
|
+
center: "center";
|
|
835
|
+
end: "end";
|
|
836
|
+
stretch: "stretch";
|
|
837
|
+
}>>;
|
|
838
|
+
shadow: z.ZodOptional<z.ZodObject<{
|
|
839
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
840
|
+
outer: "outer";
|
|
841
|
+
inner: "inner";
|
|
842
|
+
}>>;
|
|
843
|
+
opacity: z.ZodOptional<z.ZodNumber>;
|
|
844
|
+
blur: z.ZodOptional<z.ZodNumber>;
|
|
845
|
+
angle: z.ZodOptional<z.ZodNumber>;
|
|
846
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
847
|
+
color: z.ZodOptional<z.ZodString>;
|
|
848
|
+
}, z.core.$strip>>;
|
|
849
|
+
type: z.ZodLiteral<"svg">;
|
|
850
|
+
svgContent: z.ZodString;
|
|
851
|
+
w: z.ZodOptional<z.ZodNumber>;
|
|
852
|
+
h: z.ZodOptional<z.ZodNumber>;
|
|
853
|
+
color: z.ZodOptional<z.ZodString>;
|
|
854
|
+
}, z.core.$strip>;
|
|
855
|
+
export type SvgNode = z.infer<typeof svgNodeSchema>;
|
|
782
856
|
export declare const tableNodeSchema: z.ZodObject<{
|
|
783
857
|
w: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
|
|
784
858
|
h: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
|
|
@@ -2062,7 +2136,7 @@ export type LayerNode = BasePOMNode & {
|
|
|
2062
2136
|
type: "layer";
|
|
2063
2137
|
children: LayerChild[];
|
|
2064
2138
|
};
|
|
2065
|
-
export type POMNode = TextNode | UlNode | OlNode | ImageNode | TableNode | VStackNode | HStackNode | ShapeNode | ChartNode | TimelineNode | MatrixNode | TreeNode | FlowNode | ProcessArrowNode | PyramidNode | LineNode | LayerNode | IconNode;
|
|
2139
|
+
export type POMNode = TextNode | UlNode | OlNode | ImageNode | TableNode | VStackNode | HStackNode | ShapeNode | ChartNode | TimelineNode | MatrixNode | TreeNode | FlowNode | ProcessArrowNode | PyramidNode | LineNode | LayerNode | IconNode | SvgNode;
|
|
2066
2140
|
declare const positionedBaseSchema: z.ZodObject<{
|
|
2067
2141
|
x: z.ZodNumber;
|
|
2068
2142
|
y: z.ZodNumber;
|
|
@@ -2092,6 +2166,8 @@ export type PositionedNode = (TextNode & PositionedBase) | (UlNode & PositionedB
|
|
|
2092
2166
|
iconY?: number;
|
|
2093
2167
|
iconW?: number;
|
|
2094
2168
|
iconH?: number;
|
|
2169
|
+
}) | (SvgNode & PositionedBase & {
|
|
2170
|
+
iconImageData: string;
|
|
2095
2171
|
});
|
|
2096
2172
|
declare const masterTextObjectSchema: z.ZodObject<{
|
|
2097
2173
|
type: z.ZodLiteral<"text">;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA0CxB,eAAO,MAAM,iBAAiB;;;;;;;;;;i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AC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -402,13 +402,19 @@ const iconVariantSchema = z
|
|
|
402
402
|
.optional();
|
|
403
403
|
export const iconNodeSchema = basePOMNodeSchema.extend({
|
|
404
404
|
type: z.literal("icon"),
|
|
405
|
-
name: iconNameSchema
|
|
406
|
-
svgContent: z.string().optional(),
|
|
405
|
+
name: iconNameSchema,
|
|
407
406
|
size: z.number().positive().max(1024).optional(),
|
|
408
407
|
color: iconColorSchema,
|
|
409
408
|
variant: iconVariantSchema,
|
|
410
409
|
bgColor: iconColorSchema,
|
|
411
410
|
});
|
|
411
|
+
export const svgNodeSchema = basePOMNodeSchema.extend({
|
|
412
|
+
type: z.literal("svg"),
|
|
413
|
+
svgContent: z.string(),
|
|
414
|
+
w: z.number().positive().max(1024).optional(),
|
|
415
|
+
h: z.number().positive().max(1024).optional(),
|
|
416
|
+
color: iconColorSchema,
|
|
417
|
+
});
|
|
412
418
|
const tableCellSchema = z.object({
|
|
413
419
|
text: z.string(),
|
|
414
420
|
runs: z.array(textRunSchema).optional(),
|
|
@@ -691,6 +697,7 @@ const pomNodeSchema = z.lazy(() => z.discriminatedUnion("type", [
|
|
|
691
697
|
lineNodeSchema,
|
|
692
698
|
layerNodeSchemaBase,
|
|
693
699
|
iconNodeSchema,
|
|
700
|
+
svgNodeSchema,
|
|
694
701
|
]));
|
|
695
702
|
// ===== Positioned Node Types =====
|
|
696
703
|
const positionedBaseSchema = z.object({
|
|
@@ -732,6 +739,9 @@ const positionedNodeSchema = z.lazy(() => z.union([
|
|
|
732
739
|
iconNodeSchema.merge(positionedBaseSchema).extend({
|
|
733
740
|
iconImageData: z.string(),
|
|
734
741
|
}),
|
|
742
|
+
svgNodeSchema.merge(positionedBaseSchema).extend({
|
|
743
|
+
iconImageData: z.string(),
|
|
744
|
+
}),
|
|
735
745
|
]));
|
|
736
746
|
// ===== Slide Master Options =====
|
|
737
747
|
const masterTextObjectSchema = z.object({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hirokisakabe/pom",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"description": "AI-friendly PowerPoint generation with a Flexbox layout engine.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -46,17 +46,17 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@size-limit/file": "^12.0.1",
|
|
49
|
-
"@types/node": "^25.5.
|
|
49
|
+
"@types/node": "^25.5.2",
|
|
50
50
|
"@types/opentype.js": "^1.3.8",
|
|
51
51
|
"@types/pngjs": "6.0.5",
|
|
52
|
-
"@vitest/coverage-v8": "^4.1.
|
|
53
|
-
"@vitest/ui": "^4.1.
|
|
54
|
-
"lucide-static": "^
|
|
52
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
53
|
+
"@vitest/ui": "^4.1.2",
|
|
54
|
+
"lucide-static": "^1.7.0",
|
|
55
55
|
"pixelmatch": "7.1.0",
|
|
56
56
|
"pngjs": "7.0.0",
|
|
57
57
|
"size-limit": "^12.0.1",
|
|
58
58
|
"tsx": "4.21.0",
|
|
59
|
-
"typescript-eslint": "^8.
|
|
59
|
+
"typescript-eslint": "^8.58.0"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@resvg/resvg-wasm": "^2.6.2",
|