@pdfme/common 6.0.3 → 6.0.4-dev.1
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/constants.d.ts +20 -0
- package/dist/dynamicTemplate.d.ts +27 -0
- package/dist/expression.d.ts +6 -0
- package/dist/helper.d.ts +36 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +950 -0
- package/dist/index.js.map +1 -0
- package/dist/pluginRegistry.d.ts +5 -0
- package/dist/schema.d.ts +820 -0
- package/{src/types.ts → dist/types.d.ts} +78 -95
- package/dist/version.d.ts +1 -0
- package/package.json +5 -1
- package/set-version.js +0 -36
- package/src/constants.ts +0 -30
- package/src/dynamicTemplate.ts +0 -321
- package/src/expression.ts +0 -469
- package/src/helper.ts +0 -347
- package/src/index.ts +0 -138
- package/src/pluginRegistry.ts +0 -30
- package/src/schema.ts +0 -223
- package/src/version.ts +0 -1
- package/tsconfig.build.json +0 -14
- package/tsconfig.json +0 -16
- package/vite.config.mts +0 -33
|
@@ -2,44 +2,19 @@ import { z } from 'zod';
|
|
|
2
2
|
import type { PDFPage, PDFDocument } from '@pdfme/pdf-lib';
|
|
3
3
|
import type { ThemeConfig } from 'antd';
|
|
4
4
|
import type { WidgetProps as _PropPanelWidgetProps, Schema as _PropPanelSchema } from 'form-render';
|
|
5
|
-
import {
|
|
6
|
-
Lang,
|
|
7
|
-
Dict,
|
|
8
|
-
Mode,
|
|
9
|
-
Size,
|
|
10
|
-
Schema,
|
|
11
|
-
Font,
|
|
12
|
-
SchemaForUI,
|
|
13
|
-
BasePdf,
|
|
14
|
-
BlankPdf,
|
|
15
|
-
CustomPdf,
|
|
16
|
-
CommonOptions,
|
|
17
|
-
Template,
|
|
18
|
-
GeneratorOptions,
|
|
19
|
-
GenerateProps,
|
|
20
|
-
UIOptions,
|
|
21
|
-
UIProps,
|
|
22
|
-
PreviewProps,
|
|
23
|
-
DesignerProps,
|
|
24
|
-
ColorType,
|
|
25
|
-
LegacySchemaPageArray,
|
|
26
|
-
SchemaPageArray,
|
|
27
|
-
} from './schema.js';
|
|
28
|
-
|
|
5
|
+
import { Lang, Dict, Mode, Size, Schema, Font, SchemaForUI, BasePdf, BlankPdf, CustomPdf, CommonOptions, Template, GeneratorOptions, GenerateProps, UIOptions, UIProps, PreviewProps, DesignerProps, ColorType, LegacySchemaPageArray, SchemaPageArray } from './schema.js';
|
|
29
6
|
export type PropPanelSchema = _PropPanelSchema;
|
|
30
7
|
export type ChangeSchemaItem = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
8
|
+
key: string;
|
|
9
|
+
value: unknown;
|
|
10
|
+
schemaId: string;
|
|
34
11
|
};
|
|
35
12
|
export type ChangeSchemas = (objs: ChangeSchemaItem[]) => void;
|
|
36
|
-
|
|
37
13
|
export type UITheme = {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
14
|
+
colorPrimary: string;
|
|
15
|
+
colorPrimaryBg: string;
|
|
16
|
+
colorWhite: string;
|
|
41
17
|
};
|
|
42
|
-
|
|
43
18
|
/**
|
|
44
19
|
* Properties used for PDF rendering.
|
|
45
20
|
* @template T Type of the extended Schema object.
|
|
@@ -53,17 +28,15 @@ export type UITheme = {
|
|
|
53
28
|
* @property {Map<string | number, unknown>} _cache Cache shared only during the execution of the generate function (useful for caching images, etc. if needed).
|
|
54
29
|
*/
|
|
55
30
|
export interface PDFRenderProps<T extends Schema> {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
_cache: Map<string | number, unknown>;
|
|
31
|
+
value: string;
|
|
32
|
+
schema: T;
|
|
33
|
+
basePdf: BasePdf;
|
|
34
|
+
pdfLib: typeof import('@pdfme/pdf-lib');
|
|
35
|
+
pdfDoc: PDFDocument;
|
|
36
|
+
page: PDFPage;
|
|
37
|
+
options: GeneratorOptions;
|
|
38
|
+
_cache: Map<string | number, unknown>;
|
|
65
39
|
}
|
|
66
|
-
|
|
67
40
|
/**
|
|
68
41
|
* Type for properties used in UI rendering.
|
|
69
42
|
*
|
|
@@ -84,22 +57,27 @@ export interface PDFRenderProps<T extends Schema> {
|
|
|
84
57
|
* @property {Map<string | number, unknown>} _cache - Cache shared only during the execution of the render function (useful for caching images, etc. if needed).
|
|
85
58
|
*/
|
|
86
59
|
export type UIRenderProps<T extends Schema> = {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
60
|
+
schema: T;
|
|
61
|
+
basePdf: BasePdf;
|
|
62
|
+
mode: Mode;
|
|
63
|
+
tabIndex?: number;
|
|
64
|
+
placeholder?: string;
|
|
65
|
+
stopEditing?: () => void;
|
|
66
|
+
value: string;
|
|
67
|
+
onChange?: (arg: {
|
|
68
|
+
key: string;
|
|
69
|
+
value: unknown;
|
|
70
|
+
} | {
|
|
71
|
+
key: string;
|
|
72
|
+
value: unknown;
|
|
73
|
+
}[]) => void;
|
|
74
|
+
rootElement: HTMLDivElement;
|
|
75
|
+
options: UIOptions;
|
|
76
|
+
theme: UITheme;
|
|
77
|
+
i18n: (key: string) => string;
|
|
78
|
+
scale: number;
|
|
79
|
+
_cache: Map<string | number, unknown>;
|
|
101
80
|
};
|
|
102
|
-
|
|
103
81
|
/**
|
|
104
82
|
* Type for properties used in configuring the property panel.
|
|
105
83
|
*
|
|
@@ -114,18 +92,16 @@ export type UIRenderProps<T extends Schema> = {
|
|
|
114
92
|
* @property {(key: keyof Dict | string) => string} i18n - Internationalization dictionary for UI labels and texts.
|
|
115
93
|
*/
|
|
116
94
|
type PropPanelProps = {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
95
|
+
rootElement: HTMLDivElement;
|
|
96
|
+
activeSchema: SchemaForUI;
|
|
97
|
+
activeElements: HTMLElement[];
|
|
98
|
+
changeSchemas: ChangeSchemas;
|
|
99
|
+
schemas: SchemaForUI[];
|
|
100
|
+
options: UIOptions;
|
|
101
|
+
theme: UITheme;
|
|
102
|
+
i18n: (key: string) => string;
|
|
125
103
|
};
|
|
126
|
-
|
|
127
104
|
export type PropPanelWidgetProps = _PropPanelWidgetProps & PropPanelProps;
|
|
128
|
-
|
|
129
105
|
/**
|
|
130
106
|
* Used for customizing the property panel.
|
|
131
107
|
* @template T - Type of the extended Schema object.
|
|
@@ -134,14 +110,10 @@ export type PropPanelWidgetProps = _PropPanelWidgetProps & PropPanelProps;
|
|
|
134
110
|
* @property {T} defaultSchema - The default schema set when adding the schema.
|
|
135
111
|
*/
|
|
136
112
|
export interface PropPanel<T extends Schema> {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
widgets?: Record<string, (props: PropPanelWidgetProps) => void>;
|
|
142
|
-
defaultSchema: T;
|
|
113
|
+
schema: ((propPanelProps: Omit<PropPanelProps, 'rootElement'>) => Record<string, PropPanelSchema>) | Record<string, PropPanelSchema>;
|
|
114
|
+
widgets?: Record<string, (props: PropPanelWidgetProps) => void>;
|
|
115
|
+
defaultSchema: T;
|
|
143
116
|
}
|
|
144
|
-
|
|
145
117
|
/**
|
|
146
118
|
* The Plugin interface is used for PDF and UI rendering, as well as defining the property panel.
|
|
147
119
|
* The 'pdf' is used in the generator package, 'ui' is used in the viewer, form, and designer packages, and 'propPanel' is used in the designer package.
|
|
@@ -154,31 +126,31 @@ export interface PropPanel<T extends Schema> {
|
|
|
154
126
|
* @property {boolean} [uninterruptedEditMode] When editing in the UI, should the field avoid re-rendering while in edit mode?
|
|
155
127
|
*/
|
|
156
128
|
export interface Plugin<T extends Schema = Schema> {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
129
|
+
pdf(arg: PDFRenderProps<T & Schema>): Promise<void> | void;
|
|
130
|
+
ui(arg: UIRenderProps<T & Schema>): Promise<void> | void;
|
|
131
|
+
propPanel: PropPanel<T & Schema>;
|
|
132
|
+
icon?: string;
|
|
133
|
+
uninterruptedEditMode?: boolean;
|
|
162
134
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
135
|
+
export type Plugins = {
|
|
136
|
+
[key: string]: Plugin;
|
|
137
|
+
};
|
|
166
138
|
export interface PluginRegistry {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
139
|
+
plugins: {
|
|
140
|
+
[key: string]: Plugin;
|
|
141
|
+
};
|
|
142
|
+
exists(): boolean;
|
|
143
|
+
values(): Plugin[];
|
|
144
|
+
entries(): [string, Plugin][];
|
|
145
|
+
findByType(type: string): Plugin | undefined;
|
|
146
|
+
findWithLabelByType(type: string): [string, Plugin | undefined];
|
|
173
147
|
}
|
|
174
|
-
|
|
175
148
|
export type Lang = z.infer<typeof Lang>;
|
|
176
149
|
export type Dict = z.infer<typeof Dict>;
|
|
177
150
|
export type Mode = z.infer<typeof Mode>;
|
|
178
151
|
export type Size = z.infer<typeof Size>;
|
|
179
152
|
export type Schema = z.infer<typeof Schema>;
|
|
180
153
|
export type SchemaForUI = z.infer<typeof SchemaForUI>;
|
|
181
|
-
|
|
182
154
|
/**
|
|
183
155
|
* Represents the Font type definition.
|
|
184
156
|
* @property {Object} [x: string] - Object key is the font name.
|
|
@@ -194,10 +166,21 @@ export type CustomPdf = z.infer<typeof CustomPdf>;
|
|
|
194
166
|
export type Template = z.infer<typeof Template>;
|
|
195
167
|
export type CommonOptions = z.infer<typeof CommonOptions>;
|
|
196
168
|
export type GeneratorOptions = z.infer<typeof GeneratorOptions>;
|
|
197
|
-
export type GenerateProps = Omit<z.infer<typeof GenerateProps>, 'plugins'> & {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
export type
|
|
201
|
-
|
|
169
|
+
export type GenerateProps = Omit<z.infer<typeof GenerateProps>, 'plugins'> & {
|
|
170
|
+
plugins?: Plugins;
|
|
171
|
+
};
|
|
172
|
+
export type UIOptions = z.infer<typeof UIOptions> & {
|
|
173
|
+
theme?: ThemeConfig;
|
|
174
|
+
};
|
|
175
|
+
export type UIProps = Omit<z.infer<typeof UIProps>, 'plugins'> & {
|
|
176
|
+
plugins?: Plugins;
|
|
177
|
+
};
|
|
178
|
+
export type PreviewProps = Omit<z.infer<typeof PreviewProps>, 'plugins'> & {
|
|
179
|
+
plugins?: Plugins;
|
|
180
|
+
};
|
|
181
|
+
export type DesignerProps = Omit<z.infer<typeof DesignerProps>, 'plugins'> & {
|
|
182
|
+
plugins?: Plugins;
|
|
183
|
+
};
|
|
202
184
|
export type SchemaPageArray = z.infer<typeof SchemaPageArray>;
|
|
203
185
|
export type LegacySchemaPageArray = z.infer<typeof LegacySchemaPageArray>;
|
|
186
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PDFME_VERSION = "6.0.4";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdfme/common",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.4-dev.1",
|
|
4
4
|
"description": "TypeScript base PDF generator and React base UI. Open source, developed by the community, and completely free to use under the MIT license!",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pdf",
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
24
|
"sideEffects": false,
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
25
29
|
"main": "./dist/index.js",
|
|
26
30
|
"module": "./dist/index.js",
|
|
27
31
|
"types": "./dist/index.d.ts",
|
package/set-version.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { execSync } from 'node:child_process';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
|
|
6
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
|
|
8
|
-
const updateVersion = (version) => {
|
|
9
|
-
const filePath = path.join(__dirname, 'src/version.ts');
|
|
10
|
-
let content = '';
|
|
11
|
-
|
|
12
|
-
if (!fs.existsSync(filePath)) {
|
|
13
|
-
content = `export const PDFME_VERSION = '${version}';\n`;
|
|
14
|
-
} else {
|
|
15
|
-
content = fs.readFileSync(filePath, 'utf8');
|
|
16
|
-
const versionRegex = /export const PDFME_VERSION = '.*';/;
|
|
17
|
-
if (versionRegex.test(content)) {
|
|
18
|
-
content = content.replace(versionRegex, `export const PDFME_VERSION = '${version}';`);
|
|
19
|
-
} else {
|
|
20
|
-
content += `\nexport const PDFME_VERSION = '${version}';\n`;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
fs.writeFileSync(filePath, content, 'utf8');
|
|
25
|
-
console.log(`Replaced PDFME_VERSION with '${version}' in ${filePath}`);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
const gitTag = execSync('git describe --tags $(git rev-list --tags --max-count=1)', {
|
|
30
|
-
encoding: 'utf8',
|
|
31
|
-
}).trim();
|
|
32
|
-
updateVersion(gitTag);
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.error('Error replacing PDFME_VERSION:', error);
|
|
35
|
-
updateVersion('x.x.x');
|
|
36
|
-
}
|