pptx-templates 0.0.0-stage → 0.1.0

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 (320) hide show
  1. package/AI-INSTRUCTOR.md +2253 -0
  2. package/CHANGELOG.md +49 -0
  3. package/LICENSE +23 -0
  4. package/README.md +86 -2
  5. package/dist/automizer.d.ts +224 -0
  6. package/dist/automizer.js +704 -0
  7. package/dist/automizer.js.map +1 -0
  8. package/dist/classes/content-type-registry.d.ts +46 -0
  9. package/dist/classes/content-type-registry.js +170 -0
  10. package/dist/classes/content-type-registry.js.map +1 -0
  11. package/dist/classes/element-importer.d.ts +49 -0
  12. package/dist/classes/element-importer.js +254 -0
  13. package/dist/classes/element-importer.js.map +1 -0
  14. package/dist/classes/has-shapes.d.ts +286 -0
  15. package/dist/classes/has-shapes.js +385 -0
  16. package/dist/classes/has-shapes.js.map +1 -0
  17. package/dist/classes/layout.d.ts +42 -0
  18. package/dist/classes/layout.js +113 -0
  19. package/dist/classes/layout.js.map +1 -0
  20. package/dist/classes/master.d.ts +45 -0
  21. package/dist/classes/master.js +146 -0
  22. package/dist/classes/master.js.map +1 -0
  23. package/dist/classes/placeholder-normalizer.d.ts +42 -0
  24. package/dist/classes/placeholder-normalizer.js +136 -0
  25. package/dist/classes/placeholder-normalizer.js.map +1 -0
  26. package/dist/classes/related-content-copier.d.ts +18 -0
  27. package/dist/classes/related-content-copier.js +114 -0
  28. package/dist/classes/related-content-copier.js.map +1 -0
  29. package/dist/classes/shape.d.ts +62 -0
  30. package/dist/classes/shape.js +194 -0
  31. package/dist/classes/shape.js.map +1 -0
  32. package/dist/classes/slide-master-remover.d.ts +44 -0
  33. package/dist/classes/slide-master-remover.js +201 -0
  34. package/dist/classes/slide-master-remover.js.map +1 -0
  35. package/dist/classes/slide-notes-copier.d.ts +26 -0
  36. package/dist/classes/slide-notes-copier.js +76 -0
  37. package/dist/classes/slide-notes-copier.js.map +1 -0
  38. package/dist/classes/slide.d.ts +91 -0
  39. package/dist/classes/slide.js +286 -0
  40. package/dist/classes/slide.js.map +1 -0
  41. package/dist/classes/template.d.ts +137 -0
  42. package/dist/classes/template.js +311 -0
  43. package/dist/classes/template.js.map +1 -0
  44. package/dist/constants/constants.d.ts +11 -0
  45. package/dist/constants/constants.js +182 -0
  46. package/dist/constants/constants.js.map +1 -0
  47. package/dist/enums/chart-type.d.ts +11 -0
  48. package/dist/enums/chart-type.js +16 -0
  49. package/dist/enums/chart-type.js.map +1 -0
  50. package/dist/enums/content-type-map.d.ts +16 -0
  51. package/dist/enums/content-type-map.js +23 -0
  52. package/dist/enums/content-type-map.js.map +1 -0
  53. package/dist/enums/element-type.d.ts +14 -0
  54. package/dist/enums/element-type.js +20 -0
  55. package/dist/enums/element-type.js.map +1 -0
  56. package/dist/errors.d.ts +81 -0
  57. package/dist/errors.js +100 -0
  58. package/dist/errors.js.map +1 -0
  59. package/dist/extensions/index.d.ts +5 -0
  60. package/dist/extensions/index.js +31 -0
  61. package/dist/extensions/index.js.map +1 -0
  62. package/dist/extensions/pptxgenjs-compat/img-broken-png.d.ts +5 -0
  63. package/dist/extensions/pptxgenjs-compat/img-broken-png.js +9 -0
  64. package/dist/extensions/pptxgenjs-compat/img-broken-png.js.map +1 -0
  65. package/dist/extensions/pptxgenjs-compat/index.d.ts +5 -0
  66. package/dist/extensions/pptxgenjs-compat/index.js +10 -0
  67. package/dist/extensions/pptxgenjs-compat/index.js.map +1 -0
  68. package/dist/extensions/pptxgenjs-compat/svg-fallback.d.ts +14 -0
  69. package/dist/extensions/pptxgenjs-compat/svg-fallback.js +139 -0
  70. package/dist/extensions/pptxgenjs-compat/svg-fallback.js.map +1 -0
  71. package/dist/extensions/template-logic/commands.d.ts +22 -0
  72. package/dist/extensions/template-logic/commands.js +83 -0
  73. package/dist/extensions/template-logic/commands.js.map +1 -0
  74. package/dist/extensions/template-logic/expression.d.ts +61 -0
  75. package/dist/extensions/template-logic/expression.js +499 -0
  76. package/dist/extensions/template-logic/expression.js.map +1 -0
  77. package/dist/extensions/template-logic/images.d.ts +26 -0
  78. package/dist/extensions/template-logic/images.js +183 -0
  79. package/dist/extensions/template-logic/images.js.map +1 -0
  80. package/dist/extensions/template-logic/index.d.ts +14 -0
  81. package/dist/extensions/template-logic/index.js +64 -0
  82. package/dist/extensions/template-logic/index.js.map +1 -0
  83. package/dist/extensions/template-logic/list-commands.d.ts +9 -0
  84. package/dist/extensions/template-logic/list-commands.js +72 -0
  85. package/dist/extensions/template-logic/list-commands.js.map +1 -0
  86. package/dist/extensions/template-logic/renderer.d.ts +85 -0
  87. package/dist/extensions/template-logic/renderer.js +867 -0
  88. package/dist/extensions/template-logic/renderer.js.map +1 -0
  89. package/dist/extensions/template-logic/types.d.ts +62 -0
  90. package/dist/extensions/template-logic/types.js +3 -0
  91. package/dist/extensions/template-logic/types.js.map +1 -0
  92. package/dist/helper/archive/archive-fs.d.ts +45 -0
  93. package/dist/helper/archive/archive-fs.js +206 -0
  94. package/dist/helper/archive/archive-fs.js.map +1 -0
  95. package/dist/helper/archive/archive-jszip.d.ts +31 -0
  96. package/dist/helper/archive/archive-jszip.js +173 -0
  97. package/dist/helper/archive/archive-jszip.js.map +1 -0
  98. package/dist/helper/archive/archive.d.ts +27 -0
  99. package/dist/helper/archive/archive.js +78 -0
  100. package/dist/helper/archive/archive.js.map +1 -0
  101. package/dist/helper/cell-id-helper.d.ts +25 -0
  102. package/dist/helper/cell-id-helper.js +95 -0
  103. package/dist/helper/cell-id-helper.js.map +1 -0
  104. package/dist/helper/compute-src-rect.d.ts +9 -0
  105. package/dist/helper/compute-src-rect.js +52 -0
  106. package/dist/helper/compute-src-rect.js.map +1 -0
  107. package/dist/helper/content-tracker.d.ts +31 -0
  108. package/dist/helper/content-tracker.js +227 -0
  109. package/dist/helper/content-tracker.js.map +1 -0
  110. package/dist/helper/count-helper.d.ts +33 -0
  111. package/dist/helper/count-helper.js +140 -0
  112. package/dist/helper/count-helper.js.map +1 -0
  113. package/dist/helper/css-style-parser.d.ts +52 -0
  114. package/dist/helper/css-style-parser.js +246 -0
  115. package/dist/helper/css-style-parser.js.map +1 -0
  116. package/dist/helper/file-helper.d.ts +36 -0
  117. package/dist/helper/file-helper.js +150 -0
  118. package/dist/helper/file-helper.js.map +1 -0
  119. package/dist/helper/general-helper.d.ts +6 -0
  120. package/dist/helper/general-helper.js +34 -0
  121. package/dist/helper/general-helper.js.map +1 -0
  122. package/dist/helper/generate/generate-pptxgenjs.d.ts +37 -0
  123. package/dist/helper/generate/generate-pptxgenjs.js +134 -0
  124. package/dist/helper/generate/generate-pptxgenjs.js.map +1 -0
  125. package/dist/helper/html-to-multitext-helper.d.ts +84 -0
  126. package/dist/helper/html-to-multitext-helper.js +490 -0
  127. package/dist/helper/html-to-multitext-helper.js.map +1 -0
  128. package/dist/helper/hyperlink-processor.d.ts +54 -0
  129. package/dist/helper/hyperlink-processor.js +289 -0
  130. package/dist/helper/hyperlink-processor.js.map +1 -0
  131. package/dist/helper/image-dimensions.d.ts +21 -0
  132. package/dist/helper/image-dimensions.js +202 -0
  133. package/dist/helper/image-dimensions.js.map +1 -0
  134. package/dist/helper/jszip-helper.d.ts +21 -0
  135. package/dist/helper/jszip-helper.js +162 -0
  136. package/dist/helper/jszip-helper.js.map +1 -0
  137. package/dist/helper/layout-index.d.ts +55 -0
  138. package/dist/helper/layout-index.js +155 -0
  139. package/dist/helper/layout-index.js.map +1 -0
  140. package/dist/helper/logger.d.ts +53 -0
  141. package/dist/helper/logger.js +73 -0
  142. package/dist/helper/logger.js.map +1 -0
  143. package/dist/helper/media-deduplicator.d.ts +42 -0
  144. package/dist/helper/media-deduplicator.js +88 -0
  145. package/dist/helper/media-deduplicator.js.map +1 -0
  146. package/dist/helper/modify-background-helper.d.ts +19 -0
  147. package/dist/helper/modify-background-helper.js +59 -0
  148. package/dist/helper/modify-background-helper.js.map +1 -0
  149. package/dist/helper/modify-chart-helper.d.ts +159 -0
  150. package/dist/helper/modify-chart-helper.js +642 -0
  151. package/dist/helper/modify-chart-helper.js.map +1 -0
  152. package/dist/helper/modify-cleanup-helper.d.ts +69 -0
  153. package/dist/helper/modify-cleanup-helper.js +343 -0
  154. package/dist/helper/modify-cleanup-helper.js.map +1 -0
  155. package/dist/helper/modify-color-helper.d.ts +35 -0
  156. package/dist/helper/modify-color-helper.js +211 -0
  157. package/dist/helper/modify-color-helper.js.map +1 -0
  158. package/dist/helper/modify-helper.d.ts +23 -0
  159. package/dist/helper/modify-helper.js +61 -0
  160. package/dist/helper/modify-helper.js.map +1 -0
  161. package/dist/helper/modify-hyperlink-element.d.ts +9 -0
  162. package/dist/helper/modify-hyperlink-element.js +34 -0
  163. package/dist/helper/modify-hyperlink-element.js.map +1 -0
  164. package/dist/helper/modify-hyperlink-helper.d.ts +42 -0
  165. package/dist/helper/modify-hyperlink-helper.js +258 -0
  166. package/dist/helper/modify-hyperlink-helper.js.map +1 -0
  167. package/dist/helper/modify-image-helper.d.ts +23 -0
  168. package/dist/helper/modify-image-helper.js +157 -0
  169. package/dist/helper/modify-image-helper.js.map +1 -0
  170. package/dist/helper/modify-presentation-helper.d.ts +55 -0
  171. package/dist/helper/modify-presentation-helper.js +177 -0
  172. package/dist/helper/modify-presentation-helper.js.map +1 -0
  173. package/dist/helper/modify-shape-helper.d.ts +111 -0
  174. package/dist/helper/modify-shape-helper.js +340 -0
  175. package/dist/helper/modify-shape-helper.js.map +1 -0
  176. package/dist/helper/modify-table-helper.d.ts +11 -0
  177. package/dist/helper/modify-table-helper.js +100 -0
  178. package/dist/helper/modify-table-helper.js.map +1 -0
  179. package/dist/helper/modify-text-helper.d.ts +62 -0
  180. package/dist/helper/modify-text-helper.js +244 -0
  181. package/dist/helper/modify-text-helper.js.map +1 -0
  182. package/dist/helper/modify-xml-helper.d.ts +52 -0
  183. package/dist/helper/modify-xml-helper.js +305 -0
  184. package/dist/helper/modify-xml-helper.js.map +1 -0
  185. package/dist/helper/multitext-helper.d.ts +116 -0
  186. package/dist/helper/multitext-helper.js +462 -0
  187. package/dist/helper/multitext-helper.js.map +1 -0
  188. package/dist/helper/ppt-paths.d.ts +76 -0
  189. package/dist/helper/ppt-paths.js +116 -0
  190. package/dist/helper/ppt-paths.js.map +1 -0
  191. package/dist/helper/shape-type-detector.d.ts +34 -0
  192. package/dist/helper/shape-type-detector.js +99 -0
  193. package/dist/helper/shape-type-detector.js.map +1 -0
  194. package/dist/helper/text-replace-helper.d.ts +30 -0
  195. package/dist/helper/text-replace-helper.js +147 -0
  196. package/dist/helper/text-replace-helper.js.map +1 -0
  197. package/dist/helper/xml/lnLRTB.d.ts +1 -0
  198. package/dist/helper/xml/lnLRTB.js +62 -0
  199. package/dist/helper/xml/lnLRTB.js.map +1 -0
  200. package/dist/helper/xml/prstGeom.d.ts +1 -0
  201. package/dist/helper/xml/prstGeom.js +11 -0
  202. package/dist/helper/xml/prstGeom.js.map +1 -0
  203. package/dist/helper/xml-elements.d.ts +134 -0
  204. package/dist/helper/xml-elements.js +538 -0
  205. package/dist/helper/xml-elements.js.map +1 -0
  206. package/dist/helper/xml-helper.d.ts +120 -0
  207. package/dist/helper/xml-helper.js +495 -0
  208. package/dist/helper/xml-helper.js.map +1 -0
  209. package/dist/helper/xml-placeholder-helper.d.ts +92 -0
  210. package/dist/helper/xml-placeholder-helper.js +454 -0
  211. package/dist/helper/xml-placeholder-helper.js.map +1 -0
  212. package/dist/helper/xml-pretty-print.d.ts +17 -0
  213. package/dist/helper/xml-pretty-print.js +88 -0
  214. package/dist/helper/xml-pretty-print.js.map +1 -0
  215. package/dist/helper/xml-relationship-helper.d.ts +103 -0
  216. package/dist/helper/xml-relationship-helper.js +397 -0
  217. package/dist/helper/xml-relationship-helper.js.map +1 -0
  218. package/dist/helper/xml-slide-helper.d.ts +107 -0
  219. package/dist/helper/xml-slide-helper.js +676 -0
  220. package/dist/helper/xml-slide-helper.js.map +1 -0
  221. package/dist/helper/xml-template-helper.d.ts +42 -0
  222. package/dist/helper/xml-template-helper.js +252 -0
  223. package/dist/helper/xml-template-helper.js.map +1 -0
  224. package/dist/helper/xmldom-sax-patch.d.ts +18 -0
  225. package/dist/helper/xmldom-sax-patch.js +58 -0
  226. package/dist/helper/xmldom-sax-patch.js.map +1 -0
  227. package/dist/index.d.ts +81 -0
  228. package/dist/index.js +177 -0
  229. package/dist/index.js.map +1 -0
  230. package/dist/interfaces/iarchive.d.ts +43 -0
  231. package/dist/interfaces/iarchive.js +3 -0
  232. package/dist/interfaces/iarchive.js.map +1 -0
  233. package/dist/interfaces/ichart.d.ts +7 -0
  234. package/dist/interfaces/ichart.js +3 -0
  235. package/dist/interfaces/ichart.js.map +1 -0
  236. package/dist/interfaces/icounter.d.ts +7 -0
  237. package/dist/interfaces/icounter.js +3 -0
  238. package/dist/interfaces/icounter.js.map +1 -0
  239. package/dist/interfaces/igenerator.d.ts +4 -0
  240. package/dist/interfaces/igenerator.js +3 -0
  241. package/dist/interfaces/igenerator.js.map +1 -0
  242. package/dist/interfaces/iimage.d.ts +7 -0
  243. package/dist/interfaces/iimage.js +3 -0
  244. package/dist/interfaces/iimage.js.map +1 -0
  245. package/dist/interfaces/ilayout.d.ts +14 -0
  246. package/dist/interfaces/ilayout.js +3 -0
  247. package/dist/interfaces/ilayout.js.map +1 -0
  248. package/dist/interfaces/imaster.d.ts +15 -0
  249. package/dist/interfaces/imaster.js +3 -0
  250. package/dist/interfaces/imaster.js.map +1 -0
  251. package/dist/interfaces/imulti-text.d.ts +50 -0
  252. package/dist/interfaces/imulti-text.js +3 -0
  253. package/dist/interfaces/imulti-text.js.map +1 -0
  254. package/dist/interfaces/ipptxgenjs-slide.d.ts +40 -0
  255. package/dist/interfaces/ipptxgenjs-slide.js +3 -0
  256. package/dist/interfaces/ipptxgenjs-slide.js.map +1 -0
  257. package/dist/interfaces/ipresentation-props.d.ts +16 -0
  258. package/dist/interfaces/ipresentation-props.js +3 -0
  259. package/dist/interfaces/ipresentation-props.js.map +1 -0
  260. package/dist/interfaces/ishape-action.d.ts +18 -0
  261. package/dist/interfaces/ishape-action.js +3 -0
  262. package/dist/interfaces/ishape-action.js.map +1 -0
  263. package/dist/interfaces/ishape.d.ts +5 -0
  264. package/dist/interfaces/ishape.js +3 -0
  265. package/dist/interfaces/ishape.js.map +1 -0
  266. package/dist/interfaces/islide.d.ts +71 -0
  267. package/dist/interfaces/islide.js +3 -0
  268. package/dist/interfaces/islide.js.map +1 -0
  269. package/dist/interfaces/itemplate.d.ts +9 -0
  270. package/dist/interfaces/itemplate.js +3 -0
  271. package/dist/interfaces/itemplate.js.map +1 -0
  272. package/dist/interfaces/pres-template.d.ts +9 -0
  273. package/dist/interfaces/pres-template.js +3 -0
  274. package/dist/interfaces/pres-template.js.map +1 -0
  275. package/dist/interfaces/root-pres-template.d.ts +38 -0
  276. package/dist/interfaces/root-pres-template.js +3 -0
  277. package/dist/interfaces/root-pres-template.js.map +1 -0
  278. package/dist/modify/modify-chart.d.ts +74 -0
  279. package/dist/modify/modify-chart.js +753 -0
  280. package/dist/modify/modify-chart.js.map +1 -0
  281. package/dist/modify/modify-table.d.ts +64 -0
  282. package/dist/modify/modify-table.js +435 -0
  283. package/dist/modify/modify-table.js.map +1 -0
  284. package/dist/shapes/chart.d.ts +91 -0
  285. package/dist/shapes/chart.js +437 -0
  286. package/dist/shapes/chart.js.map +1 -0
  287. package/dist/shapes/diagram.d.ts +33 -0
  288. package/dist/shapes/diagram.js +167 -0
  289. package/dist/shapes/diagram.js.map +1 -0
  290. package/dist/shapes/generic.d.ts +27 -0
  291. package/dist/shapes/generic.js +118 -0
  292. package/dist/shapes/generic.js.map +1 -0
  293. package/dist/shapes/hyperlink.d.ts +27 -0
  294. package/dist/shapes/hyperlink.js +193 -0
  295. package/dist/shapes/hyperlink.js.map +1 -0
  296. package/dist/shapes/image.d.ts +47 -0
  297. package/dist/shapes/image.js +244 -0
  298. package/dist/shapes/image.js.map +1 -0
  299. package/dist/shapes/ole.d.ts +30 -0
  300. package/dist/shapes/ole.js +237 -0
  301. package/dist/shapes/ole.js.map +1 -0
  302. package/dist/types/chart-types.d.ts +115 -0
  303. package/dist/types/chart-types.js +3 -0
  304. package/dist/types/chart-types.js.map +1 -0
  305. package/dist/types/modify-types.d.ts +128 -0
  306. package/dist/types/modify-types.js +3 -0
  307. package/dist/types/modify-types.js.map +1 -0
  308. package/dist/types/shape-types.d.ts +40 -0
  309. package/dist/types/shape-types.js +3 -0
  310. package/dist/types/shape-types.js.map +1 -0
  311. package/dist/types/table-types.d.ts +38 -0
  312. package/dist/types/table-types.js +3 -0
  313. package/dist/types/table-types.js.map +1 -0
  314. package/dist/types/types.d.ts +317 -0
  315. package/dist/types/types.js +16 -0
  316. package/dist/types/types.js.map +1 -0
  317. package/dist/types/xml-types.d.ts +168 -0
  318. package/dist/types/xml-types.js +3 -0
  319. package/dist/types/xml-types.js.map +1 -0
  320. package/package.json +92 -4
@@ -0,0 +1,704 @@
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
+ const slide_1 = require("./classes/slide");
49
+ const types_1 = require("./types/types");
50
+ const template_1 = require("./classes/template");
51
+ const general_helper_1 = require("./helper/general-helper");
52
+ const logger_1 = require("./helper/logger");
53
+ const master_1 = require("./classes/master");
54
+ const layout_1 = require("./classes/layout");
55
+ const slide_master_remover_1 = require("./classes/slide-master-remover");
56
+ const constants_1 = require("./constants/constants");
57
+ const path_1 = __importDefault(require("path"));
58
+ const fs = __importStar(require("fs"));
59
+ const xml_helper_1 = require("./helper/xml-helper");
60
+ const modify_presentation_helper_1 = __importDefault(require("./helper/modify-presentation-helper"));
61
+ const content_tracker_1 = require("./helper/content-tracker");
62
+ const content_type_map_1 = require("./enums/content-type-map");
63
+ const errors_1 = require("./errors");
64
+ const slugify_1 = __importDefault(require("slugify"));
65
+ /**
66
+ * Valid media file extensions based on ContentTypeMap.
67
+ * Used to validate file extensions before processing.
68
+ */
69
+ const VALID_MEDIA_EXTENSIONS = Object.keys(content_type_map_1.ContentTypeMap);
70
+ /**
71
+ * Validates that a file extension is a supported media type.
72
+ * @param extension - The file extension to validate (without leading dot)
73
+ * @param filename - The original filename (for error message)
74
+ * @throws {Error} If the extension is not supported
75
+ */
76
+ function validateMediaExtension(extension, filename) {
77
+ if (!VALID_MEDIA_EXTENSIONS.includes(extension.toLowerCase())) {
78
+ throw new errors_1.AutomizerError(`Unsupported media extension '${extension}' for file '${filename}'. ` +
79
+ `Supported extensions: ${VALID_MEDIA_EXTENSIONS.join(', ')}`);
80
+ }
81
+ }
82
+ /**
83
+ * Extracts and validates file extension.
84
+ * @param filename - The filename to extract extension from
85
+ * @returns The validated extension
86
+ * @throws {Error} If filename has no extension or extension is not supported
87
+ */
88
+ function getValidatedExtension(filename) {
89
+ const extension = path_1.default
90
+ .extname(filename)
91
+ .replace('.', '');
92
+ if (!extension) {
93
+ throw new errors_1.AutomizerError(`Filename must include extension: ${filename}. Example: 'logo.png'`);
94
+ }
95
+ validateMediaExtension(extension, filename);
96
+ return extension;
97
+ }
98
+ /**
99
+ * Automizer
100
+ *
101
+ * The basic class for `pptx-templates` package.
102
+ * This class will be exported as `Automizer` by `index.ts`.
103
+ */
104
+ class Automizer {
105
+ /**
106
+ * Creates an instance of `pptx-templates`.
107
+ * @param [params]
108
+ */
109
+ constructor(params) {
110
+ var _a, _b, _c, _d, _f, _g, _h;
111
+ /**
112
+ * Templates of automizer
113
+ * @internal
114
+ */
115
+ this.templates = [];
116
+ this.modifyPresentation = [];
117
+ /**
118
+ * Masters queued for removal (`removeMaster`), by number.
119
+ * @internal
120
+ */
121
+ this.mastersToRemove = [];
122
+ this.params = params;
123
+ this.logger = (_a = params.logger) !== null && _a !== void 0 ? _a : new logger_1.ConsoleLogger((_b = params.verbosity) !== null && _b !== void 0 ? _b : 1);
124
+ this.templateDir = (params === null || params === void 0 ? void 0 : params.templateDir) ? params.templateDir + '/' : '';
125
+ this.templateFallbackDir = (params === null || params === void 0 ? void 0 : params.templateFallbackDir)
126
+ ? params.templateFallbackDir + '/'
127
+ : '';
128
+ this.outputDir = (params === null || params === void 0 ? void 0 : params.outputDir) ? params.outputDir + '/' : '';
129
+ this.archiveParams = {
130
+ mode: ((_c = params === null || params === void 0 ? void 0 : params.archiveType) === null || _c === void 0 ? void 0 : _c.mode) || 'jszip',
131
+ baseDir: ((_d = params === null || params === void 0 ? void 0 : params.archiveType) === null || _d === void 0 ? void 0 : _d.baseDir) || __dirname + '/../cache',
132
+ workDir: ((_f = params === null || params === void 0 ? void 0 : params.archiveType) === null || _f === void 0 ? void 0 : _f.workDir) || 'tmp',
133
+ cleanupWorkDir: (_g = params === null || params === void 0 ? void 0 : params.archiveType) === null || _g === void 0 ? void 0 : _g.cleanupWorkDir,
134
+ decodeText: (_h = params === null || params === void 0 ? void 0 : params.archiveType) === null || _h === void 0 ? void 0 : _h.decodeText,
135
+ };
136
+ this.timer = Date.now();
137
+ this.setStatusTracker(params === null || params === void 0 ? void 0 : params.statusTracker);
138
+ this.content = new content_tracker_1.ContentTracker();
139
+ if (params.rootTemplate) {
140
+ let file = params.rootTemplate;
141
+ if (typeof file !== 'object') {
142
+ file = this.getLocation(file, 'template');
143
+ }
144
+ this.rootTemplate = new template_1.OutputTemplate(file, this.archiveParams, this);
145
+ }
146
+ if (params.presTemplates) {
147
+ this.params.presTemplates.forEach((file, i) => {
148
+ let name;
149
+ if (typeof file !== 'object') {
150
+ name = file;
151
+ file = this.getLocation(file, 'template');
152
+ }
153
+ else {
154
+ name = `${i}.pptx`;
155
+ }
156
+ const archiveParams = Object.assign(Object.assign({}, this.archiveParams), { name });
157
+ this.templates.push(new template_1.SourceTemplate(file, archiveParams));
158
+ });
159
+ }
160
+ }
161
+ setStatusTracker(statusTracker) {
162
+ const defaultStatusTracker = (status) => {
163
+ this.logger.info(status.info + ' (' + status.share + '%)');
164
+ };
165
+ this.status = {
166
+ current: 0,
167
+ max: 0,
168
+ share: 0,
169
+ info: undefined,
170
+ increment: () => {
171
+ this.status.current++;
172
+ const nextShare = this.status.max > 0
173
+ ? Math.round((this.status.current / this.status.max) * 100)
174
+ : 0;
175
+ if (this.status.share !== nextShare) {
176
+ this.status.share = nextShare;
177
+ this.status.next(this.status);
178
+ }
179
+ },
180
+ next: statusTracker || defaultStatusTracker,
181
+ };
182
+ }
183
+ /**
184
+
185
+ */
186
+ presentation() {
187
+ return __awaiter(this, void 0, void 0, function* () {
188
+ var _a;
189
+ if (((_a = this.params) === null || _a === void 0 ? void 0 : _a.useCreationIds) === true) {
190
+ yield this.setCreationIds();
191
+ }
192
+ return this;
193
+ });
194
+ }
195
+ /**
196
+ * Load a pptx file and set it as root template.
197
+ * @param file - Filename, path to the template or Buffer containing the file.
198
+ * Filenames and paths will be prefixed with 'templateDir'
199
+ * @returns Instance of Automizer
200
+ */
201
+ loadRoot(file) {
202
+ return this.loadTemplate(file);
203
+ }
204
+ /**
205
+ * Load a template pptx file.
206
+ * @param file - Filename, path to the template or Buffer containing the file.
207
+ * Filenames and paths will be prefixed with 'templateDir'
208
+ * @param name - Optional short name for a template loaded from a file. If skipped, the template will be named by its location.
209
+ * if the file is a Buffer the name is required.
210
+ * @returns Instance of Automizer
211
+ */
212
+ load(file, name) {
213
+ if (!name && typeof file !== 'object') {
214
+ name = name === undefined ? file : name;
215
+ }
216
+ else if (typeof file === 'object' && !name) {
217
+ throw new Error('Name is required when loading a template from a Buffer');
218
+ }
219
+ return this.loadTemplate(file, name);
220
+ }
221
+ /**
222
+ * Loads a pptx file either as a root template as a template file.
223
+ * A name can be specified to give templates an alias.
224
+ * @param location
225
+ * @param [name]
226
+ * @returns template
227
+ */
228
+ loadTemplate(file, name) {
229
+ if (typeof file !== 'object') {
230
+ file = this.getLocation(file, 'template');
231
+ }
232
+ const alreadyLoaded = this.templates.find((template) => template.name === name);
233
+ if (alreadyLoaded) {
234
+ return this;
235
+ }
236
+ const importParams = Object.assign(Object.assign({}, this.archiveParams), { name });
237
+ const newTemplate = template_1.Template.import(file, importParams, this);
238
+ if (newTemplate instanceof template_1.SourceTemplate) {
239
+ this.templates.push(newTemplate);
240
+ }
241
+ else {
242
+ this.rootTemplate = newTemplate;
243
+ }
244
+ return this;
245
+ }
246
+ /**
247
+ * Load media files to output presentation.
248
+ * @returns Instance of Automizer
249
+ * @param filename Filename or path to the media file.
250
+ * @param dir Specify custom path for media instead of mediaDir from AutomizerParams.
251
+ */
252
+ loadMedia(filename, dir, prefix) {
253
+ const files = general_helper_1.GeneralHelper.arrayify(filename);
254
+ if (!this.rootTemplate) {
255
+ throw new errors_1.AutomizerError("Can't load media, you need to load a root template first");
256
+ }
257
+ files.forEach((file) => {
258
+ const directory = dir || this.params.mediaDir;
259
+ const filepath = path_1.default.join(directory, file);
260
+ const extension = getValidatedExtension(file);
261
+ try {
262
+ fs.accessSync(filepath, fs.constants.F_OK);
263
+ }
264
+ catch (_e) {
265
+ throw new errors_1.AutomizerError(`Can't load media: ${filepath} does not exist.`);
266
+ }
267
+ this.rootTemplate.mediaFiles.push({
268
+ source: 'path',
269
+ file,
270
+ directory,
271
+ filepath,
272
+ extension,
273
+ prefix,
274
+ });
275
+ });
276
+ return this;
277
+ }
278
+ /**
279
+ * Load media files from buffers to output presentation.
280
+ * @returns Instance of Automizer
281
+ * @param filename Filename(s) to use (must include extension).
282
+ * @param buffer Buffer(s) containing the media data.
283
+ * @param prefix Optional prefix to prepend to filename in archive.
284
+ */
285
+ loadMediaBuffer(filename, buffer, prefix) {
286
+ const files = general_helper_1.GeneralHelper.arrayify(filename);
287
+ const buffers = general_helper_1.GeneralHelper.arrayify(buffer);
288
+ if (!this.rootTemplate) {
289
+ throw new errors_1.AutomizerError("Can't load media, you need to load a root template first");
290
+ }
291
+ if (files.length !== buffers.length) {
292
+ throw new errors_1.AutomizerError(`Mismatched arrays: ${files.length} filename(s) but ${buffers.length} buffer(s)`);
293
+ }
294
+ files.forEach((file, index) => {
295
+ const buf = buffers[index];
296
+ if (!Buffer.isBuffer(buf)) {
297
+ throw new errors_1.AutomizerError(`Invalid buffer for file: ${file}`);
298
+ }
299
+ if (buf.length === 0) {
300
+ throw new errors_1.AutomizerError(`Empty buffer provided for file: ${file}`);
301
+ }
302
+ const extension = getValidatedExtension(file);
303
+ this.rootTemplate.mediaFiles.push({
304
+ source: 'buffer',
305
+ file,
306
+ buffer: buf,
307
+ extension,
308
+ prefix,
309
+ });
310
+ });
311
+ return this;
312
+ }
313
+ /**
314
+ * Parses all loaded templates and collects creationIds for slides and
315
+ * elements. This will make finding templates and elements independent
316
+ * of slide number and element name.
317
+ * @returns Promise<TemplateInfo[]>
318
+ */
319
+ setCreationIds() {
320
+ return __awaiter(this, void 0, void 0, function* () {
321
+ return (0, logger_1.runWithLogger)(this.logger, () => __awaiter(this, void 0, void 0, function* () {
322
+ const templateCreationId = [];
323
+ for (const template of this.templates) {
324
+ const creationIds = template.creationIds || (yield template.setCreationIds());
325
+ template.useCreationIds = this.params.useCreationIds;
326
+ templateCreationId.push({
327
+ name: template.name,
328
+ slides: creationIds,
329
+ });
330
+ }
331
+ return templateCreationId;
332
+ }));
333
+ });
334
+ }
335
+ /**
336
+ * Get some info about the imported templates
337
+ * @returns Promise<PresentationInfo>
338
+ */
339
+ getInfo() {
340
+ return __awaiter(this, void 0, void 0, function* () {
341
+ const creationIds = yield this.setCreationIds();
342
+ const info = {
343
+ templateByName: (tplName) => {
344
+ return creationIds.find((template) => template.name === tplName);
345
+ },
346
+ slidesByTemplate: (tplName) => {
347
+ var _a;
348
+ return ((_a = info.templateByName(tplName)) === null || _a === void 0 ? void 0 : _a.slides) || [];
349
+ },
350
+ slideByNumber: (tplName, slideNumber) => {
351
+ return info
352
+ .slidesByTemplate(tplName)
353
+ .find((slide) => slide.number === slideNumber);
354
+ },
355
+ elementByName: (tplName, slideNumber, elementName) => {
356
+ var _a;
357
+ return (_a = info
358
+ .slideByNumber(tplName, slideNumber)) === null || _a === void 0 ? void 0 : _a.elements.find((element) => elementName === element.name);
359
+ },
360
+ };
361
+ return info;
362
+ });
363
+ }
364
+ /**
365
+ * Add a slide from one of the imported templates by slide number or creationId.
366
+ * @param name - Name or alias of the template; must have been loaded with `Automizer.load()`
367
+ * @param slideIdentifier - Number or creationId of slide in template presentation
368
+ * @param callback - Executed after slide was added. The newly created slide will be passed to the callback as first argument.
369
+ * @returns Instance of Automizer
370
+ */
371
+ addSlide(name, slideIdentifier, callback) {
372
+ if (this.rootTemplate === undefined) {
373
+ throw new Error('You have to set a root template first.');
374
+ }
375
+ const template = this.getTemplate(name);
376
+ const newSlide = new slide_1.Slide({
377
+ presentation: this,
378
+ template,
379
+ slideIdentifier,
380
+ });
381
+ if (this.params.autoImportSlideMasters) {
382
+ newSlide.useSlideLayout();
383
+ }
384
+ if (callback !== undefined) {
385
+ newSlide.root = this;
386
+ callback(newSlide);
387
+ }
388
+ this.rootTemplate.slides.push(newSlide);
389
+ return this;
390
+ }
391
+ /**
392
+ * Copy and modify a master and the associated layouts from template to output.
393
+ *
394
+ * @param name
395
+ * @param sourceIdentifier
396
+ * @param callback
397
+ */
398
+ addMaster(name, sourceIdentifier, callback) {
399
+ const key = sourceIdentifier + '@' + name;
400
+ if (this.rootTemplate.masters.find((master) => master.key === key)) {
401
+ this.logger.info('Already imported ' + key);
402
+ return this;
403
+ }
404
+ const template = this.getTemplate(name);
405
+ const newMaster = new master_1.Master({
406
+ presentation: this,
407
+ template,
408
+ sourceIdentifier,
409
+ });
410
+ if (callback !== undefined) {
411
+ newMaster.root = this;
412
+ callback(newMaster);
413
+ }
414
+ this.rootTemplate.masters.push(newMaster);
415
+ return this;
416
+ }
417
+ /**
418
+ * Modify a slide master that is already part of the root template, in
419
+ * place: no copy is made, the master keeps its number and every slide
420
+ * using it keeps using it. The callback gets the same
421
+ * `modifyElement` / `addElement` / `removeElement` vocabulary as
422
+ * `addMaster`. Deferred: applied on write, before the slides are
423
+ * written, in call order with `addMaster` imports.
424
+ *
425
+ * @param masterNumber - 1-based number of the master in the root
426
+ * template as loaded (`ppt/slideMasters/slideMaster<n>.xml`). Imported
427
+ * masters are modified through their `addMaster` callback instead.
428
+ * @param callback - Receives the master; queue element actions on it.
429
+ */
430
+ modifyMaster(masterNumber, callback) {
431
+ if (this.rootTemplate === undefined) {
432
+ throw new Error('You have to set a root template first.');
433
+ }
434
+ const key = master_1.Master.getKey(masterNumber, constants_1.ROOT_TEMPLATE_ALIAS);
435
+ let master = this.rootTemplate.masters.find((candidate) => candidate.key === key);
436
+ if (!master) {
437
+ master = new master_1.Master({
438
+ presentation: this,
439
+ template: this.rootTemplate.asSourceTemplate(),
440
+ sourceIdentifier: masterNumber,
441
+ inPlace: true,
442
+ });
443
+ master.root = this;
444
+ this.rootTemplate.masters.push(master);
445
+ }
446
+ callback(master);
447
+ return this;
448
+ }
449
+ /**
450
+ * Modify a slide layout that is already part of the root template, in
451
+ * place (see `modifyMaster`).
452
+ *
453
+ * @param layoutNumber - 1-based number of the layout in the root template
454
+ * as loaded (`ppt/slideLayouts/slideLayout<n>.xml`).
455
+ * @param callback - Receives the layout; queue element actions on it.
456
+ */
457
+ modifyLayout(layoutNumber, callback) {
458
+ if (this.rootTemplate === undefined) {
459
+ throw new Error('You have to set a root template first.');
460
+ }
461
+ let layout = this.rootTemplate.layouts.find((candidate) => candidate.sourceNumber === layoutNumber);
462
+ if (!layout) {
463
+ layout = new layout_1.Layout({
464
+ presentation: this,
465
+ template: this.rootTemplate.asSourceTemplate(),
466
+ sourceIdentifier: layoutNumber,
467
+ inPlace: true,
468
+ });
469
+ layout.root = this;
470
+ this.rootTemplate.layouts.push(layout);
471
+ }
472
+ callback(layout);
473
+ return this;
474
+ }
475
+ /**
476
+ * Remove a slide master from the output together with its layouts, its
477
+ * theme (unless another part still uses it) and all entries referring
478
+ * to them. Deferred: applied on write after all slides have been
479
+ * written. Fails if a slide of the output still uses one of the
480
+ * master's layouts — switch those slides with `useSlideLayout()` first
481
+ * (or drop the root template's slides with `removeExistingSlides`).
482
+ *
483
+ * @param masterNumber - 1-based number of the master in the root
484
+ * template as loaded (`ppt/slideMasters/slideMaster<n>.xml`).
485
+ */
486
+ removeMaster(masterNumber) {
487
+ if (this.rootTemplate === undefined) {
488
+ throw new Error('You have to set a root template first.');
489
+ }
490
+ if (!this.mastersToRemove.includes(masterNumber)) {
491
+ this.mastersToRemove.push(masterNumber);
492
+ }
493
+ return this;
494
+ }
495
+ /**
496
+ * Searches this.templates to find template by given name.
497
+ * @internal
498
+ * @param name Alias name if given to loaded template.
499
+ * @returns template
500
+ */
501
+ getTemplate(name) {
502
+ const template = this.templates.find((t) => t.name === name);
503
+ if (template === undefined) {
504
+ throw new Error(`Template not found: ${name}`);
505
+ }
506
+ return template;
507
+ }
508
+ /**
509
+ * Write all imports and modifications to a file.
510
+ * @param location - Filename or path for the file. Will be prefixed with 'outputDir'
511
+ * @returns summary object.
512
+ */
513
+ write(location) {
514
+ return __awaiter(this, void 0, void 0, function* () {
515
+ return (0, logger_1.runWithLogger)(this.logger, () => __awaiter(this, void 0, void 0, function* () {
516
+ yield this.finalizePresentation();
517
+ yield this.rootTemplate.archive.output(this.getLocation(location, 'output'), this.params);
518
+ const duration = (Date.now() - this.timer) / 1000;
519
+ return {
520
+ status: 'finished',
521
+ duration,
522
+ file: location,
523
+ filename: path_1.default.basename(location),
524
+ templates: this.templates.length,
525
+ slides: this.rootTemplate.count('slides'),
526
+ charts: this.rootTemplate.count('charts'),
527
+ images: this.rootTemplate.count('images'),
528
+ masters: this.rootTemplate.count('masters'),
529
+ };
530
+ }));
531
+ });
532
+ }
533
+ /**
534
+ * Create a ReadableStream from output pptx file.
535
+ * @param generatorOptions - JSZipGeneratorOptions for nodebuffer Output type
536
+ * @returns Promise<NodeJS.ReadableStream>
537
+ */
538
+ stream(generatorOptions) {
539
+ return __awaiter(this, void 0, void 0, function* () {
540
+ return (0, logger_1.runWithLogger)(this.logger, () => __awaiter(this, void 0, void 0, function* () {
541
+ yield this.finalizePresentation();
542
+ if (!this.rootTemplate.archive.stream) {
543
+ throw new errors_1.OutputError('Streaming is not implemented for current archive type');
544
+ }
545
+ return this.rootTemplate.archive.stream(this.params, generatorOptions);
546
+ }));
547
+ });
548
+ }
549
+ /**
550
+ * Pass final JSZip instance.
551
+ * @returns Promise<NodeJS.ReadableStream>
552
+ */
553
+ getJSZip() {
554
+ return __awaiter(this, void 0, void 0, function* () {
555
+ return (0, logger_1.runWithLogger)(this.logger, () => __awaiter(this, void 0, void 0, function* () {
556
+ yield this.finalizePresentation();
557
+ if (!this.rootTemplate.archive.getFinalArchive) {
558
+ throw new errors_1.OutputError('GetFinalArchive is not implemented for current archive type');
559
+ }
560
+ return this.rootTemplate.archive.getFinalArchive();
561
+ }));
562
+ });
563
+ }
564
+ finalizePresentation() {
565
+ return __awaiter(this, void 0, void 0, function* () {
566
+ return (0, logger_1.runWithLogger)(this.logger, () => __awaiter(this, void 0, void 0, function* () {
567
+ yield this.writeMasterSlides();
568
+ yield this.writeSlides();
569
+ yield this.removeSlideMasters();
570
+ yield this.writeMediaFiles();
571
+ yield this.normalizePresentation();
572
+ yield this.applyModifyPresentationCallbacks();
573
+ this.content.reset();
574
+ }));
575
+ });
576
+ }
577
+ /**
578
+ * Write all masterSlides to archive.
579
+ */
580
+ writeMasterSlides() {
581
+ return __awaiter(this, void 0, void 0, function* () {
582
+ var _a;
583
+ for (const slide of this.rootTemplate.masters) {
584
+ yield this.rootTemplate.appendMasterSlide(slide);
585
+ }
586
+ for (const layout of (_a = this.rootTemplate.layouts) !== null && _a !== void 0 ? _a : []) {
587
+ yield this.rootTemplate.appendLayout(layout);
588
+ }
589
+ });
590
+ }
591
+ /**
592
+ * Remove the masters queued by `removeMaster()`. Runs after the slides
593
+ * are written, so layout switches have been applied when the "still in
594
+ * use" check runs.
595
+ */
596
+ removeSlideMasters() {
597
+ return __awaiter(this, void 0, void 0, function* () {
598
+ if (!this.mastersToRemove.length) {
599
+ return;
600
+ }
601
+ const remover = new slide_master_remover_1.SlideMasterRemover(this.rootTemplate);
602
+ for (const masterNumber of this.mastersToRemove) {
603
+ yield remover.remove(masterNumber);
604
+ }
605
+ });
606
+ }
607
+ /**
608
+ * Write all slides to archive.
609
+ */
610
+ writeSlides() {
611
+ return __awaiter(this, void 0, void 0, function* () {
612
+ yield this.rootTemplate.countExistingSlides();
613
+ this.status.max = this.rootTemplate.slides.length;
614
+ yield this.rootTemplate.runExternalGenerator();
615
+ for (const slide of this.rootTemplate.slides) {
616
+ yield this.rootTemplate.appendSlide(slide);
617
+ }
618
+ yield this.rootTemplate.cleanupExternalGenerator();
619
+ if (this.params.removeExistingSlides) {
620
+ yield this.rootTemplate.truncate();
621
+ }
622
+ });
623
+ }
624
+ /**
625
+ * Write all media files to archive.
626
+ */
627
+ writeMediaFiles() {
628
+ return __awaiter(this, void 0, void 0, function* () {
629
+ const mediaDir = 'ppt/media/';
630
+ for (const file of this.rootTemplate.mediaFiles) {
631
+ const data = (0, types_1.getMediaBuffer)(file, fs.readFileSync);
632
+ let archiveFilename = file.file;
633
+ if (file.prefix) {
634
+ archiveFilename = file.prefix + file.file;
635
+ }
636
+ archiveFilename = (0, slugify_1.default)(archiveFilename);
637
+ yield this.rootTemplate.archive.write(mediaDir + archiveFilename, data);
638
+ yield xml_helper_1.XmlHelper.appendImageExtensionToContentType(this.rootTemplate.archive, file.extension);
639
+ }
640
+ });
641
+ }
642
+ /**
643
+ * Applies all callbacks in this.modifyPresentation-array.
644
+ * The callback array can be pushed by this.modify()
645
+ */
646
+ applyModifyPresentationCallbacks() {
647
+ return __awaiter(this, void 0, void 0, function* () {
648
+ yield xml_helper_1.XmlHelper.modifyXmlInArchive(this.rootTemplate.archive, `ppt/presentation.xml`, this.modifyPresentation);
649
+ });
650
+ }
651
+ /**
652
+ * Apply some callbacks to restore archive/xml structure
653
+ * and prevent corrupted pptx files.
654
+ *
655
+ * TODO: Use every imported image only once
656
+ * TODO: Check for lost relations
657
+ */
658
+ normalizePresentation() {
659
+ return __awaiter(this, void 0, void 0, function* () {
660
+ this.modify(modify_presentation_helper_1.default.normalizeSlideIds);
661
+ this.modify(modify_presentation_helper_1.default.normalizeSlideMasterIds);
662
+ if (this.params.cleanup) {
663
+ if (this.params.removeExistingSlides) {
664
+ this.modify(modify_presentation_helper_1.default.removeUnusedFiles);
665
+ }
666
+ this.modify(modify_presentation_helper_1.default.removedUnusedImages);
667
+ this.modify(modify_presentation_helper_1.default.removeUnusedContentTypes);
668
+ }
669
+ });
670
+ }
671
+ modify(cb) {
672
+ this.modifyPresentation.push(cb);
673
+ return this;
674
+ }
675
+ /**
676
+ * Applies path prefix to given location string.
677
+ * @param location path and/or filename
678
+ * @param [type] template or output
679
+ * @returns location
680
+ */
681
+ getLocation(location, type) {
682
+ switch (type) {
683
+ case 'template':
684
+ if (fs.existsSync(this.templateDir + location)) {
685
+ return this.templateDir + location;
686
+ }
687
+ else if (fs.existsSync(this.templateFallbackDir + location)) {
688
+ return this.templateFallbackDir + location;
689
+ }
690
+ else {
691
+ throw new errors_1.TemplateNotFoundError(location, [
692
+ this.templateDir,
693
+ this.templateFallbackDir,
694
+ ]);
695
+ }
696
+ case 'output':
697
+ return this.outputDir + location;
698
+ default:
699
+ return location;
700
+ }
701
+ }
702
+ }
703
+ exports.default = Automizer;
704
+ //# sourceMappingURL=automizer.js.map