@json-to-office/core-docx 0.38.1 → 1.1.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/components/highcharts.d.ts +16 -6
- package/dist/components/highcharts.d.ts.map +1 -1
- package/dist/components/index.d.ts +8 -14
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/visual.d.ts +66 -24
- package/dist/components/visual.d.ts.map +1 -1
- package/dist/core/collectTocHeadings.d.ts +15 -1
- package/dist/core/collectTocHeadings.d.ts.map +1 -1
- package/dist/core/componentTransform.d.ts +30 -0
- package/dist/core/componentTransform.d.ts.map +1 -0
- package/dist/core/desugarExternals.d.ts +35 -0
- package/dist/core/desugarExternals.d.ts.map +1 -0
- package/dist/core/flattenVisuals.d.ts.map +1 -1
- package/dist/core/generateFromIr.d.ts +78 -0
- package/dist/core/generateFromIr.d.ts.map +1 -0
- package/dist/core/generationContext.d.ts +2 -2
- package/dist/core/generationContext.d.ts.map +1 -1
- package/dist/core/generator.d.ts +48 -39
- package/dist/core/generator.d.ts.map +1 -1
- package/dist/core/imageResources.d.ts +35 -0
- package/dist/core/imageResources.d.ts.map +1 -0
- package/dist/core/index.d.ts +4 -5
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/layout.d.ts +15 -3
- package/dist/core/layout.d.ts.map +1 -1
- package/dist/core/markdownList.d.ts +21 -0
- package/dist/core/markdownList.d.ts.map +1 -0
- package/dist/core/prerasterizeVisuals.d.ts +12 -7
- package/dist/core/prerasterizeVisuals.d.ts.map +1 -1
- package/dist/core/sectionBookmarks.d.ts +15 -40
- package/dist/core/sectionBookmarks.d.ts.map +1 -1
- package/dist/core/tableModel.d.ts +188 -0
- package/dist/core/tableModel.d.ts.map +1 -0
- package/dist/core/tocField.d.ts +70 -0
- package/dist/core/tocField.d.ts.map +1 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8967 -7329
- package/dist/index.js.map +1 -1
- package/dist/ir/compiler.d.ts +49 -0
- package/dist/ir/compiler.d.ts.map +1 -0
- package/dist/ir/debug.d.ts +15 -0
- package/dist/ir/debug.d.ts.map +1 -0
- package/dist/ir/features.d.ts +19 -0
- package/dist/ir/features.d.ts.map +1 -0
- package/dist/ir/index.d.ts +16 -0
- package/dist/ir/index.d.ts.map +1 -0
- package/dist/ir/inline.d.ts +126 -0
- package/dist/ir/inline.d.ts.map +1 -0
- package/dist/ir/nativeVisual.d.ts +79 -0
- package/dist/ir/nativeVisual.d.ts.map +1 -0
- package/dist/ir/types.d.ts +883 -0
- package/dist/ir/types.d.ts.map +1 -0
- package/dist/ir/units.d.ts +69 -0
- package/dist/ir/units.d.ts.map +1 -0
- package/dist/ir/validation.d.ts +19 -0
- package/dist/ir/validation.d.ts.map +1 -0
- package/dist/plugin/createDocumentGenerator.d.ts +10 -3
- package/dist/plugin/createDocumentGenerator.d.ts.map +1 -1
- package/dist/plugin/example/index.d.ts.map +1 -1
- package/dist/plugin/example/index.js +8943 -7167
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/plugin/index.d.ts +1 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/schema.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +13 -26
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/renderers/docxjs/emit.d.ts +41 -0
- package/dist/renderers/docxjs/emit.d.ts.map +1 -0
- package/dist/renderers/docxjs/index.d.ts +22 -0
- package/dist/renderers/docxjs/index.d.ts.map +1 -0
- package/dist/renderers/docxjs/styles.d.ts +12 -0
- package/dist/renderers/docxjs/styles.d.ts.map +1 -0
- package/dist/renderers/office-open/emit.d.ts +95 -0
- package/dist/renderers/office-open/emit.d.ts.map +1 -0
- package/dist/renderers/office-open/index.d.ts +25 -0
- package/dist/renderers/office-open/index.d.ts.map +1 -0
- package/dist/renderers/office-open/styles.d.ts +13 -0
- package/dist/renderers/office-open/styles.d.ts.map +1 -0
- package/dist/renderers/registry.d.ts +15 -0
- package/dist/renderers/registry.d.ts.map +1 -0
- package/dist/renderers/types.d.ts +35 -0
- package/dist/renderers/types.d.ts.map +1 -0
- package/dist/styles/themeToStyles.d.ts +12 -0
- package/dist/styles/themeToStyles.d.ts.map +1 -0
- package/dist/styles/utils/borderUtils.d.ts +13 -6
- package/dist/styles/utils/borderUtils.d.ts.map +1 -1
- package/dist/styles/utils/layoutUtils.d.ts +10 -14
- package/dist/styles/utils/layoutUtils.d.ts.map +1 -1
- package/dist/styles/utils/styleHelpers.d.ts +6 -2
- package/dist/styles/utils/styleHelpers.d.ts.map +1 -1
- package/dist/themes/overrides.d.ts +0 -2
- package/dist/themes/overrides.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +18 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/bookmarkRegistry.d.ts +13 -77
- package/dist/utils/bookmarkRegistry.d.ts.map +1 -1
- package/dist/utils/commentRegistry.d.ts +5 -43
- package/dist/utils/commentRegistry.d.ts.map +1 -1
- package/dist/utils/exampleRunner.d.ts.map +1 -1
- package/dist/utils/imageUtils.d.ts +23 -19
- package/dist/utils/imageUtils.d.ts.map +1 -1
- package/dist/utils/numberingConfig.d.ts +7 -87
- package/dist/utils/numberingConfig.d.ts.map +1 -1
- package/dist/utils/packageDocument.d.ts +0 -3
- package/dist/utils/packageDocument.d.ts.map +1 -1
- package/dist/utils/revisionUtils.d.ts +6 -67
- package/dist/utils/revisionUtils.d.ts.map +1 -1
- package/dist/utils/warningsDocument.d.ts.map +1 -1
- package/package.json +12 -4
- package/dist/cache/index.d.ts +0 -7
- package/dist/cache/index.d.ts.map +0 -1
- package/dist/cache/key-generator.d.ts +0 -34
- package/dist/cache/key-generator.d.ts.map +0 -1
- package/dist/components/columns.d.ts +0 -12
- package/dist/components/columns.d.ts.map +0 -1
- package/dist/components/heading.d.ts +0 -12
- package/dist/components/heading.d.ts.map +0 -1
- package/dist/components/image.d.ts +0 -12
- package/dist/components/image.d.ts.map +0 -1
- package/dist/components/list.d.ts +0 -12
- package/dist/components/list.d.ts.map +0 -1
- package/dist/components/paragraph.d.ts +0 -12
- package/dist/components/paragraph.d.ts.map +0 -1
- package/dist/components/section.d.ts +0 -12
- package/dist/components/section.d.ts.map +0 -1
- package/dist/components/statistic.d.ts +0 -12
- package/dist/components/statistic.d.ts.map +0 -1
- package/dist/components/table.d.ts +0 -13
- package/dist/components/table.d.ts.map +0 -1
- package/dist/components/text-box.d.ts +0 -9
- package/dist/components/text-box.d.ts.map +0 -1
- package/dist/components/toc/index.d.ts +0 -30
- package/dist/components/toc/index.d.ts.map +0 -1
- package/dist/core/cached-render.d.ts +0 -92
- package/dist/core/cached-render.d.ts.map +0 -1
- package/dist/core/content.d.ts +0 -319
- package/dist/core/content.d.ts.map +0 -1
- package/dist/core/render.d.ts +0 -48
- package/dist/core/render.d.ts.map +0 -1
- package/dist/styles/themeToDocxAdapter.d.ts +0 -22
- package/dist/styles/themeToDocxAdapter.d.ts.map +0 -1
- package/dist/styles/utils/cellUtils.d.ts +0 -55
- package/dist/styles/utils/cellUtils.d.ts.map +0 -1
- package/dist/utils/alignmentUtils.d.ts +0 -10
- package/dist/utils/alignmentUtils.d.ts.map +0 -1
- package/dist/utils/commentAnchors.d.ts +0 -39
- package/dist/utils/commentAnchors.d.ts.map +0 -1
- package/dist/utils/componentAnnotations.d.ts +0 -23
- package/dist/utils/componentAnnotations.d.ts.map +0 -1
- package/dist/utils/docxImagePositioning.d.ts +0 -19
- package/dist/utils/docxImagePositioning.d.ts.map +0 -1
- package/dist/utils/noteRegistry.d.ts +0 -43
- package/dist/utils/noteRegistry.d.ts.map +0 -1
- package/dist/utils/noteResolver.d.ts +0 -31
- package/dist/utils/noteResolver.d.ts.map +0 -1
- package/dist/utils/numberedItemsRegistry.d.ts +0 -38
- package/dist/utils/numberedItemsRegistry.d.ts.map +0 -1
- package/dist/utils/placeholderImage.d.ts +0 -31
- package/dist/utils/placeholderImage.d.ts.map +0 -1
- package/dist/utils/placeholderProcessor.d.ts +0 -58
- package/dist/utils/placeholderProcessor.d.ts.map +0 -1
- package/dist/utils/textParser.d.ts +0 -117
- package/dist/utils/textParser.d.ts.map +0 -1
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* The `highcharts` component: a chart drawn by an export server.
|
|
3
|
+
*
|
|
4
|
+
* Nothing here renders a document. A chart has no OOXML form of its own — it
|
|
5
|
+
* becomes a PNG and then an `image` — so what lives here is the request the
|
|
6
|
+
* export server needs, the theme palette that goes into it, and the image props
|
|
7
|
+
* the result desugars to.
|
|
4
8
|
*/
|
|
5
|
-
import { Paragraph, Table } from 'docx';
|
|
6
|
-
import { ComponentDefinition, RenderContext } from '../types';
|
|
7
9
|
import { ThemeConfig } from '../styles';
|
|
10
|
+
import type { HighchartsProps } from '@json-to-office/shared-docx';
|
|
11
|
+
import type { HighchartsServiceConfig } from '@json-to-office/shared';
|
|
8
12
|
export type { HighchartsProps } from '@json-to-office/shared-docx';
|
|
9
13
|
/**
|
|
10
14
|
* Chart generation result
|
|
@@ -15,7 +19,13 @@ export interface ChartGenerationResult {
|
|
|
15
19
|
height: number;
|
|
16
20
|
}
|
|
17
21
|
/**
|
|
18
|
-
*
|
|
22
|
+
* Map a chart's props to the `image` props it desugars to.
|
|
23
|
+
*
|
|
24
|
+
* Shared by the render-time component and the DocxIR desugaring pass so the two
|
|
25
|
+
* cannot drift on the one decision that is not obvious: an explicit `width` or
|
|
26
|
+
* `height` on the component replaces the chart's own canvas size outright,
|
|
27
|
+
* rather than merging with it — stating one and inheriting the other would
|
|
28
|
+
* distort the chart.
|
|
19
29
|
*/
|
|
20
|
-
export declare function
|
|
30
|
+
export declare function renderChartToImageProps(props: HighchartsProps, theme: ThemeConfig, servicesConfig?: HighchartsServiceConfig): Promise<Record<string, unknown>>;
|
|
21
31
|
//# sourceMappingURL=highcharts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highcharts.d.ts","sourceRoot":"","sources":["../../src/components/highcharts.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"highcharts.d.ts","sourceRoot":"","sources":["../../src/components/highcharts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAMxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAItE,YAAY,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AA6GD;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,WAAW,EAClB,cAAc,CAAC,EAAE,uBAAuB,GACvC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAalC"}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Components with behaviour of their own.
|
|
3
|
+
*
|
|
4
|
+
* Not a renderer registry: the DocxIR compiler knows every standard component
|
|
5
|
+
* by name. What is left here is the two components that need an external
|
|
6
|
+
* service before they can become anything — a `visual` and a `highcharts`, both
|
|
7
|
+
* of which desugar to an image — and the bundled custom component.
|
|
4
8
|
*/
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export { renderListComponent } from './list';
|
|
8
|
-
export { renderImageComponent } from './image';
|
|
9
|
-
export { renderTextBoxComponent } from './text-box';
|
|
10
|
-
export { renderTableComponent } from './table';
|
|
11
|
-
export { renderSectionComponent } from './section';
|
|
12
|
-
export { renderColumnsComponent } from './columns';
|
|
13
|
-
export { renderStatisticComponent } from './statistic';
|
|
14
|
-
export { renderTocComponent } from './toc';
|
|
15
|
-
export { renderHighchartsComponent } from './highcharts';
|
|
16
|
-
export { renderVisualComponent } from './visual';
|
|
9
|
+
export { buildVisualPresentation, defaultVisualWidthPx, effectiveVisualServerUrl, rasterizeVisualSlide, visualRasterKey, visualToImageOptions, visualToImageProps, type ImageOptions, } from './visual';
|
|
10
|
+
export { renderChartToImageProps, type ChartGenerationResult, type HighchartsProps, } from './highcharts';
|
|
17
11
|
export { textSpaceAfterComponent } from './text-space-after';
|
|
18
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,KAAK,YAAY,GAClB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,42 +1,88 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The `visual` component: a free-canvas graphic authored as a single pptx
|
|
3
|
+
* slide.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Nothing here renders a document. A visual has no OOXML form of its own — an
|
|
6
|
+
* injected rasterization service (`services.pptx`) draws the slide into a PNG
|
|
7
|
+
* and it becomes a plain `image`, exactly as a `highcharts` becomes one. What
|
|
8
|
+
* lives here is the presentation that gets sent, the identity that keys the
|
|
9
|
+
* batch, and the image props the result desugars to.
|
|
9
10
|
*/
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { ThemeConfig } from '../styles';
|
|
13
|
-
import { type ImageOptions } from '../core/content';
|
|
14
|
-
import type { VisualProps } from '@json-to-office/shared-docx';
|
|
15
|
-
import { type PptxServiceConfig, type PptxRasterizeResult, type RasterizeFontFace } from '@json-to-office/shared';
|
|
11
|
+
import type { VisualRasterProps } from '@json-to-office/shared-docx';
|
|
12
|
+
import type { PptxServiceConfig, PptxRasterizeResult, RasterizeFontFace } from '@json-to-office/shared';
|
|
16
13
|
export declare const DEFAULT_RASTERIZE_SERVER_URL = "http://localhost:7802";
|
|
17
14
|
/**
|
|
18
15
|
* Build a single-slide pptx presentation component definition from visual props.
|
|
19
16
|
* The shape mirrors a normal `.pptx.json` document so the pptx engine renders
|
|
20
17
|
* it unchanged. Exported for reuse by the `flattenVisuals` transform.
|
|
21
18
|
*/
|
|
22
|
-
export declare function buildVisualPresentation(props:
|
|
19
|
+
export declare function buildVisualPresentation(props: VisualRasterProps): Record<string, unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* Where an image sits on the page, and how big it is.
|
|
22
|
+
*
|
|
23
|
+
* The authoring surface of the `image` component a visual desugars into, so
|
|
24
|
+
* this is the shape a visual's placement props have to land in.
|
|
25
|
+
*/
|
|
26
|
+
export interface ImageOptions {
|
|
27
|
+
caption?: string;
|
|
28
|
+
width?: number | string;
|
|
29
|
+
height?: number | string;
|
|
30
|
+
widthRelativeTo?: 'content' | 'page';
|
|
31
|
+
heightRelativeTo?: 'content' | 'page';
|
|
32
|
+
alignment?: 'left' | 'center' | 'right';
|
|
33
|
+
spacing?: {
|
|
34
|
+
before?: number;
|
|
35
|
+
after?: number;
|
|
36
|
+
};
|
|
37
|
+
floating?: {
|
|
38
|
+
horizontalPosition?: {
|
|
39
|
+
relative?: 'character' | 'column' | 'margin' | 'page' | 'text';
|
|
40
|
+
align?: 'left' | 'center' | 'right' | 'inside' | 'outside';
|
|
41
|
+
offset?: number | string;
|
|
42
|
+
};
|
|
43
|
+
verticalPosition?: {
|
|
44
|
+
relative?: 'margin' | 'page' | 'paragraph' | 'line' | 'text';
|
|
45
|
+
align?: 'top' | 'center' | 'bottom' | 'inside' | 'outside';
|
|
46
|
+
offset?: number | string;
|
|
47
|
+
};
|
|
48
|
+
wrap?: {
|
|
49
|
+
type: 'none' | 'square' | 'topAndBottom' | 'around' | 'tight' | 'through';
|
|
50
|
+
side?: 'bothSides' | 'left' | 'right' | 'largest';
|
|
51
|
+
margins?: {
|
|
52
|
+
top?: number | string;
|
|
53
|
+
bottom?: number | string;
|
|
54
|
+
left?: number | string;
|
|
55
|
+
right?: number | string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
allowOverlap?: boolean;
|
|
59
|
+
behindDocument?: boolean;
|
|
60
|
+
lockAnchor?: boolean;
|
|
61
|
+
layoutInCell?: boolean;
|
|
62
|
+
zIndex?: number;
|
|
63
|
+
rotation?: number;
|
|
64
|
+
visibility?: 'hidden' | 'inherit';
|
|
65
|
+
};
|
|
66
|
+
keepNext?: boolean;
|
|
67
|
+
keepLines?: boolean;
|
|
68
|
+
}
|
|
23
69
|
/**
|
|
24
70
|
* Default rendered width (px) for a visual: its physical canvas inches, so a
|
|
25
71
|
* 6×4 canvas prints 6×4 unless `width` overrides.
|
|
26
72
|
*/
|
|
27
|
-
export declare function defaultVisualWidthPx(props:
|
|
73
|
+
export declare function defaultVisualWidthPx(props: VisualRasterProps): number;
|
|
28
74
|
/**
|
|
29
75
|
* Shared image-placement options derived from a visual's props. Used by BOTH
|
|
30
|
-
* the
|
|
31
|
-
*
|
|
32
|
-
* spacing, floating
|
|
76
|
+
* desugaring paths — the generation pre-pass and the offline flatten transform
|
|
77
|
+
* — so the two cannot drift: width default, alignment default, caption,
|
|
78
|
+
* spacing, floating and the keep flags all live here once.
|
|
33
79
|
*/
|
|
34
|
-
export declare function visualToImageOptions(props:
|
|
80
|
+
export declare function visualToImageOptions(props: VisualRasterProps): ImageOptions;
|
|
35
81
|
/**
|
|
36
82
|
* Map visual props to the `image` props they desugar to (used by the
|
|
37
83
|
* `flattenVisuals` transform to produce a portable, service-free document).
|
|
38
84
|
*/
|
|
39
|
-
export declare function visualToImageProps(props:
|
|
85
|
+
export declare function visualToImageProps(props: VisualRasterProps, base64DataUri: string): Record<string, unknown>;
|
|
40
86
|
/**
|
|
41
87
|
* Identity of one visual rasterization: content + resolution + (for HTTP
|
|
42
88
|
* services) the target server. Keys the per-document pre-rasterization map
|
|
@@ -61,7 +107,7 @@ export declare function visualRasterKey(presentation: unknown, dpi: number, serv
|
|
|
61
107
|
* actually do or the same visual could rasterize against two different
|
|
62
108
|
* services depending on cache luck.
|
|
63
109
|
*/
|
|
64
|
-
export declare function effectiveVisualServerUrl(props:
|
|
110
|
+
export declare function effectiveVisualServerUrl(props: VisualRasterProps, serviceConfig: PptxServiceConfig | undefined): string | undefined;
|
|
65
111
|
/**
|
|
66
112
|
* Rasterize a single-slide presentation to a PNG via the configured service.
|
|
67
113
|
* An in-process `render` callback takes precedence over an HTTP `serverUrl`.
|
|
@@ -75,8 +121,4 @@ export declare function rasterizeVisualSlide(presentation: Record<string, unknow
|
|
|
75
121
|
* what it was before fonts existed.
|
|
76
122
|
*/
|
|
77
123
|
fonts?: readonly RasterizeFontFace[]): Promise<PptxRasterizeResult>;
|
|
78
|
-
/**
|
|
79
|
-
* Render visual component
|
|
80
|
-
*/
|
|
81
|
-
export declare function renderVisualComponent(component: ComponentDefinition, theme: ThemeConfig, themeName?: string, context?: RenderContext): Promise<(Paragraph | Table)[]>;
|
|
82
124
|
//# sourceMappingURL=visual.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visual.d.ts","sourceRoot":"","sources":["../../src/components/visual.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"visual.d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;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,OAAO,EACrB,GAAG,EAAE,MAAM,EACX,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAIR;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,iBAAiB,EACxB,aAAa,EAAE,iBAAiB,GAAG,SAAS,GAC3C,MAAM,GAAG,SAAS,CAGpB;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,aAAa,EAAE,iBAAiB,GAAG,SAAS,EAC5C,OAAO,EAAE,MAAM,GAAG,SAAS;AAC3B;;;;GAIG;AACH,KAAK,CAAC,EAAE,SAAS,iBAAiB,EAAE,GACnC,OAAO,CAAC,mBAAmB,CAAC,CAuD9B"}
|
|
@@ -40,7 +40,21 @@
|
|
|
40
40
|
* come later in the document) and each list's item counters.
|
|
41
41
|
*/
|
|
42
42
|
import type { SectionLayout } from './layout';
|
|
43
|
-
|
|
43
|
+
/**
|
|
44
|
+
* A cross-reference target: a numbered heading or list item.
|
|
45
|
+
*
|
|
46
|
+
* Resolved by the outline pre-pass and read back while text is compiled, which
|
|
47
|
+
* is why a `[@id]` can point at something further down the document.
|
|
48
|
+
*/
|
|
49
|
+
export interface NumberedItemInfo {
|
|
50
|
+
kind: 'heading' | 'list-item';
|
|
51
|
+
/** Rendered text of the target, for a `:none` (text) reference. */
|
|
52
|
+
text: string;
|
|
53
|
+
/** Full multilevel number ("2.1.3"), absent when the target is unnumbered. */
|
|
54
|
+
full?: string;
|
|
55
|
+
/** The target's own level counter ("3"), absent when unnumbered. */
|
|
56
|
+
own?: string;
|
|
57
|
+
}
|
|
44
58
|
export interface TocHeadingEntry {
|
|
45
59
|
/** Rendered text, with markdown decorators stripped as `createHeading` does. */
|
|
46
60
|
title: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectTocHeadings.d.ts","sourceRoot":"","sources":["../../src/core/collectTocHeadings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAQ9C,
|
|
1
|
+
{"version":3,"file":"collectTocHeadings.d.ts","sourceRoot":"","sources":["../../src/core/collectTocHeadings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAQ9C;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,SAAS,GAAG,WAAW,CAAC;IAC9B,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAKD,MAAM,WAAW,eAAe;IAC9B,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,0EAA0E;IAC1E,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC9C;AAOD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMxD;AA8CD;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,SAAS,aAAa,EAAE,GACjC,eAAe,CAkLjB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,SAAS,aAAa,EAAE,GACjC,eAAe,EAAE,CAEnB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Walk a document tree and replace components.
|
|
3
|
+
*
|
|
4
|
+
* The docx model holds child components in more places than `children`: a
|
|
5
|
+
* section's `header` and `footer`, and a table's `columns[].header.content` and
|
|
6
|
+
* `columns[].cells[].content`. Any transform that misses one of those quietly
|
|
7
|
+
* leaves part of the document behind, which is exactly the kind of bug that
|
|
8
|
+
* only shows up in the one template that puts a chart in a table cell.
|
|
9
|
+
*
|
|
10
|
+
* So the walk lives here, once, and transforms supply only the decision about
|
|
11
|
+
* what to replace.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Decide what one component becomes.
|
|
15
|
+
*
|
|
16
|
+
* Return a replacement node to substitute it — the walk does not descend into
|
|
17
|
+
* a replacement — or `undefined` to leave the node alone and keep walking.
|
|
18
|
+
*/
|
|
19
|
+
export type ComponentReplacer = (node: Record<string, unknown>) => Promise<Record<string, unknown> | undefined>;
|
|
20
|
+
/** Return a deep copy of `doc` with `replace` applied to every component. */
|
|
21
|
+
export declare function transformComponents<T>(doc: T, replace: ComponentReplacer): Promise<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Carry a node's identity and visibility onto its replacement.
|
|
24
|
+
*
|
|
25
|
+
* A desugared node is still the component the author wrote: an `id` other
|
|
26
|
+
* things link to, and an `enabled` flag something downstream may act on, both
|
|
27
|
+
* have to survive the substitution.
|
|
28
|
+
*/
|
|
29
|
+
export declare function withNodeIdentity(original: Record<string, unknown>, replacement: Record<string, unknown>): Record<string, unknown>;
|
|
30
|
+
//# sourceMappingURL=componentTransform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentTransform.d.ts","sourceRoot":"","sources":["../../src/core/componentTransform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC1B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC;AAElD,6EAA6E;AAC7E,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,GAAG,EAAE,CAAC,EACN,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,CAAC,CAAC,CAEZ;AAkFD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAKzB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn components that need an external service into plain `image` components,
|
|
3
|
+
* before anything else looks at the document.
|
|
4
|
+
*
|
|
5
|
+
* A `visual` is a nested presentation rendered by LibreOffice; a `highcharts`
|
|
6
|
+
* is a chart rendered by an export server. Both end up as a PNG in the package,
|
|
7
|
+
* and neither has an OOXML form of its own — so rather than teaching the
|
|
8
|
+
* compiler about services, they are desugared here and the compiler only ever
|
|
9
|
+
* sees an image.
|
|
10
|
+
*
|
|
11
|
+
* That keeps compilation a pure function of the document. Everything that can
|
|
12
|
+
* fail, block on a network call or depend on a machine's LibreOffice happens in
|
|
13
|
+
* this pass; what comes out is a document that builds anywhere.
|
|
14
|
+
*/
|
|
15
|
+
import { type RasterizeFontFace, type ServicesConfig } from '@json-to-office/shared';
|
|
16
|
+
import type { ThemeConfig } from '../styles';
|
|
17
|
+
export interface DesugarExternalsOptions {
|
|
18
|
+
theme: ThemeConfig;
|
|
19
|
+
services?: ServicesConfig;
|
|
20
|
+
/** Directory relative asset paths inside a visual resolve against. */
|
|
21
|
+
baseDir?: string;
|
|
22
|
+
/** Font faces staged for each visual's LibreOffice render. */
|
|
23
|
+
visualFonts?: readonly RasterizeFontFace[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Replace every `visual` and `highcharts` in `document` with its image.
|
|
27
|
+
*
|
|
28
|
+
* Visuals are rasterized in one batch first: the document walk is sequential,
|
|
29
|
+
* and without the batch each visual would cost its own service round trip and
|
|
30
|
+
* its own LibreOffice launch — about twenty-five of each for the bundled
|
|
31
|
+
* templates. The batch is only an accelerator, though: anything it misses, or a
|
|
32
|
+
* batch that fails outright, falls back to rasterizing that visual on its own.
|
|
33
|
+
*/
|
|
34
|
+
export declare function desugarExternals<T>(document: T, options: DesugarExternalsOptions): Promise<T>;
|
|
35
|
+
//# sourceMappingURL=desugarExternals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"desugarExternals.d.ts","sourceRoot":"","sources":["../../src/core/desugarExternals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACpB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAY7C,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAC5C;AAED;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,CAAC,CAAC,CA4CZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flattenVisuals.d.ts","sourceRoot":"","sources":["../../src/core/flattenVisuals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"flattenVisuals.d.ts","sourceRoot":"","sources":["../../src/core/flattenVisuals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAiBhC,MAAM,WAAW,qBAAqB;IACpC,yEAAyE;IACzE,SAAS,EAAE,cAAc,CAAC;IAC1B;;;;OAIG;IACH,cAAc,CAAC,EAAE,mBAAmB,CAAC;IACrC,8EAA8E;IAC9E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACtC;AAUD;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,CAAC,GAAG,OAAO,EAC9C,GAAG,EAAE,CAAC,EACN,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,CAAC,CAAC,CAyDZ"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The IR-based DOCX generation path.
|
|
3
|
+
*
|
|
4
|
+
* Normalisation, theme resolution, font resolution, desugaring of the
|
|
5
|
+
* service-backed components, structure and layout — and then, instead of
|
|
6
|
+
* building renderer objects directly, it compiles to DocxIR, checks the
|
|
7
|
+
* selected backend can express what the document needs, and hands the IR to an
|
|
8
|
+
* adapter.
|
|
9
|
+
*
|
|
10
|
+
* The shape is deliberate: everything asynchronous or fallible happens before
|
|
11
|
+
* compilation, so compiling is a pure function of the document plus the
|
|
12
|
+
* resources already in hand. Two compilations of the same document give the
|
|
13
|
+
* same IR, which is what makes the IR comparable, cacheable and snapshottable.
|
|
14
|
+
*/
|
|
15
|
+
/// <reference types="node" />
|
|
16
|
+
import type { GenerationWarning, ServicesConfig } from '@json-to-office/shared';
|
|
17
|
+
import type { FontRuntimeOpts } from '@json-to-office/shared';
|
|
18
|
+
import { compileDocument, type UnsupportedComponent } from '../ir/compiler';
|
|
19
|
+
import type { DocxIR } from '../ir/types';
|
|
20
|
+
import type { DocxRendererId } from '../renderers/types';
|
|
21
|
+
import type { ThemeConfig } from '../styles';
|
|
22
|
+
import type { ReportComponentDefinition } from '../types';
|
|
23
|
+
import { type GenerationThemeContext } from './generationContext';
|
|
24
|
+
export interface IrDocxGenerationOptions {
|
|
25
|
+
customThemes?: Record<string, ThemeConfig>;
|
|
26
|
+
services?: ServicesConfig;
|
|
27
|
+
fonts?: FontRuntimeOpts;
|
|
28
|
+
warnings?: GenerationWarning[];
|
|
29
|
+
baseDir?: string;
|
|
30
|
+
deterministic?: boolean;
|
|
31
|
+
generatedAt?: string | Date;
|
|
32
|
+
/** Backend to render with. Defaults to `docxjs`. */
|
|
33
|
+
renderer?: DocxRendererId;
|
|
34
|
+
/**
|
|
35
|
+
* A prologue already run by the caller.
|
|
36
|
+
*
|
|
37
|
+
* The plugin path has to resolve the theme before it expands custom
|
|
38
|
+
* components — a component's `render` is handed the resolved theme — and
|
|
39
|
+
* normalises the tree that expansion produced. Passing that result in means
|
|
40
|
+
* the prologue runs once rather than twice, which matters because the
|
|
41
|
+
* export-mode pre-pass inside it rewrites the document.
|
|
42
|
+
*/
|
|
43
|
+
context?: GenerationThemeContext;
|
|
44
|
+
}
|
|
45
|
+
export interface IrDocxGenerationResult {
|
|
46
|
+
buffer: Buffer;
|
|
47
|
+
warnings: GenerationWarning[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Thrown when the compiler meets something it does not lower yet.
|
|
51
|
+
*
|
|
52
|
+
* Silently dropping it would be worse than failing: the document would look
|
|
53
|
+
* complete and not be. This disappears as the compiler covers the surface.
|
|
54
|
+
*/
|
|
55
|
+
export declare class UncompiledComponentError extends Error {
|
|
56
|
+
readonly code = "UNCOMPILED_COMPONENT";
|
|
57
|
+
readonly components: readonly UnsupportedComponent[];
|
|
58
|
+
constructor(components: readonly UnsupportedComponent[]);
|
|
59
|
+
}
|
|
60
|
+
export interface CompiledDocx {
|
|
61
|
+
ir: DocxIR;
|
|
62
|
+
theme: ThemeConfig;
|
|
63
|
+
warnings: GenerationWarning[];
|
|
64
|
+
required: ReturnType<typeof compileDocument>['required'];
|
|
65
|
+
unsupported: UnsupportedComponent[];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Compile a report definition to DocxIR without rendering it.
|
|
69
|
+
*
|
|
70
|
+
* Scoped rather than plain: a relative image path resolves against the
|
|
71
|
+
* document's own directory, and leaf utilities report warnings into the
|
|
72
|
+
* caller's collector, both through async-local state that has to be entered
|
|
73
|
+
* before the walk begins.
|
|
74
|
+
*/
|
|
75
|
+
export declare function compileDocumentToIr(document: ReportComponentDefinition, options?: IrDocxGenerationOptions, collector?: GenerationWarning[]): Promise<CompiledDocx>;
|
|
76
|
+
/** Generate a `.docx` buffer through DocxIR and the selected renderer. */
|
|
77
|
+
export declare function generateBufferViaIr(document: ReportComponentDefinition, options?: IrDocxGenerationOptions): Promise<IrDocxGenerationResult>;
|
|
78
|
+
//# sourceMappingURL=generateFromIr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateFromIr.d.ts","sourceRoot":"","sources":["../../src/core/generateFromIr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAO9D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AAU,CAAC,OAAO,eAAe,CAAC,CAAC,UAAU,CAAC,CAAC;IACzD,WAAW,EAAE,oBAAoB,EAAE,CAAC;CACrC;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,yBAAyB,EACnC,OAAO,GAAE,uBAA4B,EACrC,SAAS,CAAC,EAAE,iBAAiB,EAAE,GAC9B,OAAO,CAAC,YAAY,CAAC,CAOvB;AA2FD,0EAA0E;AAC1E,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,yBAAyB,EACnC,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,sBAAsB,CAAC,CAcjC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Both entry points — `generateBufferFromJson` (core) and
|
|
5
5
|
* `createDocumentGenerator` (plugin) — must resolve the same theme, apply the
|
|
6
|
-
* same in-document overrides, and
|
|
6
|
+
* same in-document overrides, and apply the same export mode before the
|
|
7
7
|
* structure → layout → render engine runs. Keeping two copies of that meant
|
|
8
8
|
* `props.themeOverrides` reached only one of them (#133); this module is the
|
|
9
9
|
* single definition so the next root-level prop cannot diverge (#132).
|
|
@@ -35,7 +35,7 @@ export interface GenerationThemeContext {
|
|
|
35
35
|
/** The document after the export-mode pre-pass rewrote font references. */
|
|
36
36
|
document: ReportComponentDefinition;
|
|
37
37
|
theme: ThemeConfig;
|
|
38
|
-
/**
|
|
38
|
+
/** Base theme name, retained for built-in fallback lookups. */
|
|
39
39
|
themeName: string;
|
|
40
40
|
}
|
|
41
41
|
export declare function resolveThemeContext(documentIn: ReportComponentDefinition, options?: ThemeContextOptions): GenerationThemeContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generationContext.d.ts","sourceRoot":"","sources":["../../src/core/generationContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,KAAK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AAM,WAAW,sBAAsB;IACrC,2EAA2E;IAC3E,QAAQ,EAAE,yBAAyB,CAAC;IACpC,KAAK,EAAE,WAAW,CAAC;IACnB,+DAA+D;IAC/D,SAAS,EAAE,MAAM,CAAC;CACnB;AAoBD,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,yBAAyB,EACrC,OAAO,GAAE,mBAAwB,GAChC,sBAAsB,CA6DxB"}
|
package/dist/core/generator.d.ts
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Document
|
|
3
|
-
*
|
|
2
|
+
* Document generation entry points.
|
|
3
|
+
*
|
|
4
|
+
* Every path here compiles the authoring tree to DocxIR and hands it to a
|
|
5
|
+
* renderer adapter; nothing in this module knows which backend that is. The
|
|
6
|
+
* default is `docxjs`, which reproduces the output this pipeline has always
|
|
7
|
+
* produced — see `src/__tests__/corpus-ir-parity.test.ts`.
|
|
8
|
+
*
|
|
9
|
+
* The surface is buffer- and file-oriented. No entry point returns or accepts a
|
|
10
|
+
* renderer-native object: the whole point of the IR is that the backend is an
|
|
11
|
+
* implementation detail, and handing a caller a docx.js `Document` would make
|
|
12
|
+
* it part of the contract again.
|
|
4
13
|
*/
|
|
5
14
|
/// <reference types="node" />
|
|
6
|
-
import { Document } from 'docx';
|
|
7
15
|
import { ComponentDefinition, ReportProps, ReportComponentDefinition } from '../types';
|
|
8
16
|
import { ThemeConfig } from '../styles';
|
|
9
17
|
import type { ServicesConfig, FontRuntimeOpts } from '@json-to-office/shared';
|
|
18
|
+
import type { DocxRendererId } from '../renderers/types';
|
|
10
19
|
import { DocumentValidationResult } from '@json-to-office/shared-docx';
|
|
11
20
|
import type { GenerationWarning } from '@json-to-office/shared';
|
|
12
21
|
export interface JsonGenerationOptions {
|
|
@@ -47,78 +56,78 @@ export interface JsonGenerationOptions {
|
|
|
47
56
|
* it falls back to `process.cwd()` (#142).
|
|
48
57
|
*/
|
|
49
58
|
baseDir?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Backend to render with. Defaults to `docxjs`.
|
|
61
|
+
*
|
|
62
|
+
* The default reproduces byte-for-byte what this pipeline has always
|
|
63
|
+
* produced; anything else is opt-in and may not.
|
|
64
|
+
*/
|
|
65
|
+
renderer?: DocxRendererId;
|
|
66
|
+
}
|
|
67
|
+
/** A generated package, with whatever the pipeline had to say about it. */
|
|
68
|
+
export interface DocxGenerationResult {
|
|
69
|
+
buffer: Buffer;
|
|
70
|
+
warnings: GenerationWarning[];
|
|
50
71
|
}
|
|
51
72
|
/**
|
|
52
73
|
* Type guard to check if input is a report component definition
|
|
53
74
|
*/
|
|
54
75
|
export declare function isReportComponentDefinition(definition: unknown): definition is ReportComponentDefinition;
|
|
55
76
|
/**
|
|
56
|
-
* Generate a
|
|
57
|
-
*
|
|
77
|
+
* Generate a `.docx` buffer from a report definition, with its warnings.
|
|
78
|
+
*
|
|
79
|
+
* Validation runs first unless the caller opts out: the same validator the
|
|
80
|
+
* playground uses, so an object or a buffer is held to the same standard as a
|
|
81
|
+
* pasted document and malformed props are surfaced rather than dropped into an
|
|
82
|
+
* incomplete file.
|
|
58
83
|
*/
|
|
59
|
-
export declare function
|
|
84
|
+
export declare function generateBufferWithWarnings(jsonConfig: string | ComponentDefinition | ReportComponentDefinition, options?: JsonGenerationOptions): Promise<DocxGenerationResult>;
|
|
60
85
|
/**
|
|
61
|
-
* Generate
|
|
62
|
-
*
|
|
86
|
+
* Generate a `.docx` buffer from a report definition built out of props and
|
|
87
|
+
* children — the same document as passing `{ name: 'docx', props, children }`.
|
|
63
88
|
*/
|
|
64
|
-
export declare function
|
|
65
|
-
/**
|
|
66
|
-
* Generate a Word document from JSON report definition
|
|
67
|
-
* Handles parsing, validation, and conversion to internal components
|
|
68
|
-
*/
|
|
69
|
-
export declare function generateDocumentFromJson(jsonConfig: string | ComponentDefinition | ReportComponentDefinition, options?: JsonGenerationOptions): Promise<Document>;
|
|
89
|
+
export declare function generateBufferFromConfig(props: ReportProps, components: ComponentDefinition[], options?: JsonGenerationOptions): Promise<Buffer>;
|
|
70
90
|
/**
|
|
71
91
|
* Validate JSON schema without generating document
|
|
72
92
|
*/
|
|
73
93
|
export declare function validateJsonSchema(jsonConfig: string | object): DocumentValidationResult;
|
|
74
94
|
/**
|
|
75
|
-
* Generate
|
|
95
|
+
* Generate a `.docx` buffer from a report definition.
|
|
76
96
|
*/
|
|
77
|
-
export declare function generateBufferFromJson(jsonConfig: string | ReportComponentDefinition, options?: JsonGenerationOptions): Promise<Buffer>;
|
|
97
|
+
export declare function generateBufferFromJson(jsonConfig: string | ComponentDefinition | ReportComponentDefinition, options?: JsonGenerationOptions): Promise<Buffer>;
|
|
78
98
|
/**
|
|
79
|
-
* Generate and save
|
|
99
|
+
* Generate and save a `.docx` file from a report definition.
|
|
80
100
|
*/
|
|
81
|
-
export declare function generateAndSaveFromJson(jsonConfig: string | ReportComponentDefinition, filename: string, options?: JsonGenerationOptions): Promise<void>;
|
|
101
|
+
export declare function generateAndSaveFromJson(jsonConfig: string | ComponentDefinition | ReportComponentDefinition, filename: string, options?: JsonGenerationOptions): Promise<void>;
|
|
82
102
|
/**
|
|
83
|
-
* Generate
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
* Generate document buffer from JSON file
|
|
103
|
+
* Generate a `.docx` buffer from a JSON file.
|
|
104
|
+
*
|
|
105
|
+
* The document's own directory is the natural base for its relative assets, so
|
|
106
|
+
* it becomes the default `baseDir` unless the caller says otherwise.
|
|
88
107
|
*/
|
|
89
108
|
export declare function generateBufferFromFile(filePath: string, options?: JsonGenerationOptions): Promise<Buffer>;
|
|
90
109
|
/**
|
|
91
|
-
* Generate and save
|
|
110
|
+
* Generate and save a `.docx` file from a JSON file.
|
|
92
111
|
*/
|
|
93
112
|
export declare function generateAndSaveFromFile(inputFilePath: string, outputFilePath: string, options?: JsonGenerationOptions): Promise<void>;
|
|
94
|
-
/**
|
|
95
|
-
* Save a document to file
|
|
96
|
-
*/
|
|
97
|
-
export declare function saveDocument(document: Document, filename: string, options?: JsonGenerationOptions): Promise<void>;
|
|
98
|
-
/**
|
|
99
|
-
* Generate and save document in one operation
|
|
100
|
-
*/
|
|
101
|
-
export declare function generateAndSave(document: ReportComponentDefinition, filename: string, options?: JsonGenerationOptions): Promise<void>;
|
|
102
113
|
/**
|
|
103
114
|
* Compose multiple transform functions
|
|
104
115
|
* Utility for creating custom pipelines
|
|
105
116
|
*/
|
|
106
117
|
export declare function pipe<T>(...fns: Array<(_arg: T) => T>): (_arg: T) => T;
|
|
107
118
|
/**
|
|
108
|
-
*
|
|
119
|
+
* The main API surface.
|
|
120
|
+
*
|
|
121
|
+
* Buffer- and file-oriented only: no member returns a renderer-native object.
|
|
109
122
|
*/
|
|
110
123
|
export declare const DocumentGenerator: {
|
|
111
|
-
generate: typeof generateDocument;
|
|
112
|
-
generateFromConfig: typeof generateFromConfig;
|
|
113
|
-
generateFromJson: typeof generateDocumentFromJson;
|
|
114
|
-
generateFromFile: typeof generateDocumentFromFile;
|
|
115
124
|
generateBufferFromJson: typeof generateBufferFromJson;
|
|
125
|
+
generateBufferWithWarnings: typeof generateBufferWithWarnings;
|
|
126
|
+
generateBufferFromConfig: typeof generateBufferFromConfig;
|
|
116
127
|
generateBufferFromFile: typeof generateBufferFromFile;
|
|
117
128
|
generateAndSaveFromJson: typeof generateAndSaveFromJson;
|
|
118
129
|
generateAndSaveFromFile: typeof generateAndSaveFromFile;
|
|
119
130
|
validateJsonSchema: typeof validateJsonSchema;
|
|
120
|
-
save: typeof saveDocument;
|
|
121
|
-
generateAndSave: typeof generateAndSave;
|
|
122
131
|
isReportComponentDefinition: typeof isReportComponentDefinition;
|
|
123
132
|
};
|
|
124
133
|
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/core/generator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../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