@pdfme/common 6.0.3 → 6.0.5-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/src/schema.ts DELETED
@@ -1,223 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const langs = ['en', 'zh', 'ja', 'ko', 'ar', 'th', 'pl', 'it', 'de', 'es', 'fr'] as const;
4
-
5
- export const Lang = z.enum(langs);
6
- export const Dict = z.object({
7
- // -----------------used in ui-----------------
8
- cancel: z.string(),
9
- close: z.string(),
10
- set: z.string(),
11
- clear: z.string(),
12
- field: z.string(),
13
- fieldName: z.string(),
14
- align: z.string(),
15
- width: z.string(),
16
- opacity: z.string(),
17
- height: z.string(),
18
- rotate: z.string(),
19
- edit: z.string(),
20
- required: z.string(),
21
- editable: z.string(),
22
- plsInputName: z.string(),
23
- fieldMustUniq: z.string(),
24
- notUniq: z.string(),
25
- noKeyName: z.string(),
26
- fieldsList: z.string(),
27
- editField: z.string(),
28
- type: z.string(),
29
- errorOccurred: z.string(),
30
- errorBulkUpdateFieldName: z.string(),
31
- commitBulkUpdateFieldName: z.string(),
32
- bulkUpdateFieldName: z.string(),
33
- addPageAfter: z.string(),
34
- removePage: z.string(),
35
- removePageConfirm: z.string(),
36
- // --------------------validation-------------------
37
- 'validation.uniqueName': z.string(),
38
- 'validation.hexColor': z.string(),
39
- 'validation.dateTimeFormat': z.string(),
40
- 'validation.outOfBounds': z.string(),
41
-
42
- // -----------------used in schemas-----------------
43
- 'schemas.color': z.string(),
44
- 'schemas.borderWidth': z.string(),
45
- 'schemas.borderColor': z.string(),
46
- 'schemas.backgroundColor': z.string(),
47
- 'schemas.textColor': z.string(),
48
- 'schemas.bgColor': z.string(),
49
- 'schemas.horizontal': z.string(),
50
- 'schemas.vertical': z.string(),
51
- 'schemas.left': z.string(),
52
- 'schemas.center': z.string(),
53
- 'schemas.right': z.string(),
54
- 'schemas.top': z.string(),
55
- 'schemas.middle': z.string(),
56
- 'schemas.bottom': z.string(),
57
- 'schemas.padding': z.string(),
58
-
59
- 'schemas.text.fontName': z.string(),
60
- 'schemas.text.size': z.string(),
61
- 'schemas.text.spacing': z.string(),
62
- 'schemas.text.textAlign': z.string(),
63
- 'schemas.text.verticalAlign': z.string(),
64
- 'schemas.text.lineHeight': z.string(),
65
- 'schemas.text.min': z.string(),
66
- 'schemas.text.max': z.string(),
67
- 'schemas.text.fit': z.string(),
68
- 'schemas.text.dynamicFontSize': z.string(),
69
- 'schemas.text.format': z.string(),
70
- 'schemas.radius': z.string(),
71
-
72
- 'schemas.mvt.typingInstructions': z.string(),
73
- 'schemas.mvt.sampleField': z.string(),
74
- 'schemas.mvt.variablesSampleData': z.string(),
75
-
76
- 'schemas.barcodes.barColor': z.string(),
77
- 'schemas.barcodes.includetext': z.string(),
78
-
79
- 'schemas.table.alternateBackgroundColor': z.string(),
80
- 'schemas.table.tableStyle': z.string(),
81
- 'schemas.table.showHead': z.string(),
82
- 'schemas.table.repeatHead': z.string(),
83
- 'schemas.table.headStyle': z.string(),
84
- 'schemas.table.bodyStyle': z.string(),
85
- 'schemas.table.columnStyle': z.string(),
86
-
87
- 'schemas.date.format': z.string(),
88
- 'schemas.date.locale': z.string(),
89
-
90
- 'schemas.select.options': z.string(),
91
- 'schemas.select.optionPlaceholder': z.string(),
92
-
93
- 'schemas.radioGroup.groupName': z.string(),
94
- });
95
- export const Mode = z.enum(['viewer', 'form', 'designer']);
96
-
97
- export const ColorType = z.enum(['rgb', 'cmyk']).optional();
98
-
99
- export const Size = z.object({ height: z.number(), width: z.number() });
100
-
101
- export const Schema = z
102
- .object({
103
- name: z.string(),
104
- type: z.string(),
105
- content: z.string().optional(),
106
- position: z.object({ x: z.number(), y: z.number() }),
107
- width: z.number(),
108
- height: z.number(),
109
- rotate: z.number().optional(),
110
- opacity: z.number().optional(),
111
- readOnly: z.boolean().optional(),
112
- required: z.boolean().optional(),
113
- __bodyRange: z.object({ start: z.number(), end: z.number().optional() }).optional(),
114
- __isSplit: z.boolean().optional(),
115
- })
116
- .passthrough();
117
-
118
- const SchemaForUIAdditionalInfo = z.object({ id: z.string() });
119
- export const SchemaForUI = Schema.merge(SchemaForUIAdditionalInfo);
120
-
121
- const ArrayBufferSchema: z.ZodSchema<ArrayBuffer> = z.any().refine((v) => v instanceof ArrayBuffer);
122
- const Uint8ArraySchema: z.ZodSchema<Uint8Array<ArrayBuffer>> = z
123
- .any()
124
- .refine((v) => v instanceof Uint8Array && v.buffer instanceof ArrayBuffer);
125
-
126
- export const BlankPdf = z.object({
127
- width: z.number(),
128
- height: z.number(),
129
- padding: z.tuple([z.number(), z.number(), z.number(), z.number()]),
130
- staticSchema: z.array(Schema).optional(),
131
- });
132
-
133
- export const CustomPdf = z.union([z.string(), ArrayBufferSchema, Uint8ArraySchema]);
134
-
135
- export const BasePdf = z.union([CustomPdf, BlankPdf]);
136
-
137
- // Legacy keyed structure for BC - we convert to SchemaPageArray on import
138
- export const LegacySchemaPageArray = z.array(z.record(z.string(), Schema));
139
- export const SchemaPageArray = z.array(z.array(Schema));
140
-
141
- export const Template = z
142
- .object({
143
- schemas: SchemaPageArray,
144
- basePdf: BasePdf,
145
- pdfmeVersion: z.string().optional(),
146
- })
147
- .passthrough();
148
-
149
- export const Inputs = z.array(z.record(z.string(), z.any())).min(1);
150
-
151
- export const Font = z.record(
152
- z.string(),
153
- z.object({
154
- data: z.union([z.string(), ArrayBufferSchema, Uint8ArraySchema]),
155
- fallback: z.boolean().optional(),
156
- subset: z.boolean().optional(),
157
- }),
158
- );
159
-
160
- export const Plugin = z
161
- .object({
162
- ui: z.any(),
163
- pdf: z.any(),
164
- propPanel: z.object({
165
- schema: z.unknown(),
166
- widgets: z.record(z.string(), z.any()).optional(),
167
- defaultSchema: Schema,
168
- }),
169
- icon: z.string().optional(),
170
- })
171
- .passthrough();
172
-
173
- export const CommonOptions = z.object({ font: Font.optional() }).passthrough();
174
-
175
- const CommonProps = z.object({
176
- template: Template,
177
- options: CommonOptions.optional(),
178
- plugins: z.record(z.string(), Plugin).optional(),
179
- });
180
-
181
- // -------------------generate-------------------
182
-
183
- export const GeneratorOptions = CommonOptions.extend({
184
- colorType: ColorType,
185
- author: z.string().optional(),
186
- creationDate: z.date().optional(),
187
- creator: z.string().optional(),
188
- keywords: z.array(z.string()).optional(),
189
- lang: Lang.optional(),
190
- modificationDate: z.date().optional(),
191
- producer: z.string().optional(),
192
- subject: z.string().optional(),
193
- title: z.string().optional(),
194
- });
195
-
196
- export const GenerateProps = CommonProps.extend({
197
- inputs: Inputs,
198
- options: GeneratorOptions.optional(),
199
- }).strict();
200
-
201
- // ---------------------ui------------------------
202
-
203
- export const UIOptions = CommonOptions.extend({
204
- lang: Lang.optional(),
205
- labels: z.record(z.string(), z.string()).optional(),
206
- theme: z.record(z.string(), z.unknown()).optional(),
207
- icons: z.record(z.string(), z.string()).optional(),
208
- requiredByDefault: z.boolean().optional(),
209
- maxZoom: z.number().optional(),
210
- sidebarOpen: z.boolean().optional(),
211
- zoomLevel: z.number().optional(),
212
- });
213
-
214
- const HTMLElementSchema: z.ZodSchema<HTMLElement> = z.any().refine((v) => v instanceof HTMLElement);
215
-
216
- export const UIProps = CommonProps.extend({
217
- domContainer: HTMLElementSchema,
218
- options: UIOptions.optional(),
219
- });
220
-
221
- export const PreviewProps = UIProps.extend({ inputs: Inputs }).strict();
222
-
223
- export const DesignerProps = UIProps.extend({}).strict();
package/src/version.ts DELETED
@@ -1 +0,0 @@
1
- export const PDFME_VERSION = '6.0.3';
@@ -1,14 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.build.base.json",
3
- "compilerOptions": {
4
- "declaration": true,
5
- "declarationDir": "./dist",
6
- "emitDeclarationOnly": true,
7
- "module": "ESNext",
8
- "moduleResolution": "bundler",
9
- "outDir": "./dist",
10
- "rootDir": "./src",
11
- "skipLibCheck": true
12
- },
13
- "include": ["src/**/*.ts"]
14
- }
package/tsconfig.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "composite": true,
5
- "declaration": true,
6
- "declarationDir": "./dist/typecheck",
7
- "emitDeclarationOnly": true,
8
- "module": "ESNext",
9
- "moduleResolution": "bundler",
10
- "outDir": "./dist/typecheck",
11
- "tsBuildInfoFile": "./dist/typecheck/tsconfig.tsbuildinfo",
12
- "skipLibCheck": true
13
- },
14
- "include": ["src/**/*.ts"],
15
- "references": [{ "path": "../pdf-lib" }]
16
- }
package/vite.config.mts DELETED
@@ -1,33 +0,0 @@
1
- import { readFileSync } from 'node:fs';
2
- import { builtinModules } from 'node:module';
3
- import { dirname, resolve } from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
- import { defineConfig } from 'vite';
6
-
7
- const __dirname = dirname(fileURLToPath(import.meta.url));
8
- const packageJson = JSON.parse(readFileSync(resolve(__dirname, 'package.json'), 'utf8')) as {
9
- dependencies?: Record<string, string>;
10
- peerDependencies?: Record<string, string>;
11
- };
12
-
13
- const external = [
14
- ...builtinModules,
15
- ...builtinModules.map((moduleName) => `node:${moduleName}`),
16
- ...Object.keys(packageJson.dependencies ?? {}),
17
- ...Object.keys(packageJson.peerDependencies ?? {}),
18
- ];
19
-
20
- export default defineConfig({
21
- build: {
22
- lib: {
23
- entry: resolve(__dirname, 'src/index.ts'),
24
- fileName: 'index',
25
- formats: ['es'],
26
- },
27
- minify: false,
28
- outDir: 'dist',
29
- rollupOptions: { external },
30
- sourcemap: true,
31
- target: 'es2020',
32
- },
33
- });