@json-to-office/core-pptx 0.1.1 → 0.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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +393 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin/createPresentationGenerator.d.ts +18 -0
- package/dist/plugin/createPresentationGenerator.d.ts.map +1 -0
- package/dist/plugin/example/index.d.ts +4 -0
- package/dist/plugin/example/index.d.ts.map +1 -0
- package/dist/plugin/example/weather.component.d.ts +28 -0
- package/dist/plugin/example/weather.component.d.ts.map +1 -0
- package/dist/plugin/index.d.ts +32 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/schema.d.ts +13 -0
- package/dist/plugin/schema.d.ts.map +1 -0
- package/dist/plugin/types.d.ts +106 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/plugin/validation.d.ts +30 -0
- package/dist/plugin/validation.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PptxThemeConfig } from '../types';
|
|
2
|
+
import type { PresentationGeneratorBuilder } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Options for creating a presentation generator
|
|
5
|
+
*/
|
|
6
|
+
export interface PresentationGeneratorOptions {
|
|
7
|
+
/** Theme configuration or theme name */
|
|
8
|
+
theme?: PptxThemeConfig | string;
|
|
9
|
+
/** Custom themes map */
|
|
10
|
+
customThemes?: Record<string, PptxThemeConfig>;
|
|
11
|
+
/** Enable debug logging */
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Create a presentation generator with chainable component registration.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createPresentationGenerator(options?: PresentationGeneratorOptions): PresentationGeneratorBuilder<readonly []>;
|
|
18
|
+
//# sourceMappingURL=createPresentationGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPresentationGenerator.d.ts","sourceRoot":"","sources":["../../src/plugin/createPresentationGenerator.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAIV,eAAe,EAChB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAEV,4BAA4B,EAI7B,MAAM,SAAS,CAAC;AAOjB;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,wCAAwC;IACxC,KAAK,CAAC,EAAE,eAAe,GAAG,MAAM,CAAC;IACjC,wBAAwB;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC/C,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAmZD;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,GAAE,4BAAiC,GACzC,4BAA4B,CAAC,SAAS,EAAE,CAAC,CAU3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugin/example/index.ts"],"names":[],"mappings":"AAcA,iBAAe,aAAa,kBAgE3B;AAMD,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PptxComponentInput } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Weather component for PPTX presentations.
|
|
4
|
+
*
|
|
5
|
+
* v1 renders a title + temperature reading + optional detail lines.
|
|
6
|
+
* v2 renders a title + multi-day forecast table.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```json
|
|
10
|
+
* {
|
|
11
|
+
* "name": "weather",
|
|
12
|
+
* "props": { "city": "London", "units": "metric", "showDetails": true }
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const weatherComponent: import("@json-to-office/shared/plugin").CustomComponent<unknown, {
|
|
17
|
+
'1.0.0': import("@json-to-office/shared/plugin").ComponentVersion<PptxComponentInput, import("@sinclair/typebox").TObject<{
|
|
18
|
+
city: import("@sinclair/typebox").TString;
|
|
19
|
+
units: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"metric">, import("@sinclair/typebox").TLiteral<"imperial">]>>;
|
|
20
|
+
showDetails: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
21
|
+
}>, unknown>;
|
|
22
|
+
'2.0.0': import("@json-to-office/shared/plugin").ComponentVersion<PptxComponentInput, import("@sinclair/typebox").TObject<{
|
|
23
|
+
city: import("@sinclair/typebox").TString;
|
|
24
|
+
units: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"metric">, import("@sinclair/typebox").TLiteral<"imperial">]>>;
|
|
25
|
+
days: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
26
|
+
}>, unknown>;
|
|
27
|
+
}, "weather">;
|
|
28
|
+
//# sourceMappingURL=weather.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weather.component.d.ts","sourceRoot":"","sources":["../../../src/plugin/example/weather.component.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAoHtD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;aA6H3B,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin system for json-to-pptx
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { createComponent, createVersion, createPresentationGenerator } from '@json-to-office/core-pptx/plugin';
|
|
7
|
+
* import { Type } from '@sinclair/typebox';
|
|
8
|
+
*
|
|
9
|
+
* const bannerComponent = createComponent({
|
|
10
|
+
* name: 'banner' as const,
|
|
11
|
+
* versions: {
|
|
12
|
+
* '1.0.0': createVersion({
|
|
13
|
+
* propsSchema: Type.Object({ title: Type.String() }),
|
|
14
|
+
* render: async ({ props }) => [{
|
|
15
|
+
* name: 'text',
|
|
16
|
+
* props: { text: props.title, x: 0.5, y: 0.5, w: 9, h: 1 }
|
|
17
|
+
* }]
|
|
18
|
+
* })
|
|
19
|
+
* }
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* const generator = createPresentationGenerator()
|
|
23
|
+
* .addComponent(bannerComponent);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export { createComponent, createVersion, type CustomComponent, type ComponentVersion, type ComponentVersionMap, type RenderFunction, type RenderContext, } from '@json-to-office/shared/plugin';
|
|
27
|
+
export { createPresentationGenerator, type PresentationGeneratorOptions, } from './createPresentationGenerator';
|
|
28
|
+
export { type PresentationGenerator, type PresentationGeneratorBuilder, type BufferGenerationResult, type FileGenerationResult, type ValidationResult, type ExtractCustomComponentType, type CustomComponentUnion, type ExtendedPptxComponentInput, type ExtendedPresentationComponent, type InferBuilderComponents, type InferDocumentType, type InferComponentDefinition, } from './types';
|
|
29
|
+
export { validateComponentProps, validatePresentation, cleanComponentProps, ComponentValidationError, DuplicateComponentError, type ValidationError, type ComponentValidationResult, } from './validation';
|
|
30
|
+
export { generatePluginPresentationSchema, exportPluginSchema } from './schema';
|
|
31
|
+
export { resolveComponentVersion } from '@json-to-office/shared/plugin';
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EACL,eAAe,EACf,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EACL,2BAA2B,EAC3B,KAAK,4BAA4B,GAClC,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,EAClC,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,GAC9B,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,KAAK,eAAe,EACpB,KAAK,yBAAyB,GAC/B,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,gCAAgC,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGhF,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TSchema } from '@sinclair/typebox';
|
|
2
|
+
import type { CustomComponent } from '@json-to-office/shared/plugin';
|
|
3
|
+
/**
|
|
4
|
+
* Generate a JSON schema for plugin-enhanced presentations at RUNTIME.
|
|
5
|
+
*/
|
|
6
|
+
export declare function generatePluginPresentationSchema(customComponents: CustomComponent<any, any, any>[]): TSchema;
|
|
7
|
+
/**
|
|
8
|
+
* Export a plugin-enhanced JSON schema to a file at RUNTIME
|
|
9
|
+
*/
|
|
10
|
+
export declare function exportPluginSchema(customComponents: CustomComponent<any, any, any>[], outputPath: string, options?: {
|
|
11
|
+
prettyPrint?: boolean;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/plugin/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAMrE;;GAEG;AACH,wBAAgB,gCAAgC,CAC9C,gBAAgB,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GACjD,OAAO,CAsBT;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,gBAAgB,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,EAClD,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACtC,OAAO,CAAC,IAAI,CAAC,CAcf"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PPTX plugin type utilities
|
|
3
|
+
*/
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
import type { Static, TSchema } from '@sinclair/typebox';
|
|
6
|
+
import type { CustomComponent } from '@json-to-office/shared/plugin';
|
|
7
|
+
import type { PptxComponentInput, PresentationComponentDefinition, SlideComponentDefinition, PipelineWarning } from '../types';
|
|
8
|
+
type InferVersionMap<T> = T extends CustomComponent<any, infer V, any> ? V : never;
|
|
9
|
+
type InferName<T> = T extends CustomComponent<any, any, infer N> ? N : never;
|
|
10
|
+
/**
|
|
11
|
+
* Extract the component type definition from a versioned CustomComponent.
|
|
12
|
+
* Produces a discriminated union per version + a fallback variant.
|
|
13
|
+
*/
|
|
14
|
+
export type ExtractCustomComponentType<T extends CustomComponent<any, any, any>> = {
|
|
15
|
+
[V in keyof InferVersionMap<T> & string]: {
|
|
16
|
+
name: InferName<T>;
|
|
17
|
+
version: V;
|
|
18
|
+
id?: string;
|
|
19
|
+
props: Static<InferVersionMap<T>[V]['propsSchema']>;
|
|
20
|
+
children?: InferVersionMap<T>[V] extends {
|
|
21
|
+
hasChildren: true;
|
|
22
|
+
} ? PptxComponentInput[] : never;
|
|
23
|
+
};
|
|
24
|
+
}[keyof InferVersionMap<T> & string] | {
|
|
25
|
+
name: InferName<T>;
|
|
26
|
+
version?: never;
|
|
27
|
+
id?: string;
|
|
28
|
+
props: {
|
|
29
|
+
[V in keyof InferVersionMap<T> & string]: Static<InferVersionMap<T>[V]['propsSchema']>;
|
|
30
|
+
}[keyof InferVersionMap<T> & string];
|
|
31
|
+
children?: {
|
|
32
|
+
[V in keyof InferVersionMap<T> & string]: InferVersionMap<T>[V] extends {
|
|
33
|
+
hasChildren: true;
|
|
34
|
+
} ? PptxComponentInput[] : never;
|
|
35
|
+
}[keyof InferVersionMap<T> & string];
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Union type of all custom component definitions from an array
|
|
39
|
+
*/
|
|
40
|
+
export type CustomComponentUnion<T extends readonly CustomComponent<any, any, any>[]> = {
|
|
41
|
+
[K in keyof T]: T[K] extends CustomComponent<any, any, any> ? ExtractCustomComponentType<T[K]> : never;
|
|
42
|
+
}[number];
|
|
43
|
+
/**
|
|
44
|
+
* Extended PptxComponentInput that includes custom components
|
|
45
|
+
*/
|
|
46
|
+
export type ExtendedPptxComponentInput<TCustomComponents extends readonly CustomComponent<any, any, any>[] = readonly []> = TCustomComponents extends readonly [] ? PptxComponentInput : PptxComponentInput | CustomComponentUnion<TCustomComponents>;
|
|
47
|
+
/**
|
|
48
|
+
* Extended SlideComponentDefinition with custom components in slide children
|
|
49
|
+
*/
|
|
50
|
+
export type ExtendedSlideComponent<TCustomComponents extends readonly CustomComponent<any, any, any>[] = readonly []> = Omit<SlideComponentDefinition, 'children'> & {
|
|
51
|
+
children?: ExtendedPptxComponentInput<TCustomComponents>[];
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Extended PresentationComponentDefinition with custom components in children
|
|
55
|
+
*/
|
|
56
|
+
export type ExtendedPresentationComponent<TCustomComponents extends readonly CustomComponent<any, any, any>[] = readonly []> = Omit<PresentationComponentDefinition, 'children'> & {
|
|
57
|
+
children?: (ExtendedSlideComponent<TCustomComponents> | ExtendedPptxComponentInput<TCustomComponents>)[];
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Result of buffer generation
|
|
61
|
+
*/
|
|
62
|
+
export interface BufferGenerationResult {
|
|
63
|
+
buffer: Buffer;
|
|
64
|
+
warnings: PipelineWarning[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Result of file generation
|
|
68
|
+
*/
|
|
69
|
+
export interface FileGenerationResult {
|
|
70
|
+
warnings: PipelineWarning[];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Result of validation
|
|
74
|
+
*/
|
|
75
|
+
export interface ValidationResult {
|
|
76
|
+
valid: boolean;
|
|
77
|
+
errors?: Array<{
|
|
78
|
+
path: string;
|
|
79
|
+
message: string;
|
|
80
|
+
}>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Presentation generator with custom components and full type safety
|
|
84
|
+
*/
|
|
85
|
+
export interface PresentationGenerator<TCustomComponents extends readonly CustomComponent<any, any, any>[] = readonly []> {
|
|
86
|
+
generate: (document: ExtendedPresentationComponent<TCustomComponents>) => Promise<BufferGenerationResult>;
|
|
87
|
+
generateBuffer: (document: ExtendedPresentationComponent<TCustomComponents>) => Promise<BufferGenerationResult>;
|
|
88
|
+
generateFile: (document: ExtendedPresentationComponent<TCustomComponents>, outputPath: string) => Promise<FileGenerationResult>;
|
|
89
|
+
getComponentNames: () => string[];
|
|
90
|
+
validate: (document: ExtendedPresentationComponent<TCustomComponents>) => ValidationResult;
|
|
91
|
+
generateSchema: () => TSchema;
|
|
92
|
+
exportSchema: (outputPath: string, options?: {
|
|
93
|
+
prettyPrint?: boolean;
|
|
94
|
+
}) => Promise<void>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Presentation generator builder with chainable .addComponent() method
|
|
98
|
+
*/
|
|
99
|
+
export interface PresentationGeneratorBuilder<TComponents extends readonly CustomComponent<any, any, any>[] = readonly []> extends PresentationGenerator<TComponents> {
|
|
100
|
+
addComponent<TNewComponent extends CustomComponent<any, any, any>>(component: TNewComponent): PresentationGeneratorBuilder<readonly [...TComponents, TNewComponent]>;
|
|
101
|
+
}
|
|
102
|
+
export type InferBuilderComponents<T> = T extends PresentationGeneratorBuilder<infer M> ? M : never;
|
|
103
|
+
export type InferDocumentType<T> = T extends PresentationGeneratorBuilder<infer M> ? ExtendedPresentationComponent<M> : never;
|
|
104
|
+
export type InferComponentDefinition<T> = T extends PresentationGeneratorBuilder<infer M> ? ExtendedPptxComponentInput<M> : T extends PresentationGenerator<infer M> ? ExtendedPptxComponentInput<M> : never;
|
|
105
|
+
export {};
|
|
106
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugin/types.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EACV,kBAAkB,EAClB,+BAA+B,EAC/B,wBAAwB,EACxB,eAAe,EAChB,MAAM,UAAU,CAAC;AAIlB,KAAK,eAAe,CAAC,CAAC,IACpB,CAAC,SAAS,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE3D,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAI7E;;;GAGG;AACH,MAAM,MAAM,0BAA0B,CACpC,CAAC,SAAS,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAEtC;KACG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C/D,SAAS,EAAE,aAAa,GACvB,4BAA4B,CAAC,SAAS,CAAC,GAAG,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC;CAC3E;AAID,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAClC,CAAC,SAAS,4BAA4B,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE9D,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAC7B,CAAC,SAAS,4BAA4B,CAAC,MAAM,CAAC,CAAC,GAC3C,6BAA6B,CAAC,CAAC,CAAC,GAChC,KAAK,CAAC;AAEZ,MAAM,MAAM,wBAAwB,CAAC,CAAC,IACpC,CAAC,SAAS,4BAA4B,CAAC,MAAM,CAAC,CAAC,GAC3C,0BAA0B,CAAC,CAAC,CAAC,GAC7B,CAAC,SAAS,qBAAqB,CAAC,MAAM,CAAC,CAAC,GACtC,0BAA0B,CAAC,CAAC,CAAC,GAC7B,KAAK,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { TSchema, Static } from '@sinclair/typebox';
|
|
2
|
+
import type { CustomComponent } from '@json-to-office/shared/plugin';
|
|
3
|
+
import type { PresentationComponentDefinition } from '../types';
|
|
4
|
+
import { type ComponentValidationResult } from '@json-to-office/shared/plugin';
|
|
5
|
+
import type { ValidationError } from '@json-to-office/shared';
|
|
6
|
+
export { DuplicateComponentError, ComponentValidationError, } from '@json-to-office/shared/plugin';
|
|
7
|
+
export type { ComponentValidationResult } from '@json-to-office/shared/plugin';
|
|
8
|
+
export type { ValidationError } from '@json-to-office/shared';
|
|
9
|
+
/**
|
|
10
|
+
* Validate component props against a schema.
|
|
11
|
+
*/
|
|
12
|
+
export declare function validateComponentProps<TPropsSchema extends TSchema>(schema: {
|
|
13
|
+
propsSchema: TPropsSchema;
|
|
14
|
+
}, props: unknown, componentName?: string): ComponentValidationResult<TPropsSchema>;
|
|
15
|
+
/**
|
|
16
|
+
* Validate presentation and all custom components (version-aware).
|
|
17
|
+
* PPTX has no structural document validation — only custom component props are checked.
|
|
18
|
+
*/
|
|
19
|
+
export declare function validatePresentation(document: PresentationComponentDefinition, customComponents: CustomComponent<any, any, any>[]): {
|
|
20
|
+
valid: boolean;
|
|
21
|
+
errors: ValidationError[];
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Validates component props and returns typed props or throws.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getValidatedProps<TPropsSchema extends TSchema>(schema: {
|
|
27
|
+
propsSchema: TPropsSchema;
|
|
28
|
+
}, props: unknown): Static<TPropsSchema>;
|
|
29
|
+
export declare const cleanComponentProps: typeof getValidatedProps;
|
|
30
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/plugin/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAIL,KAAK,yBAAyB,EAC/B,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG9D,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,SAAS,OAAO,EACjE,MAAM,EAAE;IAAE,WAAW,EAAE,YAAY,CAAA;CAAE,EACrC,KAAK,EAAE,OAAO,EACd,aAAa,CAAC,EAAE,MAAM,GACrB,yBAAyB,CAAC,YAAY,CAAC,CAMzC;AAED;;;GAGG;A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