@lemonppt/renderer 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.
- package/LICENSE +21 -0
- package/dist/editor-script.d.ts +2 -0
- package/dist/editor-script.d.ts.map +1 -0
- package/dist/editor-script.js +876 -0
- package/dist/editor-script.js.map +1 -0
- package/dist/export-pdf.d.ts +11 -0
- package/dist/export-pdf.d.ts.map +1 -0
- package/dist/export-pdf.js +28 -0
- package/dist/export-pdf.js.map +1 -0
- package/dist/export-pptx.d.ts +9 -0
- package/dist/export-pptx.d.ts.map +1 -0
- package/dist/export-pptx.js +845 -0
- package/dist/export-pptx.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/render.d.ts +11 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +752 -0
- package/dist/render.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-script.js","sourceRoot":"","sources":["../src/editor-script.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA02B3B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DeckGoal } from '@lemonppt/core';
|
|
2
|
+
export interface ExportPdfOptions {
|
|
3
|
+
/** 输出 PDF 文件路径 */
|
|
4
|
+
outFile: string;
|
|
5
|
+
/** 页面宽度(像素),默认 1280 */
|
|
6
|
+
width?: number;
|
|
7
|
+
/** 页面高度(像素),默认 720 */
|
|
8
|
+
height?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function exportDeckToPdf(goal: DeckGoal, options: ExportPdfOptions): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=export-pdf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-pdf.d.ts","sourceRoot":"","sources":["../src/export-pdf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAO/C,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwB9F"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { writeFile } from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { chromium } from 'playwright';
|
|
5
|
+
import { renderDeck } from './render.js';
|
|
6
|
+
export async function exportDeckToPdf(goal, options) {
|
|
7
|
+
const { outFile, width = 1280, height = 720 } = options;
|
|
8
|
+
const result = renderDeck(goal);
|
|
9
|
+
const tempDir = await os.tmpdir();
|
|
10
|
+
const tempHtml = path.join(tempDir, `lemonppt-${Date.now()}.html`);
|
|
11
|
+
await writeFile(tempHtml, result.html, 'utf-8');
|
|
12
|
+
const browser = await chromium.launch();
|
|
13
|
+
const page = await browser.newPage();
|
|
14
|
+
try {
|
|
15
|
+
await page.goto('file://' + tempHtml, { waitUntil: 'networkidle' });
|
|
16
|
+
await page.pdf({
|
|
17
|
+
path: outFile,
|
|
18
|
+
width: `${width}px`,
|
|
19
|
+
height: `${height}px`,
|
|
20
|
+
printBackground: true,
|
|
21
|
+
preferCSSPageSize: false,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
await browser.close();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=export-pdf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-pdf.js","sourceRoot":"","sources":["../src/export-pdf.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzC,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAc,EAAE,OAAyB;IAC7E,MAAM,EAAE,OAAO,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC;IAExD,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAEhC,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC;IAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACnE,MAAM,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAEhD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC;IACxC,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;IAErC,IAAI,CAAC;QACH,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,QAAQ,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC;QACpE,MAAM,IAAI,CAAC,GAAG,CAAC;YACb,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,GAAG,KAAK,IAAI;YACnB,MAAM,EAAE,GAAG,MAAM,IAAI;YACrB,eAAe,EAAE,IAAI;YACrB,iBAAiB,EAAE,KAAK;SACzB,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DeckGoal } from '@lemonppt/core';
|
|
2
|
+
export interface PptxExportOptions {
|
|
3
|
+
outFile: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
subject?: string;
|
|
6
|
+
author?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function exportDeckToPptx(goal: DeckGoal, options: PptxExportOptions): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=export-pptx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-pptx.d.ts","sourceRoot":"","sources":["../src/export-pptx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAsB,MAAM,gBAAgB,CAAC;AAGnE,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAiBD,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAehG"}
|