@json-to-office/core-docx 0.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.
Files changed (169) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +9 -0
  3. package/dist/cache/index.d.ts +7 -0
  4. package/dist/cache/index.d.ts.map +1 -0
  5. package/dist/cache/key-generator.d.ts +34 -0
  6. package/dist/cache/key-generator.d.ts.map +1 -0
  7. package/dist/components/columns.d.ts +12 -0
  8. package/dist/components/columns.d.ts.map +1 -0
  9. package/dist/components/footer.d.ts +12 -0
  10. package/dist/components/footer.d.ts.map +1 -0
  11. package/dist/components/header.d.ts +12 -0
  12. package/dist/components/header.d.ts.map +1 -0
  13. package/dist/components/heading.d.ts +12 -0
  14. package/dist/components/heading.d.ts.map +1 -0
  15. package/dist/components/highcharts.d.ts +21 -0
  16. package/dist/components/highcharts.d.ts.map +1 -0
  17. package/dist/components/image.d.ts +12 -0
  18. package/dist/components/image.d.ts.map +1 -0
  19. package/dist/components/index.d.ts +19 -0
  20. package/dist/components/index.d.ts.map +1 -0
  21. package/dist/components/list.d.ts +12 -0
  22. package/dist/components/list.d.ts.map +1 -0
  23. package/dist/components/paragraph.d.ts +12 -0
  24. package/dist/components/paragraph.d.ts.map +1 -0
  25. package/dist/components/section.d.ts +12 -0
  26. package/dist/components/section.d.ts.map +1 -0
  27. package/dist/components/statistic.d.ts +12 -0
  28. package/dist/components/statistic.d.ts.map +1 -0
  29. package/dist/components/table.d.ts +13 -0
  30. package/dist/components/table.d.ts.map +1 -0
  31. package/dist/components/text-box.d.ts +9 -0
  32. package/dist/components/text-box.d.ts.map +1 -0
  33. package/dist/components/text-space-after.d.ts +35 -0
  34. package/dist/components/text-space-after.d.ts.map +1 -0
  35. package/dist/components/toc/index.d.ts +30 -0
  36. package/dist/components/toc/index.d.ts.map +1 -0
  37. package/dist/core/cached-render.d.ts +46 -0
  38. package/dist/core/cached-render.d.ts.map +1 -0
  39. package/dist/core/content.d.ts +263 -0
  40. package/dist/core/content.d.ts.map +1 -0
  41. package/dist/core/generator.d.ts +93 -0
  42. package/dist/core/generator.d.ts.map +1 -0
  43. package/dist/core/index.d.ts +14 -0
  44. package/dist/core/index.d.ts.map +1 -0
  45. package/dist/core/layout.d.ts +107 -0
  46. package/dist/core/layout.d.ts.map +1 -0
  47. package/dist/core/render.d.ts +26 -0
  48. package/dist/core/render.d.ts.map +1 -0
  49. package/dist/core/structure.d.ts +67 -0
  50. package/dist/core/structure.d.ts.map +1 -0
  51. package/dist/examples/test-spacing-debug.d.ts +2 -0
  52. package/dist/examples/test-spacing-debug.d.ts.map +1 -0
  53. package/dist/examples/test-spacing.d.ts +6 -0
  54. package/dist/examples/test-spacing.d.ts.map +1 -0
  55. package/dist/index.d.ts +20 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +7726 -0
  58. package/dist/index.js.map +1 -0
  59. package/dist/json/filesystem.d.ts +81 -0
  60. package/dist/json/filesystem.d.ts.map +1 -0
  61. package/dist/json/index.d.ts +6 -0
  62. package/dist/json/index.d.ts.map +1 -0
  63. package/dist/json/normalizer.d.ts +30 -0
  64. package/dist/json/normalizer.d.ts.map +1 -0
  65. package/dist/json/parser.d.ts +9 -0
  66. package/dist/json/parser.d.ts.map +1 -0
  67. package/dist/plugin/createComponent.d.ts +113 -0
  68. package/dist/plugin/createComponent.d.ts.map +1 -0
  69. package/dist/plugin/createDocumentGenerator.d.ts +18 -0
  70. package/dist/plugin/createDocumentGenerator.d.ts.map +1 -0
  71. package/dist/plugin/example/columns-layout.component.d.ts +29 -0
  72. package/dist/plugin/example/columns-layout.component.d.ts.map +1 -0
  73. package/dist/plugin/example/index.d.ts +6 -0
  74. package/dist/plugin/example/index.d.ts.map +1 -0
  75. package/dist/plugin/example/index.js +7449 -0
  76. package/dist/plugin/example/index.js.map +1 -0
  77. package/dist/plugin/example/nested-section.component.d.ts +16 -0
  78. package/dist/plugin/example/nested-section.component.d.ts.map +1 -0
  79. package/dist/plugin/example/plugin-demo.json +103 -0
  80. package/dist/plugin/example/text-space-after.component.d.ts +22 -0
  81. package/dist/plugin/example/text-space-after.component.d.ts.map +1 -0
  82. package/dist/plugin/example/weather.component.d.ts +29 -0
  83. package/dist/plugin/example/weather.component.d.ts.map +1 -0
  84. package/dist/plugin/index.d.ts +35 -0
  85. package/dist/plugin/index.d.ts.map +1 -0
  86. package/dist/plugin/schema.d.ts +30 -0
  87. package/dist/plugin/schema.d.ts.map +1 -0
  88. package/dist/plugin/types.d.ts +144 -0
  89. package/dist/plugin/types.d.ts.map +1 -0
  90. package/dist/plugin/validation.d.ts +45 -0
  91. package/dist/plugin/validation.d.ts.map +1 -0
  92. package/dist/plugin/version-resolver.d.ts +10 -0
  93. package/dist/plugin/version-resolver.d.ts.map +1 -0
  94. package/dist/styles/index.d.ts +13 -0
  95. package/dist/styles/index.d.ts.map +1 -0
  96. package/dist/styles/theme-resolver.d.ts +6 -0
  97. package/dist/styles/theme-resolver.d.ts.map +1 -0
  98. package/dist/styles/theme-validator.d.ts +7 -0
  99. package/dist/styles/theme-validator.d.ts.map +1 -0
  100. package/dist/styles/themeToDocxAdapter.d.ts +22 -0
  101. package/dist/styles/themeToDocxAdapter.d.ts.map +1 -0
  102. package/dist/styles/utils/borderUtils.d.ts +88 -0
  103. package/dist/styles/utils/borderUtils.d.ts.map +1 -0
  104. package/dist/styles/utils/cellUtils.d.ts +55 -0
  105. package/dist/styles/utils/cellUtils.d.ts.map +1 -0
  106. package/dist/styles/utils/colorUtils.d.ts +27 -0
  107. package/dist/styles/utils/colorUtils.d.ts.map +1 -0
  108. package/dist/styles/utils/componentDefaults.d.ts +97 -0
  109. package/dist/styles/utils/componentDefaults.d.ts.map +1 -0
  110. package/dist/styles/utils/layoutUtils.d.ts +87 -0
  111. package/dist/styles/utils/layoutUtils.d.ts.map +1 -0
  112. package/dist/styles/utils/styleHelpers.d.ts +90 -0
  113. package/dist/styles/utils/styleHelpers.d.ts.map +1 -0
  114. package/dist/templates/documents/index.d.ts +34 -0
  115. package/dist/templates/documents/index.d.ts.map +1 -0
  116. package/dist/templates/documents/proposal.docx.json +171 -0
  117. package/dist/templates/documents/quarterly-report.docx.json +117 -0
  118. package/dist/templates/documents/technical-guide.docx.json +178 -0
  119. package/dist/templates/themes/corporate.docx.theme.json +118 -0
  120. package/dist/templates/themes/index.d.ts +5765 -0
  121. package/dist/templates/themes/index.d.ts.map +1 -0
  122. package/dist/templates/themes/minimal.docx.theme.json +194 -0
  123. package/dist/templates/themes/modern.docx.theme.json +115 -0
  124. package/dist/themes/defaults.d.ts +1300 -0
  125. package/dist/themes/defaults.d.ts.map +1 -0
  126. package/dist/themes/json/index.d.ts +44 -0
  127. package/dist/themes/json/index.d.ts.map +1 -0
  128. package/dist/themes/json/loader.d.ts +26 -0
  129. package/dist/themes/json/loader.d.ts.map +1 -0
  130. package/dist/themes/json/parser.d.ts +25 -0
  131. package/dist/themes/json/parser.d.ts.map +1 -0
  132. package/dist/themes/json/validator.d.ts +35 -0
  133. package/dist/themes/json/validator.d.ts.map +1 -0
  134. package/dist/tsconfig.tsbuildinfo +1 -0
  135. package/dist/types/index.d.ts +158 -0
  136. package/dist/types/index.d.ts.map +1 -0
  137. package/dist/types/plugin.d.ts +67 -0
  138. package/dist/types/plugin.d.ts.map +1 -0
  139. package/dist/utils/alignmentUtils.d.ts +10 -0
  140. package/dist/utils/alignmentUtils.d.ts.map +1 -0
  141. package/dist/utils/bookmarkRegistry.d.ts +49 -0
  142. package/dist/utils/bookmarkRegistry.d.ts.map +1 -0
  143. package/dist/utils/docxImagePositioning.d.ts +18 -0
  144. package/dist/utils/docxImagePositioning.d.ts.map +1 -0
  145. package/dist/utils/environment.d.ts +14 -0
  146. package/dist/utils/environment.d.ts.map +1 -0
  147. package/dist/utils/exampleRunner.d.ts +17 -0
  148. package/dist/utils/exampleRunner.d.ts.map +1 -0
  149. package/dist/utils/fixFloatingImageIds.d.ts +18 -0
  150. package/dist/utils/fixFloatingImageIds.d.ts.map +1 -0
  151. package/dist/utils/formatters.d.ts +2 -0
  152. package/dist/utils/formatters.d.ts.map +1 -0
  153. package/dist/utils/imageUtils.d.ts +84 -0
  154. package/dist/utils/imageUtils.d.ts.map +1 -0
  155. package/dist/utils/numberingConfig.d.ts +84 -0
  156. package/dist/utils/numberingConfig.d.ts.map +1 -0
  157. package/dist/utils/placeholderImage.d.ts +31 -0
  158. package/dist/utils/placeholderImage.d.ts.map +1 -0
  159. package/dist/utils/placeholderProcessor.d.ts +58 -0
  160. package/dist/utils/placeholderProcessor.d.ts.map +1 -0
  161. package/dist/utils/textParser.d.ts +35 -0
  162. package/dist/utils/textParser.d.ts.map +1 -0
  163. package/dist/utils/unicode.d.ts +6 -0
  164. package/dist/utils/unicode.d.ts.map +1 -0
  165. package/dist/utils/warningsDocument.d.ts +17 -0
  166. package/dist/utils/warningsDocument.d.ts.map +1 -0
  167. package/dist/utils/widthUtils.d.ts +27 -0
  168. package/dist/utils/widthUtils.d.ts.map +1 -0
  169. package/package.json +88 -0
@@ -0,0 +1,81 @@
1
+ /// <reference types="node" />
2
+ import { FSWatcher } from 'fs';
3
+ import { ComponentDefinition } from '@json-to-office/shared-docx';
4
+ /**
5
+ * File System utilities for JSON report definitions
6
+ */
7
+ /**
8
+ * Load JSON report definition from file
9
+ * Supports both relative and absolute file paths
10
+ */
11
+ export declare function loadJsonDefinition(filePath: string): Promise<ComponentDefinition>;
12
+ /**
13
+ * Load JSON definition with validation but without throwing on validation errors
14
+ */
15
+ export declare function loadJsonDefinitionSafe(filePath: string): Promise<{
16
+ success: boolean;
17
+ definition?: ComponentDefinition;
18
+ error?: JsonFileError;
19
+ }>;
20
+ /**
21
+ * Watch JSON file for changes and call callback on modifications
22
+ * Useful for development workflows
23
+ */
24
+ export declare function watchJsonFile(filePath: string, callback: (_definition: ComponentDefinition | null, _error?: JsonFileError) => void): JsonFileWatcher;
25
+ /**
26
+ * Watch multiple JSON files and call callback when any changes
27
+ */
28
+ export declare function watchJsonFiles(filePaths: string[], callback: (_filePath: string, _definition: ComponentDefinition | null, _error?: JsonFileError) => void): JsonFileWatcher[];
29
+ /**
30
+ * Check if file exists and is accessible
31
+ */
32
+ export declare function checkJsonFile(filePath: string): Promise<{
33
+ exists: boolean;
34
+ readable: boolean;
35
+ isDirectory: boolean;
36
+ error?: string;
37
+ }>;
38
+ /**
39
+ * Find JSON files in a directory (non-recursive)
40
+ */
41
+ export declare function findJsonFiles(directoryPath: string): Promise<string[]>;
42
+ /**
43
+ * Save JSON report definition to file
44
+ */
45
+ export declare function saveJsonDefinition(definition: ComponentDefinition, filePath: string, options?: {
46
+ pretty?: boolean;
47
+ backup?: boolean;
48
+ }): Promise<void>;
49
+ /**
50
+ * File watcher wrapper class
51
+ */
52
+ export declare class JsonFileWatcher {
53
+ private watcher;
54
+ private filePath;
55
+ constructor(watcher: FSWatcher, filePath: string);
56
+ /**
57
+ * Stop watching the file
58
+ */
59
+ close(): void;
60
+ /**
61
+ * Get the watched file path
62
+ */
63
+ getFilePath(): string;
64
+ }
65
+ /**
66
+ * Custom error class for file system operations
67
+ */
68
+ export declare class JsonFileError extends Error {
69
+ readonly code: string;
70
+ readonly originalError?: Error;
71
+ constructor(message: string, code: string, originalError?: Error);
72
+ }
73
+ /**
74
+ * Utility function to validate JSON file extension
75
+ */
76
+ export declare function hasJsonExtension(filePath: string): boolean;
77
+ /**
78
+ * Utility to ensure a path has .json extension
79
+ */
80
+ export declare function ensureJsonExtension(filePath: string): string;
81
+ //# sourceMappingURL=filesystem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem.d.ts","sourceRoot":"","sources":["../../src/json/filesystem.ts"],"names":[],"mappings":";AAEA,OAAO,EAAS,SAAS,EAAE,MAAM,IAAI,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGlE;;GAEG;AAEH;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,GACf,OAAO,CAA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AC,QAAQ,CAAS;gBAEb,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM;IAKhD;;OAEG;IACI,KAAK,IAAI,IAAI;IAIpB;;OAEG;IACI,WAAW,IAAI,MAAM;CAG7B;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,aAAa,CAAC,EAAE,KAAK,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,KAAK;CAMjE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE5D"}
@@ -0,0 +1,6 @@
1
+ export * from './parser';
2
+ export * from './normalizer';
3
+ export * from './filesystem';
4
+ export type { ComponentDefinition as JsonComponentDefinition } from '@json-to-office/shared-docx';
5
+ export type { CoreValidationResult as ValidationResult, JsonValidationError as ValidationError, } from '@json-to-office/shared-docx';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/json/index.ts"],"names":[],"mappings":"AAEA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAG7B,YAAY,EAAE,mBAAmB,IAAI,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAClG,YAAY,EACV,oBAAoB,IAAI,gBAAgB,EACxC,mBAAmB,IAAI,eAAe,GACvC,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Component Normalizer - Transforms JSON components where business logic requires it
3
+ *
4
+ * This module ONLY handles transformations that are actually necessary:
5
+ * 1. Columns shorthand notation (columns: 3 → array format)
6
+ * 2. Recursive processing of nested components
7
+ * 3. Gap application for columns
8
+ *
9
+ * All other properties are preserved as-is from TypeBox validation.
10
+ * This prevents information loss and maintains single source of truth.
11
+ */
12
+ import { ComponentDefinition, ReportComponentDefinition } from '../types';
13
+ /**
14
+ * Normalize a component definition and its nested children
15
+ * Preserves all validated properties - only transforms where business logic requires
16
+ */
17
+ export declare function normalizeComponent(component: ComponentDefinition): ComponentDefinition;
18
+ /**
19
+ * Normalize entire document (top-level report component)
20
+ * Returns as single-element tuple for backward compatibility
21
+ */
22
+ export declare function normalizeDocument(document: ComponentDefinition | ReportComponentDefinition): [ReportComponentDefinition];
23
+ /**
24
+ * Validate component structure (container vs content components)
25
+ */
26
+ export declare function validateComponentStructure(component: any): {
27
+ valid: boolean;
28
+ errors: string[];
29
+ };
30
+ //# sourceMappingURL=normalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../src/json/normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EAI1B,MAAM,UAAU,CAAC;AAElB;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,mBAAmB,GAC7B,mBAAmB,CAqBrB;AAqGD;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,mBAAmB,GAAG,yBAAyB,GACxD,CAAC,yBAAyB,CAAC,CAU7B;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,GAAG,GAAG;IAC1D,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAqCA"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * JSON Document Parser - Re-exports from shared package
3
+ *
4
+ * This module re-exports the JSON parsing functionality from the shared package
5
+ * and provide a clean interface for the core package.
6
+ */
7
+ export { JsonDocumentParser, JsonParsingError, JsonValidationError, parseJsonComponent, validateJsonComponent, parseJsonWithLineNumbers, } from '@json-to-office/shared-docx';
8
+ export type { DocumentValidationResult, DocumentValidationError, } from '@json-to-office/shared-docx';
9
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/json/parser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,6BAA6B,CAAC;AAGrC,YAAY,EACV,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,113 @@
1
+ import { type TSchema, type Static } from '@sinclair/typebox';
2
+ import type { ComponentDefinition } from '@json-to-office/shared-docx';
3
+ import type { AddWarningFunction } from '@json-to-office/shared-docx';
4
+ import type { ThemeConfig } from '../styles';
5
+ /**
6
+ * Render function context - parameters passed to render
7
+ */
8
+ export interface RenderContext<T> {
9
+ /** The validated props for this component */
10
+ props: T;
11
+ /** The resolved theme configuration */
12
+ theme: ThemeConfig;
13
+ /** Function to add warnings during processing */
14
+ addWarning: AddWarningFunction;
15
+ /** For container components: processed nested children */
16
+ children?: unknown[];
17
+ }
18
+ /**
19
+ * Render function that transforms custom component props into standard components.
20
+ */
21
+ export type RenderFunction<TProps, TComponentDefinition = ComponentDefinition> = (context: RenderContext<TProps>) => Promise<TComponentDefinition[]>;
22
+ /**
23
+ * A single version entry within a versioned component.
24
+ * Each version is self-contained with its own schema, render, and metadata.
25
+ */
26
+ export interface ComponentVersion<TComponentDefinition = ComponentDefinition, TPropsSchema extends TSchema = TSchema> {
27
+ /** TypeBox schema for props validation */
28
+ propsSchema: TPropsSchema;
29
+ /** Async render function to transform props into standard components */
30
+ render: RenderFunction<Static<TPropsSchema>, TComponentDefinition>;
31
+ /** Whether this version supports nested children */
32
+ hasChildren?: boolean;
33
+ /** Optional description for this version */
34
+ description?: string;
35
+ }
36
+ /**
37
+ * Map of semver version strings to their version definitions.
38
+ */
39
+ export type ComponentVersionMap<TComponentDefinition = ComponentDefinition> = Record<string, ComponentVersion<TComponentDefinition, any>>;
40
+ /**
41
+ * Custom component definition with multiple semver-keyed versions.
42
+ * Each version is self-contained with its own schema + render.
43
+ *
44
+ * @typeParam TComponentDefinition - The component definition type for render return
45
+ * @typeParam TVersions - The versions map type
46
+ * @typeParam TName - The literal string type for the component name
47
+ */
48
+ export interface CustomComponent<TComponentDefinition = ComponentDefinition, TVersions extends ComponentVersionMap<TComponentDefinition> = ComponentVersionMap<TComponentDefinition>, TName extends string = string> {
49
+ /** Unique name for the component type */
50
+ name: TName;
51
+ /** Map of semver version strings to version definitions */
52
+ versions: TVersions;
53
+ }
54
+ /**
55
+ * Create a single version entry with full type inference for props.
56
+ *
57
+ * Wrapping each version with `createVersion` lets TypeScript infer the
58
+ * props type from `propsSchema` and propagate it to the `render` function,
59
+ * so `props` is fully typed instead of `any`.
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * createVersion({
64
+ * propsSchema: Type.Object({ city: Type.String() }),
65
+ * render: async ({ props }) => {
66
+ * // props.city is inferred as string
67
+ * return [{ name: 'paragraph', props: { text: props.city } }];
68
+ * },
69
+ * })
70
+ * ```
71
+ */
72
+ export declare function createVersion<TPropsSchema extends TSchema, TComponentDefinition = ComponentDefinition>(version: ComponentVersion<TComponentDefinition, TPropsSchema>): ComponentVersion<TComponentDefinition, TPropsSchema>;
73
+ /**
74
+ * Create a custom component with multiple semver-keyed versions.
75
+ *
76
+ * Use {@link createVersion} for each version entry to get full type inference
77
+ * for `props` in render functions.
78
+ *
79
+ * @example Basic single-version usage
80
+ * ```typescript
81
+ * const weatherComponent = createComponent({
82
+ * name: 'weather' as const,
83
+ * versions: {
84
+ * '1.0.0': createVersion({
85
+ * propsSchema: Type.Object({ city: Type.String() }),
86
+ * render: async ({ props }) => [{
87
+ * name: 'paragraph',
88
+ * props: { text: `Weather in ${props.city}` }
89
+ * }]
90
+ * })
91
+ * }
92
+ * });
93
+ * ```
94
+ *
95
+ * @example Multi-version with breaking changes
96
+ * ```typescript
97
+ * const weatherComponent = createComponent({
98
+ * name: 'weather' as const,
99
+ * versions: {
100
+ * '1.0.0': createVersion({
101
+ * propsSchema: WeatherV1PropsSchema,
102
+ * render: async ({ props }) => [...],
103
+ * }),
104
+ * '2.0.0': createVersion({
105
+ * propsSchema: WeatherV2PropsSchema,
106
+ * render: async ({ props }) => [...],
107
+ * }),
108
+ * },
109
+ * });
110
+ * ```
111
+ */
112
+ export declare function createComponent<TComponentDefinition = ComponentDefinition, TVersions extends ComponentVersionMap<TComponentDefinition> = ComponentVersionMap<TComponentDefinition>, TName extends string = string>(component: CustomComponent<TComponentDefinition, TVersions, TName>): CustomComponent<TComponentDefinition, TVersions, TName>;
113
+ //# sourceMappingURL=createComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../../src/plugin/createComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,6CAA6C;IAC7C,KAAK,EAAE,CAAC,CAAC;IACT,uCAAuC;IACvC,KAAK,EAAE,WAAW,CAAC;IACnB,iDAAiD;IACjD,UAAU,EAAE,kBAAkB,CAAC;IAC/B,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,CACxB,MAAM,EACN,oBAAoB,GAAG,mBAAmB,IACxC,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAA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,CAAC,oBAAoB,CAAC,EACvF,KAAK,SAAS,MAAM,GAAG,MAAM,EAE7B,SAAS,EAAE,eAAe,CAAC,oBAAoB,EAAE,SAAS,EAAE,KAAK,CAAC,GACjE,eAAe,CAAC,oBAAoB,EAAE,SAAS,EAAE,KAAK,CAAC,CAoCzD"}
@@ -0,0 +1,18 @@
1
+ import type { ThemeConfig } from '../styles';
2
+ import type { DocumentGeneratorBuilder } from './types';
3
+ /**
4
+ * Options for creating a document generator
5
+ */
6
+ export interface DocumentGeneratorOptions {
7
+ /** Theme configuration */
8
+ theme: ThemeConfig;
9
+ /** Enable caching for better performance */
10
+ enableCache?: boolean;
11
+ /** Enable debug logging */
12
+ debug?: boolean;
13
+ }
14
+ /**
15
+ * Create a document generator with chainable component registration.
16
+ */
17
+ export declare function createDocumentGenerator(options: DocumentGeneratorOptions): DocumentGeneratorBuilder<readonly []>;
18
+ //# sourceMappingURL=createDocumentGenerator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDocumentGenerator.d.ts","sourceRoot":"","sources":["../../src/plugin/createDocumentGenerator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,KAAK,EAEV,wBAAwB,EAKzB,MAAM,SAAS,CAAC;AAgBjB;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,0BAA0B;IAC1B,KAAK,EAAE,WAAW,CAAC;IACnB,4CAA4C;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAoZD;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,wBAAwB,GAChC,wBAAwB,CAAC,SAAS,EAAE,CAAC,CAUvC"}
@@ -0,0 +1,29 @@
1
+ import type { ComponentDefinition } from '@json-to-office/shared-docx';
2
+ /**
3
+ * Columns layout component that renders a list of components in a 2-column layout
4
+ *
5
+ * @example
6
+ * ```json
7
+ * {
8
+ * "name": "columnsLayout",
9
+ * "children": [
10
+ * {
11
+ * "name": "paragraph",
12
+ * "props": {
13
+ * "content": "Left column content"
14
+ * }
15
+ * },
16
+ * {
17
+ * "name": "paragraph",
18
+ * "props": {
19
+ * "content": "Right column content"
20
+ * }
21
+ * }
22
+ * ]
23
+ * }
24
+ * ```
25
+ */
26
+ export declare const columnsLayoutComponent: import("../createComponent").CustomComponent<ComponentDefinition, {
27
+ '1.0.0': import("../createComponent").ComponentVersion<ComponentDefinition, import("@sinclair/typebox").TObject<{}>>;
28
+ }, "columnsLayout">;
29
+ //# sourceMappingURL=columns-layout.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"columns-layout.component.d.ts","sourceRoot":"","sources":["../../../src/plugin/example/columns-layout.component.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAavE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,sBAAsB;;mBAqBjC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Demo application showing how to use the plugin system
3
+ */
4
+ declare function runPluginDemo(): Promise<void>;
5
+ export { runPluginDemo };
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugin/example/index.ts"],"names":[],"mappings":"AAsBA;;GAEG;AACH,iBAAe,aAAa,kBA6E3B;AAQD,OAAO,EAAE,aAAa,EAAE,CAAC"}