@pdfme/common 5.4.6-dev.25 → 5.4.6-dev.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/common",
3
- "version": "5.4.6-dev.25",
3
+ "version": "5.4.6-dev.29",
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
@@ -131,7 +131,7 @@ export const CustomPdf = z.union([z.string(), ArrayBufferSchema, Uint8ArraySchem
131
131
  export const BasePdf = z.union([CustomPdf, BlankPdf]);
132
132
 
133
133
  // Legacy keyed structure for BC - we convert to SchemaPageArray on import
134
- export const LegacySchemaPageArray = z.array(z.record(Schema));
134
+ export const LegacySchemaPageArray = z.array(z.record(z.string(), Schema));
135
135
  export const SchemaPageArray = z.array(z.array(Schema));
136
136
 
137
137
  export const Template = z
@@ -142,9 +142,10 @@ export const Template = z
142
142
  })
143
143
  .passthrough();
144
144
 
145
- export const Inputs = z.array(z.record(z.any())).min(1);
145
+ export const Inputs = z.array(z.record(z.string(), z.any())).min(1);
146
146
 
147
147
  export const Font = z.record(
148
+ z.string(),
148
149
  z.object({
149
150
  data: z.union([z.string(), ArrayBufferSchema, Uint8ArraySchema]),
150
151
  fallback: z.boolean().optional(),
@@ -154,11 +155,11 @@ export const Font = z.record(
154
155
 
155
156
  export const Plugin = z
156
157
  .object({
157
- ui: z.function().args(z.any()).returns(z.any()),
158
- pdf: z.function().args(z.any()).returns(z.any()),
158
+ ui: z.any(),
159
+ pdf: z.any(),
159
160
  propPanel: z.object({
160
161
  schema: z.unknown(),
161
- widgets: z.record(z.any()).optional(),
162
+ widgets: z.record(z.string(), z.any()).optional(),
162
163
  defaultSchema: Schema,
163
164
  }),
164
165
  icon: z.string().optional(),
@@ -170,7 +171,7 @@ export const CommonOptions = z.object({ font: Font.optional() }).passthrough();
170
171
  const CommonProps = z.object({
171
172
  template: Template,
172
173
  options: CommonOptions.optional(),
173
- plugins: z.record(Plugin).optional(),
174
+ plugins: z.record(z.string(), Plugin).optional(),
174
175
  });
175
176
 
176
177
  // -------------------generate-------------------