pdfjs-dist 2.5.207 → 2.6.347

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.

Potentially problematic release.


This version of pdfjs-dist might be problematic. Click here for more details.

Files changed (133) hide show
  1. package/bower.json +1 -1
  2. package/build/pdf.js +867 -216
  3. package/build/pdf.js.map +1 -1
  4. package/build/pdf.min.js +1 -1
  5. package/build/pdf.worker.js +10214 -8547
  6. package/build/pdf.worker.js.map +1 -1
  7. package/build/pdf.worker.min.js +1 -1
  8. package/es5/build/pdf.js +2023 -1046
  9. package/es5/build/pdf.js.map +1 -1
  10. package/es5/build/pdf.min.js +22 -0
  11. package/es5/build/pdf.worker.js +11136 -8144
  12. package/es5/build/pdf.worker.js.map +1 -1
  13. package/es5/build/pdf.worker.min.js +22 -0
  14. package/es5/image_decoders/pdf.image_decoders.js +12529 -0
  15. package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
  16. package/es5/image_decoders/pdf.image_decoders.min.js +22 -0
  17. package/es5/web/images/shadow.png +0 -0
  18. package/es5/web/pdf_viewer.css +8 -5
  19. package/es5/web/pdf_viewer.js +195 -51
  20. package/es5/web/pdf_viewer.js.map +1 -1
  21. package/image_decoders/pdf.image_decoders.js +24 -16
  22. package/image_decoders/pdf.image_decoders.js.map +1 -1
  23. package/image_decoders/pdf.image_decoders.min.js +1 -1
  24. package/lib/core/annotation.js +479 -43
  25. package/lib/core/cff_parser.js +643 -615
  26. package/lib/core/chunked_stream.js +64 -50
  27. package/lib/core/colorspace.js +126 -104
  28. package/lib/core/crypto.js +37 -0
  29. package/lib/core/document.js +128 -75
  30. package/lib/core/evaluator.js +3015 -2754
  31. package/lib/core/fonts.js +47 -46
  32. package/lib/core/function.js +79 -6
  33. package/lib/core/image.js +364 -357
  34. package/lib/core/image_utils.js +109 -8
  35. package/lib/core/jpg.js +8 -3
  36. package/lib/core/obj.js +255 -34
  37. package/lib/core/operator_list.js +17 -15
  38. package/lib/core/parser.js +40 -3
  39. package/lib/core/pattern.js +24 -11
  40. package/lib/core/primitives.js +112 -53
  41. package/lib/core/type1_parser.js +2 -0
  42. package/lib/core/worker.js +102 -37
  43. package/lib/core/writer.js +242 -0
  44. package/lib/display/annotation_layer.js +51 -10
  45. package/lib/display/annotation_storage.js +89 -0
  46. package/lib/display/api.js +140 -54
  47. package/lib/display/canvas.js +215 -46
  48. package/lib/display/display_utils.js +55 -18
  49. package/lib/display/fetch_stream.js +6 -0
  50. package/lib/display/font_loader.js +26 -15
  51. package/lib/display/metadata.js +1 -7
  52. package/lib/display/network.js +0 -14
  53. package/lib/display/node_utils.js +87 -0
  54. package/lib/display/optional_content_config.js +184 -0
  55. package/lib/display/svg.js +1 -1
  56. package/lib/display/text_layer.js +4 -1
  57. package/lib/pdf.js +2 -2
  58. package/lib/pdf.worker.js +2 -2
  59. package/lib/shared/is_node.js +1 -1
  60. package/lib/shared/util.js +13 -10
  61. package/lib/test/unit/annotation_spec.js +520 -50
  62. package/lib/test/unit/annotation_storage_spec.js +83 -0
  63. package/lib/test/unit/api_spec.js +16 -6
  64. package/lib/test/unit/cmap_spec.js +4 -4
  65. package/lib/test/unit/colorspace_spec.js +216 -24
  66. package/lib/test/unit/crypto_spec.js +51 -4
  67. package/lib/test/unit/custom_spec.js +129 -1
  68. package/lib/test/unit/document_spec.js +112 -1
  69. package/lib/test/unit/evaluator_spec.js +29 -10
  70. package/lib/test/unit/jasmine-boot.js +1 -1
  71. package/lib/test/unit/metadata_spec.js +3 -3
  72. package/lib/test/unit/primitives_spec.js +242 -63
  73. package/lib/test/unit/test_utils.js +42 -89
  74. package/lib/test/unit/testreporter.js +17 -6
  75. package/lib/test/unit/util_spec.js +13 -12
  76. package/lib/test/unit/writer_spec.js +84 -0
  77. package/lib/web/annotation_layer_builder.js +13 -9
  78. package/lib/web/app.js +231 -26
  79. package/lib/web/app_options.js +1 -6
  80. package/lib/web/base_tree_viewer.js +100 -0
  81. package/lib/web/base_viewer.js +53 -4
  82. package/lib/web/download_manager.js +3 -10
  83. package/lib/web/firefox_print_service.js +32 -12
  84. package/lib/web/firefoxcom.js +20 -6
  85. package/lib/web/interfaces.js +1 -1
  86. package/lib/web/pdf_attachment_viewer.js +80 -38
  87. package/lib/web/pdf_find_controller.js +2 -1
  88. package/lib/web/pdf_layer_viewer.js +208 -0
  89. package/lib/web/pdf_outline_viewer.js +24 -57
  90. package/lib/web/pdf_page_view.js +29 -6
  91. package/lib/web/pdf_print_service.js +13 -11
  92. package/lib/web/pdf_sidebar.js +46 -25
  93. package/lib/web/pdf_thumbnail_view.js +16 -3
  94. package/lib/web/pdf_thumbnail_viewer.js +17 -1
  95. package/lib/web/pdf_viewer.component.js +2 -2
  96. package/lib/web/preferences.js +1 -1
  97. package/lib/web/toolbar.js +1 -1
  98. package/lib/web/ui_utils.js +7 -1
  99. package/package.json +3 -1
  100. package/types/display/annotation_layer.d.ts +61 -0
  101. package/types/display/annotation_storage.d.ts +36 -0
  102. package/types/display/api.d.ts +1107 -0
  103. package/types/display/api_compatibility.d.ts +1 -0
  104. package/types/display/canvas.d.ts +4 -0
  105. package/types/display/content_disposition.d.ts +7 -0
  106. package/types/display/display_utils.d.ts +243 -0
  107. package/types/display/fetch_stream.d.ts +67 -0
  108. package/types/display/font_loader.d.ts +19 -0
  109. package/types/display/metadata.d.ts +9 -0
  110. package/types/display/network.d.ts +80 -0
  111. package/types/display/network_utils.d.ts +14 -0
  112. package/types/display/node_stream.d.ts +72 -0
  113. package/types/display/node_utils.d.ts +6 -0
  114. package/types/display/optional_content_config.d.ts +12 -0
  115. package/types/display/pattern_helper.d.ts +5 -0
  116. package/types/display/svg.d.ts +2 -0
  117. package/types/display/text_layer.d.ts +83 -0
  118. package/types/display/transport_stream.d.ts +57 -0
  119. package/types/display/webgl.d.ts +20 -0
  120. package/types/display/worker_options.d.ts +27 -0
  121. package/types/display/xml_parser.d.ts +35 -0
  122. package/types/pdf.d.ts +33 -0
  123. package/types/shared/compatibility.d.ts +1 -0
  124. package/types/shared/is_node.d.ts +1 -0
  125. package/types/shared/message_handler.d.ts +62 -0
  126. package/types/shared/util.d.ts +421 -0
  127. package/web/images/shadow.png +0 -0
  128. package/web/pdf_viewer.css +8 -5
  129. package/web/pdf_viewer.js +109 -33
  130. package/web/pdf_viewer.js.map +1 -1
  131. package/webpack.js +1 -9
  132. package/es5/web/images/texture.png +0 -0
  133. package/web/images/texture.png +0 -0
@@ -31,7 +31,8 @@ var _util = require("../shared/util.js");
31
31
  class BaseFontLoader {
32
32
  constructor({
33
33
  docId,
34
- onUnsupportedFeature
34
+ onUnsupportedFeature,
35
+ ownerDocument = globalThis.document
35
36
  }) {
36
37
  if (this.constructor === BaseFontLoader) {
37
38
  (0, _util.unreachable)("Cannot initialize BaseFontLoader.");
@@ -39,22 +40,25 @@ class BaseFontLoader {
39
40
 
40
41
  this.docId = docId;
41
42
  this._onUnsupportedFeature = onUnsupportedFeature;
43
+ this._document = ownerDocument;
42
44
  this.nativeFontFaces = [];
43
45
  this.styleElement = null;
44
46
  }
45
47
 
46
48
  addNativeFontFace(nativeFontFace) {
47
49
  this.nativeFontFaces.push(nativeFontFace);
48
- document.fonts.add(nativeFontFace);
50
+
51
+ this._document.fonts.add(nativeFontFace);
49
52
  }
50
53
 
51
54
  insertRule(rule) {
52
55
  let styleElement = this.styleElement;
53
56
 
54
57
  if (!styleElement) {
55
- styleElement = this.styleElement = document.createElement("style");
58
+ styleElement = this.styleElement = this._document.createElement("style");
56
59
  styleElement.id = `PDFJS_FONT_STYLE_TAG_${this.docId}`;
57
- document.documentElement.getElementsByTagName("head")[0].appendChild(styleElement);
60
+
61
+ this._document.documentElement.getElementsByTagName("head")[0].appendChild(styleElement);
58
62
  }
59
63
 
60
64
  const styleSheet = styleElement.sheet;
@@ -62,8 +66,8 @@ class BaseFontLoader {
62
66
  }
63
67
 
64
68
  clear() {
65
- this.nativeFontFaces.forEach(function (nativeFontFace) {
66
- document.fonts.delete(nativeFontFace);
69
+ this.nativeFontFaces.forEach(nativeFontFace => {
70
+ this._document.fonts.delete(nativeFontFace);
67
71
  });
68
72
  this.nativeFontFaces.length = 0;
69
73
 
@@ -124,7 +128,7 @@ class BaseFontLoader {
124
128
  }
125
129
 
126
130
  get isFontLoadingAPISupported() {
127
- const supported = typeof document !== "undefined" && !!document.fonts;
131
+ const supported = typeof this._document !== "undefined" && !!this._document.fonts;
128
132
  return (0, _util.shadow)(this, "isFontLoadingAPISupported", supported);
129
133
  }
130
134
 
@@ -146,8 +150,8 @@ let FontLoader;
146
150
  exports.FontLoader = FontLoader;
147
151
  {
148
152
  exports.FontLoader = FontLoader = class GenericFontLoader extends BaseFontLoader {
149
- constructor(docId) {
150
- super(docId);
153
+ constructor(params) {
154
+ super(params);
151
155
  this.loadingContext = {
152
156
  requests: [],
153
157
  nextRequestId: 0
@@ -213,7 +217,9 @@ exports.FontLoader = FontLoader;
213
217
  }
214
218
 
215
219
  let i, ii;
216
- const canvas = document.createElement("canvas");
220
+
221
+ const canvas = this._document.createElement("canvas");
222
+
217
223
  canvas.width = 1;
218
224
  canvas.height = 1;
219
225
  const ctx = canvas.getContext("2d");
@@ -267,22 +273,27 @@ exports.FontLoader = FontLoader;
267
273
  }
268
274
 
269
275
  names.push(loadTestFontId);
270
- const div = document.createElement("div");
276
+
277
+ const div = this._document.createElement("div");
278
+
271
279
  div.style.visibility = "hidden";
272
280
  div.style.width = div.style.height = "10px";
273
281
  div.style.position = "absolute";
274
282
  div.style.top = div.style.left = "0px";
275
283
 
276
284
  for (i = 0, ii = names.length; i < ii; ++i) {
277
- const span = document.createElement("span");
285
+ const span = this._document.createElement("span");
286
+
278
287
  span.textContent = "Hi";
279
288
  span.style.fontFamily = names[i];
280
289
  div.appendChild(span);
281
290
  }
282
291
 
283
- document.body.appendChild(div);
284
- isFontReady(loadTestFontId, function () {
285
- document.body.removeChild(div);
292
+ this._document.body.appendChild(div);
293
+
294
+ isFontReady(loadTestFontId, () => {
295
+ this._document.body.removeChild(div);
296
+
286
297
  request.complete();
287
298
  });
288
299
  }
@@ -125,13 +125,7 @@ class Metadata {
125
125
  }
126
126
 
127
127
  getAll() {
128
- const obj = Object.create(null);
129
-
130
- for (const [key, value] of this._metadataMap) {
131
- obj[key] = value;
132
- }
133
-
134
- return obj;
128
+ return Object.fromEntries(this._metadataMap);
135
129
  }
136
130
 
137
131
  has(name) {
@@ -196,14 +196,6 @@ class NetworkManager {
196
196
  }
197
197
  }
198
198
 
199
- hasPendingRequests() {
200
- for (const xhrId in this.pendingRequests) {
201
- return true;
202
- }
203
-
204
- return false;
205
- }
206
-
207
199
  getRequestXhr(xhrId) {
208
200
  return this.pendingRequests[xhrId].xhr;
209
201
  }
@@ -212,12 +204,6 @@ class NetworkManager {
212
204
  return xhrId in this.pendingRequests;
213
205
  }
214
206
 
215
- abortAllRequests() {
216
- for (const xhrId in this.pendingRequests) {
217
- this.abortRequest(xhrId | 0);
218
- }
219
- }
220
-
221
207
  abortRequest(xhrId) {
222
208
  const xhr = this.pendingRequests[xhrId].xhr;
223
209
  delete this.pendingRequests[xhrId];
@@ -0,0 +1,87 @@
1
+ /**
2
+ * @licstart The following is the entire license notice for the
3
+ * Javascript code in this page
4
+ *
5
+ * Copyright 2020 Mozilla Foundation
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ *
19
+ * @licend The above is the entire license notice for the
20
+ * Javascript code in this page
21
+ */
22
+ "use strict";
23
+
24
+ Object.defineProperty(exports, "__esModule", {
25
+ value: true
26
+ });
27
+ exports.NodeCMapReaderFactory = exports.NodeCanvasFactory = void 0;
28
+
29
+ var _display_utils = require("./display_utils.js");
30
+
31
+ var _is_node = require("../shared/is_node.js");
32
+
33
+ var _util = require("../shared/util.js");
34
+
35
+ let NodeCanvasFactory = class {
36
+ constructor() {
37
+ (0, _util.unreachable)("Not implemented: NodeCanvasFactory");
38
+ }
39
+
40
+ };
41
+ exports.NodeCanvasFactory = NodeCanvasFactory;
42
+ let NodeCMapReaderFactory = class {
43
+ constructor() {
44
+ (0, _util.unreachable)("Not implemented: NodeCMapReaderFactory");
45
+ }
46
+
47
+ };
48
+ exports.NodeCMapReaderFactory = NodeCMapReaderFactory;
49
+
50
+ if (_is_node.isNodeJS) {
51
+ exports.NodeCanvasFactory = NodeCanvasFactory = class extends _display_utils.BaseCanvasFactory {
52
+ create(width, height) {
53
+ if (width <= 0 || height <= 0) {
54
+ throw new Error("Invalid canvas size");
55
+ }
56
+
57
+ const Canvas = require("canvas");
58
+
59
+ const canvas = Canvas.createCanvas(width, height);
60
+ return {
61
+ canvas,
62
+ context: canvas.getContext("2d")
63
+ };
64
+ }
65
+
66
+ };
67
+ exports.NodeCMapReaderFactory = NodeCMapReaderFactory = class extends _display_utils.BaseCMapReaderFactory {
68
+ _fetchData(url, compressionType) {
69
+ return new Promise((resolve, reject) => {
70
+ const fs = require("fs");
71
+
72
+ fs.readFile(url, (error, data) => {
73
+ if (error || !data) {
74
+ reject(new Error(error));
75
+ return;
76
+ }
77
+
78
+ resolve({
79
+ cMapData: new Uint8Array(data),
80
+ compressionType
81
+ });
82
+ });
83
+ });
84
+ }
85
+
86
+ };
87
+ }
@@ -0,0 +1,184 @@
1
+ /**
2
+ * @licstart The following is the entire license notice for the
3
+ * Javascript code in this page
4
+ *
5
+ * Copyright 2020 Mozilla Foundation
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ *
19
+ * @licend The above is the entire license notice for the
20
+ * Javascript code in this page
21
+ */
22
+ "use strict";
23
+
24
+ Object.defineProperty(exports, "__esModule", {
25
+ value: true
26
+ });
27
+ exports.OptionalContentConfig = void 0;
28
+
29
+ var _util = require("../shared/util.js");
30
+
31
+ class OptionalContentGroup {
32
+ constructor(name, intent) {
33
+ this.visible = true;
34
+ this.name = name;
35
+ this.intent = intent;
36
+ }
37
+
38
+ }
39
+
40
+ class OptionalContentConfig {
41
+ constructor(data) {
42
+ this.name = null;
43
+ this.creator = null;
44
+ this._order = null;
45
+ this._groups = new Map();
46
+
47
+ if (data === null) {
48
+ return;
49
+ }
50
+
51
+ this.name = data.name;
52
+ this.creator = data.creator;
53
+ this._order = data.order;
54
+
55
+ for (const group of data.groups) {
56
+ this._groups.set(group.id, new OptionalContentGroup(group.name, group.intent));
57
+ }
58
+
59
+ if (data.baseState === "OFF") {
60
+ for (const group of this._groups) {
61
+ group.visible = false;
62
+ }
63
+ }
64
+
65
+ for (const on of data.on) {
66
+ this._groups.get(on).visible = true;
67
+ }
68
+
69
+ for (const off of data.off) {
70
+ this._groups.get(off).visible = false;
71
+ }
72
+ }
73
+
74
+ isVisible(group) {
75
+ if (group.type === "OCG") {
76
+ if (!this._groups.has(group.id)) {
77
+ (0, _util.warn)(`Optional content group not found: ${group.id}`);
78
+ return true;
79
+ }
80
+
81
+ return this._groups.get(group.id).visible;
82
+ } else if (group.type === "OCMD") {
83
+ if (group.expression) {
84
+ (0, _util.warn)("Visibility expression not supported yet.");
85
+ }
86
+
87
+ if (!group.policy || group.policy === "AnyOn") {
88
+ for (const id of group.ids) {
89
+ if (!this._groups.has(id)) {
90
+ (0, _util.warn)(`Optional content group not found: ${id}`);
91
+ return true;
92
+ }
93
+
94
+ if (this._groups.get(id).visible) {
95
+ return true;
96
+ }
97
+ }
98
+
99
+ return false;
100
+ } else if (group.policy === "AllOn") {
101
+ for (const id of group.ids) {
102
+ if (!this._groups.has(id)) {
103
+ (0, _util.warn)(`Optional content group not found: ${id}`);
104
+ return true;
105
+ }
106
+
107
+ if (!this._groups.get(id).visible) {
108
+ return false;
109
+ }
110
+ }
111
+
112
+ return true;
113
+ } else if (group.policy === "AnyOff") {
114
+ for (const id of group.ids) {
115
+ if (!this._groups.has(id)) {
116
+ (0, _util.warn)(`Optional content group not found: ${id}`);
117
+ return true;
118
+ }
119
+
120
+ if (!this._groups.get(id).visible) {
121
+ return true;
122
+ }
123
+ }
124
+
125
+ return false;
126
+ } else if (group.policy === "AllOff") {
127
+ for (const id of group.ids) {
128
+ if (!this._groups.has(id)) {
129
+ (0, _util.warn)(`Optional content group not found: ${id}`);
130
+ return true;
131
+ }
132
+
133
+ if (this._groups.get(id).visible) {
134
+ return false;
135
+ }
136
+ }
137
+
138
+ return true;
139
+ }
140
+
141
+ (0, _util.warn)(`Unknown optional content policy ${group.policy}.`);
142
+ return true;
143
+ }
144
+
145
+ (0, _util.warn)(`Unknown group type ${group.type}.`);
146
+ return true;
147
+ }
148
+
149
+ setVisibility(id, visible = true) {
150
+ if (!this._groups.has(id)) {
151
+ (0, _util.warn)(`Optional content group not found: ${id}`);
152
+ return;
153
+ }
154
+
155
+ this._groups.get(id).visible = !!visible;
156
+ }
157
+
158
+ getOrder() {
159
+ if (!this._groups.size) {
160
+ return null;
161
+ }
162
+
163
+ if (this._order) {
164
+ return this._order.slice();
165
+ }
166
+
167
+ return Array.from(this._groups.keys());
168
+ }
169
+
170
+ getGroups() {
171
+ if (!this._groups.size) {
172
+ return null;
173
+ }
174
+
175
+ return Object.fromEntries(this._groups);
176
+ }
177
+
178
+ getGroup(id) {
179
+ return this._groups.get(id) || null;
180
+ }
181
+
182
+ }
183
+
184
+ exports.OptionalContentConfig = OptionalContentConfig;
@@ -1420,7 +1420,7 @@ exports.SVGGraphics = SVGGraphics;
1420
1420
  }
1421
1421
 
1422
1422
  paintImageXObject(objId) {
1423
- const imgData = this.objs.get(objId);
1423
+ const imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
1424
1424
 
1425
1425
  if (!imgData) {
1426
1426
  (0, _util.warn)(`Dependent image with object ID ${objId} is not ready yet`);
@@ -462,6 +462,7 @@ var renderTextLayer = function renderTextLayerClosure() {
462
462
  this._textContent = textContent;
463
463
  this._textContentStream = textContentStream;
464
464
  this._container = container;
465
+ this._document = container.ownerDocument;
465
466
  this._viewport = viewport;
466
467
  this._textDivs = textDivs || [];
467
468
  this._textContentItemsStr = textContentItemsStr || [];
@@ -568,7 +569,9 @@ var renderTextLayer = function renderTextLayerClosure() {
568
569
  _render: function TextLayer_render(timeout) {
569
570
  const capability = (0, _util.createPromiseCapability)();
570
571
  let styleCache = Object.create(null);
571
- const canvas = document.createElement("canvas");
572
+
573
+ const canvas = this._document.createElement("canvas");
574
+
572
575
  canvas.mozOpaque = true;
573
576
  this._layoutTextCtx = canvas.getContext("2d", {
574
577
  alpha: false
package/lib/pdf.js CHANGED
@@ -233,8 +233,8 @@ var _text_layer = require("./display/text_layer.js");
233
233
 
234
234
  var _svg = require("./display/svg.js");
235
235
 
236
- const pdfjsVersion = '2.5.207';
237
- const pdfjsBuild = '0974d605';
236
+ const pdfjsVersion = '2.6.347';
237
+ const pdfjsBuild = '3be9c65f';
238
238
  {
239
239
  const {
240
240
  isNodeJS
package/lib/pdf.worker.js CHANGED
@@ -33,5 +33,5 @@ Object.defineProperty(exports, "WorkerMessageHandler", {
33
33
 
34
34
  var _worker = require("./core/worker.js");
35
35
 
36
- const pdfjsVersion = '2.5.207';
37
- const pdfjsBuild = '0974d605';
36
+ const pdfjsVersion = '2.6.347';
37
+ const pdfjsBuild = '3be9c65f';
@@ -25,5 +25,5 @@ Object.defineProperty(exports, "__esModule", {
25
25
  value: true
26
26
  });
27
27
  exports.isNodeJS = void 0;
28
- const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !process.versions.electron;
28
+ const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
29
29
  exports.isNodeJS = isNodeJS;
@@ -29,12 +29,13 @@ exports.arraysToBytes = arraysToBytes;
29
29
  exports.assert = assert;
30
30
  exports.bytesToString = bytesToString;
31
31
  exports.createPromiseCapability = createPromiseCapability;
32
+ exports.escapeString = escapeString;
33
+ exports.getModificationDate = getModificationDate;
32
34
  exports.getVerbosityLevel = getVerbosityLevel;
33
35
  exports.info = info;
34
36
  exports.isArrayBuffer = isArrayBuffer;
35
37
  exports.isArrayEqual = isArrayEqual;
36
38
  exports.isBool = isBool;
37
- exports.isEmptyObj = isEmptyObj;
38
39
  exports.isNum = isNum;
39
40
  exports.isString = isString;
40
41
  exports.isSameOrigin = isSameOrigin;
@@ -333,7 +334,8 @@ const UNSUPPORTED_FEATURES = {
333
334
  errorOperatorList: "errorOperatorList",
334
335
  errorFontToUnicode: "errorFontToUnicode",
335
336
  errorFontLoadNative: "errorFontLoadNative",
336
- errorFontGetPath: "errorFontGetPath"
337
+ errorFontGetPath: "errorFontGetPath",
338
+ errorMarkedContent: "errorMarkedContent"
337
339
  };
338
340
  exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
339
341
  const PasswordResponses = {
@@ -748,6 +750,10 @@ function stringToPDFString(str) {
748
750
  return strBuf.join("");
749
751
  }
750
752
 
753
+ function escapeString(str) {
754
+ return str.replace(/([\(\)\\])/g, "\\$1");
755
+ }
756
+
751
757
  function stringToUTF8String(str) {
752
758
  return decodeURIComponent(escape(str));
753
759
  }
@@ -756,14 +762,6 @@ function utf8StringToString(str) {
756
762
  return unescape(encodeURIComponent(str));
757
763
  }
758
764
 
759
- function isEmptyObj(obj) {
760
- for (const key in obj) {
761
- return false;
762
- }
763
-
764
- return true;
765
- }
766
-
767
765
  function isBool(v) {
768
766
  return typeof v === "boolean";
769
767
  }
@@ -790,6 +788,11 @@ function isArrayEqual(arr1, arr2) {
790
788
  });
791
789
  }
792
790
 
791
+ function getModificationDate(date = new Date(Date.now())) {
792
+ const buffer = [date.getUTCFullYear().toString(), (date.getUTCMonth() + 1).toString().padStart(2, "0"), (date.getUTCDate() + 1).toString().padStart(2, "0"), date.getUTCHours().toString().padStart(2, "0"), date.getUTCMinutes().toString().padStart(2, "0"), date.getUTCSeconds().toString().padStart(2, "0")];
793
+ return buffer.join("");
794
+ }
795
+
793
796
  function createPromiseCapability() {
794
797
  const capability = Object.create(null);
795
798
  let isSettled = false;