pptx-templates 0.3.5 → 0.3.7

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 (37) hide show
  1. package/AI-INSTRUCTOR.md +134 -2
  2. package/CHANGELOG.md +60 -1
  3. package/README.md +1 -0
  4. package/dist/extensions/hide-slide/index.d.ts +44 -0
  5. package/dist/extensions/hide-slide/index.js +244 -0
  6. package/dist/extensions/hide-slide/index.js.map +1 -0
  7. package/dist/extensions/index.d.ts +3 -1
  8. package/dist/extensions/index.js +4 -1
  9. package/dist/extensions/index.js.map +1 -1
  10. package/dist/extensions/template-lint/lint.js +53 -1
  11. package/dist/extensions/template-lint/lint.js.map +1 -1
  12. package/dist/extensions/template-logic/commands.js +5 -0
  13. package/dist/extensions/template-logic/commands.js.map +1 -1
  14. package/dist/extensions/template-logic/renderer.d.ts +3 -0
  15. package/dist/extensions/template-logic/renderer.js +20 -0
  16. package/dist/extensions/template-logic/renderer.js.map +1 -1
  17. package/dist/extensions/template-logic/types.d.ts +10 -2
  18. package/dist/extensions/template-render/index.d.ts +6 -0
  19. package/dist/extensions/template-render/index.js +46 -5
  20. package/dist/extensions/template-render/index.js.map +1 -1
  21. package/dist/extensions/text-flow/flow.d.ts +25 -0
  22. package/dist/extensions/text-flow/flow.js +82 -3
  23. package/dist/extensions/text-flow/flow.js.map +1 -1
  24. package/dist/extensions/text-flow/index.d.ts +1 -1
  25. package/dist/extensions/text-flow/index.js +3 -1
  26. package/dist/extensions/text-flow/index.js.map +1 -1
  27. package/dist/helper/content-tracker.js +6 -0
  28. package/dist/helper/content-tracker.js.map +1 -1
  29. package/dist/helper/count-helper.d.ts +12 -0
  30. package/dist/helper/count-helper.js +27 -2
  31. package/dist/helper/count-helper.js.map +1 -1
  32. package/dist/helper/xml-relationship-helper.js +5 -2
  33. package/dist/helper/xml-relationship-helper.js.map +1 -1
  34. package/dist/shapes/ole.d.ts +16 -1
  35. package/dist/shapes/ole.js +58 -22
  36. package/dist/shapes/ole.js.map +1 -1
  37. package/package.json +1 -1
package/AI-INSTRUCTOR.md CHANGED
@@ -713,6 +713,7 @@ pres.addSlide('TextReplace.pptx', 1, (slide) => {
713
713
  | `{{HTML expr}}` | Insert HTML as formatted paragraphs (bold, italic, lists, links, …) through the [HTML converter](https://daborsten.github.io/pptx-templates/text.md) |
714
714
  | `{{LINK expr}}` | Insert a hyperlink. `expr` is a URL or `({ url, label })`. A number as `url` links to that slide of the output |
715
715
  | `{{IMAGE expr}}` | Place a picture where the shape is (see [Images](#images)). Needs `slide.modify` |
716
+ | `{{HIDE-SLIDE expr}}` | In the speaker notes: `renderDeck` leaves the slide out when `expr` is true (see [Hide Slides](https://daborsten.github.io/pptx-templates/hide-slide.md)). Anywhere else it is removed and does nothing |
716
717
 
717
718
  Keywords are case-insensitive. A block can sit inside one paragraph
718
719
  (`Status: {{IF ok}}fine{{ELSE}}broken{{END-IF}}`) or span paragraphs. A
@@ -1228,6 +1229,41 @@ pres.addSlide('Columns.pptx', 1, (slide) => {
1228
1229
  });
1229
1230
  ```
1230
1231
 
1232
+ ### Continuing on another slide
1233
+
1234
+ `flowContinue(list)` is `list` without the entries that `flow()` shows on
1235
+ the slides before it in the output of `renderDeck`. A first slide can show
1236
+ as many projects as fit into one text box, and a second slide the rest, one
1237
+ per column:
1238
+
1239
+ ```text
1240
+ {{FOR p IN flow(projects)}}
1241
+ {{p.name}}
1242
+ {{END-FOR}}
1243
+ ```
1244
+
1245
+ ```text
1246
+ {{FOR p IN flow(flowContinue(projects), 1)}}
1247
+ {{p.name}}
1248
+ {{END-FOR}}
1249
+ ```
1250
+
1251
+ Without more, the first slide would repeat until every project is on it.
1252
+ `{{HIDE-SLIDE flowPage > 1}}` in its speaker notes keeps only its first
1253
+ copy (see [Hide Slides](https://daborsten.github.io/pptx-templates/hide-slide.md)); entries of hidden copies count
1254
+ as not shown. The second slide repeats as usual while projects are left.
1255
+
1256
+ - Objects are compared with `===`: the objects of your data count as shown
1257
+ wherever `flow()` showed them. Strings and numbers count only for the
1258
+ same list, `projects` itself or a `flowContinue(projects)`; of equal ones,
1259
+ as many are skipped as were shown. A list built anew in the template
1260
+ (`projects.map(…)`, `filter(…)`) is a different list.
1261
+ - With the `flowPage` option, each slide shows that part of its lists, and
1262
+ `flowContinue()` goes on after it.
1263
+ - `{{HIDE-SLIDE !flowContinue(projects).length}}` leaves the second slide
1264
+ out when the first one shows every project.
1265
+ - Outside `renderDeck`, `flowContinue(list)` is the whole list.
1266
+
1231
1267
  ### Rules for the template
1232
1268
 
1233
1269
  - `{{FOR … IN flow(…)}}` and `{{END-FOR}}` each need a paragraph of their own,
@@ -1254,11 +1290,107 @@ pres.addSlide('Columns.pptx', 1, (slide) => {
1254
1290
  matters.
1255
1291
  - Hyphenation, kerning and right-to-left or East Asian line breaking rules
1256
1292
  are not taken into account.
1257
- - `flow`, `flowRest`, `flowPage` and `flowPages` are built in. The same name
1293
+ - `flow`, `flowRest`, `flowContinue`, `flowPage` and `flowPages` are built in. The same name
1258
1294
  in your data or in `additionalJsContext` takes precedence.
1259
1295
  - To count the slides, `renderDeck` and `countFlowPages` render the slide
1260
1296
  once more. Functions in your data are called again then.
1261
1297
 
1298
+ ## Hide Slides
1299
+
1300
+ Some slides only make sense with the right data: a slide for further
1301
+ projects when there are more than two, a discount slide for VIP customers.
1302
+ Write `{{HIDE-SLIDE condition}}` into the **speaker notes** of the slide,
1303
+ and `renderDeck` leaves the slide out when the condition is true:
1304
+
1305
+ ```text
1306
+ {{HIDE-SLIDE projects.length <= 2}}
1307
+ ```
1308
+
1309
+ ```ts
1310
+ import fs from 'fs';
1311
+ import { renderDeck } from 'pptx-templates';
1312
+
1313
+ const projects = [{ name: 'Portal' }, { name: 'App' }];
1314
+
1315
+ // The slide with the tag in its notes is not in the output
1316
+ fs.writeFileSync(
1317
+ 'output/Projects.pptx',
1318
+ await renderDeck('templates/Projects.pptx', { projects }),
1319
+ );
1320
+ ```
1321
+
1322
+ The condition is an [expression](https://daborsten.github.io/pptx-templates/template-logic.md#expressions) like the
1323
+ one of `{{IF …}}`, with the data, `additionalJsContext` and the options of
1324
+ the render (`strict`, `fixSmartQuotes`, other delimiters, `errorHandler`).
1325
+ `pptx-templates render` on the command line does the same.
1326
+
1327
+ - `{{HIDE-SLIDE}}` without a condition always hides the slide, for example
1328
+ a slide that is still being worked on.
1329
+ - With several tags in the notes, the slide is left out as soon as one of
1330
+ them is true.
1331
+ - The tags are removed from the notes of the output; the rest of the notes
1332
+ stays. A paragraph that held nothing but the tag goes as well.
1333
+ - A hidden slide leaves nothing behind in the output file: neither its
1334
+ notes nor its embedded objects.
1335
+ - When every slide is hidden, the output has no slides.
1336
+
1337
+ ### Why the speaker notes
1338
+
1339
+ The tag decides about the whole slide, not about a piece of text, so it
1340
+ belongs to the slide once. The notes exist once per slide and are not part
1341
+ of the design. On the slide itself, in a text box or a table,
1342
+ `{{HIDE-SLIDE …}}` is removed with a warning and does nothing; the
1343
+ [linter](https://daborsten.github.io/pptx-templates/template-lint.md) reports it there as `unsupported-location`.
1344
+ Other tags in the notes are not rendered and stay as they are.
1345
+
1346
+ ### Copies of a flow() slide
1347
+
1348
+ A slide whose [`flow()`](https://daborsten.github.io/pptx-templates/text-flow.md) list needs more than one slide is
1349
+ repeated by `renderDeck`. The condition is evaluated for each copy, with
1350
+ `flowPage` (1, 2, …) and `flowPages`:
1351
+
1352
+ ```text
1353
+ {{HIDE-SLIDE flowPage > 3}}
1354
+ ```
1355
+
1356
+ keeps the first three copies of the slide and leaves out the rest.
1357
+ Each copy has its own speaker notes and its own copy of the slide's
1358
+ embedded objects (OLE objects, embedded Excel or Word documents, charts
1359
+ with their workbooks).
1360
+
1361
+ ### With addSlide
1362
+
1363
+ `renderTemplate` renders one slide and cannot take it out of the deck.
1364
+ With your own `addSlide` calls, ask `isSlideHidden` first and skip the
1365
+ slide:
1366
+
1367
+ ```ts
1368
+ import { isSlideHidden, modify } from 'pptx-templates';
1369
+
1370
+ const data = { projects: [{ name: 'Portal' }] };
1371
+
1372
+ if (!(await isSlideHidden('templates/Projects.pptx', 2, data))) {
1373
+ pres.addSlide('Projects.pptx', 2, (slide) => {
1374
+ slide.modify(modify.renderTemplate(data));
1375
+ });
1376
+ }
1377
+ ```
1378
+
1379
+ It takes the options of `renderTemplate`, plus `flowPage` (0-based) and
1380
+ `flowPages` for a condition that depends on them. `addSlide` copies the
1381
+ notes as they are, tag included.
1382
+
1383
+ ### Good to know
1384
+
1385
+ - An error in the condition rejects `renderDeck` with a
1386
+ `TemplateRenderError` that starts with the slide number
1387
+ (`slide 2: {{HIDE-SLIDE check()}}: …`), unless `errorHandler` returns a
1388
+ value for it.
1389
+ - The tag must be in one paragraph of the notes. PowerPoint may split it
1390
+ into several runs (spell check); that is fine.
1391
+ - `flow()` and `flowRest()` in the condition do not distribute anything:
1392
+ `flow(list)` is the whole list there.
1393
+
1262
1394
  ## Shape Geometry
1263
1395
 
1264
1396
  Every shape and picture in PowerPoint has a geometry: a rectangle, an
@@ -1485,7 +1617,7 @@ npx pptx-templates lint --config other.json
1485
1617
  | `unmatched-tag` | error | `END-IF`, `END-FOR`, `ELSE`, `ELSE-IF` without an opening tag, or an `ELSE` after `ELSE` |
1486
1618
  | `unknown-alias` | error | `{{*name}}` without `{{ALIAS name …}}` on the slide |
1487
1619
  | `unsupported-location` | error | `IMAGE` in a table cell, `IMAGE` in a placeholder that inherits its position from the layout, `ELSE` that spans table rows |
1488
- | `unsupported-location` | warning | Tags in slide layouts, masters, speaker notes, charts and SmartArt. `renderTemplate` does not render them, so they stay as they are |
1620
+ | `unsupported-location` | warning | Tags in slide layouts, masters, speaker notes, charts and SmartArt. `renderTemplate` does not render them, so they stay as they are. `{{HIDE-SLIDE …}}` belongs into the speaker notes (checked there like any expression) and is reported everywhere else |
1489
1621
  | `unknown-variable` | warning | A name that is not in `data`/`schema`/`additionalJsContext` and not defined by `FOR`, `EXEC` or an arrow function |
1490
1622
  | `unknown-property` | warning | A property path that does not exist, including methods: `user.name.lenght` on a string |
1491
1623
  | `not-a-list` | warning | `FOR` over a value that is not a list in the data |
package/CHANGELOG.md CHANGED
@@ -6,6 +6,63 @@ semver, with the pre-1.0 convention that **breaking changes bump the minor**.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.3.7] - 2026-11-18
10
+
11
+ ### Fixed
12
+
13
+ - A slide with an embedded Office document (Excel worksheet, Word document:
14
+ a `package` relationship, as PowerPoint inserts them) can be copied. Its
15
+ relationship matched every prefix, so the slide was taken for a chart and
16
+ `addSlide`/`renderDeck` failed with `Could not find file
17
+ ppt/charts/chart0.xml`.
18
+ - Embedded documents are copied with their slide. Before, only `oleObject`
19
+ relationships were copied; an embedded worksheet kept pointing at the
20
+ template's file, which `renderDeck` (cleanup) then deleted.
21
+ - Copied OLE objects no longer overwrite each other. The copy was named
22
+ after the slide's relationship id (`oleObjectrId9-created.bin`), which
23
+ repeats from slide to slide: two slides with different objects ended up
24
+ with the same file. Copies are now named after the source with the next
25
+ free number (`oleObject2.bin`, `Microsoft_Excel_Worksheet1.xlsx`), keep
26
+ their extension (`.xlsm`, `.docx`, … were renamed to `.bin`) and the
27
+ content type of the template. Linked objects (`TargetMode="External"`)
28
+ are left as they are instead of failing.
29
+ - A copied `chartEx` chart (waterfall, sunburst, …) no longer overwrites a
30
+ chart of the deck: the chart counter skipped `chartEx` parts, so the copy
31
+ reused `chartEx1.xml`/`style1.xml`/`colors1.xml` and `[Content_Types].xml`
32
+ listed them twice.
33
+ - A deck written by pptx-templates can be loaded again as root and get new
34
+ slides (e.g. the output of `renderDeck`, processed further with
35
+ `addSlide`/`modifyElement`). Its slide parts start at `slide4.xml` or
36
+ higher; new slides were numbered after the slide count, overwrote its
37
+ slides and registered them twice in `[Content_Types].xml`, and PowerPoint
38
+ offered to repair the file.
39
+ - With `removeExistingSlides` and `cleanup` (as in `renderDeck`), the
40
+ speaker notes and rels of the removed template slides are deleted too.
41
+ The notes of a slide left out with `{{HIDE-SLIDE …}}` were still in the
42
+ output file.
43
+
44
+ ## [0.3.6] - 2026-11-17
45
+
46
+ ### Added
47
+
48
+ - `{{HIDE-SLIDE condition}}` in the speaker notes of a slide: `renderDeck`
49
+ (and `pptx-templates render`) leaves the slide out when the condition is
50
+ true. Without a condition the slide is always left out; with several tags,
51
+ one true condition is enough. For the copies of a `flow()` slide the
52
+ condition is evaluated per copy, with `flowPage` and `flowPages`. The tag
53
+ is removed from the notes of the output. On the slide itself the tag is
54
+ removed with a warning and does nothing.
55
+ - `isSlideHidden(pptx, slide, data, options)` tells `addSlide` users
56
+ whether to skip a slide.
57
+ - `flowContinue(list)`: the entries of `list` that `flow()` does not show on
58
+ the slides before it in `renderDeck`, hidden copies not counted. A slide
59
+ with `flow(flowContinue(projects), 1)` goes on where an earlier slide's
60
+ `flow(projects)` stopped.
61
+ - The linter checks `{{HIDE-SLIDE …}}` in the speaker notes like any
62
+ expression (syntax, unknown names) and reports it as
63
+ `unsupported-location` anywhere else. `listTemplateCommands` lists it
64
+ with the type `HIDE-SLIDE`.
65
+
9
66
  ## [0.3.5] - 2026-11-16
10
67
 
11
68
  ### Added
@@ -292,7 +349,9 @@ for that history.
292
349
  into one `.png` part. The fallback now gets the same placeholder PNG that
293
350
  pptxgenjs 3.12 wrote.
294
351
 
295
- [Unreleased]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.5...HEAD
352
+ [Unreleased]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.7...HEAD
353
+ [0.3.7]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.6...v0.3.7
354
+ [0.3.6]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.5...v0.3.6
296
355
  [0.3.5]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.4...v0.3.5
297
356
  [0.3.4]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.3...v0.3.4
298
357
  [0.3.3]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.2...v0.3.3
package/README.md CHANGED
@@ -139,6 +139,7 @@ third.
139
139
  | `{{HTML expr}}` | Insert HTML as formatted text: bold, italic, lists, links |
140
140
  | `{{LINK expr}}` | Insert a hyperlink, to a URL or to a slide of the output |
141
141
  | `{{IMAGE expr}}` | Place a picture where the text box is, optionally cropped to a shape with a border |
142
+ | `{{HIDE-SLIDE expr}}` | In the speaker notes: leave the slide out of the deck when `expr` is true |
142
143
 
143
144
  Expressions are JavaScript without the dangerous parts: property paths,
144
145
  comparisons, `&&`, `||`, `??`, `? :`, arrow functions
@@ -0,0 +1,44 @@
1
+ import JSZip from 'jszip';
2
+ import { XmlDocument } from '../../types/xml-types';
3
+ import type { RenderTemplateOptions, TemplateData } from '../template-logic/types';
4
+ /** One `{{HIDE-SLIDE …}}` of a slide's notes. */
5
+ export type HideSlideCondition = {
6
+ /** The tag as written, e.g. `{{HIDE-SLIDE !projects.length}}`. */
7
+ tag: string;
8
+ /** The condition; empty: always hide. */
9
+ code: string;
10
+ };
11
+ export type IsSlideHiddenOptions = RenderTemplateOptions & {
12
+ /**
13
+ * How many slides the `flow()` lists of the slide need, for `flowPages`
14
+ * in the condition (`countFlowPages`). Default: 1
15
+ */
16
+ flowPages?: number;
17
+ };
18
+ /** Path of the notes part of `ppt/slides/slide<n>.xml`, if it has notes. */
19
+ export declare const notesPartOf: (zip: JSZip, slide: number) => Promise<string | undefined>;
20
+ /** The `{{HIDE-SLIDE …}}` tags in the speaker notes of a slide. */
21
+ export declare const hideSlideConditions: (zip: JSZip, slide: number, options?: RenderTemplateOptions) => Promise<HideSlideCondition[]>;
22
+ /**
23
+ * Whether one of the conditions is true. `page` is 0-based, as the
24
+ * `flowPage` option; the condition sees it 1-based, as in the slide.
25
+ */
26
+ export declare const evaluateHideConditions: (conditions: HideSlideCondition[], data: TemplateData, options: RenderTemplateOptions, page: number, pages: number) => Promise<boolean>;
27
+ /** A TemplateRenderError of a condition, its message led by the slide. */
28
+ export declare const withSlideNumber: (error: unknown, slide: number) => unknown;
29
+ /**
30
+ * Whether `renderDeck` leaves a slide out: one of the `{{HIDE-SLIDE …}}`
31
+ * tags in its speaker notes is true with this data. For slides added with
32
+ * `addSlide`: skip the `addSlide` call when it returns true.
33
+ *
34
+ * @param pptx Path to a .pptx file or its contents.
35
+ * @param slide 1-based number of the slide in the template.
36
+ */
37
+ export declare const isSlideHidden: (pptx: string | Buffer | Uint8Array | ArrayBuffer, slide: number, data: TemplateData, options?: IsSlideHiddenOptions) => Promise<boolean>;
38
+ /**
39
+ * Removes the `{{HIDE-SLIDE …}}` tags from a notes part; a paragraph that
40
+ * held nothing else goes as well. Returns whether anything changed.
41
+ */
42
+ export declare const stripHideSlideTags: (doc: XmlDocument, options?: RenderTemplateOptions) => boolean;
43
+ /** stripHideSlideTags for every notes part of a deck. */
44
+ export declare const stripHideSlideTagsInDeck: (zip: JSZip, options?: RenderTemplateOptions) => Promise<void>;
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.stripHideSlideTagsInDeck = exports.stripHideSlideTags = exports.isSlideHidden = exports.withSlideNumber = exports.evaluateHideConditions = exports.hideSlideConditions = exports.notesPartOf = void 0;
49
+ /**
50
+ * `{{HIDE-SLIDE condition}}` in the speaker notes of a slide: `renderDeck`
51
+ * leaves the slide out when the condition is true. See docs/hide-slide.md.
52
+ */
53
+ const fs_1 = __importDefault(require("fs"));
54
+ const jszip_1 = __importDefault(require("jszip"));
55
+ const xmldom_1 = require("@xmldom/xmldom");
56
+ const ppt_paths_1 = require("../../helper/ppt-paths");
57
+ const commands_1 = require("../template-logic/commands");
58
+ const expression_1 = require("../template-logic/expression");
59
+ const flow_1 = require("../text-flow/flow");
60
+ const NOTES_REL = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide';
61
+ const parseXml = (xml) => new xmldom_1.DOMParser().parseFromString(xml, 'application/xml');
62
+ const elements = (parent, tagName) => Array.from(parent.getElementsByTagName(tagName));
63
+ /** The text of a paragraph, runs joined (a tag can be split across runs). */
64
+ const paragraphText = (paragraph) => elements(paragraph, 'a:t')
65
+ .map((t) => t.textContent)
66
+ .join('');
67
+ /** The HIDE-SLIDE tags in `text`; other tags and invalid ones are skipped. */
68
+ const hideTagsIn = (text, syntax, options) => Array.from(text.matchAll(syntax.pattern)).flatMap((m) => {
69
+ if ((0, commands_1.isTableMarker)(m[1]))
70
+ return [];
71
+ const inner = options.fixSmartQuotes ? (0, commands_1.fixSmartQuotes)(m[1]) : m[1];
72
+ try {
73
+ const command = (0, commands_1.parseCommand)(inner, m[0]);
74
+ return command.type === 'HIDE-SLIDE'
75
+ ? [{ tag: m[0], code: command.code }]
76
+ : [];
77
+ }
78
+ catch (_a) {
79
+ return [];
80
+ }
81
+ });
82
+ /** Path of the notes part of `ppt/slides/slide<n>.xml`, if it has notes. */
83
+ const notesPartOf = (zip, slide) => __awaiter(void 0, void 0, void 0, function* () {
84
+ var _a, _b;
85
+ const rels = yield ((_a = zip.file(ppt_paths_1.PptPaths.slideRels(slide))) === null || _a === void 0 ? void 0 : _a.async('string'));
86
+ if (!rels)
87
+ return undefined;
88
+ const rel = elements(parseXml(rels), 'Relationship').find((r) => r.getAttribute('Type') === NOTES_REL);
89
+ const target = rel === null || rel === void 0 ? void 0 : rel.getAttribute('Target');
90
+ if (!target)
91
+ return undefined;
92
+ if (target.startsWith('/'))
93
+ return target.slice(1);
94
+ const n = (_b = /notesSlide(\d+)\.xml$/.exec(target)) === null || _b === void 0 ? void 0 : _b[1];
95
+ return n ? ppt_paths_1.PptPaths.notesSlide(Number(n)) : undefined;
96
+ });
97
+ exports.notesPartOf = notesPartOf;
98
+ /** The `{{HIDE-SLIDE …}}` tags in the speaker notes of a slide. */
99
+ const hideSlideConditions = (zip_1, slide_1, ...args_1) => __awaiter(void 0, [zip_1, slide_1, ...args_1], void 0, function* (zip, slide, options = {}) {
100
+ var _a;
101
+ const part = yield (0, exports.notesPartOf)(zip, slide);
102
+ const xml = part && (yield ((_a = zip.file(part)) === null || _a === void 0 ? void 0 : _a.async('string')));
103
+ if (!xml)
104
+ return [];
105
+ const syntax = (0, commands_1.tagSyntax)(options);
106
+ return elements(parseXml(xml), 'a:p').flatMap((p) => hideTagsIn(paragraphText(p), syntax, options));
107
+ });
108
+ exports.hideSlideConditions = hideSlideConditions;
109
+ /** A read-only scope: data, then additionalJsContext, then the built-ins. */
110
+ const scopeOf = (layers) => ({
111
+ lookup(name) {
112
+ for (const vars of layers) {
113
+ if (vars && Object.prototype.hasOwnProperty.call(vars, name)) {
114
+ return { found: true, value: vars[name] };
115
+ }
116
+ }
117
+ return { found: false };
118
+ },
119
+ });
120
+ /**
121
+ * Whether one of the conditions is true. `page` is 0-based, as the
122
+ * `flowPage` option; the condition sees it 1-based, as in the slide.
123
+ */
124
+ const evaluateHideConditions = (conditions, data, options, page, pages) => __awaiter(void 0, void 0, void 0, function* () {
125
+ var _a, _b, _c;
126
+ if (!conditions.length)
127
+ return false;
128
+ const scope = scopeOf([
129
+ data !== null && data !== void 0 ? data : {},
130
+ (_a = options.additionalJsContext) !== null && _a !== void 0 ? _a : {},
131
+ {
132
+ flowPage: page + 1,
133
+ flowPages: pages,
134
+ // The lists are not distributed here: flow() is the list itself
135
+ flow: (list) => list,
136
+ flowRest: () => [],
137
+ flowContinue: (list) => { var _a; return ((_a = options.flowShown) !== null && _a !== void 0 ? _a : new flow_1.FlowShown()).continue(list); },
138
+ },
139
+ ]);
140
+ const evaluation = {
141
+ strict: (_b = options.strict) !== null && _b !== void 0 ? _b : false,
142
+ allowStringPatterns: (_c = options.allowStringPatterns) !== null && _c !== void 0 ? _c : false,
143
+ };
144
+ for (const { tag, code } of conditions) {
145
+ if (!code)
146
+ return true;
147
+ let value;
148
+ try {
149
+ value = yield new expression_1.TemplateExpression(code).evaluate(scope, evaluation);
150
+ }
151
+ catch (error) {
152
+ if (!options.errorHandler) {
153
+ const message = error instanceof Error ? error.message : String(error);
154
+ // Loaded here: the renderer imports src/index.ts (import cycle)
155
+ const { TemplateRenderError } = yield Promise.resolve().then(() => __importStar(require('../template-logic/renderer')));
156
+ throw new TemplateRenderError(`${tag}: ${message}`);
157
+ }
158
+ value = yield options.errorHandler(error, code);
159
+ }
160
+ if (value)
161
+ return true;
162
+ }
163
+ return false;
164
+ });
165
+ exports.evaluateHideConditions = evaluateHideConditions;
166
+ /** A TemplateRenderError of a condition, its message led by the slide. */
167
+ const withSlideNumber = (error, slide) => {
168
+ if (error instanceof Error && error.name === 'TemplateRenderError') {
169
+ error.message = `slide ${slide}: ${error.message}`;
170
+ }
171
+ return error;
172
+ };
173
+ exports.withSlideNumber = withSlideNumber;
174
+ /**
175
+ * Whether `renderDeck` leaves a slide out: one of the `{{HIDE-SLIDE …}}`
176
+ * tags in its speaker notes is true with this data. For slides added with
177
+ * `addSlide`: skip the `addSlide` call when it returns true.
178
+ *
179
+ * @param pptx Path to a .pptx file or its contents.
180
+ * @param slide 1-based number of the slide in the template.
181
+ */
182
+ const isSlideHidden = (pptx_1, slide_1, data_1, ...args_1) => __awaiter(void 0, [pptx_1, slide_1, data_1, ...args_1], void 0, function* (pptx, slide, data, options = {}) {
183
+ var _a, _b;
184
+ const content = typeof pptx === 'string' ? yield fs_1.default.promises.readFile(pptx) : pptx;
185
+ const zip = yield jszip_1.default.loadAsync(content);
186
+ const conditions = yield (0, exports.hideSlideConditions)(zip, slide, options);
187
+ try {
188
+ return yield (0, exports.evaluateHideConditions)(conditions, data, options, (_a = options.flowPage) !== null && _a !== void 0 ? _a : 0, (_b = options.flowPages) !== null && _b !== void 0 ? _b : 1);
189
+ }
190
+ catch (error) {
191
+ throw (0, exports.withSlideNumber)(error, slide);
192
+ }
193
+ });
194
+ exports.isSlideHidden = isSlideHidden;
195
+ /**
196
+ * Removes the `{{HIDE-SLIDE …}}` tags from a notes part; a paragraph that
197
+ * held nothing else goes as well. Returns whether anything changed.
198
+ */
199
+ const stripHideSlideTags = (doc, options = {}) => {
200
+ const syntax = (0, commands_1.tagSyntax)(options);
201
+ const strip = (text) => text.replace(syntax.pattern, (raw) => hideTagsIn(raw, syntax, options).length ? '' : raw);
202
+ let changed = false;
203
+ elements(doc, 'a:p').forEach((paragraph) => {
204
+ const before = paragraphText(paragraph);
205
+ if (!hideTagsIn(before, syntax, options).length)
206
+ return;
207
+ changed = true;
208
+ const texts = elements(paragraph, 'a:t');
209
+ // Tags within one run: removed there, the formatting stays
210
+ texts.forEach((t) => {
211
+ t.textContent = strip(t.textContent);
212
+ });
213
+ // Tags split across runs: the paragraph's text goes into its first run
214
+ const joined = paragraphText(paragraph);
215
+ if (hideTagsIn(joined, syntax, options).length) {
216
+ texts.forEach((t, i) => {
217
+ t.textContent = i === 0 ? strip(joined) : '';
218
+ });
219
+ }
220
+ const body = paragraph.parentNode;
221
+ const isOnly = elements(body, 'a:p').length === 1;
222
+ if (paragraphText(paragraph).trim() === '' && !isOnly) {
223
+ body.removeChild(paragraph);
224
+ }
225
+ });
226
+ return changed;
227
+ };
228
+ exports.stripHideSlideTags = stripHideSlideTags;
229
+ /** stripHideSlideTags for every notes part of a deck. */
230
+ const stripHideSlideTagsInDeck = (zip_1, ...args_1) => __awaiter(void 0, [zip_1, ...args_1], void 0, function* (zip, options = {}) {
231
+ const parts = Object.keys(zip.files).filter((name) => /^ppt\/notesSlides\/notesSlide\d+\.xml$/.test(name));
232
+ for (const part of parts) {
233
+ const xml = yield zip.file(part).async('string');
234
+ // Cheap pre-check; the keyword is case-insensitive
235
+ if (!/hide/i.test(xml))
236
+ continue;
237
+ const doc = parseXml(xml);
238
+ if ((0, exports.stripHideSlideTags)(doc, options)) {
239
+ zip.file(part, new xmldom_1.XMLSerializer().serializeToString(doc));
240
+ }
241
+ }
242
+ });
243
+ exports.stripHideSlideTagsInDeck = stripHideSlideTagsInDeck;
244
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/hide-slide/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,IAAA,0BAAkB,EAAC,GAAG,EAAE,OAAO,CAAC,EAAE,CAAC;YACrC,GAAG,CAAC,IAAI,CACN,IAAI,EACJ,IAAI,sBAAa,EAAE,CAAC,iBAAiB,CACnC,GAAmE,CACpE,CACF,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAA,CAAC;AArBW,QAAA,wBAAwB,4BAqBnC"}
@@ -8,6 +8,8 @@ export * from './template-logic';
8
8
  export * from './template-lint';
9
9
  export { renderDeck, countFlowPages } from './template-render';
10
10
  export type { RenderDeckOptions } from './template-render';
11
- export { FlowCache } from './text-flow';
11
+ export { FlowCache, FlowShown } from './text-flow';
12
+ export { isSlideHidden } from './hide-slide';
13
+ export type { IsSlideHiddenOptions } from './hide-slide';
12
14
  export { ShapePresets } from './shape-geometry';
13
15
  export type { ShapePreset, RoundedShapePreset, CornerRadius, ShapeAdjustments, ImageBorder, } from './shape-geometry';
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.ShapePresets = exports.FlowCache = exports.countFlowPages = exports.renderDeck = exports.extensionModifiers = void 0;
17
+ exports.ShapePresets = exports.isSlideHidden = exports.FlowShown = exports.FlowCache = exports.countFlowPages = exports.renderDeck = exports.extensionModifiers = void 0;
18
18
  /**
19
19
  * Fork extensions (not part of upstream singerla/pptx-automizer).
20
20
  *
@@ -37,6 +37,9 @@ Object.defineProperty(exports, "renderDeck", { enumerable: true, get: function (
37
37
  Object.defineProperty(exports, "countFlowPages", { enumerable: true, get: function () { return template_render_1.countFlowPages; } });
38
38
  var text_flow_1 = require("./text-flow");
39
39
  Object.defineProperty(exports, "FlowCache", { enumerable: true, get: function () { return text_flow_1.FlowCache; } });
40
+ Object.defineProperty(exports, "FlowShown", { enumerable: true, get: function () { return text_flow_1.FlowShown; } });
41
+ var hide_slide_1 = require("./hide-slide");
42
+ Object.defineProperty(exports, "isSlideHidden", { enumerable: true, get: function () { return hide_slide_1.isSlideHidden; } });
40
43
  var shape_geometry_2 = require("./shape-geometry");
41
44
  Object.defineProperty(exports, "ShapePresets", { enumerable: true, get: function () { return shape_geometry_2.ShapePresets; } });
42
45
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,qDAAkD;AAClD,qDAAgE;AAEhE,iEAAiE;AACpD,QAAA,kBAAkB,GAAG;IAChC,cAAc,EAAd,+BAAc;IACd,WAAW,EAAX,4BAAW;IACX,eAAe,EAAf,gCAAe;CAChB,CAAC;AAEF,mDAAiC;AACjC,kDAAgC;AAChC,qDAA+D;AAAtD,6GAAA,UAAU,OAAA;AAAE,iHAAA,cAAc,OAAA;AAEnC,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,mDAAgD;AAAvC,8GAAA,YAAY,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,qDAAkD;AAClD,qDAAgE;AAEhE,iEAAiE;AACpD,QAAA,kBAAkB,GAAG;IAChC,cAAc,EAAd,+BAAc;IACd,WAAW,EAAX,4BAAW;IACX,eAAe,EAAf,gCAAe;CAChB,CAAC;AAEF,mDAAiC;AACjC,kDAAgC;AAChC,qDAA+D;AAAtD,6GAAA,UAAU,OAAA;AAAE,iHAAA,cAAc,OAAA;AAEnC,yCAAmD;AAA1C,sGAAA,SAAS,OAAA;AAAE,sGAAA,SAAS,OAAA;AAC7B,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AAEtB,mDAAgD;AAAvC,8GAAA,YAAY,OAAA"}