@formepdf/preact 0.12.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/index.js ADDED
@@ -0,0 +1,15 @@
1
+ // Components
2
+ export { Document, Page, View, Text, H1, H2, H3, H4, H5, H6, OrderedList, UnorderedList, ListItem, Strong, Em, Code, Link, Image, Table, Row, Cell, Fixed, Svg, QrCode, Barcode, Canvas, Watermark, PageBreak, BarChart, LineChart, PieChart, AreaChart, DotPlot, TextField, Checkbox, Dropdown, RadioButton } from './components.js';
3
+ export { LegacyBarChart, LegacyLineChart, LegacyPieChart } from './charts.js';
4
+ // Serialization
5
+ export { serialize, serializeTemplate } from './serialize.js';
6
+ export { mapStyle, mapDimension, parseColor, expandEdges, expandCorners } from '@formepdf/shared';
7
+ // StyleSheet
8
+ export { StyleSheet } from './stylesheet.js';
9
+ // Font registration
10
+ export { Font } from './font.js';
11
+ // Template compilation
12
+ export { createDataProxy, isRefMarker, isEachMarker, isExprMarker } from './template-proxy.js';
13
+ export { expr } from './expr.js';
14
+ // Render functions
15
+ export { render, renderToObject } from './render.js';
@@ -0,0 +1,12 @@
1
+ import type { VNode } from 'preact';
2
+ import type { FormeDocument } from './types.js';
3
+ /**
4
+ * Render a Preact element tree to a Forme JSON string.
5
+ * The top-level element must be a <Document>.
6
+ */
7
+ export declare function render(element: VNode): string;
8
+ /**
9
+ * Render a Preact element tree to a Forme document object.
10
+ * The top-level element must be a <Document>.
11
+ */
12
+ export declare function renderToObject(element: VNode): FormeDocument;
package/dist/render.js ADDED
@@ -0,0 +1,15 @@
1
+ import { serialize } from './serialize.js';
2
+ /**
3
+ * Render a Preact element tree to a Forme JSON string.
4
+ * The top-level element must be a <Document>.
5
+ */
6
+ export function render(element) {
7
+ return JSON.stringify(serialize(element));
8
+ }
9
+ /**
10
+ * Render a Preact element tree to a Forme document object.
11
+ * The top-level element must be a <Document>.
12
+ */
13
+ export function renderToObject(element) {
14
+ return serialize(element);
15
+ }
@@ -0,0 +1,14 @@
1
+ import { type VNode } from 'preact';
2
+ type ReactElement = VNode;
3
+ import type { FormeDocument } from './types.js';
4
+ /**
5
+ * Serialize a React element tree into a Forme JSON document object.
6
+ * The top-level element must be a <Document> (or a component that returns one).
7
+ */
8
+ export declare function serialize(element: ReactElement): FormeDocument;
9
+ /**
10
+ * Serialize a React element tree into a Forme template JSON document.
11
+ * Like `serialize()` but with expression marker detection for template compilation.
12
+ */
13
+ export declare function serializeTemplate(element: ReactElement): Record<string, unknown>;
14
+ export {};