@hirokisakabe/pom 8.6.0 → 8.7.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 +32 -22
- package/dist/autoFit/strategies/reduceFontSize.js +23 -7
- package/dist/autoFit/strategies/reduceFontSize.js.map +1 -1
- package/dist/autoFit/strategies/uniformScale.js +19 -4
- package/dist/autoFit/strategies/uniformScale.js.map +1 -1
- package/dist/parseXml/coercionRules.js +3 -1
- package/dist/parseXml/coercionRules.js.map +1 -1
- package/dist/parseXml/parseXml.d.ts.map +1 -1
- package/dist/parseXml/parseXml.js +1 -0
- package/dist/parseXml/parseXml.js.map +1 -1
- package/dist/parseXml/serializeXml.d.ts.map +1 -1
- package/dist/parseXml/serializeXml.js +1 -0
- package/dist/parseXml/serializeXml.js.map +1 -1
- package/dist/registry/definitions/list.js +2 -1
- package/dist/registry/definitions/list.js.map +1 -1
- package/dist/registry/definitions/text.js +2 -1
- package/dist/registry/definitions/text.js.map +1 -1
- package/dist/registry/xmlChildRules.js +1 -1
- package/dist/registry/xmlChildRules.js.map +1 -1
- package/dist/renderPptx/nodes/chart.js +43 -3
- package/dist/renderPptx/nodes/chart.js.map +1 -1
- package/dist/renderPptx/nodes/list.js +1 -0
- package/dist/renderPptx/nodes/list.js.map +1 -1
- package/dist/renderPptx/nodes/table.js +1 -1
- package/dist/renderPptx/nodes/table.js.map +1 -1
- package/dist/renderPptx/nodes/text.js +2 -1
- package/dist/renderPptx/nodes/text.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseXml.js","names":[],"sources":["../../src/parseXml/parseXml.ts"],"sourcesContent":["import { XMLBuilder, XMLParser } from \"fast-xml-parser\";\nimport type { z } from \"zod\";\nimport type { POMNode } from \"../types.ts\";\nimport {\n getNodeMetadata,\n getNodeMetadataByTag,\n NODE_METADATA,\n} from \"../registry/nodeMetadata.ts\";\nimport {\n INLINE_BOOLEAN_FORMATS,\n INLINE_FORMAT_TAG_LIST,\n INLINE_FORMAT_TAGS,\n INLINE_LINK_TAG,\n INLINE_MARK_TAG,\n INLINE_SPAN_TAG,\n MARK_DEFAULT_HIGHLIGHT_COLOR,\n formatExpectedTags,\n type NodeSpecificChildRule,\n type RepeatedChildRule,\n type TextRun,\n type XmlChildRule,\n} from \"../registry/xmlChildRules.ts\";\nimport {\n type CoercionRule,\n NODE_COERCION_MAP,\n CHILD_ELEMENT_COERCION_MAP,\n coerceWithRule,\n coerceFallback,\n getObjectShapeFromRule,\n resolveMixedNotationShorthand,\n} from \"./coercionRules.ts\";\n\n// ===== ParseXmlError =====\nexport class ParseXmlError extends Error {\n public readonly errors: string[];\n constructor(errors: string[]) {\n const message = `XML validation failed (${errors.length} error${errors.length > 1 ? \"s\" : \"\"}):\\n${errors.map((e) => ` - ${e}`).join(\"\\n\")}`;\n super(message);\n this.name = \"ParseXmlError\";\n this.errors = errors;\n }\n}\n\n// ===== Tag name → POM node type mapping =====\nexport const TAG_TO_TYPE: Record<string, string> = Object.fromEntries(\n NODE_METADATA.map((def) => [def.tagName, def.type]),\n);\n// Attributes allowed on any node (e.g., x/y for Layer children positioning)\nconst UNIVERSAL_ATTRS = new Set([\"x\", \"y\"]);\n\n// ===== Validation helpers =====\nfunction getKnownAttributes(nodeType: string): string[] {\n const rules = NODE_COERCION_MAP[nodeType];\n if (!rules) return [];\n return Object.keys(rules);\n}\n\nfunction levenshteinDistance(a: string, b: string): number {\n const m = a.length;\n const n = b.length;\n const dp: number[][] = Array.from({ length: m + 1 }, () =>\n Array<number>(n + 1).fill(0),\n );\n for (let i = 0; i <= m; i++) dp[i][0] = i;\n for (let j = 0; j <= n; j++) dp[0][j] = j;\n for (let i = 1; i <= m; i++) {\n for (let j = 1; j <= n; j++) {\n dp[i][j] =\n a[i - 1] === b[j - 1]\n ? dp[i - 1][j - 1]\n : 1 + Math.min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]);\n }\n }\n return dp[m][n];\n}\n\nfunction findClosestMatch(\n input: string,\n candidates: string[],\n): string | undefined {\n const threshold = Math.max(2, Math.floor(input.length / 2));\n let bestMatch: string | undefined;\n let bestDistance = Infinity;\n for (const candidate of candidates) {\n const dist = levenshteinDistance(\n input.toLowerCase(),\n candidate.toLowerCase(),\n );\n if (dist < bestDistance && dist <= threshold) {\n bestDistance = dist;\n bestMatch = candidate;\n }\n }\n return bestMatch;\n}\n\nfunction getKnownChildAttributes(tagName: string): string[] {\n const rules = CHILD_ELEMENT_COERCION_MAP[tagName];\n if (!rules) return [];\n return Object.keys(rules);\n}\n\nfunction formatZodIssue(\n issue: z.core.$ZodIssue,\n tagName: string,\n): string | null {\n const path = issue.path;\n // Skip children-related issues (validated recursively)\n if (path.length > 0 && path[0] === \"children\") return null;\n // Skip \"type\" field issues (set internally)\n if (path.length === 1 && path[0] === \"type\") return null;\n\n const attrName = path.length > 0 ? String(path[0]) : undefined;\n\n const code = issue.code;\n\n if (code === \"invalid_type\") {\n // Missing required attribute\n if (issue.input === undefined) {\n if (attrName) {\n return `<${tagName}>: Missing required attribute \"${attrName}\"`;\n }\n return `<${tagName}>: ${issue.message}`;\n }\n // Type mismatch\n if (attrName) {\n return `<${tagName}>: Invalid type for attribute \"${attrName}\". ${issue.message}`;\n }\n return `<${tagName}>: ${issue.message}`;\n }\n\n if (code === \"invalid_value\") {\n if (attrName) {\n const values = (issue as unknown as { values: string[] }).values;\n if (values) {\n return `<${tagName}>: Invalid value for attribute \"${attrName}\". Expected: ${values.map((v) => `\"${v}\"`).join(\", \")}`;\n }\n return `<${tagName}>: Invalid value for attribute \"${attrName}\". ${issue.message}`;\n }\n return `<${tagName}>: ${issue.message}`;\n }\n\n if (code === \"too_small\" || code === \"too_big\") {\n if (attrName) {\n return `<${tagName}>: Invalid value for attribute \"${attrName}\". ${issue.message}`;\n }\n return `<${tagName}>: ${issue.message}`;\n }\n\n // Generic fallback\n if (attrName) {\n return `<${tagName}>: Attribute \"${attrName}\": ${issue.message}`;\n }\n return `<${tagName}>: ${issue.message}`;\n}\n\n// Properties that may be legitimately absent when using child element notation\n// or when the property is optional in practice (even if required in schema).\nfunction validateLeafNode(\n nodeType: string,\n result: Record<string, unknown>,\n errors: string[],\n): void {\n const def = getNodeMetadata(nodeType as POMNode[\"type\"]);\n if (def.childPolicy.kind === \"pom-children\") return;\n const schema = def.schema;\n const tagName = def.tagName;\n const optionalChildProps = new Set(\n def.childPolicy.kind === \"custom\"\n ? (def.childPolicy.optionalProperties ?? [])\n : [],\n );\n const parseResult = schema.safeParse(result);\n if (!parseResult.success) {\n const seen = new Set<string>();\n for (const issue of parseResult.error.issues) {\n // Skip only top-level missing child-element properties (path.length === 1)\n // Nested issues (e.g., data.children[0].label) must still be reported\n if (\n optionalChildProps.size > 0 &&\n issue.path.length === 1 &&\n optionalChildProps.has(String(issue.path[0])) &&\n issue.code === \"invalid_type\" &&\n issue.input === undefined\n ) {\n continue;\n }\n // Skip issues for universal attributes (x, y)\n if (issue.path.length > 0 && UNIVERSAL_ATTRS.has(String(issue.path[0]))) {\n continue;\n }\n const msg = formatZodIssue(issue, tagName);\n if (msg && !seen.has(msg)) {\n seen.add(msg);\n errors.push(msg);\n }\n }\n }\n}\n\n// ===== Types for XML parser output (preserveOrder mode) =====\ntype XmlNode = XmlElement | XmlTextNode;\ntype XmlTextNode = { \"#text\": string };\ninterface XmlElement {\n [tagName: string]: XmlNode[] | Record<string, string> | undefined;\n \":@\"?: Record<string, string>;\n}\n\n// ===== Coercion rule lookup =====\n\nfunction getCoercionRule(\n nodeType: string,\n propertyName: string,\n): CoercionRule | undefined {\n return NODE_COERCION_MAP[nodeType]?.[propertyName];\n}\n\n// ===== Dot notation helpers =====\n\n// ===== Dot notation expansion =====\nfunction expandDotNotation(attrs: Record<string, string>): {\n regular: Record<string, string>;\n dotGroups: Record<string, Record<string, string>>;\n} {\n const regular: Record<string, string> = {};\n const dotGroups: Record<string, Record<string, string>> = {};\n\n for (const [key, value] of Object.entries(attrs)) {\n const dotIndex = key.indexOf(\".\");\n if (dotIndex > 0) {\n const prefix = key.substring(0, dotIndex);\n const suffix = key.substring(dotIndex + 1);\n if (!dotGroups[prefix]) dotGroups[prefix] = {};\n dotGroups[prefix][suffix] = value;\n } else {\n regular[key] = value;\n }\n }\n\n return { regular, dotGroups };\n}\n\nfunction coerceDotGroup(\n prefix: string,\n subAttrs: Record<string, string>,\n rule: CoercionRule,\n tagName: string,\n errors: string[],\n): Record<string, unknown> {\n const objectShape = getObjectShapeFromRule(rule);\n\n const obj: Record<string, unknown> = {};\n if (objectShape) {\n for (const [subKey, subValue] of Object.entries(subAttrs)) {\n if (objectShape[subKey]) {\n const coerced = coerceWithRule(subValue, objectShape[subKey]);\n if (coerced.error !== null) {\n errors.push(`<${tagName}>: ${prefix}.${subKey}: ${coerced.error}`);\n } else {\n obj[subKey] = coerced.value;\n }\n } else {\n const knownSubKeys = Object.keys(objectShape);\n const suggestion = findClosestMatch(subKey, knownSubKeys);\n errors.push(\n `<${tagName}>: Unknown sub-attribute \"${prefix}.${subKey}\"${suggestion ? `. Did you mean \"${prefix}.${suggestion}\"?` : \"\"}`,\n );\n }\n }\n } else {\n errors.push(\n `<${tagName}>: Attribute \"${prefix}\" does not support dot notation`,\n );\n }\n return obj;\n}\n\n// ===== XML node helpers =====\nfunction isTextNode(node: XmlNode): node is XmlTextNode {\n return \"#text\" in node;\n}\n\nfunction getTagName(node: XmlElement): string {\n for (const key of Object.keys(node)) {\n if (key !== \":@\") return key;\n }\n throw new Error(\"No tag name found in XML element\");\n}\n\nfunction getAttributes(node: XmlElement): Record<string, string> {\n const attrs: Record<string, string> = {};\n const rawAttrs = node[\":@\"];\n if (rawAttrs) {\n for (const [key, value] of Object.entries(rawAttrs)) {\n const attrName = key.startsWith(\"@_\") ? key.slice(2) : key;\n attrs[attrName] = value.trim();\n }\n }\n return attrs;\n}\n\nfunction getChildElements(node: XmlElement): XmlElement[] {\n const tagName = getTagName(node);\n const children = node[tagName] as XmlNode[] | undefined;\n if (!children) return [];\n return children.filter((child): child is XmlElement => !isTextNode(child));\n}\n\nfunction getTextContent(node: XmlElement): string | undefined {\n const tagName = getTagName(node);\n const children = node[tagName] as XmlNode[] | undefined;\n if (!children) return undefined;\n const textParts: string[] = [];\n for (const child of children) {\n if (isTextNode(child)) {\n textParts.push(child[\"#text\"]);\n }\n }\n return textParts.length > 0 ? textParts.join(\"\") : undefined;\n}\n\nfunction getRawChildren(node: XmlElement): XmlNode[] {\n const tagName = getTagName(node);\n return (node[tagName] as XmlNode[] | undefined) ?? [];\n}\n\nfunction hasInlineFormatChildren(childElements: XmlElement[]): boolean {\n return (\n childElements.length > 0 &&\n childElements.every((el) => INLINE_FORMAT_TAGS.has(getTagName(el)))\n );\n}\n\nfunction extractTextRuns(\n children: XmlNode[],\n inherited: Partial<Omit<TextRun, \"text\">> = {},\n): TextRun[] {\n const runs: TextRun[] = [];\n for (const child of children) {\n if (isTextNode(child)) {\n runs.push({ text: child[\"#text\"], ...inherited });\n continue;\n }\n const tag = getTagName(child);\n const innerChildren = getRawChildren(child);\n const booleanFormat = INLINE_BOOLEAN_FORMATS.find(\n (format) => format.tag === tag,\n );\n if (booleanFormat) {\n const next: Partial<Omit<TextRun, \"text\">> = {\n ...inherited,\n [booleanFormat.property]: true,\n };\n // subscript と superscript は OOXML の baseline 値として相互排他\n // (同時 true は描画結果が未定義になる)。後で立てた側を優先して反対側を解除する。\n if (booleanFormat.property === \"subscript\") delete next.superscript;\n if (booleanFormat.property === \"superscript\") delete next.subscript;\n runs.push(...extractTextRuns(innerChildren, next));\n } else if (tag === INLINE_LINK_TAG) {\n // href なしの <A> は外側の href を引き継がない(リンク解除として扱う)\n const next = { ...inherited };\n const href = getAttributes(child).href;\n if (href) {\n next.href = href;\n } else {\n delete next.href;\n }\n runs.push(...extractTextRuns(innerChildren, next));\n } else if (tag === INLINE_MARK_TAG) {\n const rawColor = getAttributes(child).color;\n const highlight =\n rawColor && rawColor.trim() ? rawColor : MARK_DEFAULT_HIGHLIGHT_COLOR;\n runs.push(...extractTextRuns(innerChildren, { ...inherited, highlight }));\n } else if (tag === INLINE_SPAN_TAG) {\n const spanAttrs = getAttributes(child);\n const next = { ...inherited };\n if (spanAttrs.color && spanAttrs.color.trim()) {\n next.color = spanAttrs.color;\n }\n if (spanAttrs.fontFamily && spanAttrs.fontFamily.trim()) {\n next.fontFamily = spanAttrs.fontFamily;\n }\n if (spanAttrs.letterSpacing && spanAttrs.letterSpacing.trim()) {\n next.letterSpacing = Number(spanAttrs.letterSpacing);\n }\n runs.push(...extractTextRuns(innerChildren, next));\n }\n }\n return runs;\n}\n\nfunction buildRunsAndText(\n node: XmlElement,\n): { runs: TextRun[]; text: string } | null {\n const rawChildren = getRawChildren(node);\n const childElements = rawChildren.filter(\n (c): c is XmlElement => !isTextNode(c),\n );\n if (!hasInlineFormatChildren(childElements)) return null;\n const runs = extractTextRuns(rawChildren);\n const text = runs.map((r) => r.text).join(\"\");\n return { runs, text };\n}\n\nfunction coerceChildAttrs(\n parentTagName: string,\n tagName: string,\n attrs: Record<string, string>,\n errors: string[],\n): Record<string, unknown> {\n const rules = CHILD_ELEMENT_COERCION_MAP[tagName];\n const result: Record<string, unknown> = {};\n const { regular: regularAttrs, dotGroups } = expandDotNotation(attrs);\n\n // Process dot-notation attributes\n for (const [prefix, subAttrs] of Object.entries(dotGroups)) {\n if (rules && rules[prefix]) {\n result[prefix] = coerceDotGroup(\n prefix,\n subAttrs,\n rules[prefix],\n `${parentTagName}.${tagName}`,\n errors,\n );\n } else if (rules) {\n const knownAttrs = getKnownChildAttributes(tagName);\n const suggestion = findClosestMatch(prefix, knownAttrs);\n errors.push(\n `<${parentTagName}>.<${tagName}>: Unknown attribute \"${prefix}\"${suggestion ? `. Did you mean \"${suggestion}\"?` : \"\"}`,\n );\n } else {\n result[prefix] = {};\n for (const [subKey, subValue] of Object.entries(subAttrs)) {\n (result[prefix] as Record<string, unknown>)[subKey] =\n coerceFallback(subValue);\n }\n }\n }\n\n // Process regular attributes\n for (const [key, value] of Object.entries(regularAttrs)) {\n if (key in dotGroups) {\n if (rules && rules[key]) {\n const resolved = resolveMixedNotationShorthand(value, rules[key]);\n if (resolved.mode === \"ignore\") {\n continue;\n }\n if (resolved.mode === \"merge\") {\n result[key] = {\n ...resolved.value,\n ...(result[key] as Record<string, unknown>),\n };\n continue;\n }\n }\n errors.push(\n `<${parentTagName}>.<${tagName}>: Attribute \"${key}\" conflicts with dot-notation attributes. Use one or the other, not both`,\n );\n continue;\n }\n if (rules && rules[key]) {\n const coerced = coerceWithRule(value, rules[key]);\n if (coerced.error !== null) {\n errors.push(`<${parentTagName}>.<${tagName}>: ${coerced.error}`);\n } else {\n result[key] = coerced.value;\n }\n } else if (rules) {\n // Unknown attribute on child element\n const knownAttrs = getKnownChildAttributes(tagName);\n const suggestion = findClosestMatch(key, knownAttrs);\n errors.push(\n `<${parentTagName}>.<${tagName}>: Unknown attribute \"${key}\"${suggestion ? `. Did you mean \"${suggestion}\"?` : \"\"}`,\n );\n } else {\n result[key] = coerceFallback(value);\n }\n }\n return result;\n}\n\n// ===== Child element converters =====\n\nfunction unknownChildError(\n childTag: string,\n parentTag: string,\n expectedTags: readonly string[],\n): string {\n return `Unknown child element <${childTag}> inside <${parentTag}>. Expected: ${formatExpectedTags(expectedTags)}`;\n}\n\n/** element の text content / インライン装飾を attrs の text / runs へ反映する */\nfunction applyTextAndRuns(\n element: XmlElement,\n attrs: Record<string, unknown>,\n): void {\n const runsResult = buildRunsAndText(element);\n if (runsResult) {\n attrs.runs = runsResult.runs;\n attrs.text = runsResult.text;\n } else {\n const textContent = getTextContent(element);\n if (textContent !== undefined && !(\"text\" in attrs)) {\n attrs.text = textContent;\n }\n }\n}\n\n/** RepeatedChildRule (単一種類の child tag の繰り返し → 配列 property) の汎用 converter */\nfunction convertRepeatedChildren(\n rule: RepeatedChildRule,\n parentTag: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n): void {\n const items: Record<string, unknown>[] = [];\n for (const child of childElements) {\n const tag = getTagName(child);\n if (tag !== rule.childTag) {\n errors.push(unknownChildError(tag, parentTag, [rule.childTag]));\n continue;\n }\n const attrs = coerceChildAttrs(\n parentTag,\n tag,\n getAttributes(child),\n errors,\n );\n if (rule.allowsItemText) {\n applyTextAndRuns(child, attrs);\n }\n items.push(attrs);\n }\n result[rule.property] = items;\n}\n\n/** NodeSpecificChildRule を処理する専用 converter のシグネチャ */\ntype NodeSpecificChildConverter = (\n rule: NodeSpecificChildRule,\n tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n) => void;\n\nfunction convertMatrixChildren(\n rule: NodeSpecificChildRule,\n tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n): void {\n const items: Record<string, unknown>[] = [];\n for (const child of childElements) {\n const tag = getTagName(child);\n switch (tag) {\n case \"MatrixAxes\":\n result.axes = coerceChildAttrs(\n tagName,\n tag,\n getAttributes(child),\n errors,\n );\n break;\n case \"MatrixQuadrants\":\n result.quadrants = coerceChildAttrs(\n tagName,\n tag,\n getAttributes(child),\n errors,\n );\n break;\n case \"MatrixItem\":\n items.push(\n coerceChildAttrs(tagName, tag, getAttributes(child), errors),\n );\n break;\n default:\n errors.push(unknownChildError(tag, tagName, rule.expectedTags));\n }\n }\n if (items.length > 0) {\n result.items = items;\n }\n}\n\nfunction convertFlowChildren(\n rule: NodeSpecificChildRule,\n tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n): void {\n const nodes: Record<string, unknown>[] = [];\n const connections: Record<string, unknown>[] = [];\n for (const child of childElements) {\n const tag = getTagName(child);\n switch (tag) {\n case \"FlowNode\":\n nodes.push(\n coerceChildAttrs(tagName, tag, getAttributes(child), errors),\n );\n break;\n case \"FlowConnection\":\n connections.push(\n coerceChildAttrs(tagName, tag, getAttributes(child), errors),\n );\n break;\n default:\n errors.push(unknownChildError(tag, tagName, rule.expectedTags));\n }\n }\n if (nodes.length > 0) {\n result.nodes = nodes;\n }\n if (connections.length > 0) {\n result.connections = connections;\n }\n}\n\nfunction convertChartChildren(\n rule: NodeSpecificChildRule,\n tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n): void {\n const data: Record<string, unknown>[] = [];\n for (const child of childElements) {\n const tag = getTagName(child);\n if (tag !== \"ChartSeries\") {\n errors.push(unknownChildError(tag, tagName, rule.expectedTags));\n continue;\n }\n const attrs = getAttributes(child);\n const series: Record<string, unknown> = {\n labels: [],\n values: [],\n };\n if (attrs.name !== undefined) {\n // chartDataSchema.name は z.string().optional() なのでそのまま文字列として使用\n series.name = attrs.name;\n }\n\n for (const dp of getChildElements(child)) {\n const dpTag = getTagName(dp);\n if (dpTag !== \"ChartDataPoint\") {\n errors.push(\n unknownChildError(dpTag, \"ChartSeries\", [\"ChartDataPoint\"]),\n );\n continue;\n }\n const dpAttrs = getAttributes(dp);\n if (dpAttrs.label === undefined) {\n errors.push('<ChartDataPoint> requires a \"label\" attribute');\n }\n if (dpAttrs.value === undefined) {\n errors.push('<ChartDataPoint> requires a \"value\" attribute');\n }\n if (dpAttrs.label === undefined || dpAttrs.value === undefined) {\n continue;\n }\n const numValue = Number(dpAttrs.value);\n if (isNaN(numValue)) {\n errors.push(\n `Cannot convert \"${dpAttrs.value}\" to number in <ChartDataPoint> \"value\" attribute`,\n );\n continue;\n }\n (series.labels as string[]).push(dpAttrs.label);\n (series.values as number[]).push(numValue);\n }\n data.push(series);\n }\n result.data = data;\n}\n\nfunction convertTableChildren(\n rule: NodeSpecificChildRule,\n tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n): void {\n const columns: Record<string, unknown>[] = [];\n const rows: Record<string, unknown>[] = [];\n for (const child of childElements) {\n const tag = getTagName(child);\n switch (tag) {\n case \"Col\":\n columns.push(\n coerceChildAttrs(tagName, tag, getAttributes(child), errors),\n );\n break;\n case \"Tr\": {\n const rowAttrs = getAttributes(child);\n const cells: Record<string, unknown>[] = [];\n for (const cellEl of getChildElements(child)) {\n const cellTag = getTagName(cellEl);\n if (cellTag !== \"Td\") {\n errors.push(unknownChildError(cellTag, \"Tr\", [\"Td\"]));\n continue;\n }\n const cellAttrs = coerceChildAttrs(\n \"Tr\",\n cellTag,\n getAttributes(cellEl),\n errors,\n );\n applyTextAndRuns(cellEl, cellAttrs);\n cells.push(cellAttrs);\n }\n const row: Record<string, unknown> = { cells };\n if (rowAttrs.height !== undefined) {\n const h = Number(rowAttrs.height);\n if (isNaN(h)) {\n errors.push(\n `Cannot convert \"${rowAttrs.height}\" to number in <Tr> \"height\" attribute`,\n );\n } else {\n row.height = h;\n }\n }\n rows.push(row);\n break;\n }\n default:\n errors.push(unknownChildError(tag, tagName, rule.expectedTags));\n }\n }\n if (columns.length > 0) {\n result.columns = columns;\n } else if (rows.length > 0) {\n // Col が未指定の場合、行のセル数(colspan 考慮)からデフォルトの columns を自動生成\n const maxCells = Math.max(\n ...rows.map((row) =>\n (row.cells as Record<string, unknown>[]).reduce(\n (sum, cell) => sum + ((cell.colspan as number) ?? 1),\n 0,\n ),\n ),\n );\n result.columns = Array.from({ length: maxCells }, () => ({}));\n }\n if (rows.length > 0) {\n result.rows = rows;\n }\n}\n\nfunction convertTreeItem(\n element: XmlElement,\n errors: string[],\n): Record<string, unknown> {\n const attrs = getAttributes(element);\n if (attrs.label === undefined) {\n errors.push('<TreeItem> requires a \"label\" attribute');\n }\n const item: Record<string, unknown> = {};\n if (attrs.label !== undefined) {\n item.label = attrs.label;\n }\n if (attrs.color !== undefined) {\n item.color = attrs.color;\n }\n if (attrs.textColor !== undefined) {\n item.textColor = attrs.textColor;\n }\n const children = getChildElements(element);\n if (children.length > 0) {\n item.children = children\n .map((child) => {\n const tag = getTagName(child);\n if (tag !== \"TreeItem\") {\n errors.push(unknownChildError(tag, \"TreeItem\", [\"TreeItem\"]));\n return null;\n }\n return convertTreeItem(child, errors);\n })\n .filter((item): item is Record<string, unknown> => item !== null);\n }\n return item;\n}\n\nfunction convertTreeChildren(\n rule: NodeSpecificChildRule,\n tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n): void {\n if (childElements.length !== 1) {\n errors.push(\n `<Tree> must have exactly 1 <TreeItem> child element, but got ${childElements.length}`,\n );\n return;\n }\n const child = childElements[0];\n const tag = getTagName(child);\n if (tag !== \"TreeItem\") {\n errors.push(unknownChildError(tag, tagName, rule.expectedTags));\n return;\n }\n result.data = convertTreeItem(child, errors);\n}\n\n// SVG 要素を XML 文字列に再構築する\nconst svgBuilder = new XMLBuilder({\n preserveOrder: true,\n ignoreAttributes: false,\n attributeNamePrefix: \"@_\",\n});\n\nfunction serializeSvgElement(svgElement: XmlElement): string {\n return String(svgBuilder.build([svgElement]));\n}\n\nfunction convertSvgChildren(\n _rule: NodeSpecificChildRule,\n _tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n): void {\n if (childElements.length !== 1) {\n errors.push(\n `<Svg>: Expected exactly one <svg> child element, but found ${childElements.length} child element(s)`,\n );\n return;\n }\n\n const child = childElements[0];\n const tag = getTagName(child);\n if (tag !== \"svg\") {\n errors.push(`<Svg>: Expected <svg> child element, but found <${tag}>`);\n return;\n }\n\n result.svgContent = serializeSvgElement(child);\n}\n\nfunction convertInlineRunsChildren(\n tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n node?: XmlElement,\n): void {\n // インラインフォーマットタグ以外の子要素がある場合はエラー\n for (const el of childElements) {\n const tag = getTagName(el);\n if (!INLINE_FORMAT_TAGS.has(tag)) {\n const allowedTags = INLINE_FORMAT_TAG_LIST.map((t) => `<${t}>`);\n const allowedList = `${allowedTags.slice(0, -1).join(\", \")}, and ${allowedTags[allowedTags.length - 1]}`;\n errors.push(\n `<${tagName}>: Unexpected child element <${tag}>. Only ${allowedList} are allowed inside <${tagName}>`,\n );\n return;\n }\n }\n if (!node || childElements.length === 0) return;\n const runsResult = buildRunsAndText(node);\n if (runsResult) {\n result.runs = runsResult.runs;\n result.text = runsResult.text;\n }\n}\n\n/** NodeSpecificChildRule を持つノードの専用 converter テーブル */\nconst NODE_SPECIFIC_CHILD_CONVERTERS: Record<\n string,\n NodeSpecificChildConverter\n> = {\n matrix: convertMatrixChildren,\n flow: convertFlowChildren,\n chart: convertChartChildren,\n table: convertTableChildren,\n tree: convertTreeChildren,\n svg: convertSvgChildren,\n};\n\n/** NodeMetadata の xmlChildRule に従って child element を変換する */\nfunction applyXmlChildRule(\n rule: XmlChildRule,\n nodeType: string,\n tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n node?: XmlElement,\n): void {\n if (rule.kind === \"inline-runs\") {\n convertInlineRunsChildren(tagName, childElements, result, errors, node);\n return;\n }\n if (rule.kind === \"repeated\") {\n convertRepeatedChildren(rule, tagName, childElements, result, errors);\n return;\n }\n const converter = NODE_SPECIFIC_CHILD_CONVERTERS[nodeType];\n if (!converter) {\n throw new Error(\n `No node-specific child converter registered for node type: ${nodeType}`,\n );\n }\n converter(rule, tagName, childElements, result, errors);\n}\n\n// ===== Theme tokens =====\nconst THEME_TOKEN_NAME_PATTERN = /^[A-Za-z][A-Za-z0-9_-]*$/;\nconst THEME_TOKEN_VALUE_PATTERN = /^[0-9A-Fa-f]{6}$/;\n// 値全体が \"$name\"(\"#\" プレフィックスは任意)のときトークン参照とみなす\nconst TOKEN_REF_PATTERN = /^(#?)\\$([A-Za-z][A-Za-z0-9_-]*)$/;\n// backgroundGradient 文字列中に現れる \"$name\" 参照\nconst TOKEN_REF_IN_GRADIENT_PATTERN = /#?\\$([A-Za-z][A-Za-z0-9_-]*)/g;\n\nfunction parseThemeElement(\n element: XmlElement,\n tokens: Record<string, string>,\n errors: string[],\n): void {\n if (getChildElements(element).length > 0) {\n errors.push(\n `<Theme>: Child elements are not supported. Declare tokens as attributes (e.g. <Theme accent=\"1D4ED8\" />)`,\n );\n }\n for (const [name, rawValue] of Object.entries(getAttributes(element))) {\n if (!THEME_TOKEN_NAME_PATTERN.test(name)) {\n errors.push(\n `<Theme>: Invalid token name \"${name}\". Token names must start with a letter and contain only letters, digits, \"_\", and \"-\"`,\n );\n continue;\n }\n const value = rawValue.replace(/^#/, \"\");\n if (!THEME_TOKEN_VALUE_PATTERN.test(value)) {\n errors.push(\n `<Theme>: Invalid color value \"${rawValue}\" for token \"${name}\". Expected 6-digit hex (e.g. \"1D4ED8\")`,\n );\n continue;\n }\n tokens[name] = value;\n }\n}\n\n// トークン参照を解決する対象のキー判定。\n// pom の色属性は \"...Color\" / \"...Colors\" / \"highlight\" に統一されているため、\n// キー名ベースで判定することでテキスト内容(text 等)の \"$...\" を誤置換しない。\nfunction isColorKey(key: string): boolean {\n return /colors?$/i.test(key) || key === \"highlight\";\n}\n\nfunction resolveThemeToken(\n name: string,\n hashPrefix: string,\n tokens: Record<string, string>,\n themeDeclared: boolean,\n errors: string[],\n): string | undefined {\n const value = tokens[name];\n if (value !== undefined) {\n return `${hashPrefix}${value}`;\n }\n if (!themeDeclared) {\n errors.push(\n `Theme token \"$${name}\" is referenced, but no <Theme> is declared. Add a top-level <Theme ${name}=\"RRGGBB\" /> element`,\n );\n } else {\n const suggestion = findClosestMatch(name, Object.keys(tokens));\n errors.push(\n `Unknown theme token \"$${name}\"${suggestion ? `. Did you mean \"$${suggestion}\"?` : \"\"}`,\n );\n }\n return undefined;\n}\n\ninterface ThemeContext {\n tokens: Record<string, string>;\n declared: boolean;\n}\n\nfunction resolveThemeTokensDeep(\n value: unknown,\n key: string | null,\n tokens: Record<string, string>,\n themeDeclared: boolean,\n errors: string[],\n): unknown {\n if (typeof value === \"string\") {\n if (key === \"backgroundGradient\") {\n return value.replace(\n TOKEN_REF_IN_GRADIENT_PATTERN,\n (matched, name: string) => {\n const resolved = resolveThemeToken(\n name,\n \"#\",\n tokens,\n themeDeclared,\n errors,\n );\n return resolved ?? matched;\n },\n );\n }\n if (key !== null && isColorKey(key)) {\n const match = TOKEN_REF_PATTERN.exec(value.trim());\n if (match) {\n const resolved = resolveThemeToken(\n match[2],\n match[1],\n tokens,\n themeDeclared,\n errors,\n );\n return resolved ?? value;\n }\n }\n return value;\n }\n if (Array.isArray(value)) {\n // 配列はキー文脈を維持して要素ごとに解決する(chartColors 等の文字列配列に対応)\n return value.map((item) =>\n resolveThemeTokensDeep(item, key, tokens, themeDeclared, errors),\n );\n }\n if (typeof value === \"object\" && value !== null) {\n const result: Record<string, unknown> = {};\n for (const [childKey, childValue] of Object.entries(value)) {\n result[childKey] = resolveThemeTokensDeep(\n childValue,\n childKey,\n tokens,\n themeDeclared,\n errors,\n );\n }\n return result;\n }\n return value;\n}\n\n// ===== Node conversion =====\nfunction convertElement(\n node: XmlElement,\n errors: string[],\n theme: ThemeContext,\n): Record<string, unknown> | null {\n const tagName = getTagName(node);\n const def = getNodeMetadataByTag(tagName);\n const attrs = getAttributes(node);\n const childElements = getChildElements(node);\n const textContent = getTextContent(node);\n\n if (def) {\n return convertPomNode(\n def.type,\n tagName,\n attrs,\n childElements,\n textContent,\n errors,\n theme,\n node,\n );\n } else {\n errors.push(`Unknown tag: <${tagName}>`);\n return null;\n }\n}\n\nfunction convertPomNode(\n nodeType: string,\n tagName: string,\n attrs: Record<string, string>,\n childElements: XmlElement[],\n textContent: string | undefined,\n errors: string[],\n theme: ThemeContext,\n xmlNode?: XmlElement,\n): Record<string, unknown> {\n const result: Record<string, unknown> = { type: nodeType };\n const def = getNodeMetadata(nodeType as POMNode[\"type\"]);\n\n // Expand dot-notation attributes (e.g., fill.color=\"hex\" → { fill: { color: \"hex\" } })\n const { regular: regularAttrs, dotGroups } = expandDotNotation(attrs);\n\n for (const [prefix, subAttrs] of Object.entries(dotGroups)) {\n if (prefix === \"type\") continue;\n const rule = getCoercionRule(nodeType, prefix);\n if (rule) {\n result[prefix] = coerceDotGroup(prefix, subAttrs, rule, tagName, errors);\n } else {\n const knownAttrs = getKnownAttributes(nodeType);\n const suggestion = findClosestMatch(prefix, knownAttrs);\n if (suggestion) {\n errors.push(\n `<${tagName}>: Unknown attribute \"${prefix}\". Did you mean \"${suggestion}\"?`,\n );\n } else {\n errors.push(`<${tagName}>: Unknown attribute \"${prefix}\"`);\n }\n }\n }\n\n for (const [key, value] of Object.entries(regularAttrs)) {\n if (key === \"type\") continue;\n // Conflict check: dot-notation and regular attribute for the same key\n if (key in dotGroups) {\n const ruleForConflict = getCoercionRule(nodeType, key);\n if (ruleForConflict) {\n const resolved = resolveMixedNotationShorthand(value, ruleForConflict);\n if (resolved.mode === \"ignore\") {\n continue;\n }\n if (resolved.mode === \"merge\") {\n result[key] = {\n ...resolved.value,\n ...(result[key] as Record<string, unknown>),\n };\n continue;\n }\n }\n errors.push(\n `<${tagName}>: Attribute \"${key}\" conflicts with dot-notation attributes (e.g., \"${key}.xxx\"). Use one or the other, not both`,\n );\n continue;\n }\n const rule = getCoercionRule(nodeType, key);\n if (rule) {\n const coerced = coerceWithRule(value, rule);\n if (coerced.error !== null) {\n errors.push(`<${tagName}>: ${coerced.error}`);\n } else {\n result[key] = coerced.value;\n }\n } else if (UNIVERSAL_ATTRS.has(key)) {\n // Allow universal attributes (e.g., x/y for Layer children)\n result[key] = coerceFallback(value);\n } else {\n // Unknown attribute\n const knownAttrs = getKnownAttributes(nodeType);\n const suggestion = findClosestMatch(key, knownAttrs);\n if (suggestion) {\n errors.push(\n `<${tagName}>: Unknown attribute \"${key}\". Did you mean \"${suggestion}\"?`,\n );\n } else {\n errors.push(`<${tagName}>: Unknown attribute \"${key}\"`);\n }\n }\n }\n\n // Text content → text property for nodes that support it\n if (textContent !== undefined && def.textContentProperty) {\n if (!(def.textContentProperty in result)) {\n result[def.textContentProperty] = textContent;\n }\n }\n\n // Child element notation for complex properties\n const childRule = def.xmlChildRule;\n if (childRule && childElements.length > 0) {\n applyXmlChildRule(\n childRule,\n nodeType,\n tagName,\n childElements,\n result,\n errors,\n xmlNode,\n );\n }\n // Children for container nodes\n else if (\n def.childPolicy.kind === \"pom-children\" &&\n childElements.length > 0\n ) {\n const convertedChildren = childElements\n .map((child) => convertElement(child, errors, theme))\n .filter((child): child is Record<string, unknown> => child !== null);\n result.children = convertedChildren;\n }\n // Leaf nodes that shouldn't have child elements\n else if (\n def.childPolicy.kind !== \"pom-children\" &&\n !childRule &&\n childElements.length > 0\n ) {\n errors.push(\n `<${tagName}>: Unexpected child elements. <${tagName}> does not accept child elements`,\n );\n }\n\n // テーマトークン参照(色属性中の \"$name\")を Zod 検証より前に解決する。\n // children は各子ノードの convertPomNode で解決済みのためスキップする。\n for (const [key, value] of Object.entries(result)) {\n if (key === \"type\" || key === \"children\") continue;\n result[key] = resolveThemeTokensDeep(\n value,\n key,\n theme.tokens,\n theme.declared,\n errors,\n );\n }\n\n // Zod validation for leaf nodes\n if (def.childPolicy.kind !== \"pom-children\") {\n validateLeafNode(nodeType, result, errors);\n }\n\n // Icon: normalize color / bgColor\n if (nodeType === \"icon\") {\n if (typeof result.color === \"string\" && !result.color.startsWith(\"#\")) {\n result.color = `#${result.color}`;\n }\n if (typeof result.bgColor === \"string\" && !result.bgColor.startsWith(\"#\")) {\n result.bgColor = `#${result.bgColor}`;\n }\n }\n\n // Svg: normalize color and validate svgContent\n if (nodeType === \"svg\") {\n if (typeof result.color === \"string\" && !result.color.startsWith(\"#\")) {\n result.color = `#${result.color}`;\n }\n if (result.svgContent === undefined) {\n errors.push(\"<Svg>: A <svg> child element is required\");\n }\n }\n\n return result;\n}\n\n/**\n * XML 文字列を POMNode 配列に変換する。\n *\n * 最上位は `<Slide>` 要素と `<Theme>` 要素のみが許容される。各 `<Slide>` が\n * 1 つのスライドに対応し、その子要素がスライドのルート POMNode となる。\n * 子要素が複数ある場合は暗黙的に VStack でラップされる。\n *\n * `<Theme>` は文書全体に適用されるデザイントークン(配色)の宣言で、最大 1 つ\n * 置ける。属性名がトークン名、属性値が 6 桁 hex の色値となり、各ノードの色属性\n * から `$トークン名` で参照できる。参照は parse 時に解決されるため、返される\n * POMNode には解決済みの hex 値が入る(`<Theme>` 自体はノードにならない)。\n *\n * XML タグは POM ノードタイプにマッピングされ、属性値は Zod スキーマを参照して\n * 適切な型(number, boolean, array, object)に変換される。\n * 未知のタグ名が指定された場合はエラーがスローされる。\n *\n * @example\n * ```typescript\n * import { parseXml, buildPptx } from \"@hirokisakabe/pom\";\n *\n * const xml = `\n * <Slide>\n * <VStack gap=\"16\" padding=\"32\">\n * <Text fontSize=\"32\" bold=\"true\">売上レポート</Text>\n * </VStack>\n * </Slide>\n * `;\n *\n * const nodes = parseXml(xml);\n * const pptx = await buildPptx(nodes, { w: 1280, h: 720 });\n * ```\n */\nexport function parseXml(xmlString: string): POMNode[] {\n if (!xmlString.trim()) return [];\n\n const parser = new XMLParser({\n preserveOrder: true,\n ignoreAttributes: false,\n attributeNamePrefix: \"@_\",\n parseAttributeValue: false,\n parseTagValue: false,\n trimValues: false,\n });\n\n const wrappedXml = `<__root__>${xmlString}</__root__>`;\n const parsed: XmlElement[] = parser.parse(wrappedXml) as XmlElement[];\n\n if (!parsed || parsed.length === 0) return [];\n\n const rootElement = parsed[0];\n const rootChildren = (rootElement[\"__root__\"] ?? []) as XmlNode[];\n\n const errors: string[] = [];\n const topLevelElements = rootChildren.filter(\n (child): child is XmlElement => !isTextNode(child),\n );\n\n // <Theme> はスライドより先に収集する(出現位置によらず文書全体に適用)\n const theme: ThemeContext = { tokens: {}, declared: false };\n for (const element of topLevelElements) {\n if (getTagName(element) !== \"Theme\") continue;\n if (theme.declared) {\n errors.push(\n `Only one <Theme> element is allowed, but multiple were found`,\n );\n continue;\n }\n theme.declared = true;\n parseThemeElement(element, theme.tokens, errors);\n }\n\n const slideElements = topLevelElements.filter(\n (element) => getTagName(element) !== \"Theme\",\n );\n\n const nodes: POMNode[] = [];\n for (const slideEl of slideElements) {\n const tagName = getTagName(slideEl);\n if (tagName !== \"Slide\") {\n errors.push(\n `Top-level element must be <Slide> or <Theme>, but got <${tagName}>. Wrap your slide content in <Slide>...</Slide>.`,\n );\n continue;\n }\n if (Object.keys(getAttributes(slideEl)).length > 0) {\n errors.push(`<Slide>: Attributes are not supported`);\n }\n const slideChildren = getChildElements(slideEl);\n if (slideChildren.length === 0) {\n errors.push(`<Slide> must contain at least one child element`);\n continue;\n }\n const converted = slideChildren\n .map((child) => convertElement(child, errors, theme))\n .filter((c): c is Record<string, unknown> => c !== null);\n if (converted.length === 0) continue;\n if (converted.length === 1) {\n nodes.push(converted[0] as POMNode);\n } else {\n nodes.push({\n type: \"vstack\",\n children: converted,\n } as POMNode);\n }\n }\n\n if (errors.length > 0) {\n throw new ParseXmlError(errors);\n }\n\n return nodes;\n}\n"],"mappings":";;;;;AAiCA,IAAa,gBAAb,cAAmC,MAAM;CACvC;CACA,YAAY,QAAkB;EAC5B,MAAM,UAAU,0BAA0B,OAAO,OAAO,QAAQ,OAAO,SAAS,IAAI,MAAM,GAAG,MAAM,OAAO,KAAK,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,IAAI;EAC1I,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS;CAChB;AACF;AAGmD,OAAO,YACxD,cAAc,KAAK,QAAQ,CAAC,IAAI,SAAS,IAAI,IAAI,CAAC,CACpD;AAEA,MAAM,kBAAkB,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC;AAG1C,SAAS,mBAAmB,UAA4B;CACtD,MAAM,QAAQ,kBAAkB;CAChC,IAAI,CAAC,OAAO,OAAO,CAAC;CACpB,OAAO,OAAO,KAAK,KAAK;AAC1B;AAEA,SAAS,oBAAoB,GAAW,GAAmB;CACzD,MAAM,IAAI,EAAE;CACZ,MAAM,IAAI,EAAE;CACZ,MAAM,KAAiB,MAAM,KAAK,EAAE,QAAQ,IAAI,EAAE,SAChD,MAAc,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAC7B;CACA,KAAK,IAAI,IAAI,GAAG,KAAK,GAAG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,MAAM,OACvC;CAEA,MAAM,QAAmB,CAAC;CAC1B,KAAK,MAAM,WAAW,eAAe;EACnC,MAAM,UAAU,WAAW,OAAO;EAClC,IAAI,YAAY,SAAS;GACvB,OAAO,KACL,0DAA0D,QAAQ,kDACpE;GACA;EACF;EACA,IAAI,OAAO,KAAK,cAAc,OAAO,CAAC,CAAC,CAAC,SAAS,GAC/C,OAAO,KAAK,uCAAuC;EAErD,MAAM,gBAAgB,iBAAiB,OAAO;EAC9C,IAAI,cAAc,WAAW,GAAG;GAC9B,OAAO,KAAK,iDAAiD;GAC7D;EACF;EACA,MAAM,YAAY,cACf,KAAK,UAAU,eAAe,OAAO,QAAQ,KAAK,CAAC,CAAC,CACpD,QAAQ,MAAoC,MAAM,IAAI;EACzD,IAAI,UAAU,WAAW,GAAG;EAC5B,IAAI,UAAU,WAAW,GACvB,MAAM,KAAK,UAAU,EAAa;OAElC,MAAM,KAAK;GACT,MAAM;GACN,UAAU;EACZ,CAAY;CAEhB;CAEA,IAAI,OAAO,SAAS,GAClB,MAAM,IAAI,cAAc,MAAM;CAGhC,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"parseXml.js","names":[],"sources":["../../src/parseXml/parseXml.ts"],"sourcesContent":["import { XMLBuilder, XMLParser } from \"fast-xml-parser\";\nimport type { z } from \"zod\";\nimport type { POMNode } from \"../types.ts\";\nimport {\n getNodeMetadata,\n getNodeMetadataByTag,\n NODE_METADATA,\n} from \"../registry/nodeMetadata.ts\";\nimport {\n INLINE_BOOLEAN_FORMATS,\n INLINE_FORMAT_TAG_LIST,\n INLINE_FORMAT_TAGS,\n INLINE_LINK_TAG,\n INLINE_MARK_TAG,\n INLINE_SPAN_TAG,\n MARK_DEFAULT_HIGHLIGHT_COLOR,\n formatExpectedTags,\n type NodeSpecificChildRule,\n type RepeatedChildRule,\n type TextRun,\n type XmlChildRule,\n} from \"../registry/xmlChildRules.ts\";\nimport {\n type CoercionRule,\n NODE_COERCION_MAP,\n CHILD_ELEMENT_COERCION_MAP,\n coerceWithRule,\n coerceFallback,\n getObjectShapeFromRule,\n resolveMixedNotationShorthand,\n} from \"./coercionRules.ts\";\n\n// ===== ParseXmlError =====\nexport class ParseXmlError extends Error {\n public readonly errors: string[];\n constructor(errors: string[]) {\n const message = `XML validation failed (${errors.length} error${errors.length > 1 ? \"s\" : \"\"}):\\n${errors.map((e) => ` - ${e}`).join(\"\\n\")}`;\n super(message);\n this.name = \"ParseXmlError\";\n this.errors = errors;\n }\n}\n\n// ===== Tag name → POM node type mapping =====\nexport const TAG_TO_TYPE: Record<string, string> = Object.fromEntries(\n NODE_METADATA.map((def) => [def.tagName, def.type]),\n);\n// Attributes allowed on any node (e.g., x/y for Layer children positioning)\nconst UNIVERSAL_ATTRS = new Set([\"x\", \"y\"]);\n\n// ===== Validation helpers =====\nfunction getKnownAttributes(nodeType: string): string[] {\n const rules = NODE_COERCION_MAP[nodeType];\n if (!rules) return [];\n return Object.keys(rules);\n}\n\nfunction levenshteinDistance(a: string, b: string): number {\n const m = a.length;\n const n = b.length;\n const dp: number[][] = Array.from({ length: m + 1 }, () =>\n Array<number>(n + 1).fill(0),\n );\n for (let i = 0; i <= m; i++) dp[i][0] = i;\n for (let j = 0; j <= n; j++) dp[0][j] = j;\n for (let i = 1; i <= m; i++) {\n for (let j = 1; j <= n; j++) {\n dp[i][j] =\n a[i - 1] === b[j - 1]\n ? dp[i - 1][j - 1]\n : 1 + Math.min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]);\n }\n }\n return dp[m][n];\n}\n\nfunction findClosestMatch(\n input: string,\n candidates: string[],\n): string | undefined {\n const threshold = Math.max(2, Math.floor(input.length / 2));\n let bestMatch: string | undefined;\n let bestDistance = Infinity;\n for (const candidate of candidates) {\n const dist = levenshteinDistance(\n input.toLowerCase(),\n candidate.toLowerCase(),\n );\n if (dist < bestDistance && dist <= threshold) {\n bestDistance = dist;\n bestMatch = candidate;\n }\n }\n return bestMatch;\n}\n\nfunction getKnownChildAttributes(tagName: string): string[] {\n const rules = CHILD_ELEMENT_COERCION_MAP[tagName];\n if (!rules) return [];\n return Object.keys(rules);\n}\n\nfunction formatZodIssue(\n issue: z.core.$ZodIssue,\n tagName: string,\n): string | null {\n const path = issue.path;\n // Skip children-related issues (validated recursively)\n if (path.length > 0 && path[0] === \"children\") return null;\n // Skip \"type\" field issues (set internally)\n if (path.length === 1 && path[0] === \"type\") return null;\n\n const attrName = path.length > 0 ? String(path[0]) : undefined;\n\n const code = issue.code;\n\n if (code === \"invalid_type\") {\n // Missing required attribute\n if (issue.input === undefined) {\n if (attrName) {\n return `<${tagName}>: Missing required attribute \"${attrName}\"`;\n }\n return `<${tagName}>: ${issue.message}`;\n }\n // Type mismatch\n if (attrName) {\n return `<${tagName}>: Invalid type for attribute \"${attrName}\". ${issue.message}`;\n }\n return `<${tagName}>: ${issue.message}`;\n }\n\n if (code === \"invalid_value\") {\n if (attrName) {\n const values = (issue as unknown as { values: string[] }).values;\n if (values) {\n return `<${tagName}>: Invalid value for attribute \"${attrName}\". Expected: ${values.map((v) => `\"${v}\"`).join(\", \")}`;\n }\n return `<${tagName}>: Invalid value for attribute \"${attrName}\". ${issue.message}`;\n }\n return `<${tagName}>: ${issue.message}`;\n }\n\n if (code === \"too_small\" || code === \"too_big\") {\n if (attrName) {\n return `<${tagName}>: Invalid value for attribute \"${attrName}\". ${issue.message}`;\n }\n return `<${tagName}>: ${issue.message}`;\n }\n\n // Generic fallback\n if (attrName) {\n return `<${tagName}>: Attribute \"${attrName}\": ${issue.message}`;\n }\n return `<${tagName}>: ${issue.message}`;\n}\n\n// Properties that may be legitimately absent when using child element notation\n// or when the property is optional in practice (even if required in schema).\nfunction validateLeafNode(\n nodeType: string,\n result: Record<string, unknown>,\n errors: string[],\n): void {\n const def = getNodeMetadata(nodeType as POMNode[\"type\"]);\n if (def.childPolicy.kind === \"pom-children\") return;\n const schema = def.schema;\n const tagName = def.tagName;\n const optionalChildProps = new Set(\n def.childPolicy.kind === \"custom\"\n ? (def.childPolicy.optionalProperties ?? [])\n : [],\n );\n const parseResult = schema.safeParse(result);\n if (!parseResult.success) {\n const seen = new Set<string>();\n for (const issue of parseResult.error.issues) {\n // Skip only top-level missing child-element properties (path.length === 1)\n // Nested issues (e.g., data.children[0].label) must still be reported\n if (\n optionalChildProps.size > 0 &&\n issue.path.length === 1 &&\n optionalChildProps.has(String(issue.path[0])) &&\n issue.code === \"invalid_type\" &&\n issue.input === undefined\n ) {\n continue;\n }\n // Skip issues for universal attributes (x, y)\n if (issue.path.length > 0 && UNIVERSAL_ATTRS.has(String(issue.path[0]))) {\n continue;\n }\n const msg = formatZodIssue(issue, tagName);\n if (msg && !seen.has(msg)) {\n seen.add(msg);\n errors.push(msg);\n }\n }\n }\n}\n\n// ===== Types for XML parser output (preserveOrder mode) =====\ntype XmlNode = XmlElement | XmlTextNode;\ntype XmlTextNode = { \"#text\": string };\ninterface XmlElement {\n [tagName: string]: XmlNode[] | Record<string, string> | undefined;\n \":@\"?: Record<string, string>;\n}\n\n// ===== Coercion rule lookup =====\n\nfunction getCoercionRule(\n nodeType: string,\n propertyName: string,\n): CoercionRule | undefined {\n return NODE_COERCION_MAP[nodeType]?.[propertyName];\n}\n\n// ===== Dot notation helpers =====\n\n// ===== Dot notation expansion =====\nfunction expandDotNotation(attrs: Record<string, string>): {\n regular: Record<string, string>;\n dotGroups: Record<string, Record<string, string>>;\n} {\n const regular: Record<string, string> = {};\n const dotGroups: Record<string, Record<string, string>> = {};\n\n for (const [key, value] of Object.entries(attrs)) {\n const dotIndex = key.indexOf(\".\");\n if (dotIndex > 0) {\n const prefix = key.substring(0, dotIndex);\n const suffix = key.substring(dotIndex + 1);\n if (!dotGroups[prefix]) dotGroups[prefix] = {};\n dotGroups[prefix][suffix] = value;\n } else {\n regular[key] = value;\n }\n }\n\n return { regular, dotGroups };\n}\n\nfunction coerceDotGroup(\n prefix: string,\n subAttrs: Record<string, string>,\n rule: CoercionRule,\n tagName: string,\n errors: string[],\n): Record<string, unknown> {\n const objectShape = getObjectShapeFromRule(rule);\n\n const obj: Record<string, unknown> = {};\n if (objectShape) {\n for (const [subKey, subValue] of Object.entries(subAttrs)) {\n if (objectShape[subKey]) {\n const coerced = coerceWithRule(subValue, objectShape[subKey]);\n if (coerced.error !== null) {\n errors.push(`<${tagName}>: ${prefix}.${subKey}: ${coerced.error}`);\n } else {\n obj[subKey] = coerced.value;\n }\n } else {\n const knownSubKeys = Object.keys(objectShape);\n const suggestion = findClosestMatch(subKey, knownSubKeys);\n errors.push(\n `<${tagName}>: Unknown sub-attribute \"${prefix}.${subKey}\"${suggestion ? `. Did you mean \"${prefix}.${suggestion}\"?` : \"\"}`,\n );\n }\n }\n } else {\n errors.push(\n `<${tagName}>: Attribute \"${prefix}\" does not support dot notation`,\n );\n }\n return obj;\n}\n\n// ===== XML node helpers =====\nfunction isTextNode(node: XmlNode): node is XmlTextNode {\n return \"#text\" in node;\n}\n\nfunction getTagName(node: XmlElement): string {\n for (const key of Object.keys(node)) {\n if (key !== \":@\") return key;\n }\n throw new Error(\"No tag name found in XML element\");\n}\n\nfunction getAttributes(node: XmlElement): Record<string, string> {\n const attrs: Record<string, string> = {};\n const rawAttrs = node[\":@\"];\n if (rawAttrs) {\n for (const [key, value] of Object.entries(rawAttrs)) {\n const attrName = key.startsWith(\"@_\") ? key.slice(2) : key;\n attrs[attrName] = value.trim();\n }\n }\n return attrs;\n}\n\nfunction getChildElements(node: XmlElement): XmlElement[] {\n const tagName = getTagName(node);\n const children = node[tagName] as XmlNode[] | undefined;\n if (!children) return [];\n return children.filter((child): child is XmlElement => !isTextNode(child));\n}\n\nfunction getTextContent(node: XmlElement): string | undefined {\n const tagName = getTagName(node);\n const children = node[tagName] as XmlNode[] | undefined;\n if (!children) return undefined;\n const textParts: string[] = [];\n for (const child of children) {\n if (isTextNode(child)) {\n textParts.push(child[\"#text\"]);\n }\n }\n return textParts.length > 0 ? textParts.join(\"\") : undefined;\n}\n\nfunction getRawChildren(node: XmlElement): XmlNode[] {\n const tagName = getTagName(node);\n return (node[tagName] as XmlNode[] | undefined) ?? [];\n}\n\nfunction hasInlineFormatChildren(childElements: XmlElement[]): boolean {\n return (\n childElements.length > 0 &&\n childElements.every((el) => INLINE_FORMAT_TAGS.has(getTagName(el)))\n );\n}\n\nfunction extractTextRuns(\n children: XmlNode[],\n inherited: Partial<Omit<TextRun, \"text\">> = {},\n): TextRun[] {\n const runs: TextRun[] = [];\n for (const child of children) {\n if (isTextNode(child)) {\n runs.push({ text: child[\"#text\"], ...inherited });\n continue;\n }\n const tag = getTagName(child);\n const innerChildren = getRawChildren(child);\n const booleanFormat = INLINE_BOOLEAN_FORMATS.find(\n (format) => format.tag === tag,\n );\n if (booleanFormat) {\n const next: Partial<Omit<TextRun, \"text\">> = {\n ...inherited,\n [booleanFormat.property]: true,\n };\n // subscript と superscript は OOXML の baseline 値として相互排他\n // (同時 true は描画結果が未定義になる)。後で立てた側を優先して反対側を解除する。\n if (booleanFormat.property === \"subscript\") delete next.superscript;\n if (booleanFormat.property === \"superscript\") delete next.subscript;\n runs.push(...extractTextRuns(innerChildren, next));\n } else if (tag === INLINE_LINK_TAG) {\n // href なしの <A> は外側の href を引き継がない(リンク解除として扱う)\n const next = { ...inherited };\n const href = getAttributes(child).href;\n if (href) {\n next.href = href;\n } else {\n delete next.href;\n }\n runs.push(...extractTextRuns(innerChildren, next));\n } else if (tag === INLINE_MARK_TAG) {\n const rawColor = getAttributes(child).color;\n const highlight =\n rawColor && rawColor.trim() ? rawColor : MARK_DEFAULT_HIGHLIGHT_COLOR;\n runs.push(...extractTextRuns(innerChildren, { ...inherited, highlight }));\n } else if (tag === INLINE_SPAN_TAG) {\n const spanAttrs = getAttributes(child);\n const next = { ...inherited };\n if (spanAttrs.color && spanAttrs.color.trim()) {\n next.color = spanAttrs.color;\n }\n if (spanAttrs.fontFamily && spanAttrs.fontFamily.trim()) {\n next.fontFamily = spanAttrs.fontFamily;\n }\n if (spanAttrs.fontSize && spanAttrs.fontSize.trim()) {\n next.fontSize = Number(spanAttrs.fontSize);\n }\n if (spanAttrs.letterSpacing && spanAttrs.letterSpacing.trim()) {\n next.letterSpacing = Number(spanAttrs.letterSpacing);\n }\n runs.push(...extractTextRuns(innerChildren, next));\n }\n }\n return runs;\n}\n\nfunction buildRunsAndText(\n node: XmlElement,\n): { runs: TextRun[]; text: string } | null {\n const rawChildren = getRawChildren(node);\n const childElements = rawChildren.filter(\n (c): c is XmlElement => !isTextNode(c),\n );\n if (!hasInlineFormatChildren(childElements)) return null;\n const runs = extractTextRuns(rawChildren);\n const text = runs.map((r) => r.text).join(\"\");\n return { runs, text };\n}\n\nfunction coerceChildAttrs(\n parentTagName: string,\n tagName: string,\n attrs: Record<string, string>,\n errors: string[],\n): Record<string, unknown> {\n const rules = CHILD_ELEMENT_COERCION_MAP[tagName];\n const result: Record<string, unknown> = {};\n const { regular: regularAttrs, dotGroups } = expandDotNotation(attrs);\n\n // Process dot-notation attributes\n for (const [prefix, subAttrs] of Object.entries(dotGroups)) {\n if (rules && rules[prefix]) {\n result[prefix] = coerceDotGroup(\n prefix,\n subAttrs,\n rules[prefix],\n `${parentTagName}.${tagName}`,\n errors,\n );\n } else if (rules) {\n const knownAttrs = getKnownChildAttributes(tagName);\n const suggestion = findClosestMatch(prefix, knownAttrs);\n errors.push(\n `<${parentTagName}>.<${tagName}>: Unknown attribute \"${prefix}\"${suggestion ? `. Did you mean \"${suggestion}\"?` : \"\"}`,\n );\n } else {\n result[prefix] = {};\n for (const [subKey, subValue] of Object.entries(subAttrs)) {\n (result[prefix] as Record<string, unknown>)[subKey] =\n coerceFallback(subValue);\n }\n }\n }\n\n // Process regular attributes\n for (const [key, value] of Object.entries(regularAttrs)) {\n if (key in dotGroups) {\n if (rules && rules[key]) {\n const resolved = resolveMixedNotationShorthand(value, rules[key]);\n if (resolved.mode === \"ignore\") {\n continue;\n }\n if (resolved.mode === \"merge\") {\n result[key] = {\n ...resolved.value,\n ...(result[key] as Record<string, unknown>),\n };\n continue;\n }\n }\n errors.push(\n `<${parentTagName}>.<${tagName}>: Attribute \"${key}\" conflicts with dot-notation attributes. Use one or the other, not both`,\n );\n continue;\n }\n if (rules && rules[key]) {\n const coerced = coerceWithRule(value, rules[key]);\n if (coerced.error !== null) {\n errors.push(`<${parentTagName}>.<${tagName}>: ${coerced.error}`);\n } else {\n result[key] = coerced.value;\n }\n } else if (rules) {\n // Unknown attribute on child element\n const knownAttrs = getKnownChildAttributes(tagName);\n const suggestion = findClosestMatch(key, knownAttrs);\n errors.push(\n `<${parentTagName}>.<${tagName}>: Unknown attribute \"${key}\"${suggestion ? `. Did you mean \"${suggestion}\"?` : \"\"}`,\n );\n } else {\n result[key] = coerceFallback(value);\n }\n }\n return result;\n}\n\n// ===== Child element converters =====\n\nfunction unknownChildError(\n childTag: string,\n parentTag: string,\n expectedTags: readonly string[],\n): string {\n return `Unknown child element <${childTag}> inside <${parentTag}>. Expected: ${formatExpectedTags(expectedTags)}`;\n}\n\n/** element の text content / インライン装飾を attrs の text / runs へ反映する */\nfunction applyTextAndRuns(\n element: XmlElement,\n attrs: Record<string, unknown>,\n): void {\n const runsResult = buildRunsAndText(element);\n if (runsResult) {\n attrs.runs = runsResult.runs;\n attrs.text = runsResult.text;\n } else {\n const textContent = getTextContent(element);\n if (textContent !== undefined && !(\"text\" in attrs)) {\n attrs.text = textContent;\n }\n }\n}\n\n/** RepeatedChildRule (単一種類の child tag の繰り返し → 配列 property) の汎用 converter */\nfunction convertRepeatedChildren(\n rule: RepeatedChildRule,\n parentTag: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n): void {\n const items: Record<string, unknown>[] = [];\n for (const child of childElements) {\n const tag = getTagName(child);\n if (tag !== rule.childTag) {\n errors.push(unknownChildError(tag, parentTag, [rule.childTag]));\n continue;\n }\n const attrs = coerceChildAttrs(\n parentTag,\n tag,\n getAttributes(child),\n errors,\n );\n if (rule.allowsItemText) {\n applyTextAndRuns(child, attrs);\n }\n items.push(attrs);\n }\n result[rule.property] = items;\n}\n\n/** NodeSpecificChildRule を処理する専用 converter のシグネチャ */\ntype NodeSpecificChildConverter = (\n rule: NodeSpecificChildRule,\n tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n) => void;\n\nfunction convertMatrixChildren(\n rule: NodeSpecificChildRule,\n tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n): void {\n const items: Record<string, unknown>[] = [];\n for (const child of childElements) {\n const tag = getTagName(child);\n switch (tag) {\n case \"MatrixAxes\":\n result.axes = coerceChildAttrs(\n tagName,\n tag,\n getAttributes(child),\n errors,\n );\n break;\n case \"MatrixQuadrants\":\n result.quadrants = coerceChildAttrs(\n tagName,\n tag,\n getAttributes(child),\n errors,\n );\n break;\n case \"MatrixItem\":\n items.push(\n coerceChildAttrs(tagName, tag, getAttributes(child), errors),\n );\n break;\n default:\n errors.push(unknownChildError(tag, tagName, rule.expectedTags));\n }\n }\n if (items.length > 0) {\n result.items = items;\n }\n}\n\nfunction convertFlowChildren(\n rule: NodeSpecificChildRule,\n tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n): void {\n const nodes: Record<string, unknown>[] = [];\n const connections: Record<string, unknown>[] = [];\n for (const child of childElements) {\n const tag = getTagName(child);\n switch (tag) {\n case \"FlowNode\":\n nodes.push(\n coerceChildAttrs(tagName, tag, getAttributes(child), errors),\n );\n break;\n case \"FlowConnection\":\n connections.push(\n coerceChildAttrs(tagName, tag, getAttributes(child), errors),\n );\n break;\n default:\n errors.push(unknownChildError(tag, tagName, rule.expectedTags));\n }\n }\n if (nodes.length > 0) {\n result.nodes = nodes;\n }\n if (connections.length > 0) {\n result.connections = connections;\n }\n}\n\nfunction convertChartChildren(\n rule: NodeSpecificChildRule,\n tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n): void {\n const data: Record<string, unknown>[] = [];\n for (const child of childElements) {\n const tag = getTagName(child);\n if (tag !== \"ChartSeries\") {\n errors.push(unknownChildError(tag, tagName, rule.expectedTags));\n continue;\n }\n const attrs = getAttributes(child);\n const series: Record<string, unknown> = {\n labels: [],\n values: [],\n };\n if (attrs.name !== undefined) {\n // chartDataSchema.name は z.string().optional() なのでそのまま文字列として使用\n series.name = attrs.name;\n }\n\n for (const dp of getChildElements(child)) {\n const dpTag = getTagName(dp);\n if (dpTag !== \"ChartDataPoint\") {\n errors.push(\n unknownChildError(dpTag, \"ChartSeries\", [\"ChartDataPoint\"]),\n );\n continue;\n }\n const dpAttrs = getAttributes(dp);\n if (dpAttrs.label === undefined) {\n errors.push('<ChartDataPoint> requires a \"label\" attribute');\n }\n if (dpAttrs.value === undefined) {\n errors.push('<ChartDataPoint> requires a \"value\" attribute');\n }\n if (dpAttrs.label === undefined || dpAttrs.value === undefined) {\n continue;\n }\n const numValue = Number(dpAttrs.value);\n if (isNaN(numValue)) {\n errors.push(\n `Cannot convert \"${dpAttrs.value}\" to number in <ChartDataPoint> \"value\" attribute`,\n );\n continue;\n }\n (series.labels as string[]).push(dpAttrs.label);\n (series.values as number[]).push(numValue);\n }\n data.push(series);\n }\n result.data = data;\n}\n\nfunction convertTableChildren(\n rule: NodeSpecificChildRule,\n tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n): void {\n const columns: Record<string, unknown>[] = [];\n const rows: Record<string, unknown>[] = [];\n for (const child of childElements) {\n const tag = getTagName(child);\n switch (tag) {\n case \"Col\":\n columns.push(\n coerceChildAttrs(tagName, tag, getAttributes(child), errors),\n );\n break;\n case \"Tr\": {\n const rowAttrs = getAttributes(child);\n const cells: Record<string, unknown>[] = [];\n for (const cellEl of getChildElements(child)) {\n const cellTag = getTagName(cellEl);\n if (cellTag !== \"Td\") {\n errors.push(unknownChildError(cellTag, \"Tr\", [\"Td\"]));\n continue;\n }\n const cellAttrs = coerceChildAttrs(\n \"Tr\",\n cellTag,\n getAttributes(cellEl),\n errors,\n );\n applyTextAndRuns(cellEl, cellAttrs);\n cells.push(cellAttrs);\n }\n const row: Record<string, unknown> = { cells };\n if (rowAttrs.height !== undefined) {\n const h = Number(rowAttrs.height);\n if (isNaN(h)) {\n errors.push(\n `Cannot convert \"${rowAttrs.height}\" to number in <Tr> \"height\" attribute`,\n );\n } else {\n row.height = h;\n }\n }\n rows.push(row);\n break;\n }\n default:\n errors.push(unknownChildError(tag, tagName, rule.expectedTags));\n }\n }\n if (columns.length > 0) {\n result.columns = columns;\n } else if (rows.length > 0) {\n // Col が未指定の場合、行のセル数(colspan 考慮)からデフォルトの columns を自動生成\n const maxCells = Math.max(\n ...rows.map((row) =>\n (row.cells as Record<string, unknown>[]).reduce(\n (sum, cell) => sum + ((cell.colspan as number) ?? 1),\n 0,\n ),\n ),\n );\n result.columns = Array.from({ length: maxCells }, () => ({}));\n }\n if (rows.length > 0) {\n result.rows = rows;\n }\n}\n\nfunction convertTreeItem(\n element: XmlElement,\n errors: string[],\n): Record<string, unknown> {\n const attrs = getAttributes(element);\n if (attrs.label === undefined) {\n errors.push('<TreeItem> requires a \"label\" attribute');\n }\n const item: Record<string, unknown> = {};\n if (attrs.label !== undefined) {\n item.label = attrs.label;\n }\n if (attrs.color !== undefined) {\n item.color = attrs.color;\n }\n if (attrs.textColor !== undefined) {\n item.textColor = attrs.textColor;\n }\n const children = getChildElements(element);\n if (children.length > 0) {\n item.children = children\n .map((child) => {\n const tag = getTagName(child);\n if (tag !== \"TreeItem\") {\n errors.push(unknownChildError(tag, \"TreeItem\", [\"TreeItem\"]));\n return null;\n }\n return convertTreeItem(child, errors);\n })\n .filter((item): item is Record<string, unknown> => item !== null);\n }\n return item;\n}\n\nfunction convertTreeChildren(\n rule: NodeSpecificChildRule,\n tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n): void {\n if (childElements.length !== 1) {\n errors.push(\n `<Tree> must have exactly 1 <TreeItem> child element, but got ${childElements.length}`,\n );\n return;\n }\n const child = childElements[0];\n const tag = getTagName(child);\n if (tag !== \"TreeItem\") {\n errors.push(unknownChildError(tag, tagName, rule.expectedTags));\n return;\n }\n result.data = convertTreeItem(child, errors);\n}\n\n// SVG 要素を XML 文字列に再構築する\nconst svgBuilder = new XMLBuilder({\n preserveOrder: true,\n ignoreAttributes: false,\n attributeNamePrefix: \"@_\",\n});\n\nfunction serializeSvgElement(svgElement: XmlElement): string {\n return String(svgBuilder.build([svgElement]));\n}\n\nfunction convertSvgChildren(\n _rule: NodeSpecificChildRule,\n _tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n): void {\n if (childElements.length !== 1) {\n errors.push(\n `<Svg>: Expected exactly one <svg> child element, but found ${childElements.length} child element(s)`,\n );\n return;\n }\n\n const child = childElements[0];\n const tag = getTagName(child);\n if (tag !== \"svg\") {\n errors.push(`<Svg>: Expected <svg> child element, but found <${tag}>`);\n return;\n }\n\n result.svgContent = serializeSvgElement(child);\n}\n\nfunction convertInlineRunsChildren(\n tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n node?: XmlElement,\n): void {\n // インラインフォーマットタグ以外の子要素がある場合はエラー\n for (const el of childElements) {\n const tag = getTagName(el);\n if (!INLINE_FORMAT_TAGS.has(tag)) {\n const allowedTags = INLINE_FORMAT_TAG_LIST.map((t) => `<${t}>`);\n const allowedList = `${allowedTags.slice(0, -1).join(\", \")}, and ${allowedTags[allowedTags.length - 1]}`;\n errors.push(\n `<${tagName}>: Unexpected child element <${tag}>. Only ${allowedList} are allowed inside <${tagName}>`,\n );\n return;\n }\n }\n if (!node || childElements.length === 0) return;\n const runsResult = buildRunsAndText(node);\n if (runsResult) {\n result.runs = runsResult.runs;\n result.text = runsResult.text;\n }\n}\n\n/** NodeSpecificChildRule を持つノードの専用 converter テーブル */\nconst NODE_SPECIFIC_CHILD_CONVERTERS: Record<\n string,\n NodeSpecificChildConverter\n> = {\n matrix: convertMatrixChildren,\n flow: convertFlowChildren,\n chart: convertChartChildren,\n table: convertTableChildren,\n tree: convertTreeChildren,\n svg: convertSvgChildren,\n};\n\n/** NodeMetadata の xmlChildRule に従って child element を変換する */\nfunction applyXmlChildRule(\n rule: XmlChildRule,\n nodeType: string,\n tagName: string,\n childElements: XmlElement[],\n result: Record<string, unknown>,\n errors: string[],\n node?: XmlElement,\n): void {\n if (rule.kind === \"inline-runs\") {\n convertInlineRunsChildren(tagName, childElements, result, errors, node);\n return;\n }\n if (rule.kind === \"repeated\") {\n convertRepeatedChildren(rule, tagName, childElements, result, errors);\n return;\n }\n const converter = NODE_SPECIFIC_CHILD_CONVERTERS[nodeType];\n if (!converter) {\n throw new Error(\n `No node-specific child converter registered for node type: ${nodeType}`,\n );\n }\n converter(rule, tagName, childElements, result, errors);\n}\n\n// ===== Theme tokens =====\nconst THEME_TOKEN_NAME_PATTERN = /^[A-Za-z][A-Za-z0-9_-]*$/;\nconst THEME_TOKEN_VALUE_PATTERN = /^[0-9A-Fa-f]{6}$/;\n// 値全体が \"$name\"(\"#\" プレフィックスは任意)のときトークン参照とみなす\nconst TOKEN_REF_PATTERN = /^(#?)\\$([A-Za-z][A-Za-z0-9_-]*)$/;\n// backgroundGradient 文字列中に現れる \"$name\" 参照\nconst TOKEN_REF_IN_GRADIENT_PATTERN = /#?\\$([A-Za-z][A-Za-z0-9_-]*)/g;\n\nfunction parseThemeElement(\n element: XmlElement,\n tokens: Record<string, string>,\n errors: string[],\n): void {\n if (getChildElements(element).length > 0) {\n errors.push(\n `<Theme>: Child elements are not supported. Declare tokens as attributes (e.g. <Theme accent=\"1D4ED8\" />)`,\n );\n }\n for (const [name, rawValue] of Object.entries(getAttributes(element))) {\n if (!THEME_TOKEN_NAME_PATTERN.test(name)) {\n errors.push(\n `<Theme>: Invalid token name \"${name}\". Token names must start with a letter and contain only letters, digits, \"_\", and \"-\"`,\n );\n continue;\n }\n const value = rawValue.replace(/^#/, \"\");\n if (!THEME_TOKEN_VALUE_PATTERN.test(value)) {\n errors.push(\n `<Theme>: Invalid color value \"${rawValue}\" for token \"${name}\". Expected 6-digit hex (e.g. \"1D4ED8\")`,\n );\n continue;\n }\n tokens[name] = value;\n }\n}\n\n// トークン参照を解決する対象のキー判定。\n// pom の色属性は \"...Color\" / \"...Colors\" / \"highlight\" に統一されているため、\n// キー名ベースで判定することでテキスト内容(text 等)の \"$...\" を誤置換しない。\nfunction isColorKey(key: string): boolean {\n return /colors?$/i.test(key) || key === \"highlight\";\n}\n\nfunction resolveThemeToken(\n name: string,\n hashPrefix: string,\n tokens: Record<string, string>,\n themeDeclared: boolean,\n errors: string[],\n): string | undefined {\n const value = tokens[name];\n if (value !== undefined) {\n return `${hashPrefix}${value}`;\n }\n if (!themeDeclared) {\n errors.push(\n `Theme token \"$${name}\" is referenced, but no <Theme> is declared. Add a top-level <Theme ${name}=\"RRGGBB\" /> element`,\n );\n } else {\n const suggestion = findClosestMatch(name, Object.keys(tokens));\n errors.push(\n `Unknown theme token \"$${name}\"${suggestion ? `. Did you mean \"$${suggestion}\"?` : \"\"}`,\n );\n }\n return undefined;\n}\n\ninterface ThemeContext {\n tokens: Record<string, string>;\n declared: boolean;\n}\n\nfunction resolveThemeTokensDeep(\n value: unknown,\n key: string | null,\n tokens: Record<string, string>,\n themeDeclared: boolean,\n errors: string[],\n): unknown {\n if (typeof value === \"string\") {\n if (key === \"backgroundGradient\") {\n return value.replace(\n TOKEN_REF_IN_GRADIENT_PATTERN,\n (matched, name: string) => {\n const resolved = resolveThemeToken(\n name,\n \"#\",\n tokens,\n themeDeclared,\n errors,\n );\n return resolved ?? matched;\n },\n );\n }\n if (key !== null && isColorKey(key)) {\n const match = TOKEN_REF_PATTERN.exec(value.trim());\n if (match) {\n const resolved = resolveThemeToken(\n match[2],\n match[1],\n tokens,\n themeDeclared,\n errors,\n );\n return resolved ?? value;\n }\n }\n return value;\n }\n if (Array.isArray(value)) {\n // 配列はキー文脈を維持して要素ごとに解決する(chartColors 等の文字列配列に対応)\n return value.map((item) =>\n resolveThemeTokensDeep(item, key, tokens, themeDeclared, errors),\n );\n }\n if (typeof value === \"object\" && value !== null) {\n const result: Record<string, unknown> = {};\n for (const [childKey, childValue] of Object.entries(value)) {\n result[childKey] = resolveThemeTokensDeep(\n childValue,\n childKey,\n tokens,\n themeDeclared,\n errors,\n );\n }\n return result;\n }\n return value;\n}\n\n// ===== Node conversion =====\nfunction convertElement(\n node: XmlElement,\n errors: string[],\n theme: ThemeContext,\n): Record<string, unknown> | null {\n const tagName = getTagName(node);\n const def = getNodeMetadataByTag(tagName);\n const attrs = getAttributes(node);\n const childElements = getChildElements(node);\n const textContent = getTextContent(node);\n\n if (def) {\n return convertPomNode(\n def.type,\n tagName,\n attrs,\n childElements,\n textContent,\n errors,\n theme,\n node,\n );\n } else {\n errors.push(`Unknown tag: <${tagName}>`);\n return null;\n }\n}\n\nfunction convertPomNode(\n nodeType: string,\n tagName: string,\n attrs: Record<string, string>,\n childElements: XmlElement[],\n textContent: string | undefined,\n errors: string[],\n theme: ThemeContext,\n xmlNode?: XmlElement,\n): Record<string, unknown> {\n const result: Record<string, unknown> = { type: nodeType };\n const def = getNodeMetadata(nodeType as POMNode[\"type\"]);\n\n // Expand dot-notation attributes (e.g., fill.color=\"hex\" → { fill: { color: \"hex\" } })\n const { regular: regularAttrs, dotGroups } = expandDotNotation(attrs);\n\n for (const [prefix, subAttrs] of Object.entries(dotGroups)) {\n if (prefix === \"type\") continue;\n const rule = getCoercionRule(nodeType, prefix);\n if (rule) {\n result[prefix] = coerceDotGroup(prefix, subAttrs, rule, tagName, errors);\n } else {\n const knownAttrs = getKnownAttributes(nodeType);\n const suggestion = findClosestMatch(prefix, knownAttrs);\n if (suggestion) {\n errors.push(\n `<${tagName}>: Unknown attribute \"${prefix}\". Did you mean \"${suggestion}\"?`,\n );\n } else {\n errors.push(`<${tagName}>: Unknown attribute \"${prefix}\"`);\n }\n }\n }\n\n for (const [key, value] of Object.entries(regularAttrs)) {\n if (key === \"type\") continue;\n // Conflict check: dot-notation and regular attribute for the same key\n if (key in dotGroups) {\n const ruleForConflict = getCoercionRule(nodeType, key);\n if (ruleForConflict) {\n const resolved = resolveMixedNotationShorthand(value, ruleForConflict);\n if (resolved.mode === \"ignore\") {\n continue;\n }\n if (resolved.mode === \"merge\") {\n result[key] = {\n ...resolved.value,\n ...(result[key] as Record<string, unknown>),\n };\n continue;\n }\n }\n errors.push(\n `<${tagName}>: Attribute \"${key}\" conflicts with dot-notation attributes (e.g., \"${key}.xxx\"). Use one or the other, not both`,\n );\n continue;\n }\n const rule = getCoercionRule(nodeType, key);\n if (rule) {\n const coerced = coerceWithRule(value, rule);\n if (coerced.error !== null) {\n errors.push(`<${tagName}>: ${coerced.error}`);\n } else {\n result[key] = coerced.value;\n }\n } else if (UNIVERSAL_ATTRS.has(key)) {\n // Allow universal attributes (e.g., x/y for Layer children)\n result[key] = coerceFallback(value);\n } else {\n // Unknown attribute\n const knownAttrs = getKnownAttributes(nodeType);\n const suggestion = findClosestMatch(key, knownAttrs);\n if (suggestion) {\n errors.push(\n `<${tagName}>: Unknown attribute \"${key}\". Did you mean \"${suggestion}\"?`,\n );\n } else {\n errors.push(`<${tagName}>: Unknown attribute \"${key}\"`);\n }\n }\n }\n\n // Text content → text property for nodes that support it\n if (textContent !== undefined && def.textContentProperty) {\n if (!(def.textContentProperty in result)) {\n result[def.textContentProperty] = textContent;\n }\n }\n\n // Child element notation for complex properties\n const childRule = def.xmlChildRule;\n if (childRule && childElements.length > 0) {\n applyXmlChildRule(\n childRule,\n nodeType,\n tagName,\n childElements,\n result,\n errors,\n xmlNode,\n );\n }\n // Children for container nodes\n else if (\n def.childPolicy.kind === \"pom-children\" &&\n childElements.length > 0\n ) {\n const convertedChildren = childElements\n .map((child) => convertElement(child, errors, theme))\n .filter((child): child is Record<string, unknown> => child !== null);\n result.children = convertedChildren;\n }\n // Leaf nodes that shouldn't have child elements\n else if (\n def.childPolicy.kind !== \"pom-children\" &&\n !childRule &&\n childElements.length > 0\n ) {\n errors.push(\n `<${tagName}>: Unexpected child elements. <${tagName}> does not accept child elements`,\n );\n }\n\n // テーマトークン参照(色属性中の \"$name\")を Zod 検証より前に解決する。\n // children は各子ノードの convertPomNode で解決済みのためスキップする。\n for (const [key, value] of Object.entries(result)) {\n if (key === \"type\" || key === \"children\") continue;\n result[key] = resolveThemeTokensDeep(\n value,\n key,\n theme.tokens,\n theme.declared,\n errors,\n );\n }\n\n // Zod validation for leaf nodes\n if (def.childPolicy.kind !== \"pom-children\") {\n validateLeafNode(nodeType, result, errors);\n }\n\n // Icon: normalize color / bgColor\n if (nodeType === \"icon\") {\n if (typeof result.color === \"string\" && !result.color.startsWith(\"#\")) {\n result.color = `#${result.color}`;\n }\n if (typeof result.bgColor === \"string\" && !result.bgColor.startsWith(\"#\")) {\n result.bgColor = `#${result.bgColor}`;\n }\n }\n\n // Svg: normalize color and validate svgContent\n if (nodeType === \"svg\") {\n if (typeof result.color === \"string\" && !result.color.startsWith(\"#\")) {\n result.color = `#${result.color}`;\n }\n if (result.svgContent === undefined) {\n errors.push(\"<Svg>: A <svg> child element is required\");\n }\n }\n\n return result;\n}\n\n/**\n * XML 文字列を POMNode 配列に変換する。\n *\n * 最上位は `<Slide>` 要素と `<Theme>` 要素のみが許容される。各 `<Slide>` が\n * 1 つのスライドに対応し、その子要素がスライドのルート POMNode となる。\n * 子要素が複数ある場合は暗黙的に VStack でラップされる。\n *\n * `<Theme>` は文書全体に適用されるデザイントークン(配色)の宣言で、最大 1 つ\n * 置ける。属性名がトークン名、属性値が 6 桁 hex の色値となり、各ノードの色属性\n * から `$トークン名` で参照できる。参照は parse 時に解決されるため、返される\n * POMNode には解決済みの hex 値が入る(`<Theme>` 自体はノードにならない)。\n *\n * XML タグは POM ノードタイプにマッピングされ、属性値は Zod スキーマを参照して\n * 適切な型(number, boolean, array, object)に変換される。\n * 未知のタグ名が指定された場合はエラーがスローされる。\n *\n * @example\n * ```typescript\n * import { parseXml, buildPptx } from \"@hirokisakabe/pom\";\n *\n * const xml = `\n * <Slide>\n * <VStack gap=\"16\" padding=\"32\">\n * <Text fontSize=\"32\" bold=\"true\">売上レポート</Text>\n * </VStack>\n * </Slide>\n * `;\n *\n * const nodes = parseXml(xml);\n * const pptx = await buildPptx(nodes, { w: 1280, h: 720 });\n * ```\n */\nexport function parseXml(xmlString: string): POMNode[] {\n if (!xmlString.trim()) return [];\n\n const parser = new XMLParser({\n preserveOrder: true,\n ignoreAttributes: false,\n attributeNamePrefix: \"@_\",\n parseAttributeValue: false,\n parseTagValue: false,\n trimValues: false,\n });\n\n const wrappedXml = `<__root__>${xmlString}</__root__>`;\n const parsed: XmlElement[] = parser.parse(wrappedXml) as XmlElement[];\n\n if (!parsed || parsed.length === 0) return [];\n\n const rootElement = parsed[0];\n const rootChildren = (rootElement[\"__root__\"] ?? []) as XmlNode[];\n\n const errors: string[] = [];\n const topLevelElements = rootChildren.filter(\n (child): child is XmlElement => !isTextNode(child),\n );\n\n // <Theme> はスライドより先に収集する(出現位置によらず文書全体に適用)\n const theme: ThemeContext = { tokens: {}, declared: false };\n for (const element of topLevelElements) {\n if (getTagName(element) !== \"Theme\") continue;\n if (theme.declared) {\n errors.push(\n `Only one <Theme> element is allowed, but multiple were found`,\n );\n continue;\n }\n theme.declared = true;\n parseThemeElement(element, theme.tokens, errors);\n }\n\n const slideElements = topLevelElements.filter(\n (element) => getTagName(element) !== \"Theme\",\n );\n\n const nodes: POMNode[] = [];\n for (const slideEl of slideElements) {\n const tagName = getTagName(slideEl);\n if (tagName !== \"Slide\") {\n errors.push(\n `Top-level element must be <Slide> or <Theme>, but got <${tagName}>. Wrap your slide content in <Slide>...</Slide>.`,\n );\n continue;\n }\n if (Object.keys(getAttributes(slideEl)).length > 0) {\n errors.push(`<Slide>: Attributes are not supported`);\n }\n const slideChildren = getChildElements(slideEl);\n if (slideChildren.length === 0) {\n errors.push(`<Slide> must contain at least one child element`);\n continue;\n }\n const converted = slideChildren\n .map((child) => convertElement(child, errors, theme))\n .filter((c): c is Record<string, unknown> => c !== null);\n if (converted.length === 0) continue;\n if (converted.length === 1) {\n nodes.push(converted[0] as POMNode);\n } else {\n nodes.push({\n type: \"vstack\",\n children: converted,\n } as POMNode);\n }\n }\n\n if (errors.length > 0) {\n throw new ParseXmlError(errors);\n }\n\n return nodes;\n}\n"],"mappings":";;;;;AAiCA,IAAa,gBAAb,cAAmC,MAAM;CACvC;CACA,YAAY,QAAkB;EAC5B,MAAM,UAAU,0BAA0B,OAAO,OAAO,QAAQ,OAAO,SAAS,IAAI,MAAM,GAAG,MAAM,OAAO,KAAK,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,IAAI;EAC1I,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS;CAChB;AACF;AAGmD,OAAO,YACxD,cAAc,KAAK,QAAQ,CAAC,IAAI,SAAS,IAAI,IAAI,CAAC,CACpD;AAEA,MAAM,kBAAkB,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC;AAG1C,SAAS,mBAAmB,UAA4B;CACtD,MAAM,QAAQ,kBAAkB;CAChC,IAAI,CAAC,OAAO,OAAO,CAAC;CACpB,OAAO,OAAO,KAAK,KAAK;AAC1B;AAEA,SAAS,oBAAoB,GAAW,GAAmB;CACzD,MAAM,IAAI,EAAE;CACZ,MAAM,IAAI,EAAE;CACZ,MAAM,KAAiB,MAAM,KAAK,EAAE,QAAQ,IAAI,EAAE,SAChD,MAAc,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAC7B;CACA,KAAK,IAAI,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,EAAE,CAAC,KAAK;CACxC,KAAK,IAAI,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,EAAE,CAAC,KAAK;CACxC,KAAK,IAAI,IAAI,GAAG,KAAK,GAAG,KACtB,KAAK,IAAI,IAAI,GAAG,KAAK,GAAG,KACtB,GAAG,EAAE,CAAC,KACJ,EAAE,IAAI,OAAO,EAAE,IAAI,KACf,GAAG,IAAI,EAAE,CAAC,IAAI,KACd,IAAI,KAAK,I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CAAC,SAAS,GAC/C,OAAO,KAAK,uCAAuC;EAErD,MAAM,gBAAgB,iBAAiB,OAAO;EAC9C,IAAI,cAAc,WAAW,GAAG;GAC9B,OAAO,KAAK,iDAAiD;GAC7D;EACF;EACA,MAAM,YAAY,cACf,KAAK,UAAU,eAAe,OAAO,QAAQ,KAAK,CAAC,CAAC,CACpD,QAAQ,MAAoC,MAAM,IAAI;EACzD,IAAI,UAAU,WAAW,GAAG;EAC5B,IAAI,UAAU,WAAW,GACvB,MAAM,KAAK,UAAU,EAAa;OAElC,MAAM,KAAK;GACT,MAAM;GACN,UAAU;EACZ,CAAY;CAEhB;CAEA,IAAI,OAAO,SAAS,GAClB,MAAM,IAAI,cAAc,MAAM;CAGhC,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializeXml.d.ts","names":[],"sources":["../../src/parseXml/serializeXml.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"serializeXml.d.ts","names":[],"sources":["../../src/parseXml/serializeXml.ts"],"mappings":";;;;;AAsJA;;;;AAA6C;;;;;;;;;;iBAA7B,YAAA,CAAa,KAAgB,EAAT,OAAO"}
|
|
@@ -36,6 +36,7 @@ function serializeRun(run) {
|
|
|
36
36
|
const spanAttrs = [];
|
|
37
37
|
if (run.color) spanAttrs.push(`color="${escapeAttrValue(run.color)}"`);
|
|
38
38
|
if (run.fontFamily) spanAttrs.push(`fontFamily="${escapeAttrValue(run.fontFamily)}"`);
|
|
39
|
+
if (run.fontSize !== void 0) spanAttrs.push(`fontSize="${run.fontSize}"`);
|
|
39
40
|
if (run.letterSpacing !== void 0) spanAttrs.push(`letterSpacing="${run.letterSpacing}"`);
|
|
40
41
|
if (spanAttrs.length > 0) content = `<${INLINE_SPAN_TAG} ${spanAttrs.join(" ")}>${content}</${INLINE_SPAN_TAG}>`;
|
|
41
42
|
for (let i = INLINE_BOOLEAN_FORMATS.length - 1; i >= 0; i--) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializeXml.js","names":[],"sources":["../../src/parseXml/serializeXml.ts"],"sourcesContent":["import type { POMNode } from \"../types.ts\";\nimport { getNodeMetadata } from \"../registry/nodeMetadata.ts\";\nimport {\n INLINE_BOOLEAN_FORMATS,\n INLINE_LINK_TAG,\n INLINE_MARK_TAG,\n INLINE_SPAN_TAG,\n type TextRun,\n} from \"../registry/xmlChildRules.ts\";\n\n// runs と svgContent は専用の直列化パスで処理する\nconst SKIP_KEYS = new Set([\"type\", \"children\", \"runs\", \"svgContent\"]);\n\nfunction escapeAttrValue(value: string): string {\n return value\n .replace(/&/g, \"&\")\n .replace(/\"/g, \""\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\");\n}\n\nfunction escapeXmlContent(value: string): string {\n return value\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\");\n}\n\nfunction serializePrimitive(value: string | number | boolean): string {\n if (typeof value === \"string\") return escapeAttrValue(value);\n if (typeof value === \"number\") return String(value);\n return value ? \"true\" : \"false\";\n}\n\nfunction serializeAttrs(node: Record<string, unknown>): string {\n const parts: string[] = [];\n for (const [key, value] of Object.entries(node)) {\n if (SKIP_KEYS.has(key) || value === undefined) continue;\n if (typeof value === \"object\" && value !== null && !Array.isArray(value)) {\n for (const [subKey, subValue] of Object.entries(\n value as Record<string, unknown>,\n )) {\n if (subValue !== undefined) {\n parts.push(\n `${key}.${subKey}=\"${serializePrimitive(subValue as string | number | boolean)}\"`,\n );\n }\n }\n } else if (Array.isArray(value)) {\n parts.push(`${key}=\"${escapeAttrValue(JSON.stringify(value))}\"`);\n } else if (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\"\n ) {\n parts.push(`${key}=\"${serializePrimitive(value)}\"`);\n }\n }\n return parts.length > 0 ? \" \" + parts.join(\" \") : \"\";\n}\n\nfunction serializeRun(run: TextRun): string {\n let content = escapeXmlContent(run.text);\n\n if (run.href) {\n content = `<${INLINE_LINK_TAG} href=\"${escapeAttrValue(run.href)}\">${content}</${INLINE_LINK_TAG}>`;\n }\n if (run.highlight) {\n content = `<${INLINE_MARK_TAG} color=\"${escapeAttrValue(run.highlight)}\">${content}</${INLINE_MARK_TAG}>`;\n }\n const spanAttrs: string[] = [];\n if (run.color) spanAttrs.push(`color=\"${escapeAttrValue(run.color)}\"`);\n if (run.fontFamily)\n spanAttrs.push(`fontFamily=\"${escapeAttrValue(run.fontFamily)}\"`);\n if (run.letterSpacing !== undefined)\n spanAttrs.push(`letterSpacing=\"${run.letterSpacing}\"`);\n if (spanAttrs.length > 0) {\n content = `<${INLINE_SPAN_TAG} ${spanAttrs.join(\" \")}>${content}</${INLINE_SPAN_TAG}>`;\n }\n // INLINE_BOOLEAN_FORMATS は外側→内側のネスト順なので、内側から順に包む\n for (let i = INLINE_BOOLEAN_FORMATS.length - 1; i >= 0; i--) {\n const { tag, property } = INLINE_BOOLEAN_FORMATS[i];\n if (run[property]) content = `<${tag}>${content}</${tag}>`;\n }\n return content;\n}\n\nfunction serializeRuns(runs: TextRun[]): string {\n return runs.map(serializeRun).join(\"\");\n}\n\nfunction serializeNode(node: POMNode, depth: number): string {\n const indent = \" \".repeat(depth);\n const def = getNodeMetadata(node.type);\n const tag = def.tagName;\n const nodeRecord = node as Record<string, unknown>;\n\n if (def.childPolicy.kind === \"pom-children\") {\n const children = (nodeRecord.children as POMNode[]) ?? [];\n const attrStr = serializeAttrs(nodeRecord);\n if (children.length === 0) {\n return `${indent}<${tag}${attrStr} />`;\n }\n const childrenStr = children\n .map((c) => serializeNode(c, depth + 1))\n .join(\"\\n\");\n return `${indent}<${tag}${attrStr}>\\n${childrenStr}\\n${indent}</${tag}>`;\n }\n\n if (node.type === \"svg\") {\n const svgContent = (nodeRecord.svgContent as string) ?? \"\";\n const attrStr = serializeAttrs(nodeRecord);\n return `${indent}<${tag}${attrStr}>\\n${svgContent}\\n${indent}</${tag}>`;\n }\n\n // Text / Shape: runs があればインライン child element として直列化し装飾を保持する\n if (\n def.supportsInlineRuns &&\n Array.isArray(nodeRecord.runs) &&\n (nodeRecord.runs as unknown[]).length > 0\n ) {\n const runs = nodeRecord.runs as TextRun[];\n // runs がある場合、text は runs から復元できるため属性からも除外する\n const attrsWithoutText = { ...nodeRecord, text: undefined };\n const attrStr = serializeAttrs(attrsWithoutText);\n const inlineContent = serializeRuns(runs);\n return `${indent}<${tag}${attrStr}>${inlineContent}</${tag}>`;\n }\n\n const attrStr = serializeAttrs(nodeRecord);\n return `${indent}<${tag}${attrStr} />`;\n}\n\n/**\n * POMNode 配列を XML 文字列に変換する。\n *\n * parseXml の逆操作として機能する。runs(インライン装飾)は\n * B/I/A/U/S/Sub/Sup/Mark/Span タグとして child element に直列化されるため、\n * テキストの装飾情報も保持される。\n *\n * @example\n * ```typescript\n * import { parseXml, serializeXml } from \"@hirokisakabe/pom\";\n *\n * const nodes = parseXml(xml);\n * // ... ノードの並び替えなど ...\n * const newXml = serializeXml(nodes);\n * ```\n */\nexport function serializeXml(nodes: POMNode[]): string {\n return nodes\n .map((node) => `<Slide>\\n${serializeNode(node, 1)}\\n</Slide>`)\n .join(\"\\n\");\n}\n"],"mappings":";;;AAWA,MAAM,YAAY,IAAI,IAAI;CAAC;CAAQ;CAAY;CAAQ;AAAY,CAAC;AAEpE,SAAS,gBAAgB,OAAuB;CAC9C,OAAO,MACJ,QAAQ,MAAM,OAAO,CAAC,CACtB,QAAQ,MAAM,QAAQ,CAAC,CACvB,QAAQ,MAAM,MAAM,CAAC,CACrB,QAAQ,MAAM,MAAM;AACzB;AAEA,SAAS,iBAAiB,OAAuB;CAC/C,OAAO,MACJ,QAAQ,MAAM,OAAO,CAAC,CACtB,QAAQ,MAAM,MAAM,CAAC,CACrB,QAAQ,MAAM,MAAM;AACzB;AAEA,SAAS,mBAAmB,OAA0C;CACpE,IAAI,OAAO,UAAU,UAAU,OAAO,gBAAgB,KAAK;CAC3D,IAAI,OAAO,UAAU,UAAU,OAAO,OAAO,KAAK;CAClD,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ACa,EAAE,IAAI,IAAI;CAC7D;CAGA,OAAO,GAAG,OAAO,GAAG,MADJ,eAAe,UACC,EAAE;AACpC;;;;;;;;;;;;;;;;;AAkBA,SAAgB,aAAa,OAA0B;CACrD,OAAO,MACJ,KAAK,SAAS,YAAY,cAAc,MAAM,CAAC,EAAE,WAAW,CAAC,CAC7D,KAAK,IAAI;AACd"}
|
|
1
|
+
{"version":3,"file":"serializeXml.js","names":[],"sources":["../../src/parseXml/serializeXml.ts"],"sourcesContent":["import type { POMNode } from \"../types.ts\";\nimport { getNodeMetadata } from \"../registry/nodeMetadata.ts\";\nimport {\n INLINE_BOOLEAN_FORMATS,\n INLINE_LINK_TAG,\n INLINE_MARK_TAG,\n INLINE_SPAN_TAG,\n type TextRun,\n} from \"../registry/xmlChildRules.ts\";\n\n// runs と svgContent は専用の直列化パスで処理する\nconst SKIP_KEYS = new Set([\"type\", \"children\", \"runs\", \"svgContent\"]);\n\nfunction escapeAttrValue(value: string): string {\n return value\n .replace(/&/g, \"&\")\n .replace(/\"/g, \""\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\");\n}\n\nfunction escapeXmlContent(value: string): string {\n return value\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\");\n}\n\nfunction serializePrimitive(value: string | number | boolean): string {\n if (typeof value === \"string\") return escapeAttrValue(value);\n if (typeof value === \"number\") return String(value);\n return value ? \"true\" : \"false\";\n}\n\nfunction serializeAttrs(node: Record<string, unknown>): string {\n const parts: string[] = [];\n for (const [key, value] of Object.entries(node)) {\n if (SKIP_KEYS.has(key) || value === undefined) continue;\n if (typeof value === \"object\" && value !== null && !Array.isArray(value)) {\n for (const [subKey, subValue] of Object.entries(\n value as Record<string, unknown>,\n )) {\n if (subValue !== undefined) {\n parts.push(\n `${key}.${subKey}=\"${serializePrimitive(subValue as string | number | boolean)}\"`,\n );\n }\n }\n } else if (Array.isArray(value)) {\n parts.push(`${key}=\"${escapeAttrValue(JSON.stringify(value))}\"`);\n } else if (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\"\n ) {\n parts.push(`${key}=\"${serializePrimitive(value)}\"`);\n }\n }\n return parts.length > 0 ? \" \" + parts.join(\" \") : \"\";\n}\n\nfunction serializeRun(run: TextRun): string {\n let content = escapeXmlContent(run.text);\n\n if (run.href) {\n content = `<${INLINE_LINK_TAG} href=\"${escapeAttrValue(run.href)}\">${content}</${INLINE_LINK_TAG}>`;\n }\n if (run.highlight) {\n content = `<${INLINE_MARK_TAG} color=\"${escapeAttrValue(run.highlight)}\">${content}</${INLINE_MARK_TAG}>`;\n }\n const spanAttrs: string[] = [];\n if (run.color) spanAttrs.push(`color=\"${escapeAttrValue(run.color)}\"`);\n if (run.fontFamily)\n spanAttrs.push(`fontFamily=\"${escapeAttrValue(run.fontFamily)}\"`);\n if (run.fontSize !== undefined) spanAttrs.push(`fontSize=\"${run.fontSize}\"`);\n if (run.letterSpacing !== undefined)\n spanAttrs.push(`letterSpacing=\"${run.letterSpacing}\"`);\n if (spanAttrs.length > 0) {\n content = `<${INLINE_SPAN_TAG} ${spanAttrs.join(\" \")}>${content}</${INLINE_SPAN_TAG}>`;\n }\n // INLINE_BOOLEAN_FORMATS は外側→内側のネスト順なので、内側から順に包む\n for (let i = INLINE_BOOLEAN_FORMATS.length - 1; i >= 0; i--) {\n const { tag, property } = INLINE_BOOLEAN_FORMATS[i];\n if (run[property]) content = `<${tag}>${content}</${tag}>`;\n }\n return content;\n}\n\nfunction serializeRuns(runs: TextRun[]): string {\n return runs.map(serializeRun).join(\"\");\n}\n\nfunction serializeNode(node: POMNode, depth: number): string {\n const indent = \" \".repeat(depth);\n const def = getNodeMetadata(node.type);\n const tag = def.tagName;\n const nodeRecord = node as Record<string, unknown>;\n\n if (def.childPolicy.kind === \"pom-children\") {\n const children = (nodeRecord.children as POMNode[]) ?? [];\n const attrStr = serializeAttrs(nodeRecord);\n if (children.length === 0) {\n return `${indent}<${tag}${attrStr} />`;\n }\n const childrenStr = children\n .map((c) => serializeNode(c, depth + 1))\n .join(\"\\n\");\n return `${indent}<${tag}${attrStr}>\\n${childrenStr}\\n${indent}</${tag}>`;\n }\n\n if (node.type === \"svg\") {\n const svgContent = (nodeRecord.svgContent as string) ?? \"\";\n const attrStr = serializeAttrs(nodeRecord);\n return `${indent}<${tag}${attrStr}>\\n${svgContent}\\n${indent}</${tag}>`;\n }\n\n // Text / Shape: runs があればインライン child element として直列化し装飾を保持する\n if (\n def.supportsInlineRuns &&\n Array.isArray(nodeRecord.runs) &&\n (nodeRecord.runs as unknown[]).length > 0\n ) {\n const runs = nodeRecord.runs as TextRun[];\n // runs がある場合、text は runs から復元できるため属性からも除外する\n const attrsWithoutText = { ...nodeRecord, text: undefined };\n const attrStr = serializeAttrs(attrsWithoutText);\n const inlineContent = serializeRuns(runs);\n return `${indent}<${tag}${attrStr}>${inlineContent}</${tag}>`;\n }\n\n const attrStr = serializeAttrs(nodeRecord);\n return `${indent}<${tag}${attrStr} />`;\n}\n\n/**\n * POMNode 配列を XML 文字列に変換する。\n *\n * parseXml の逆操作として機能する。runs(インライン装飾)は\n * B/I/A/U/S/Sub/Sup/Mark/Span タグとして child element に直列化されるため、\n * テキストの装飾情報も保持される。\n *\n * @example\n * ```typescript\n * import { parseXml, serializeXml } from \"@hirokisakabe/pom\";\n *\n * const nodes = parseXml(xml);\n * // ... ノードの並び替えなど ...\n * const newXml = serializeXml(nodes);\n * ```\n */\nexport function serializeXml(nodes: POMNode[]): string {\n return nodes\n .map((node) => `<Slide>\\n${serializeNode(node, 1)}\\n</Slide>`)\n .join(\"\\n\");\n}\n"],"mappings":";;;AAWA,MAAM,YAAY,IAAI,IAAI;CAAC;CAAQ;CAAY;CAAQ;AAAY,CAAC;AAEpE,SAAS,gBAAgB,OAAuB;CAC9C,OAAO,MACJ,QAAQ,MAAM,OAAO,CAAC,CACtB,QAAQ,MAAM,QAAQ,CAAC,CACvB,QAAQ,MAAM,MAAM,CAAC,CACrB,QAAQ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A,IAAI,KAAK,SAAS,OAAO;EACvB,MAAM,aAAc,WAAW,cAAyB;EAExD,OAAO,GAAG,OAAO,GAAG,MADJ,eAAe,UACC,EAAE,KAAK,WAAW,IAAI,OAAO,IAAI,IAAI;CACvE;CAGA,IACE,IAAI,sBACJ,MAAM,QAAQ,WAAW,IAAI,KAC5B,WAAW,KAAmB,SAAS,GACxC;EACA,MAAM,OAAO,WAAW;EAKxB,OAAO,GAAG,OAAO,GAAG,MAFJ,eAAe;GADJ,GAAG;GAAY,MAAM,KAAA;EACF,CAEd,EAAE,GADZ,cAAc,IACa,EAAE,IAAI,IAAI;CAC7D;CAGA,OAAO,GAAG,OAAO,GAAG,MADJ,eAAe,UACC,EAAE;AACpC;;;;;;;;;;;;;;;;;AAkBA,SAAgB,aAAa,OAA0B;CACrD,OAAO,MACJ,KAAK,SAAS,YAAY,cAAc,MAAM,CAAC,EAAE,WAAW,CAAC,CAC7D,KAAK,IAAI;AACd"}
|
|
@@ -6,7 +6,8 @@ import { renderOlNode, renderUlNode } from "../../renderPptx/nodes/list.js";
|
|
|
6
6
|
function applyListYogaStyle(node, yn, yoga, ctx) {
|
|
7
7
|
const n = node;
|
|
8
8
|
const combinedText = n.items.map((item) => item.text).join("\n");
|
|
9
|
-
const
|
|
9
|
+
const baseFontSizePx = n.fontSize ?? 24;
|
|
10
|
+
const fontSizePx = Math.max(baseFontSizePx, ...n.items.flatMap((item) => [item.fontSize ?? baseFontSizePx, ...item.runs?.map((r) => r.fontSize ?? item.fontSize ?? baseFontSizePx) ?? []]));
|
|
10
11
|
const fontFamily = n.fontFamily ?? "Noto Sans JP";
|
|
11
12
|
const fontWeight = n.bold ? "bold" : "normal";
|
|
12
13
|
const spacingMultiple = n.lineHeight ?? 1.3;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","names":[],"sources":["../../../src/registry/definitions/list.ts"],"sourcesContent":["import type { POMNode } from \"../../types.ts\";\nimport type { NodeDefinition, Yoga } from \"../types.ts\";\nimport type { Node as YogaNode } from \"yoga-layout\";\nimport { measureText } from \"../../calcYogaLayout/measureText.ts\";\nimport { measureFontLineHeightRatio } from \"../../calcYogaLayout/fontLoader.ts\";\nimport type { BuildContext } from \"../../buildContext.ts\";\nimport { renderUlNode, renderOlNode } from \"../../renderPptx/nodes/list.ts\";\nimport { getNodeMetadata } from \"../nodeMetadata.ts\";\n\nfunction applyListYogaStyle(\n node: POMNode,\n yn: YogaNode,\n yoga: Yoga,\n ctx: BuildContext,\n) {\n const n = node as Extract<POMNode, { type: \"ul\" | \"ol\" }>;\n const combinedText = n.items.map((item) => item.text).join(\"\\n\");\n const
|
|
1
|
+
{"version":3,"file":"list.js","names":[],"sources":["../../../src/registry/definitions/list.ts"],"sourcesContent":["import type { POMNode } from \"../../types.ts\";\nimport type { NodeDefinition, Yoga } from \"../types.ts\";\nimport type { Node as YogaNode } from \"yoga-layout\";\nimport { measureText } from \"../../calcYogaLayout/measureText.ts\";\nimport { measureFontLineHeightRatio } from \"../../calcYogaLayout/fontLoader.ts\";\nimport type { BuildContext } from \"../../buildContext.ts\";\nimport { renderUlNode, renderOlNode } from \"../../renderPptx/nodes/list.ts\";\nimport { getNodeMetadata } from \"../nodeMetadata.ts\";\n\nfunction applyListYogaStyle(\n node: POMNode,\n yn: YogaNode,\n yoga: Yoga,\n ctx: BuildContext,\n) {\n const n = node as Extract<POMNode, { type: \"ul\" | \"ol\" }>;\n const combinedText = n.items.map((item) => item.text).join(\"\\n\");\n const baseFontSizePx = n.fontSize ?? 24;\n // Li 単位の fontSize 上書きと、Li 内 <Span fontSize=\"...\"> による run 単位\n // 上書きを両方考慮した最大値で計測する。単一 fontSize でしか計測できない\n // 制約に対する保守的な見積もりで、横方向は過剰評価になるが縦方向 clipping\n // を防ぐ。\n const fontSizePx = Math.max(\n baseFontSizePx,\n ...n.items.flatMap((item) => [\n item.fontSize ?? baseFontSizePx,\n ...(item.runs?.map(\n (r) => r.fontSize ?? item.fontSize ?? baseFontSizePx,\n ) ?? []),\n ]),\n );\n const fontFamily = n.fontFamily ?? \"Noto Sans JP\";\n const fontWeight = n.bold ? \"bold\" : \"normal\";\n const spacingMultiple = n.lineHeight ?? 1.3;\n\n const fontMetricsRatio = measureFontLineHeightRatio(fontWeight);\n const lineHeight = fontMetricsRatio * spacingMultiple;\n\n // バレット/番号のインデント幅(pptxgenjs DEF_BULLET_MARGIN = 27pt = 36px @96dpi)\n const bulletIndentPx = 36;\n\n yn.setMeasureFunc((width, widthMode) => {\n const maxWidthPx = (() => {\n switch (widthMode) {\n case yoga.MEASURE_MODE_UNDEFINED:\n return Number.POSITIVE_INFINITY;\n case yoga.MEASURE_MODE_EXACTLY:\n case yoga.MEASURE_MODE_AT_MOST:\n return width;\n default:\n return Number.POSITIVE_INFINITY;\n }\n })();\n\n const textMaxWidthPx = Math.max(0, maxWidthPx - bulletIndentPx);\n\n const { widthPx, heightPx } = measureText(\n combinedText,\n textMaxWidthPx,\n {\n fontFamily,\n fontSizePx,\n lineHeight,\n fontWeight,\n },\n ctx.textMeasurementMode,\n );\n\n return {\n width: widthPx + bulletIndentPx,\n height: heightPx,\n };\n });\n}\n\nexport const ulNodeDef: NodeDefinition = {\n ...getNodeMetadata(\"ul\"),\n applyYogaStyle: applyListYogaStyle,\n render(node, ctx) {\n renderUlNode(node as Extract<typeof node, { type: \"ul\" }>, ctx);\n },\n};\n\nexport const olNodeDef: NodeDefinition = {\n ...getNodeMetadata(\"ol\"),\n applyYogaStyle: applyListYogaStyle,\n render(node, ctx) {\n renderOlNode(node as Extract<typeof node, { type: \"ol\" }>, ctx);\n },\n};\n"],"mappings":";;;;;AASA,SAAS,mBACP,MACA,IACA,MACA,KACA;CACA,MAAM,IAAI;CACV,MAAM,eAAe,EAAE,MAAM,KAAK,SAAS,KAAK,IAAI,CAAC,CAAC,KAAK,IAAI;CAC/D,MAAM,iBAAiB,EAAE,YAAY;CAKrC,MAAM,aAAa,KAAK,IACtB,gBACA,GAAG,EAAE,MAAM,SAAS,SAAS,CAC3B,KAAK,YAAY,gBACjB,GAAI,KAAK,MAAM,KACZ,MAAM,EAAE,YAAY,KAAK,YAAY,cACxC,KAAK,CAAC,CACR,CAAC,CACH;CACA,MAAM,aAAa,EAAE,cAAc;CACnC,MAAM,aAAa,EAAE,OAAO,SAAS;CACrC,MAAM,kBAAkB,EAAE,cAAc;CAGxC,MAAM,aADmB,2BAA2B,UAClB,IAAI;CAGtC,MAAM,iBAAiB;CAEvB,GAAG,gBAAgB,OAAO,cAAc;EACtC,MAAM,oBAAoB;GACxB,QAAQ,WAAR;IACE,KAAK,KAAK,wBACR,OAAO,OAAO;IAChB,KAAK,KAAK;IACV,KAAK,KAAK,sBACR,OAAO;IACT,SACE,OAAO,OAAO;GAClB;EACF,EAAA,CAAG;EAIH,MAAM,EAAE,SAAS,aAAa,YAC5B,cAHqB,KAAK,IAAI,GAAG,aAAa,cAIjC,GACb;GACE;GACA;GACA;GACA;EACF,GACA,IAAI,mBACN;EAEA,OAAO;GACL,OAAO,UAAU;GACjB,QAAQ;EACV;CACF,CAAC;AACH;AAEA,MAAa,YAA4B;CACvC,GAAG,gBAAgB,IAAI;CACvB,gBAAgB;CAChB,OAAO,MAAM,KAAK;EAChB,aAAa,MAA8C,GAAG;CAChE;AACF;AAEA,MAAa,YAA4B;CACvC,GAAG,gBAAgB,IAAI;CACvB,gBAAgB;CAChB,OAAO,MAAM,KAAK;EAChB,aAAa,MAA8C,GAAG;CAChE;AACF"}
|
|
@@ -7,7 +7,8 @@ const textNodeDef = {
|
|
|
7
7
|
applyYogaStyle(node, yn, yoga, ctx) {
|
|
8
8
|
const n = node;
|
|
9
9
|
const text = n.text;
|
|
10
|
-
const
|
|
10
|
+
const baseFontSizePx = n.fontSize ?? 24;
|
|
11
|
+
const fontSizePx = Math.max(baseFontSizePx, ...n.runs?.map((r) => r.fontSize ?? baseFontSizePx) ?? []);
|
|
11
12
|
const fontFamily = n.fontFamily ?? "Noto Sans JP";
|
|
12
13
|
const fontWeight = n.bold ? "bold" : "normal";
|
|
13
14
|
const lineHeight = n.lineHeight ?? 1.3;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","names":[],"sources":["../../../src/registry/definitions/text.ts"],"sourcesContent":["import type { POMNode } from \"../../types.ts\";\nimport type { NodeDefinition, Yoga } from \"../types.ts\";\nimport type { Node as YogaNode } from \"yoga-layout\";\nimport { measureText } from \"../../calcYogaLayout/measureText.ts\";\nimport type { BuildContext } from \"../../buildContext.ts\";\nimport { renderTextNode } from \"../../renderPptx/nodes/text.ts\";\nimport { getNodeMetadata } from \"../nodeMetadata.ts\";\n\nexport const textNodeDef: NodeDefinition = {\n ...getNodeMetadata(\"text\"),\n applyYogaStyle(node: POMNode, yn: YogaNode, yoga: Yoga, ctx: BuildContext) {\n const n = node as Extract<POMNode, { type: \"text\" }>;\n const text = n.text;\n const
|
|
1
|
+
{"version":3,"file":"text.js","names":[],"sources":["../../../src/registry/definitions/text.ts"],"sourcesContent":["import type { POMNode } from \"../../types.ts\";\nimport type { NodeDefinition, Yoga } from \"../types.ts\";\nimport type { Node as YogaNode } from \"yoga-layout\";\nimport { measureText } from \"../../calcYogaLayout/measureText.ts\";\nimport type { BuildContext } from \"../../buildContext.ts\";\nimport { renderTextNode } from \"../../renderPptx/nodes/text.ts\";\nimport { getNodeMetadata } from \"../nodeMetadata.ts\";\n\nexport const textNodeDef: NodeDefinition = {\n ...getNodeMetadata(\"text\"),\n applyYogaStyle(node: POMNode, yn: YogaNode, yoga: Yoga, ctx: BuildContext) {\n const n = node as Extract<POMNode, { type: \"text\" }>;\n const text = n.text;\n const baseFontSizePx = n.fontSize ?? 24;\n // runs に fontSize override がある場合は最大値で計測する(描画は run 単位で\n // 各自の fontSize が適用されるが、計測関数は単一 fontSize しか扱えないので\n // 最大値を採用して縦方向の clipping を防ぐ。\n // 横方向は最大値だと過剰評価になるが、典型ケース (大きな数字 + 小さい単位)\n // では小さい unit 部分が短く影響は軽微で、安全側に倒す)\n const fontSizePx = Math.max(\n baseFontSizePx,\n ...(n.runs?.map((r) => r.fontSize ?? baseFontSizePx) ?? []),\n );\n const fontFamily = n.fontFamily ?? \"Noto Sans JP\";\n const fontWeight = n.bold ? \"bold\" : \"normal\";\n const lineHeight = n.lineHeight ?? 1.3;\n const letterSpacingPx = n.letterSpacing;\n\n yn.setMeasureFunc((width, widthMode) => {\n const maxWidthPx = (() => {\n switch (widthMode) {\n case yoga.MEASURE_MODE_UNDEFINED:\n return Number.POSITIVE_INFINITY;\n case yoga.MEASURE_MODE_EXACTLY:\n case yoga.MEASURE_MODE_AT_MOST:\n return width;\n default:\n return Number.POSITIVE_INFINITY;\n }\n })();\n\n const { widthPx, heightPx } = measureText(\n text,\n maxWidthPx,\n {\n fontFamily,\n fontSizePx,\n lineHeight,\n fontWeight,\n letterSpacingPx,\n },\n ctx.textMeasurementMode,\n );\n\n return { width: widthPx, height: heightPx };\n });\n },\n render(node, ctx) {\n renderTextNode(node as Extract<typeof node, { type: \"text\" }>, ctx);\n },\n};\n"],"mappings":";;;;AAQA,MAAa,cAA8B;CACzC,GAAG,gBAAgB,MAAM;CACzB,eAAe,MAAe,IAAc,MAAY,KAAmB;EACzE,MAAM,IAAI;EACV,MAAM,OAAO,EAAE;EACf,MAAM,iBAAiB,EAAE,YAAY;EAMrC,MAAM,aAAa,KAAK,IACtB,gBACA,GAAI,EAAE,MAAM,KAAK,MAAM,EAAE,YAAY,cAAc,KAAK,CAAC,CAC3D;EACA,MAAM,aAAa,EAAE,cAAc;EACnC,MAAM,aAAa,EAAE,OAAO,SAAS;EACrC,MAAM,aAAa,EAAE,cAAc;EACnC,MAAM,kBAAkB,EAAE;EAE1B,GAAG,gBAAgB,OAAO,cAAc;GAatC,MAAM,EAAE,SAAS,aAAa,YAC5B,aAbwB;IACxB,QAAQ,WAAR;KACE,KAAK,KAAK,wBACR,OAAO,OAAO;KAChB,KAAK,KAAK;KACV,KAAK,KAAK,sBACR,OAAO;KACT,SACE,OAAO,OAAO;IAClB;GACF,EAAA,CAIW,GACT;IACE;IACA;IACA;IACA;IACA;GACF,GACA,IAAI,mBACN;GAEA,OAAO;IAAE,OAAO;IAAS,QAAQ;GAAS;EAC5C,CAAC;CACH;CACA,OAAO,MAAM,KAAK;EAChB,eAAe,MAAgD,GAAG;CACpE;AACF"}
|
|
@@ -33,7 +33,7 @@ const INLINE_BOOLEAN_FORMATS = [
|
|
|
33
33
|
const INLINE_MARK_TAG = "Mark";
|
|
34
34
|
/** Mark の color 属性省略時に適用される既定のハイライト色 */
|
|
35
35
|
const MARK_DEFAULT_HIGHLIGHT_COLOR = "FFFF00";
|
|
36
|
-
/** 文字スタイルタグ。color / fontFamily / letterSpacing 属性 → TextRun の同名 property */
|
|
36
|
+
/** 文字スタイルタグ。color / fontFamily / fontSize / letterSpacing 属性 → TextRun の同名 property */
|
|
37
37
|
const INLINE_SPAN_TAG = "Span";
|
|
38
38
|
/** インライン装飾として許容されるタグの一覧(エラーメッセージの列挙順) */
|
|
39
39
|
const INLINE_FORMAT_TAG_LIST = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xmlChildRules.js","names":[],"sources":["../../src/registry/xmlChildRules.ts"],"sourcesContent":["/**\n * parseXml / serializeXml が共有する XML child handling のルール定義。\n *\n * - インライン装飾タグ (B/I/A/U/S/Sub/Sup/Mark/Span) と TextRun property の対応\n * - ノードごとの XML child element 受け入れルール (XmlChildRule)\n *\n * parse 側 (parseXml.ts) と serialize 側 (serializeXml.ts) の双方がこの\n * モジュールを参照することで、タグ名・対応 property・許容 child のズレを防ぐ。\n * 依存方向は parseXml / serializeXml → registry の一方向に保つ(このモジュール\n * からは parseXml / serializeXml を import しない)。\n */\n\n// ===== インライン装飾 (B/I/A/U/S/Sub/Sup/Mark/Span) =====\n\n/** Text / Shape / Li / Td 内のインライン装飾を表すテキスト run */\nexport interface TextRun {\n text: string;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n strike?: boolean;\n subscript?: boolean;\n superscript?: boolean;\n highlight?: string;\n color?: string;\n href?: string;\n fontFamily?: string;\n letterSpacing?: number;\n}\n\n/**\n * boolean 装飾タグ ↔ TextRun property の対応。\n * 配列の順序は serialize 時のネスト順(先頭が最も外側)。\n */\nexport const INLINE_BOOLEAN_FORMATS: readonly {\n readonly tag: string;\n readonly property:\n | \"bold\"\n | \"italic\"\n | \"underline\"\n | \"strike\"\n | \"subscript\"\n | \"superscript\";\n}[] = [\n { tag: \"B\", property: \"bold\" },\n { tag: \"I\", property: \"italic\" },\n { tag: \"U\", property: \"underline\" },\n { tag: \"S\", property: \"strike\" },\n { tag: \"Sub\", property: \"subscript\" },\n { tag: \"Sup\", property: \"superscript\" },\n];\n\n/** ハイパーリンクタグ。href 属性 → TextRun.href */\nexport const INLINE_LINK_TAG = \"A\";\n\n/** ハイライトタグ。color 属性 → TextRun.highlight(省略時は既定色) */\nexport const INLINE_MARK_TAG = \"Mark\";\n\n/** Mark の color 属性省略時に適用される既定のハイライト色 */\nexport const MARK_DEFAULT_HIGHLIGHT_COLOR = \"FFFF00\";\n\n/** 文字スタイルタグ。color / fontFamily / letterSpacing 属性 → TextRun の同名 property */\nexport const INLINE_SPAN_TAG = \"Span\";\n\n/** インライン装飾として許容されるタグの一覧(エラーメッセージの列挙順) */\nexport const INLINE_FORMAT_TAG_LIST: readonly string[] = [\n \"B\",\n \"I\",\n \"A\",\n \"U\",\n \"S\",\n \"Sub\",\n \"Sup\",\n \"Mark\",\n \"Span\",\n];\n\n/** インライン装飾タグの集合(child element 判定用) */\nexport const INLINE_FORMAT_TAGS: ReadonlySet<string> = new Set(\n INLINE_FORMAT_TAG_LIST,\n);\n\n// ===== XML child element 受け入れルール =====\n\n/**\n * インライン装飾タグ (B/I/A/U/S/Mark/Span) のみを child として受け付け、\n * runs / text property へ変換するルール(Text 用)\n */\nexport interface InlineRunsChildRule {\n kind: \"inline-runs\";\n}\n\n/** 単一種類の child tag の繰り返しを受け取り、配列 property へ変換するルール */\nexport interface RepeatedChildRule {\n kind: \"repeated\";\n /** 受け付ける child tag 名 */\n childTag: string;\n /** 変換結果を格納する property 名 */\n property: string;\n /** 各 item が text content / インライン装飾タグを受け付けるか(Li 用) */\n allowsItemText?: boolean;\n}\n\n/**\n * parseXml 側の専用 converter で処理する複雑な child 構造\n * (ネスト構造や複数 property への振り分けを伴うもの)\n */\nexport interface NodeSpecificChildRule {\n kind: \"node-specific\";\n /** 直下で受け付ける child tag 名の一覧(unknown child エラーメッセージに使用) */\n expectedTags: readonly string[];\n}\n\nexport type XmlChildRule =\n | InlineRunsChildRule\n | RepeatedChildRule\n | NodeSpecificChildRule;\n\n/**\n * unknown child エラーメッセージ用に期待タグ一覧を整形する。\n * 例: [\"A\"] → \"<A>\" / [\"A\",\"B\"] → \"<A> or <B>\" / [\"A\",\"B\",\"C\"] → \"<A>, <B>, or <C>\"\n */\nexport function formatExpectedTags(tags: readonly string[]): string {\n const wrapped = tags.map((tag) => `<${tag}>`);\n if (wrapped.length === 1) return wrapped[0];\n if (wrapped.length === 2) return `${wrapped[0]} or ${wrapped[1]}`;\n return `${wrapped.slice(0, -1).join(\", \")}, or ${wrapped[wrapped.length - 1]}`;\n}\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"xmlChildRules.js","names":[],"sources":["../../src/registry/xmlChildRules.ts"],"sourcesContent":["/**\n * parseXml / serializeXml が共有する XML child handling のルール定義。\n *\n * - インライン装飾タグ (B/I/A/U/S/Sub/Sup/Mark/Span) と TextRun property の対応\n * - ノードごとの XML child element 受け入れルール (XmlChildRule)\n *\n * parse 側 (parseXml.ts) と serialize 側 (serializeXml.ts) の双方がこの\n * モジュールを参照することで、タグ名・対応 property・許容 child のズレを防ぐ。\n * 依存方向は parseXml / serializeXml → registry の一方向に保つ(このモジュール\n * からは parseXml / serializeXml を import しない)。\n */\n\n// ===== インライン装飾 (B/I/A/U/S/Sub/Sup/Mark/Span) =====\n\n/** Text / Shape / Li / Td 内のインライン装飾を表すテキスト run */\nexport interface TextRun {\n text: string;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n strike?: boolean;\n subscript?: boolean;\n superscript?: boolean;\n highlight?: string;\n color?: string;\n href?: string;\n fontFamily?: string;\n fontSize?: number;\n letterSpacing?: number;\n}\n\n/**\n * boolean 装飾タグ ↔ TextRun property の対応。\n * 配列の順序は serialize 時のネスト順(先頭が最も外側)。\n */\nexport const INLINE_BOOLEAN_FORMATS: readonly {\n readonly tag: string;\n readonly property:\n | \"bold\"\n | \"italic\"\n | \"underline\"\n | \"strike\"\n | \"subscript\"\n | \"superscript\";\n}[] = [\n { tag: \"B\", property: \"bold\" },\n { tag: \"I\", property: \"italic\" },\n { tag: \"U\", property: \"underline\" },\n { tag: \"S\", property: \"strike\" },\n { tag: \"Sub\", property: \"subscript\" },\n { tag: \"Sup\", property: \"superscript\" },\n];\n\n/** ハイパーリンクタグ。href 属性 → TextRun.href */\nexport const INLINE_LINK_TAG = \"A\";\n\n/** ハイライトタグ。color 属性 → TextRun.highlight(省略時は既定色) */\nexport const INLINE_MARK_TAG = \"Mark\";\n\n/** Mark の color 属性省略時に適用される既定のハイライト色 */\nexport const MARK_DEFAULT_HIGHLIGHT_COLOR = \"FFFF00\";\n\n/** 文字スタイルタグ。color / fontFamily / fontSize / letterSpacing 属性 → TextRun の同名 property */\nexport const INLINE_SPAN_TAG = \"Span\";\n\n/** インライン装飾として許容されるタグの一覧(エラーメッセージの列挙順) */\nexport const INLINE_FORMAT_TAG_LIST: readonly string[] = [\n \"B\",\n \"I\",\n \"A\",\n \"U\",\n \"S\",\n \"Sub\",\n \"Sup\",\n \"Mark\",\n \"Span\",\n];\n\n/** インライン装飾タグの集合(child element 判定用) */\nexport const INLINE_FORMAT_TAGS: ReadonlySet<string> = new Set(\n INLINE_FORMAT_TAG_LIST,\n);\n\n// ===== XML child element 受け入れルール =====\n\n/**\n * インライン装飾タグ (B/I/A/U/S/Mark/Span) のみを child として受け付け、\n * runs / text property へ変換するルール(Text 用)\n */\nexport interface InlineRunsChildRule {\n kind: \"inline-runs\";\n}\n\n/** 単一種類の child tag の繰り返しを受け取り、配列 property へ変換するルール */\nexport interface RepeatedChildRule {\n kind: \"repeated\";\n /** 受け付ける child tag 名 */\n childTag: string;\n /** 変換結果を格納する property 名 */\n property: string;\n /** 各 item が text content / インライン装飾タグを受け付けるか(Li 用) */\n allowsItemText?: boolean;\n}\n\n/**\n * parseXml 側の専用 converter で処理する複雑な child 構造\n * (ネスト構造や複数 property への振り分けを伴うもの)\n */\nexport interface NodeSpecificChildRule {\n kind: \"node-specific\";\n /** 直下で受け付ける child tag 名の一覧(unknown child エラーメッセージに使用) */\n expectedTags: readonly string[];\n}\n\nexport type XmlChildRule =\n | InlineRunsChildRule\n | RepeatedChildRule\n | NodeSpecificChildRule;\n\n/**\n * unknown child エラーメッセージ用に期待タグ一覧を整形する。\n * 例: [\"A\"] → \"<A>\" / [\"A\",\"B\"] → \"<A> or <B>\" / [\"A\",\"B\",\"C\"] → \"<A>, <B>, or <C>\"\n */\nexport function formatExpectedTags(tags: readonly string[]): string {\n const wrapped = tags.map((tag) => `<${tag}>`);\n if (wrapped.length === 1) return wrapped[0];\n if (wrapped.length === 2) return `${wrapped[0]} or ${wrapped[1]}`;\n return `${wrapped.slice(0, -1).join(\", \")}, or ${wrapped[wrapped.length - 1]}`;\n}\n"],"mappings":";;;;;AAmCA,MAAa,yBASP;CACJ;EAAE,KAAK;EAAK,UAAU;CAAO;CAC7B;EAAE,KAAK;EAAK,UAAU;CAAS;CAC/B;EAAE,KAAK;EAAK,UAAU;CAAY;CAClC;EAAE,KAAK;EAAK,UAAU;CAAS;CAC/B;EAAE,KAAK;EAAO,UAAU;CAAY;CACpC;EAAE,KAAK;EAAO,UAAU;CAAc;AACxC;;AAMA,MAAa,kBAAkB;;AAG/B,MAAa,+BAA+B;;AAG5C,MAAa,kBAAkB;;AAG/B,MAAa,yBAA4C;CACvD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,qBAA0C,IAAI,IACzD,sBACF;;;;;AA0CA,SAAgB,mBAAmB,MAAiC;CAClE,MAAM,UAAU,KAAK,KAAK,QAAQ,IAAI,IAAI,EAAE;CAC5C,IAAI,QAAQ,WAAW,GAAG,OAAO,QAAQ;CACzC,IAAI,QAAQ,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,QAAQ;CAC7D,OAAO,GAAG,QAAQ,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,OAAO,QAAQ,QAAQ,SAAS;AAC5E"}
|
|
@@ -6,14 +6,54 @@ function renderChartNode(node, ctx) {
|
|
|
6
6
|
labels: d.labels,
|
|
7
7
|
values: d.values
|
|
8
8
|
}));
|
|
9
|
+
const isSparkline = node.sparkline === true && (node.chartType === "bar" || node.chartType === "line" || node.chartType === "area");
|
|
9
10
|
const chartOptions = {
|
|
10
11
|
...getContentAreaIn(node),
|
|
11
|
-
showLegend: node.showLegend ?? false,
|
|
12
|
-
showTitle: node.showTitle ?? false,
|
|
13
|
-
title: node.title,
|
|
12
|
+
showLegend: isSparkline ? false : node.showLegend ?? false,
|
|
13
|
+
showTitle: isSparkline ? false : node.showTitle ?? false,
|
|
14
|
+
title: isSparkline ? void 0 : node.title,
|
|
14
15
|
chartColors: node.chartColors
|
|
15
16
|
};
|
|
16
17
|
if (node.chartType === "radar" && node.radarStyle) chartOptions.radarStyle = node.radarStyle;
|
|
18
|
+
if (isSparkline) {
|
|
19
|
+
chartOptions.catAxisHidden = true;
|
|
20
|
+
chartOptions.valAxisHidden = true;
|
|
21
|
+
chartOptions.catAxisLineShow = false;
|
|
22
|
+
chartOptions.valAxisLineShow = false;
|
|
23
|
+
chartOptions.showCatAxisTitle = false;
|
|
24
|
+
chartOptions.showValAxisTitle = false;
|
|
25
|
+
chartOptions.catGridLine = { style: "none" };
|
|
26
|
+
chartOptions.valGridLine = { style: "none" };
|
|
27
|
+
chartOptions.chartArea = {
|
|
28
|
+
fill: {
|
|
29
|
+
type: "solid",
|
|
30
|
+
color: "FFFFFF",
|
|
31
|
+
transparency: 100
|
|
32
|
+
},
|
|
33
|
+
border: {
|
|
34
|
+
color: "FFFFFF",
|
|
35
|
+
pt: 0
|
|
36
|
+
},
|
|
37
|
+
roundedCorners: false
|
|
38
|
+
};
|
|
39
|
+
chartOptions.plotArea = {
|
|
40
|
+
fill: {
|
|
41
|
+
type: "solid",
|
|
42
|
+
color: "FFFFFF",
|
|
43
|
+
transparency: 100
|
|
44
|
+
},
|
|
45
|
+
border: {
|
|
46
|
+
color: "FFFFFF",
|
|
47
|
+
pt: 0
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
chartOptions.layout = {
|
|
51
|
+
x: 0,
|
|
52
|
+
y: 0,
|
|
53
|
+
w: 1,
|
|
54
|
+
h: 1
|
|
55
|
+
};
|
|
56
|
+
}
|
|
17
57
|
ctx.slide.addChart(node.chartType, chartData, chartOptions);
|
|
18
58
|
}
|
|
19
59
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart.js","names":[],"sources":["../../../src/renderPptx/nodes/chart.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { getContentAreaIn } from \"../utils/contentArea.ts\";\n\ntype ChartPositionedNode = Extract<PositionedNode, { type: \"chart\" }>;\n\nexport function renderChartNode(\n node: ChartPositionedNode,\n ctx: RenderContext,\n): void {\n const chartData = node.data.map((d) => ({\n name: d.name,\n labels: d.labels,\n values: d.values,\n }));\n\n const chartOptions: Record<string, unknown> = {\n ...getContentAreaIn(node),\n showLegend: node.showLegend ?? false,\n showTitle: node.showTitle ?? false,\n title: node.title,\n chartColors: node.chartColors,\n };\n\n // radar専用オプション\n if (node.chartType === \"radar\" && node.radarStyle) {\n chartOptions.radarStyle = node.radarStyle;\n }\n\n ctx.slide.addChart(node.chartType, chartData, chartOptions);\n}\n"],"mappings":";;AAMA,SAAgB,gBACd,MACA,KACM;CACN,MAAM,YAAY,KAAK,KAAK,KAAK,OAAO;EACtC,MAAM,EAAE;EACR,QAAQ,EAAE;EACV,QAAQ,EAAE;CACZ,EAAE;
|
|
1
|
+
{"version":3,"file":"chart.js","names":[],"sources":["../../../src/renderPptx/nodes/chart.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { getContentAreaIn } from \"../utils/contentArea.ts\";\n\ntype ChartPositionedNode = Extract<PositionedNode, { type: \"chart\" }>;\n\nexport function renderChartNode(\n node: ChartPositionedNode,\n ctx: RenderContext,\n): void {\n const chartData = node.data.map((d) => ({\n name: d.name,\n labels: d.labels,\n values: d.values,\n }));\n\n // sparkline モードは bar / line / area のみ対応。pie / doughnut / radar は\n // 元々凡例 / 軸の概念が異なるため sparkline=true でも通常描画にフォールバックする。\n const isSparkline =\n node.sparkline === true &&\n (node.chartType === \"bar\" ||\n node.chartType === \"line\" ||\n node.chartType === \"area\");\n\n const chartOptions: Record<string, unknown> = {\n ...getContentAreaIn(node),\n showLegend: isSparkline ? false : (node.showLegend ?? false),\n showTitle: isSparkline ? false : (node.showTitle ?? false),\n title: isSparkline ? undefined : node.title,\n chartColors: node.chartColors,\n };\n\n // radar専用オプション\n if (node.chartType === \"radar\" && node.radarStyle) {\n chartOptions.radarStyle = node.radarStyle;\n }\n\n // sparkline モード: 凡例 / 軸 / グリッド線 / マージンをすべて非表示にし、\n // プロット領域をチャート領域いっぱいに広げて小寸法でも視認できるようにする\n if (isSparkline) {\n chartOptions.catAxisHidden = true;\n chartOptions.valAxisHidden = true;\n chartOptions.catAxisLineShow = false;\n chartOptions.valAxisLineShow = false;\n chartOptions.showCatAxisTitle = false;\n chartOptions.showValAxisTitle = false;\n chartOptions.catGridLine = { style: \"none\" };\n chartOptions.valGridLine = { style: \"none\" };\n chartOptions.chartArea = {\n fill: { type: \"solid\", color: \"FFFFFF\", transparency: 100 },\n border: { color: \"FFFFFF\", pt: 0 },\n roundedCorners: false,\n };\n chartOptions.plotArea = {\n fill: { type: \"solid\", color: \"FFFFFF\", transparency: 100 },\n border: { color: \"FFFFFF\", pt: 0 },\n };\n chartOptions.layout = { x: 0, y: 0, w: 1, h: 1 };\n }\n\n ctx.slide.addChart(node.chartType, chartData, chartOptions);\n}\n"],"mappings":";;AAMA,SAAgB,gBACd,MACA,KACM;CACN,MAAM,YAAY,KAAK,KAAK,KAAK,OAAO;EACtC,MAAM,EAAE;EACR,QAAQ,EAAE;EACV,QAAQ,EAAE;CACZ,EAAE;CAIF,MAAM,cACJ,KAAK,cAAc,SAClB,KAAK,cAAc,SAClB,KAAK,cAAc,UACnB,KAAK,cAAc;CAEvB,MAAM,eAAwC;EAC5C,GAAG,iBAAiB,IAAI;EACxB,YAAY,cAAc,QAAS,KAAK,cAAc;EACtD,WAAW,cAAc,QAAS,KAAK,aAAa;EACpD,OAAO,cAAc,KAAA,IAAY,KAAK;EACtC,aAAa,KAAK;CACpB;CAGA,IAAI,KAAK,cAAc,WAAW,KAAK,YACrC,aAAa,aAAa,KAAK;CAKjC,IAAI,aAAa;EACf,aAAa,gBAAgB;EAC7B,aAAa,gBAAgB;EAC7B,aAAa,kBAAkB;EAC/B,aAAa,kBAAkB;EAC/B,aAAa,mBAAmB;EAChC,aAAa,mBAAmB;EAChC,aAAa,cAAc,EAAE,OAAO,OAAO;EAC3C,aAAa,cAAc,EAAE,OAAO,OAAO;EAC3C,aAAa,YAAY;GACvB,MAAM;IAAE,MAAM;IAAS,OAAO;IAAU,cAAc;GAAI;GAC1D,QAAQ;IAAE,OAAO;IAAU,IAAI;GAAE;GACjC,gBAAgB;EAClB;EACA,aAAa,WAAW;GACtB,MAAM;IAAE,MAAM;IAAS,OAAO;IAAU,cAAc;GAAI;GAC1D,QAAQ;IAAE,OAAO;IAAU,IAAI;GAAE;EACnC;EACA,aAAa,SAAS;GAAE,GAAG;GAAG,GAAG;GAAG,GAAG;GAAG,GAAG;EAAE;CACjD;CAEA,IAAI,MAAM,SAAS,KAAK,WAAW,WAAW,YAAY;AAC5D"}
|
|
@@ -43,6 +43,7 @@ function buildListTextItems(items, parent, bullet) {
|
|
|
43
43
|
text,
|
|
44
44
|
options: {
|
|
45
45
|
...baseOptions,
|
|
46
|
+
fontSize: pxToPt(run.fontSize ?? style.fontSize),
|
|
46
47
|
fontFace: run.fontFamily ?? style.fontFamily,
|
|
47
48
|
color: run.color ?? style.color,
|
|
48
49
|
bold: run.bold ?? style.bold,
|