@luxurylabs/pretdf-render-chromium 0.0.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/dist/chunk-DGLH4GAC.js +60 -0
- package/dist/chunk-DGLH4GAC.js.map +1 -0
- package/dist/chunk-F55DUO5E.js +60 -0
- package/dist/chunk-F55DUO5E.js.map +1 -0
- package/dist/chunk-SNMJDRSH.js +176 -0
- package/dist/chunk-SNMJDRSH.js.map +1 -0
- package/dist/html.d.ts +14 -0
- package/dist/html.js +7 -0
- package/dist/html.js.map +1 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.d.ts +14 -0
- package/dist/styles.js +7 -0
- package/dist/styles.js.map +1 -0
- package/dist/template.d.ts +9 -0
- package/dist/template.js +8 -0
- package/dist/template.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildStylesheet
|
|
3
|
+
} from "./chunk-SNMJDRSH.js";
|
|
4
|
+
|
|
5
|
+
// src/template.ts
|
|
6
|
+
function wrapDocument(bodyHtml, config, extraCss) {
|
|
7
|
+
const baseCss = buildStylesheet(config);
|
|
8
|
+
const css = extraCss ? `${baseCss}
|
|
9
|
+
${extraCss}` : baseCss;
|
|
10
|
+
const lang = config.locale.split("-")[0] ?? "en";
|
|
11
|
+
const title = config.title ?? "pretdf document";
|
|
12
|
+
return `<!DOCTYPE html>
|
|
13
|
+
<html lang="${escapeAttr(lang)}">
|
|
14
|
+
<head>
|
|
15
|
+
<meta charset="UTF-8">
|
|
16
|
+
<title>${escapeText(title)}</title>
|
|
17
|
+
<style>${css}</style>
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
${bodyHtml}
|
|
21
|
+
</body>
|
|
22
|
+
</html>`;
|
|
23
|
+
}
|
|
24
|
+
function escapeAttr(value) {
|
|
25
|
+
return value.replace(/[&<>"']/g, (ch) => {
|
|
26
|
+
switch (ch) {
|
|
27
|
+
case "&":
|
|
28
|
+
return "&";
|
|
29
|
+
case "<":
|
|
30
|
+
return "<";
|
|
31
|
+
case ">":
|
|
32
|
+
return ">";
|
|
33
|
+
case '"':
|
|
34
|
+
return """;
|
|
35
|
+
case "'":
|
|
36
|
+
return "'";
|
|
37
|
+
default:
|
|
38
|
+
return ch;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function escapeText(value) {
|
|
43
|
+
return value.replace(/[&<>]/g, (ch) => {
|
|
44
|
+
switch (ch) {
|
|
45
|
+
case "&":
|
|
46
|
+
return "&";
|
|
47
|
+
case "<":
|
|
48
|
+
return "<";
|
|
49
|
+
case ">":
|
|
50
|
+
return ">";
|
|
51
|
+
default:
|
|
52
|
+
return ch;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
wrapDocument
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=chunk-DGLH4GAC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/template.ts"],"sourcesContent":["import type { DocumentConfig } from '@luxurylabs/pretdf-core';\nimport { buildStylesheet } from './styles.js';\n\n/**\n * Wrap a body HTML fragment in a complete HTML document ready to be loaded\n * into Playwright's `page.setContent()`.\n */\nexport function wrapDocument(bodyHtml: string, config: DocumentConfig, extraCss?: string): string {\n const baseCss = buildStylesheet(config);\n const css = extraCss ? `${baseCss}\\n${extraCss}` : baseCss;\n const lang = config.locale.split('-')[0] ?? 'en';\n const title = config.title ?? 'pretdf document';\n\n return `<!DOCTYPE html>\n<html lang=\"${escapeAttr(lang)}\">\n<head>\n<meta charset=\"UTF-8\">\n<title>${escapeText(title)}</title>\n<style>${css}</style>\n</head>\n<body>\n${bodyHtml}\n</body>\n</html>`;\n}\n\nfunction escapeAttr(value: string): string {\n return value.replace(/[&<>\"']/g, (ch) => {\n switch (ch) {\n case '&':\n return '&';\n case '<':\n return '<';\n case '>':\n return '>';\n case '\"':\n return '"';\n case \"'\":\n return ''';\n default:\n return ch;\n }\n });\n}\n\nfunction escapeText(value: string): string {\n return value.replace(/[&<>]/g, (ch) => {\n switch (ch) {\n case '&':\n return '&';\n case '<':\n return '<';\n case '>':\n return '>';\n default:\n return ch;\n }\n });\n}\n"],"mappings":";;;;;AAOO,SAAS,aAAa,UAAkB,QAAwB,UAA2B;AAChG,QAAM,UAAU,gBAAgB,MAAM;AACtC,QAAM,MAAM,WAAW,GAAG,OAAO;AAAA,EAAK,QAAQ,KAAK;AACnD,QAAM,OAAO,OAAO,OAAO,MAAM,GAAG,EAAE,CAAC,KAAK;AAC5C,QAAM,QAAQ,OAAO,SAAS;AAE9B,SAAO;AAAA,cACK,WAAW,IAAI,CAAC;AAAA;AAAA;AAAA,SAGrB,WAAW,KAAK,CAAC;AAAA,SACjB,GAAG;AAAA;AAAA;AAAA,EAGV,QAAQ;AAAA;AAAA;AAGV;AAEA,SAAS,WAAW,OAAuB;AACzC,SAAO,MAAM,QAAQ,YAAY,CAAC,OAAO;AACvC,YAAQ,IAAI;AAAA,MACV,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF,CAAC;AACH;AAEA,SAAS,WAAW,OAAuB;AACzC,SAAO,MAAM,QAAQ,UAAU,CAAC,OAAO;AACrC,YAAQ,IAAI;AAAA,MACV,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// src/html.ts
|
|
2
|
+
import { toHtml } from "hast-util-to-html";
|
|
3
|
+
import { toHast } from "mdast-util-to-hast";
|
|
4
|
+
|
|
5
|
+
// src/directives.ts
|
|
6
|
+
import { h } from "hastscript";
|
|
7
|
+
import { visit } from "unist-util-visit";
|
|
8
|
+
function isDirective(node) {
|
|
9
|
+
return node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective";
|
|
10
|
+
}
|
|
11
|
+
var DIRECTIVE_MAP = {
|
|
12
|
+
section: { tag: "section", baseClass: "pretdf-section" },
|
|
13
|
+
callout: { tag: "aside", baseClass: "pretdf-callout" },
|
|
14
|
+
source: { tag: "footer", baseClass: "pretdf-source" },
|
|
15
|
+
columns: { tag: "div", baseClass: "pretdf-columns" },
|
|
16
|
+
column: { tag: "div", baseClass: "pretdf-column" },
|
|
17
|
+
table: { tag: "div", baseClass: "pretdf-table" },
|
|
18
|
+
card: { tag: "div", baseClass: "pretdf-card" },
|
|
19
|
+
banner: { tag: "div", baseClass: "pretdf-banner" },
|
|
20
|
+
"page-break": { tag: "div", baseClass: "pretdf-page-break" }
|
|
21
|
+
};
|
|
22
|
+
function pretdfDirectives() {
|
|
23
|
+
return (tree) => {
|
|
24
|
+
visit(tree, (node) => {
|
|
25
|
+
if (!isDirective(node)) return;
|
|
26
|
+
const mapping = DIRECTIVE_MAP[node.name];
|
|
27
|
+
const tag = mapping?.tag ?? (node.type === "textDirective" ? "span" : "div");
|
|
28
|
+
const baseClass = mapping?.baseClass ?? `pretdf-${node.name}`;
|
|
29
|
+
const { class: extraClass, ...attrs } = { ...node.attributes ?? {} };
|
|
30
|
+
const classes = [baseClass];
|
|
31
|
+
if (extraClass) {
|
|
32
|
+
classes.push(extraClass);
|
|
33
|
+
}
|
|
34
|
+
if (attrs.type) {
|
|
35
|
+
classes.push(`${baseClass}--${attrs.type}`);
|
|
36
|
+
}
|
|
37
|
+
if (attrs.status) {
|
|
38
|
+
classes.push(`${baseClass}--status-${attrs.status}`);
|
|
39
|
+
}
|
|
40
|
+
const hast = h(tag, { ...attrs, class: classes.join(" ") });
|
|
41
|
+
node.data = node.data ?? {};
|
|
42
|
+
node.data.hName = hast.tagName;
|
|
43
|
+
node.data.hProperties = hast.properties;
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/html.ts
|
|
49
|
+
function astToHtml(ast) {
|
|
50
|
+
const transform = pretdfDirectives();
|
|
51
|
+
transform(ast);
|
|
52
|
+
const hast = toHast(ast, { allowDangerousHtml: true });
|
|
53
|
+
if (!hast) return "";
|
|
54
|
+
return toHtml(hast, { allowDangerousHtml: true });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
astToHtml
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=chunk-F55DUO5E.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/html.ts","../src/directives.ts"],"sourcesContent":["import { toHtml } from 'hast-util-to-html';\nimport type { Root } from 'mdast';\nimport { toHast } from 'mdast-util-to-hast';\nimport { pretdfDirectives } from './directives.js';\n\n/**\n * Convert an mdast tree (already produced by @luxurylabs/pretdf-core) into\n * an HTML body string ready to be wrapped in the page template.\n *\n * The pipeline is:\n * 1. pretdfDirectives — translate pretdf directives into hast-friendly metadata.\n * 2. mdast-util-to-hast — convert mdast → hast.\n * 3. hast-util-to-html — serialize hast → HTML string.\n */\nexport function astToHtml(ast: Root): string {\n const transform = pretdfDirectives();\n transform(ast);\n\n const hast = toHast(ast, { allowDangerousHtml: true });\n if (!hast) return '';\n return toHtml(hast, { allowDangerousHtml: true });\n}\n","import { h } from 'hastscript';\nimport type { Root } from 'mdast';\nimport type { Node } from 'unist';\nimport { visit } from 'unist-util-visit';\n\n/**\n * Minimal type for mdast directive nodes added by remark-directive.\n * These types are not in @types/mdast, so we declare the shape ourselves\n * to avoid `any` casts while keeping type-safety for the rest of the code.\n */\ninterface DirectiveNode extends Node {\n type: 'containerDirective' | 'leafDirective' | 'textDirective';\n name: string;\n attributes?: Record<string, string>;\n data?: Record<string, unknown>;\n}\n\nfunction isDirective(node: Node): node is DirectiveNode {\n return (\n node.type === 'containerDirective' ||\n node.type === 'leafDirective' ||\n node.type === 'textDirective'\n );\n}\n\n/**\n * Map of pretdf directive names to the HTML element + base CSS class they\n * should produce. Unknown directives fall back to a generic <div> with the\n * directive name as a class so users can style ad-hoc directives in their\n * own CSS.\n */\nconst DIRECTIVE_MAP: Record<string, { tag: string; baseClass: string }> = {\n section: { tag: 'section', baseClass: 'pretdf-section' },\n callout: { tag: 'aside', baseClass: 'pretdf-callout' },\n source: { tag: 'footer', baseClass: 'pretdf-source' },\n columns: { tag: 'div', baseClass: 'pretdf-columns' },\n column: { tag: 'div', baseClass: 'pretdf-column' },\n table: { tag: 'div', baseClass: 'pretdf-table' },\n card: { tag: 'div', baseClass: 'pretdf-card' },\n banner: { tag: 'div', baseClass: 'pretdf-banner' },\n 'page-break': { tag: 'div', baseClass: 'pretdf-page-break' },\n};\n\n/**\n * Transform pretdf directives into hast-friendly nodes by setting `data.hName`\n * and `data.hProperties`. These are consumed by mdast-util-to-hast during the\n * mdast → hast conversion.\n *\n * Attributes on a directive become HTML attributes; a `type` attribute (common\n * in callouts and banners) is also reflected as a `--{value}` modifier class.\n */\nexport function pretdfDirectives(): (tree: Root) => void {\n return (tree: Root) => {\n visit(tree, (node: Node) => {\n if (!isDirective(node)) return;\n\n const mapping = DIRECTIVE_MAP[node.name];\n const tag = mapping?.tag ?? (node.type === 'textDirective' ? 'span' : 'div');\n const baseClass = mapping?.baseClass ?? `pretdf-${node.name}`;\n\n const { class: extraClass, ...attrs } = { ...(node.attributes ?? {}) };\n const classes: string[] = [baseClass];\n\n if (extraClass) {\n classes.push(extraClass);\n }\n if (attrs.type) {\n classes.push(`${baseClass}--${attrs.type}`);\n }\n if (attrs.status) {\n classes.push(`${baseClass}--status-${attrs.status}`);\n }\n\n const hast = h(tag, { ...attrs, class: classes.join(' ') });\n node.data = node.data ?? {};\n node.data.hName = hast.tagName;\n node.data.hProperties = hast.properties;\n });\n };\n}\n"],"mappings":";AAAA,SAAS,cAAc;AAEvB,SAAS,cAAc;;;ACFvB,SAAS,SAAS;AAGlB,SAAS,aAAa;AActB,SAAS,YAAY,MAAmC;AACtD,SACE,KAAK,SAAS,wBACd,KAAK,SAAS,mBACd,KAAK,SAAS;AAElB;AAQA,IAAM,gBAAoE;AAAA,EACxE,SAAS,EAAE,KAAK,WAAW,WAAW,iBAAiB;AAAA,EACvD,SAAS,EAAE,KAAK,SAAS,WAAW,iBAAiB;AAAA,EACrD,QAAQ,EAAE,KAAK,UAAU,WAAW,gBAAgB;AAAA,EACpD,SAAS,EAAE,KAAK,OAAO,WAAW,iBAAiB;AAAA,EACnD,QAAQ,EAAE,KAAK,OAAO,WAAW,gBAAgB;AAAA,EACjD,OAAO,EAAE,KAAK,OAAO,WAAW,eAAe;AAAA,EAC/C,MAAM,EAAE,KAAK,OAAO,WAAW,cAAc;AAAA,EAC7C,QAAQ,EAAE,KAAK,OAAO,WAAW,gBAAgB;AAAA,EACjD,cAAc,EAAE,KAAK,OAAO,WAAW,oBAAoB;AAC7D;AAUO,SAAS,mBAAyC;AACvD,SAAO,CAAC,SAAe;AACrB,UAAM,MAAM,CAAC,SAAe;AAC1B,UAAI,CAAC,YAAY,IAAI,EAAG;AAExB,YAAM,UAAU,cAAc,KAAK,IAAI;AACvC,YAAM,MAAM,SAAS,QAAQ,KAAK,SAAS,kBAAkB,SAAS;AACtE,YAAM,YAAY,SAAS,aAAa,UAAU,KAAK,IAAI;AAE3D,YAAM,EAAE,OAAO,YAAY,GAAG,MAAM,IAAI,EAAE,GAAI,KAAK,cAAc,CAAC,EAAG;AACrE,YAAM,UAAoB,CAAC,SAAS;AAEpC,UAAI,YAAY;AACd,gBAAQ,KAAK,UAAU;AAAA,MACzB;AACA,UAAI,MAAM,MAAM;AACd,gBAAQ,KAAK,GAAG,SAAS,KAAK,MAAM,IAAI,EAAE;AAAA,MAC5C;AACA,UAAI,MAAM,QAAQ;AAChB,gBAAQ,KAAK,GAAG,SAAS,YAAY,MAAM,MAAM,EAAE;AAAA,MACrD;AAEA,YAAM,OAAO,EAAE,KAAK,EAAE,GAAG,OAAO,OAAO,QAAQ,KAAK,GAAG,EAAE,CAAC;AAC1D,WAAK,OAAO,KAAK,QAAQ,CAAC;AAC1B,WAAK,KAAK,QAAQ,KAAK;AACvB,WAAK,KAAK,cAAc,KAAK;AAAA,IAC/B,CAAC;AAAA,EACH;AACF;;;ADjEO,SAAS,UAAU,KAAmB;AAC3C,QAAM,YAAY,iBAAiB;AACnC,YAAU,GAAG;AAEb,QAAM,OAAO,OAAO,KAAK,EAAE,oBAAoB,KAAK,CAAC;AACrD,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,OAAO,MAAM,EAAE,oBAAoB,KAAK,CAAC;AAClD;","names":[]}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
// src/styles.ts
|
|
2
|
+
function buildStylesheet(config) {
|
|
3
|
+
const { page } = config;
|
|
4
|
+
return [pageRules(page.size, page.margin, page.orientation), BASE_STYLES].join("\n");
|
|
5
|
+
}
|
|
6
|
+
function pageRules(size, margin, orientation) {
|
|
7
|
+
const sizeDecl = typeof size === "string" ? `${size} ${orientation}` : `${size.width} ${size.height}`;
|
|
8
|
+
return `@page {
|
|
9
|
+
size: ${sizeDecl};
|
|
10
|
+
margin: ${margin.top} ${margin.right} ${margin.bottom} ${margin.left};
|
|
11
|
+
}`;
|
|
12
|
+
}
|
|
13
|
+
var BASE_STYLES = `
|
|
14
|
+
:root {
|
|
15
|
+
--pretdf-text: #1a1a1a;
|
|
16
|
+
--pretdf-muted: #6b7280;
|
|
17
|
+
--pretdf-border: #e5e7eb;
|
|
18
|
+
--pretdf-accent: #2563eb;
|
|
19
|
+
--pretdf-callout-info: #eff6ff;
|
|
20
|
+
--pretdf-callout-warning: #fffbeb;
|
|
21
|
+
--pretdf-callout-danger: #fef2f2;
|
|
22
|
+
--pretdf-callout-success: #ecfdf5;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
* {
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
html, body {
|
|
30
|
+
margin: 0;
|
|
31
|
+
padding: 0;
|
|
32
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
|
|
33
|
+
Arial, 'Noto Sans', sans-serif;
|
|
34
|
+
font-size: 11pt;
|
|
35
|
+
line-height: 1.5;
|
|
36
|
+
color: var(--pretdf-text);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
h1, h2, h3, h4, h5, h6 {
|
|
40
|
+
margin: 1.2em 0 0.5em;
|
|
41
|
+
line-height: 1.25;
|
|
42
|
+
page-break-after: avoid;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
h1 { font-size: 1.8em; }
|
|
46
|
+
h2 { font-size: 1.4em; }
|
|
47
|
+
h3 { font-size: 1.2em; }
|
|
48
|
+
h4 { font-size: 1.05em; }
|
|
49
|
+
|
|
50
|
+
p {
|
|
51
|
+
margin: 0.5em 0;
|
|
52
|
+
orphans: 3;
|
|
53
|
+
widows: 3;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
a {
|
|
57
|
+
color: var(--pretdf-accent);
|
|
58
|
+
text-decoration: underline;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
table {
|
|
62
|
+
width: 100%;
|
|
63
|
+
border-collapse: collapse;
|
|
64
|
+
margin: 0.75em 0;
|
|
65
|
+
font-size: 0.95em;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
th, td {
|
|
69
|
+
padding: 6px 10px;
|
|
70
|
+
border-bottom: 1px solid var(--pretdf-border);
|
|
71
|
+
text-align: left;
|
|
72
|
+
vertical-align: top;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
th {
|
|
76
|
+
background: #f9fafb;
|
|
77
|
+
font-weight: 600;
|
|
78
|
+
border-bottom: 2px solid var(--pretdf-border);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
thead {
|
|
82
|
+
display: table-header-group;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
tr {
|
|
86
|
+
page-break-inside: avoid;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
ul, ol {
|
|
90
|
+
margin: 0.5em 0;
|
|
91
|
+
padding-left: 1.4em;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
code {
|
|
95
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
96
|
+
font-size: 0.9em;
|
|
97
|
+
background: #f3f4f6;
|
|
98
|
+
padding: 0 0.25em;
|
|
99
|
+
border-radius: 3px;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
pre {
|
|
103
|
+
background: #f3f4f6;
|
|
104
|
+
padding: 0.75em;
|
|
105
|
+
border-radius: 4px;
|
|
106
|
+
overflow-x: auto;
|
|
107
|
+
page-break-inside: avoid;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.pretdf-section {
|
|
111
|
+
margin: 1em 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.pretdf-callout {
|
|
115
|
+
margin: 0.75em 0;
|
|
116
|
+
padding: 0.75em 1em;
|
|
117
|
+
border-left: 4px solid var(--pretdf-accent);
|
|
118
|
+
background: var(--pretdf-callout-info);
|
|
119
|
+
border-radius: 4px;
|
|
120
|
+
page-break-inside: avoid;
|
|
121
|
+
}
|
|
122
|
+
.pretdf-callout--warning {
|
|
123
|
+
border-left-color: #d97706;
|
|
124
|
+
background: var(--pretdf-callout-warning);
|
|
125
|
+
}
|
|
126
|
+
.pretdf-callout--danger {
|
|
127
|
+
border-left-color: #dc2626;
|
|
128
|
+
background: var(--pretdf-callout-danger);
|
|
129
|
+
}
|
|
130
|
+
.pretdf-callout--success {
|
|
131
|
+
border-left-color: #059669;
|
|
132
|
+
background: var(--pretdf-callout-success);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.pretdf-source {
|
|
136
|
+
margin-top: 0.5em;
|
|
137
|
+
padding: 0.4em 0.8em;
|
|
138
|
+
font-size: 0.85em;
|
|
139
|
+
color: var(--pretdf-muted);
|
|
140
|
+
background: #f9fafb;
|
|
141
|
+
border-top: 1px solid var(--pretdf-border);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.pretdf-columns {
|
|
145
|
+
display: grid;
|
|
146
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
147
|
+
gap: 1em;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.pretdf-page-break {
|
|
151
|
+
page-break-after: always;
|
|
152
|
+
break-after: page;
|
|
153
|
+
height: 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.pretdf-card {
|
|
157
|
+
border: 1px solid var(--pretdf-border);
|
|
158
|
+
border-radius: 6px;
|
|
159
|
+
padding: 0.75em 1em;
|
|
160
|
+
margin: 0.75em 0;
|
|
161
|
+
page-break-inside: avoid;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.pretdf-banner {
|
|
165
|
+
padding: 0.6em 1em;
|
|
166
|
+
background: #eff6ff;
|
|
167
|
+
border-left: 4px solid var(--pretdf-accent);
|
|
168
|
+
margin: 0.75em 0;
|
|
169
|
+
border-radius: 4px;
|
|
170
|
+
}
|
|
171
|
+
`;
|
|
172
|
+
|
|
173
|
+
export {
|
|
174
|
+
buildStylesheet
|
|
175
|
+
};
|
|
176
|
+
//# sourceMappingURL=chunk-SNMJDRSH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/styles.ts"],"sourcesContent":["import type { DocumentConfig, PageMargin, PageSize } from '@luxurylabs/pretdf-core';\n\n/**\n * Generate the base stylesheet for a pretdf document.\n *\n * The CSS is intentionally small and unopinionated: it sets up the @page\n * rules for size/margin/orientation and provides minimum styling for the\n * built-in directive classes (section, callout, source, columns, etc.).\n *\n * Project-specific theming should be layered on top via `extraCss`.\n */\nexport function buildStylesheet(config: DocumentConfig): string {\n const { page } = config;\n return [pageRules(page.size, page.margin, page.orientation), BASE_STYLES].join('\\n');\n}\n\nfunction pageRules(\n size: PageSize,\n margin: PageMargin,\n orientation: 'portrait' | 'landscape',\n): string {\n const sizeDecl =\n typeof size === 'string' ? `${size} ${orientation}` : `${size.width} ${size.height}`;\n return `@page {\n size: ${sizeDecl};\n margin: ${margin.top} ${margin.right} ${margin.bottom} ${margin.left};\n}`;\n}\n\nconst BASE_STYLES = `\n:root {\n --pretdf-text: #1a1a1a;\n --pretdf-muted: #6b7280;\n --pretdf-border: #e5e7eb;\n --pretdf-accent: #2563eb;\n --pretdf-callout-info: #eff6ff;\n --pretdf-callout-warning: #fffbeb;\n --pretdf-callout-danger: #fef2f2;\n --pretdf-callout-success: #ecfdf5;\n}\n\n* {\n box-sizing: border-box;\n}\n\nhtml, body {\n margin: 0;\n padding: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',\n Arial, 'Noto Sans', sans-serif;\n font-size: 11pt;\n line-height: 1.5;\n color: var(--pretdf-text);\n}\n\nh1, h2, h3, h4, h5, h6 {\n margin: 1.2em 0 0.5em;\n line-height: 1.25;\n page-break-after: avoid;\n}\n\nh1 { font-size: 1.8em; }\nh2 { font-size: 1.4em; }\nh3 { font-size: 1.2em; }\nh4 { font-size: 1.05em; }\n\np {\n margin: 0.5em 0;\n orphans: 3;\n widows: 3;\n}\n\na {\n color: var(--pretdf-accent);\n text-decoration: underline;\n}\n\ntable {\n width: 100%;\n border-collapse: collapse;\n margin: 0.75em 0;\n font-size: 0.95em;\n}\n\nth, td {\n padding: 6px 10px;\n border-bottom: 1px solid var(--pretdf-border);\n text-align: left;\n vertical-align: top;\n}\n\nth {\n background: #f9fafb;\n font-weight: 600;\n border-bottom: 2px solid var(--pretdf-border);\n}\n\nthead {\n display: table-header-group;\n}\n\ntr {\n page-break-inside: avoid;\n}\n\nul, ol {\n margin: 0.5em 0;\n padding-left: 1.4em;\n}\n\ncode {\n font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font-size: 0.9em;\n background: #f3f4f6;\n padding: 0 0.25em;\n border-radius: 3px;\n}\n\npre {\n background: #f3f4f6;\n padding: 0.75em;\n border-radius: 4px;\n overflow-x: auto;\n page-break-inside: avoid;\n}\n\n.pretdf-section {\n margin: 1em 0;\n}\n\n.pretdf-callout {\n margin: 0.75em 0;\n padding: 0.75em 1em;\n border-left: 4px solid var(--pretdf-accent);\n background: var(--pretdf-callout-info);\n border-radius: 4px;\n page-break-inside: avoid;\n}\n.pretdf-callout--warning {\n border-left-color: #d97706;\n background: var(--pretdf-callout-warning);\n}\n.pretdf-callout--danger {\n border-left-color: #dc2626;\n background: var(--pretdf-callout-danger);\n}\n.pretdf-callout--success {\n border-left-color: #059669;\n background: var(--pretdf-callout-success);\n}\n\n.pretdf-source {\n margin-top: 0.5em;\n padding: 0.4em 0.8em;\n font-size: 0.85em;\n color: var(--pretdf-muted);\n background: #f9fafb;\n border-top: 1px solid var(--pretdf-border);\n}\n\n.pretdf-columns {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 1em;\n}\n\n.pretdf-page-break {\n page-break-after: always;\n break-after: page;\n height: 0;\n}\n\n.pretdf-card {\n border: 1px solid var(--pretdf-border);\n border-radius: 6px;\n padding: 0.75em 1em;\n margin: 0.75em 0;\n page-break-inside: avoid;\n}\n\n.pretdf-banner {\n padding: 0.6em 1em;\n background: #eff6ff;\n border-left: 4px solid var(--pretdf-accent);\n margin: 0.75em 0;\n border-radius: 4px;\n}\n`;\n"],"mappings":";AAWO,SAAS,gBAAgB,QAAgC;AAC9D,QAAM,EAAE,KAAK,IAAI;AACjB,SAAO,CAAC,UAAU,KAAK,MAAM,KAAK,QAAQ,KAAK,WAAW,GAAG,WAAW,EAAE,KAAK,IAAI;AACrF;AAEA,SAAS,UACP,MACA,QACA,aACQ;AACR,QAAM,WACJ,OAAO,SAAS,WAAW,GAAG,IAAI,IAAI,WAAW,KAAK,GAAG,KAAK,KAAK,IAAI,KAAK,MAAM;AACpF,SAAO;AAAA,UACC,QAAQ;AAAA,YACN,OAAO,GAAG,IAAI,OAAO,KAAK,IAAI,OAAO,MAAM,IAAI,OAAO,IAAI;AAAA;AAEtE;AAEA,IAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
|
package/dist/html.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Root } from 'mdast';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Convert an mdast tree (already produced by @luxurylabs/pretdf-core) into
|
|
5
|
+
* an HTML body string ready to be wrapped in the page template.
|
|
6
|
+
*
|
|
7
|
+
* The pipeline is:
|
|
8
|
+
* 1. pretdfDirectives — translate pretdf directives into hast-friendly metadata.
|
|
9
|
+
* 2. mdast-util-to-hast — convert mdast → hast.
|
|
10
|
+
* 3. hast-util-to-html — serialize hast → HTML string.
|
|
11
|
+
*/
|
|
12
|
+
declare function astToHtml(ast: Root): string;
|
|
13
|
+
|
|
14
|
+
export { astToHtml };
|
package/dist/html.js
ADDED
package/dist/html.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ResolvedDocument } from '@luxurylabs/pretdf-core';
|
|
2
|
+
import { Browser, chromium } from 'playwright-core';
|
|
3
|
+
export { astToHtml } from './html.js';
|
|
4
|
+
export { buildStylesheet } from './styles.js';
|
|
5
|
+
export { wrapDocument } from './template.js';
|
|
6
|
+
import 'mdast';
|
|
7
|
+
|
|
8
|
+
interface RenderOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Optional warm Browser instance (e.g., from a pool managed by the future
|
|
11
|
+
* pretdf-server package). When provided, the render function will not
|
|
12
|
+
* launch or close it; the caller owns the lifecycle.
|
|
13
|
+
*
|
|
14
|
+
* When omitted, a fresh headless Chromium is launched per call and shut
|
|
15
|
+
* down before the function returns. This is the spawn-per-invocation mode
|
|
16
|
+
* the CLI uses.
|
|
17
|
+
*/
|
|
18
|
+
browser?: Browser;
|
|
19
|
+
/**
|
|
20
|
+
* Additional CSS to inject into the document, layered on top of the base
|
|
21
|
+
* stylesheet. Useful for project-specific theming.
|
|
22
|
+
*/
|
|
23
|
+
extraCss?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Override the Playwright launch options. Ignored when `browser` is provided.
|
|
26
|
+
*/
|
|
27
|
+
launchOptions?: Parameters<typeof chromium.launch>[0];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Render a resolved document to a PDF byte buffer.
|
|
31
|
+
*
|
|
32
|
+
* The returned value is a Uint8Array (Playwright's native return type for
|
|
33
|
+
* page.pdf()). It can be written directly to disk via fs.writeFile or piped
|
|
34
|
+
* to stdout.
|
|
35
|
+
*/
|
|
36
|
+
declare function render(document: ResolvedDocument, options?: RenderOptions): Promise<Uint8Array>;
|
|
37
|
+
/**
|
|
38
|
+
* Translate a resolved document into a complete HTML document string,
|
|
39
|
+
* without invoking Chromium. Exposed so the (future) preview command can
|
|
40
|
+
* serve the same HTML the renderer uses.
|
|
41
|
+
*/
|
|
42
|
+
declare function renderToHtml(document: ResolvedDocument, extraCss?: string): string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @luxurylabs/pretdf-render-chromium
|
|
46
|
+
*
|
|
47
|
+
* Chromium-based PDF render engine for pretdf, built on Playwright.
|
|
48
|
+
*
|
|
49
|
+
* Responsibilities:
|
|
50
|
+
* - Translate the resolved AST from @luxurylabs/pretdf-core into HTML + CSS.
|
|
51
|
+
* - Apply CSS Paged Media for headers, footers, page numbering, page breaks.
|
|
52
|
+
* - Drive Playwright's page.pdf() to produce the final binary.
|
|
53
|
+
* - Expose a stateless render(document, options) -> Uint8Array for the CLI
|
|
54
|
+
* to call spawn-per-invocation, plus a `browser` option so the future
|
|
55
|
+
* pretdf-server package can share a warm browser pool.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
declare const VERSION = "0.0.0";
|
|
59
|
+
|
|
60
|
+
export { type RenderOptions, VERSION, render, renderToHtml };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
astToHtml
|
|
3
|
+
} from "./chunk-F55DUO5E.js";
|
|
4
|
+
import {
|
|
5
|
+
wrapDocument
|
|
6
|
+
} from "./chunk-DGLH4GAC.js";
|
|
7
|
+
import {
|
|
8
|
+
buildStylesheet
|
|
9
|
+
} from "./chunk-SNMJDRSH.js";
|
|
10
|
+
|
|
11
|
+
// src/render.ts
|
|
12
|
+
import { chromium } from "playwright-core";
|
|
13
|
+
async function render(document, options = {}) {
|
|
14
|
+
const html = renderToHtml(document, options.extraCss);
|
|
15
|
+
const ownsBrowser = !options.browser;
|
|
16
|
+
const browser = options.browser ?? await chromium.launch({ headless: true, ...options.launchOptions });
|
|
17
|
+
try {
|
|
18
|
+
const context = await browser.newContext();
|
|
19
|
+
const page = await context.newPage();
|
|
20
|
+
try {
|
|
21
|
+
await page.setContent(html, { waitUntil: "networkidle" });
|
|
22
|
+
const hasHeaderFooter = !!(document.headerHtml || document.footerHtml);
|
|
23
|
+
const pdf = await page.pdf({
|
|
24
|
+
printBackground: true,
|
|
25
|
+
preferCSSPageSize: true,
|
|
26
|
+
displayHeaderFooter: hasHeaderFooter,
|
|
27
|
+
headerTemplate: document.headerHtml ?? "<span></span>",
|
|
28
|
+
footerTemplate: document.footerHtml ?? "<span></span>"
|
|
29
|
+
});
|
|
30
|
+
return pdf;
|
|
31
|
+
} finally {
|
|
32
|
+
await page.close();
|
|
33
|
+
await context.close();
|
|
34
|
+
}
|
|
35
|
+
} finally {
|
|
36
|
+
if (ownsBrowser) {
|
|
37
|
+
await browser.close();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function renderToHtml(document, extraCss) {
|
|
42
|
+
const bodyHtml = astToHtml(document.ast);
|
|
43
|
+
return wrapDocument(bodyHtml, document.config, extraCss);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/index.ts
|
|
47
|
+
var VERSION = "0.0.0";
|
|
48
|
+
export {
|
|
49
|
+
VERSION,
|
|
50
|
+
astToHtml,
|
|
51
|
+
buildStylesheet,
|
|
52
|
+
render,
|
|
53
|
+
renderToHtml,
|
|
54
|
+
wrapDocument
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/render.ts","../src/index.ts"],"sourcesContent":["import type { ResolvedDocument } from '@luxurylabs/pretdf-core';\nimport { type Browser, chromium } from 'playwright-core';\nimport { astToHtml } from './html.js';\nimport { wrapDocument } from './template.js';\n\nexport interface RenderOptions {\n /**\n * Optional warm Browser instance (e.g., from a pool managed by the future\n * pretdf-server package). When provided, the render function will not\n * launch or close it; the caller owns the lifecycle.\n *\n * When omitted, a fresh headless Chromium is launched per call and shut\n * down before the function returns. This is the spawn-per-invocation mode\n * the CLI uses.\n */\n browser?: Browser;\n\n /**\n * Additional CSS to inject into the document, layered on top of the base\n * stylesheet. Useful for project-specific theming.\n */\n extraCss?: string;\n\n /**\n * Override the Playwright launch options. Ignored when `browser` is provided.\n */\n launchOptions?: Parameters<typeof chromium.launch>[0];\n}\n\n/**\n * Render a resolved document to a PDF byte buffer.\n *\n * The returned value is a Uint8Array (Playwright's native return type for\n * page.pdf()). It can be written directly to disk via fs.writeFile or piped\n * to stdout.\n */\nexport async function render(\n document: ResolvedDocument,\n options: RenderOptions = {},\n): Promise<Uint8Array> {\n const html = renderToHtml(document, options.extraCss);\n\n const ownsBrowser = !options.browser;\n const browser =\n options.browser ?? (await chromium.launch({ headless: true, ...options.launchOptions }));\n\n try {\n const context = await browser.newContext();\n const page = await context.newPage();\n try {\n await page.setContent(html, { waitUntil: 'networkidle' });\n const hasHeaderFooter = !!(document.headerHtml || document.footerHtml);\n const pdf = await page.pdf({\n printBackground: true,\n preferCSSPageSize: true,\n displayHeaderFooter: hasHeaderFooter,\n headerTemplate: document.headerHtml ?? '<span></span>',\n footerTemplate: document.footerHtml ?? '<span></span>',\n });\n return pdf;\n } finally {\n await page.close();\n await context.close();\n }\n } finally {\n if (ownsBrowser) {\n await browser.close();\n }\n }\n}\n\n/**\n * Translate a resolved document into a complete HTML document string,\n * without invoking Chromium. Exposed so the (future) preview command can\n * serve the same HTML the renderer uses.\n */\nexport function renderToHtml(document: ResolvedDocument, extraCss?: string): string {\n const bodyHtml = astToHtml(document.ast);\n return wrapDocument(bodyHtml, document.config, extraCss);\n}\n","/**\n * @luxurylabs/pretdf-render-chromium\n *\n * Chromium-based PDF render engine for pretdf, built on Playwright.\n *\n * Responsibilities:\n * - Translate the resolved AST from @luxurylabs/pretdf-core into HTML + CSS.\n * - Apply CSS Paged Media for headers, footers, page numbering, page breaks.\n * - Drive Playwright's page.pdf() to produce the final binary.\n * - Expose a stateless render(document, options) -> Uint8Array for the CLI\n * to call spawn-per-invocation, plus a `browser` option so the future\n * pretdf-server package can share a warm browser pool.\n */\n\nexport { render, renderToHtml } from './render.js';\nexport type { RenderOptions } from './render.js';\nexport { astToHtml } from './html.js';\nexport { buildStylesheet } from './styles.js';\nexport { wrapDocument } from './template.js';\n\nexport const VERSION = '0.0.0';\n"],"mappings":";;;;;;;;;;;AACA,SAAuB,gBAAgB;AAmCvC,eAAsB,OACpB,UACA,UAAyB,CAAC,GACL;AACrB,QAAM,OAAO,aAAa,UAAU,QAAQ,QAAQ;AAEpD,QAAM,cAAc,CAAC,QAAQ;AAC7B,QAAM,UACJ,QAAQ,WAAY,MAAM,SAAS,OAAO,EAAE,UAAU,MAAM,GAAG,QAAQ,cAAc,CAAC;AAExF,MAAI;AACF,UAAM,UAAU,MAAM,QAAQ,WAAW;AACzC,UAAM,OAAO,MAAM,QAAQ,QAAQ;AACnC,QAAI;AACF,YAAM,KAAK,WAAW,MAAM,EAAE,WAAW,cAAc,CAAC;AACxD,YAAM,kBAAkB,CAAC,EAAE,SAAS,cAAc,SAAS;AAC3D,YAAM,MAAM,MAAM,KAAK,IAAI;AAAA,QACzB,iBAAiB;AAAA,QACjB,mBAAmB;AAAA,QACnB,qBAAqB;AAAA,QACrB,gBAAgB,SAAS,cAAc;AAAA,QACvC,gBAAgB,SAAS,cAAc;AAAA,MACzC,CAAC;AACD,aAAO;AAAA,IACT,UAAE;AACA,YAAM,KAAK,MAAM;AACjB,YAAM,QAAQ,MAAM;AAAA,IACtB;AAAA,EACF,UAAE;AACA,QAAI,aAAa;AACf,YAAM,QAAQ,MAAM;AAAA,IACtB;AAAA,EACF;AACF;AAOO,SAAS,aAAa,UAA4B,UAA2B;AAClF,QAAM,WAAW,UAAU,SAAS,GAAG;AACvC,SAAO,aAAa,UAAU,SAAS,QAAQ,QAAQ;AACzD;;;AC3DO,IAAM,UAAU;","names":[]}
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DocumentConfig } from '@luxurylabs/pretdf-core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generate the base stylesheet for a pretdf document.
|
|
5
|
+
*
|
|
6
|
+
* The CSS is intentionally small and unopinionated: it sets up the @page
|
|
7
|
+
* rules for size/margin/orientation and provides minimum styling for the
|
|
8
|
+
* built-in directive classes (section, callout, source, columns, etc.).
|
|
9
|
+
*
|
|
10
|
+
* Project-specific theming should be layered on top via `extraCss`.
|
|
11
|
+
*/
|
|
12
|
+
declare function buildStylesheet(config: DocumentConfig): string;
|
|
13
|
+
|
|
14
|
+
export { buildStylesheet };
|
package/dist/styles.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DocumentConfig } from '@luxurylabs/pretdf-core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wrap a body HTML fragment in a complete HTML document ready to be loaded
|
|
5
|
+
* into Playwright's `page.setContent()`.
|
|
6
|
+
*/
|
|
7
|
+
declare function wrapDocument(bodyHtml: string, config: DocumentConfig, extraCss?: string): string;
|
|
8
|
+
|
|
9
|
+
export { wrapDocument };
|
package/dist/template.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@luxurylabs/pretdf-render-chromium",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Chromium/Playwright PDF render engine for pretdf",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./html": {
|
|
16
|
+
"types": "./dist/html.d.ts",
|
|
17
|
+
"import": "./dist/html.js"
|
|
18
|
+
},
|
|
19
|
+
"./template": {
|
|
20
|
+
"types": "./dist/template.d.ts",
|
|
21
|
+
"import": "./dist/template.js"
|
|
22
|
+
},
|
|
23
|
+
"./styles": {
|
|
24
|
+
"types": "./dist/styles.d.ts",
|
|
25
|
+
"import": "./dist/styles.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": ["dist", "README.md"],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsup",
|
|
31
|
+
"dev": "tsup --watch",
|
|
32
|
+
"test": "vitest run --passWithNoTests",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"clean": "rm -rf dist .turbo"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@luxurylabs/pretdf-core": "workspace:*",
|
|
38
|
+
"@types/hast": "^3.0.4",
|
|
39
|
+
"@types/mdast": "^4.0.4",
|
|
40
|
+
"@types/unist": "^3.0.3",
|
|
41
|
+
"hast-util-to-html": "^9.0.0",
|
|
42
|
+
"hastscript": "^9.0.0",
|
|
43
|
+
"mdast-util-to-hast": "^13.2.0",
|
|
44
|
+
"playwright-core": "^1.46.1",
|
|
45
|
+
"unist-util-visit": "^5.0.0"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
}
|
|
50
|
+
}
|