@json-to-office/shared-docx 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-TODYYVZ4.js → chunk-5NLKSIS2.js} +2 -2
- package/dist/{chunk-NAZDY3PK.js → chunk-AH7DXSUV.js} +4 -4
- package/dist/{chunk-5KOKA5GY.js → chunk-EG5UTHFZ.js} +8 -1
- package/dist/{chunk-5KOKA5GY.js.map → chunk-EG5UTHFZ.js.map} +1 -1
- package/dist/{chunk-6B3LHADB.js → chunk-M4F3PWQR.js} +2 -2
- package/dist/chunk-M4F3PWQR.js.map +1 -0
- package/dist/{chunk-A2K66URO.js → chunk-MMD4A5LR.js} +157 -20
- package/dist/chunk-MMD4A5LR.js.map +1 -0
- package/dist/{chunk-BBFR3RRN.js → chunk-NT236J7G.js} +3 -3
- package/dist/{chunk-MYLVUQCN.js → chunk-P4FD5B7U.js} +2 -2
- package/dist/{chunk-SOI64OJZ.js → chunk-XEB3SHFQ.js} +4 -4
- package/dist/{chunk-B4STXH5L.js → chunk-Z4L6TH5Y.js} +2 -2
- package/dist/index.d.ts +18 -5
- package/dist/index.js +12 -9
- package/dist/index.js.map +1 -1
- package/dist/schemas/api.js +4 -4
- package/dist/schemas/component-registry.d.ts +9 -0
- package/dist/schemas/component-registry.js +2 -2
- package/dist/schemas/components.d.ts +75 -1
- package/dist/schemas/components.js +5 -3
- package/dist/schemas/document.js +5 -5
- package/dist/schemas/export.js +3 -3
- package/dist/schemas/generator.js +3 -3
- package/dist/schemas/renderer.js +1 -1
- package/dist/validation/unified/index.js +5 -5
- package/package.json +2 -2
- package/dist/chunk-6B3LHADB.js.map +0 -1
- package/dist/chunk-A2K66URO.js.map +0 -1
- /package/dist/{chunk-TODYYVZ4.js.map → chunk-5NLKSIS2.js.map} +0 -0
- /package/dist/{chunk-NAZDY3PK.js.map → chunk-AH7DXSUV.js.map} +0 -0
- /package/dist/{chunk-BBFR3RRN.js.map → chunk-NT236J7G.js.map} +0 -0
- /package/dist/{chunk-MYLVUQCN.js.map → chunk-P4FD5B7U.js.map} +0 -0
- /package/dist/{chunk-SOI64OJZ.js.map → chunk-XEB3SHFQ.js.map} +0 -0
- /package/dist/{chunk-B4STXH5L.js.map → chunk-Z4L6TH5Y.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ComponentDefinitionSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-M4F3PWQR.js";
|
|
4
4
|
|
|
5
5
|
// src/schemas/api.ts
|
|
6
6
|
import { Type } from "@sinclair/typebox";
|
|
@@ -105,4 +105,4 @@ export {
|
|
|
105
105
|
GenerateDocumentResponseSchema,
|
|
106
106
|
ValidateDocumentResponseSchema
|
|
107
107
|
};
|
|
108
|
-
//# sourceMappingURL=chunk-
|
|
108
|
+
//# sourceMappingURL=chunk-5NLKSIS2.js.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ComponentDefinitionSchema,
|
|
3
3
|
StandardComponentDefinitionSchema
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-M4F3PWQR.js";
|
|
5
5
|
import {
|
|
6
6
|
CustomComponentDefinitionSchema
|
|
7
7
|
} from "./chunk-7GGTZ4TA.js";
|
|
8
8
|
import {
|
|
9
9
|
ReportPropsSchema,
|
|
10
10
|
STANDARD_COMPONENTS_REGISTRY
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-MMD4A5LR.js";
|
|
12
12
|
import {
|
|
13
13
|
collectDocxRendererErrors
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-EG5UTHFZ.js";
|
|
15
15
|
|
|
16
16
|
// src/validation/unified/error-transformer.ts
|
|
17
17
|
import {
|
|
@@ -996,4 +996,4 @@ export {
|
|
|
996
996
|
validateJsonComponent,
|
|
997
997
|
validateDocumentWithSchema
|
|
998
998
|
};
|
|
999
|
-
//# sourceMappingURL=chunk-
|
|
999
|
+
//# sourceMappingURL=chunk-AH7DXSUV.js.map
|
|
@@ -568,6 +568,13 @@ function collectDocxRendererErrors(data) {
|
|
|
568
568
|
if (object.name === "visual") {
|
|
569
569
|
collectVisualErrors(object, `${path}`, isOfficeOpen, errors);
|
|
570
570
|
}
|
|
571
|
+
if (object.name === "chart" && !isOfficeOpen) {
|
|
572
|
+
errors.push({
|
|
573
|
+
path: `${path}/name`,
|
|
574
|
+
message: `Only the "office-open" renderer draws a native chart. Set the document's "renderer" to "office-open", or use "highcharts" to render one as an image.`,
|
|
575
|
+
code: "unsupported_renderer_feature"
|
|
576
|
+
});
|
|
577
|
+
}
|
|
571
578
|
for (const [key, value] of Object.entries(object)) {
|
|
572
579
|
if (key !== "renderer") visit(value, `${path}/${key}`);
|
|
573
580
|
}
|
|
@@ -684,4 +691,4 @@ export {
|
|
|
684
691
|
docxPropsSchemaForRenderer,
|
|
685
692
|
collectDocxRendererErrors
|
|
686
693
|
};
|
|
687
|
-
//# sourceMappingURL=chunk-
|
|
694
|
+
//# sourceMappingURL=chunk-EG5UTHFZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/components/visual.ts","../src/schemas/components/visual-native.ts","../src/schemas/renderer.ts"],"sourcesContent":["/**\n * Visual Component Schema\n *\n * A `visual` is a free-canvas graphic: absolute positioning, overlapping\n * shapes and layered art that the docx flow layout cannot express — think\n * infographics, diagrams and hero compositions.\n *\n * There are two ways to draw one, chosen by `renderMode`.\n *\n * `raster` (the default, and what an omitted `renderMode` means) authors the\n * canvas as a single pptx slide and embeds the result as a PNG. An injected\n * rasterization service renders it (see `PptxServiceConfig` in\n * @json-to-office/shared), exactly the way `highcharts` offloads chart\n * rendering to an export server; at render time the component desugars to a\n * plain `image`. Every pptx slide element is available, and the output is\n * pixels.\n *\n * `native` draws the same canvas as one Word DrawingML group — real text\n * boxes, real shapes, real pictures — with no pptx, no rasterizer and no PNG.\n * The text stays searchable and every object stays editable in Word. It needs\n * the `office-open` renderer, and its content model is the narrower, strictly\n * validated one in `./visual-native`.\n */\n\nimport { Type, Static } from '@sinclair/typebox';\nimport {\n MIN_VISUAL_DPI,\n MAX_VISUAL_DPI,\n DEFAULT_VISUAL_DPI,\n} from '@json-to-office/shared';\nimport { PptxSlideContentSchema } from '@json-to-office/shared/schemas/slide-content';\nimport {\n AlignmentSchema,\n SpacingSchema,\n FloatingPropertiesSchema,\n} from './common';\nimport {\n NativeVisualCanvasSchema,\n NativeVisualElementSchema,\n} from './visual-native';\n\nexport * from './visual-native';\n\n/**\n * Canvas background — a solid color and/or a background image.\n * Mirrors the pptx slide background shape (kept local to avoid coupling\n * shared-docx to shared-pptx; the rasterizer forwards it verbatim).\n */\nexport const VisualCanvasBackgroundSchema = Type.Object(\n {\n color: Type.Optional(\n Type.String({\n description:\n 'Background color (hex like \"#FFFFFF\" or a theme color name)',\n })\n ),\n image: Type.Optional(\n Type.Object(\n {\n path: Type.Optional(Type.String()),\n base64: Type.Optional(Type.String()),\n },\n { additionalProperties: false }\n )\n ),\n },\n { additionalProperties: false }\n);\n\n/**\n * The pptx canvas the visual is drawn on. Width/height are in inches and set\n * both the aspect ratio and the physical print size of the embedded image.\n */\nexport const VisualCanvasSchema = Type.Object(\n {\n width: Type.Number({\n minimum: 0.1,\n description: 'Canvas width in inches (pptx slideWidth)',\n }),\n height: Type.Number({\n minimum: 0.1,\n description: 'Canvas height in inches (pptx slideHeight)',\n }),\n theme: Type.Optional(\n Type.String({ description: 'pptx theme name applied to the slide' })\n ),\n background: Type.Optional(VisualCanvasBackgroundSchema),\n },\n {\n description: 'pptx canvas definition for the visual',\n additionalProperties: false,\n }\n);\n\n/**\n * Where the drawing sits on the page, and how big it is.\n *\n * Identical for both render modes: a visual is placed like an image whether\n * its pixels came from a rasterizer or its objects were drawn by Word.\n */\nconst PlacementProps = {\n width: Type.Optional(\n Type.Union(\n [\n Type.Number({ minimum: 1, description: 'Rendered width in pixels' }),\n Type.String({\n pattern: '^\\\\d+(\\\\.\\\\d+)?%$',\n description: 'Rendered width as percentage (e.g. \"90%\")',\n }),\n ],\n {\n description:\n 'Rendered width in the document, in pixels (number) or percentage string. Defaults to the canvas physical size.',\n }\n )\n ),\n height: Type.Optional(\n Type.Union([\n Type.Number({ minimum: 1, description: 'Rendered height in pixels' }),\n Type.String({\n pattern: '^\\\\d+(\\\\.\\\\d+)?%$',\n description: 'Rendered height as percentage (e.g. \"90%\")',\n }),\n ])\n ),\n alignment: Type.Optional(AlignmentSchema),\n caption: Type.Optional(\n Type.String({\n description:\n 'Caption (supports rich text with **bold**, *italic*, ***both***)',\n })\n ),\n alt: Type.Optional(\n Type.String({ description: 'Alternative text for accessibility' })\n ),\n spacing: Type.Optional(SpacingSchema),\n floating: Type.Optional(FloatingPropertiesSchema),\n keepNext: Type.Optional(\n Type.Boolean({\n description: 'Keep paragraph with next paragraph on same page',\n })\n ),\n keepLines: Type.Optional(\n Type.Boolean({\n description: 'Keep all lines of paragraph together on same page',\n })\n ),\n} as const;\n\n// A single pptx slide content element (text, image, shape, table, highcharts,\n// chart) is validated against the real PPTX slide-content union\n// (`PptxSlideContentSchema` from @json-to-office/shared/schemas/slide-content)\n// — same authoring fidelity as a standalone `.pptx.json`. Used directly as the\n// `elements` item schema below.\n\n/**\n * The rasterized form: a pptx slide rendered to a PNG.\n *\n * `renderMode` is optional here because omitting it has always meant raster,\n * and every document written before native mode existed must keep rendering\n * byte-for-byte the way it did.\n */\nexport const VisualRasterPropsSchema = Type.Object(\n {\n renderMode: Type.Optional(\n Type.Literal('raster', {\n description:\n 'Render as a rasterized pptx slide (the default when omitted).',\n })\n ),\n\n // ── canvas (drives aspect ratio + physical size) ──\n canvas: VisualCanvasSchema,\n // pptx slide content elements, absolutely positioned on the canvas\n elements: Type.Optional(\n Type.Array(PptxSlideContentSchema, {\n description:\n 'pptx slide content elements (text, image, shape, table, highcharts, chart), positioned with x/y/w/h in inches',\n })\n ),\n\n // ── rasterization ──\n dpi: Type.Optional(\n Type.Number({\n minimum: MIN_VISUAL_DPI,\n maximum: MAX_VISUAL_DPI,\n default: DEFAULT_VISUAL_DPI,\n description: `Raster resolution in DPI (default ${DEFAULT_VISUAL_DPI}, range ${MIN_VISUAL_DPI}-${MAX_VISUAL_DPI}). Higher = sharper + larger.`,\n })\n ),\n serverUrl: Type.Optional(\n Type.String({\n description:\n 'Rasterization service URL override (default from services.pptx)',\n })\n ),\n\n // ── placement in the document (mirrors `image`) ──\n ...PlacementProps,\n },\n {\n // Hoisted into its own JSON-Schema definition rather than inlined at every\n // position a component can appear. `visual.props` is by far the largest\n // props schema in the registry, and inlining two of them pushed the\n // exported `ComponentDefinition` past the depth Ajv can compile.\n $id: 'DocxVisualRasterProps',\n description: 'Visual component props (pptx-rendered graphic)',\n additionalProperties: false,\n }\n);\n\n/**\n * The native form: one Word DrawingML group.\n *\n * `dpi` and `serverUrl` are absent rather than ignored — nothing is\n * rasterized, so a resolution or a service URL would describe work that never\n * happens. `renderMode` is required, which is what makes this branch\n * unreachable by accident.\n */\nexport const VisualNativePropsSchema = Type.Object(\n {\n renderMode: Type.Literal('native', {\n description:\n 'Draw natively as a Word DrawingML group. Requires the \"office-open\" renderer.',\n }),\n canvas: NativeVisualCanvasSchema,\n elements: Type.Optional(\n Type.Array(NativeVisualElementSchema, {\n description:\n 'Native drawing elements (text, shape, image), positioned with x/y/w/h in inches or canvas percentages',\n })\n ),\n ...PlacementProps,\n },\n {\n // Hoisted for the same reason as the raster branch above.\n $id: 'DocxVisualNativeProps',\n description:\n 'Visual component props (native Word drawing group; requires renderer \"office-open\")',\n additionalProperties: false,\n }\n);\n\n/**\n * The authoring surface of `visual`, as a union discriminated on `renderMode`.\n *\n * Kept as one canonical schema rather than two registry entries because the\n * runtime validator checks an un-profiled schema: both shapes have to be\n * structurally valid here, and which one a *document* may use is decided by\n * its renderer, in `schemas/renderer.ts`.\n */\nexport const VisualPropsSchema = Type.Union(\n [VisualRasterPropsSchema, VisualNativePropsSchema],\n {\n description:\n 'Visual component props — rasterized pptx slide (default) or a native Word drawing group',\n }\n);\n\nexport type VisualRasterProps = Static<typeof VisualRasterPropsSchema>;\nexport type VisualNativeProps = Static<typeof VisualNativePropsSchema>;\nexport type VisualProps = VisualRasterProps | VisualNativeProps;\nexport type VisualCanvas = Static<typeof VisualCanvasSchema>;\n\n/** The `renderMode` value that selects the native drawing-group path. */\nexport const NATIVE_RENDER_MODE = 'native';\n\n/** True when these props ask for the native DrawingML path. */\nexport function isNativeVisualProps(\n props: VisualProps | undefined | null\n): props is VisualNativeProps {\n return (\n !!props &&\n (props as { renderMode?: unknown }).renderMode === NATIVE_RENDER_MODE\n );\n}\n","/**\n * Native visual content — the DrawingML side of the `visual` component.\n *\n * A raster visual is authored as a pptx slide because a pptx slide is what\n * rasterizes it. A *native* visual has no such intermediary: it becomes one\n * Word drawing group, so its content model is the subset of that pptx surface\n * Word can draw natively — three element kinds, and only the properties that\n * lower to real DrawingML.\n *\n * The surface is deliberately narrower than the raster one, and strict with it.\n * Every schema here is `additionalProperties: false`, so a property that native\n * mode would ignore is rejected at the authoring boundary instead of silently\n * doing nothing: an author who writes a gradient fill or a chart gets told it\n * is not drawn, rather than shipping a document missing the thing they asked\n * for.\n *\n * Geometry is inches, or a percentage of the canvas extent on that axis. The\n * raster path's \"a number below 100 is inches, at or above it is EMU\" rule is\n * deliberately not reproduced: nothing here is ever EMU.\n */\n\nimport { Type, Static, type TSchema } from '@sinclair/typebox';\nimport { ShapeTypeSchema } from '@json-to-office/shared/schemas/slide-content';\n\n/**\n * A colour anywhere inside a native visual.\n *\n * The same vocabulary the rest of a `.docx.json` uses — `#RRGGBB`, a bare\n * six-digit hex, or a docx theme colour name — because a native visual is\n * drawn by the docx pipeline against the docx theme. The pptx palette names\n * (`accent4`, `tx1`, `bg2`) belong to the raster path and do not resolve here.\n */\nexport const NativeVisualColorSchema = Type.String({\n pattern: '^(#?[0-9A-Fa-f]{6}|[a-zA-Z][a-zA-Z0-9]*)$',\n description:\n 'Hex colour (\"#0F172A\" or \"0F172A\") or a docx theme colour name (e.g. \"primary\")',\n});\n\n/**\n * A signed percentage, for a position: an element may legitimately start off\n * the left or top edge of the canvas.\n */\nconst SIGNED_PERCENT_PATTERN = '^-?\\\\d+(\\\\.\\\\d+)?%$';\n\n/**\n * An unsigned percentage, for a size.\n *\n * Separate from the signed pattern on purpose. The number branch below states\n * `minimum: 0`, and a size that could be negative in one spelling and not the\n * other would make the surface's strictness depend on how the author happened\n * to write it — a negative width has no drawing to refuse it, it just comes\n * out as a zero-size object nobody can see.\n */\nconst PERCENT_PATTERN = '^\\\\d+(\\\\.\\\\d+)?%$';\n\n/** A position on the canvas: inches, or a percentage of the canvas extent. */\nexport const NativeVisualOffsetSchema = Type.Union(\n [\n Type.Number({ description: 'Inches from the canvas origin' }),\n Type.String({\n pattern: SIGNED_PERCENT_PATTERN,\n description: 'Percentage of the canvas extent on this axis, e.g. \"25%\"',\n }),\n ],\n { description: 'Position in inches (number) or as a canvas percentage' }\n);\n\n/** An extent on the canvas: inches, or a percentage of the canvas extent. */\nexport const NativeVisualExtentSchema = Type.Union(\n [\n Type.Number({ minimum: 0, description: 'Size in inches' }),\n Type.String({\n pattern: PERCENT_PATTERN,\n description: 'Percentage of the canvas extent on this axis, e.g. \"50%\"',\n }),\n ],\n { description: 'Size in inches (number) or as a canvas percentage' }\n);\n\nconst FrameProps = {\n x: Type.Optional(NativeVisualOffsetSchema),\n y: Type.Optional(NativeVisualOffsetSchema),\n w: Type.Optional(NativeVisualExtentSchema),\n h: Type.Optional(NativeVisualExtentSchema),\n rotate: Type.Optional(\n Type.Number({ description: 'Clockwise rotation in degrees' })\n ),\n} as const;\n\n/**\n * Underline, as Word draws it.\n *\n * `true` is a single line in the run's own colour; the object form names the\n * line style and, optionally, a colour of its own.\n */\nexport const NativeVisualUnderlineSchema = Type.Union(\n [\n Type.Boolean({ description: 'Single underline in the text colour' }),\n Type.Object(\n {\n style: Type.Optional(\n Type.Union(\n [\n Type.Literal('sng'),\n Type.Literal('dbl'),\n Type.Literal('dash'),\n Type.Literal('dotted'),\n ],\n { description: 'Underline style (default \"sng\")' }\n )\n ),\n color: Type.Optional(NativeVisualColorSchema),\n },\n { additionalProperties: false }\n ),\n ],\n { description: 'Underline: true for a single line, or a style/colour object' }\n);\n\nconst InlineTextProps = {\n fontFace: Type.Optional(Type.String({ description: 'Font family name' })),\n fontSize: Type.Optional(\n Type.Number({ minimum: 1, description: 'Font size in points' })\n ),\n bold: Type.Optional(Type.Boolean()),\n italic: Type.Optional(Type.Boolean()),\n} as const;\n\n/** One formatted span inside a native `text` element. */\nexport const NativeVisualTextRunSchema = Type.Object(\n {\n text: Type.String({ description: 'Run text' }),\n color: Type.Optional(NativeVisualColorSchema),\n ...InlineTextProps,\n underline: Type.Optional(NativeVisualUnderlineSchema),\n strike: Type.Optional(Type.Boolean({ description: 'Strikethrough' })),\n breakLine: Type.Optional(\n Type.Boolean({ description: 'Start a new line after this run' })\n ),\n },\n {\n additionalProperties: false,\n description: 'A formatted run inside a native visual text element',\n }\n);\n\n/**\n * One span of a shape's text.\n *\n * Deliberately not the same shape as a text run: shape text carries no\n * underline or strikethrough in the raster surface either, and native mode\n * keeps the two surfaces aligned rather than quietly widening one.\n */\nexport const NativeVisualTextSegmentSchema = Type.Object(\n {\n text: Type.String({ description: 'Segment text' }),\n color: Type.Optional(NativeVisualColorSchema),\n ...InlineTextProps,\n breakLine: Type.Optional(\n Type.Boolean({ description: 'Start a new line after this segment' })\n ),\n },\n {\n additionalProperties: false,\n description: 'A formatted segment of a native visual shape’s text',\n }\n);\n\n/** A solid fill, or none at all. */\nexport const NativeVisualFillSchema = Type.Object(\n {\n color: Type.Optional(NativeVisualColorSchema),\n transparency: Type.Optional(\n Type.Number({\n minimum: 0,\n maximum: 100,\n description: 'Fill transparency, 0 (opaque) to 100 (invisible)',\n })\n ),\n },\n {\n additionalProperties: false,\n description:\n 'Solid fill. Omit the whole property for no fill; gradients and patterns are raster-only.',\n }\n);\n\n/** A shape outline: solid or dashed, one uniform stroke. */\nexport const NativeVisualLineSchema = Type.Object(\n {\n color: Type.Optional(NativeVisualColorSchema),\n width: Type.Optional(\n Type.Number({ minimum: 0, description: 'Outline width in points' })\n ),\n dashType: Type.Optional(\n Type.Union(\n [\n Type.Literal('solid'),\n Type.Literal('dash'),\n Type.Literal('dot'),\n Type.Literal('dashDot'),\n ],\n { description: 'Outline dash pattern (default \"solid\")' }\n )\n ),\n },\n { additionalProperties: false, description: 'Shape outline' }\n);\n\nexport const NativeVisualAlignmentSchema = Type.Union(\n [\n Type.Literal('left'),\n Type.Literal('center'),\n Type.Literal('right'),\n Type.Literal('justify'),\n ],\n { description: 'Horizontal text alignment' }\n);\n\nexport const NativeVisualVerticalAlignmentSchema = Type.Union(\n [Type.Literal('top'), Type.Literal('middle'), Type.Literal('bottom')],\n { description: 'Vertical text anchoring inside the box' }\n);\n\n/** Text inset, in points: one value for every side, or `[top, right, bottom, left]`. */\nexport const NativeVisualMarginSchema = Type.Union(\n [\n Type.Number({ minimum: 0, description: 'Inset on every side, in points' }),\n Type.Array(Type.Number({ minimum: 0 }), {\n minItems: 4,\n maxItems: 4,\n description: 'Insets as [top, right, bottom, left], in points',\n }),\n ],\n { description: 'Text insets in points' }\n);\n\nexport const NativeVisualTextPropsSchema = Type.Object(\n {\n text: Type.Optional(Type.String({ description: 'Plain text content' })),\n runs: Type.Optional(\n Type.Array(NativeVisualTextRunSchema, {\n minItems: 1,\n description: 'Formatted runs, as an alternative to \"text\"',\n })\n ),\n ...FrameProps,\n color: Type.Optional(NativeVisualColorSchema),\n ...InlineTextProps,\n underline: Type.Optional(NativeVisualUnderlineSchema),\n strike: Type.Optional(Type.Boolean({ description: 'Strikethrough' })),\n align: Type.Optional(NativeVisualAlignmentSchema),\n valign: Type.Optional(NativeVisualVerticalAlignmentSchema),\n margin: Type.Optional(NativeVisualMarginSchema),\n fill: Type.Optional(NativeVisualFillSchema),\n },\n {\n additionalProperties: false,\n description:\n 'Native visual text element — becomes a Word text box (wps:wsp) inside the drawing group',\n }\n);\n\nexport const NativeVisualShapePropsSchema = Type.Object(\n {\n type: ShapeTypeSchema,\n ...FrameProps,\n fill: Type.Optional(NativeVisualFillSchema),\n line: Type.Optional(NativeVisualLineSchema),\n text: Type.Optional(\n Type.Union(\n [\n Type.String(),\n Type.Array(NativeVisualTextSegmentSchema, { minItems: 1 }),\n ],\n { description: 'Text drawn inside the shape' }\n )\n ),\n ...InlineTextProps,\n fontColor: Type.Optional(NativeVisualColorSchema),\n align: Type.Optional(NativeVisualAlignmentSchema),\n valign: Type.Optional(NativeVisualVerticalAlignmentSchema),\n margin: Type.Optional(NativeVisualMarginSchema),\n flipH: Type.Optional(Type.Boolean({ description: 'Mirror horizontally' })),\n flipV: Type.Optional(Type.Boolean({ description: 'Mirror vertically' })),\n },\n {\n additionalProperties: false,\n description:\n 'Native visual shape element — becomes a preset-geometry shape (wps:wsp) inside the drawing group',\n }\n);\n\nexport const NativeVisualImagePropsSchema = Type.Object(\n {\n path: Type.Optional(\n Type.String({ description: 'File path or http(s) URL' })\n ),\n base64: Type.Optional(Type.String({ description: 'Base64 data URI' })),\n svg: Type.Optional(Type.String({ description: 'Raw SVG markup' })),\n ...FrameProps,\n sizing: Type.Optional(\n Type.Object(\n {\n type: Type.Union(\n [\n Type.Literal('contain'),\n Type.Literal('cover'),\n Type.Literal('crop'),\n ],\n { description: 'How the image fills its box' }\n ),\n w: Type.Optional(\n Type.Number({\n minimum: 0,\n description:\n 'Box width in inches; overrides the element’s own \"w\"',\n })\n ),\n h: Type.Optional(\n Type.Number({\n minimum: 0,\n description:\n 'Box height in inches; overrides the element’s own \"h\"',\n })\n ),\n },\n {\n additionalProperties: false,\n description:\n 'How the image fills its box. \"w\"/\"h\" state the box itself, taking precedence over the element’s \"w\"/\"h\", as they do in raster mode.',\n }\n )\n ),\n alt: Type.Optional(\n Type.String({ description: 'Alternative text for accessibility' })\n ),\n },\n {\n additionalProperties: false,\n description:\n 'Native visual image element — becomes a native picture inside the drawing group',\n }\n);\n\n/** The three element kinds a native visual can hold, in public schema order. */\nexport const NATIVE_VISUAL_ELEMENT_NAMES = ['text', 'shape', 'image'] as const;\n\nexport type NativeVisualElementName =\n (typeof NATIVE_VISUAL_ELEMENT_NAMES)[number];\n\nfunction nativeElement<\n const TName extends NativeVisualElementName,\n const TProps extends TSchema,\n>(name: TName, propsSchema: TProps, description: string) {\n return Type.Object(\n {\n name: Type.Literal(name),\n id: Type.Optional(Type.String()),\n enabled: Type.Optional(\n Type.Boolean({\n default: true,\n description:\n 'When false, this element is filtered out and not drawn. Defaults to true.',\n })\n ),\n props: propsSchema,\n },\n { additionalProperties: false, description }\n );\n}\n\n/**\n * A single element of a native visual.\n *\n * `table`, `chart` and `highcharts` are absent on purpose: a Word table cannot\n * live inside a drawing group, and neither chart kind has a native mapping\n * here yet. Naming one is a validation error rather than a silent drop.\n *\n * The `$id` is distinct from the raster union's `PptxSlideContent` so the two\n * never collide when the document schema hoists them into shared definitions.\n */\nexport const NativeVisualElementSchema = Type.Union(\n [\n nativeElement(\n 'text',\n NativeVisualTextPropsSchema,\n 'Text element - a native Word text box drawn on the visual canvas.'\n ),\n nativeElement(\n 'shape',\n NativeVisualShapePropsSchema,\n 'Shape element - a native preset-geometry shape, optionally holding text.'\n ),\n nativeElement(\n 'image',\n NativeVisualImagePropsSchema,\n 'Image element - a native picture; an SVG stays vector.'\n ),\n ],\n {\n $id: 'DocxNativeVisualContent',\n discriminator: { propertyName: 'name' },\n description: 'A single native visual element (text, shape, or image).',\n }\n);\n\n/**\n * The canvas a native visual is drawn on.\n *\n * No `theme`: the raster canvas names a *pptx* theme, which the docx pipeline\n * cannot resolve. Native colours resolve against the document's own docx theme\n * instead, so naming a pptx theme here would promise something that could not\n * be kept.\n */\nexport const NativeVisualCanvasSchema = Type.Object(\n {\n width: Type.Number({\n minimum: 0.1,\n description: 'Canvas width in inches',\n }),\n height: Type.Number({\n minimum: 0.1,\n description: 'Canvas height in inches',\n }),\n background: Type.Optional(\n Type.Object(\n {\n color: Type.Optional(NativeVisualColorSchema),\n image: Type.Optional(\n Type.Object(\n {\n path: Type.Optional(Type.String()),\n base64: Type.Optional(Type.String()),\n },\n { additionalProperties: false }\n )\n ),\n },\n {\n additionalProperties: false,\n description:\n 'Canvas background. A colour becomes the bottom-most rectangle; an image becomes the bottom-most picture.',\n }\n )\n ),\n },\n {\n additionalProperties: false,\n description: 'Drawing canvas for a native visual',\n }\n);\n\nexport type NativeVisualCanvas = Static<typeof NativeVisualCanvasSchema>;\nexport type NativeVisualElement = Static<typeof NativeVisualElementSchema>;\nexport type NativeVisualTextProps = Static<typeof NativeVisualTextPropsSchema>;\nexport type NativeVisualShapeProps = Static<\n typeof NativeVisualShapePropsSchema\n>;\nexport type NativeVisualImageProps = Static<\n typeof NativeVisualImagePropsSchema\n>;\nexport type NativeVisualTextRun = Static<typeof NativeVisualTextRunSchema>;\nexport type NativeVisualTextSegment = Static<\n typeof NativeVisualTextSegmentSchema\n>;\nexport type NativeVisualFill = Static<typeof NativeVisualFillSchema>;\nexport type NativeVisualLine = Static<typeof NativeVisualLineSchema>;\n","import type { TSchema } from '@sinclair/typebox';\nimport type { ValidationError } from '@json-to-office/shared';\nimport { NATIVE_RENDER_MODE } from './components/visual';\n\nexport const DOCX_RENDERER_IDS = ['docxjs', 'office-open'] as const;\nexport type DocxRendererId = (typeof DOCX_RENDERER_IDS)[number];\nexport const DEFAULT_DOCX_RENDERER_ID: DocxRendererId = 'docxjs';\n\n/** The element kinds a native `visual` can hold. */\nconst NATIVE_VISUAL_ELEMENTS: ReadonlySet<string> = new Set([\n 'text',\n 'shape',\n 'image',\n]);\n\n/**\n * The exported JSON-Schema definition name for one renderer's component union.\n *\n * One name per renderer, never a shared one. The two views differ wherever a\n * backend cannot draw something, so a single definition would hand every\n * position that goes through it — a section header or footer, a table cell's\n * content, `componentDefaults` — whichever view the exporter happened to walk\n * last, and give a schema-driven editor the wrong diagnostics for the other\n * renderer.\n */\nexport function docxComponentDefinitionName(renderer: DocxRendererId): string {\n return `ComponentDefinition_${renderer}`;\n}\n\n/**\n * Derive one renderer view from the canonical props schema.\n *\n * The canonical schema is the union of everything any backend can express, so\n * a profile is a *subtraction*: the branches and fields this renderer cannot\n * draw are removed, which is what makes a schema-driven editor offer only what\n * the chosen backend will actually render.\n */\nexport function docxPropsSchemaForRenderer(\n componentName: string,\n schema: TSchema,\n renderer: DocxRendererId\n): TSchema {\n const copy = cloneSchema(schema);\n nameComponentPlaceholders(copy, docxComponentDefinitionName(renderer));\n\n if (componentName === 'visual' && renderer !== 'office-open') {\n // Only `office-open` draws a native group, so every other backend sees the\n // raster branch alone — a plain object rather than a union, which is what\n // gives an editor one unambiguous completion set.\n return firstUnionBranch(copy) ?? copy;\n }\n\n if (renderer === 'office-open') pruneThreadFields(copy);\n return copy;\n}\n\n/** Static renderer-profile diagnostics used by CLI/library validation. */\nexport function collectDocxRendererErrors(data: unknown): ValidationError[] {\n if (!data || typeof data !== 'object' || Array.isArray(data)) return [];\n const root = data as Record<string, any>;\n const renderer = root.renderer ?? DEFAULT_DOCX_RENDERER_ID;\n\n if (!DOCX_RENDERER_IDS.includes(renderer)) {\n return [\n {\n path: '/renderer',\n message: `Invalid renderer \"${String(renderer)}\". Expected \"docxjs\" or \"office-open\".`,\n code: 'invalid_value',\n },\n ];\n }\n\n const errors: ValidationError[] = [];\n const isOfficeOpen = renderer === 'office-open';\n\n const visit = (node: unknown, path: string): void => {\n if (Array.isArray(node)) {\n node.forEach((entry, index) => visit(entry, `${path}/${index}`));\n return;\n }\n if (!node || typeof node !== 'object') return;\n const object = node as Record<string, unknown>;\n\n if (isOfficeOpen) {\n const comment = object.comment;\n if (comment && typeof comment === 'object' && !Array.isArray(comment)) {\n const value = comment as Record<string, unknown>;\n for (const field of ['replies', 'resolved'] as const) {\n if (value[field] !== undefined) {\n errors.push({\n path: `${path}/comment/${field}`,\n message: `The \"office-open\" renderer does not support comment threads.`,\n code: 'unsupported_renderer_feature',\n });\n }\n }\n }\n }\n\n if (object.name === 'visual') {\n collectVisualErrors(object, `${path}`, isOfficeOpen, errors);\n }\n\n for (const [key, value] of Object.entries(object)) {\n if (key !== 'renderer') visit(value, `${path}/${key}`);\n }\n };\n\n visit(root, '');\n return errors;\n}\n\n/**\n * Native-mode rules for one `visual` node.\n *\n * Two separate concerns, and both have to name a path an editor can jump to.\n * A backend that cannot draw a group must reject the mode itself, at\n * `props/renderMode`. A backend that can must still reject element kinds that\n * have no native form — otherwise a `chart` inside a native visual would\n * validate and then vanish, which is exactly the failure mode strictness\n * exists to prevent.\n */\nfunction collectVisualErrors(\n node: Record<string, unknown>,\n path: string,\n isOfficeOpen: boolean,\n errors: ValidationError[]\n): void {\n const props = node.props;\n if (!props || typeof props !== 'object' || Array.isArray(props)) return;\n const value = props as Record<string, unknown>;\n if (value.renderMode !== NATIVE_RENDER_MODE) return;\n\n if (!isOfficeOpen) {\n errors.push({\n path: `${path}/props/renderMode`,\n message:\n 'Only the \"office-open\" renderer draws a native visual. Set the document\\'s \"renderer\" to \"office-open\", or drop \"renderMode\" to rasterize.',\n code: 'unsupported_renderer_feature',\n });\n return;\n }\n\n const elements = value.elements;\n if (!Array.isArray(elements)) return;\n elements.forEach((element, index) => {\n if (!element || typeof element !== 'object' || Array.isArray(element)) {\n return;\n }\n const name = (element as Record<string, unknown>).name;\n if (typeof name !== 'string' || NATIVE_VISUAL_ELEMENTS.has(name)) return;\n errors.push({\n path: `${path}/props/elements/${index}/name`,\n message:\n `A native visual cannot draw \"${name}\". Native mode holds \"text\", ` +\n '\"shape\" and \"image\"; use renderMode \"raster\" for anything else.',\n code: 'unsupported_renderer_feature',\n });\n });\n}\n\n/** The first branch of a union schema, if this is one. */\nfunction firstUnionBranch(schema: TSchema): TSchema | undefined {\n const branches = (schema as { anyOf?: TSchema[] }).anyOf;\n return Array.isArray(branches) && branches.length > 0\n ? branches[0]\n : undefined;\n}\n\nfunction pruneThreadFields(node: unknown): void {\n if (Array.isArray(node)) {\n node.forEach(pruneThreadFields);\n return;\n }\n if (!node || typeof node !== 'object') return;\n const schema = node as Record<PropertyKey, any>;\n const properties = schema.properties as Record<string, TSchema> | undefined;\n if (\n properties?.text &&\n properties?.author &&\n (properties.replies || properties.resolved) &&\n typeof schema.description === 'string' &&\n schema.description.includes('Word review comment')\n ) {\n delete properties.replies;\n delete properties.resolved;\n const required = schema.required as string[] | undefined;\n if (required) {\n schema.required = required.filter(\n (key) => key !== 'replies' && key !== 'resolved'\n );\n }\n }\n for (const key of Reflect.ownKeys(schema)) {\n pruneThreadFields(schema[key]);\n }\n}\n\n/**\n * Point a renderer's props at that renderer's component definition.\n *\n * A position that holds arbitrary components but is built from a *static*\n * schema carries an untyped item instead of a live recursive ref —\n * `componentDefaults.section.header` is the one that matters, because\n * `ComponentDefaultsSchema` is shared with the theme and so cannot be handed\n * the recursion. The export pass used to resolve those against one hard-coded\n * name; naming them here, while the renderer is still known and the schema is\n * still this renderer's private clone, is what keeps the two views apart.\n */\nfunction nameComponentPlaceholders(\n node: unknown,\n definitionName: string\n): void {\n if (Array.isArray(node)) {\n node.forEach((entry) => nameComponentPlaceholders(entry, definitionName));\n return;\n }\n if (!node || typeof node !== 'object') return;\n const schema = node as Record<PropertyKey, any>;\n\n if (\n schema.type === 'array' &&\n schema.items &&\n typeof schema.items === 'object' &&\n Object.keys(schema.items).length === 0\n ) {\n // A bare name, the same shape `Type.Recursive` emits for its own self\n // reference. `fixSchemaReferences` resolves both to `#/definitions/...`.\n schema.items = { $ref: definitionName };\n }\n\n for (const key of Reflect.ownKeys(schema)) {\n nameComponentPlaceholders(schema[key], definitionName);\n }\n}\n\nfunction cloneSchema<T>(value: T): T {\n if (Array.isArray(value)) return value.map(cloneSchema) as T;\n if (!value || typeof value !== 'object') return value;\n const copy = Object.create(Object.getPrototypeOf(value));\n for (const key of Reflect.ownKeys(value as object)) {\n copy[key] = cloneSchema((value as any)[key]);\n }\n return copy;\n}\n"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,MACE,YAAY,QACZ,YAAY,WACX,WAAW,WAAW,WAAW,aAClC,OAAO,OAAO,gBAAgB,YAC9B,OAAO,YAAY,SAAS,qBAAqB,GACjD;AACA,WAAO,WAAW;AAClB,WAAO,WAAW;AAClB,UAAM,WAAW,OAAO;AACxB,QAAI,UAAU;AACZ,aAAO,WAAW,SAAS;AAAA,QACzB,CAAC,QAAQ,QAAQ,aAAa,QAAQ;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AACA,aAAW,OAAO,QAAQ,QAAQ,MAAM,GAAG;AACzC,sBAAkB,OAAO,GAAG,CAAC;AAAA,EAC/B;AACF;AAaA,SAAS,0BACP,MACA,gBACM;AACN,MAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,SAAK,QAAQ,CAAC,UAAU,0BAA0B,OAAO,cAAc,CAAC;AACxE;AAAA,EACF;AACA,MAAI,CAAC,QAAQ,OAAO,SAAS,SAAU;AACvC,QAAM,SAAS;AAEf,MACE,OAAO,SAAS,WAChB,OAAO,SACP,OAAO,OAAO,UAAU,YACxB,OAAO,KAAK,OAAO,KAAK,EAAE,WAAW,GACrC;AAGA,WAAO,QAAQ,EAAE,MAAM,eAAe;AAAA,EACxC;AAEA,aAAW,OAAO,QAAQ,QAAQ,MAAM,GAAG;AACzC,8BAA0B,OAAO,GAAG,GAAG,cAAc;AAAA,EACvD;AACF;AAEA,SAAS,YAAe,OAAa;AACnC,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,IAAI,WAAW;AACtD,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,OAAO,OAAO,OAAO,OAAO,eAAe,KAAK,CAAC;AACvD,aAAW,OAAO,QAAQ,QAAQ,KAAe,GAAG;AAClD,SAAK,GAAG,IAAI,YAAa,MAAc,GAAG,CAAC;AAAA,EAC7C;AACA,SAAO;AACT;","names":["Type","Type"]}
|
|
1
|
+
{"version":3,"sources":["../src/schemas/components/visual.ts","../src/schemas/components/visual-native.ts","../src/schemas/renderer.ts"],"sourcesContent":["/**\n * Visual Component Schema\n *\n * A `visual` is a free-canvas graphic: absolute positioning, overlapping\n * shapes and layered art that the docx flow layout cannot express — think\n * infographics, diagrams and hero compositions.\n *\n * There are two ways to draw one, chosen by `renderMode`.\n *\n * `raster` (the default, and what an omitted `renderMode` means) authors the\n * canvas as a single pptx slide and embeds the result as a PNG. An injected\n * rasterization service renders it (see `PptxServiceConfig` in\n * @json-to-office/shared), exactly the way `highcharts` offloads chart\n * rendering to an export server; at render time the component desugars to a\n * plain `image`. Every pptx slide element is available, and the output is\n * pixels.\n *\n * `native` draws the same canvas as one Word DrawingML group — real text\n * boxes, real shapes, real pictures — with no pptx, no rasterizer and no PNG.\n * The text stays searchable and every object stays editable in Word. It needs\n * the `office-open` renderer, and its content model is the narrower, strictly\n * validated one in `./visual-native`.\n */\n\nimport { Type, Static } from '@sinclair/typebox';\nimport {\n MIN_VISUAL_DPI,\n MAX_VISUAL_DPI,\n DEFAULT_VISUAL_DPI,\n} from '@json-to-office/shared';\nimport { PptxSlideContentSchema } from '@json-to-office/shared/schemas/slide-content';\nimport {\n AlignmentSchema,\n SpacingSchema,\n FloatingPropertiesSchema,\n} from './common';\nimport {\n NativeVisualCanvasSchema,\n NativeVisualElementSchema,\n} from './visual-native';\n\nexport * from './visual-native';\n\n/**\n * Canvas background — a solid color and/or a background image.\n * Mirrors the pptx slide background shape (kept local to avoid coupling\n * shared-docx to shared-pptx; the rasterizer forwards it verbatim).\n */\nexport const VisualCanvasBackgroundSchema = Type.Object(\n {\n color: Type.Optional(\n Type.String({\n description:\n 'Background color (hex like \"#FFFFFF\" or a theme color name)',\n })\n ),\n image: Type.Optional(\n Type.Object(\n {\n path: Type.Optional(Type.String()),\n base64: Type.Optional(Type.String()),\n },\n { additionalProperties: false }\n )\n ),\n },\n { additionalProperties: false }\n);\n\n/**\n * The pptx canvas the visual is drawn on. Width/height are in inches and set\n * both the aspect ratio and the physical print size of the embedded image.\n */\nexport const VisualCanvasSchema = Type.Object(\n {\n width: Type.Number({\n minimum: 0.1,\n description: 'Canvas width in inches (pptx slideWidth)',\n }),\n height: Type.Number({\n minimum: 0.1,\n description: 'Canvas height in inches (pptx slideHeight)',\n }),\n theme: Type.Optional(\n Type.String({ description: 'pptx theme name applied to the slide' })\n ),\n background: Type.Optional(VisualCanvasBackgroundSchema),\n },\n {\n description: 'pptx canvas definition for the visual',\n additionalProperties: false,\n }\n);\n\n/**\n * Where the drawing sits on the page, and how big it is.\n *\n * Identical for both render modes: a visual is placed like an image whether\n * its pixels came from a rasterizer or its objects were drawn by Word.\n */\nconst PlacementProps = {\n width: Type.Optional(\n Type.Union(\n [\n Type.Number({ minimum: 1, description: 'Rendered width in pixels' }),\n Type.String({\n pattern: '^\\\\d+(\\\\.\\\\d+)?%$',\n description: 'Rendered width as percentage (e.g. \"90%\")',\n }),\n ],\n {\n description:\n 'Rendered width in the document, in pixels (number) or percentage string. Defaults to the canvas physical size.',\n }\n )\n ),\n height: Type.Optional(\n Type.Union([\n Type.Number({ minimum: 1, description: 'Rendered height in pixels' }),\n Type.String({\n pattern: '^\\\\d+(\\\\.\\\\d+)?%$',\n description: 'Rendered height as percentage (e.g. \"90%\")',\n }),\n ])\n ),\n alignment: Type.Optional(AlignmentSchema),\n caption: Type.Optional(\n Type.String({\n description:\n 'Caption (supports rich text with **bold**, *italic*, ***both***)',\n })\n ),\n alt: Type.Optional(\n Type.String({ description: 'Alternative text for accessibility' })\n ),\n spacing: Type.Optional(SpacingSchema),\n floating: Type.Optional(FloatingPropertiesSchema),\n keepNext: Type.Optional(\n Type.Boolean({\n description: 'Keep paragraph with next paragraph on same page',\n })\n ),\n keepLines: Type.Optional(\n Type.Boolean({\n description: 'Keep all lines of paragraph together on same page',\n })\n ),\n} as const;\n\n// A single pptx slide content element (text, image, shape, table, highcharts,\n// chart) is validated against the real PPTX slide-content union\n// (`PptxSlideContentSchema` from @json-to-office/shared/schemas/slide-content)\n// — same authoring fidelity as a standalone `.pptx.json`. Used directly as the\n// `elements` item schema below.\n\n/**\n * The rasterized form: a pptx slide rendered to a PNG.\n *\n * `renderMode` is optional here because omitting it has always meant raster,\n * and every document written before native mode existed must keep rendering\n * byte-for-byte the way it did.\n */\nexport const VisualRasterPropsSchema = Type.Object(\n {\n renderMode: Type.Optional(\n Type.Literal('raster', {\n description:\n 'Render as a rasterized pptx slide (the default when omitted).',\n })\n ),\n\n // ── canvas (drives aspect ratio + physical size) ──\n canvas: VisualCanvasSchema,\n // pptx slide content elements, absolutely positioned on the canvas\n elements: Type.Optional(\n Type.Array(PptxSlideContentSchema, {\n description:\n 'pptx slide content elements (text, image, shape, table, highcharts, chart), positioned with x/y/w/h in inches',\n })\n ),\n\n // ── rasterization ──\n dpi: Type.Optional(\n Type.Number({\n minimum: MIN_VISUAL_DPI,\n maximum: MAX_VISUAL_DPI,\n default: DEFAULT_VISUAL_DPI,\n description: `Raster resolution in DPI (default ${DEFAULT_VISUAL_DPI}, range ${MIN_VISUAL_DPI}-${MAX_VISUAL_DPI}). Higher = sharper + larger.`,\n })\n ),\n serverUrl: Type.Optional(\n Type.String({\n description:\n 'Rasterization service URL override (default from services.pptx)',\n })\n ),\n\n // ── placement in the document (mirrors `image`) ──\n ...PlacementProps,\n },\n {\n // Hoisted into its own JSON-Schema definition rather than inlined at every\n // position a component can appear. `visual.props` is by far the largest\n // props schema in the registry, and inlining two of them pushed the\n // exported `ComponentDefinition` past the depth Ajv can compile.\n $id: 'DocxVisualRasterProps',\n description: 'Visual component props (pptx-rendered graphic)',\n additionalProperties: false,\n }\n);\n\n/**\n * The native form: one Word DrawingML group.\n *\n * `dpi` and `serverUrl` are absent rather than ignored — nothing is\n * rasterized, so a resolution or a service URL would describe work that never\n * happens. `renderMode` is required, which is what makes this branch\n * unreachable by accident.\n */\nexport const VisualNativePropsSchema = Type.Object(\n {\n renderMode: Type.Literal('native', {\n description:\n 'Draw natively as a Word DrawingML group. Requires the \"office-open\" renderer.',\n }),\n canvas: NativeVisualCanvasSchema,\n elements: Type.Optional(\n Type.Array(NativeVisualElementSchema, {\n description:\n 'Native drawing elements (text, shape, image), positioned with x/y/w/h in inches or canvas percentages',\n })\n ),\n ...PlacementProps,\n },\n {\n // Hoisted for the same reason as the raster branch above.\n $id: 'DocxVisualNativeProps',\n description:\n 'Visual component props (native Word drawing group; requires renderer \"office-open\")',\n additionalProperties: false,\n }\n);\n\n/**\n * The authoring surface of `visual`, as a union discriminated on `renderMode`.\n *\n * Kept as one canonical schema rather than two registry entries because the\n * runtime validator checks an un-profiled schema: both shapes have to be\n * structurally valid here, and which one a *document* may use is decided by\n * its renderer, in `schemas/renderer.ts`.\n */\nexport const VisualPropsSchema = Type.Union(\n [VisualRasterPropsSchema, VisualNativePropsSchema],\n {\n description:\n 'Visual component props — rasterized pptx slide (default) or a native Word drawing group',\n }\n);\n\nexport type VisualRasterProps = Static<typeof VisualRasterPropsSchema>;\nexport type VisualNativeProps = Static<typeof VisualNativePropsSchema>;\nexport type VisualProps = VisualRasterProps | VisualNativeProps;\nexport type VisualCanvas = Static<typeof VisualCanvasSchema>;\n\n/** The `renderMode` value that selects the native drawing-group path. */\nexport const NATIVE_RENDER_MODE = 'native';\n\n/** True when these props ask for the native DrawingML path. */\nexport function isNativeVisualProps(\n props: VisualProps | undefined | null\n): props is VisualNativeProps {\n return (\n !!props &&\n (props as { renderMode?: unknown }).renderMode === NATIVE_RENDER_MODE\n );\n}\n","/**\n * Native visual content — the DrawingML side of the `visual` component.\n *\n * A raster visual is authored as a pptx slide because a pptx slide is what\n * rasterizes it. A *native* visual has no such intermediary: it becomes one\n * Word drawing group, so its content model is the subset of that pptx surface\n * Word can draw natively — three element kinds, and only the properties that\n * lower to real DrawingML.\n *\n * The surface is deliberately narrower than the raster one, and strict with it.\n * Every schema here is `additionalProperties: false`, so a property that native\n * mode would ignore is rejected at the authoring boundary instead of silently\n * doing nothing: an author who writes a gradient fill or a chart gets told it\n * is not drawn, rather than shipping a document missing the thing they asked\n * for.\n *\n * Geometry is inches, or a percentage of the canvas extent on that axis. The\n * raster path's \"a number below 100 is inches, at or above it is EMU\" rule is\n * deliberately not reproduced: nothing here is ever EMU.\n */\n\nimport { Type, Static, type TSchema } from '@sinclair/typebox';\nimport { ShapeTypeSchema } from '@json-to-office/shared/schemas/slide-content';\n\n/**\n * A colour anywhere inside a native visual.\n *\n * The same vocabulary the rest of a `.docx.json` uses — `#RRGGBB`, a bare\n * six-digit hex, or a docx theme colour name — because a native visual is\n * drawn by the docx pipeline against the docx theme. The pptx palette names\n * (`accent4`, `tx1`, `bg2`) belong to the raster path and do not resolve here.\n */\nexport const NativeVisualColorSchema = Type.String({\n pattern: '^(#?[0-9A-Fa-f]{6}|[a-zA-Z][a-zA-Z0-9]*)$',\n description:\n 'Hex colour (\"#0F172A\" or \"0F172A\") or a docx theme colour name (e.g. \"primary\")',\n});\n\n/**\n * A signed percentage, for a position: an element may legitimately start off\n * the left or top edge of the canvas.\n */\nconst SIGNED_PERCENT_PATTERN = '^-?\\\\d+(\\\\.\\\\d+)?%$';\n\n/**\n * An unsigned percentage, for a size.\n *\n * Separate from the signed pattern on purpose. The number branch below states\n * `minimum: 0`, and a size that could be negative in one spelling and not the\n * other would make the surface's strictness depend on how the author happened\n * to write it — a negative width has no drawing to refuse it, it just comes\n * out as a zero-size object nobody can see.\n */\nconst PERCENT_PATTERN = '^\\\\d+(\\\\.\\\\d+)?%$';\n\n/** A position on the canvas: inches, or a percentage of the canvas extent. */\nexport const NativeVisualOffsetSchema = Type.Union(\n [\n Type.Number({ description: 'Inches from the canvas origin' }),\n Type.String({\n pattern: SIGNED_PERCENT_PATTERN,\n description: 'Percentage of the canvas extent on this axis, e.g. \"25%\"',\n }),\n ],\n { description: 'Position in inches (number) or as a canvas percentage' }\n);\n\n/** An extent on the canvas: inches, or a percentage of the canvas extent. */\nexport const NativeVisualExtentSchema = Type.Union(\n [\n Type.Number({ minimum: 0, description: 'Size in inches' }),\n Type.String({\n pattern: PERCENT_PATTERN,\n description: 'Percentage of the canvas extent on this axis, e.g. \"50%\"',\n }),\n ],\n { description: 'Size in inches (number) or as a canvas percentage' }\n);\n\nconst FrameProps = {\n x: Type.Optional(NativeVisualOffsetSchema),\n y: Type.Optional(NativeVisualOffsetSchema),\n w: Type.Optional(NativeVisualExtentSchema),\n h: Type.Optional(NativeVisualExtentSchema),\n rotate: Type.Optional(\n Type.Number({ description: 'Clockwise rotation in degrees' })\n ),\n} as const;\n\n/**\n * Underline, as Word draws it.\n *\n * `true` is a single line in the run's own colour; the object form names the\n * line style and, optionally, a colour of its own.\n */\nexport const NativeVisualUnderlineSchema = Type.Union(\n [\n Type.Boolean({ description: 'Single underline in the text colour' }),\n Type.Object(\n {\n style: Type.Optional(\n Type.Union(\n [\n Type.Literal('sng'),\n Type.Literal('dbl'),\n Type.Literal('dash'),\n Type.Literal('dotted'),\n ],\n { description: 'Underline style (default \"sng\")' }\n )\n ),\n color: Type.Optional(NativeVisualColorSchema),\n },\n { additionalProperties: false }\n ),\n ],\n { description: 'Underline: true for a single line, or a style/colour object' }\n);\n\nconst InlineTextProps = {\n fontFace: Type.Optional(Type.String({ description: 'Font family name' })),\n fontSize: Type.Optional(\n Type.Number({ minimum: 1, description: 'Font size in points' })\n ),\n bold: Type.Optional(Type.Boolean()),\n italic: Type.Optional(Type.Boolean()),\n} as const;\n\n/** One formatted span inside a native `text` element. */\nexport const NativeVisualTextRunSchema = Type.Object(\n {\n text: Type.String({ description: 'Run text' }),\n color: Type.Optional(NativeVisualColorSchema),\n ...InlineTextProps,\n underline: Type.Optional(NativeVisualUnderlineSchema),\n strike: Type.Optional(Type.Boolean({ description: 'Strikethrough' })),\n breakLine: Type.Optional(\n Type.Boolean({ description: 'Start a new line after this run' })\n ),\n },\n {\n additionalProperties: false,\n description: 'A formatted run inside a native visual text element',\n }\n);\n\n/**\n * One span of a shape's text.\n *\n * Deliberately not the same shape as a text run: shape text carries no\n * underline or strikethrough in the raster surface either, and native mode\n * keeps the two surfaces aligned rather than quietly widening one.\n */\nexport const NativeVisualTextSegmentSchema = Type.Object(\n {\n text: Type.String({ description: 'Segment text' }),\n color: Type.Optional(NativeVisualColorSchema),\n ...InlineTextProps,\n breakLine: Type.Optional(\n Type.Boolean({ description: 'Start a new line after this segment' })\n ),\n },\n {\n additionalProperties: false,\n description: 'A formatted segment of a native visual shape’s text',\n }\n);\n\n/** A solid fill, or none at all. */\nexport const NativeVisualFillSchema = Type.Object(\n {\n color: Type.Optional(NativeVisualColorSchema),\n transparency: Type.Optional(\n Type.Number({\n minimum: 0,\n maximum: 100,\n description: 'Fill transparency, 0 (opaque) to 100 (invisible)',\n })\n ),\n },\n {\n additionalProperties: false,\n description:\n 'Solid fill. Omit the whole property for no fill; gradients and patterns are raster-only.',\n }\n);\n\n/** A shape outline: solid or dashed, one uniform stroke. */\nexport const NativeVisualLineSchema = Type.Object(\n {\n color: Type.Optional(NativeVisualColorSchema),\n width: Type.Optional(\n Type.Number({ minimum: 0, description: 'Outline width in points' })\n ),\n dashType: Type.Optional(\n Type.Union(\n [\n Type.Literal('solid'),\n Type.Literal('dash'),\n Type.Literal('dot'),\n Type.Literal('dashDot'),\n ],\n { description: 'Outline dash pattern (default \"solid\")' }\n )\n ),\n },\n { additionalProperties: false, description: 'Shape outline' }\n);\n\nexport const NativeVisualAlignmentSchema = Type.Union(\n [\n Type.Literal('left'),\n Type.Literal('center'),\n Type.Literal('right'),\n Type.Literal('justify'),\n ],\n { description: 'Horizontal text alignment' }\n);\n\nexport const NativeVisualVerticalAlignmentSchema = Type.Union(\n [Type.Literal('top'), Type.Literal('middle'), Type.Literal('bottom')],\n { description: 'Vertical text anchoring inside the box' }\n);\n\n/** Text inset, in points: one value for every side, or `[top, right, bottom, left]`. */\nexport const NativeVisualMarginSchema = Type.Union(\n [\n Type.Number({ minimum: 0, description: 'Inset on every side, in points' }),\n Type.Array(Type.Number({ minimum: 0 }), {\n minItems: 4,\n maxItems: 4,\n description: 'Insets as [top, right, bottom, left], in points',\n }),\n ],\n { description: 'Text insets in points' }\n);\n\nexport const NativeVisualTextPropsSchema = Type.Object(\n {\n text: Type.Optional(Type.String({ description: 'Plain text content' })),\n runs: Type.Optional(\n Type.Array(NativeVisualTextRunSchema, {\n minItems: 1,\n description: 'Formatted runs, as an alternative to \"text\"',\n })\n ),\n ...FrameProps,\n color: Type.Optional(NativeVisualColorSchema),\n ...InlineTextProps,\n underline: Type.Optional(NativeVisualUnderlineSchema),\n strike: Type.Optional(Type.Boolean({ description: 'Strikethrough' })),\n align: Type.Optional(NativeVisualAlignmentSchema),\n valign: Type.Optional(NativeVisualVerticalAlignmentSchema),\n margin: Type.Optional(NativeVisualMarginSchema),\n fill: Type.Optional(NativeVisualFillSchema),\n },\n {\n additionalProperties: false,\n description:\n 'Native visual text element — becomes a Word text box (wps:wsp) inside the drawing group',\n }\n);\n\nexport const NativeVisualShapePropsSchema = Type.Object(\n {\n type: ShapeTypeSchema,\n ...FrameProps,\n fill: Type.Optional(NativeVisualFillSchema),\n line: Type.Optional(NativeVisualLineSchema),\n text: Type.Optional(\n Type.Union(\n [\n Type.String(),\n Type.Array(NativeVisualTextSegmentSchema, { minItems: 1 }),\n ],\n { description: 'Text drawn inside the shape' }\n )\n ),\n ...InlineTextProps,\n fontColor: Type.Optional(NativeVisualColorSchema),\n align: Type.Optional(NativeVisualAlignmentSchema),\n valign: Type.Optional(NativeVisualVerticalAlignmentSchema),\n margin: Type.Optional(NativeVisualMarginSchema),\n flipH: Type.Optional(Type.Boolean({ description: 'Mirror horizontally' })),\n flipV: Type.Optional(Type.Boolean({ description: 'Mirror vertically' })),\n },\n {\n additionalProperties: false,\n description:\n 'Native visual shape element — becomes a preset-geometry shape (wps:wsp) inside the drawing group',\n }\n);\n\nexport const NativeVisualImagePropsSchema = Type.Object(\n {\n path: Type.Optional(\n Type.String({ description: 'File path or http(s) URL' })\n ),\n base64: Type.Optional(Type.String({ description: 'Base64 data URI' })),\n svg: Type.Optional(Type.String({ description: 'Raw SVG markup' })),\n ...FrameProps,\n sizing: Type.Optional(\n Type.Object(\n {\n type: Type.Union(\n [\n Type.Literal('contain'),\n Type.Literal('cover'),\n Type.Literal('crop'),\n ],\n { description: 'How the image fills its box' }\n ),\n w: Type.Optional(\n Type.Number({\n minimum: 0,\n description:\n 'Box width in inches; overrides the element’s own \"w\"',\n })\n ),\n h: Type.Optional(\n Type.Number({\n minimum: 0,\n description:\n 'Box height in inches; overrides the element’s own \"h\"',\n })\n ),\n },\n {\n additionalProperties: false,\n description:\n 'How the image fills its box. \"w\"/\"h\" state the box itself, taking precedence over the element’s \"w\"/\"h\", as they do in raster mode.',\n }\n )\n ),\n alt: Type.Optional(\n Type.String({ description: 'Alternative text for accessibility' })\n ),\n },\n {\n additionalProperties: false,\n description:\n 'Native visual image element — becomes a native picture inside the drawing group',\n }\n);\n\n/** The three element kinds a native visual can hold, in public schema order. */\nexport const NATIVE_VISUAL_ELEMENT_NAMES = ['text', 'shape', 'image'] as const;\n\nexport type NativeVisualElementName =\n (typeof NATIVE_VISUAL_ELEMENT_NAMES)[number];\n\nfunction nativeElement<\n const TName extends NativeVisualElementName,\n const TProps extends TSchema,\n>(name: TName, propsSchema: TProps, description: string) {\n return Type.Object(\n {\n name: Type.Literal(name),\n id: Type.Optional(Type.String()),\n enabled: Type.Optional(\n Type.Boolean({\n default: true,\n description:\n 'When false, this element is filtered out and not drawn. Defaults to true.',\n })\n ),\n props: propsSchema,\n },\n { additionalProperties: false, description }\n );\n}\n\n/**\n * A single element of a native visual.\n *\n * `table`, `chart` and `highcharts` are absent on purpose: a Word table cannot\n * live inside a drawing group, and neither chart kind has a native mapping\n * here yet. Naming one is a validation error rather than a silent drop.\n *\n * The `$id` is distinct from the raster union's `PptxSlideContent` so the two\n * never collide when the document schema hoists them into shared definitions.\n */\nexport const NativeVisualElementSchema = Type.Union(\n [\n nativeElement(\n 'text',\n NativeVisualTextPropsSchema,\n 'Text element - a native Word text box drawn on the visual canvas.'\n ),\n nativeElement(\n 'shape',\n NativeVisualShapePropsSchema,\n 'Shape element - a native preset-geometry shape, optionally holding text.'\n ),\n nativeElement(\n 'image',\n NativeVisualImagePropsSchema,\n 'Image element - a native picture; an SVG stays vector.'\n ),\n ],\n {\n $id: 'DocxNativeVisualContent',\n discriminator: { propertyName: 'name' },\n description: 'A single native visual element (text, shape, or image).',\n }\n);\n\n/**\n * The canvas a native visual is drawn on.\n *\n * No `theme`: the raster canvas names a *pptx* theme, which the docx pipeline\n * cannot resolve. Native colours resolve against the document's own docx theme\n * instead, so naming a pptx theme here would promise something that could not\n * be kept.\n */\nexport const NativeVisualCanvasSchema = Type.Object(\n {\n width: Type.Number({\n minimum: 0.1,\n description: 'Canvas width in inches',\n }),\n height: Type.Number({\n minimum: 0.1,\n description: 'Canvas height in inches',\n }),\n background: Type.Optional(\n Type.Object(\n {\n color: Type.Optional(NativeVisualColorSchema),\n image: Type.Optional(\n Type.Object(\n {\n path: Type.Optional(Type.String()),\n base64: Type.Optional(Type.String()),\n },\n { additionalProperties: false }\n )\n ),\n },\n {\n additionalProperties: false,\n description:\n 'Canvas background. A colour becomes the bottom-most rectangle; an image becomes the bottom-most picture.',\n }\n )\n ),\n },\n {\n additionalProperties: false,\n description: 'Drawing canvas for a native visual',\n }\n);\n\nexport type NativeVisualCanvas = Static<typeof NativeVisualCanvasSchema>;\nexport type NativeVisualElement = Static<typeof NativeVisualElementSchema>;\nexport type NativeVisualTextProps = Static<typeof NativeVisualTextPropsSchema>;\nexport type NativeVisualShapeProps = Static<\n typeof NativeVisualShapePropsSchema\n>;\nexport type NativeVisualImageProps = Static<\n typeof NativeVisualImagePropsSchema\n>;\nexport type NativeVisualTextRun = Static<typeof NativeVisualTextRunSchema>;\nexport type NativeVisualTextSegment = Static<\n typeof NativeVisualTextSegmentSchema\n>;\nexport type NativeVisualFill = Static<typeof NativeVisualFillSchema>;\nexport type NativeVisualLine = Static<typeof NativeVisualLineSchema>;\n","import type { TSchema } from '@sinclair/typebox';\nimport type { ValidationError } from '@json-to-office/shared';\nimport { NATIVE_RENDER_MODE } from './components/visual';\n\nexport const DOCX_RENDERER_IDS = ['docxjs', 'office-open'] as const;\nexport type DocxRendererId = (typeof DOCX_RENDERER_IDS)[number];\nexport const DEFAULT_DOCX_RENDERER_ID: DocxRendererId = 'docxjs';\n\n/** The element kinds a native `visual` can hold. */\nconst NATIVE_VISUAL_ELEMENTS: ReadonlySet<string> = new Set([\n 'text',\n 'shape',\n 'image',\n]);\n\n/**\n * The exported JSON-Schema definition name for one renderer's component union.\n *\n * One name per renderer, never a shared one. The two views differ wherever a\n * backend cannot draw something, so a single definition would hand every\n * position that goes through it — a section header or footer, a table cell's\n * content, `componentDefaults` — whichever view the exporter happened to walk\n * last, and give a schema-driven editor the wrong diagnostics for the other\n * renderer.\n */\nexport function docxComponentDefinitionName(renderer: DocxRendererId): string {\n return `ComponentDefinition_${renderer}`;\n}\n\n/**\n * Derive one renderer view from the canonical props schema.\n *\n * The canonical schema is the union of everything any backend can express, so\n * a profile is a *subtraction*: the branches and fields this renderer cannot\n * draw are removed, which is what makes a schema-driven editor offer only what\n * the chosen backend will actually render.\n */\nexport function docxPropsSchemaForRenderer(\n componentName: string,\n schema: TSchema,\n renderer: DocxRendererId\n): TSchema {\n const copy = cloneSchema(schema);\n nameComponentPlaceholders(copy, docxComponentDefinitionName(renderer));\n\n if (componentName === 'visual' && renderer !== 'office-open') {\n // Only `office-open` draws a native group, so every other backend sees the\n // raster branch alone — a plain object rather than a union, which is what\n // gives an editor one unambiguous completion set.\n return firstUnionBranch(copy) ?? copy;\n }\n\n if (renderer === 'office-open') pruneThreadFields(copy);\n return copy;\n}\n\n/** Static renderer-profile diagnostics used by CLI/library validation. */\nexport function collectDocxRendererErrors(data: unknown): ValidationError[] {\n if (!data || typeof data !== 'object' || Array.isArray(data)) return [];\n const root = data as Record<string, any>;\n const renderer = root.renderer ?? DEFAULT_DOCX_RENDERER_ID;\n\n if (!DOCX_RENDERER_IDS.includes(renderer)) {\n return [\n {\n path: '/renderer',\n message: `Invalid renderer \"${String(renderer)}\". Expected \"docxjs\" or \"office-open\".`,\n code: 'invalid_value',\n },\n ];\n }\n\n const errors: ValidationError[] = [];\n const isOfficeOpen = renderer === 'office-open';\n\n const visit = (node: unknown, path: string): void => {\n if (Array.isArray(node)) {\n node.forEach((entry, index) => visit(entry, `${path}/${index}`));\n return;\n }\n if (!node || typeof node !== 'object') return;\n const object = node as Record<string, unknown>;\n\n if (isOfficeOpen) {\n const comment = object.comment;\n if (comment && typeof comment === 'object' && !Array.isArray(comment)) {\n const value = comment as Record<string, unknown>;\n for (const field of ['replies', 'resolved'] as const) {\n if (value[field] !== undefined) {\n errors.push({\n path: `${path}/comment/${field}`,\n message: `The \"office-open\" renderer does not support comment threads.`,\n code: 'unsupported_renderer_feature',\n });\n }\n }\n }\n }\n\n if (object.name === 'visual') {\n collectVisualErrors(object, `${path}`, isOfficeOpen, errors);\n }\n\n // A schema-driven editor already refuses `chart` outside office-open —\n // the component is absent from that branch entirely. This is the same\n // rule stated where a caller reaches validation without the schema, and\n // it names the path of the node rather than the document, so the error\n // lands on the component the author has to move or drop.\n if (object.name === 'chart' && !isOfficeOpen) {\n errors.push({\n path: `${path}/name`,\n message:\n 'Only the \"office-open\" renderer draws a native chart. Set the document\\'s \"renderer\" to \"office-open\", or use \"highcharts\" to render one as an image.',\n code: 'unsupported_renderer_feature',\n });\n }\n\n for (const [key, value] of Object.entries(object)) {\n if (key !== 'renderer') visit(value, `${path}/${key}`);\n }\n };\n\n visit(root, '');\n return errors;\n}\n\n/**\n * Native-mode rules for one `visual` node.\n *\n * Two separate concerns, and both have to name a path an editor can jump to.\n * A backend that cannot draw a group must reject the mode itself, at\n * `props/renderMode`. A backend that can must still reject element kinds that\n * have no native form — otherwise a `chart` inside a native visual would\n * validate and then vanish, which is exactly the failure mode strictness\n * exists to prevent.\n */\nfunction collectVisualErrors(\n node: Record<string, unknown>,\n path: string,\n isOfficeOpen: boolean,\n errors: ValidationError[]\n): void {\n const props = node.props;\n if (!props || typeof props !== 'object' || Array.isArray(props)) return;\n const value = props as Record<string, unknown>;\n if (value.renderMode !== NATIVE_RENDER_MODE) return;\n\n if (!isOfficeOpen) {\n errors.push({\n path: `${path}/props/renderMode`,\n message:\n 'Only the \"office-open\" renderer draws a native visual. Set the document\\'s \"renderer\" to \"office-open\", or drop \"renderMode\" to rasterize.',\n code: 'unsupported_renderer_feature',\n });\n return;\n }\n\n const elements = value.elements;\n if (!Array.isArray(elements)) return;\n elements.forEach((element, index) => {\n if (!element || typeof element !== 'object' || Array.isArray(element)) {\n return;\n }\n const name = (element as Record<string, unknown>).name;\n if (typeof name !== 'string' || NATIVE_VISUAL_ELEMENTS.has(name)) return;\n errors.push({\n path: `${path}/props/elements/${index}/name`,\n message:\n `A native visual cannot draw \"${name}\". Native mode holds \"text\", ` +\n '\"shape\" and \"image\"; use renderMode \"raster\" for anything else.',\n code: 'unsupported_renderer_feature',\n });\n });\n}\n\n/** The first branch of a union schema, if this is one. */\nfunction firstUnionBranch(schema: TSchema): TSchema | undefined {\n const branches = (schema as { anyOf?: TSchema[] }).anyOf;\n return Array.isArray(branches) && branches.length > 0\n ? branches[0]\n : undefined;\n}\n\nfunction pruneThreadFields(node: unknown): void {\n if (Array.isArray(node)) {\n node.forEach(pruneThreadFields);\n return;\n }\n if (!node || typeof node !== 'object') return;\n const schema = node as Record<PropertyKey, any>;\n const properties = schema.properties as Record<string, TSchema> | undefined;\n if (\n properties?.text &&\n properties?.author &&\n (properties.replies || properties.resolved) &&\n typeof schema.description === 'string' &&\n schema.description.includes('Word review comment')\n ) {\n delete properties.replies;\n delete properties.resolved;\n const required = schema.required as string[] | undefined;\n if (required) {\n schema.required = required.filter(\n (key) => key !== 'replies' && key !== 'resolved'\n );\n }\n }\n for (const key of Reflect.ownKeys(schema)) {\n pruneThreadFields(schema[key]);\n }\n}\n\n/**\n * Point a renderer's props at that renderer's component definition.\n *\n * A position that holds arbitrary components but is built from a *static*\n * schema carries an untyped item instead of a live recursive ref —\n * `componentDefaults.section.header` is the one that matters, because\n * `ComponentDefaultsSchema` is shared with the theme and so cannot be handed\n * the recursion. The export pass used to resolve those against one hard-coded\n * name; naming them here, while the renderer is still known and the schema is\n * still this renderer's private clone, is what keeps the two views apart.\n */\nfunction nameComponentPlaceholders(\n node: unknown,\n definitionName: string\n): void {\n if (Array.isArray(node)) {\n node.forEach((entry) => nameComponentPlaceholders(entry, definitionName));\n return;\n }\n if (!node || typeof node !== 'object') return;\n const schema = node as Record<PropertyKey, any>;\n\n if (\n schema.type === 'array' &&\n schema.items &&\n typeof schema.items === 'object' &&\n Object.keys(schema.items).length === 0\n ) {\n // A bare name, the same shape `Type.Recursive` emits for its own self\n // reference. `fixSchemaReferences` resolves both to `#/definitions/...`.\n schema.items = { $ref: definitionName };\n }\n\n for (const key of Reflect.ownKeys(schema)) {\n nameComponentPlaceholders(schema[key], definitionName);\n }\n}\n\nfunction cloneSchema<T>(value: T): T {\n if (Array.isArray(value)) return value.map(cloneSchema) as T;\n if (!value || typeof value !== 'object') return value;\n const copy = Object.create(Object.getPrototypeOf(value));\n for (const key of Reflect.ownKeys(value as object)) {\n copy[key] = cloneSchema((value as any)[key]);\n }\n return copy;\n}\n"],"mappings":";;;;;;;AAwBA,SAAS,QAAAA,aAAoB;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;;;ACTvC,SAAS,YAAkC;AAC3C,SAAS,uBAAuB;AAUzB,IAAM,0BAA0B,KAAK,OAAO;AAAA,EACjD,SAAS;AAAA,EACT,aACE;AACJ,CAAC;AAMD,IAAM,yBAAyB;AAW/B,IAAM,kBAAkB;AAGjB,IAAM,2BAA2B,KAAK;AAAA,EAC3C;AAAA,IACE,KAAK,OAAO,EAAE,aAAa,gCAAgC,CAAC;AAAA,IAC5D,KAAK,OAAO;AAAA,MACV,SAAS;AAAA,MACT,aAAa;AAAA,IACf,CAAC;AAAA,EACH;AAAA,EACA,EAAE,aAAa,wDAAwD;AACzE;AAGO,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B,OAAO,GAAG,CAAC;AAAA,EAC/B;AACF;AAaA,SAAS,0BACP,MACA,gBACM;AACN,MAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,SAAK,QAAQ,CAAC,UAAU,0BAA0B,OAAO,cAAc,CAAC;AACxE;AAAA,EACF;AACA,MAAI,CAAC,QAAQ,OAAO,SAAS,SAAU;AACvC,QAAM,SAAS;AAEf,MACE,OAAO,SAAS,WAChB,OAAO,SACP,OAAO,OAAO,UAAU,YACxB,OAAO,KAAK,OAAO,KAAK,EAAE,WAAW,GACrC;AAGA,WAAO,QAAQ,EAAE,MAAM,eAAe;AAAA,EACxC;AAEA,aAAW,OAAO,QAAQ,QAAQ,MAAM,GAAG;AACzC,8BAA0B,OAAO,GAAG,GAAG,cAAc;AAAA,EACvD;AACF;AAEA,SAAS,YAAe,OAAa;AACnC,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,IAAI,WAAW;AACtD,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,OAAO,OAAO,OAAO,OAAO,eAAe,KAAK,CAAC;AACvD,aAAW,OAAO,QAAQ,QAAQ,KAAe,GAAG;AAClD,SAAK,GAAG,IAAI,YAAa,MAAc,GAAG,CAAC;AAAA,EAC7C;AACA,SAAO;AACT;","names":["Type","Type"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAllComponentSchemas,
|
|
3
3
|
createAllComponentSchemasNarrowed
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MMD4A5LR.js";
|
|
5
5
|
|
|
6
6
|
// src/schemas/components.ts
|
|
7
7
|
import { Type } from "@sinclair/typebox";
|
|
@@ -31,4 +31,4 @@ export {
|
|
|
31
31
|
StandardComponentDefinitionSchema,
|
|
32
32
|
ComponentDefinitionSchema
|
|
33
33
|
};
|
|
34
|
-
//# sourceMappingURL=chunk-
|
|
34
|
+
//# sourceMappingURL=chunk-M4F3PWQR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/components.ts"],"sourcesContent":["/**\n * TypeBox Component Schemas\n *\n * Complete component definitions with discriminated unions for perfect\n * JSON schema autocompletion and validation.\n *\n * IMPORTANT: Standard components are defined in component-registry.ts (SINGLE SOURCE OF TRUTH).\n * This file uses that registry to generate TypeBox schemas.\n */\n\nimport { Type, Static } from '@sinclair/typebox';\nimport {\n createAllComponentSchemas,\n createAllComponentSchemasNarrowed,\n} from './component-registry';\n\n// Re-export all schemas from individual component files\nexport * from './components/common';\nexport * from './components/revision';\nexport * from './components/comment';\nexport * from './components/note';\nexport * from './components/report';\nexport * from './components/section';\nexport * from './components/columns';\nexport * from './components/heading';\nexport * from './components/paragraph';\nexport * from './components/image';\nexport * from './components/highcharts';\nexport * from './components/chart';\nexport * from './components/visual';\nexport * from './components/statistic';\nexport * from './components/table';\nexport * from './components/list';\nexport * from './components/toc';\nexport * from './components/text-box';\n\n// ============================================================================\n// Component Definitions with Discriminated Union\n// ============================================================================\n\n// StandardComponentDefinitionSchema - Union of all standard component types\n// Generated from the component registry (SINGLE SOURCE OF TRUTH)\nexport const StandardComponentDefinitionSchema = Type.Union(\n // Use Type.Any() for non-recursive standard components\n // Convert readonly array to mutable array for Type.Union\n [...createAllComponentSchemas(Type.Any())],\n {\n discriminator: { propertyName: 'name' },\n description: 'Standard component definition with discriminated union',\n }\n);\n\nexport const ComponentDefinitionSchema = Type.Recursive((This) =>\n Type.Union(\n [\n // Standard components from registry with per-container narrowed children\n ...createAllComponentSchemasNarrowed(This).schemas,\n ],\n {\n discriminator: { propertyName: 'name' },\n description: 'Component definition with discriminated union',\n }\n )\n);\n\n// ============================================================================\n// TypeScript Types\n// ============================================================================\n\nexport type ComponentDefinition = Static<typeof ComponentDefinitionSchema>;\n"],"mappings":";;;;;;AAUA,SAAS,YAAoB;AAgCtB,IAAM,oCAAoC,KAAK;AAAA;AAAA;AAAA,EAGpD,CAAC,GAAG,0BAA0B,KAAK,IAAI,CAAC,CAAC;AAAA,EACzC;AAAA,IACE,eAAe,EAAE,cAAc,OAAO;AAAA,IACtC,aAAa;AAAA,EACf;AACF;AAEO,IAAM,4BAA4B,KAAK;AAAA,EAAU,CAAC,SACvD,KAAK;AAAA,IACH;AAAA;AAAA,MAEE,GAAG,kCAAkC,IAAI,EAAE;AAAA,IAC7C;AAAA,IACA;AAAA,MACE,eAAe,EAAE,cAAc,OAAO;AAAA,MACtC,aAAa;AAAA,IACf;AAAA,EACF;AACF;","names":[]}
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
DOCX_RENDERER_IDS,
|
|
3
3
|
VisualPropsSchema,
|
|
4
4
|
docxPropsSchemaForRenderer
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-EG5UTHFZ.js";
|
|
6
6
|
import {
|
|
7
7
|
ThemeOverridesSchema
|
|
8
8
|
} from "./chunk-45I2NASU.js";
|
|
@@ -20,7 +20,9 @@ import {
|
|
|
20
20
|
createTablePropsSchema
|
|
21
21
|
} from "./chunk-OP5PCDNN.js";
|
|
22
22
|
import {
|
|
23
|
-
|
|
23
|
+
AlignmentSchema,
|
|
24
|
+
FloatingPropertiesSchema,
|
|
25
|
+
SpacingSchema
|
|
24
26
|
} from "./chunk-VX2J2KWA.js";
|
|
25
27
|
import {
|
|
26
28
|
HexColorSchema,
|
|
@@ -28,7 +30,7 @@ import {
|
|
|
28
30
|
} from "./chunk-7TTAAYQ5.js";
|
|
29
31
|
|
|
30
32
|
// src/schemas/component-registry.ts
|
|
31
|
-
import { Type as
|
|
33
|
+
import { Type as Type6 } from "@sinclair/typebox";
|
|
32
34
|
|
|
33
35
|
// src/schemas/components/report.ts
|
|
34
36
|
import { Type } from "@sinclair/typebox";
|
|
@@ -518,6 +520,123 @@ var HighchartsPropsSchema = Type4.Object({
|
|
|
518
520
|
)
|
|
519
521
|
});
|
|
520
522
|
|
|
523
|
+
// src/schemas/components/chart.ts
|
|
524
|
+
import { Type as Type5 } from "@sinclair/typebox";
|
|
525
|
+
var ChartTypeSchema = Type5.Union(
|
|
526
|
+
[
|
|
527
|
+
Type5.Literal("area"),
|
|
528
|
+
Type5.Literal("bar"),
|
|
529
|
+
Type5.Literal("column"),
|
|
530
|
+
Type5.Literal("doughnut"),
|
|
531
|
+
Type5.Literal("line"),
|
|
532
|
+
Type5.Literal("pie"),
|
|
533
|
+
Type5.Literal("radar"),
|
|
534
|
+
Type5.Literal("scatter")
|
|
535
|
+
],
|
|
536
|
+
{ description: "Chart type" }
|
|
537
|
+
);
|
|
538
|
+
var ChartDataSeriesSchema = Type5.Object(
|
|
539
|
+
{
|
|
540
|
+
name: Type5.Optional(Type5.String({ description: "Series name" })),
|
|
541
|
+
labels: Type5.Optional(
|
|
542
|
+
Type5.Array(Type5.String(), {
|
|
543
|
+
description: "Category labels. Needed on every series, not just the first, and the same length as `values`; a series without both `labels` and `values` drops the whole chart."
|
|
544
|
+
})
|
|
545
|
+
),
|
|
546
|
+
values: Type5.Optional(
|
|
547
|
+
Type5.Array(Type5.Number(), {
|
|
548
|
+
description: "Data values, one per label. Needed on every series \u2014 see `labels`."
|
|
549
|
+
})
|
|
550
|
+
)
|
|
551
|
+
},
|
|
552
|
+
{ additionalProperties: false }
|
|
553
|
+
);
|
|
554
|
+
var ChartPropsSchema = Type5.Object(
|
|
555
|
+
{
|
|
556
|
+
type: ChartTypeSchema,
|
|
557
|
+
data: Type5.Array(ChartDataSeriesSchema, {
|
|
558
|
+
description: "Chart data series",
|
|
559
|
+
minItems: 1
|
|
560
|
+
}),
|
|
561
|
+
// Title
|
|
562
|
+
title: Type5.Optional(Type5.String({ description: "Chart title text" })),
|
|
563
|
+
showTitle: Type5.Optional(
|
|
564
|
+
Type5.Boolean({
|
|
565
|
+
description: "Show the chart title. Defaults to true when `title` is set."
|
|
566
|
+
})
|
|
567
|
+
),
|
|
568
|
+
// Legend
|
|
569
|
+
showLegend: Type5.Optional(
|
|
570
|
+
Type5.Boolean({ description: "Show chart legend" })
|
|
571
|
+
),
|
|
572
|
+
legendPos: Type5.Optional(
|
|
573
|
+
Type5.Union(
|
|
574
|
+
[
|
|
575
|
+
Type5.Literal("b"),
|
|
576
|
+
Type5.Literal("l"),
|
|
577
|
+
Type5.Literal("r"),
|
|
578
|
+
Type5.Literal("t"),
|
|
579
|
+
Type5.Literal("tr")
|
|
580
|
+
],
|
|
581
|
+
{ description: "Legend position" }
|
|
582
|
+
)
|
|
583
|
+
),
|
|
584
|
+
// Series colors
|
|
585
|
+
chartColors: Type5.Optional(
|
|
586
|
+
Type5.Array(Type5.String(), {
|
|
587
|
+
description: "Series colors (hex or semantic theme names). Defaults to the theme palette."
|
|
588
|
+
})
|
|
589
|
+
),
|
|
590
|
+
// Axis titles
|
|
591
|
+
catAxisTitle: Type5.Optional(
|
|
592
|
+
Type5.String({ description: "Category axis title" })
|
|
593
|
+
),
|
|
594
|
+
valAxisTitle: Type5.Optional(
|
|
595
|
+
Type5.String({ description: "Value axis title" })
|
|
596
|
+
),
|
|
597
|
+
// Flow placement — the same vocabulary as `image` and `highcharts`.
|
|
598
|
+
width: Type5.Optional(
|
|
599
|
+
Type5.Number({
|
|
600
|
+
minimum: 0,
|
|
601
|
+
exclusiveMinimum: 0,
|
|
602
|
+
description: "Chart width in inches. Defaults to the content width."
|
|
603
|
+
})
|
|
604
|
+
),
|
|
605
|
+
height: Type5.Optional(
|
|
606
|
+
Type5.Number({
|
|
607
|
+
minimum: 0,
|
|
608
|
+
exclusiveMinimum: 0,
|
|
609
|
+
description: "Chart height in inches. Defaults to 3."
|
|
610
|
+
})
|
|
611
|
+
),
|
|
612
|
+
alignment: Type5.Optional(AlignmentSchema),
|
|
613
|
+
caption: Type5.Optional(
|
|
614
|
+
Type5.String({
|
|
615
|
+
description: "Chart caption (supports rich text with **bold**, *italic*, ***both***)"
|
|
616
|
+
})
|
|
617
|
+
),
|
|
618
|
+
alt: Type5.Optional(
|
|
619
|
+
Type5.String({ description: "Alternative text for accessibility" })
|
|
620
|
+
),
|
|
621
|
+
spacing: Type5.Optional(SpacingSchema),
|
|
622
|
+
floating: Type5.Optional(FloatingPropertiesSchema),
|
|
623
|
+
keepNext: Type5.Optional(
|
|
624
|
+
Type5.Boolean({
|
|
625
|
+
description: "Keep paragraph with next paragraph on same page"
|
|
626
|
+
})
|
|
627
|
+
),
|
|
628
|
+
keepLines: Type5.Optional(
|
|
629
|
+
Type5.Boolean({
|
|
630
|
+
description: "Keep all lines of paragraph together on same page"
|
|
631
|
+
})
|
|
632
|
+
)
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
description: 'Native Word chart - editable, scalable, no export server needed. Requires renderer "office-open".',
|
|
636
|
+
additionalProperties: false
|
|
637
|
+
}
|
|
638
|
+
);
|
|
639
|
+
|
|
521
640
|
// src/schemas/component-registry.ts
|
|
522
641
|
var STANDARD_COMPONENTS_REGISTRY = [
|
|
523
642
|
// ========================================================================
|
|
@@ -549,6 +668,7 @@ var STANDARD_COMPONENTS_REGISTRY = [
|
|
|
549
668
|
"list",
|
|
550
669
|
"toc",
|
|
551
670
|
"highcharts",
|
|
671
|
+
"chart",
|
|
552
672
|
"visual",
|
|
553
673
|
"columns",
|
|
554
674
|
"text-box"
|
|
@@ -569,6 +689,7 @@ var STANDARD_COMPONENTS_REGISTRY = [
|
|
|
569
689
|
"list",
|
|
570
690
|
"toc",
|
|
571
691
|
"highcharts",
|
|
692
|
+
"chart",
|
|
572
693
|
"visual",
|
|
573
694
|
"text-box"
|
|
574
695
|
],
|
|
@@ -643,6 +764,17 @@ var STANDARD_COMPONENTS_REGISTRY = [
|
|
|
643
764
|
category: "content",
|
|
644
765
|
description: "Chart component powered by Highcharts - render line, bar, pie, heatmap, and more with rich options."
|
|
645
766
|
},
|
|
767
|
+
{
|
|
768
|
+
name: "chart",
|
|
769
|
+
propsSchema: ChartPropsSchema,
|
|
770
|
+
hasChildren: false,
|
|
771
|
+
// docx.js has no chart primitive at all, so this is a backend gap rather
|
|
772
|
+
// than a slice boundary — the same reasoning that keeps `drawing-groups`
|
|
773
|
+
// off the docxjs capability set.
|
|
774
|
+
renderers: ["office-open"],
|
|
775
|
+
category: "content",
|
|
776
|
+
description: 'Native Word chart - editable, scalable, no export server needed. Requires renderer "office-open".'
|
|
777
|
+
},
|
|
646
778
|
{
|
|
647
779
|
name: "visual",
|
|
648
780
|
propsSchema: VisualPropsSchema,
|
|
@@ -675,26 +807,26 @@ function demandsProps(propsSchema) {
|
|
|
675
807
|
}
|
|
676
808
|
function createComponentSchemaObject(component, childrenType, selfRef, profile) {
|
|
677
809
|
const schema = {
|
|
678
|
-
name:
|
|
679
|
-
id:
|
|
680
|
-
enabled:
|
|
681
|
-
|
|
810
|
+
name: Type6.Literal(component.name),
|
|
811
|
+
id: Type6.Optional(Type6.String()),
|
|
812
|
+
enabled: Type6.Optional(
|
|
813
|
+
Type6.Boolean({
|
|
682
814
|
default: true,
|
|
683
815
|
description: "When false, this component is filtered out and not rendered. Defaults to true. Useful for conditional component inclusion."
|
|
684
816
|
})
|
|
685
817
|
)
|
|
686
818
|
};
|
|
687
819
|
if (component.special?.hasSchemaField) {
|
|
688
|
-
schema.$schema =
|
|
689
|
-
schema.renderer = profile ? profile.requireDiscriminator ?
|
|
820
|
+
schema.$schema = Type6.Optional(Type6.String({ format: "uri" }));
|
|
821
|
+
schema.renderer = profile ? profile.requireDiscriminator ? Type6.Literal(profile.renderer, {
|
|
690
822
|
description: "Renderer backend for this document"
|
|
691
|
-
}) :
|
|
692
|
-
|
|
823
|
+
}) : Type6.Optional(
|
|
824
|
+
Type6.Literal(profile.renderer, {
|
|
693
825
|
description: 'Renderer backend. Omitted defaults to "docxjs".'
|
|
694
826
|
})
|
|
695
|
-
) :
|
|
696
|
-
|
|
697
|
-
DOCX_RENDERER_IDS.map((renderer) =>
|
|
827
|
+
) : Type6.Optional(
|
|
828
|
+
Type6.Union(
|
|
829
|
+
DOCX_RENDERER_IDS.map((renderer) => Type6.Literal(renderer)),
|
|
698
830
|
{
|
|
699
831
|
description: 'Renderer backend. Omitted defaults to "docxjs".'
|
|
700
832
|
}
|
|
@@ -707,11 +839,11 @@ function createComponentSchemaObject(component, childrenType, selfRef, profile)
|
|
|
707
839
|
basePropsSchema,
|
|
708
840
|
profile.renderer
|
|
709
841
|
) : basePropsSchema;
|
|
710
|
-
schema.props = demandsProps(propsSchema) ? propsSchema :
|
|
842
|
+
schema.props = demandsProps(propsSchema) ? propsSchema : Type6.Optional(propsSchema);
|
|
711
843
|
if (component.hasChildren && childrenType) {
|
|
712
|
-
schema.children = component.special?.hasSchemaField ?
|
|
844
|
+
schema.children = component.special?.hasSchemaField ? Type6.Array(childrenType) : Type6.Optional(Type6.Array(childrenType));
|
|
713
845
|
}
|
|
714
|
-
return
|
|
846
|
+
return Type6.Object(schema, {
|
|
715
847
|
additionalProperties: false,
|
|
716
848
|
description: component.description
|
|
717
849
|
});
|
|
@@ -722,8 +854,10 @@ function createAllComponentSchemas(recursiveRef) {
|
|
|
722
854
|
);
|
|
723
855
|
}
|
|
724
856
|
function createAllComponentSchemasNarrowed(selfRef, pluginSchemas = [], profile) {
|
|
857
|
+
const drawnHere = (comp) => !profile || !comp.renderers || comp.renderers.includes(profile.renderer);
|
|
725
858
|
const leafSchemas = /* @__PURE__ */ new Map();
|
|
726
859
|
for (const comp of STANDARD_COMPONENTS_REGISTRY) {
|
|
860
|
+
if (!drawnHere(comp)) continue;
|
|
727
861
|
if (!comp.hasChildren) {
|
|
728
862
|
leafSchemas.set(
|
|
729
863
|
comp.name,
|
|
@@ -731,7 +865,9 @@ function createAllComponentSchemasNarrowed(selfRef, pluginSchemas = [], profile)
|
|
|
731
865
|
);
|
|
732
866
|
}
|
|
733
867
|
}
|
|
734
|
-
const containers = STANDARD_COMPONENTS_REGISTRY.filter(
|
|
868
|
+
const containers = STANDARD_COMPONENTS_REGISTRY.filter(
|
|
869
|
+
(c) => c.hasChildren && drawnHere(c)
|
|
870
|
+
);
|
|
735
871
|
const resolved = /* @__PURE__ */ new Map();
|
|
736
872
|
const pending = [...containers];
|
|
737
873
|
while (pending.length > 0) {
|
|
@@ -752,7 +888,7 @@ function createAllComponentSchemasNarrowed(selfRef, pluginSchemas = [], profile)
|
|
|
752
888
|
if (!containerDeps.every((d) => resolved.has(d))) continue;
|
|
753
889
|
const childSchemas = comp.allowedChildren.map((name) => resolved.get(name) ?? leafSchemas.get(name)).filter((s) => s !== void 0);
|
|
754
890
|
const allChildSchemas = [...childSchemas, ...pluginSchemas];
|
|
755
|
-
const childrenType = allChildSchemas.length === 1 ? allChildSchemas[0] :
|
|
891
|
+
const childrenType = allChildSchemas.length === 1 ? allChildSchemas[0] : Type6.Union(allChildSchemas);
|
|
756
892
|
resolved.set(
|
|
757
893
|
comp.name,
|
|
758
894
|
createComponentSchemaObject(comp, childrenType, selfRef, profile)
|
|
@@ -779,6 +915,7 @@ export {
|
|
|
779
915
|
TocDepthRangeSchema,
|
|
780
916
|
TocPropsSchema,
|
|
781
917
|
HighchartsPropsSchema,
|
|
918
|
+
ChartPropsSchema,
|
|
782
919
|
STANDARD_COMPONENTS_REGISTRY,
|
|
783
920
|
getStandardComponent,
|
|
784
921
|
getAllStandardComponentNames,
|
|
@@ -790,4 +927,4 @@ export {
|
|
|
790
927
|
createAllComponentSchemas,
|
|
791
928
|
createAllComponentSchemasNarrowed
|
|
792
929
|
};
|
|
793
|
-
//# sourceMappingURL=chunk-
|
|
930
|
+
//# sourceMappingURL=chunk-MMD4A5LR.js.map
|