pptx-ts 0.0.1

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 (78) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +319 -0
  3. package/dist/autopage-DkjYZUFD.js +423 -0
  4. package/dist/autopage-DkjYZUFD.js.map +1 -0
  5. package/dist/browser.d.ts +31 -0
  6. package/dist/browser.d.ts.map +1 -0
  7. package/dist/browser.js +110 -0
  8. package/dist/browser.js.map +1 -0
  9. package/dist/diagnostics-Du_s75MT.d.ts +829 -0
  10. package/dist/diagnostics-Du_s75MT.d.ts.map +1 -0
  11. package/dist/enums-CvRYniUA.d.ts +463 -0
  12. package/dist/enums-CvRYniUA.d.ts.map +1 -0
  13. package/dist/errors-Bvln0H-7.js +112 -0
  14. package/dist/errors-Bvln0H-7.js.map +1 -0
  15. package/dist/errors-PflMPWBn.d.ts +182 -0
  16. package/dist/errors-PflMPWBn.d.ts.map +1 -0
  17. package/dist/fit-BKs0zxMI.js +1356 -0
  18. package/dist/fit-BKs0zxMI.js.map +1 -0
  19. package/dist/html-dom-B0I0QSbU.js +679 -0
  20. package/dist/html-dom-B0I0QSbU.js.map +1 -0
  21. package/dist/html.d.ts +26 -0
  22. package/dist/html.d.ts.map +1 -0
  23. package/dist/html.js +63 -0
  24. package/dist/html.js.map +1 -0
  25. package/dist/index.d.ts +24 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +57 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/inspect.d.ts +197 -0
  30. package/dist/inspect.d.ts.map +1 -0
  31. package/dist/inspect.js +317 -0
  32. package/dist/inspect.js.map +1 -0
  33. package/dist/math.d.ts +37 -0
  34. package/dist/math.d.ts.map +1 -0
  35. package/dist/math.js +203 -0
  36. package/dist/math.js.map +1 -0
  37. package/dist/measure.d.ts +313 -0
  38. package/dist/measure.d.ts.map +1 -0
  39. package/dist/measure.js +3 -0
  40. package/dist/namespaces-BVnNu7sg.js +666 -0
  41. package/dist/namespaces-BVnNu7sg.js.map +1 -0
  42. package/dist/node.d.ts +20 -0
  43. package/dist/node.d.ts.map +1 -0
  44. package/dist/node.js +55 -0
  45. package/dist/node.js.map +1 -0
  46. package/dist/notes-RLCwdlTE.js +1703 -0
  47. package/dist/notes-RLCwdlTE.js.map +1 -0
  48. package/dist/package-CaOLXSNi.d.ts +193 -0
  49. package/dist/package-CaOLXSNi.d.ts.map +1 -0
  50. package/dist/pres-C5__xkDh.d.ts +202 -0
  51. package/dist/pres-C5__xkDh.d.ts.map +1 -0
  52. package/dist/presentation-Cp7vzlAw.js +5427 -0
  53. package/dist/presentation-Cp7vzlAw.js.map +1 -0
  54. package/dist/presentation-types-DP_8jog7.d.ts +4872 -0
  55. package/dist/presentation-types-DP_8jog7.d.ts.map +1 -0
  56. package/dist/read.d.ts +55 -0
  57. package/dist/read.d.ts.map +1 -0
  58. package/dist/read.js +4 -0
  59. package/dist/script.d.ts +581 -0
  60. package/dist/script.d.ts.map +1 -0
  61. package/dist/script.js +3741 -0
  62. package/dist/script.js.map +1 -0
  63. package/dist/shapes-BemroU-z.js +6951 -0
  64. package/dist/shapes-BemroU-z.js.map +1 -0
  65. package/dist/slide-js0QpRV-.d.ts +3873 -0
  66. package/dist/slide-js0QpRV-.d.ts.map +1 -0
  67. package/dist/text-CyetbF6p.js +11278 -0
  68. package/dist/text-CyetbF6p.js.map +1 -0
  69. package/dist/units-1kRzYShk.js +231 -0
  70. package/dist/units-1kRzYShk.js.map +1 -0
  71. package/dist/units-internal-Dg95w_YD.js +753 -0
  72. package/dist/units-internal-Dg95w_YD.js.map +1 -0
  73. package/dist/zip.d.ts +68 -0
  74. package/dist/zip.d.ts.map +1 -0
  75. package/dist/zip.js +163 -0
  76. package/dist/zip.js.map +1 -0
  77. package/package.json +152 -0
  78. package/skills/ts-pptx-upstream/SKILL.md +340 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-2022 Brent Ely
4
+ Copyright (c) 2026 shbernal
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,319 @@
1
+ # ts-pptx
2
+
3
+ > **`pptx-ts` is an alias.** It is the same package as
4
+ > [`@shbernal/ts-pptx`](https://www.npmjs.com/package/@shbernal/ts-pptx), published from the
5
+ > same commit at the same version with the same contents. Install one or the other,
6
+ > never both: two copies of this library in one dependency tree are two module
7
+ > registries, and state such as the diagnostic handler is per-copy. The scoped name is
8
+ > canonical, and the issue tracker, the changelog and every example below use it.
9
+
10
+ [![npm](https://img.shields.io/npm/v/%40shbernal%2Fts-pptx)](https://www.npmjs.com/package/@shbernal/ts-pptx)
11
+ [![weekly downloads](https://img.shields.io/npm/dw/%40shbernal%2Fts-pptx.svg?label=npm%20downloads&logo=npm)](https://www.npmjs.com/package/@shbernal/ts-pptx)
12
+ [![total downloads](https://img.shields.io/npm/dt/%40shbernal%2Fts-pptx.svg?label=npm%20total%20downloads&logo=npm)](https://www.npmjs.com/package/@shbernal/ts-pptx)
13
+ [![CI](https://github.com/shbernal/ts-pptx/actions/workflows/ci.yml/badge.svg)](https://github.com/shbernal/ts-pptx/actions/workflows/ci.yml)
14
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
15
+
16
+ ts-pptx generates PowerPoint `.pptx` files from TypeScript and modern
17
+ JavaScript. This project targets ESM package consumers, typed application code,
18
+ reproducible package verification, and agent-assisted OOXML development.
19
+
20
+ > **Lineage.** ts-pptx descends from [gitbrent/PptxGenJS](https://github.com/gitbrent/PptxGenJS)
21
+ > (MIT), detached at its v6.0.0 (June 2025) and developed independently since. It
22
+ > does not track, merge from, or mirror the original project, and pursues its own
23
+ > Node-first direction (see _Project Target_). The original work remains under its
24
+ > MIT license: see _License_ below.
25
+
26
+ ## Project Target
27
+
28
+ - Generate standards-based PowerPoint `.pptx` packages without requiring
29
+ PowerPoint at runtime.
30
+ - Support TypeScript-first workflows with checked declarations and modern
31
+ bundler resolution.
32
+ - Ship a small, explicit ESM package boundary for Node.js, Vite, React,
33
+ Angular, Electron, and similar modern toolchains.
34
+ - Keep OOXML changes grounded in fixtures, schema validation, and PowerPoint
35
+ compatibility evidence.
36
+ - Make the repository practical for human and agent-driven maintenance.
37
+
38
+ ## Install
39
+
40
+ ```bash
41
+ pnpm add @shbernal/ts-pptx
42
+ ```
43
+
44
+ ```bash
45
+ npm install @shbernal/ts-pptx
46
+ ```
47
+
48
+ ```bash
49
+ yarn add @shbernal/ts-pptx
50
+ ```
51
+
52
+ The unscoped name [`pptx-ts`](https://www.npmjs.com/package/pptx-ts) is an alias
53
+ for the same package: same contents, same version, published from the same
54
+ commit by the same workflow. Take it if a scoped name is awkward somewhere in
55
+ your toolchain. Install one or the other and never both, because two copies of
56
+ this library in one dependency tree are two module registries and state such as
57
+ the diagnostic handler is per-copy. The scoped name is canonical: the issue
58
+ tracker, the changelog and every example in these docs use it.
59
+
60
+ ### Installing an unreleased commit
61
+
62
+ Any commit is installable directly from GitHub, without waiting for a release:
63
+
64
+ ```bash
65
+ npm install github:shbernal/ts-pptx#<commit-sha>
66
+ ```
67
+
68
+ `master` (`github:shbernal/ts-pptx`) works too, but pin the sha: a branch spec
69
+ re-resolves to whatever is at the head of it when the lockfile is next written.
70
+
71
+ `dist/` is not committed, so this builds the package on install: your package
72
+ manager clones the repo, installs this package's `devDependencies`, and runs its
73
+ `prepare` script. That makes the install slow (a couple of minutes) and heavier
74
+ than a registry install, and it needs a working Node toolchain. It is meant for
75
+ trying a fix before it ships, not for production dependencies.
76
+
77
+ Note that `pres.version` reports the version in `package.json` at that commit, so
78
+ several different commits report the same number. The sha in your `package.json`
79
+ is what identifies the build.
80
+
81
+ ## Quick Start
82
+
83
+ ```ts
84
+ import TsPptx from "@shbernal/ts-pptx"
85
+
86
+ const pptx = new TsPptx()
87
+ const slide = pptx.addSlide()
88
+
89
+ slide.addText("Hello from ts-pptx", {
90
+ x: 1,
91
+ y: 1,
92
+ w: 8,
93
+ h: 1,
94
+ fontSize: 24,
95
+ color: "363636",
96
+ })
97
+
98
+ await pptx.writeFile({ fileName: "example.pptx" })
99
+ ```
100
+
101
+ ## What It Can Generate
102
+
103
+ - Slides, layouts, masters, sections, notes, and metadata.
104
+ - Text, tables, shapes, images, SVGs, charts, and media.
105
+ - Browser-downloadable, streamed, buffered, Blob, base64, or file outputs,
106
+ depending on the runtime.
107
+ - OOXML that is intended to open cleanly in Microsoft PowerPoint and other
108
+ `.pptx` consumers such as Keynote, LibreOffice Impress, and Google Slides
109
+ import.
110
+
111
+ ## Scope And Contributions
112
+
113
+ This project is **Node-first**: it generates and is tested without a browser or any
114
+ office application. Two areas are out of *active* maintenance scope, not because
115
+ they lack merit, but because there is no in-house use case driving them, so the
116
+ maintainer generally will not pick up bugs or feature requests there:
117
+
118
+ - **Live-DOM / browser-layout features**, anything whose answer comes from a
119
+ *rendered* page: real `offsetWidth` after layout, the resolved cascade, fonts as
120
+ the browser actually chose them. (Converting an HTML `<table>` is *not* in this
121
+ category: see [HTML tables → slides](#html-tables--slides) below. Only real
122
+ measurement needs a browser.)
123
+ - **Third-party office-suite interop quirks** that appear only after a file is
124
+ round-tripped through another application (for example, copy/paste inside WPS
125
+ Office, then opening in PowerPoint) when the generated package is itself valid
126
+ OOXML. The supported bar is that output opens cleanly in Microsoft PowerPoint.
127
+
128
+ **Contributions in these areas are welcome**: issues and pull requests are
129
+ encouraged even though the maintainer is not actively developing them. See
130
+ [`docs/project-target.md`](docs/project-target.md) for the full scope statement
131
+ and suggested testing approaches.
132
+
133
+ ## Hit A Bug? There Is A Skill For That
134
+
135
+ Most code that uses this library is written by an agent, and an agent that hits a
136
+ library defect will usually route around it silently, so the defect is never
137
+ reported and never fixed. `ts-pptx-upstream` is a skill that turns that moment into
138
+ a filed issue with a minimal reproduction, which is what becomes a permanent
139
+ regression test here. It ships inside the package, so it is already on disk:
140
+
141
+ ```bash
142
+ # Name the skill and the runtimes, and take the defaults: this is the form that
143
+ # completes unattended, which is how an agent will be running it.
144
+ npx skills add ./node_modules/@shbernal/ts-pptx -s '*' -a claude-code -a codex -a universal -y
145
+
146
+ npx skills add shbernal/ts-pptx # same flags, straight from the repo instead of node_modules
147
+ ```
148
+
149
+ Drop the flags for an interactive prompt if you are at a terminal yourself. Do not reach
150
+ for `--all` to avoid the prompt: it installs into every runtime the CLI knows about,
151
+ around seventy of them, and leaves an `agent/` directory at your repository root for
152
+ runtimes nobody there uses. Name the ones you have.
153
+
154
+ Two things about living with the installed copy. It is a copy, so **a version bump does
155
+ not update it**: re-run the command above, or `npx skills update ts-pptx-upstream`, in
156
+ the same commit as the bump. And if you track it, track `skills-lock.json` and ignore the
157
+ copy: `skills experimental_install` restores the file from that lock but creates none of
158
+ the runtime links, so it is a record, not a restore command.
159
+
160
+ It covers triage (is this ours, your deck's, or out of scope?), reducing a failure to
161
+ a script that builds its own deck, and (because presentations carry client names and
162
+ unreleased numbers) never uploading one to a public tracker. Once the reproduction
163
+ stands on its own it files without interrupting you, and tells you the issue number
164
+ afterwards. It also covers the far end of the cycle, which is the half that usually
165
+ rots: when a release lands, finding every workaround it retires and deleting them.
166
+
167
+ You do not need it to report something: <https://github.com/shbernal/ts-pptx/issues>
168
+ is open, and errors the library knows are its own fault print that link themselves.
169
+ See [errors](docs/errors.md#which-failures-are-worth-reporting) for which failures are
170
+ worth a report.
171
+
172
+ ## Runtime And Package Support
173
+
174
+ The package is ESM-only.
175
+
176
+ Supported package surface:
177
+
178
+ - `import TsPptx, { ShapeType } from "@shbernal/ts-pptx"` (enums, shared types, and
179
+ layout helpers ship from the main entry)
180
+ - `import { inspectPptx } from "@shbernal/ts-pptx/inspect"`
181
+ - `import { measureText } from "@shbernal/ts-pptx/measure"`
182
+ - `import { Presentation } from "@shbernal/ts-pptx/read"`
183
+ - `import { latexToOmml } from "@shbernal/ts-pptx/math"`
184
+ - `import { tableToSlides } from "@shbernal/ts-pptx/html"`
185
+ - `import TsPptx from "@shbernal/ts-pptx/node"`
186
+ - `import TsPptx from "@shbernal/ts-pptx/browser"`:
187
+ the bare specifier resolves to one of these two by export condition, so Node
188
+ and bundled browser apps get the right build without naming it. A runtime that
189
+ sets neither (Deno, Bun, edge workers) gets a runtime-agnostic build that
190
+ authors and exports bytes normally but has no `writeFile` destination; see
191
+ [Runtime And Package Support](docs/runtime-and-package-support.md#which-build-the-bare-import-gives-you).
192
+ - generated runtime and declaration artifacts under `dist/`
193
+ - Node.js `>=24`
194
+ - modern bundlers and module-aware app frameworks
195
+
196
+ Deliberately not supported:
197
+
198
+ - No CommonJS: no `require("@shbernal/ts-pptx")`, no CJS export condition, and no
199
+ `.cjs` artifact. Modern Node.js may provide `require()` interop for ESM, but it
200
+ is not a maintained API.
201
+ - No IIFE/global browser bundle: no classic-script global, no `dist/*.bundle.js`,
202
+ and no `dist/*.min.js`.
203
+
204
+ Use the package exports rather than direct `dist/` artifact paths.
205
+
206
+ See [runtime and package support](docs/runtime-and-package-support.md) for the
207
+ complete support contract.
208
+
209
+ ## HTML Tables → Slides
210
+
211
+ `@shbernal/ts-pptx/html` reproduces an existing HTML `<table>` as a PowerPoint
212
+ table, auto-paging across as many slides as its rows need. It works in the
213
+ browser and under Node with any DOM implementation, from one artifact.
214
+
215
+ ```ts
216
+ import { TsPptx } from '@shbernal/ts-pptx'
217
+ import { tableToSlides } from '@shbernal/ts-pptx/html'
218
+ import { Window } from 'happy-dom'
219
+
220
+ const win = new Window()
221
+ win.document.body.innerHTML = '<table id="report">…</table>'
222
+
223
+ const pptx = new TsPptx()
224
+ tableToSlides(pptx, win.document.getElementById('report'))
225
+ await pptx.writeFile({ fileName: 'report.pptx' })
226
+ ```
227
+
228
+ Pass the element itself and no global DOM is consulted at all. To pass a string
229
+ id instead, say which document it belongs to:
230
+
231
+ ```ts
232
+ tableToSlides(pptx, 'report', { document: win.document })
233
+ ```
234
+
235
+ In a browser, `options.document` defaults to the global `document`, so
236
+ `tableToSlides(pptx, 'report')` is enough. The equivalent method form,
237
+ `pptx.tableToSlides('report', options)`, remains on the browser build and
238
+ delegates to the same implementation.
239
+
240
+ **Column widths need a layout engine.** In a browser the columns are sized from
241
+ each cell's rendered `offsetWidth`, reproducing the table's real proportions.
242
+ Nothing outside a browser lays a table out, so `offsetWidth` is `0` there and
243
+ the conversion falls back in two steps: it uses the computed CSS `width`s when the
244
+ stylesheet states them for every column in one unit (all `px` or all `%`), and
245
+ an equal split when it does not.
246
+
247
+ The first step is a *fallback*, not a graceful loss of precision: `offsetWidth` is
248
+ the border box and computed `width` the content box, so padding alone can put the
249
+ two bases in different proportions. The same table can therefore come out with
250
+ different column widths in a browser and outside one.
251
+
252
+ To pin widths regardless of runtime, annotate the `<thead>` header cells, which
253
+ win outright on every path:
254
+
255
+ ```html
256
+ <thead>
257
+ <tr>
258
+ <th data-pptx-width="2.5">Name</th>
259
+ <th data-pptx-min-width="1">Qty</th>
260
+ </tr>
261
+ </thead>
262
+ ```
263
+
264
+ Everything else behaves the same wherever it runs: cell text (with `<br>` kept
265
+ as a line break), `colspan`/`rowspan`, computed colors, weight, alignment,
266
+ padding and borders, and auto-paging.
267
+
268
+ ## Documentation
269
+
270
+ The full documentation site is published at
271
+ **<https://shbernal.github.io/ts-pptx/>**, including the generated API reference.
272
+
273
+ - [Documentation index](docs/README.md)
274
+ - [Project target](docs/project-target.md)
275
+ - [Runtime and package support](docs/runtime-and-package-support.md)
276
+ - [Development guide](docs/development.md)
277
+ - [Testing guide](docs/testing.md)
278
+ - [Agent development guide](docs/agent-development.md)
279
+ - [OOXML agent context](docs/ooxml-agent-context.md)
280
+ - [Evidence and fixtures](docs/evidence-and-fixtures.md)
281
+
282
+ ## Repository Development
283
+
284
+ This repository uses `pnpm` and requires Node.js `>=24`.
285
+
286
+ ```bash
287
+ pnpm install
288
+ pnpm run verify
289
+ ```
290
+
291
+ OOXML serialization changes should also add or update a schema fixture in
292
+ `test/schema-cases.js`. The schema suite validates through `ooxml-validate`, which
293
+ fetches and caches its oracle binary on first use, so there is nothing to install.
294
+
295
+ Package-boundary changes should run:
296
+
297
+ ```bash
298
+ pnpm run check:package
299
+ ```
300
+
301
+ ## Demos
302
+
303
+ - `demos/showcases` builds the two flagship decks from one command.
304
+ - `demos/node` exercises Node.js ESM generation and stream output.
305
+ - The [demos page](https://shbernal.github.io/ts-pptx/demos) builds the quarterly review in
306
+ your browser and previews the slides: nothing to clone.
307
+
308
+ ## Relationship To Upstream
309
+
310
+ ts-pptx builds on the original work of Brent Ely and the gitbrent/PptxGenJS
311
+ contributors. The modernized package target is intentionally narrower than the
312
+ original in order to simplify the runtime contract and keep maintenance focused.
313
+
314
+ ## License
315
+
316
+ Copyright (c) 2015-2022 Brent Ely.
317
+ Modifications copyright (c) 2026 shbernal.
318
+
319
+ [MIT](LICENSE)