pptx-templates 0.3.2 → 0.3.4
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/AI-INSTRUCTOR.md +147 -7
- package/CHANGELOG.md +55 -1
- package/README.md +242 -49
- package/dist/extensions/cli/index.js +8 -0
- package/dist/extensions/cli/index.js.map +1 -1
- package/dist/extensions/index.d.ts +2 -0
- package/dist/extensions/index.js +3 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/template-lint/index.d.ts +3 -1
- package/dist/extensions/template-lint/index.js +4 -1
- package/dist/extensions/template-lint/index.js.map +1 -1
- package/dist/extensions/template-lint/init-cli.d.ts +4 -0
- package/dist/extensions/template-lint/init-cli.js +244 -0
- package/dist/extensions/template-lint/init-cli.js.map +1 -0
- package/dist/extensions/template-lint/lint.d.ts +25 -1
- package/dist/extensions/template-lint/lint.js +37 -4
- package/dist/extensions/template-lint/lint.js.map +1 -1
- package/dist/extensions/template-lint/skeleton.d.ts +51 -0
- package/dist/extensions/template-lint/skeleton.js +199 -0
- package/dist/extensions/template-lint/skeleton.js.map +1 -0
- package/dist/extensions/template-lint/usage.d.ts +1 -0
- package/dist/extensions/template-lint/usage.js +4 -3
- package/dist/extensions/template-lint/usage.js.map +1 -1
- package/dist/extensions/template-logic/expression.d.ts +13 -0
- package/dist/extensions/template-logic/expression.js +53 -8
- package/dist/extensions/template-logic/expression.js.map +1 -1
- package/dist/extensions/template-logic/images.d.ts +6 -2
- package/dist/extensions/template-logic/images.js +62 -12
- package/dist/extensions/template-logic/images.js.map +1 -1
- package/dist/extensions/template-logic/renderer.js +1 -1
- package/dist/extensions/template-logic/renderer.js.map +1 -1
- package/dist/extensions/template-logic/types.d.ts +15 -2
- package/dist/extensions/template-render/cli.d.ts +6 -0
- package/dist/extensions/template-render/cli.js +205 -0
- package/dist/extensions/template-render/cli.js.map +1 -0
- package/dist/extensions/template-render/index.d.ts +19 -0
- package/dist/extensions/template-render/index.js +129 -0
- package/dist/extensions/template-render/index.js.map +1 -0
- package/package.json +14 -15
|
@@ -0,0 +1,129 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
45
|
+
var t = {};
|
|
46
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
47
|
+
t[p] = s[p];
|
|
48
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
49
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
50
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
51
|
+
t[p[i]] = s[p[i]];
|
|
52
|
+
}
|
|
53
|
+
return t;
|
|
54
|
+
};
|
|
55
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
56
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
57
|
+
};
|
|
58
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
+
exports.renderDeck = void 0;
|
|
60
|
+
const fs_1 = __importDefault(require("fs"));
|
|
61
|
+
const toBuffer = (pptx) => Buffer.isBuffer(pptx)
|
|
62
|
+
? pptx
|
|
63
|
+
: pptx instanceof ArrayBuffer
|
|
64
|
+
? Buffer.from(pptx)
|
|
65
|
+
: Buffer.from(pptx.buffer, pptx.byteOffset, pptx.byteLength);
|
|
66
|
+
/**
|
|
67
|
+
* Renders the tags of every slide of a template with one set of data and
|
|
68
|
+
* returns the new .pptx: `renderTemplate` applied to each slide, the masters
|
|
69
|
+
* and layouts of the template kept as they are.
|
|
70
|
+
*
|
|
71
|
+
* A failing tag rejects with a `TemplateRenderError` whose message starts
|
|
72
|
+
* with the slide number ("slide 2: {{euro(p.preis)}}: Not a function …").
|
|
73
|
+
*
|
|
74
|
+
* @param pptx Path to a .pptx file or its contents.
|
|
75
|
+
*/
|
|
76
|
+
const renderDeck = (pptx_1, data_1, ...args_1) => __awaiter(void 0, [pptx_1, data_1, ...args_1], void 0, function* (pptx, data, options = {}) {
|
|
77
|
+
const { slides } = options, renderOptions = __rest(options, ["slides"]);
|
|
78
|
+
const content = typeof pptx === 'string'
|
|
79
|
+
? yield fs_1.default.promises.readFile(pptx)
|
|
80
|
+
: toBuffer(pptx);
|
|
81
|
+
// Loaded here, through the package entry: upstream helpers import
|
|
82
|
+
// src/index.ts, so loading automizer.ts or the template logic first (as
|
|
83
|
+
// the CLI does) breaks on the import cycle
|
|
84
|
+
const { default: Automizer, CallbackError, modify, TemplateRenderError, } = yield Promise.resolve().then(() => __importStar(require('../../index')));
|
|
85
|
+
const pres = new Automizer({
|
|
86
|
+
removeExistingSlides: true,
|
|
87
|
+
// drops the template's own slides from the archive, not only the list
|
|
88
|
+
cleanup: true,
|
|
89
|
+
verbosity: 0,
|
|
90
|
+
})
|
|
91
|
+
.loadRoot(content)
|
|
92
|
+
.load(content, 'deck');
|
|
93
|
+
const available = yield pres.getTemplate('deck').getAllSlideNumbers();
|
|
94
|
+
const numbers = slides !== null && slides !== void 0 ? slides : available;
|
|
95
|
+
const missing = numbers.filter((n) => !available.includes(n));
|
|
96
|
+
if (missing.length) {
|
|
97
|
+
throw new Error(`The deck has no slide ${missing.join(', ')} (slides: ${available.join(', ')})`);
|
|
98
|
+
}
|
|
99
|
+
for (const number of numbers) {
|
|
100
|
+
pres.addSlide('deck', number, (slide) => {
|
|
101
|
+
const render = modify.renderTemplate(data, renderOptions);
|
|
102
|
+
slide.modify((document, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
103
|
+
try {
|
|
104
|
+
yield render(document, context);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
108
|
+
throw new TemplateRenderError(`slide ${number}: ${message}`);
|
|
109
|
+
}
|
|
110
|
+
}));
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
const zip = yield pres.getJSZip();
|
|
115
|
+
return yield zip.generateAsync({
|
|
116
|
+
type: 'nodebuffer',
|
|
117
|
+
compression: 'DEFLATE',
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
// Automizer wraps callback errors; the tag error is what users need
|
|
122
|
+
if (error instanceof CallbackError && error.cause instanceof Error) {
|
|
123
|
+
throw error.cause;
|
|
124
|
+
}
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
exports.renderDeck = renderDeck;
|
|
129
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/template-render/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAoB;AAcpB,MAAM,QAAQ,GAAG,CAAC,IAAuC,EAAU,EAAE,CACnE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;IACnB,CAAC,CAAC,IAAI;IACN,CAAC,CAAC,IAAI,YAAY,WAAW;QAC3B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;QACnB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AAEnE;;;;;;;;;GASG;AACI,MAAM,UAAU,GAAG,4BAIP,EAAE,mEAHnB,IAAgD,EAChD,IAAkB,EAClB,UAA6B,EAAE;IAE/B,MAAM,EAAE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AE;YACtC,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;YAC1D,KAAK,CAAC,MAAM,CAAC,CAAO,QAAQ,EAAE,OAAO,EAAE,EAAE;gBACvC,IAAI,CAAC;oBACH,MAAM,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;gBAClC,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,OAAO,GACX,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBACzD,MAAM,IAAI,mBAAmB,CAAC,SAAS,MAAM,KAAK,OAAO,EAAE,CAAC,CAAC;gBAC/D,CAAC;YACH,CAAC,CAAA,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClC,OAAO,MAAM,GAAG,CAAC,aAAa,CAAC;YAC7B,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,SAAS;SACvB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,oEAAoE;QACpE,IAAI,KAAK,YAAY,aAAa,IAAI,KAAK,CAAC,KAAK,YAAY,KAAK,EAAE,CAAC;YACnE,MAAM,KAAK,CAAC,KAAK,CAAC;QACpB,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAA,CAAC;AAlEW,QAAA,UAAU,cAkErB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pptx-templates",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.4",
|
|
4
|
+
"description": "Fill PowerPoint templates with data: tags, conditions and loops written into the slides, rendered from JavaScript or TypeScript",
|
|
5
|
+
"homepage": "https://daborsten.github.io/pptx-templates/",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
7
8
|
"url": "git+https://github.com/DaBorsten/pptx-templates.git"
|
|
@@ -40,21 +41,19 @@
|
|
|
40
41
|
},
|
|
41
42
|
"types": "dist/index.d.ts",
|
|
42
43
|
"keywords": [
|
|
43
|
-
"
|
|
44
|
-
"js-create-pptx",
|
|
45
|
-
"js-generate-powerpoint",
|
|
46
|
-
"js-pptx",
|
|
47
|
-
"js-produce-powerpoint",
|
|
48
|
-
"js-powerpoint",
|
|
44
|
+
"pptx",
|
|
49
45
|
"powerpoint",
|
|
50
|
-
"
|
|
51
|
-
"powerpoint-
|
|
52
|
-
"
|
|
46
|
+
"pptx-template",
|
|
47
|
+
"powerpoint-template",
|
|
48
|
+
"templating",
|
|
49
|
+
"template-engine",
|
|
50
|
+
"data-driven",
|
|
51
|
+
"pptx-generator",
|
|
53
52
|
"powerpoint-generator",
|
|
54
|
-
"powerpoint-
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
53
|
+
"powerpoint-automation",
|
|
54
|
+
"presentation",
|
|
55
|
+
"openxml",
|
|
56
|
+
"template-linter"
|
|
58
57
|
],
|
|
59
58
|
"devDependencies": {
|
|
60
59
|
"@eslint/js": "^10.0.1",
|