ppt2json 0.3.1 → 0.3.3

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 normalized by the `json2pptx-schema` pipeline.
3
+ Convert `.pptx` files into presentation JSON structures normalized by the `json2pptx-schema` pipeline.
4
4
 
5
5
  ## Install
6
6
 
@@ -13,19 +13,18 @@ npm i ppt2json
13
13
  ```ts
14
14
  import { parsePptxToJson } from 'ppt2json'
15
15
 
16
- const file = new File([arrayBuffer], 'deck.pptx', {
16
+ const file = new File([arrayBuffer], 'presentation.pptx', {
17
17
  type: 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
18
18
  })
19
19
 
20
- const { deck, warnings } = await parsePptxToJson(file)
20
+ const { presentationJSON, warnings } = await parsePptxToJson(file)
21
21
  ```
22
22
 
23
- `deck` is normalized `PresentationData`, and `warnings` contains non-fatal conversion warnings.
23
+ `presentationJSON` is normalized `PresentationData`, and `warnings` contains non-fatal conversion warnings.
24
24
 
25
25
  ## Notes
26
26
 
27
- - Parsing is based on Office XML only. The package does not read embedded custom JSON payloads from `.pptx` files.
27
+ - Parsing is based on Office XML.
28
28
  - Returned output is normalized through `json2pptx-schema`, whose parse layer returns `PresentationDocument`.
29
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
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
@@ -128,13 +128,11 @@ type PresentationData = {
128
128
  slides?: Slide[];
129
129
  theme?: PresentationTheme;
130
130
  };
131
- type Presentation = PresentationData;
132
- type Deck = PresentationData;
133
131
 
134
132
  type ParsedResult = {
135
- deck: PresentationData;
133
+ presentation: PresentationData;
136
134
  warnings: string[];
137
135
  };
138
136
  declare function parsePptxToJson(file: File): Promise<ParsedResult>;
139
137
 
140
- export { type Deck, type ParsedResult, type Presentation, type PresentationData, type PresentationTheme, type Slide, type SlideElement, parsePptxToJson };
138
+ export { type PresentationData as Deck, type ParsedResult, type PresentationData as Presentation, type PresentationData, type PresentationTheme, type Slide, type SlideElement, parsePptxToJson };
package/dist/index.d.ts CHANGED
@@ -128,13 +128,11 @@ type PresentationData = {
128
128
  slides?: Slide[];
129
129
  theme?: PresentationTheme;
130
130
  };
131
- type Presentation = PresentationData;
132
- type Deck = PresentationData;
133
131
 
134
132
  type ParsedResult = {
135
- deck: PresentationData;
133
+ presentation: PresentationData;
136
134
  warnings: string[];
137
135
  };
138
136
  declare function parsePptxToJson(file: File): Promise<ParsedResult>;
139
137
 
140
- export { type Deck, type ParsedResult, type Presentation, type PresentationData, type PresentationTheme, type Slide, type SlideElement, parsePptxToJson };
138
+ export { type PresentationData as Deck, type ParsedResult, type PresentationData as Presentation, type PresentationData, type PresentationTheme, type Slide, type SlideElement, parsePptxToJson };
package/dist/index.js CHANGED
@@ -3128,7 +3128,7 @@ function getSpanStyleInfo(node, pNode, textBodyNode, pFontStyle, slideLayoutSpNo
3128
3128
 
3129
3129
  // parser/shape.ts
3130
3130
  function shapeArc(cX, cY, rX, rY, stAng, endAng, isClose) {
3131
- let dData;
3131
+ let dData = "";
3132
3132
  let angle = stAng;
3133
3133
  if (endAng >= stAng) {
3134
3134
  while (angle <= endAng) {
@@ -9262,7 +9262,9 @@ function parseGradientPosition(value) {
9262
9262
  }
9263
9263
  function mapGradient(value) {
9264
9264
  if (!value || typeof value !== "object") return void 0;
9265
- const colors = Array.isArray(value.colors) ? value.colors.filter((stop) => stop && typeof stop === "object").map((stop) => ({
9265
+ const colors = Array.isArray(value.colors) ? value.colors.filter(
9266
+ (stop) => typeof stop === "object" && stop !== null
9267
+ ).map((stop) => ({
9266
9268
  pos: parseGradientPosition(stop.pos),
9267
9269
  color: mapFillColor(stop.color) ?? "#FFFFFF"
9268
9270
  })) : [];
@@ -9535,7 +9537,7 @@ function mapElement(raw) {
9535
9537
  fill,
9536
9538
  ...special ? { special: true } : {},
9537
9539
  text: hasText ? {
9538
- content: normalizedShapeText,
9540
+ content: normalizedShapeText ?? "",
9539
9541
  align: normalizeVAlign(raw.vAlign) ?? "middle",
9540
9542
  defaultColor: normalizeColor(raw.defaultColor) ?? normalizeColor(raw.color) ?? "#333",
9541
9543
  defaultFontName: raw.fontName ?? "",
@@ -9776,7 +9778,7 @@ var DEFAULT_THEME = {
9776
9778
  async function parsePptxToJson(file) {
9777
9779
  const fileBuffer = await file.arrayBuffer();
9778
9780
  return {
9779
- deck: await buildDeckFromPptx(fileBuffer),
9781
+ presentation: await buildDeckFromPptx(fileBuffer),
9780
9782
  warnings: []
9781
9783
  };
9782
9784
  }