@formepdf/svelte 0.11.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/README.md +101 -0
- package/dist/components/AreaChart.svelte +8 -0
- package/dist/components/AreaChart.svelte.d.ts +4 -0
- package/dist/components/BarChart.svelte +8 -0
- package/dist/components/BarChart.svelte.d.ts +4 -0
- package/dist/components/Barcode.svelte +23 -0
- package/dist/components/Barcode.svelte.d.ts +18 -0
- package/dist/components/Canvas.svelte +28 -0
- package/dist/components/Canvas.svelte.d.ts +21 -0
- package/dist/components/Cell.svelte +16 -0
- package/dist/components/Cell.svelte.d.ts +11 -0
- package/dist/components/Checkbox.svelte +22 -0
- package/dist/components/Checkbox.svelte.d.ts +17 -0
- package/dist/components/Code.svelte +14 -0
- package/dist/components/Code.svelte.d.ts +9 -0
- package/dist/components/Document.svelte +33 -0
- package/dist/components/Document.svelte.d.ts +28 -0
- package/dist/components/DotPlot.svelte +8 -0
- package/dist/components/DotPlot.svelte.d.ts +4 -0
- package/dist/components/Dropdown.svelte +26 -0
- package/dist/components/Dropdown.svelte.d.ts +21 -0
- package/dist/components/Em.svelte +14 -0
- package/dist/components/Em.svelte.d.ts +9 -0
- package/dist/components/Fixed.svelte +18 -0
- package/dist/components/Fixed.svelte.d.ts +13 -0
- package/dist/components/H1.svelte +16 -0
- package/dist/components/H1.svelte.d.ts +11 -0
- package/dist/components/H2.svelte +16 -0
- package/dist/components/H2.svelte.d.ts +11 -0
- package/dist/components/H3.svelte +16 -0
- package/dist/components/H3.svelte.d.ts +11 -0
- package/dist/components/H4.svelte +16 -0
- package/dist/components/H4.svelte.d.ts +11 -0
- package/dist/components/H5.svelte +16 -0
- package/dist/components/H5.svelte.d.ts +11 -0
- package/dist/components/H6.svelte +16 -0
- package/dist/components/H6.svelte.d.ts +11 -0
- package/dist/components/Image.svelte +25 -0
- package/dist/components/Image.svelte.d.ts +20 -0
- package/dist/components/LineChart.svelte +8 -0
- package/dist/components/LineChart.svelte.d.ts +4 -0
- package/dist/components/Link.svelte +15 -0
- package/dist/components/Link.svelte.d.ts +10 -0
- package/dist/components/ListItem.svelte +14 -0
- package/dist/components/ListItem.svelte.d.ts +9 -0
- package/dist/components/OrderedList.svelte +19 -0
- package/dist/components/OrderedList.svelte.d.ts +14 -0
- package/dist/components/Page.svelte +26 -0
- package/dist/components/Page.svelte.d.ts +24 -0
- package/dist/components/PageBreak.svelte +6 -0
- package/dist/components/PageBreak.svelte.d.ts +18 -0
- package/dist/components/PieChart.svelte +8 -0
- package/dist/components/PieChart.svelte.d.ts +4 -0
- package/dist/components/QrCode.svelte +19 -0
- package/dist/components/QrCode.svelte.d.ts +14 -0
- package/dist/components/RadioButton.svelte +24 -0
- package/dist/components/RadioButton.svelte.d.ts +19 -0
- package/dist/components/Row.svelte +17 -0
- package/dist/components/Row.svelte.d.ts +12 -0
- package/dist/components/Strong.svelte +14 -0
- package/dist/components/Strong.svelte.d.ts +9 -0
- package/dist/components/Svg.svelte +26 -0
- package/dist/components/Svg.svelte.d.ts +21 -0
- package/dist/components/Table.svelte +18 -0
- package/dist/components/Table.svelte.d.ts +13 -0
- package/dist/components/Text.svelte +16 -0
- package/dist/components/Text.svelte.d.ts +11 -0
- package/dist/components/TextField.svelte +32 -0
- package/dist/components/TextField.svelte.d.ts +27 -0
- package/dist/components/UnorderedList.svelte +17 -0
- package/dist/components/UnorderedList.svelte.d.ts +12 -0
- package/dist/components/View.svelte +17 -0
- package/dist/components/View.svelte.d.ts +12 -0
- package/dist/components/Watermark.svelte +23 -0
- package/dist/components/Watermark.svelte.d.ts +18 -0
- package/dist/constants.d.ts +20 -0
- package/dist/constants.js +20 -0
- package/dist/encode.d.ts +27 -0
- package/dist/encode.js +93 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +50 -0
- package/dist/parser.d.ts +30 -0
- package/dist/parser.js +756 -0
- package/dist/preview/index.d.ts +87 -0
- package/dist/preview/index.js +256 -0
- package/dist/preview/preview-html.generated.d.ts +5 -0
- package/dist/preview/preview-html.generated.js +5 -0
- package/dist/render-document.d.ts +36 -0
- package/dist/render-document.js +47 -0
- package/dist/serialize.d.ts +36 -0
- package/dist/serialize.js +39 -0
- package/dist/stylesheet.d.ts +4 -0
- package/dist/stylesheet.js +5 -0
- package/package.json +63 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { Style } from '@formepdf/shared';
|
|
4
|
+
import { encodeProps } from '../encode.js';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
style?: Style;
|
|
8
|
+
wrap?: boolean;
|
|
9
|
+
bookmark?: string;
|
|
10
|
+
href?: string;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let { children, ...rest }: Props = $props();
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<forme-view props={encodeProps('View', rest)}>{@render children?.()}</forme-view>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { Style } from '@formepdf/shared';
|
|
3
|
+
interface Props {
|
|
4
|
+
style?: Style;
|
|
5
|
+
wrap?: boolean;
|
|
6
|
+
bookmark?: string;
|
|
7
|
+
href?: string;
|
|
8
|
+
children?: Snippet;
|
|
9
|
+
}
|
|
10
|
+
declare const View: import("svelte").Component<Props, {}, "">;
|
|
11
|
+
type View = ReturnType<typeof View>;
|
|
12
|
+
export default View;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Style } from '@formepdf/shared';
|
|
3
|
+
import { encodeProps } from '../encode.js';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
/** Watermark text (e.g. "DRAFT", "CONFIDENTIAL"). */
|
|
7
|
+
text: string;
|
|
8
|
+
/** Font size in points. Default: 60. */
|
|
9
|
+
fontSize?: number;
|
|
10
|
+
/** Text color. Use `rgba(0,0,0,0.1)` for subtle watermarks.
|
|
11
|
+
* Default: "rgba(0,0,0,0.1)". */
|
|
12
|
+
color?: string;
|
|
13
|
+
/** Rotation angle in degrees (negative = counterclockwise).
|
|
14
|
+
* Default: -45. */
|
|
15
|
+
angle?: number;
|
|
16
|
+
/** Additional style properties (fontFamily, etc.). */
|
|
17
|
+
style?: Style;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let rest: Props = $props();
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<forme-watermark props={encodeProps('Watermark', rest)}></forme-watermark>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Style } from '@formepdf/shared';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Watermark text (e.g. "DRAFT", "CONFIDENTIAL"). */
|
|
4
|
+
text: string;
|
|
5
|
+
/** Font size in points. Default: 60. */
|
|
6
|
+
fontSize?: number;
|
|
7
|
+
/** Text color. Use `rgba(0,0,0,0.1)` for subtle watermarks.
|
|
8
|
+
* Default: "rgba(0,0,0,0.1)". */
|
|
9
|
+
color?: string;
|
|
10
|
+
/** Rotation angle in degrees (negative = counterclockwise).
|
|
11
|
+
* Default: -45. */
|
|
12
|
+
angle?: number;
|
|
13
|
+
/** Additional style properties (fontFamily, etc.). */
|
|
14
|
+
style?: Style;
|
|
15
|
+
}
|
|
16
|
+
declare const Watermark: import("svelte").Component<Props, {}, "">;
|
|
17
|
+
type Watermark = ReturnType<typeof Watermark>;
|
|
18
|
+
export default Watermark;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page-number placeholders.
|
|
3
|
+
*
|
|
4
|
+
* The engine substitutes `{{pageNumber}}` and `{{totalPages}}` in text
|
|
5
|
+
* content when it serializes each page. In JSX the braces can be typed
|
|
6
|
+
* as a string literal (`{'{{pageNumber}}'}`), but in a Svelte template
|
|
7
|
+
* `{{pageNumber}}` parses as an object-literal expression - so the
|
|
8
|
+
* documented way to emit the placeholders is interpolating these
|
|
9
|
+
* constants:
|
|
10
|
+
*
|
|
11
|
+
* ```svelte
|
|
12
|
+
* <Fixed position="footer">
|
|
13
|
+
* <Text>Page {PAGE_NUMBER} of {TOTAL_PAGES}</Text>
|
|
14
|
+
* </Fixed>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
/** Replaced with the current page number at render time. */
|
|
18
|
+
export declare const PAGE_NUMBER = "{{pageNumber}}";
|
|
19
|
+
/** Replaced with the document's total page count at render time. */
|
|
20
|
+
export declare const TOTAL_PAGES = "{{totalPages}}";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page-number placeholders.
|
|
3
|
+
*
|
|
4
|
+
* The engine substitutes `{{pageNumber}}` and `{{totalPages}}` in text
|
|
5
|
+
* content when it serializes each page. In JSX the braces can be typed
|
|
6
|
+
* as a string literal (`{'{{pageNumber}}'}`), but in a Svelte template
|
|
7
|
+
* `{{pageNumber}}` parses as an object-literal expression - so the
|
|
8
|
+
* documented way to emit the placeholders is interpolating these
|
|
9
|
+
* constants:
|
|
10
|
+
*
|
|
11
|
+
* ```svelte
|
|
12
|
+
* <Fixed position="footer">
|
|
13
|
+
* <Text>Page {PAGE_NUMBER} of {TOTAL_PAGES}</Text>
|
|
14
|
+
* </Fixed>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
/** Replaced with the current page number at render time. */
|
|
18
|
+
export const PAGE_NUMBER = '{{pageNumber}}';
|
|
19
|
+
/** Replaced with the document's total page count at render time. */
|
|
20
|
+
export const TOTAL_PAGES = '{{totalPages}}';
|
package/dist/encode.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prop encoding for the emitting components.
|
|
3
|
+
*
|
|
4
|
+
* Each Forme Svelte component renders one placeholder tag whose
|
|
5
|
+
* `props` attribute carries the component's props as JSON (part of
|
|
6
|
+
* the internal emitter/parser contract - see `parser.ts`). Values
|
|
7
|
+
* that cannot survive the JSON round-trip fail loudly here, naming
|
|
8
|
+
* the component and prop, rather than silently producing a wrong PDF.
|
|
9
|
+
* The one exception is `Uint8Array` (byte font sources on
|
|
10
|
+
* `<Document fonts>`): it is tunneled through a marker object and
|
|
11
|
+
* restored by the parser's reviver, so byte sources survive
|
|
12
|
+
* serialization exactly as they do in the react adapter.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* `JSON.parse` reviver restoring `Uint8Array` values that
|
|
16
|
+
* `encodeProps` tunneled through byte markers.
|
|
17
|
+
*/
|
|
18
|
+
export declare function reviveBytesMarker(_key: string, value: unknown): unknown;
|
|
19
|
+
/**
|
|
20
|
+
* JSON-encode a component's props for the placeholder `props`
|
|
21
|
+
* attribute. `undefined` values are omitted (matching how absent
|
|
22
|
+
* props behave in the react adapter). `Uint8Array` values become
|
|
23
|
+
* byte markers (see `reviveBytesMarker`). Functions, symbols,
|
|
24
|
+
* bigints, and circular structures throw an error naming the
|
|
25
|
+
* component and the offending prop.
|
|
26
|
+
*/
|
|
27
|
+
export declare function encodeProps(component: string, props: object): string;
|
package/dist/encode.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prop encoding for the emitting components.
|
|
3
|
+
*
|
|
4
|
+
* Each Forme Svelte component renders one placeholder tag whose
|
|
5
|
+
* `props` attribute carries the component's props as JSON (part of
|
|
6
|
+
* the internal emitter/parser contract - see `parser.ts`). Values
|
|
7
|
+
* that cannot survive the JSON round-trip fail loudly here, naming
|
|
8
|
+
* the component and prop, rather than silently producing a wrong PDF.
|
|
9
|
+
* The one exception is `Uint8Array` (byte font sources on
|
|
10
|
+
* `<Document fonts>`): it is tunneled through a marker object and
|
|
11
|
+
* restored by the parser's reviver, so byte sources survive
|
|
12
|
+
* serialization exactly as they do in the react adapter.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Marker key wrapping a base64-encoded `Uint8Array` inside the props
|
|
16
|
+
* JSON. Part of the internal emitter/parser contract.
|
|
17
|
+
*/
|
|
18
|
+
const BYTES_MARKER = '__formeBytes';
|
|
19
|
+
/** Encode bytes to base64 without Node APIs (works in edge runtimes). */
|
|
20
|
+
function bytesToBase64(bytes) {
|
|
21
|
+
let binary = '';
|
|
22
|
+
const chunk = 0x8000;
|
|
23
|
+
for (let i = 0; i < bytes.length; i += chunk) {
|
|
24
|
+
binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
|
|
25
|
+
}
|
|
26
|
+
return btoa(binary);
|
|
27
|
+
}
|
|
28
|
+
function base64ToBytes(b64) {
|
|
29
|
+
const binary = atob(b64);
|
|
30
|
+
const bytes = new Uint8Array(binary.length);
|
|
31
|
+
for (let i = 0; i < binary.length; i++)
|
|
32
|
+
bytes[i] = binary.charCodeAt(i);
|
|
33
|
+
return bytes;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* `JSON.parse` reviver restoring `Uint8Array` values that
|
|
37
|
+
* `encodeProps` tunneled through byte markers.
|
|
38
|
+
*/
|
|
39
|
+
export function reviveBytesMarker(_key, value) {
|
|
40
|
+
if (value !== null &&
|
|
41
|
+
typeof value === 'object' &&
|
|
42
|
+
typeof value[BYTES_MARKER] === 'string') {
|
|
43
|
+
return base64ToBytes(value[BYTES_MARKER]);
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* JSON-encode a component's props for the placeholder `props`
|
|
49
|
+
* attribute. `undefined` values are omitted (matching how absent
|
|
50
|
+
* props behave in the react adapter). `Uint8Array` values become
|
|
51
|
+
* byte markers (see `reviveBytesMarker`). Functions, symbols,
|
|
52
|
+
* bigints, and circular structures throw an error naming the
|
|
53
|
+
* component and the offending prop.
|
|
54
|
+
*/
|
|
55
|
+
export function encodeProps(component, props) {
|
|
56
|
+
const parts = [];
|
|
57
|
+
for (const [key, value] of Object.entries(props)) {
|
|
58
|
+
if (value === undefined)
|
|
59
|
+
continue;
|
|
60
|
+
let json;
|
|
61
|
+
try {
|
|
62
|
+
json = JSON.stringify(value, (_k, v) => {
|
|
63
|
+
const t = typeof v;
|
|
64
|
+
if (t === 'function' || t === 'symbol' || t === 'bigint') {
|
|
65
|
+
throw new TypeError(`contains a ${t}, which cannot be serialized to JSON`);
|
|
66
|
+
}
|
|
67
|
+
if (v instanceof Uint8Array) {
|
|
68
|
+
return { [BYTES_MARKER]: bytesToBase64(v) };
|
|
69
|
+
}
|
|
70
|
+
// A user object carrying the marker key would be revived as a
|
|
71
|
+
// Uint8Array on the other side - fail loudly instead of
|
|
72
|
+
// silently corrupting it. (Marker objects produced above are
|
|
73
|
+
// never re-visited by the replacer, so this only fires on
|
|
74
|
+
// user-supplied values.)
|
|
75
|
+
if (v !== null && t === 'object' && BYTES_MARKER in v) {
|
|
76
|
+
throw new TypeError(`contains a reserved "${BYTES_MARKER}" key`);
|
|
77
|
+
}
|
|
78
|
+
return v;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
83
|
+
throw new Error(`[Forme] <${component}>: prop "${key}" is not serializable: ${reason}`);
|
|
84
|
+
}
|
|
85
|
+
// JSON.stringify returns undefined (without throwing) for values
|
|
86
|
+
// with no JSON representation at the top level, e.g. functions -
|
|
87
|
+
// drop such props rather than emitting invalid JSON.
|
|
88
|
+
if (json === undefined)
|
|
89
|
+
continue;
|
|
90
|
+
parts.push(`${JSON.stringify(key)}:${json}`);
|
|
91
|
+
}
|
|
92
|
+
return `{${parts.join(',')}}`;
|
|
93
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export { default as Document } from './components/Document.svelte';
|
|
2
|
+
export { default as Page } from './components/Page.svelte';
|
|
3
|
+
export { default as View } from './components/View.svelte';
|
|
4
|
+
export { default as Text } from './components/Text.svelte';
|
|
5
|
+
export { default as H1 } from './components/H1.svelte';
|
|
6
|
+
export { default as H2 } from './components/H2.svelte';
|
|
7
|
+
export { default as H3 } from './components/H3.svelte';
|
|
8
|
+
export { default as H4 } from './components/H4.svelte';
|
|
9
|
+
export { default as H5 } from './components/H5.svelte';
|
|
10
|
+
export { default as H6 } from './components/H6.svelte';
|
|
11
|
+
export { default as OrderedList } from './components/OrderedList.svelte';
|
|
12
|
+
export { default as UnorderedList } from './components/UnorderedList.svelte';
|
|
13
|
+
export { default as ListItem } from './components/ListItem.svelte';
|
|
14
|
+
export { default as Strong } from './components/Strong.svelte';
|
|
15
|
+
export { default as Em } from './components/Em.svelte';
|
|
16
|
+
export { default as Code } from './components/Code.svelte';
|
|
17
|
+
export { default as Link } from './components/Link.svelte';
|
|
18
|
+
export { default as Table } from './components/Table.svelte';
|
|
19
|
+
export { default as Row } from './components/Row.svelte';
|
|
20
|
+
export { default as Cell } from './components/Cell.svelte';
|
|
21
|
+
export { default as Fixed } from './components/Fixed.svelte';
|
|
22
|
+
export { default as Image } from './components/Image.svelte';
|
|
23
|
+
export { default as Svg } from './components/Svg.svelte';
|
|
24
|
+
export { default as QrCode } from './components/QrCode.svelte';
|
|
25
|
+
export { default as Barcode } from './components/Barcode.svelte';
|
|
26
|
+
export { default as Canvas } from './components/Canvas.svelte';
|
|
27
|
+
export { default as Watermark } from './components/Watermark.svelte';
|
|
28
|
+
export { default as PageBreak } from './components/PageBreak.svelte';
|
|
29
|
+
export { default as BarChart } from './components/BarChart.svelte';
|
|
30
|
+
export { default as LineChart } from './components/LineChart.svelte';
|
|
31
|
+
export { default as PieChart } from './components/PieChart.svelte';
|
|
32
|
+
export { default as AreaChart } from './components/AreaChart.svelte';
|
|
33
|
+
export { default as DotPlot } from './components/DotPlot.svelte';
|
|
34
|
+
export { default as TextField } from './components/TextField.svelte';
|
|
35
|
+
export { default as Checkbox } from './components/Checkbox.svelte';
|
|
36
|
+
export { default as Dropdown } from './components/Dropdown.svelte';
|
|
37
|
+
export { default as RadioButton } from './components/RadioButton.svelte';
|
|
38
|
+
export { PAGE_NUMBER, TOTAL_PAGES } from './constants.js';
|
|
39
|
+
export { Font } from '@formepdf/shared';
|
|
40
|
+
export type { FontRegistration } from '@formepdf/shared';
|
|
41
|
+
export { serialize, render, renderToObject } from './serialize.js';
|
|
42
|
+
export type { SerializeOptions } from './serialize.js';
|
|
43
|
+
export { mapStyle, mapDimension, parseColor, expandEdges, expandCorners } from '@formepdf/shared';
|
|
44
|
+
export { renderDocument, renderDocumentWithLayout } from './render-document.js';
|
|
45
|
+
export type { RenderDocumentOptions, RenderDocumentWithLayoutResult } from './render-document.js';
|
|
46
|
+
export { StyleSheet } from './stylesheet.js';
|
|
47
|
+
export type { Style, TextRun, ListMarker, ColumnDef, BarcodeFormat, ChartDataPoint, ChartSeries, DotPlotGroup, BarChartProps, LineChartProps, PieChartProps, AreaChartProps, DotPlotProps, CanvasContext, CanvasOp, GridTrackSize, Edges, Corners, EdgeColors, CertificationConfig, SignatureConfig, FormeDocument, FormeFont, FormeNode, FormeNodeKind, FormeStyle, FormeMetadata, FormePageConfig, FormePageSize, FormeEdges, FormeColumnDef, FormeColumnWidth, FormeDimension, FormeColor, FormeEdgeValues, FormeCornerValues, FormeGridTrackSize, FormeGridPlacement, FormeListMarkerType, FormeTransformOp, } from '@formepdf/shared';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Components
|
|
2
|
+
export { default as Document } from './components/Document.svelte';
|
|
3
|
+
export { default as Page } from './components/Page.svelte';
|
|
4
|
+
export { default as View } from './components/View.svelte';
|
|
5
|
+
export { default as Text } from './components/Text.svelte';
|
|
6
|
+
export { default as H1 } from './components/H1.svelte';
|
|
7
|
+
export { default as H2 } from './components/H2.svelte';
|
|
8
|
+
export { default as H3 } from './components/H3.svelte';
|
|
9
|
+
export { default as H4 } from './components/H4.svelte';
|
|
10
|
+
export { default as H5 } from './components/H5.svelte';
|
|
11
|
+
export { default as H6 } from './components/H6.svelte';
|
|
12
|
+
export { default as OrderedList } from './components/OrderedList.svelte';
|
|
13
|
+
export { default as UnorderedList } from './components/UnorderedList.svelte';
|
|
14
|
+
export { default as ListItem } from './components/ListItem.svelte';
|
|
15
|
+
export { default as Strong } from './components/Strong.svelte';
|
|
16
|
+
export { default as Em } from './components/Em.svelte';
|
|
17
|
+
export { default as Code } from './components/Code.svelte';
|
|
18
|
+
export { default as Link } from './components/Link.svelte';
|
|
19
|
+
export { default as Table } from './components/Table.svelte';
|
|
20
|
+
export { default as Row } from './components/Row.svelte';
|
|
21
|
+
export { default as Cell } from './components/Cell.svelte';
|
|
22
|
+
export { default as Fixed } from './components/Fixed.svelte';
|
|
23
|
+
export { default as Image } from './components/Image.svelte';
|
|
24
|
+
export { default as Svg } from './components/Svg.svelte';
|
|
25
|
+
export { default as QrCode } from './components/QrCode.svelte';
|
|
26
|
+
export { default as Barcode } from './components/Barcode.svelte';
|
|
27
|
+
export { default as Canvas } from './components/Canvas.svelte';
|
|
28
|
+
export { default as Watermark } from './components/Watermark.svelte';
|
|
29
|
+
export { default as PageBreak } from './components/PageBreak.svelte';
|
|
30
|
+
export { default as BarChart } from './components/BarChart.svelte';
|
|
31
|
+
export { default as LineChart } from './components/LineChart.svelte';
|
|
32
|
+
export { default as PieChart } from './components/PieChart.svelte';
|
|
33
|
+
export { default as AreaChart } from './components/AreaChart.svelte';
|
|
34
|
+
export { default as DotPlot } from './components/DotPlot.svelte';
|
|
35
|
+
export { default as TextField } from './components/TextField.svelte';
|
|
36
|
+
export { default as Checkbox } from './components/Checkbox.svelte';
|
|
37
|
+
export { default as Dropdown } from './components/Dropdown.svelte';
|
|
38
|
+
export { default as RadioButton } from './components/RadioButton.svelte';
|
|
39
|
+
// Page-number placeholders
|
|
40
|
+
export { PAGE_NUMBER, TOTAL_PAGES } from './constants.js';
|
|
41
|
+
// Font registration (the shared store singleton - registrations are
|
|
42
|
+
// visible to every adapter in the process)
|
|
43
|
+
export { Font } from '@formepdf/shared';
|
|
44
|
+
// Serialization
|
|
45
|
+
export { serialize, render, renderToObject } from './serialize.js';
|
|
46
|
+
export { mapStyle, mapDimension, parseColor, expandEdges, expandCorners } from '@formepdf/shared';
|
|
47
|
+
// One-call PDF rendering (requires the optional @formepdf/core peer)
|
|
48
|
+
export { renderDocument, renderDocumentWithLayout } from './render-document.js';
|
|
49
|
+
// StyleSheet
|
|
50
|
+
export { StyleSheet } from './stylesheet.js';
|
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markup parser: Svelte SSR output in, Forme document model out.
|
|
3
|
+
*
|
|
4
|
+
* The Forme Svelte components render namespaced placeholder tags
|
|
5
|
+
* (`<forme-document>`, `<forme-page>`, `<forme-view>`, `<forme-text>`)
|
|
6
|
+
* with a single `props` attribute holding the JSON-encoded component
|
|
7
|
+
* props. This module parses that markup - the emitting components and
|
|
8
|
+
* this parser are a matched pair inside this package. The placeholder
|
|
9
|
+
* tag/attribute vocabulary is an INTERNAL contract, not a public
|
|
10
|
+
* format: it may change in any release without notice.
|
|
11
|
+
*
|
|
12
|
+
* Whitespace is normalized to JSX-equivalent semantics so that a
|
|
13
|
+
* `.svelte` template and its TSX counterpart serialize identically:
|
|
14
|
+
* indentation and newlines never leak into text content, while
|
|
15
|
+
* interior spaces and interpolation boundaries are preserved. The
|
|
16
|
+
* Svelte compiler trims fragment edges and collapses inter-element
|
|
17
|
+
* whitespace before we ever see the markup, so the remaining rules
|
|
18
|
+
* are applied here (see `cleanJsxText`). Known divergences from JSX,
|
|
19
|
+
* where the compiler destroys the distinction before serialization -
|
|
20
|
+
* each matches how Svelte itself renders the template to the DOM:
|
|
21
|
+
*
|
|
22
|
+
* - Same-line leading/trailing spaces inside `<Text>` are trimmed
|
|
23
|
+
* (`<Text> a </Text>` → `"a"`; JSX keeps them).
|
|
24
|
+
* - Interpolations split across lines join with a single space
|
|
25
|
+
* (JSX drops the whitespace-only literal between them entirely).
|
|
26
|
+
* - Newlines inside interpolated *values* are treated like template
|
|
27
|
+
* text and collapse to a space.
|
|
28
|
+
*/
|
|
29
|
+
import type { FormeDocument } from '@formepdf/shared';
|
|
30
|
+
export declare function parseMarkup(markup: string): FormeDocument;
|