@embedpdf/models 1.0.16 → 1.0.17
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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +83 -2
- package/dist/index.js.map +1 -1
- package/dist/pdf.d.ts +161 -18
- package/dist/task.d.ts +21 -1
- package/dist/uuid.d.ts +22 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -469,6 +469,7 @@ class Task {
|
|
|
469
469
|
this.resolvedCallbacks = [];
|
|
470
470
|
this.rejectedCallbacks = [];
|
|
471
471
|
this._promise = null;
|
|
472
|
+
this.progressCbs = [];
|
|
472
473
|
}
|
|
473
474
|
/**
|
|
474
475
|
* Convert task to promise
|
|
@@ -598,6 +599,20 @@ class Task {
|
|
|
598
599
|
this.reject(error.reason);
|
|
599
600
|
}
|
|
600
601
|
}
|
|
602
|
+
/**
|
|
603
|
+
* add a progress callback
|
|
604
|
+
* @param cb - progress callback
|
|
605
|
+
*/
|
|
606
|
+
onProgress(cb) {
|
|
607
|
+
this.progressCbs.push(cb);
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* call progress callback
|
|
611
|
+
* @param p - progress value
|
|
612
|
+
*/
|
|
613
|
+
progress(p) {
|
|
614
|
+
for (const cb of this.progressCbs) cb(p);
|
|
615
|
+
}
|
|
601
616
|
/**
|
|
602
617
|
* Static method to wait for all tasks to resolve
|
|
603
618
|
* Returns a new task that resolves with an array of all results
|
|
@@ -991,16 +1006,47 @@ var PdfAnnotationState = /* @__PURE__ */ ((PdfAnnotationState2) => {
|
|
|
991
1006
|
PdfAnnotationState2["Unmarked"] = "Unmarked";
|
|
992
1007
|
PdfAnnotationState2["Accepted"] = "Accepted";
|
|
993
1008
|
PdfAnnotationState2["Rejected"] = "Rejected";
|
|
994
|
-
PdfAnnotationState2["
|
|
1009
|
+
PdfAnnotationState2["Completed"] = "Completed";
|
|
995
1010
|
PdfAnnotationState2["Cancelled"] = "Cancelled";
|
|
996
1011
|
PdfAnnotationState2["None"] = "None";
|
|
997
1012
|
return PdfAnnotationState2;
|
|
998
1013
|
})(PdfAnnotationState || {});
|
|
999
1014
|
var PdfAnnotationStateModel = /* @__PURE__ */ ((PdfAnnotationStateModel2) => {
|
|
1000
1015
|
PdfAnnotationStateModel2["Marked"] = "Marked";
|
|
1001
|
-
PdfAnnotationStateModel2["
|
|
1016
|
+
PdfAnnotationStateModel2["Review"] = "Review";
|
|
1002
1017
|
return PdfAnnotationStateModel2;
|
|
1003
1018
|
})(PdfAnnotationStateModel || {});
|
|
1019
|
+
var PdfAnnotationIcon = /* @__PURE__ */ ((PdfAnnotationIcon2) => {
|
|
1020
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Unknown"] = -1] = "Unknown";
|
|
1021
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Comment"] = 0] = "Comment";
|
|
1022
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Key"] = 1] = "Key";
|
|
1023
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Note"] = 2] = "Note";
|
|
1024
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Help"] = 3] = "Help";
|
|
1025
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["NewParagraph"] = 4] = "NewParagraph";
|
|
1026
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Paragraph"] = 5] = "Paragraph";
|
|
1027
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Insert"] = 6] = "Insert";
|
|
1028
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Graph"] = 7] = "Graph";
|
|
1029
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["PushPin"] = 8] = "PushPin";
|
|
1030
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Paperclip"] = 9] = "Paperclip";
|
|
1031
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Tag"] = 10] = "Tag";
|
|
1032
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Speaker"] = 11] = "Speaker";
|
|
1033
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Mic"] = 12] = "Mic";
|
|
1034
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Approved"] = 13] = "Approved";
|
|
1035
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Experimental"] = 14] = "Experimental";
|
|
1036
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["NotApproved"] = 15] = "NotApproved";
|
|
1037
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["AsIs"] = 16] = "AsIs";
|
|
1038
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Expired"] = 17] = "Expired";
|
|
1039
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["NotForPublicRelease"] = 18] = "NotForPublicRelease";
|
|
1040
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Confidential"] = 19] = "Confidential";
|
|
1041
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Final"] = 20] = "Final";
|
|
1042
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Sold"] = 21] = "Sold";
|
|
1043
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Departmental"] = 22] = "Departmental";
|
|
1044
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["ForComment"] = 23] = "ForComment";
|
|
1045
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["TopSecret"] = 24] = "TopSecret";
|
|
1046
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["Draft"] = 25] = "Draft";
|
|
1047
|
+
PdfAnnotationIcon2[PdfAnnotationIcon2["ForPublicRelease"] = 26] = "ForPublicRelease";
|
|
1048
|
+
return PdfAnnotationIcon2;
|
|
1049
|
+
})(PdfAnnotationIcon || {});
|
|
1004
1050
|
var PdfAnnotationLineEnding = /* @__PURE__ */ ((PdfAnnotationLineEnding2) => {
|
|
1005
1051
|
PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["None"] = 0] = "None";
|
|
1006
1052
|
PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Square"] = 1] = "Square";
|
|
@@ -1235,6 +1281,7 @@ var PdfErrorCode = /* @__PURE__ */ ((PdfErrorCode2) => {
|
|
|
1235
1281
|
PdfErrorCode2[PdfErrorCode2["CantSelectText"] = 26] = "CantSelectText";
|
|
1236
1282
|
PdfErrorCode2[PdfErrorCode2["CantSelectOption"] = 27] = "CantSelectOption";
|
|
1237
1283
|
PdfErrorCode2[PdfErrorCode2["CantCheckField"] = 28] = "CantCheckField";
|
|
1284
|
+
PdfErrorCode2[PdfErrorCode2["CantSetAnnotString"] = 29] = "CantSetAnnotString";
|
|
1238
1285
|
return PdfErrorCode2;
|
|
1239
1286
|
})(PdfErrorCode || {});
|
|
1240
1287
|
class PdfTaskHelper {
|
|
@@ -1626,6 +1673,37 @@ const blendModeSelectOptions = BLEND_MODE_INFOS.map((info) => ({
|
|
|
1626
1673
|
function uiBlendModeDisplay(value) {
|
|
1627
1674
|
return value === MixedBlendMode ? "(mixed)" : blendModeLabel(value);
|
|
1628
1675
|
}
|
|
1676
|
+
const V4_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
1677
|
+
function isUuidV4(str) {
|
|
1678
|
+
return V4_REGEX.test(str);
|
|
1679
|
+
}
|
|
1680
|
+
function getRandomBytes(len) {
|
|
1681
|
+
var _a;
|
|
1682
|
+
if (typeof ((_a = globalThis.crypto) == null ? void 0 : _a.getRandomValues) === "function") {
|
|
1683
|
+
return globalThis.crypto.getRandomValues(new Uint8Array(len));
|
|
1684
|
+
}
|
|
1685
|
+
if (typeof require === "function") {
|
|
1686
|
+
try {
|
|
1687
|
+
const { randomBytes } = require("crypto");
|
|
1688
|
+
return randomBytes(len);
|
|
1689
|
+
} catch {
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
const bytes = new Uint8Array(len);
|
|
1693
|
+
for (let i = 0; i < len; i++) bytes[i] = Math.floor(Math.random() * 256);
|
|
1694
|
+
return bytes;
|
|
1695
|
+
}
|
|
1696
|
+
function uuidV4() {
|
|
1697
|
+
var _a;
|
|
1698
|
+
if (typeof ((_a = globalThis.crypto) == null ? void 0 : _a.randomUUID) === "function") {
|
|
1699
|
+
return globalThis.crypto.randomUUID();
|
|
1700
|
+
}
|
|
1701
|
+
const bytes = getRandomBytes(16);
|
|
1702
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
1703
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
1704
|
+
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
1705
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
1706
|
+
}
|
|
1629
1707
|
function ignore() {
|
|
1630
1708
|
}
|
|
1631
1709
|
export {
|
|
@@ -1646,6 +1724,7 @@ export {
|
|
|
1646
1724
|
PdfAnnotationColorType,
|
|
1647
1725
|
PdfAnnotationFlagName,
|
|
1648
1726
|
PdfAnnotationFlags,
|
|
1727
|
+
PdfAnnotationIcon,
|
|
1649
1728
|
PdfAnnotationLineEnding,
|
|
1650
1729
|
PdfAnnotationObjectStatus,
|
|
1651
1730
|
PdfAnnotationState,
|
|
@@ -1702,6 +1781,7 @@ export {
|
|
|
1702
1781
|
getStandardFontDescriptor,
|
|
1703
1782
|
getTextAlignmentInfo,
|
|
1704
1783
|
ignore,
|
|
1784
|
+
isUuidV4,
|
|
1705
1785
|
makeMatrix,
|
|
1706
1786
|
makeStandardFont,
|
|
1707
1787
|
namesToFlags,
|
|
@@ -1744,6 +1824,7 @@ export {
|
|
|
1744
1824
|
transformSize,
|
|
1745
1825
|
uiBlendModeDisplay,
|
|
1746
1826
|
unionFlags,
|
|
1827
|
+
uuidV4,
|
|
1747
1828
|
webAlphaColorToPdfAlphaColor,
|
|
1748
1829
|
webColorToPdfColor,
|
|
1749
1830
|
webOpacityToPdfAlpha
|