@pdfme/common 5.4.6 → 5.4.7

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.
@@ -1 +1 @@
1
- export declare const PDFME_VERSION = "5.4.6";
1
+ export declare const PDFME_VERSION = "5.4.7";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/common",
3
- "version": "5.4.6",
3
+ "version": "5.4.7",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
@@ -51,7 +51,7 @@
51
51
  "@pdfme/pdf-lib": "*",
52
52
  "acorn": "^8.15.0",
53
53
  "buffer": "^6.0.3",
54
- "zod": "^3.25.67"
54
+ "zod": "^4.1.12"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "antd": "^5.11.2",
package/src/helper.ts CHANGED
@@ -35,7 +35,7 @@ const uniq = <T>(array: Array<T>) => Array.from(new Set(array));
35
35
  export const getFallbackFontName = (font: Font) => {
36
36
  const initial = '';
37
37
  const fallbackFontName = Object.entries(font).reduce((acc, cur) => {
38
- const [fontName, fontValue] = cur;
38
+ const [fontName, fontValue] = cur as [string, { data: string | ArrayBuffer | Uint8Array; fallback?: boolean; subset?: boolean }];
39
39
 
40
40
  return !acc && fontValue.fallback ? fontName : acc;
41
41
  }, initial);
@@ -179,7 +179,7 @@ export const checkFont = (arg: { font: Font; template: Template }) => {
179
179
  template: { schemas },
180
180
  } = arg;
181
181
  const fontValues = Object.values(font);
182
- const fallbackFontNum = fontValues.reduce((acc, cur) => (cur.fallback ? acc + 1 : acc), 0);
182
+ const fallbackFontNum = fontValues.reduce((acc, cur) => (cur.fallback ? acc + 1 : acc), 0 as number);
183
183
  if (fallbackFontNum === 0) {
184
184
  throw Error(
185
185
  `[@pdfme/common] fallback flag is not found in font. true fallback flag must be only one.
package/src/schema.ts CHANGED
@@ -37,6 +37,7 @@ export const Dict = z.object({
37
37
  'validation.uniqueName': z.string(),
38
38
  'validation.hexColor': z.string(),
39
39
  'validation.dateTimeFormat': z.string(),
40
+ 'validation.outOfBounds': z.string(),
40
41
 
41
42
  // -----------------used in schemas-----------------
42
43
  'schemas.color': z.string(),
@@ -117,7 +118,9 @@ const SchemaForUIAdditionalInfo = z.object({ id: z.string() });
117
118
  export const SchemaForUI = Schema.merge(SchemaForUIAdditionalInfo);
118
119
 
119
120
  const ArrayBufferSchema: z.ZodSchema<ArrayBuffer> = z.any().refine((v) => v instanceof ArrayBuffer);
120
- const Uint8ArraySchema: z.ZodSchema<Uint8Array> = z.any().refine((v) => v instanceof Uint8Array);
121
+ const Uint8ArraySchema: z.ZodSchema<Uint8Array<ArrayBuffer>> = z
122
+ .any()
123
+ .refine((v) => v instanceof Uint8Array && v.buffer instanceof ArrayBuffer);
121
124
 
122
125
  export const BlankPdf = z.object({
123
126
  width: z.number(),
@@ -131,7 +134,7 @@ export const CustomPdf = z.union([z.string(), ArrayBufferSchema, Uint8ArraySchem
131
134
  export const BasePdf = z.union([CustomPdf, BlankPdf]);
132
135
 
133
136
  // Legacy keyed structure for BC - we convert to SchemaPageArray on import
134
- export const LegacySchemaPageArray = z.array(z.record(Schema));
137
+ export const LegacySchemaPageArray = z.array(z.record(z.string(), Schema));
135
138
  export const SchemaPageArray = z.array(z.array(Schema));
136
139
 
137
140
  export const Template = z
@@ -142,9 +145,10 @@ export const Template = z
142
145
  })
143
146
  .passthrough();
144
147
 
145
- export const Inputs = z.array(z.record(z.any())).min(1);
148
+ export const Inputs = z.array(z.record(z.string(), z.any())).min(1);
146
149
 
147
150
  export const Font = z.record(
151
+ z.string(),
148
152
  z.object({
149
153
  data: z.union([z.string(), ArrayBufferSchema, Uint8ArraySchema]),
150
154
  fallback: z.boolean().optional(),
@@ -154,11 +158,11 @@ export const Font = z.record(
154
158
 
155
159
  export const Plugin = z
156
160
  .object({
157
- ui: z.function().args(z.any()).returns(z.any()),
158
- pdf: z.function().args(z.any()).returns(z.any()),
161
+ ui: z.any(),
162
+ pdf: z.any(),
159
163
  propPanel: z.object({
160
164
  schema: z.unknown(),
161
- widgets: z.record(z.any()).optional(),
165
+ widgets: z.record(z.string(), z.any()).optional(),
162
166
  defaultSchema: Schema,
163
167
  }),
164
168
  icon: z.string().optional(),
@@ -170,7 +174,7 @@ export const CommonOptions = z.object({ font: Font.optional() }).passthrough();
170
174
  const CommonProps = z.object({
171
175
  template: Template,
172
176
  options: CommonOptions.optional(),
173
- plugins: z.record(Plugin).optional(),
177
+ plugins: z.record(z.string(), Plugin).optional(),
174
178
  });
175
179
 
176
180
  // -------------------generate-------------------
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const PDFME_VERSION = '5.4.6';
1
+ export const PDFME_VERSION = '5.4.7';