@christophervr/pptx-viewer 0.0.2 → 1.1.27

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/CHANGELOG.md ADDED
@@ -0,0 +1,55 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here.
4
+ This file is generated from [Conventional Commits](https://www.conventionalcommits.org)
5
+ by [git-cliff](https://git-cliff.org); do not edit it by hand.
6
+
7
+ ## [1.1.26](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-viewer-core@1.1.26) - 2026-06-21
8
+
9
+ ### Documentation
10
+
11
+ - Sharpen npm descriptions and keywords for discoverability (by @ChristopherVR) ([8fea56d](https://github.com/ChristopherVR/pptx-viewer/commit/8fea56d7650f7dc2f3167dea97b94b612a03a4e7))
12
+ - **core:** Reword README in plain language (by @ChristopherVR) ([793c26e](https://github.com/ChristopherVR/pptx-viewer/commit/793c26ec7e2415c66f34c637cb541483bf395a11))
13
+
14
+ ## [1.1.24](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-viewer-core@1.1.24) - 2026-06-20
15
+
16
+ ### Features
17
+
18
+ - **core:** Add signature-node module and shared signature utilities (by @ChristopherVR) ([e7cb263](https://github.com/ChristopherVR/pptx-viewer/commit/e7cb26335f15e633cfc37371f16a6ad210be5e11))
19
+
20
+ ### Bug Fixes
21
+
22
+ - Enable vitest globals in all packages to fix expectTypeOf errors (by @ChristopherVR) ([6d90d72](https://github.com/ChristopherVR/pptx-viewer/commit/6d90d72ff0107ad0194f9c73ceeb3df244f4cfc6))
23
+ - **test:** Add i18n mocks to react tests and bump versions to 1.2.0 (by @ChristopherVR) ([2c1c962](https://github.com/ChristopherVR/pptx-viewer/commit/2c1c9628714b905b28592493abf02fb270107b65))
24
+ - **deps:** Pin @xmldom/xmldom to 0.8.x in core to fix build (by @ChristopherVR) ([2ed7b2e](https://github.com/ChristopherVR/pptx-viewer/commit/2ed7b2e777d4e740a3e4c9ca7e2b3d6fc2bbd21f))
25
+ - **core:** Declare jszip and fast-xml-parser as runtime dependencies (by @ChristopherVR) ([b6636be](https://github.com/ChristopherVR/pptx-viewer/commit/b6636be972206bb2c6acee0fed05c45b4759fbdc))
26
+
27
+ ### Refactor
28
+
29
+ - **core:** Consume emf-converter and mtx-decompressor from npm (by @ChristopherVR) ([2f6013d](https://github.com/ChristopherVR/pptx-viewer/commit/2f6013d5b8fab0aef5b32901841d94c0fa886f24))
30
+
31
+ ### Documentation
32
+
33
+ - Restructure root README, elevate limitations, fix outdated claims (by @ChristopherVR) ([86dcda9](https://github.com/ChristopherVR/pptx-viewer/commit/86dcda9b5e3129f2223341337055778db574e985))
34
+ - Rewrite limitations with technical explanations and remove inaccurate claims (by @ChristopherVR) ([ac4bc84](https://github.com/ChristopherVR/pptx-viewer/commit/ac4bc84ed9bd03f62e3ae29c35baf3f444a3c0bf))
35
+ - **readme:** Npm-friendly READMEs — hero image, capabilities & install first (by @ChristopherVR) ([c843d19](https://github.com/ChristopherVR/pptx-viewer/commit/c843d1934b846f901bba92e63d2b01f9479594d0))
36
+ - Streamline npm READMEs and add badges, screenshots, demo links (by @ChristopherVR) ([92e980d](https://github.com/ChristopherVR/pptx-viewer/commit/92e980d434900abd223c4d70c6cae19a623f9ca8))
37
+
38
+ ### Build & CI
39
+
40
+ - Independent per-package versioning, tags, and changelogs (by @ChristopherVR) ([79595d9](https://github.com/ChristopherVR/pptx-viewer/commit/79595d972d7c4102e8b1e1e3926f439486f76ba1))
41
+
42
+ ### Dependencies
43
+
44
+ - **deps:** Update all dependencies to latest (by @ChristopherVR) ([e3287c0](https://github.com/ChristopherVR/pptx-viewer/commit/e3287c03ff58b1a1ae103ed32a513468a454a084))
45
+ - **deps:** Bump all workspace manifest floors to latest (by @ChristopherVR) ([890c33d](https://github.com/ChristopherVR/pptx-viewer/commit/890c33d667a39480a69e6a3da893964382993b29))
46
+
47
+ ### Chores
48
+
49
+ - Add license files, NOTICE, and package metadata for npm publishing (by @ChristopherVR) ([9464bb8](https://github.com/ChristopherVR/pptx-viewer/commit/9464bb8b91734daf35131d3c7e52e60895fe0a1c))
50
+ - Bump all packages to v1.1.0 and remove remaining MyClawAssist refs (by @ChristopherVR) ([c386511](https://github.com/ChristopherVR/pptx-viewer/commit/c38651150c08011cee5e17e15f7ee8adc0014b80))
51
+ - Bump all packages to 1.x.1 patch versions (by @ChristopherVR) ([c75205a](https://github.com/ChristopherVR/pptx-viewer/commit/c75205a96cc7797d1647ac4705395b7707ac8910))
52
+ - Bump all packages to minor versions for SDK table support (by @ChristopherVR) ([2d4b635](https://github.com/ChristopherVR/pptx-viewer/commit/2d4b6351b0bf328f8a556cf593733fd8ad36c7b5))
53
+ - Bump dependencies to latest and minor-bump packages for parity work (by @ChristopherVR) ([da19fdf](https://github.com/ChristopherVR/pptx-viewer/commit/da19fdf9a4670d274d9973b67aa22d34217b8555))
54
+ - Roll TypeScript back to 5.9.x; quiet new oxlint vitest rules (by @ChristopherVR) ([713c020](https://github.com/ChristopherVR/pptx-viewer/commit/713c020ac2428db0fb1eb6cb30e56b2cff19a80f))
55
+ - Relicense from MIT to Apache-2.0 (by @ChristopherVR) ([e12f926](https://github.com/ChristopherVR/pptx-viewer/commit/e12f9266f02bebbfc218986b617c418fee43a56b))
package/NOTICE ADDED
@@ -0,0 +1,18 @@
1
+ pptx-viewer-core
2
+ Copyright (c) 2025-present pptx-viewer contributors
3
+
4
+ This package is licensed under the Apache License 2.0. See the LICENSE file for
5
+ details. Under Section 4(d) of that license, please preserve this NOTICE (or the
6
+ attribution it contains) in any derivative works you distribute.
7
+
8
+ This package bundles the following component under a different license:
9
+
10
+ mtx-decompressor — MicroType Express (MTX) font decompressor
11
+ License: Mozilla Public License 2.0 (MPL-2.0)
12
+ Source: https://github.com/ChristopherVR/pptx-viewer/tree/main/packages/mtx-decompressor
13
+ Origin: Ported from libeot (https://github.com/nicowilliams/libeot)
14
+ by Brennan T. Vincent, licensed under MPL-2.0.
15
+
16
+ Under MPL-2.0, the source code of the mtx-decompressor component remains
17
+ available under the terms of the Mozilla Public License 2.0. The full text
18
+ of the MPL-2.0 can be found at: https://mozilla.org/MPL/2.0/
package/README.md CHANGED
@@ -1,40 +1,185 @@
1
- # @christophervr/pptx-viewer
1
+ # pptx-viewer-core
2
2
 
3
- > ⚠️ **For now, this package is just an alias for [`pptx-viewer-core`](https://www.npmjs.com/package/pptx-viewer-core).**
4
- > Installing it installs the core engine, and importing from it re-exports the
5
- > entire core API. There is no extra functionality on top yet.
3
+ [![npm version](https://img.shields.io/npm/v/pptx-viewer-core.svg)](https://www.npmjs.com/package/pptx-viewer-core)
4
+ [![license](https://img.shields.io/npm/l/pptx-viewer-core.svg)](https://github.com/ChristopherVR/pptx-viewer/blob/main/LICENSE)
5
+ [![types](https://img.shields.io/npm/types/pptx-viewer-core.svg)](https://www.npmjs.com/package/pptx-viewer-core)
6
+
7
+ > **Also published as [`@christophervr/pptx-viewer`](https://www.npmjs.com/package/@christophervr/pptx-viewer)** -- the two package names are identical releases of the same code. Use whichever name you prefer; they are always published together and kept in sync.
8
+
9
+ > A TypeScript library that **reads, creates, edits, and saves** PowerPoint (`.pptx`) files. It runs in the browser and in Node.js, with no native or system dependencies.
10
+
11
+ Hand it the bytes of a `.pptx` file and it gives you back a structured, fully typed object that describes every slide: text, shapes, images, charts, tables, and more. Change anything in that object and write it back to a valid `.pptx`. You can also build new presentations from scratch with a simple chainable API, or turn a deck into Markdown.
12
+
13
+ There is no UI here: this is the engine on its own. Use it directly when you need to process `.pptx` files without a screen, for example on a server, in a script, or in a build step. The same engine powers the [`pptx-react-viewer`](https://www.npmjs.com/package/pptx-react-viewer), `pptx-vue-viewer`, and `pptx-angular-viewer` UI components.
14
+
15
+ <samp>**[📦 npm](https://www.npmjs.com/package/pptx-viewer-core)** · **[📖 Full docs](https://christophervr.github.io/pptx-viewer/)** · **[▶️ Live demo](https://christophervr.github.io/pptx-viewer/demo/)** · **[⚛️ React UI](https://www.npmjs.com/package/pptx-react-viewer)**</samp>
16
+
17
+ ---
18
+
19
+ ## Install
6
20
 
7
21
  ```bash
8
- npm install @christophervr/pptx-viewer
22
+ npm install pptx-viewer-core
23
+ # required companions:
24
+ npm install jszip fast-xml-parser
9
25
  ```
10
26
 
11
- ```ts
12
- // These are equivalent today:
13
- import { PptxHandler } from '@christophervr/pptx-viewer';
27
+ > Two packages are always needed alongside it: **jszip** (a `.pptx` is a ZIP file, and this reads and writes that container) and **fast-xml-parser** (the slides inside are XML, and this reads and writes it). Password protection and digital signatures need a few extra packages (`node-forge`, `xml-crypto`, `@xmldom/xmldom`), but only if you actually use those features.
28
+
29
+ ## What it does
30
+
31
+ | Capability | Description |
32
+ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
33
+ | **Read** | Open a `.pptx` and pull out slides, text, shapes, images, charts, tables, SmartArt, themes, comments, animations, transitions, and document info |
34
+ | **Edit** | Change the data in memory: add, remove, or reorder slides; insert elements; edit text; restyle; switch themes |
35
+ | **Save** | Write the changed data back to a valid `.pptx`, leaving everything you did not touch untouched |
36
+ | **Convert** | Turn a deck into Markdown, optionally pulling the images out alongside it |
37
+ | **Export** | Save individual slides as their own standalone `.pptx` files |
38
+ | **Protect** | Open and save password-protected files (AES-128/256 encryption) |
39
+
40
+ Positions and sizes use PowerPoint's own internal unit, the EMU (English Metric Unit): 1 inch = 914,400 EMU, 1 point = 12,700 EMU, and 1 pixel = 9,525 EMU at 96 DPI. You rarely deal with the raw numbers: helpers (`inches`, `cm`, `mm`, `pt`) let you work in familiar units instead.
41
+
42
+ ---
43
+
44
+ ## Quick start
45
+
46
+ ```typescript
14
47
  import { PptxHandler } from 'pptx-viewer-core';
48
+
49
+ // 1. Open a .pptx file
50
+ const handler = new PptxHandler();
51
+ const buffer = await fetch('presentation.pptx').then((r) => r.arrayBuffer());
52
+ const data = await handler.load(buffer);
53
+
54
+ console.log(
55
+ `${data.slides.length} slides, canvas ${data.canvasSize.width}×${data.canvasSize.height}`,
56
+ );
57
+
58
+ // 2. Change a slide
59
+ data.slides[0].elements[0].text = 'Updated title';
60
+
61
+ // 3. Save it back to .pptx bytes
62
+ const outputBytes = await handler.save(data.slides); // => Uint8Array
63
+
64
+ // 4. Or pull out just a few slides as separate files
65
+ const exports = await handler.exportSlides(data.slides, { slideIndexes: [0, 2] }); // => Map<number, Uint8Array>
66
+ ```
67
+
68
+ `load()` gives you a `PptxData` object: a plain, fully typed description of the presentation. Read from it, change it, and pass its `slides` back to `save()` to get a valid `.pptx` file as bytes.
69
+
70
+ ### Build a presentation from scratch
71
+
72
+ The chainable API lets you create a deck step by step, without touching any file format details:
73
+
74
+ ```typescript
75
+ import { Presentation, ThemePresets, ChartBuilder } from 'pptx-viewer-core';
76
+
77
+ const pptx = await Presentation.create({
78
+ title: 'Sales Report',
79
+ theme: ThemePresets.MODERN_BLUE,
80
+ });
81
+
82
+ // Each slide is added to the deck automatically: no manual .build() or .push() needed
83
+ pptx
84
+ .addSlide('Title Slide')
85
+ .addText('Q4 Sales Report', { fontSize: 44, bold: true, x: 100, y: 200, width: 800, height: 80 });
86
+
87
+ pptx
88
+ .addSlide('Blank')
89
+ .addText('Revenue by Region', { fontSize: 28, x: 50, y: 30, width: 600, height: 50 })
90
+ .addBuilderElement(
91
+ ChartBuilder.create('bar')
92
+ .categories(['North', 'South', 'East', 'West'])
93
+ .addSeries('2026', [210, 150, 180, 120], '#2563EB')
94
+ .title('Revenue ($M)')
95
+ .bounds(50, 100, 860, 420),
96
+ );
97
+
98
+ pptx.replaceText('2026', 'FY2026'); // find/replace, merge, and templates all chain the same way
99
+
100
+ const bytes = await pptx.save();
101
+ ```
102
+
103
+ The builder API comes in three levels, from highest to lowest:
104
+
105
+ 1. **`Presentation`**: the whole deck at once (slides, text operations, sections, templates, merging, saving).
106
+ 2. **Element builders**: one per element type, for fine-grained control: `TextBuilder`, `ShapeBuilder`, `ChartBuilder`, `TableBuilder`, `ImageBuilder`, `ConnectorBuilder`, `MediaBuilder`, `GroupBuilder`.
107
+ 3. **`PptxXmlBuilder`**: raw XML, for the rare cases the higher levels do not cover.
108
+
109
+ It also ships unit helpers (`inches`, `cm`, `mm`, `pt`), common slide sizes (`SlideSizes`), and 8 ready-made themes (`ThemePresets`). The [full docs](https://christophervr.github.io/pptx-viewer/) cover every builder.
110
+
111
+ ### Turn a deck into Markdown
112
+
113
+ ```typescript
114
+ import { PptxMarkdownConverter } from 'pptx-viewer-core';
115
+
116
+ const converter = new PptxMarkdownConverter({ includeMetadata: true, imageHandling: 'extract' });
117
+ const result = await converter.convert(
118
+ buffer,
119
+ { outputPath: 'output.md', mediaFolderName: 'media' },
120
+ fileSystemAdapter,
121
+ );
122
+ // => the Markdown text, plus stats on any images that were pulled out
15
123
  ```
16
124
 
17
- `pptx-viewer-core` is the framework-agnostic engine: parse, edit, serialize, and
18
- convert PowerPoint (`.pptx`) files in memory.
125
+ To write files to disk, pass a `FileSystemAdapter` (an object with `writeFile`, `writeBinaryFile`, and `createFolder` methods); this keeps the converter free of any assumptions about where it runs. By default it keeps each element where it sat on the slide (absolutely positioned HTML); set `semanticMode: true` to get clean headings, paragraphs, and lists instead.
126
+
127
+ ---
128
+
129
+ ## `PptxHandler` API
130
+
131
+ `PptxHandler` is the one class you use to open, change, and save files. Its main methods:
132
+
133
+ | Method | Signature | What it does |
134
+ | -------------------------- | ------------------------------------------------------- | ------------------------------------------------------ |
135
+ | `load` | `(data, options?) => Promise<PptxData>` | Open a `.pptx` and return the structured data |
136
+ | `save` | `(slides, options?) => Promise<Uint8Array>` | Write slides back to `.pptx` bytes |
137
+ | `exportSlides` | `(slides, options) => Promise<Map<number, Uint8Array>>` | Save chosen slides as standalone files |
138
+ | `getImageData` | `(path) => Promise<string \| undefined>` | Get an embedded image as a base64 data URL |
139
+ | `getMediaArrayBuffer` | `(path) => Promise<ArrayBuffer \| undefined>` | Get the raw bytes of an embedded media file |
140
+ | `getLayoutOptions` | `() => PptxLayoutOption[]` | List the slide layouts available |
141
+ | `getCompatibilityWarnings` | `() => PptxCompatibilityWarning[]` | List features in the file that are not fully supported |
142
+ | `applyTheme` | `(colors, fonts, name?) => Promise<void>` | Apply a complete theme |
143
+ | `setPresentationTheme` | `(path, applyToAll?) => Promise<void>` | Load a `.thmx` theme file |
144
+
145
+ The `PptxData` you get from `load()` exposes `slides`, `canvasSize`, `theme`, `slideMasters`, `slideLayouts`, `sections`, `coreProperties`, `embeddedFonts`, and more. See the [full docs](https://christophervr.github.io/pptx-viewer/) for the complete `PptxHandler`, chart/SmartArt, and theme APIs.
146
+
147
+ ## What's supported
148
+
149
+ | Category | Details |
150
+ | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
151
+ | **Element types** | 16: text, shape, connector, image, picture, table, chart, smartArt, ole, media, group, ink, contentPart, zoom, model3d, unknown |
152
+ | **Preset shapes** | 187+ PowerPoint shapes, including ones with adjustable handles |
153
+ | **Chart types** | 23, including waterfall, funnel, treemap, sunburst, box-whisker, region-map, and combo charts; with trendlines, error bars, and embedded Excel data |
154
+ | **Transitions** | 42 types (including morph, vortex, ripple, and shred) |
155
+ | **Animations** | 40+ presets, including colour animation, motion paths, and text that builds in by word, letter, or paragraph |
156
+ | **SmartArt** | 13 layout types, broken down into editable shapes |
157
+ | **Fills** | Solid, gradient (linear, radial, path), image, and 48 patterns |
158
+ | **Themes** | 8 built-in presets, switchable at runtime, with layout and placeholder remapping |
159
+ | **Security** | AES-128/256 encryption and decryption, modify-password (SHA), and detection of digital signatures |
160
+ | **Preserved** | VBA macros, custom XML, comment authors, and strict-format files are kept intact through a save |
161
+
162
+ ## How it works
163
+
164
+ You only ever work with one class, `PptxHandler`, and one data object, `PptxData`. The engine takes care of the rest: when you call `load()` it unzips the file, reads the XML, resolves the theme, masters, and layouts, and hands you a clean object. `save()` runs those same steps in reverse.
19
165
 
20
- ## Want a UI component?
166
+ A few things worth knowing as you use it:
21
167
 
22
- This package does **not** provide a viewer component. Use the framework-specific
23
- package for your stack each is built on `pptx-viewer-core`:
168
+ - **Every element has a `type` field** (`text`, `shape`, `image`, `chart`, `table`, and so on). Check it before reading element-specific properties, for example `if (element.type === 'image')`. TypeScript then knows exactly which fields exist.
169
+ - **Shapes are drawn from a built-in catalogue** of 187+ PowerPoint shapes, so curves, arrows, and callouts come out with the right outlines.
170
+ - **Colours follow PowerPoint's theme rules**, so a colour defined as "accent 1, but 20% lighter" resolves to the correct final value for the active theme.
24
171
 
25
- - **React** [`pptx-react-viewer`](https://www.npmjs.com/package/pptx-react-viewer)
26
- - **Vue 3** — [`pptx-vue-viewer`](https://www.npmjs.com/package/pptx-vue-viewer)
27
- - **Angular** — [`pptx-angular-viewer`](https://www.npmjs.com/package/pptx-angular-viewer)
172
+ Under the hood the engine is split into many small, focused modules. If you want the full load and save pipeline, the complete type system, and a module-by-module map, see the [full documentation](https://christophervr.github.io/pptx-viewer/).
28
173
 
29
- ## Status
174
+ ## Limitations
30
175
 
31
- This is a reserved scope name that currently forwards to the core engine. It may
32
- gain its own surface in the future; until then, prefer importing `pptx-viewer-core`
33
- directly or the framework package above.
176
+ - **OLE objects** (embedded Word docs, spreadsheets, and similar) are read-only: you get their preview image, not their contents.
177
+ - **SmartArt** is broken into editable shapes using the drawing data PowerPoint already saved in the file. There is no engine that re-flows the layout if you change it.
178
+ - **Chart editing is data-only**: you can change series, data points, categories, and the chart type. Other chart properties are read for display but cannot be edited.
179
+ - **Strict-format files** (ISO/IEC 29500 Strict) are converted to the more common Transitional form when opened and converted back when saved.
34
180
 
35
- See the [project repository](https://github.com/ChristopherVR/pptx-viewer) for
36
- full documentation.
181
+ See the [full docs](https://christophervr.github.io/pptx-viewer/) for the details behind each of these.
37
182
 
38
183
  ## License
39
184
 
40
- Apache-2.0 © ChristopherVR
185
+ [Apache-2.0](LICENSE). Please keep the [`NOTICE`](NOTICE) file with redistributions.