@pdfme/common 6.1.12 → 6.1.13-dev.13
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/index.js +20 -12
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +86 -72
- package/dist/version.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Buffer } from "buffer";
|
|
|
3
3
|
import { PDFName } from "@pdfme/pdf-lib";
|
|
4
4
|
import * as acorn from "acorn";
|
|
5
5
|
//#region src/version.ts
|
|
6
|
-
var PDFME_VERSION = "6.1.
|
|
6
|
+
var PDFME_VERSION = "6.1.13";
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/pageSize.ts
|
|
9
9
|
var PAGE_SIZE_PRESETS = {
|
|
@@ -100,10 +100,12 @@ var DEFAULT_FONT_VALUE = "data:font/ttf;base64,AAEAAAASAQAABAAgR0RFRnC0bdgAAZ5sA
|
|
|
100
100
|
var Lang = z.enum([
|
|
101
101
|
"en",
|
|
102
102
|
"zh",
|
|
103
|
+
"zh-TW",
|
|
103
104
|
"ja",
|
|
104
105
|
"ko",
|
|
105
106
|
"ar",
|
|
106
107
|
"th",
|
|
108
|
+
"tr",
|
|
107
109
|
"pl",
|
|
108
110
|
"it",
|
|
109
111
|
"de",
|
|
@@ -852,13 +854,14 @@ var evaluateAST = (node, context) => {
|
|
|
852
854
|
const callNode = node;
|
|
853
855
|
const callee = evaluateAST(callNode.callee, context);
|
|
854
856
|
const args = callNode.arguments.map((argNode) => evaluateAST(argNode, context));
|
|
855
|
-
if (typeof callee === "function")
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
857
|
+
if (typeof callee === "function") {
|
|
858
|
+
if (callNode.callee.type === "MemberExpression") {
|
|
859
|
+
const memberExpr = callNode.callee;
|
|
860
|
+
const obj = evaluateAST(memberExpr.object, context);
|
|
861
|
+
if (obj !== null && (typeof obj === "object" || typeof obj === "number" || typeof obj === "string" || typeof obj === "boolean")) return callee.call(obj, ...args);
|
|
862
|
+
else throw new Error("Invalid object in member function call");
|
|
863
|
+
} else return callee(...args);
|
|
864
|
+
} else throw new Error("Attempted to call a non-function");
|
|
862
865
|
}
|
|
863
866
|
case "ArrowFunctionExpression": {
|
|
864
867
|
const arrowFuncNode = node;
|
|
@@ -885,7 +888,8 @@ var evaluateAST = (node, context) => {
|
|
|
885
888
|
if (typeof evaluatedKey !== "string" && typeof evaluatedKey !== "number") throw new Error("Object property keys must be strings or numbers");
|
|
886
889
|
key = String(evaluatedKey);
|
|
887
890
|
}
|
|
888
|
-
|
|
891
|
+
const value = evaluateAST(propNode.value, context);
|
|
892
|
+
objResult[key] = value;
|
|
889
893
|
});
|
|
890
894
|
return objResult;
|
|
891
895
|
}
|
|
@@ -931,7 +935,10 @@ var evaluatePlaceholders = (arg) => {
|
|
|
931
935
|
resultContent += content.slice(startIndex, endIndex);
|
|
932
936
|
}
|
|
933
937
|
index = endIndex;
|
|
934
|
-
} else
|
|
938
|
+
} else {
|
|
939
|
+
resultContent += content.slice(startIndex);
|
|
940
|
+
break;
|
|
941
|
+
}
|
|
935
942
|
}
|
|
936
943
|
return resultContent;
|
|
937
944
|
};
|
|
@@ -1007,7 +1014,7 @@ function normalizePageSchemas(pageSchemas, paddingTop) {
|
|
|
1007
1014
|
function placeUnitsOnPages(schema, dynamicLayout, startGlobalY, contentHeight, paddingTop, pages) {
|
|
1008
1015
|
const dynamicHeights = dynamicLayout.heights;
|
|
1009
1016
|
let currentUnitIndex = 0;
|
|
1010
|
-
let currentPageIndex = Math.floor(startGlobalY / contentHeight);
|
|
1017
|
+
let currentPageIndex = Math.max(0, Math.floor(startGlobalY / contentHeight));
|
|
1011
1018
|
let currentYInPage = startGlobalY % contentHeight;
|
|
1012
1019
|
if (currentYInPage < 0) currentYInPage = 0;
|
|
1013
1020
|
let actualGlobalEndY = 0;
|
|
@@ -1131,7 +1138,8 @@ var getDynamicTemplate = async (arg) => {
|
|
|
1131
1138
|
for (let i = 0; i < items.length; i += PARALLEL_LIMIT) {
|
|
1132
1139
|
const chunk = items.slice(i, i + PARALLEL_LIMIT);
|
|
1133
1140
|
const chunkResults = await Promise.all(chunk.map((item) => {
|
|
1134
|
-
|
|
1141
|
+
const value = getSchemaValue(item.schema, input, template.schemas);
|
|
1142
|
+
return getDynamicHeights(value, {
|
|
1135
1143
|
schema: item.schema,
|
|
1136
1144
|
basePdf,
|
|
1137
1145
|
options,
|