ppt2json 0.2.0 → 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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ppt2json
2
2
 
3
- Convert `.pptx` files into JSON deck structures compatible with the `json2pptx` schema pipeline.
3
+ Convert `.pptx` files into JSON deck structures normalized by the `json2pptx-schema` pipeline.
4
4
 
5
5
  ## Install
6
6
 
@@ -20,4 +20,12 @@ const file = new File([arrayBuffer], 'deck.pptx', {
20
20
  const { deck, warnings } = await parsePptxToJson(file)
21
21
  ```
22
22
 
23
- `deck` is schema-compatible JSON, and `warnings` contains non-fatal conversion warnings.
23
+ `deck` is normalized `PresentationData`, and `warnings` contains non-fatal conversion warnings.
24
+
25
+ ## Notes
26
+
27
+ - Parsing is based on Office XML only. The package does not read embedded custom JSON payloads from `.pptx` files.
28
+ - Returned output is normalized through `json2pptx-schema`, whose parse layer returns `PresentationDocument`.
29
+ - Visual round-trip is optimized for the built-in templates in this repo and shared primitives such as fills, text, paths, lines, images, and image clipping.
30
+ - Arbitrary third-party PPTX files are best-effort conversions.
31
+ - `Deck` remains exported as a compatibility alias, but the recommended application-layer type name is `PresentationData`.
package/dist/index.d.mts CHANGED
@@ -1,3 +1,23 @@
1
+ type FillGradientStop = {
2
+ pos?: number;
3
+ color?: string;
4
+ };
5
+ type FillGradient = {
6
+ type?: string;
7
+ rotate?: number;
8
+ colors?: FillGradientStop[];
9
+ };
10
+ type ElementFill = {
11
+ type: 'solid';
12
+ color?: string;
13
+ } | {
14
+ type: 'gradient';
15
+ gradient?: FillGradient;
16
+ } | {
17
+ type: 'image';
18
+ src?: string;
19
+ opacity?: number;
20
+ };
1
21
  type SlideElement = {
2
22
  type: string;
3
23
  id?: string;
@@ -7,8 +27,7 @@ type SlideElement = {
7
27
  width?: number;
8
28
  height?: number;
9
29
  rotate?: number;
10
- fill?: string;
11
- pattern?: string;
30
+ fill?: ElementFill;
12
31
  path?: string;
13
32
  viewBox?: [number, number];
14
33
  pathFormula?: string;
@@ -82,41 +101,40 @@ type Slide = {
82
101
  id?: string;
83
102
  elements?: SlideElement[];
84
103
  remark?: string;
85
- background?: {
86
- type?: string;
104
+ background?: ElementFill;
105
+ type?: string;
106
+ };
107
+ type PresentationTheme = {
108
+ themeColors?: string[];
109
+ fontName?: string;
110
+ fontColor?: string;
111
+ backgroundColor?: string;
112
+ shadow?: {
113
+ h?: number;
114
+ v?: number;
115
+ blur?: number;
87
116
  color?: string;
88
- src?: string;
89
117
  };
90
- type?: string;
118
+ outline?: {
119
+ width?: number;
120
+ color?: string;
121
+ style?: string;
122
+ };
91
123
  };
92
- type Deck = {
124
+ type PresentationData = {
93
125
  title?: string;
94
126
  width?: number;
95
127
  height?: number;
96
128
  slides?: Slide[];
97
- theme?: {
98
- themeColors?: string[];
99
- fontName?: string;
100
- fontColor?: string;
101
- backgroundColor?: string;
102
- shadow?: {
103
- h?: number;
104
- v?: number;
105
- blur?: number;
106
- color?: string;
107
- };
108
- outline?: {
109
- width?: number;
110
- color?: string;
111
- style?: string;
112
- };
113
- };
129
+ theme?: PresentationTheme;
114
130
  };
131
+ type Presentation = PresentationData;
132
+ type Deck = PresentationData;
115
133
 
116
134
  type ParsedResult = {
117
- deck: Deck;
135
+ deck: PresentationData;
118
136
  warnings: string[];
119
137
  };
120
138
  declare function parsePptxToJson(file: File): Promise<ParsedResult>;
121
139
 
122
- export { type Deck, type ParsedResult, type Slide, type SlideElement, parsePptxToJson };
140
+ export { type Deck, type ParsedResult, type Presentation, type PresentationData, type PresentationTheme, type Slide, type SlideElement, parsePptxToJson };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,23 @@
1
+ type FillGradientStop = {
2
+ pos?: number;
3
+ color?: string;
4
+ };
5
+ type FillGradient = {
6
+ type?: string;
7
+ rotate?: number;
8
+ colors?: FillGradientStop[];
9
+ };
10
+ type ElementFill = {
11
+ type: 'solid';
12
+ color?: string;
13
+ } | {
14
+ type: 'gradient';
15
+ gradient?: FillGradient;
16
+ } | {
17
+ type: 'image';
18
+ src?: string;
19
+ opacity?: number;
20
+ };
1
21
  type SlideElement = {
2
22
  type: string;
3
23
  id?: string;
@@ -7,8 +27,7 @@ type SlideElement = {
7
27
  width?: number;
8
28
  height?: number;
9
29
  rotate?: number;
10
- fill?: string;
11
- pattern?: string;
30
+ fill?: ElementFill;
12
31
  path?: string;
13
32
  viewBox?: [number, number];
14
33
  pathFormula?: string;
@@ -82,41 +101,40 @@ type Slide = {
82
101
  id?: string;
83
102
  elements?: SlideElement[];
84
103
  remark?: string;
85
- background?: {
86
- type?: string;
104
+ background?: ElementFill;
105
+ type?: string;
106
+ };
107
+ type PresentationTheme = {
108
+ themeColors?: string[];
109
+ fontName?: string;
110
+ fontColor?: string;
111
+ backgroundColor?: string;
112
+ shadow?: {
113
+ h?: number;
114
+ v?: number;
115
+ blur?: number;
87
116
  color?: string;
88
- src?: string;
89
117
  };
90
- type?: string;
118
+ outline?: {
119
+ width?: number;
120
+ color?: string;
121
+ style?: string;
122
+ };
91
123
  };
92
- type Deck = {
124
+ type PresentationData = {
93
125
  title?: string;
94
126
  width?: number;
95
127
  height?: number;
96
128
  slides?: Slide[];
97
- theme?: {
98
- themeColors?: string[];
99
- fontName?: string;
100
- fontColor?: string;
101
- backgroundColor?: string;
102
- shadow?: {
103
- h?: number;
104
- v?: number;
105
- blur?: number;
106
- color?: string;
107
- };
108
- outline?: {
109
- width?: number;
110
- color?: string;
111
- style?: string;
112
- };
113
- };
129
+ theme?: PresentationTheme;
114
130
  };
131
+ type Presentation = PresentationData;
132
+ type Deck = PresentationData;
115
133
 
116
134
  type ParsedResult = {
117
- deck: Deck;
135
+ deck: PresentationData;
118
136
  warnings: string[];
119
137
  };
120
138
  declare function parsePptxToJson(file: File): Promise<ParsedResult>;
121
139
 
122
- export { type Deck, type ParsedResult, type Slide, type SlideElement, parsePptxToJson };
140
+ export { type Deck, type ParsedResult, type Presentation, type PresentationData, type PresentationTheme, type Slide, type SlideElement, parsePptxToJson };