@pdfme/common 6.1.12 → 6.1.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 +19 -12
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +79 -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,6 +100,7 @@ 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",
|
|
@@ -852,13 +853,14 @@ var evaluateAST = (node, context) => {
|
|
|
852
853
|
const callNode = node;
|
|
853
854
|
const callee = evaluateAST(callNode.callee, context);
|
|
854
855
|
const args = callNode.arguments.map((argNode) => evaluateAST(argNode, context));
|
|
855
|
-
if (typeof callee === "function")
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
856
|
+
if (typeof callee === "function") {
|
|
857
|
+
if (callNode.callee.type === "MemberExpression") {
|
|
858
|
+
const memberExpr = callNode.callee;
|
|
859
|
+
const obj = evaluateAST(memberExpr.object, context);
|
|
860
|
+
if (obj !== null && (typeof obj === "object" || typeof obj === "number" || typeof obj === "string" || typeof obj === "boolean")) return callee.call(obj, ...args);
|
|
861
|
+
else throw new Error("Invalid object in member function call");
|
|
862
|
+
} else return callee(...args);
|
|
863
|
+
} else throw new Error("Attempted to call a non-function");
|
|
862
864
|
}
|
|
863
865
|
case "ArrowFunctionExpression": {
|
|
864
866
|
const arrowFuncNode = node;
|
|
@@ -885,7 +887,8 @@ var evaluateAST = (node, context) => {
|
|
|
885
887
|
if (typeof evaluatedKey !== "string" && typeof evaluatedKey !== "number") throw new Error("Object property keys must be strings or numbers");
|
|
886
888
|
key = String(evaluatedKey);
|
|
887
889
|
}
|
|
888
|
-
|
|
890
|
+
const value = evaluateAST(propNode.value, context);
|
|
891
|
+
objResult[key] = value;
|
|
889
892
|
});
|
|
890
893
|
return objResult;
|
|
891
894
|
}
|
|
@@ -931,7 +934,10 @@ var evaluatePlaceholders = (arg) => {
|
|
|
931
934
|
resultContent += content.slice(startIndex, endIndex);
|
|
932
935
|
}
|
|
933
936
|
index = endIndex;
|
|
934
|
-
} else
|
|
937
|
+
} else {
|
|
938
|
+
resultContent += content.slice(startIndex);
|
|
939
|
+
break;
|
|
940
|
+
}
|
|
935
941
|
}
|
|
936
942
|
return resultContent;
|
|
937
943
|
};
|
|
@@ -1007,7 +1013,7 @@ function normalizePageSchemas(pageSchemas, paddingTop) {
|
|
|
1007
1013
|
function placeUnitsOnPages(schema, dynamicLayout, startGlobalY, contentHeight, paddingTop, pages) {
|
|
1008
1014
|
const dynamicHeights = dynamicLayout.heights;
|
|
1009
1015
|
let currentUnitIndex = 0;
|
|
1010
|
-
let currentPageIndex = Math.floor(startGlobalY / contentHeight);
|
|
1016
|
+
let currentPageIndex = Math.max(0, Math.floor(startGlobalY / contentHeight));
|
|
1011
1017
|
let currentYInPage = startGlobalY % contentHeight;
|
|
1012
1018
|
if (currentYInPage < 0) currentYInPage = 0;
|
|
1013
1019
|
let actualGlobalEndY = 0;
|
|
@@ -1131,7 +1137,8 @@ var getDynamicTemplate = async (arg) => {
|
|
|
1131
1137
|
for (let i = 0; i < items.length; i += PARALLEL_LIMIT) {
|
|
1132
1138
|
const chunk = items.slice(i, i + PARALLEL_LIMIT);
|
|
1133
1139
|
const chunkResults = await Promise.all(chunk.map((item) => {
|
|
1134
|
-
|
|
1140
|
+
const value = getSchemaValue(item.schema, input, template.schemas);
|
|
1141
|
+
return getDynamicHeights(value, {
|
|
1135
1142
|
schema: item.schema,
|
|
1136
1143
|
basePdf,
|
|
1137
1144
|
options,
|