@pdfme/schemas 6.0.6-dev.11 → 6.0.6-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 +24 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -457,7 +457,30 @@ var imageSize = (imgBuffer) => {
|
|
|
457
457
|
};
|
|
458
458
|
//#endregion
|
|
459
459
|
//#region src/graphics/image.ts
|
|
460
|
-
|
|
460
|
+
/**
|
|
461
|
+
* Build a short fingerprint for a potentially-large base64 image string.
|
|
462
|
+
* Previously `${schema.type}${input}` was used, pinning multi-MB base64
|
|
463
|
+
* strings in the cache Map forever — every unique image input created a
|
|
464
|
+
* permanent Map key whose byte length matched the image itself.
|
|
465
|
+
*
|
|
466
|
+
* The fingerprint is an FNV-1a 32-bit hash over the full input, combined
|
|
467
|
+
* with the schema type and input byte length. An earlier revision sampled
|
|
468
|
+
* three 16-char regions (first + middle + last) instead of hashing, but
|
|
469
|
+
* the first-16 slice is a constant data-URI prefix for any image of the
|
|
470
|
+
* same MIME type (`data:image/png;b…` / `data:image/jpeg…`), contributing
|
|
471
|
+
* no entropy. Hashing every byte removes that weakness at the same O(n)
|
|
472
|
+
* cost, without retaining any slice of the input as a Map key. Keys stay
|
|
473
|
+
* well under ~40 chars regardless of input size.
|
|
474
|
+
*/
|
|
475
|
+
var getCacheKey = (schema, input) => {
|
|
476
|
+
let hash = 2166136261;
|
|
477
|
+
for (let i = 0; i < input.length; i++) {
|
|
478
|
+
hash ^= input.charCodeAt(i);
|
|
479
|
+
hash = Math.imul(hash, 16777619);
|
|
480
|
+
}
|
|
481
|
+
const hex = (hash >>> 0).toString(16).padStart(8, "0");
|
|
482
|
+
return `${schema.type}:${input.length}:${hex}`;
|
|
483
|
+
};
|
|
461
484
|
var fullSize$1 = {
|
|
462
485
|
width: "100%",
|
|
463
486
|
height: "100%"
|