@pdfme/generator 5.3.8-dev.6 → 5.3.8-dev.61
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/cjs/__tests__/generate.test.js +15 -15
- package/dist/cjs/__tests__/generate.test.js.map +1 -1
- package/dist/cjs/__tests__/integration1.test.js +7 -7
- package/dist/cjs/__tests__/integration1.test.js.map +1 -1
- package/dist/cjs/__tests__/integration2.test.js +7 -7
- package/dist/cjs/__tests__/integration2.test.js.map +1 -1
- package/dist/cjs/__tests__/integration3.test.js +7 -7
- package/dist/cjs/__tests__/integration3.test.js.map +1 -1
- package/dist/cjs/__tests__/integration4.test.js +7 -7
- package/dist/cjs/__tests__/integration4.test.js.map +1 -1
- package/dist/cjs/__tests__/integration5.test.js +7 -7
- package/dist/cjs/__tests__/integration5.test.js.map +1 -1
- package/dist/cjs/src/helper.js.map +1 -1
- package/dist/cjs/src/index.js +2 -2
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/esm/__tests__/generate.test.js +2 -2
- package/dist/esm/__tests__/generate.test.js.map +1 -1
- package/dist/esm/__tests__/integration1.test.js +3 -3
- package/dist/esm/__tests__/integration1.test.js.map +1 -1
- package/dist/esm/__tests__/integration2.test.js +3 -3
- package/dist/esm/__tests__/integration2.test.js.map +1 -1
- package/dist/esm/__tests__/integration3.test.js +3 -3
- package/dist/esm/__tests__/integration3.test.js.map +1 -1
- package/dist/esm/__tests__/integration4.test.js +3 -3
- package/dist/esm/__tests__/integration4.test.js.map +1 -1
- package/dist/esm/__tests__/integration5.test.js +3 -3
- package/dist/esm/__tests__/integration5.test.js.map +1 -1
- package/dist/esm/src/helper.js.map +1 -1
- package/dist/esm/src/index.js +1 -1
- package/dist/esm/src/index.js.map +1 -1
- package/dist/node/__tests__/generate.test.js +15 -15
- package/dist/node/__tests__/generate.test.js.map +1 -1
- package/dist/node/__tests__/integration1.test.js +7 -7
- package/dist/node/__tests__/integration1.test.js.map +1 -1
- package/dist/node/__tests__/integration2.test.js +7 -7
- package/dist/node/__tests__/integration2.test.js.map +1 -1
- package/dist/node/__tests__/integration3.test.js +7 -7
- package/dist/node/__tests__/integration3.test.js.map +1 -1
- package/dist/node/__tests__/integration4.test.js +7 -7
- package/dist/node/__tests__/integration4.test.js.map +1 -1
- package/dist/node/__tests__/integration5.test.js +7 -7
- package/dist/node/__tests__/integration5.test.js.map +1 -1
- package/dist/node/src/helper.js.map +1 -1
- package/dist/node/src/index.js +2 -2
- package/dist/node/src/index.js.map +1 -1
- package/dist/types/src/helper.d.ts +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/eslint.config.mjs +22 -0
- package/package.json +3 -4
- package/src/generate.ts +1 -1
- package/src/helper.ts +16 -13
- package/src/index.ts +1 -1
- package/tsconfig.esm.json +2 -1
- package/.eslintrc.cjs +0 -3
@@ -1,2 +1,2 @@
|
|
1
|
-
import generate from './generate';
|
1
|
+
import generate from './generate.js';
|
2
2
|
export { generate };
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { fileURLToPath } from 'url';
|
2
|
+
import { dirname, resolve } from 'path';
|
3
|
+
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
5
|
+
const __dirname = dirname(__filename);
|
6
|
+
|
7
|
+
// Import the root config
|
8
|
+
const rootConfigPath = resolve(__dirname, '../../eslint.config.mjs');
|
9
|
+
const rootConfig = await import(rootConfigPath);
|
10
|
+
|
11
|
+
export default [
|
12
|
+
...rootConfig.default,
|
13
|
+
{
|
14
|
+
files: ['src/**/*.ts'],
|
15
|
+
languageOptions: {
|
16
|
+
parserOptions: {
|
17
|
+
project: ['./tsconfig.esm.json'],
|
18
|
+
tsconfigRootDir: __dirname,
|
19
|
+
},
|
20
|
+
},
|
21
|
+
},
|
22
|
+
];
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pdfme/generator",
|
3
|
-
"version": "5.3.8-dev.
|
3
|
+
"version": "5.3.8-dev.61",
|
4
4
|
"sideEffects": false,
|
5
5
|
"author": "hand-dot",
|
6
6
|
"license": "MIT",
|
@@ -41,7 +41,7 @@
|
|
41
41
|
"build:esm": "tsc -p tsconfig.esm.json",
|
42
42
|
"build:node": "tsc -p tsconfig.node.json",
|
43
43
|
"clean": "rimraf dist",
|
44
|
-
"lint": "eslint --ext .ts src",
|
44
|
+
"lint": "eslint --ext .ts src --config eslint.config.mjs --no-error-on-unmatched-pattern",
|
45
45
|
"test": "jest",
|
46
46
|
"test:update-snapshots": "jest --updateSnapshot",
|
47
47
|
"prune": "ts-prune src",
|
@@ -49,7 +49,6 @@
|
|
49
49
|
},
|
50
50
|
"dependencies": {
|
51
51
|
"@pdfme/pdf-lib": "*",
|
52
|
-
"atob": "^2.1.2",
|
53
52
|
"fontkit": "^2.0.2"
|
54
53
|
},
|
55
54
|
"devDependencies": {
|
@@ -84,7 +83,7 @@
|
|
84
83
|
"tsconfig": "tsconfig.esm.json"
|
85
84
|
}
|
86
85
|
],
|
87
|
-
"^.+\\.css$": "<rootDir>/__tests__/cssTransform.
|
86
|
+
"^.+\\.css$": "<rootDir>/__tests__/cssTransform.cjs"
|
88
87
|
},
|
89
88
|
"testMatch": [
|
90
89
|
"**/*.test.ts"
|
package/src/generate.ts
CHANGED
@@ -26,7 +26,7 @@ const generate = async (props: GenerateProps) => {
|
|
26
26
|
|
27
27
|
if (inputs.length === 0) {
|
28
28
|
throw new Error(
|
29
|
-
'[@pdfme/generator] inputs should not be empty, pass at least an empty object in the array'
|
29
|
+
'[@pdfme/generator] inputs should not be empty, pass at least an empty object in the array',
|
30
30
|
);
|
31
31
|
}
|
32
32
|
|
package/src/helper.ts
CHANGED
@@ -13,7 +13,7 @@ import {
|
|
13
13
|
import { builtInPlugins } from '@pdfme/schemas';
|
14
14
|
import { PDFPage, PDFDocument, PDFEmbeddedPage, TransformationMatrix } from '@pdfme/pdf-lib';
|
15
15
|
import { TOOL_NAME } from './constants.js';
|
16
|
-
import type { EmbedPdfBox } from './types';
|
16
|
+
import type { EmbedPdfBox } from './types.js';
|
17
17
|
|
18
18
|
export const getEmbedPdfPages = async (arg: { template: Template; pdfDoc: PDFDocument }) => {
|
19
19
|
const {
|
@@ -51,7 +51,7 @@ export const getEmbedPdfPages = async (arg: { template: Template; pdfDoc: PDFDoc
|
|
51
51
|
return { left: x, bottom: y, right: width, top: height + y };
|
52
52
|
});
|
53
53
|
const transformationMatrices = embedPdfPages.map(
|
54
|
-
() => [1, 0, 0, 1, 0, 0] as TransformationMatrix
|
54
|
+
() => [1, 0, 0, 1, 0, 0] as TransformationMatrix,
|
55
55
|
);
|
56
56
|
basePages = await pdfDoc.embedPages(embedPdfPages, boundingBoxes, transformationMatrices);
|
57
57
|
}
|
@@ -63,10 +63,10 @@ export const validateRequiredFields = (template: Template, inputs: Record<string
|
|
63
63
|
schemaPage.forEach((schema) => {
|
64
64
|
if (schema.required && !schema.readOnly && !inputs.some((input) => input[schema.name])) {
|
65
65
|
throw new Error(
|
66
|
-
`[@pdfme/generator] input for '${schema.name}' is required to generate this PDF
|
66
|
+
`[@pdfme/generator] input for '${schema.name}' is required to generate this PDF`,
|
67
67
|
);
|
68
68
|
}
|
69
|
-
})
|
69
|
+
}),
|
70
70
|
);
|
71
71
|
};
|
72
72
|
|
@@ -89,19 +89,22 @@ export const preprocessing = async (arg: { template: Template; userPlugins: Plug
|
|
89
89
|
new Set(
|
90
90
|
schemas
|
91
91
|
.flatMap((schemaPage) => schemaPage.map((schema) => schema.type))
|
92
|
-
.concat(staticSchema.map((schema) => schema.type))
|
93
|
-
)
|
92
|
+
.concat(staticSchema.map((schema) => schema.type)),
|
93
|
+
),
|
94
94
|
);
|
95
95
|
|
96
|
-
const renderObj = schemaTypes.reduce(
|
97
|
-
|
96
|
+
const renderObj = schemaTypes.reduce(
|
97
|
+
(acc, type) => {
|
98
|
+
const render = pluginValues.find((pv) => pv.propPanel.defaultSchema.type === type);
|
98
99
|
|
99
|
-
|
100
|
-
|
100
|
+
if (!render) {
|
101
|
+
throw new Error(`[@pdfme/generator] Renderer for type ${type} not found.
|
101
102
|
Check this document: https://pdfme.com/docs/custom-schemas`);
|
102
|
-
|
103
|
-
|
104
|
-
|
103
|
+
}
|
104
|
+
return { ...acc, [type]: render.pdf };
|
105
|
+
},
|
106
|
+
{} as Record<string, (arg: PDFRenderProps<Schema>) => Promise<void> | void>,
|
107
|
+
);
|
105
108
|
|
106
109
|
return { pdfDoc, renderObj };
|
107
110
|
};
|
package/src/index.ts
CHANGED
package/tsconfig.esm.json
CHANGED
package/.eslintrc.cjs
DELETED