node-pptx-templater 1.1.7 → 1.1.8

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/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "node-pptx-templater",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "description": "High-performance, low-level PowerPoint (PPTX) OpenXML template engine for Node.js. Dynamically replace text, insert images, update charts (with Excel workbook data caching), and merge table cells without PowerPoint corruption or Repair Mode prompts.",
5
5
  "main": "./src/index.js",
6
+ "module": "./src/index.mjs",
7
+ "types": "./src/index.d.ts",
6
8
  "type": "commonjs",
9
+ "sideEffects": false,
7
10
  "exports": {
8
11
  ".": {
12
+ "types": "./src/index.d.ts",
13
+ "import": "./src/index.mjs",
9
14
  "require": "./src/index.js"
10
15
  }
11
16
  },
@@ -172,23 +177,36 @@
172
177
  "node": ">=18.0.0"
173
178
  },
174
179
  "dependencies": {
175
- "fast-xml-parser": "^4.3.6",
176
- "jszip": "^3.10.1",
177
- "fs-extra": "^11.2.0",
178
- "commander": "^12.0.0",
179
180
  "chalk": "^4.1.2",
181
+ "commander": "^12.0.0",
182
+ "fast-xml-parser": "^5.9.3",
183
+ "fs-extra": "^11.2.0",
184
+ "jszip": "^3.10.1",
180
185
  "ora": "^5.4.1"
181
186
  },
182
187
  "devDependencies": {
183
- "vitest": "^1.6.0",
184
- "@vitest/coverage-v8": "^1.6.0",
188
+ "@vitest/coverage-v8": "^4.1.9",
185
189
  "eslint": "^8.57.0",
186
- "prettier": "^3.2.5"
190
+ "prettier": "^3.2.5",
191
+ "vitest": "^4.1.9"
187
192
  },
188
193
  "files": [
189
194
  "src/",
190
195
  "README.md",
191
196
  "LICENSE",
192
197
  "CHANGELOG.md"
193
- ]
198
+ ],
199
+ "browser": {
200
+ "fs": false,
201
+ "path": false,
202
+ "os": false,
203
+ "stream": false,
204
+ "fs-extra": false,
205
+ "ora": false,
206
+ "chalk": false,
207
+ "commander": false
208
+ },
209
+ "publishConfig": {
210
+ "access": "public"
211
+ }
194
212
  }
package/src/index.d.ts ADDED
@@ -0,0 +1,138 @@
1
+ export class PPTXTemplater {
2
+ static load(source: string | Buffer, options?: any): Promise<PPTXTemplater>;
3
+ static setLogLevel(level: string): void;
4
+ static preload(source: string | Buffer): Promise<any>;
5
+ static cache(source: string | Buffer): Promise<any>;
6
+ static fromCache(source: string | Buffer): Promise<PPTXTemplater>;
7
+ static clearCache(): void;
8
+ static fromPresentationXml(options: any): Promise<PPTXTemplater>;
9
+ static create(): Promise<PPTXTemplater>;
10
+ static extractPptx(pptxPath: string, outputPath: string, options?: any): Promise<void>;
11
+ static buildPptx(folderPath: string, pptxPath: string): Promise<void>;
12
+
13
+ slideCount: number;
14
+ useSlide(slideNumber: number): this;
15
+ replaceText(replacements: Record<string, string | number>): this;
16
+ updateChart(chartName: string, data: any): this;
17
+ updateChartTitle(chartName: string, title: string): this;
18
+ applyZOrder(slideNumber: number, zOrderConfig: any[]): this;
19
+ removeSlide(slideNumber: number): this;
20
+ addHyperlink(options: any): this;
21
+ addSlideLink(options: any): this;
22
+ getTableRows(tableName: string): Promise<any[]>;
23
+ updateTable(tableName: string, rows: any[][]): this;
24
+ addTableRow(tableName: string, row: any[]): this;
25
+ removeTableRow(tableName: string, rowIndex: number): this;
26
+ mergeCells(tableName: string, startRow: number, startCol: number, endRow: number, endCol: number): this;
27
+ saveToFile(filePath: string, options?: any): Promise<void>;
28
+ save(filePath: string, options?: any): Promise<void>;
29
+ saveXml(folderPath: string): Promise<void>;
30
+ saveToFolder(folderPath: string): Promise<void>;
31
+ toBuffer(options?: any): Promise<Buffer>;
32
+ toStream(options?: any): Promise<any>;
33
+ saveToStream(writableOrOptions: any, options?: any): Promise<void>;
34
+ exportSlides(...slideNumbers: number[]): Promise<any>;
35
+ importSlideFrom(sourceEngine: PPTXTemplater, slideRef: any): Promise<any>;
36
+ repair(): Promise<this>;
37
+ inspectXML(xmlPath: string): Promise<any>;
38
+ validateCharts(): Promise<any>;
39
+ repairCharts(): Promise<any>;
40
+ inspectChartXML(chartFileName: string): Promise<any>;
41
+ getDataLabels(chartId: string, options?: any): Promise<any>;
42
+ validateDataLabels(chartId: string, options?: any): Promise<any>;
43
+ validateChartLabels(chartId: string, options?: any): Promise<any>;
44
+ validateSeriesNameLabels(chartId: string, options?: any): Promise<any>;
45
+ getChartLabelPositions(chartId: string): Promise<any>;
46
+ getChartBarPositions(chartId: string): Promise<any>;
47
+ addShape(typeOrOptions: any, options?: any): Promise<any>;
48
+ updateShape(shapeId: string, options: any): Promise<any>;
49
+ removeShape(shapeId: string): Promise<any>;
50
+ addCellShape(tableId: string, rowIndex: number, colIndex: number, options: any): Promise<any>;
51
+ updateCellShape(tableId: string, rowIndex: number, colIndex: number, shapeIndex: number, options: any): Promise<any>;
52
+ removeCellShape(tableId: string, rowIndex: number, colIndex: number, shapeIndex: number): Promise<any>;
53
+ replaceImage(imageIdOrName: string, sourcePathOrBuffer: string | Buffer): Promise<any>;
54
+ addImage(sourcePathOrBuffer: string | Buffer, options?: any): Promise<any>;
55
+ validatePresentation(): Promise<any>;
56
+ validatePresentationXml(): Promise<any>;
57
+ validateSlide(slideIndex: number): Promise<any>;
58
+ validateTable(tableId: string): Promise<any>;
59
+ validateArchive(): Promise<any>;
60
+ }
61
+
62
+ export const PPTXTemplate: typeof PPTXTemplater;
63
+
64
+ export class ZipManager {
65
+ [key: string]: any;
66
+ }
67
+
68
+ export class XMLParser {
69
+ [key: string]: any;
70
+ }
71
+
72
+ export const Z_ORDER_SYMBOL: unique symbol;
73
+
74
+ export class SlideManager {
75
+ [key: string]: any;
76
+ }
77
+
78
+ export class ChartManager {
79
+ [key: string]: any;
80
+ }
81
+
82
+ export class TableManager {
83
+ [key: string]: any;
84
+ }
85
+
86
+ export class ShapeManager {
87
+ [key: string]: any;
88
+ }
89
+
90
+ export class ImageManager {
91
+ [key: string]: any;
92
+ }
93
+
94
+ export class TextManager {
95
+ [key: string]: any;
96
+ }
97
+
98
+ export class HyperlinkManager {
99
+ [key: string]: any;
100
+ }
101
+
102
+ export class MediaManager {
103
+ [key: string]: any;
104
+ }
105
+
106
+ export class RelationshipManager {
107
+ [key: string]: any;
108
+ }
109
+
110
+ export class OutputWriter {
111
+ [key: string]: any;
112
+ }
113
+
114
+ export class TemplateEngine {
115
+ [key: string]: any;
116
+ }
117
+
118
+ export class ValidationEngine {
119
+ [key: string]: any;
120
+ }
121
+
122
+ export function generateRelationshipId(slideId: any): string;
123
+ export function parseRelationshipId(relId: string): any;
124
+ export function validateXml(xmlStr: string): any;
125
+ export function validateXML(xmlStr: string): any;
126
+ export function safeParseXml(xmlStr: string): any;
127
+ export function repairXML(xmlStr: string): string;
128
+ export function scanForEntities(xmlStr: string): any;
129
+ export function analyzeXmlFile(xmlStr: string): any;
130
+ export function reportXmlComplexity(xmlStr: string): any;
131
+ export function createLogger(name: string): any;
132
+ export function setGlobalLogLevel(level: string): void;
133
+ export function resetLogLevel(): void;
134
+
135
+ export class PPTXError extends Error {}
136
+ export class SlideNotFoundError extends PPTXError {}
137
+ export class ChartNotFoundError extends PPTXError {}
138
+ export class TableNotFoundError extends PPTXError {}
package/src/index.mjs ADDED
@@ -0,0 +1,39 @@
1
+ import pkg from './index.js'
2
+
3
+ export const {
4
+ PPTXTemplater,
5
+ PPTXTemplate,
6
+ ZipManager,
7
+ XMLParser,
8
+ Z_ORDER_SYMBOL,
9
+ SlideManager,
10
+ ChartManager,
11
+ TableManager,
12
+ ShapeManager,
13
+ ImageManager,
14
+ TextManager,
15
+ HyperlinkManager,
16
+ MediaManager,
17
+ RelationshipManager,
18
+ OutputWriter,
19
+ TemplateEngine,
20
+ ValidationEngine,
21
+ generateRelationshipId,
22
+ parseRelationshipId,
23
+ validateXml,
24
+ validateXML,
25
+ safeParseXml,
26
+ repairXML,
27
+ scanForEntities,
28
+ analyzeXmlFile,
29
+ reportXmlComplexity,
30
+ createLogger,
31
+ setGlobalLogLevel,
32
+ resetLogLevel,
33
+ PPTXError,
34
+ SlideNotFoundError,
35
+ ChartNotFoundError,
36
+ TableNotFoundError,
37
+ } = pkg
38
+
39
+ export default pkg