@chialab/pdfjs-lib 1.0.0-alpha.29 → 1.0.0-alpha.30
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/browser/{chunk-W35PJZ6L.js → chunk-R7G44NYV.js} +521 -3
- package/dist/browser/index.js +2329 -969
- package/dist/browser/openjpeg-Q27OVS4T.js +9 -0
- package/dist/browser/worker.js +594 -609
- package/dist/index.d.ts +1 -1
- package/dist/lib/TextLayer.d.ts +4 -0
- package/dist/node/{NodeUtils-ZPPZPJWD.js → NodeUtils-PVXQMWFJ.js} +2 -2
- package/dist/node/{chunk-GWGW2EKY.js → chunk-4Y7OZIIX.js} +520 -2
- package/dist/node/{chunk-D4U3W2CD.js → chunk-O74KGUUC.js} +451 -1
- package/dist/node/{chunk-FHASHZBJ.js → chunk-T2JWSGAF.js} +2 -2
- package/dist/node/index.js +1896 -972
- package/dist/node/openjpeg-QFJSFVSJ.js +9 -0
- package/dist/node/worker.js +595 -610
- package/dist/pdf.js/external/openjpeg/openjpeg.d.ts +1 -1
- package/dist/pdf.js/src/core/fonts.d.ts +7 -1
- package/dist/pdf.js/src/display/annotation_layer.d.ts +28 -6
- package/dist/pdf.js/src/display/annotation_storage.d.ts +2 -0
- package/dist/pdf.js/src/display/api.d.ts +13 -7
- package/dist/pdf.js/src/display/canvas.d.ts +1 -1
- package/dist/pdf.js/src/display/canvas_dependency_tracker.d.ts +36 -20
- package/dist/pdf.js/src/display/display_utils.d.ts +22 -0
- package/dist/pdf.js/src/display/editor/annotation_editor_layer.d.ts +4 -2
- package/dist/pdf.js/src/display/editor/comment.d.ts +20 -5
- package/dist/pdf.js/src/display/editor/drawers/freedraw.d.ts +1 -0
- package/dist/pdf.js/src/display/editor/drawers/highlight.d.ts +2 -1
- package/dist/pdf.js/src/display/editor/editor.d.ts +67 -15
- package/dist/pdf.js/src/display/editor/freetext.d.ts +1 -1
- package/dist/pdf.js/src/display/editor/highlight.d.ts +3 -1
- package/dist/pdf.js/src/display/editor/ink.d.ts +2 -1
- package/dist/pdf.js/src/display/editor/signature.d.ts +0 -5
- package/dist/pdf.js/src/display/editor/toolbar.d.ts +3 -1
- package/dist/pdf.js/src/display/editor/tools.d.ts +21 -3
- package/dist/pdf.js/src/display/font_loader.d.ts +27 -1
- package/dist/pdf.js/src/display/pattern_helper.d.ts +2 -2
- package/dist/pdf.js/src/pdf.d.ts +5 -1
- package/dist/pdf.js/src/shared/obj-bin-transform.d.ts +64 -0
- package/dist/pdf.js/web/comment_manager.d.ts +20 -0
- package/package.json +1 -1
- package/dist/browser/openjpeg-QLA762TL.js +0 -9
- package/dist/node/openjpeg-TRZ4ANDN.js +0 -9
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
unreachable,
|
|
8
8
|
updateUrlHash,
|
|
9
9
|
warn
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-T2JWSGAF.js";
|
|
11
11
|
import {
|
|
12
12
|
__privateAdd,
|
|
13
13
|
__privateGet,
|
|
@@ -25,6 +25,270 @@ import {
|
|
|
25
25
|
Path2D as NodePath2D
|
|
26
26
|
} from "skia-canvas";
|
|
27
27
|
|
|
28
|
+
// src/pdf.js/src/display/xfa_text.js
|
|
29
|
+
var XfaText = class _XfaText {
|
|
30
|
+
/**
|
|
31
|
+
* Walk an XFA tree and create an array of text nodes that is compatible
|
|
32
|
+
* with a regular PDFs TextContent. Currently, only TextItem.str is supported,
|
|
33
|
+
* all other fields and styles haven't been implemented.
|
|
34
|
+
*
|
|
35
|
+
* @param {Object} xfa - An XFA fake DOM object.
|
|
36
|
+
*
|
|
37
|
+
* @returns {TextContent}
|
|
38
|
+
*/
|
|
39
|
+
static textContent(xfa) {
|
|
40
|
+
const items = [];
|
|
41
|
+
const output = {
|
|
42
|
+
items,
|
|
43
|
+
styles: /* @__PURE__ */ Object.create(null)
|
|
44
|
+
};
|
|
45
|
+
function walk(node) {
|
|
46
|
+
if (!node) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
let str = null;
|
|
50
|
+
const name = node.name;
|
|
51
|
+
if (name === "#text") {
|
|
52
|
+
str = node.value;
|
|
53
|
+
} else if (!_XfaText.shouldBuildText(name)) {
|
|
54
|
+
return;
|
|
55
|
+
} else if (node?.attributes?.textContent) {
|
|
56
|
+
str = node.attributes.textContent;
|
|
57
|
+
} else if (node.value) {
|
|
58
|
+
str = node.value;
|
|
59
|
+
}
|
|
60
|
+
if (str !== null) {
|
|
61
|
+
items.push({
|
|
62
|
+
str
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (!node.children) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
for (const child of node.children) {
|
|
69
|
+
walk(child);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
walk(xfa);
|
|
73
|
+
return output;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @param {string} name - DOM node name. (lower case)
|
|
77
|
+
*
|
|
78
|
+
* @returns {boolean} true if the DOM node should have a corresponding text
|
|
79
|
+
* node.
|
|
80
|
+
*/
|
|
81
|
+
static shouldBuildText(name) {
|
|
82
|
+
return !(name === "textarea" || name === "input" || name === "option" || name === "select");
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// src/pdf.js/src/display/xfa_layer.js
|
|
87
|
+
var XfaLayer = class {
|
|
88
|
+
static setupStorage(html, id, element, storage, intent) {
|
|
89
|
+
const storedData = storage.getValue(id, { value: null });
|
|
90
|
+
switch (element.name) {
|
|
91
|
+
case "textarea":
|
|
92
|
+
if (storedData.value !== null) {
|
|
93
|
+
html.textContent = storedData.value;
|
|
94
|
+
}
|
|
95
|
+
if (intent === "print") {
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
html.addEventListener("input", (event) => {
|
|
99
|
+
storage.setValue(id, { value: event.target.value });
|
|
100
|
+
});
|
|
101
|
+
break;
|
|
102
|
+
case "input":
|
|
103
|
+
if (element.attributes.type === "radio" || element.attributes.type === "checkbox") {
|
|
104
|
+
if (storedData.value === element.attributes.xfaOn) {
|
|
105
|
+
html.setAttribute("checked", true);
|
|
106
|
+
} else if (storedData.value === element.attributes.xfaOff) {
|
|
107
|
+
html.removeAttribute("checked");
|
|
108
|
+
}
|
|
109
|
+
if (intent === "print") {
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
html.addEventListener("change", (event) => {
|
|
113
|
+
storage.setValue(id, {
|
|
114
|
+
value: event.target.checked ? event.target.getAttribute("xfaOn") : event.target.getAttribute("xfaOff")
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
} else {
|
|
118
|
+
if (storedData.value !== null) {
|
|
119
|
+
html.setAttribute("value", storedData.value);
|
|
120
|
+
}
|
|
121
|
+
if (intent === "print") {
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
html.addEventListener("input", (event) => {
|
|
125
|
+
storage.setValue(id, { value: event.target.value });
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
break;
|
|
129
|
+
case "select":
|
|
130
|
+
if (storedData.value !== null) {
|
|
131
|
+
html.setAttribute("value", storedData.value);
|
|
132
|
+
for (const option of element.children) {
|
|
133
|
+
if (option.attributes.value === storedData.value) {
|
|
134
|
+
option.attributes.selected = true;
|
|
135
|
+
} else if (option.attributes.hasOwnProperty("selected")) {
|
|
136
|
+
delete option.attributes.selected;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
html.addEventListener("input", (event) => {
|
|
141
|
+
const options = event.target.options;
|
|
142
|
+
const value = options.selectedIndex === -1 ? "" : options[options.selectedIndex].value;
|
|
143
|
+
storage.setValue(id, { value });
|
|
144
|
+
});
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
static setAttributes({ html, element, storage = null, intent, linkService }) {
|
|
149
|
+
const { attributes } = element;
|
|
150
|
+
const isHTMLAnchorElement = html instanceof HTMLAnchorElement;
|
|
151
|
+
if (attributes.type === "radio") {
|
|
152
|
+
attributes.name = `${attributes.name}-${intent}`;
|
|
153
|
+
}
|
|
154
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
155
|
+
if (value === null || value === void 0) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
switch (key) {
|
|
159
|
+
case "class":
|
|
160
|
+
if (value.length) {
|
|
161
|
+
html.setAttribute(key, value.join(" "));
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
case "dataId":
|
|
165
|
+
break;
|
|
166
|
+
case "id":
|
|
167
|
+
html.setAttribute("data-element-id", value);
|
|
168
|
+
break;
|
|
169
|
+
case "style":
|
|
170
|
+
Object.assign(html.style, value);
|
|
171
|
+
break;
|
|
172
|
+
case "textContent":
|
|
173
|
+
html.textContent = value;
|
|
174
|
+
break;
|
|
175
|
+
default:
|
|
176
|
+
if (!isHTMLAnchorElement || key !== "href" && key !== "newWindow") {
|
|
177
|
+
html.setAttribute(key, value);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (isHTMLAnchorElement) {
|
|
182
|
+
linkService.addLinkAttributes(
|
|
183
|
+
html,
|
|
184
|
+
attributes.href,
|
|
185
|
+
attributes.newWindow
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
if (storage && attributes.dataId) {
|
|
189
|
+
this.setupStorage(html, attributes.dataId, element, storage);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Render the XFA layer.
|
|
194
|
+
*
|
|
195
|
+
* @param {XfaLayerParameters} parameters
|
|
196
|
+
*/
|
|
197
|
+
static render(parameters) {
|
|
198
|
+
const storage = parameters.annotationStorage;
|
|
199
|
+
const linkService = parameters.linkService;
|
|
200
|
+
const root = parameters.xfaHtml;
|
|
201
|
+
const intent = parameters.intent || "display";
|
|
202
|
+
const rootHtml = document.createElement(root.name);
|
|
203
|
+
if (root.attributes) {
|
|
204
|
+
this.setAttributes({
|
|
205
|
+
html: rootHtml,
|
|
206
|
+
element: root,
|
|
207
|
+
intent,
|
|
208
|
+
linkService
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
const isNotForRichText = intent !== "richText";
|
|
212
|
+
const rootDiv = parameters.div;
|
|
213
|
+
rootDiv.append(rootHtml);
|
|
214
|
+
if (parameters.viewport) {
|
|
215
|
+
const transform = `matrix(${parameters.viewport.transform.join(",")})`;
|
|
216
|
+
rootDiv.style.transform = transform;
|
|
217
|
+
}
|
|
218
|
+
if (isNotForRichText) {
|
|
219
|
+
rootDiv.setAttribute("class", "xfaLayer xfaFont");
|
|
220
|
+
}
|
|
221
|
+
const textDivs = [];
|
|
222
|
+
if (root.children.length === 0) {
|
|
223
|
+
if (root.value) {
|
|
224
|
+
const node = document.createTextNode(root.value);
|
|
225
|
+
rootHtml.append(node);
|
|
226
|
+
if (isNotForRichText && XfaText.shouldBuildText(root.name)) {
|
|
227
|
+
textDivs.push(node);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return { textDivs };
|
|
231
|
+
}
|
|
232
|
+
const stack = [[root, -1, rootHtml]];
|
|
233
|
+
while (stack.length > 0) {
|
|
234
|
+
const [parent, i, html] = stack.at(-1);
|
|
235
|
+
if (i + 1 === parent.children.length) {
|
|
236
|
+
stack.pop();
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
const child = parent.children[++stack.at(-1)[1]];
|
|
240
|
+
if (child === null) {
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
const { name } = child;
|
|
244
|
+
if (name === "#text") {
|
|
245
|
+
const node = document.createTextNode(child.value);
|
|
246
|
+
textDivs.push(node);
|
|
247
|
+
html.append(node);
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
const childHtml = child?.attributes?.xmlns ? document.createElementNS(child.attributes.xmlns, name) : document.createElement(name);
|
|
251
|
+
html.append(childHtml);
|
|
252
|
+
if (child.attributes) {
|
|
253
|
+
this.setAttributes({
|
|
254
|
+
html: childHtml,
|
|
255
|
+
element: child,
|
|
256
|
+
storage,
|
|
257
|
+
intent,
|
|
258
|
+
linkService
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
if (child.children?.length > 0) {
|
|
262
|
+
stack.push([child, -1, childHtml]);
|
|
263
|
+
} else if (child.value) {
|
|
264
|
+
const node = document.createTextNode(child.value);
|
|
265
|
+
if (isNotForRichText && XfaText.shouldBuildText(name)) {
|
|
266
|
+
textDivs.push(node);
|
|
267
|
+
}
|
|
268
|
+
childHtml.append(node);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
for (const el of rootDiv.querySelectorAll(
|
|
272
|
+
".xfaNonInteractive input, .xfaNonInteractive textarea"
|
|
273
|
+
)) {
|
|
274
|
+
el.setAttribute("readOnly", true);
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
textDivs
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Update the XFA layer.
|
|
282
|
+
*
|
|
283
|
+
* @param {XfaLayerParameters} parameters
|
|
284
|
+
*/
|
|
285
|
+
static update(parameters) {
|
|
286
|
+
const transform = `matrix(${parameters.viewport.transform.join(",")})`;
|
|
287
|
+
parameters.div.style.transform = transform;
|
|
288
|
+
parameters.div.hidden = false;
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
|
|
28
292
|
// src/pdf.js/src/display/display_utils.js
|
|
29
293
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
30
294
|
var _PixelsPerInch = class _PixelsPerInch {
|
|
@@ -590,6 +854,185 @@ var SupportedImageMimeTypes = [
|
|
|
590
854
|
"image/webp",
|
|
591
855
|
"image/x-icon"
|
|
592
856
|
];
|
|
857
|
+
var ColorScheme = class {
|
|
858
|
+
static get isDarkMode() {
|
|
859
|
+
return shadow(
|
|
860
|
+
this,
|
|
861
|
+
"isDarkMode",
|
|
862
|
+
!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches
|
|
863
|
+
);
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
var CSSConstants = class {
|
|
867
|
+
static get commentForegroundColor() {
|
|
868
|
+
const element = document.createElement("span");
|
|
869
|
+
element.classList.add("comment", "sidebar");
|
|
870
|
+
const { style } = element;
|
|
871
|
+
style.width = style.height = "0";
|
|
872
|
+
style.display = "none";
|
|
873
|
+
style.color = "var(--comment-fg-color)";
|
|
874
|
+
document.body.append(element);
|
|
875
|
+
const { color } = window.getComputedStyle(element);
|
|
876
|
+
element.remove();
|
|
877
|
+
return shadow(this, "commentForegroundColor", getRGB(color));
|
|
878
|
+
}
|
|
879
|
+
};
|
|
880
|
+
function applyOpacity(r, g, b, opacity) {
|
|
881
|
+
opacity = Math.min(Math.max(opacity ?? 1, 0), 1);
|
|
882
|
+
const white = 255 * (1 - opacity);
|
|
883
|
+
r = Math.round(r * opacity + white);
|
|
884
|
+
g = Math.round(g * opacity + white);
|
|
885
|
+
b = Math.round(b * opacity + white);
|
|
886
|
+
return [r, g, b];
|
|
887
|
+
}
|
|
888
|
+
function RGBToHSL(rgb, output) {
|
|
889
|
+
const r = rgb[0] / 255;
|
|
890
|
+
const g = rgb[1] / 255;
|
|
891
|
+
const b = rgb[2] / 255;
|
|
892
|
+
const max = Math.max(r, g, b);
|
|
893
|
+
const min = Math.min(r, g, b);
|
|
894
|
+
const l = (max + min) / 2;
|
|
895
|
+
if (max === min) {
|
|
896
|
+
output[0] = output[1] = 0;
|
|
897
|
+
} else {
|
|
898
|
+
const d = max - min;
|
|
899
|
+
output[1] = l < 0.5 ? d / (max + min) : d / (2 - max - min);
|
|
900
|
+
switch (max) {
|
|
901
|
+
case r:
|
|
902
|
+
output[0] = ((g - b) / d + (g < b ? 6 : 0)) * 60;
|
|
903
|
+
break;
|
|
904
|
+
case g:
|
|
905
|
+
output[0] = ((b - r) / d + 2) * 60;
|
|
906
|
+
break;
|
|
907
|
+
case b:
|
|
908
|
+
output[0] = ((r - g) / d + 4) * 60;
|
|
909
|
+
break;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
output[2] = l;
|
|
913
|
+
}
|
|
914
|
+
function HSLToRGB(hsl, output) {
|
|
915
|
+
const h = hsl[0];
|
|
916
|
+
const s = hsl[1];
|
|
917
|
+
const l = hsl[2];
|
|
918
|
+
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
919
|
+
const x = c * (1 - Math.abs(h / 60 % 2 - 1));
|
|
920
|
+
const m = l - c / 2;
|
|
921
|
+
switch (Math.floor(h / 60)) {
|
|
922
|
+
case 0:
|
|
923
|
+
output[0] = c + m;
|
|
924
|
+
output[1] = x + m;
|
|
925
|
+
output[2] = m;
|
|
926
|
+
break;
|
|
927
|
+
case 1:
|
|
928
|
+
output[0] = x + m;
|
|
929
|
+
output[1] = c + m;
|
|
930
|
+
output[2] = m;
|
|
931
|
+
break;
|
|
932
|
+
case 2:
|
|
933
|
+
output[0] = m;
|
|
934
|
+
output[1] = c + m;
|
|
935
|
+
output[2] = x + m;
|
|
936
|
+
break;
|
|
937
|
+
case 3:
|
|
938
|
+
output[0] = m;
|
|
939
|
+
output[1] = x + m;
|
|
940
|
+
output[2] = c + m;
|
|
941
|
+
break;
|
|
942
|
+
case 4:
|
|
943
|
+
output[0] = x + m;
|
|
944
|
+
output[1] = m;
|
|
945
|
+
output[2] = c + m;
|
|
946
|
+
break;
|
|
947
|
+
case 5:
|
|
948
|
+
case 6:
|
|
949
|
+
output[0] = c + m;
|
|
950
|
+
output[1] = m;
|
|
951
|
+
output[2] = x + m;
|
|
952
|
+
break;
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
function computeLuminance(x) {
|
|
956
|
+
return x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
|
|
957
|
+
}
|
|
958
|
+
function contrastRatio(hsl1, hsl2, output) {
|
|
959
|
+
HSLToRGB(hsl1, output);
|
|
960
|
+
output.map(computeLuminance);
|
|
961
|
+
const lum1 = 0.2126 * output[0] + 0.7152 * output[1] + 0.0722 * output[2];
|
|
962
|
+
HSLToRGB(hsl2, output);
|
|
963
|
+
output.map(computeLuminance);
|
|
964
|
+
const lum2 = 0.2126 * output[0] + 0.7152 * output[1] + 0.0722 * output[2];
|
|
965
|
+
return lum1 > lum2 ? (lum1 + 0.05) / (lum2 + 0.05) : (lum2 + 0.05) / (lum1 + 0.05);
|
|
966
|
+
}
|
|
967
|
+
var contrastCache = /* @__PURE__ */ new Map();
|
|
968
|
+
function findContrastColor(baseColor, fixedColor) {
|
|
969
|
+
const key = baseColor[0] + baseColor[1] * 256 + baseColor[2] * 65536 + fixedColor[0] * 16777216 + fixedColor[1] * 4294967296 + fixedColor[2] * 1099511627776;
|
|
970
|
+
let cachedValue = contrastCache.get(key);
|
|
971
|
+
if (cachedValue) {
|
|
972
|
+
return cachedValue;
|
|
973
|
+
}
|
|
974
|
+
const array = new Float32Array(9);
|
|
975
|
+
const output = array.subarray(0, 3);
|
|
976
|
+
const baseHSL = array.subarray(3, 6);
|
|
977
|
+
RGBToHSL(baseColor, baseHSL);
|
|
978
|
+
const fixedHSL = array.subarray(6, 9);
|
|
979
|
+
RGBToHSL(fixedColor, fixedHSL);
|
|
980
|
+
const isFixedColorDark = fixedHSL[2] < 0.5;
|
|
981
|
+
const minContrast = isFixedColorDark ? 12 : 4.5;
|
|
982
|
+
baseHSL[2] = isFixedColorDark ? Math.sqrt(baseHSL[2]) : 1 - Math.sqrt(1 - baseHSL[2]);
|
|
983
|
+
if (contrastRatio(baseHSL, fixedHSL, output) < minContrast) {
|
|
984
|
+
let start, end;
|
|
985
|
+
if (isFixedColorDark) {
|
|
986
|
+
start = baseHSL[2];
|
|
987
|
+
end = 1;
|
|
988
|
+
} else {
|
|
989
|
+
start = 0;
|
|
990
|
+
end = baseHSL[2];
|
|
991
|
+
}
|
|
992
|
+
const PRECISION = 5e-3;
|
|
993
|
+
while (end - start > PRECISION) {
|
|
994
|
+
const mid = baseHSL[2] = (start + end) / 2;
|
|
995
|
+
if (isFixedColorDark === contrastRatio(baseHSL, fixedHSL, output) < minContrast) {
|
|
996
|
+
start = mid;
|
|
997
|
+
} else {
|
|
998
|
+
end = mid;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
baseHSL[2] = isFixedColorDark ? end : start;
|
|
1002
|
+
}
|
|
1003
|
+
HSLToRGB(baseHSL, output);
|
|
1004
|
+
cachedValue = Util.makeHexColor(
|
|
1005
|
+
Math.round(output[0] * 255),
|
|
1006
|
+
Math.round(output[1] * 255),
|
|
1007
|
+
Math.round(output[2] * 255)
|
|
1008
|
+
);
|
|
1009
|
+
contrastCache.set(key, cachedValue);
|
|
1010
|
+
return cachedValue;
|
|
1011
|
+
}
|
|
1012
|
+
function renderRichText({ html, dir, className }, container) {
|
|
1013
|
+
const fragment = document.createDocumentFragment();
|
|
1014
|
+
if (typeof html === "string") {
|
|
1015
|
+
const p = document.createElement("p");
|
|
1016
|
+
p.dir = dir || "auto";
|
|
1017
|
+
const lines = html.split(/(?:\r\n?|\n)/);
|
|
1018
|
+
for (let i = 0, ii = lines.length; i < ii; ++i) {
|
|
1019
|
+
const line = lines[i];
|
|
1020
|
+
p.append(document.createTextNode(line));
|
|
1021
|
+
if (i < ii - 1) {
|
|
1022
|
+
p.append(document.createElement("br"));
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
fragment.append(p);
|
|
1026
|
+
} else {
|
|
1027
|
+
XfaLayer.render({
|
|
1028
|
+
xfaHtml: html,
|
|
1029
|
+
div: fragment,
|
|
1030
|
+
intent: "richText"
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
fragment.firstChild.classList.add("richText", className);
|
|
1034
|
+
container.append(fragment);
|
|
1035
|
+
}
|
|
593
1036
|
|
|
594
1037
|
// src/pdf.js/src/display/cmap_reader_factory.js
|
|
595
1038
|
var BaseCMapReaderFactory = class {
|
|
@@ -1598,6 +2041,8 @@ var NodeWasmFactory = class extends BaseWasmFactory {
|
|
|
1598
2041
|
};
|
|
1599
2042
|
|
|
1600
2043
|
export {
|
|
2044
|
+
XfaText,
|
|
2045
|
+
XfaLayer,
|
|
1601
2046
|
SVG_NS,
|
|
1602
2047
|
PixelsPerInch,
|
|
1603
2048
|
fetchData,
|
|
@@ -1621,6 +2066,11 @@ export {
|
|
|
1621
2066
|
setLayerDimensions,
|
|
1622
2067
|
OutputScale,
|
|
1623
2068
|
SupportedImageMimeTypes,
|
|
2069
|
+
ColorScheme,
|
|
2070
|
+
CSSConstants,
|
|
2071
|
+
applyOpacity,
|
|
2072
|
+
findContrastColor,
|
|
2073
|
+
renderRichText,
|
|
1624
2074
|
DOMCMapReaderFactory,
|
|
1625
2075
|
BaseStandardFontDataFactory,
|
|
1626
2076
|
DOMStandardFontDataFactory,
|
|
@@ -305,12 +305,12 @@ function getVerbosityLevel() {
|
|
|
305
305
|
}
|
|
306
306
|
function info(msg) {
|
|
307
307
|
if (verbosity >= VerbosityLevel.INFOS) {
|
|
308
|
-
console.
|
|
308
|
+
console.info(`Info: ${msg}`);
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
function warn(msg) {
|
|
312
312
|
if (verbosity >= VerbosityLevel.WARNINGS) {
|
|
313
|
-
console.
|
|
313
|
+
console.warn(`Warning: ${msg}`);
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
function unreachable(msg) {
|