@things-factory/integration-headless 7.0.48 → 7.0.53
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/dist-server/engine/task/headless-pdf-capture-board.d.ts +59 -1
- package/dist-server/engine/task/headless-pdf-capture-board.js +29 -250
- package/dist-server/engine/task/headless-pdf-capture-board.js.map +1 -1
- package/dist-server/engine/task/headless-pdf-capture-markdown.d.ts +52 -0
- package/dist-server/engine/task/headless-pdf-capture-markdown.js +38 -0
- package/dist-server/engine/task/headless-pdf-capture-markdown.js.map +1 -0
- package/dist-server/engine/task/headless-pdf-capture.d.ts +52 -1
- package/dist-server/engine/task/headless-pdf-capture.js +13 -196
- package/dist-server/engine/task/headless-pdf-capture.js.map +1 -1
- package/dist-server/engine/task/index.d.ts +1 -0
- package/dist-server/engine/task/index.js +1 -0
- package/dist-server/engine/task/index.js.map +1 -1
- package/dist-server/engine/task/pdf-capture-util.d.ts +88 -0
- package/dist-server/engine/task/pdf-capture-util.js +223 -0
- package/dist-server/engine/task/pdf-capture-util.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/server/engine/task/headless-pdf-capture-board.ts +42 -293
- package/server/engine/task/headless-pdf-capture-markdown.ts +41 -0
- package/server/engine/task/headless-pdf-capture.ts +12 -226
- package/server/engine/task/index.ts +1 -0
- package/server/engine/task/pdf-capture-util.ts +276 -0
|
@@ -1 +1,59 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export declare function HeadlessPDFCaptureBoard(step: any, context: any): Promise<{
|
|
2
|
+
data: any;
|
|
3
|
+
}>;
|
|
4
|
+
export declare namespace HeadlessPDFCaptureBoard {
|
|
5
|
+
var parameterSpec: ({
|
|
6
|
+
type: string;
|
|
7
|
+
name: string;
|
|
8
|
+
label: string;
|
|
9
|
+
property?: undefined;
|
|
10
|
+
description?: undefined;
|
|
11
|
+
placeholder?: undefined;
|
|
12
|
+
defaultValue?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
type: string;
|
|
15
|
+
name: string;
|
|
16
|
+
label: string;
|
|
17
|
+
property: {
|
|
18
|
+
options: {
|
|
19
|
+
display: string;
|
|
20
|
+
value: string;
|
|
21
|
+
}[];
|
|
22
|
+
};
|
|
23
|
+
description: string;
|
|
24
|
+
placeholder?: undefined;
|
|
25
|
+
defaultValue?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
type: string;
|
|
28
|
+
name: string;
|
|
29
|
+
label: string;
|
|
30
|
+
placeholder: string;
|
|
31
|
+
description: string;
|
|
32
|
+
property?: undefined;
|
|
33
|
+
defaultValue?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
type: string;
|
|
36
|
+
name: string;
|
|
37
|
+
label: string;
|
|
38
|
+
defaultValue: number;
|
|
39
|
+
description: string;
|
|
40
|
+
property?: undefined;
|
|
41
|
+
placeholder?: undefined;
|
|
42
|
+
} | {
|
|
43
|
+
type: string;
|
|
44
|
+
name: string;
|
|
45
|
+
label: string;
|
|
46
|
+
defaultValue: boolean;
|
|
47
|
+
description: string;
|
|
48
|
+
property?: undefined;
|
|
49
|
+
placeholder?: undefined;
|
|
50
|
+
} | {
|
|
51
|
+
type: string;
|
|
52
|
+
name: string;
|
|
53
|
+
label: string;
|
|
54
|
+
property: {
|
|
55
|
+
queryName: string;
|
|
56
|
+
};
|
|
57
|
+
})[];
|
|
58
|
+
var help: string;
|
|
59
|
+
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const ejs = tslib_1.__importStar(require("ejs"));
|
|
3
|
+
exports.HeadlessPDFCaptureBoard = HeadlessPDFCaptureBoard;
|
|
5
4
|
const integration_base_1 = require("@things-factory/integration-base");
|
|
6
|
-
const
|
|
7
|
-
const utils_1 = require("@things-factory/utils");
|
|
5
|
+
const pdf_capture_util_1 = require("./pdf-capture-util");
|
|
8
6
|
const board_service_1 = require("@things-factory/board-service");
|
|
9
|
-
const pdf_lib_1 = require("pdf-lib");
|
|
10
7
|
const PAGE_FORMATS = {
|
|
11
8
|
A4: { width: 595.28, height: 841.89 },
|
|
12
9
|
A3: { width: 841.89, height: 1190.55 },
|
|
@@ -14,90 +11,37 @@ const PAGE_FORMATS = {
|
|
|
14
11
|
Legal: { width: 612, height: 1008 }
|
|
15
12
|
};
|
|
16
13
|
async function HeadlessPDFCaptureBoard(step, context) {
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var { domain, data, user, logger, __headless_pdf } = context;
|
|
21
|
-
if (!__headless_pdf) {
|
|
22
|
-
throw new Error('It requires headless-pdf-open to be performed first');
|
|
23
|
-
}
|
|
24
|
-
if (!board || !board.id) {
|
|
25
|
-
throw new Error('The board property must be set');
|
|
26
|
-
}
|
|
27
|
-
var { pdfDoc, header, footer, watermark } = __headless_pdf;
|
|
28
|
-
var headlessPool = integration_base_2.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
|
29
|
-
let browser;
|
|
14
|
+
var _a, _b;
|
|
15
|
+
const pdfUtil = new pdf_capture_util_1.PDFCaptureUtil(context);
|
|
16
|
+
await pdfUtil.initBrowser(step.connection);
|
|
30
17
|
try {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
18
|
+
const { board, draft, format = 'A4', landscape, preferCSSPageSize } = step.params;
|
|
19
|
+
if (!board || !board.id) {
|
|
20
|
+
throw new Error('The board property must be set');
|
|
21
|
+
}
|
|
22
|
+
const { model, base } = await board_service_1.BoardFunc.headlessModel({ domain: context.domain, id: board.id }, draft);
|
|
23
|
+
const [fontsToUse, fontStyles] = await board_service_1.BoardFunc.fonts(context.domain);
|
|
36
24
|
model.fonts = fontsToUse;
|
|
37
25
|
model.fontStyles = fontStyles;
|
|
38
|
-
|
|
26
|
+
let width = (_a = PAGE_FORMATS[format]) === null || _a === void 0 ? void 0 : _a.width;
|
|
27
|
+
let height = (_b = PAGE_FORMATS[format]) === null || _b === void 0 ? void 0 : _b.height;
|
|
39
28
|
if (preferCSSPageSize) {
|
|
40
29
|
width = undefined;
|
|
41
30
|
height = undefined;
|
|
42
31
|
}
|
|
43
|
-
|
|
44
|
-
const pageDimensions = PAGE_FORMATS[format];
|
|
45
|
-
width = pageDimensions.width;
|
|
46
|
-
height = pageDimensions.height;
|
|
47
|
-
}
|
|
48
|
-
if (landscape) {
|
|
32
|
+
if (landscape && width && height) {
|
|
49
33
|
;
|
|
50
34
|
[width, height] = [height, width];
|
|
51
35
|
}
|
|
52
|
-
const contentWidth = width - marginLeft - marginRight;
|
|
53
|
-
const contentHeight = height - marginTop - marginBottom;
|
|
54
|
-
const boardWidthPt = (boardWidthPx * 72) / 96;
|
|
55
|
-
const boardHeightPt = (boardHeightPx * 72) / 96;
|
|
56
|
-
const widthRatio = contentWidth / boardWidthPt;
|
|
57
|
-
const heightRatio = contentHeight / boardHeightPt;
|
|
58
|
-
const ratio = Math.min(widthRatio, heightRatio);
|
|
59
|
-
const scaledBoardWidthPt = boardWidthPt * ratio;
|
|
60
|
-
const scaledBoardHeightPt = boardHeightPt * ratio;
|
|
61
|
-
const offsetX = (contentWidth - scaledBoardWidthPt) / 2 + marginLeft;
|
|
62
|
-
const offsetY = (contentHeight - scaledBoardHeightPt) / 2 + marginBottom;
|
|
63
|
-
await page.setViewport({ width: Math.round(boardWidthPx * ratio), height: Math.round(boardHeightPx * ratio) });
|
|
64
|
-
await page.setRequestInterception(true);
|
|
65
|
-
await page.setDefaultTimeout(10000);
|
|
66
|
-
page.on('console', async (msg) => {
|
|
67
|
-
console.log(`[browser ${msg.type()}] ${msg.text()}`);
|
|
68
|
-
});
|
|
69
|
-
page.on('requestfailed', request => {
|
|
70
|
-
console.log('Request failed:', request.url());
|
|
71
|
-
});
|
|
72
36
|
const protocol = 'http';
|
|
73
37
|
const host = 'localhost';
|
|
74
38
|
const port = process.env.PORT ? `:${process.env.PORT}` : '';
|
|
75
39
|
const path = '/internal-board-service-view';
|
|
76
40
|
const url = `${protocol}://${host}${port}${path}`;
|
|
77
|
-
const
|
|
78
|
-
page.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
method: 'POST',
|
|
82
|
-
headers: {
|
|
83
|
-
'Content-Type': 'application/json',
|
|
84
|
-
'x-things-factory-domain': domain === null || domain === void 0 ? void 0 : domain.subdomain,
|
|
85
|
-
Authorization: 'Bearer ' + token
|
|
86
|
-
},
|
|
87
|
-
postData: JSON.stringify({
|
|
88
|
-
model,
|
|
89
|
-
base
|
|
90
|
-
})
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
else if (request.url().startsWith(`${protocol}://${host}${port}`)) {
|
|
94
|
-
request.continue({
|
|
95
|
-
headers: Object.assign(Object.assign({}, request.headers()), { 'x-things-factory-domain': domain === null || domain === void 0 ? void 0 : domain.subdomain, Authorization: 'Bearer ' + token })
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
request.continue();
|
|
100
|
-
}
|
|
41
|
+
const page = await pdfUtil.browser.newPage();
|
|
42
|
+
await page.setViewport({
|
|
43
|
+
width: Math.round(width || 800), // Fallback for width if not defined
|
|
44
|
+
height: Math.round(height || 600) // Fallback for height if not defined
|
|
101
45
|
});
|
|
102
46
|
await page.goto(url);
|
|
103
47
|
await page.evaluate(data => {
|
|
@@ -106,105 +50,25 @@ async function HeadlessPDFCaptureBoard(step, context) {
|
|
|
106
50
|
return new Promise(resolve => {
|
|
107
51
|
requestAnimationFrame(() => resolve(0));
|
|
108
52
|
});
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
logger.warn(`Template rendering error: ${error.message}`);
|
|
116
|
-
return template;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
header = renderTemplateSafely(header, __headless_pdf);
|
|
120
|
-
footer = renderTemplateSafely(footer, __headless_pdf);
|
|
121
|
-
// Apply header, footer, and watermark using Puppeteer
|
|
122
|
-
// Apply header, footer, and watermark using Puppeteer
|
|
123
|
-
if (header || footer || watermark) {
|
|
124
|
-
await page.evaluate(({ header, footer, watermark, isLandscape }) => {
|
|
125
|
-
const setPositioning = (element, position) => {
|
|
126
|
-
element.style.position = 'fixed';
|
|
127
|
-
element.style.left = '0';
|
|
128
|
-
element.style.width = '100%';
|
|
129
|
-
element.style.textAlign = 'center';
|
|
130
|
-
element.style.fontSize = '12px';
|
|
131
|
-
element.style.margin = '0';
|
|
132
|
-
element.style.padding = '0';
|
|
133
|
-
if (position === 'header') {
|
|
134
|
-
element.style.top = '0';
|
|
135
|
-
}
|
|
136
|
-
else if (position === 'footer') {
|
|
137
|
-
element.style.bottom = '0';
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
if (header) {
|
|
141
|
-
const headerElement = document.createElement('div');
|
|
142
|
-
headerElement.innerHTML = header;
|
|
143
|
-
setPositioning(headerElement, 'header');
|
|
144
|
-
document.body.appendChild(headerElement);
|
|
145
|
-
}
|
|
146
|
-
if (footer) {
|
|
147
|
-
const footerElement = document.createElement('div');
|
|
148
|
-
footerElement.innerHTML = footer;
|
|
149
|
-
setPositioning(footerElement, 'footer');
|
|
150
|
-
document.body.appendChild(footerElement);
|
|
151
|
-
}
|
|
152
|
-
if (watermark) {
|
|
153
|
-
const watermarkElement = document.createElement('div');
|
|
154
|
-
watermarkElement.innerHTML = watermark;
|
|
155
|
-
watermarkElement.style.position = 'fixed';
|
|
156
|
-
watermarkElement.style.top = isLandscape ? '40%' : '50%';
|
|
157
|
-
watermarkElement.style.left = '50%';
|
|
158
|
-
watermarkElement.style.transform = 'translate(-50%, -50%) rotate(-45deg)';
|
|
159
|
-
watermarkElement.style.opacity = '0.2';
|
|
160
|
-
watermarkElement.style.fontSize = '50px';
|
|
161
|
-
watermarkElement.style.color = 'red';
|
|
162
|
-
watermarkElement.style.pointerEvents = 'none';
|
|
163
|
-
watermarkElement.style.zIndex = '9999';
|
|
164
|
-
document.body.appendChild(watermarkElement);
|
|
165
|
-
}
|
|
166
|
-
}, { header, footer, watermark, isLandscape: landscape });
|
|
167
|
-
}
|
|
168
|
-
const pageOptions = {
|
|
169
|
-
format,
|
|
170
|
-
width: `${scaledBoardWidthPt}px`,
|
|
171
|
-
height: `${scaledBoardHeightPt}px`,
|
|
172
|
-
margin: {
|
|
173
|
-
top: `${offsetY}px`,
|
|
174
|
-
right: `${offsetX}px`,
|
|
175
|
-
bottom: `${offsetY}px`,
|
|
176
|
-
left: `${offsetX}px`
|
|
177
|
-
},
|
|
178
|
-
scale,
|
|
179
|
-
printBackground,
|
|
180
|
-
landscape,
|
|
181
|
-
displayHeaderFooter: false, // Handled via Puppeteer directly
|
|
182
|
-
preferCSSPageSize
|
|
183
|
-
};
|
|
184
|
-
const contentBuffer = await page.pdf(pageOptions);
|
|
185
|
-
const contentPdfDoc = await pdf_lib_1.PDFDocument.load(contentBuffer);
|
|
186
|
-
const copiedPages = await pdfDoc.copyPages(contentPdfDoc, contentPdfDoc.getPageIndices());
|
|
187
|
-
copiedPages.forEach(page => pdfDoc.addPage(page));
|
|
188
|
-
__headless_pdf.pageCount += copiedPages.length;
|
|
189
|
-
await page.close();
|
|
190
|
-
headlessPool.release(browser);
|
|
53
|
+
}, { model, base });
|
|
54
|
+
// 페이지 옵션 설정
|
|
55
|
+
const pageOptions = pdfUtil.buildPageOptions(Object.assign(Object.assign({}, step.params), { width: width ? `${width}px` : undefined, height: height ? `${height}px` : undefined }));
|
|
56
|
+
// PDF 생성 및 추가
|
|
57
|
+
const htmlContent = ''; // 보드에서 직접 렌더링되므로 HTML 컨텐츠가 비어있음
|
|
58
|
+
await pdfUtil.processPageAndGeneratePDF(Object.assign(Object.assign({}, step.params), { width, height }), htmlContent);
|
|
191
59
|
return {
|
|
192
|
-
data: __headless_pdf
|
|
60
|
+
data: context.__headless_pdf
|
|
193
61
|
};
|
|
194
62
|
}
|
|
195
63
|
catch (error) {
|
|
196
|
-
if (browser) {
|
|
197
|
-
await browser.close();
|
|
198
|
-
}
|
|
199
64
|
throw error;
|
|
200
65
|
}
|
|
66
|
+
finally {
|
|
67
|
+
await pdfUtil.closeBrowser();
|
|
68
|
+
}
|
|
201
69
|
}
|
|
202
70
|
HeadlessPDFCaptureBoard.parameterSpec = [
|
|
203
|
-
|
|
204
|
-
type: 'scenario-step-input',
|
|
205
|
-
name: 'accessor',
|
|
206
|
-
label: 'accessor'
|
|
207
|
-
},
|
|
71
|
+
...(0, pdf_capture_util_1.getCommonParameterSpec)(),
|
|
208
72
|
{
|
|
209
73
|
type: 'resource-object',
|
|
210
74
|
name: 'board',
|
|
@@ -219,91 +83,6 @@ HeadlessPDFCaptureBoard.parameterSpec = [
|
|
|
219
83
|
label: 'board-draft',
|
|
220
84
|
defaultValue: false,
|
|
221
85
|
description: 'Set whether to get the current working version or the last released version'
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
type: 'select',
|
|
225
|
-
name: 'format',
|
|
226
|
-
label: 'page-format',
|
|
227
|
-
property: {
|
|
228
|
-
options: [
|
|
229
|
-
{ display: '', value: '' },
|
|
230
|
-
{ display: 'A4', value: 'A4' },
|
|
231
|
-
{ display: 'A3', value: 'A3' },
|
|
232
|
-
{ display: 'Letter', value: 'Letter' },
|
|
233
|
-
{ display: 'Legal', value: 'Legal' }
|
|
234
|
-
]
|
|
235
|
-
},
|
|
236
|
-
description: 'Select the paper format for the PDF'
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
type: 'string',
|
|
240
|
-
name: 'width',
|
|
241
|
-
label: 'page-width',
|
|
242
|
-
placeholder: '(e.g., "8.5in", "21cm", "600px")',
|
|
243
|
-
description: 'Specify the width of the page (e.g., "8.5in", "21cm", "600px")'
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
type: 'string',
|
|
247
|
-
name: 'height',
|
|
248
|
-
label: 'page-height',
|
|
249
|
-
placeholder: '(e.g., "11in", "29.7cm", "800px")',
|
|
250
|
-
description: 'Specify the height of the page (e.g., "11in", "29.7cm", "800px")'
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
type: 'string',
|
|
254
|
-
name: 'marginTop',
|
|
255
|
-
label: 'page-margin-top',
|
|
256
|
-
placeholder: '(e.g., "0.5in", "1cm", "100px")',
|
|
257
|
-
description: 'Set the top margin for the page'
|
|
258
|
-
},
|
|
259
|
-
{
|
|
260
|
-
type: 'string',
|
|
261
|
-
name: 'marginBottom',
|
|
262
|
-
label: 'page-margin-bottom',
|
|
263
|
-
placeholder: '(e.g., "0.5in", "1cm", "100px")',
|
|
264
|
-
description: 'Set the bottom margin for the page'
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
type: 'string',
|
|
268
|
-
name: 'marginLeft',
|
|
269
|
-
label: 'page-margin-left',
|
|
270
|
-
placeholder: '(e.g., "0.5in", "1cm", "100px")',
|
|
271
|
-
description: 'Set the left margin for the page'
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
type: 'string',
|
|
275
|
-
name: 'marginRight',
|
|
276
|
-
label: 'page-margin-right',
|
|
277
|
-
placeholder: '(e.g., "0.5in", "1cm", "100px")',
|
|
278
|
-
description: 'Set the right margin for the page'
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
type: 'number',
|
|
282
|
-
name: 'scale',
|
|
283
|
-
label: 'page-scale',
|
|
284
|
-
defaultValue: 1,
|
|
285
|
-
description: 'Set the scale of the page content (default is 1)'
|
|
286
|
-
},
|
|
287
|
-
{
|
|
288
|
-
type: 'boolean',
|
|
289
|
-
name: 'printBackground',
|
|
290
|
-
label: 'print-background',
|
|
291
|
-
defaultValue: true,
|
|
292
|
-
description: 'Include background graphics when printing the page'
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
type: 'boolean',
|
|
296
|
-
name: 'landscape',
|
|
297
|
-
label: 'landscape',
|
|
298
|
-
defaultValue: false,
|
|
299
|
-
description: 'Print the PDF in landscape orientation'
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
type: 'boolean',
|
|
303
|
-
name: 'preferCSSPageSize',
|
|
304
|
-
label: 'prefer-css-page-size',
|
|
305
|
-
defaultValue: false,
|
|
306
|
-
description: 'Whether to prefer the CSS-defined page size over the given width and height'
|
|
307
86
|
}
|
|
308
87
|
];
|
|
309
88
|
HeadlessPDFCaptureBoard.help = 'integration/task/headless-pdf-capture-board';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless-pdf-capture-board.js","sourceRoot":"","sources":["../../../server/engine/task/headless-pdf-capture-board.ts"],"names":[],"mappings":";;;AAAA,iDAA0B;AAC1B,uEAA+D;AAC/D,uEAAoE;AACpE,iDAA8C;AAC9C,iEAAyD;AACzD,qCAAqC;AAErC,MAAM,YAAY,GAAG;IACnB,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;IACrC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE;IACtC,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;IACnC,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;CACpC,CAAA;AAED,KAAK,UAAU,uBAAuB,CAAC,IAAI,EAAE,OAAO;IAClD,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAC9D,IAAI,EACF,QAAQ,EACR,KAAK,EACL,KAAK,EACL,MAAM,GAAG,IAAI,EAAE,0BAA0B;IACzC,KAAK,EACL,MAAM,EACN,SAAS,GAAG,CAAC,EACb,YAAY,GAAG,CAAC,EAChB,UAAU,GAAG,CAAC,EACd,WAAW,GAAG,CAAC,EACf,KAAK,EACL,eAAe,EACf,SAAS,EACT,iBAAiB,EAClB,GAAG,WAAW,IAAI,EAAE,CAAA;IACrB,IAAI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AC3B,WAAW,EAAE,iCAAiC;QAC9C,WAAW,EAAE,oCAAoC;KAClD;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,kBAAkB;QACzB,WAAW,EAAE,iCAAiC;QAC9C,WAAW,EAAE,kCAAkC;KAChD;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EAAE,iCAAiC;QAC9C,WAAW,EAAE,mCAAmC;KACjD;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,YAAY;QACnB,YAAY,EAAE,CAAC;QACf,WAAW,EAAE,kDAAkD;KAChE;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,iBAAiB;QACvB,KAAK,EAAE,kBAAkB;QACzB,YAAY,EAAE,IAAI;QAClB,WAAW,EAAE,oDAAoD;KAClE;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,WAAW;QAClB,YAAY,EAAE,KAAK;QACnB,WAAW,EAAE,wCAAwC;KACtD;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,mBAAmB;QACzB,KAAK,EAAE,sBAAsB;QAC7B,YAAY,EAAE,KAAK;QACnB,WAAW,EAAE,6EAA6E;KAC3F;CACF,CAAA;AAED,uBAAuB,CAAC,IAAI,GAAG,6CAA6C,CAAA;AAE5E,+BAAY,CAAC,mBAAmB,CAAC,4BAA4B,EAAE,uBAAuB,CAAC,CAAA","sourcesContent":["import * as ejs from 'ejs'\nimport { TaskRegistry } from '@things-factory/integration-base'\nimport { ConnectionManager } from '@things-factory/integration-base'\nimport { access } from '@things-factory/utils'\nimport { BoardFunc } from '@things-factory/board-service'\nimport { PDFDocument } from 'pdf-lib'\n\nconst PAGE_FORMATS = {\n A4: { width: 595.28, height: 841.89 },\n A3: { width: 841.89, height: 1190.55 },\n Letter: { width: 612, height: 792 },\n Legal: { width: 612, height: 1008 }\n}\n\nasync function HeadlessPDFCaptureBoard(step, context) {\n var { connection: connectionName, params: stepOptions } = step\n var {\n accessor,\n board,\n draft,\n format = 'A4', // Set default value to A4\n width,\n height,\n marginTop = 0,\n marginBottom = 0,\n marginLeft = 0,\n marginRight = 0,\n scale,\n printBackground,\n landscape,\n preferCSSPageSize\n } = stepOptions || {}\n var { domain, data, user, logger, __headless_pdf } = context\n\n if (!__headless_pdf) {\n throw new Error('It requires headless-pdf-open to be performed first')\n }\n\n if (!board || !board.id) {\n throw new Error('The board property must be set')\n }\n\n var { pdfDoc, header, footer, watermark } = __headless_pdf\n\n var headlessPool = ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n let browser\n\n try {\n browser = await headlessPool.acquire()\n const page = await browser.newPage()\n\n const boardInput = access(accessor, data)\n\n var { model, base } = await BoardFunc.headlessModel({ domain, id: board.id, model }, draft)\n const [fontsToUse, fontStyles] = await BoardFunc.fonts(domain)\n\n model.fonts = fontsToUse\n model.fontStyles = fontStyles\n\n var { width: boardWidthPx, height: boardHeightPx } = model\n\n if (preferCSSPageSize) {\n width = undefined\n height = undefined\n } else if (PAGE_FORMATS[format]) {\n const pageDimensions = PAGE_FORMATS[format]\n width = pageDimensions.width\n height = pageDimensions.height\n }\n\n if (landscape) {\n ;[width, height] = [height, width]\n }\n\n const contentWidth = width - marginLeft - marginRight\n const contentHeight = height - marginTop - marginBottom\n\n const boardWidthPt = (boardWidthPx * 72) / 96\n const boardHeightPt = (boardHeightPx * 72) / 96\n\n const widthRatio = contentWidth / boardWidthPt\n const heightRatio = contentHeight / boardHeightPt\n const ratio = Math.min(widthRatio, heightRatio)\n\n const scaledBoardWidthPt = boardWidthPt * ratio\n const scaledBoardHeightPt = boardHeightPt * ratio\n\n const offsetX = (contentWidth - scaledBoardWidthPt) / 2 + marginLeft\n const offsetY = (contentHeight - scaledBoardHeightPt) / 2 + marginBottom\n\n await page.setViewport({ width: Math.round(boardWidthPx * ratio), height: Math.round(boardHeightPx * ratio) })\n await page.setRequestInterception(true)\n await page.setDefaultTimeout(10000)\n\n page.on('console', async msg => {\n console.log(`[browser ${msg.type()}] ${msg.text()}`)\n })\n\n page.on('requestfailed', request => {\n console.log('Request failed:', request.url())\n })\n\n const protocol = 'http'\n const host = 'localhost'\n const port = process.env.PORT ? `:${process.env.PORT}` : ''\n const path = '/internal-board-service-view'\n const url = `${protocol}://${host}${port}${path}`\n\n const token = await user?.sign()\n\n page.on('request', request => {\n if (request.url() === url) {\n request.continue({\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'x-things-factory-domain': domain?.subdomain,\n Authorization: 'Bearer ' + token\n },\n postData: JSON.stringify({\n model,\n base\n })\n })\n } else if (request.url().startsWith(`${protocol}://${host}${port}`)) {\n request.continue({\n headers: {\n ...request.headers(),\n 'x-things-factory-domain': domain?.subdomain,\n Authorization: 'Bearer ' + token\n }\n })\n } else {\n request.continue()\n }\n })\n\n await page.goto(url)\n\n await page.evaluate(data => {\n //@ts-ignore\n s.data = data\n return new Promise(resolve => {\n requestAnimationFrame(() => resolve(0))\n })\n }, boardInput)\n\n const renderTemplateSafely = (template, data) => {\n try {\n return ejs.render(template, data)\n } catch (error) {\n logger.warn(`Template rendering error: ${error.message}`)\n return template\n }\n }\n\n header = renderTemplateSafely(header, __headless_pdf)\n footer = renderTemplateSafely(footer, __headless_pdf)\n\n // Apply header, footer, and watermark using Puppeteer\n // Apply header, footer, and watermark using Puppeteer\n if (header || footer || watermark) {\n await page.evaluate(\n ({ header, footer, watermark, isLandscape }) => {\n const setPositioning = (element, position) => {\n element.style.position = 'fixed'\n element.style.left = '0'\n element.style.width = '100%'\n element.style.textAlign = 'center'\n element.style.fontSize = '12px'\n element.style.margin = '0'\n element.style.padding = '0'\n if (position === 'header') {\n element.style.top = '0'\n } else if (position === 'footer') {\n element.style.bottom = '0'\n }\n }\n\n if (header) {\n const headerElement = document.createElement('div')\n headerElement.innerHTML = header\n setPositioning(headerElement, 'header')\n document.body.appendChild(headerElement)\n }\n\n if (footer) {\n const footerElement = document.createElement('div')\n footerElement.innerHTML = footer\n setPositioning(footerElement, 'footer')\n document.body.appendChild(footerElement)\n }\n\n if (watermark) {\n const watermarkElement = document.createElement('div')\n watermarkElement.innerHTML = watermark\n watermarkElement.style.position = 'fixed'\n watermarkElement.style.top = isLandscape ? '40%' : '50%'\n watermarkElement.style.left = '50%'\n watermarkElement.style.transform = 'translate(-50%, -50%) rotate(-45deg)'\n watermarkElement.style.opacity = '0.2'\n watermarkElement.style.fontSize = '50px'\n watermarkElement.style.color = 'red'\n watermarkElement.style.pointerEvents = 'none'\n watermarkElement.style.zIndex = '9999'\n document.body.appendChild(watermarkElement)\n }\n },\n { header, footer, watermark, isLandscape: landscape }\n )\n }\n\n const pageOptions = {\n format,\n width: `${scaledBoardWidthPt}px`,\n height: `${scaledBoardHeightPt}px`,\n margin: {\n top: `${offsetY}px`,\n right: `${offsetX}px`,\n bottom: `${offsetY}px`,\n left: `${offsetX}px`\n },\n scale,\n printBackground,\n landscape,\n displayHeaderFooter: false, // Handled via Puppeteer directly\n preferCSSPageSize\n }\n\n const contentBuffer = await page.pdf(pageOptions)\n const contentPdfDoc = await PDFDocument.load(contentBuffer)\n const copiedPages = await pdfDoc.copyPages(contentPdfDoc, contentPdfDoc.getPageIndices())\n\n copiedPages.forEach(page => pdfDoc.addPage(page))\n\n __headless_pdf.pageCount += copiedPages.length\n\n await page.close()\n headlessPool.release(browser)\n\n return {\n data: __headless_pdf\n }\n } catch (error) {\n if (browser) {\n await browser.close()\n }\n\n throw error\n }\n}\n\nHeadlessPDFCaptureBoard.parameterSpec = [\n {\n type: 'scenario-step-input',\n name: 'accessor',\n label: 'accessor'\n },\n {\n type: 'resource-object',\n name: 'board',\n label: 'board',\n property: {\n queryName: 'boards'\n }\n },\n {\n type: 'boolean',\n name: 'draft',\n label: 'board-draft',\n defaultValue: false,\n description: 'Set whether to get the current working version or the last released version'\n },\n {\n type: 'select',\n name: 'format',\n label: 'page-format',\n property: {\n options: [\n { display: '', value: '' },\n { display: 'A4', value: 'A4' },\n { display: 'A3', value: 'A3' },\n { display: 'Letter', value: 'Letter' },\n { display: 'Legal', value: 'Legal' }\n ]\n },\n description: 'Select the paper format for the PDF'\n },\n {\n type: 'string',\n name: 'width',\n label: 'page-width',\n placeholder: '(e.g., \"8.5in\", \"21cm\", \"600px\")',\n description: 'Specify the width of the page (e.g., \"8.5in\", \"21cm\", \"600px\")'\n },\n {\n type: 'string',\n name: 'height',\n label: 'page-height',\n placeholder: '(e.g., \"11in\", \"29.7cm\", \"800px\")',\n description: 'Specify the height of the page (e.g., \"11in\", \"29.7cm\", \"800px\")'\n },\n {\n type: 'string',\n name: 'marginTop',\n label: 'page-margin-top',\n placeholder: '(e.g., \"0.5in\", \"1cm\", \"100px\")',\n description: 'Set the top margin for the page'\n },\n {\n type: 'string',\n name: 'marginBottom',\n label: 'page-margin-bottom',\n placeholder: '(e.g., \"0.5in\", \"1cm\", \"100px\")',\n description: 'Set the bottom margin for the page'\n },\n {\n type: 'string',\n name: 'marginLeft',\n label: 'page-margin-left',\n placeholder: '(e.g., \"0.5in\", \"1cm\", \"100px\")',\n description: 'Set the left margin for the page'\n },\n {\n type: 'string',\n name: 'marginRight',\n label: 'page-margin-right',\n placeholder: '(e.g., \"0.5in\", \"1cm\", \"100px\")',\n description: 'Set the right margin for the page'\n },\n {\n type: 'number',\n name: 'scale',\n label: 'page-scale',\n defaultValue: 1,\n description: 'Set the scale of the page content (default is 1)'\n },\n {\n type: 'boolean',\n name: 'printBackground',\n label: 'print-background',\n defaultValue: true,\n description: 'Include background graphics when printing the page'\n },\n {\n type: 'boolean',\n name: 'landscape',\n label: 'landscape',\n defaultValue: false,\n description: 'Print the PDF in landscape orientation'\n },\n {\n type: 'boolean',\n name: 'preferCSSPageSize',\n label: 'prefer-css-page-size',\n defaultValue: false,\n description: 'Whether to prefer the CSS-defined page size over the given width and height'\n }\n]\n\nHeadlessPDFCaptureBoard.help = 'integration/task/headless-pdf-capture-board'\n\nTaskRegistry.registerTaskHandler('headless-pdf-capture-board', HeadlessPDFCaptureBoard)\n"]}
|
|
1
|
+
{"version":3,"file":"headless-pdf-capture-board.js","sourceRoot":"","sources":["../../../server/engine/task/headless-pdf-capture-board.ts"],"names":[],"mappings":";;AAcA,0DA0EC;AAxFD,uEAA+D;AAE/D,yDAA2E;AAC3E,iEAAyD;AAEzD,MAAM,YAAY,GAAG;IACnB,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;IACrC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE;IACtC,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;IACnC,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;CACpC,CAAA;AAIM,KAAK,UAAU,uBAAuB,CAAC,IAAI,EAAE,OAAO;;IACzD,MAAM,OAAO,GAAG,IAAI,iCAAc,CAAC,OAAO,CAAC,CAAA;IAC3C,MAAM,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAE1C,IAAI,CAAC;QACH,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;QAEjF,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;QACnD,CAAC;QAED,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,yBAAS,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,C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,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,aAAa;QACpB,YAAY,EAAE,KAAK;QACnB,WAAW,EAAE,6EAA6E;KAC3F;CACF,CAAA;AAED,uBAAuB,CAAC,IAAI,GAAG,6CAA6C,CAAA;AAE5E,+BAAY,CAAC,mBAAmB,CAAC,4BAA4B,EAAE,uBAAuB,CAAC,CAAA","sourcesContent":["import { TaskRegistry } from '@things-factory/integration-base'\n\nimport { PDFCaptureUtil, getCommonParameterSpec } from './pdf-capture-util'\nimport { BoardFunc } from '@things-factory/board-service'\n\nconst PAGE_FORMATS = {\n A4: { width: 595.28, height: 841.89 },\n A3: { width: 841.89, height: 1190.55 },\n Letter: { width: 612, height: 792 },\n Legal: { width: 612, height: 1008 }\n}\n\ntype PageFormat = keyof typeof PAGE_FORMATS\n\nexport async function HeadlessPDFCaptureBoard(step, context) {\n const pdfUtil = new PDFCaptureUtil(context)\n await pdfUtil.initBrowser(step.connection)\n\n try {\n const { board, draft, format = 'A4', landscape, preferCSSPageSize } = step.params\n\n if (!board || !board.id) {\n throw new Error('The board property must be set')\n }\n\n const { model, base } = await BoardFunc.headlessModel({ domain: context.domain, id: board.id }, draft)\n const [fontsToUse, fontStyles] = await BoardFunc.fonts(context.domain)\n\n model.fonts = fontsToUse\n model.fontStyles = fontStyles\n\n let width: number | undefined = PAGE_FORMATS[format as PageFormat]?.width\n let height: number | undefined = PAGE_FORMATS[format as PageFormat]?.height\n\n if (preferCSSPageSize) {\n width = undefined\n height = undefined\n }\n\n if (landscape && width && height) {\n ;[width, height] = [height, width]\n }\n\n const protocol = 'http'\n const host = 'localhost'\n const port = process.env.PORT ? `:${process.env.PORT}` : ''\n const path = '/internal-board-service-view'\n const url = `${protocol}://${host}${port}${path}`\n\n const page = await pdfUtil.browser!.newPage()\n\n await page.setViewport({\n width: Math.round(width || 800), // Fallback for width if not defined\n height: Math.round(height || 600) // Fallback for height if not defined\n })\n\n await page.goto(url)\n\n await page.evaluate(\n data => {\n //@ts-ignore\n s.data = data\n return new Promise(resolve => {\n requestAnimationFrame(() => resolve(0))\n })\n },\n { model, base }\n )\n\n // 페이지 옵션 설정\n const pageOptions = pdfUtil.buildPageOptions({\n ...step.params,\n width: width ? `${width}px` : undefined,\n height: height ? `${height}px` : undefined\n })\n\n // PDF 생성 및 추가\n const htmlContent = '' // 보드에서 직접 렌더링되므로 HTML 컨텐츠가 비어있음\n await pdfUtil.processPageAndGeneratePDF({ ...step.params, width, height }, htmlContent)\n\n return {\n data: context.__headless_pdf\n }\n } catch (error) {\n throw error\n } finally {\n await pdfUtil.closeBrowser()\n }\n}\n\nHeadlessPDFCaptureBoard.parameterSpec = [\n ...getCommonParameterSpec(),\n {\n type: 'resource-object',\n name: 'board',\n label: 'board',\n property: {\n queryName: 'boards'\n }\n },\n {\n type: 'boolean',\n name: 'draft',\n label: 'board-draft',\n defaultValue: false,\n description: 'Set whether to get the current working version or the last released version'\n }\n]\n\nHeadlessPDFCaptureBoard.help = 'integration/task/headless-pdf-capture-board'\n\nTaskRegistry.registerTaskHandler('headless-pdf-capture-board', HeadlessPDFCaptureBoard)\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export declare function HeadlessPDFCaptureMarkdown(step: any, context: any): Promise<{
|
|
2
|
+
data: any;
|
|
3
|
+
}>;
|
|
4
|
+
export declare namespace HeadlessPDFCaptureMarkdown {
|
|
5
|
+
var parameterSpec: ({
|
|
6
|
+
type: string;
|
|
7
|
+
name: string;
|
|
8
|
+
label: string;
|
|
9
|
+
property?: undefined;
|
|
10
|
+
description?: undefined;
|
|
11
|
+
placeholder?: undefined;
|
|
12
|
+
defaultValue?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
type: string;
|
|
15
|
+
name: string;
|
|
16
|
+
label: string;
|
|
17
|
+
property: {
|
|
18
|
+
options: {
|
|
19
|
+
display: string;
|
|
20
|
+
value: string;
|
|
21
|
+
}[];
|
|
22
|
+
};
|
|
23
|
+
description: string;
|
|
24
|
+
placeholder?: undefined;
|
|
25
|
+
defaultValue?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
type: string;
|
|
28
|
+
name: string;
|
|
29
|
+
label: string;
|
|
30
|
+
placeholder: string;
|
|
31
|
+
description: string;
|
|
32
|
+
property?: undefined;
|
|
33
|
+
defaultValue?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
type: string;
|
|
36
|
+
name: string;
|
|
37
|
+
label: string;
|
|
38
|
+
defaultValue: number;
|
|
39
|
+
description: string;
|
|
40
|
+
property?: undefined;
|
|
41
|
+
placeholder?: undefined;
|
|
42
|
+
} | {
|
|
43
|
+
type: string;
|
|
44
|
+
name: string;
|
|
45
|
+
label: string;
|
|
46
|
+
defaultValue: boolean;
|
|
47
|
+
description: string;
|
|
48
|
+
property?: undefined;
|
|
49
|
+
placeholder?: undefined;
|
|
50
|
+
})[];
|
|
51
|
+
var help: string;
|
|
52
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HeadlessPDFCaptureMarkdown = HeadlessPDFCaptureMarkdown;
|
|
4
|
+
const integration_base_1 = require("@things-factory/integration-base");
|
|
5
|
+
const utils_1 = require("@things-factory/utils");
|
|
6
|
+
const marked_1 = require("marked");
|
|
7
|
+
const pdf_capture_util_1 = require("./pdf-capture-util");
|
|
8
|
+
async function HeadlessPDFCaptureMarkdown(step, context) {
|
|
9
|
+
const pdfUtil = new pdf_capture_util_1.PDFCaptureUtil(context);
|
|
10
|
+
await pdfUtil.initBrowser(step.connection);
|
|
11
|
+
try {
|
|
12
|
+
const { accessor, markdownContent } = step.params;
|
|
13
|
+
const templateInput = (0, utils_1.access)(accessor, context.data);
|
|
14
|
+
const renderedMarkdown = pdfUtil.renderTemplate(markdownContent, templateInput);
|
|
15
|
+
const htmlContent = (0, marked_1.marked)(renderedMarkdown);
|
|
16
|
+
await pdfUtil.processPageAndGeneratePDF(step.params, htmlContent);
|
|
17
|
+
return {
|
|
18
|
+
data: context.__headless_pdf
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
await pdfUtil.closeBrowser();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
HeadlessPDFCaptureMarkdown.parameterSpec = [
|
|
29
|
+
...(0, pdf_capture_util_1.getCommonParameterSpec)(),
|
|
30
|
+
{
|
|
31
|
+
type: 'textarea',
|
|
32
|
+
name: 'markdownContent',
|
|
33
|
+
label: 'markdown-content'
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
HeadlessPDFCaptureMarkdown.help = 'integration/task/headless-pdf-capture-markdown';
|
|
37
|
+
integration_base_1.TaskRegistry.registerTaskHandler('headless-pdf-capture-markdown', HeadlessPDFCaptureMarkdown);
|
|
38
|
+
//# sourceMappingURL=headless-pdf-capture-markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headless-pdf-capture-markdown.js","sourceRoot":"","sources":["../../../server/engine/task/headless-pdf-capture-markdown.ts"],"names":[],"mappings":";;AAMA,gEAqBC;AA3BD,uEAA+D;AAC/D,iDAA8C;AAC9C,mCAA+B;AAE/B,yDAA2E;AAEpE,KAAK,UAAU,0BAA0B,CAAC,IAAI,EAAE,OAAO;IAC5D,MAAM,OAAO,GAAG,IAAI,iCAAc,CAAC,OAAO,CAAC,CAAA;IAC3C,MAAM,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAE1C,IAAI,CAAC;QACH,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;QACjD,MAAM,aAAa,GAAG,IAAA,cAAM,EAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;QAEpD,MAAM,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC,eAAe,EAAE,aAAa,CAAC,CAAA;QAC/E,MAAM,WAAW,GAAG,IAAA,eAAM,EAAC,gBAAgB,CAAC,CAAA;QAE5C,MAAM,OAAO,CAAC,yBAAyB,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;QAEjE,OAAO;YACL,IAAI,EAAE,OAAO,CAAC,cAAc;SAC7B,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,KAAK,CAAA;IACb,CAAC;YAAS,CAAC;QACT,MAAM,OAAO,CAAC,YAAY,EAAE,CAAA;IAC9B,CAAC;AACH,CAAC;AAED,0BAA0B,CAAC,aAAa,GAAG;IACzC,GAAG,IAAA,yCAAsB,GAAE;IAC3B;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,iBAAiB;QACvB,KAAK,EAAE,kBAAkB;KAC1B;CACF,CAAA;AAED,0BAA0B,CAAC,IAAI,GAAG,gDAAgD,CAAA;AAElF,+BAAY,CAAC,mBAAmB,CAAC,+BAA+B,EAAE,0BAA0B,CAAC,CAAA","sourcesContent":["import { TaskRegistry } from '@things-factory/integration-base'\nimport { access } from '@things-factory/utils'\nimport { marked } from 'marked'\n\nimport { PDFCaptureUtil, getCommonParameterSpec } from './pdf-capture-util'\n\nexport async function HeadlessPDFCaptureMarkdown(step, context) {\n const pdfUtil = new PDFCaptureUtil(context)\n await pdfUtil.initBrowser(step.connection)\n\n try {\n const { accessor, markdownContent } = step.params\n const templateInput = access(accessor, context.data)\n\n const renderedMarkdown = pdfUtil.renderTemplate(markdownContent, templateInput)\n const htmlContent = marked(renderedMarkdown)\n\n await pdfUtil.processPageAndGeneratePDF(step.params, htmlContent)\n\n return {\n data: context.__headless_pdf\n }\n } catch (error) {\n throw error\n } finally {\n await pdfUtil.closeBrowser()\n }\n}\n\nHeadlessPDFCaptureMarkdown.parameterSpec = [\n ...getCommonParameterSpec(),\n {\n type: 'textarea',\n name: 'markdownContent',\n label: 'markdown-content'\n }\n]\n\nHeadlessPDFCaptureMarkdown.help = 'integration/task/headless-pdf-capture-markdown'\n\nTaskRegistry.registerTaskHandler('headless-pdf-capture-markdown', HeadlessPDFCaptureMarkdown)\n"]}
|
|
@@ -1 +1,52 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export declare function HeadlessPDFCapture(step: any, context: any): Promise<{
|
|
2
|
+
data: any;
|
|
3
|
+
}>;
|
|
4
|
+
export declare namespace HeadlessPDFCapture {
|
|
5
|
+
var parameterSpec: ({
|
|
6
|
+
type: string;
|
|
7
|
+
name: string;
|
|
8
|
+
label: string;
|
|
9
|
+
property?: undefined;
|
|
10
|
+
description?: undefined;
|
|
11
|
+
placeholder?: undefined;
|
|
12
|
+
defaultValue?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
type: string;
|
|
15
|
+
name: string;
|
|
16
|
+
label: string;
|
|
17
|
+
property: {
|
|
18
|
+
options: {
|
|
19
|
+
display: string;
|
|
20
|
+
value: string;
|
|
21
|
+
}[];
|
|
22
|
+
};
|
|
23
|
+
description: string;
|
|
24
|
+
placeholder?: undefined;
|
|
25
|
+
defaultValue?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
type: string;
|
|
28
|
+
name: string;
|
|
29
|
+
label: string;
|
|
30
|
+
placeholder: string;
|
|
31
|
+
description: string;
|
|
32
|
+
property?: undefined;
|
|
33
|
+
defaultValue?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
type: string;
|
|
36
|
+
name: string;
|
|
37
|
+
label: string;
|
|
38
|
+
defaultValue: number;
|
|
39
|
+
description: string;
|
|
40
|
+
property?: undefined;
|
|
41
|
+
placeholder?: undefined;
|
|
42
|
+
} | {
|
|
43
|
+
type: string;
|
|
44
|
+
name: string;
|
|
45
|
+
label: string;
|
|
46
|
+
defaultValue: boolean;
|
|
47
|
+
description: string;
|
|
48
|
+
property?: undefined;
|
|
49
|
+
placeholder?: undefined;
|
|
50
|
+
})[];
|
|
51
|
+
var help: string;
|
|
52
|
+
}
|