pdfjs-dist 2.2.228 → 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 (229) hide show
  1. package/README.md +4 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +8816 -19300
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +22 -1
  6. package/build/pdf.worker.entry.js +5 -3
  7. package/build/pdf.worker.js +27185 -35746
  8. package/build/pdf.worker.js.map +1 -1
  9. package/build/pdf.worker.min.js +22 -1
  10. package/es5/build/pdf.js +26665 -0
  11. package/es5/build/pdf.js.map +1 -0
  12. package/es5/build/pdf.min.js +22 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +61231 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/build/pdf.worker.min.js +22 -0
  17. package/es5/image_decoders/pdf.image_decoders.js +12529 -0
  18. package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
  19. package/es5/image_decoders/pdf.image_decoders.min.js +22 -0
  20. package/es5/web/images/annotation-check.svg +11 -0
  21. package/es5/web/images/annotation-comment.svg +16 -0
  22. package/es5/web/images/annotation-help.svg +26 -0
  23. package/es5/web/images/annotation-insert.svg +10 -0
  24. package/es5/web/images/annotation-key.svg +11 -0
  25. package/es5/web/images/annotation-newparagraph.svg +11 -0
  26. package/es5/web/images/annotation-noicon.svg +7 -0
  27. package/es5/web/images/annotation-note.svg +42 -0
  28. package/es5/web/images/annotation-paragraph.svg +16 -0
  29. package/es5/web/images/loading-icon.gif +0 -0
  30. package/es5/web/images/shadow.png +0 -0
  31. package/es5/web/pdf_viewer.css +406 -0
  32. package/es5/web/pdf_viewer.js +7886 -0
  33. package/es5/web/pdf_viewer.js.map +1 -0
  34. package/image_decoders/pdf.image_decoders.js +1498 -4832
  35. package/image_decoders/pdf.image_decoders.js.map +1 -1
  36. package/image_decoders/pdf.image_decoders.min.js +22 -1
  37. package/lib/README.md +7 -0
  38. package/lib/core/annotation.js +1144 -927
  39. package/lib/core/arithmetic_decoder.js +81 -97
  40. package/lib/core/bidi.js +54 -46
  41. package/lib/core/ccitt.js +88 -81
  42. package/lib/core/ccitt_stream.js +15 -14
  43. package/lib/core/cff_parser.js +747 -716
  44. package/lib/core/charsets.js +4 -4
  45. package/lib/core/chunked_stream.js +462 -553
  46. package/lib/core/cmap.js +231 -277
  47. package/lib/core/colorspace.js +715 -857
  48. package/lib/core/core_utils.js +57 -52
  49. package/lib/core/crypto.js +416 -437
  50. package/lib/core/document.js +629 -670
  51. package/lib/core/encodings.js +15 -15
  52. package/lib/core/evaluator.js +3229 -2800
  53. package/lib/core/font_renderer.js +135 -178
  54. package/lib/core/fonts.js +602 -534
  55. package/lib/core/function.js +355 -279
  56. package/lib/core/glyphlist.js +4527 -4526
  57. package/lib/core/image.js +442 -439
  58. package/lib/core/image_utils.js +221 -61
  59. package/lib/core/jbig2.js +325 -316
  60. package/lib/core/jbig2_stream.js +18 -17
  61. package/lib/core/jpeg_stream.js +21 -26
  62. package/lib/core/jpg.js +289 -233
  63. package/lib/core/jpx.js +161 -143
  64. package/lib/core/jpx_stream.js +28 -28
  65. package/lib/core/metrics.js +2928 -2928
  66. package/lib/core/murmurhash3.js +87 -102
  67. package/lib/core/obj.js +1343 -1300
  68. package/lib/core/operator_list.js +90 -67
  69. package/lib/core/parser.js +990 -987
  70. package/lib/core/pattern.js +105 -77
  71. package/lib/core/pdf_manager.js +149 -316
  72. package/lib/core/primitives.js +156 -104
  73. package/lib/core/ps_parser.js +175 -214
  74. package/lib/core/standard_fonts.js +237 -236
  75. package/lib/core/stream.js +94 -74
  76. package/lib/core/type1_parser.js +89 -69
  77. package/lib/core/unicode.js +1654 -1654
  78. package/lib/core/worker.js +275 -290
  79. package/lib/core/worker_stream.js +101 -210
  80. package/lib/core/writer.js +242 -0
  81. package/lib/display/annotation_layer.js +772 -1041
  82. package/lib/display/annotation_storage.js +89 -0
  83. package/lib/display/api.js +1575 -1868
  84. package/lib/display/api_compatibility.js +12 -17
  85. package/lib/display/canvas.js +370 -222
  86. package/lib/display/content_disposition.js +40 -59
  87. package/lib/display/display_utils.js +341 -536
  88. package/lib/display/fetch_stream.js +188 -304
  89. package/lib/display/font_loader.js +282 -414
  90. package/lib/display/metadata.js +81 -99
  91. package/lib/display/network.js +362 -511
  92. package/lib/display/network_utils.js +25 -18
  93. package/lib/display/node_stream.js +283 -465
  94. package/lib/display/node_utils.js +87 -0
  95. package/lib/display/optional_content_config.js +184 -0
  96. package/lib/display/pattern_helper.js +93 -44
  97. package/lib/display/svg.js +1163 -1401
  98. package/lib/display/text_layer.js +154 -137
  99. package/lib/display/transport_stream.js +237 -375
  100. package/lib/display/webgl.js +70 -83
  101. package/lib/display/worker_options.js +3 -3
  102. package/lib/display/xml_parser.js +303 -392
  103. package/lib/examples/node/domstubs.js +37 -37
  104. package/lib/pdf.js +220 -58
  105. package/lib/pdf.worker.js +14 -6
  106. package/lib/shared/compatibility.js +3 -246
  107. package/lib/shared/is_node.js +7 -6
  108. package/lib/shared/message_handler.js +327 -332
  109. package/lib/shared/util.js +271 -306
  110. package/lib/test/unit/annotation_spec.js +1902 -763
  111. package/lib/test/unit/annotation_storage_spec.js +83 -0
  112. package/lib/test/unit/api_spec.js +790 -592
  113. package/lib/test/unit/bidi_spec.js +7 -7
  114. package/lib/test/unit/cff_parser_spec.js +73 -72
  115. package/lib/test/unit/clitests_helper.js +7 -9
  116. package/lib/test/unit/cmap_spec.js +86 -88
  117. package/lib/test/unit/colorspace_spec.js +346 -154
  118. package/lib/test/unit/core_utils_spec.js +125 -105
  119. package/lib/test/unit/crypto_spec.js +232 -185
  120. package/lib/test/unit/custom_spec.js +150 -24
  121. package/lib/test/unit/display_svg_spec.js +34 -39
  122. package/lib/test/unit/display_utils_spec.js +139 -149
  123. package/lib/test/unit/document_spec.js +128 -17
  124. package/lib/test/unit/encodings_spec.js +12 -34
  125. package/lib/test/unit/evaluator_spec.js +112 -91
  126. package/lib/test/unit/fetch_stream_spec.js +31 -29
  127. package/lib/test/unit/function_spec.js +206 -204
  128. package/lib/test/unit/jasmine-boot.js +48 -32
  129. package/lib/test/unit/message_handler_spec.js +173 -159
  130. package/lib/test/unit/metadata_spec.js +71 -71
  131. package/lib/test/unit/murmurhash3_spec.js +12 -12
  132. package/lib/test/unit/network_spec.js +13 -11
  133. package/lib/test/unit/network_utils_spec.js +158 -144
  134. package/lib/test/unit/node_stream_spec.js +76 -90
  135. package/lib/test/unit/parser_spec.js +108 -114
  136. package/lib/test/unit/pdf_find_controller_spec.js +55 -86
  137. package/lib/test/unit/pdf_find_utils_spec.js +32 -32
  138. package/lib/test/unit/pdf_history_spec.js +32 -32
  139. package/lib/test/unit/primitives_spec.js +337 -156
  140. package/lib/test/unit/stream_spec.js +16 -14
  141. package/lib/test/unit/test_utils.js +91 -304
  142. package/lib/test/unit/testreporter.js +33 -22
  143. package/lib/test/unit/type1_parser_spec.js +42 -42
  144. package/lib/test/unit/ui_utils_spec.js +299 -461
  145. package/lib/test/unit/unicode_spec.js +42 -42
  146. package/lib/test/unit/util_spec.js +129 -149
  147. package/lib/test/unit/writer_spec.js +84 -0
  148. package/lib/web/annotation_layer_builder.js +78 -111
  149. package/lib/web/app.js +1542 -1267
  150. package/lib/web/app_options.js +76 -91
  151. package/lib/web/base_tree_viewer.js +100 -0
  152. package/lib/web/base_viewer.js +869 -834
  153. package/lib/web/chromecom.js +165 -252
  154. package/lib/web/debugger.js +149 -205
  155. package/lib/web/download_manager.js +34 -58
  156. package/lib/web/firefox_print_service.js +62 -34
  157. package/lib/web/firefoxcom.js +206 -374
  158. package/lib/web/genericcom.js +26 -108
  159. package/lib/web/genericl10n.js +24 -153
  160. package/lib/web/grab_to_pan.js +30 -30
  161. package/lib/web/interfaces.js +80 -254
  162. package/lib/web/overlay_manager.js +70 -246
  163. package/lib/web/password_prompt.js +38 -64
  164. package/lib/web/pdf_attachment_viewer.js +150 -126
  165. package/lib/web/pdf_cursor_tools.js +75 -102
  166. package/lib/web/pdf_document_properties.js +229 -383
  167. package/lib/web/pdf_find_bar.js +136 -170
  168. package/lib/web/pdf_find_controller.js +492 -548
  169. package/lib/web/pdf_find_utils.js +13 -13
  170. package/lib/web/pdf_history.js +397 -406
  171. package/lib/web/pdf_layer_viewer.js +208 -0
  172. package/lib/web/pdf_link_service.js +304 -348
  173. package/lib/web/pdf_outline_viewer.js +119 -212
  174. package/lib/web/pdf_page_view.js +474 -513
  175. package/lib/web/pdf_presentation_mode.js +308 -357
  176. package/lib/web/pdf_print_service.js +96 -110
  177. package/lib/web/pdf_rendering_queue.js +87 -108
  178. package/lib/web/pdf_sidebar.js +286 -302
  179. package/lib/web/pdf_sidebar_resizer.js +92 -119
  180. package/lib/web/pdf_single_page_viewer.js +77 -126
  181. package/lib/web/pdf_thumbnail_view.js +289 -297
  182. package/lib/web/pdf_thumbnail_viewer.js +202 -206
  183. package/lib/web/pdf_viewer.component.js +20 -21
  184. package/lib/web/pdf_viewer.js +55 -115
  185. package/lib/web/preferences.js +69 -273
  186. package/lib/web/secondary_toolbar.js +164 -196
  187. package/lib/web/text_layer_builder.js +284 -319
  188. package/lib/web/toolbar.js +217 -210
  189. package/lib/web/ui_utils.js +274 -421
  190. package/lib/web/view_history.js +52 -226
  191. package/lib/web/viewer_compatibility.js +21 -6
  192. package/package.json +4 -9
  193. package/types/display/annotation_layer.d.ts +61 -0
  194. package/types/display/annotation_storage.d.ts +36 -0
  195. package/types/display/api.d.ts +1107 -0
  196. package/types/display/api_compatibility.d.ts +1 -0
  197. package/types/display/canvas.d.ts +4 -0
  198. package/types/display/content_disposition.d.ts +7 -0
  199. package/types/display/display_utils.d.ts +243 -0
  200. package/types/display/fetch_stream.d.ts +67 -0
  201. package/types/display/font_loader.d.ts +19 -0
  202. package/types/display/metadata.d.ts +9 -0
  203. package/types/display/network.d.ts +80 -0
  204. package/types/display/network_utils.d.ts +14 -0
  205. package/types/display/node_stream.d.ts +72 -0
  206. package/types/display/node_utils.d.ts +6 -0
  207. package/types/display/optional_content_config.d.ts +12 -0
  208. package/types/display/pattern_helper.d.ts +5 -0
  209. package/types/display/svg.d.ts +2 -0
  210. package/types/display/text_layer.d.ts +83 -0
  211. package/types/display/transport_stream.d.ts +57 -0
  212. package/types/display/webgl.d.ts +20 -0
  213. package/types/display/worker_options.d.ts +27 -0
  214. package/types/display/xml_parser.d.ts +35 -0
  215. package/types/pdf.d.ts +33 -0
  216. package/types/shared/compatibility.d.ts +1 -0
  217. package/types/shared/is_node.d.ts +1 -0
  218. package/types/shared/message_handler.d.ts +62 -0
  219. package/types/shared/util.d.ts +421 -0
  220. package/web/images/shadow.png +0 -0
  221. package/web/pdf_viewer.css +29 -27
  222. package/web/pdf_viewer.js +3524 -4746
  223. package/web/pdf_viewer.js.map +1 -1
  224. package/webpack.js +6 -5
  225. package/external/streams/streams-lib.js +0 -3962
  226. package/external/url/url-lib.js +0 -627
  227. package/lib/shared/streams_polyfill.js +0 -43
  228. package/lib/shared/url_polyfill.js +0 -56
  229. package/web/images/texture.png +0 -0
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2019 Mozilla Foundation
5
+ * Copyright 2020 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -27,63 +27,111 @@ Object.defineProperty(exports, "__esModule", {
27
27
  exports.isPDFFunction = isPDFFunction;
28
28
  exports.PostScriptCompiler = exports.PostScriptEvaluator = exports.PDFFunctionFactory = void 0;
29
29
 
30
- var _util = require("../shared/util");
30
+ var _primitives = require("./primitives.js");
31
31
 
32
- var _primitives = require("./primitives");
32
+ var _util = require("../shared/util.js");
33
33
 
34
- var _ps_parser = require("./ps_parser");
34
+ var _ps_parser = require("./ps_parser.js");
35
35
 
36
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
36
+ var _image_utils = require("./image_utils.js");
37
37
 
38
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
38
+ class PDFFunctionFactory {
39
+ constructor({
40
+ xref,
41
+ isEvalSupported = true
42
+ }) {
43
+ this.xref = xref;
44
+ this.isEvalSupported = isEvalSupported !== false;
45
+ this._localFunctionCache = null;
46
+ }
39
47
 
40
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
48
+ create(fn) {
49
+ const cachedFunction = this.getCached(fn);
41
50
 
42
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
51
+ if (cachedFunction) {
52
+ return cachedFunction;
53
+ }
43
54
 
44
- var IsEvalSupportedCached = {
45
- get value() {
46
- return (0, _util.shadow)(this, 'value', (0, _util.isEvalSupported)());
55
+ const parsedFunction = PDFFunction.parse({
56
+ xref: this.xref,
57
+ isEvalSupported: this.isEvalSupported,
58
+ fn: fn instanceof _primitives.Ref ? this.xref.fetch(fn) : fn
59
+ });
60
+
61
+ this._cache(fn, parsedFunction);
62
+
63
+ return parsedFunction;
47
64
  }
48
65
 
49
- };
66
+ createFromArray(fnObj) {
67
+ const cachedFunction = this.getCached(fnObj);
50
68
 
51
- var PDFFunctionFactory =
52
- /*#__PURE__*/
53
- function () {
54
- function PDFFunctionFactory(_ref) {
55
- var xref = _ref.xref,
56
- _ref$isEvalSupported = _ref.isEvalSupported,
57
- isEvalSupported = _ref$isEvalSupported === void 0 ? true : _ref$isEvalSupported;
69
+ if (cachedFunction) {
70
+ return cachedFunction;
71
+ }
58
72
 
59
- _classCallCheck(this, PDFFunctionFactory);
73
+ const parsedFunction = PDFFunction.parseArray({
74
+ xref: this.xref,
75
+ isEvalSupported: this.isEvalSupported,
76
+ fnObj: fnObj instanceof _primitives.Ref ? this.xref.fetch(fnObj) : fnObj
77
+ });
60
78
 
61
- this.xref = xref;
62
- this.isEvalSupported = isEvalSupported !== false;
79
+ this._cache(fnObj, parsedFunction);
80
+
81
+ return parsedFunction;
63
82
  }
64
83
 
65
- _createClass(PDFFunctionFactory, [{
66
- key: "create",
67
- value: function create(fn) {
68
- return PDFFunction.parse({
69
- xref: this.xref,
70
- isEvalSupported: this.isEvalSupported,
71
- fn: fn
72
- });
84
+ getCached(cacheKey) {
85
+ let fnRef;
86
+
87
+ if (cacheKey instanceof _primitives.Ref) {
88
+ fnRef = cacheKey;
89
+ } else if (cacheKey instanceof _primitives.Dict) {
90
+ fnRef = cacheKey.objId;
91
+ } else if ((0, _primitives.isStream)(cacheKey)) {
92
+ fnRef = cacheKey.dict && cacheKey.dict.objId;
73
93
  }
74
- }, {
75
- key: "createFromArray",
76
- value: function createFromArray(fnObj) {
77
- return PDFFunction.parseArray({
78
- xref: this.xref,
79
- isEvalSupported: this.isEvalSupported,
80
- fnObj: fnObj
81
- });
94
+
95
+ if (fnRef) {
96
+ if (!this._localFunctionCache) {
97
+ this._localFunctionCache = new _image_utils.LocalFunctionCache();
98
+ }
99
+
100
+ const localFunction = this._localFunctionCache.getByRef(fnRef);
101
+
102
+ if (localFunction) {
103
+ return localFunction;
104
+ }
82
105
  }
83
- }]);
84
106
 
85
- return PDFFunctionFactory;
86
- }();
107
+ return null;
108
+ }
109
+
110
+ _cache(cacheKey, parsedFunction) {
111
+ if (!parsedFunction) {
112
+ throw new Error('PDFFunctionFactory._cache - expected "parsedFunction" argument.');
113
+ }
114
+
115
+ let fnRef;
116
+
117
+ if (cacheKey instanceof _primitives.Ref) {
118
+ fnRef = cacheKey;
119
+ } else if (cacheKey instanceof _primitives.Dict) {
120
+ fnRef = cacheKey.objId;
121
+ } else if ((0, _primitives.isStream)(cacheKey)) {
122
+ fnRef = cacheKey.dict && cacheKey.dict.objId;
123
+ }
124
+
125
+ if (fnRef) {
126
+ if (!this._localFunctionCache) {
127
+ this._localFunctionCache = new _image_utils.LocalFunctionCache();
128
+ }
129
+
130
+ this._localFunctionCache.set(null, fnRef, parsedFunction);
131
+ }
132
+ }
133
+
134
+ }
87
135
 
88
136
  exports.PDFFunctionFactory = PDFFunctionFactory;
89
137
 
@@ -92,14 +140,14 @@ function toNumberArray(arr) {
92
140
  return null;
93
141
  }
94
142
 
95
- var length = arr.length;
143
+ const length = arr.length;
96
144
 
97
- for (var i = 0; i < length; i++) {
98
- if (typeof arr[i] !== 'number') {
99
- var result = new Array(length);
145
+ for (let i = 0; i < length; i++) {
146
+ if (typeof arr[i] !== "number") {
147
+ const result = new Array(length);
100
148
 
101
- for (var _i = 0; _i < length; _i++) {
102
- result[_i] = +arr[_i];
149
+ for (let j = 0; j < length; j++) {
150
+ result[j] = +arr[j];
103
151
  }
104
152
 
105
153
  return result;
@@ -110,12 +158,12 @@ function toNumberArray(arr) {
110
158
  }
111
159
 
112
160
  var PDFFunction = function PDFFunctionClosure() {
113
- var CONSTRUCT_SAMPLED = 0;
114
- var CONSTRUCT_INTERPOLATED = 2;
115
- var CONSTRUCT_STICHED = 3;
116
- var CONSTRUCT_POSTSCRIPT = 4;
161
+ const CONSTRUCT_SAMPLED = 0;
162
+ const CONSTRUCT_INTERPOLATED = 2;
163
+ const CONSTRUCT_STICHED = 3;
164
+ const CONSTRUCT_POSTSCRIPT = 4;
117
165
  return {
118
- getSampleArray: function getSampleArray(size, outputSize, bps, stream) {
166
+ getSampleArray(size, outputSize, bps, stream) {
119
167
  var i, ii;
120
168
  var length = 1;
121
169
 
@@ -127,7 +175,7 @@ var PDFFunction = function PDFFunctionClosure() {
127
175
  var array = new Array(length);
128
176
  var codeSize = 0;
129
177
  var codeBuf = 0;
130
- var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
178
+ var sampleMul = 1.0 / (2.0 ** bps - 1);
131
179
  var strBytes = stream.getBytes((length * bps + 7) / 8);
132
180
  var strIdx = 0;
133
181
 
@@ -145,10 +193,12 @@ var PDFFunction = function PDFFunctionClosure() {
145
193
 
146
194
  return array;
147
195
  },
148
- getIR: function getIR(_ref2) {
149
- var xref = _ref2.xref,
150
- isEvalSupported = _ref2.isEvalSupported,
151
- fn = _ref2.fn;
196
+
197
+ getIR({
198
+ xref,
199
+ isEvalSupported,
200
+ fn
201
+ }) {
152
202
  var dict = fn.dict;
153
203
 
154
204
  if (!dict) {
@@ -156,80 +206,85 @@ var PDFFunction = function PDFFunctionClosure() {
156
206
  }
157
207
 
158
208
  var types = [this.constructSampled, null, this.constructInterpolated, this.constructStiched, this.constructPostScript];
159
- var typeNum = dict.get('FunctionType');
209
+ var typeNum = dict.get("FunctionType");
160
210
  var typeFn = types[typeNum];
161
211
 
162
212
  if (!typeFn) {
163
- throw new _util.FormatError('Unknown type of function');
213
+ throw new _util.FormatError("Unknown type of function");
164
214
  }
165
215
 
166
216
  return typeFn.call(this, {
167
- xref: xref,
168
- isEvalSupported: isEvalSupported,
169
- fn: fn,
170
- dict: dict
217
+ xref,
218
+ isEvalSupported,
219
+ fn,
220
+ dict
171
221
  });
172
222
  },
173
- fromIR: function fromIR(_ref3) {
174
- var xref = _ref3.xref,
175
- isEvalSupported = _ref3.isEvalSupported,
176
- IR = _ref3.IR;
223
+
224
+ fromIR({
225
+ xref,
226
+ isEvalSupported,
227
+ IR
228
+ }) {
177
229
  var type = IR[0];
178
230
 
179
231
  switch (type) {
180
232
  case CONSTRUCT_SAMPLED:
181
233
  return this.constructSampledFromIR({
182
- xref: xref,
183
- isEvalSupported: isEvalSupported,
184
- IR: IR
234
+ xref,
235
+ isEvalSupported,
236
+ IR
185
237
  });
186
238
 
187
239
  case CONSTRUCT_INTERPOLATED:
188
240
  return this.constructInterpolatedFromIR({
189
- xref: xref,
190
- isEvalSupported: isEvalSupported,
191
- IR: IR
241
+ xref,
242
+ isEvalSupported,
243
+ IR
192
244
  });
193
245
 
194
246
  case CONSTRUCT_STICHED:
195
247
  return this.constructStichedFromIR({
196
- xref: xref,
197
- isEvalSupported: isEvalSupported,
198
- IR: IR
248
+ xref,
249
+ isEvalSupported,
250
+ IR
199
251
  });
200
252
 
201
253
  default:
202
254
  return this.constructPostScriptFromIR({
203
- xref: xref,
204
- isEvalSupported: isEvalSupported,
205
- IR: IR
255
+ xref,
256
+ isEvalSupported,
257
+ IR
206
258
  });
207
259
  }
208
260
  },
209
- parse: function parse(_ref4) {
210
- var xref = _ref4.xref,
211
- isEvalSupported = _ref4.isEvalSupported,
212
- fn = _ref4.fn;
213
- var IR = this.getIR({
214
- xref: xref,
215
- isEvalSupported: isEvalSupported,
216
- fn: fn
261
+
262
+ parse({
263
+ xref,
264
+ isEvalSupported,
265
+ fn
266
+ }) {
267
+ const IR = this.getIR({
268
+ xref,
269
+ isEvalSupported,
270
+ fn
217
271
  });
218
272
  return this.fromIR({
219
- xref: xref,
220
- isEvalSupported: isEvalSupported,
221
- IR: IR
273
+ xref,
274
+ isEvalSupported,
275
+ IR
222
276
  });
223
277
  },
224
- parseArray: function parseArray(_ref5) {
225
- var xref = _ref5.xref,
226
- isEvalSupported = _ref5.isEvalSupported,
227
- fnObj = _ref5.fnObj;
228
278
 
279
+ parseArray({
280
+ xref,
281
+ isEvalSupported,
282
+ fnObj
283
+ }) {
229
284
  if (!Array.isArray(fnObj)) {
230
285
  return this.parse({
231
- xref: xref,
232
- isEvalSupported: isEvalSupported,
286
+ xref,
287
+ isEvalSupported,
233
288
  fn: fnObj
234
289
  });
235
290
  }
@@ -238,8 +293,8 @@ var PDFFunction = function PDFFunctionClosure() {
238
293
 
239
294
  for (var j = 0, jj = fnObj.length; j < jj; j++) {
240
295
  fnArray.push(this.parse({
241
- xref: xref,
242
- isEvalSupported: isEvalSupported,
296
+ xref,
297
+ isEvalSupported,
243
298
  fn: xref.fetchIfRef(fnObj[j])
244
299
  }));
245
300
  }
@@ -250,12 +305,13 @@ var PDFFunction = function PDFFunctionClosure() {
250
305
  }
251
306
  };
252
307
  },
253
- constructSampled: function constructSampled(_ref6) {
254
- var xref = _ref6.xref,
255
- isEvalSupported = _ref6.isEvalSupported,
256
- fn = _ref6.fn,
257
- dict = _ref6.dict;
258
308
 
309
+ constructSampled({
310
+ xref,
311
+ isEvalSupported,
312
+ fn,
313
+ dict
314
+ }) {
259
315
  function toMultiArray(arr) {
260
316
  var inputLength = arr.length;
261
317
  var out = [];
@@ -269,26 +325,26 @@ var PDFFunction = function PDFFunctionClosure() {
269
325
  return out;
270
326
  }
271
327
 
272
- var domain = toNumberArray(dict.getArray('Domain'));
273
- var range = toNumberArray(dict.getArray('Range'));
328
+ var domain = toNumberArray(dict.getArray("Domain"));
329
+ var range = toNumberArray(dict.getArray("Range"));
274
330
 
275
331
  if (!domain || !range) {
276
- throw new _util.FormatError('No domain or range');
332
+ throw new _util.FormatError("No domain or range");
277
333
  }
278
334
 
279
335
  var inputSize = domain.length / 2;
280
336
  var outputSize = range.length / 2;
281
337
  domain = toMultiArray(domain);
282
338
  range = toMultiArray(range);
283
- var size = toNumberArray(dict.getArray('Size'));
284
- var bps = dict.get('BitsPerSample');
285
- var order = dict.get('Order') || 1;
339
+ var size = toNumberArray(dict.getArray("Size"));
340
+ var bps = dict.get("BitsPerSample");
341
+ var order = dict.get("Order") || 1;
286
342
 
287
343
  if (order !== 1) {
288
- (0, _util.info)('No support for cubic spline interpolation: ' + order);
344
+ (0, _util.info)("No support for cubic spline interpolation: " + order);
289
345
  }
290
346
 
291
- var encode = toNumberArray(dict.getArray('Encode'));
347
+ var encode = toNumberArray(dict.getArray("Encode"));
292
348
 
293
349
  if (!encode) {
294
350
  encode = [];
@@ -300,7 +356,7 @@ var PDFFunction = function PDFFunctionClosure() {
300
356
  encode = toMultiArray(encode);
301
357
  }
302
358
 
303
- var decode = toNumberArray(dict.getArray('Decode'));
359
+ var decode = toNumberArray(dict.getArray("Decode"));
304
360
 
305
361
  if (!decode) {
306
362
  decode = range;
@@ -309,13 +365,14 @@ var PDFFunction = function PDFFunctionClosure() {
309
365
  }
310
366
 
311
367
  var samples = this.getSampleArray(size, outputSize, bps, fn);
312
- return [CONSTRUCT_SAMPLED, inputSize, domain, encode, decode, samples, size, outputSize, Math.pow(2, bps) - 1, range];
368
+ return [CONSTRUCT_SAMPLED, inputSize, domain, encode, decode, samples, size, outputSize, 2 ** bps - 1, range];
313
369
  },
314
- constructSampledFromIR: function constructSampledFromIR(_ref7) {
315
- var xref = _ref7.xref,
316
- isEvalSupported = _ref7.isEvalSupported,
317
- IR = _ref7.IR;
318
370
 
371
+ constructSampledFromIR({
372
+ xref,
373
+ isEvalSupported,
374
+ IR
375
+ }) {
319
376
  function interpolate(x, xmin, xmax, ymin, ymax) {
320
377
  return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
321
378
  }
@@ -380,14 +437,16 @@ var PDFFunction = function PDFFunctionClosure() {
380
437
  }
381
438
  };
382
439
  },
383
- constructInterpolated: function constructInterpolated(_ref8) {
384
- var xref = _ref8.xref,
385
- isEvalSupported = _ref8.isEvalSupported,
386
- fn = _ref8.fn,
387
- dict = _ref8.dict;
388
- var c0 = toNumberArray(dict.getArray('C0')) || [0];
389
- var c1 = toNumberArray(dict.getArray('C1')) || [1];
390
- var n = dict.get('N');
440
+
441
+ constructInterpolated({
442
+ xref,
443
+ isEvalSupported,
444
+ fn,
445
+ dict
446
+ }) {
447
+ var c0 = toNumberArray(dict.getArray("C0")) || [0];
448
+ var c1 = toNumberArray(dict.getArray("C1")) || [1];
449
+ var n = dict.get("N");
391
450
  var length = c0.length;
392
451
  var diff = [];
393
452
 
@@ -397,58 +456,64 @@ var PDFFunction = function PDFFunctionClosure() {
397
456
 
398
457
  return [CONSTRUCT_INTERPOLATED, c0, diff, n];
399
458
  },
400
- constructInterpolatedFromIR: function constructInterpolatedFromIR(_ref9) {
401
- var xref = _ref9.xref,
402
- isEvalSupported = _ref9.isEvalSupported,
403
- IR = _ref9.IR;
459
+
460
+ constructInterpolatedFromIR({
461
+ xref,
462
+ isEvalSupported,
463
+ IR
464
+ }) {
404
465
  var c0 = IR[1];
405
466
  var diff = IR[2];
406
467
  var n = IR[3];
407
468
  var length = diff.length;
408
469
  return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
409
- var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
470
+ var x = n === 1 ? src[srcOffset] : src[srcOffset] ** n;
410
471
 
411
472
  for (var j = 0; j < length; ++j) {
412
473
  dest[destOffset + j] = c0[j] + x * diff[j];
413
474
  }
414
475
  };
415
476
  },
416
- constructStiched: function constructStiched(_ref10) {
417
- var xref = _ref10.xref,
418
- isEvalSupported = _ref10.isEvalSupported,
419
- fn = _ref10.fn,
420
- dict = _ref10.dict;
421
- var domain = toNumberArray(dict.getArray('Domain'));
477
+
478
+ constructStiched({
479
+ xref,
480
+ isEvalSupported,
481
+ fn,
482
+ dict
483
+ }) {
484
+ var domain = toNumberArray(dict.getArray("Domain"));
422
485
 
423
486
  if (!domain) {
424
- throw new _util.FormatError('No domain');
487
+ throw new _util.FormatError("No domain");
425
488
  }
426
489
 
427
490
  var inputSize = domain.length / 2;
428
491
 
429
492
  if (inputSize !== 1) {
430
- throw new _util.FormatError('Bad domain for stiched function');
493
+ throw new _util.FormatError("Bad domain for stiched function");
431
494
  }
432
495
 
433
- var fnRefs = dict.get('Functions');
496
+ var fnRefs = dict.get("Functions");
434
497
  var fns = [];
435
498
 
436
499
  for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
437
500
  fns.push(this.parse({
438
- xref: xref,
439
- isEvalSupported: isEvalSupported,
501
+ xref,
502
+ isEvalSupported,
440
503
  fn: xref.fetchIfRef(fnRefs[i])
441
504
  }));
442
505
  }
443
506
 
444
- var bounds = toNumberArray(dict.getArray('Bounds'));
445
- var encode = toNumberArray(dict.getArray('Encode'));
507
+ var bounds = toNumberArray(dict.getArray("Bounds"));
508
+ var encode = toNumberArray(dict.getArray("Encode"));
446
509
  return [CONSTRUCT_STICHED, domain, bounds, encode, fns];
447
510
  },
448
- constructStichedFromIR: function constructStichedFromIR(_ref11) {
449
- var xref = _ref11.xref,
450
- isEvalSupported = _ref11.isEvalSupported,
451
- IR = _ref11.IR;
511
+
512
+ constructStichedFromIR({
513
+ xref,
514
+ isEvalSupported,
515
+ IR
516
+ }) {
452
517
  var domain = IR[1];
453
518
  var bounds = IR[2];
454
519
  var encode = IR[3];
@@ -491,20 +556,22 @@ var PDFFunction = function PDFFunctionClosure() {
491
556
  fns[i](tmpBuf, 0, dest, destOffset);
492
557
  };
493
558
  },
494
- constructPostScript: function constructPostScript(_ref12) {
495
- var xref = _ref12.xref,
496
- isEvalSupported = _ref12.isEvalSupported,
497
- fn = _ref12.fn,
498
- dict = _ref12.dict;
499
- var domain = toNumberArray(dict.getArray('Domain'));
500
- var range = toNumberArray(dict.getArray('Range'));
559
+
560
+ constructPostScript({
561
+ xref,
562
+ isEvalSupported,
563
+ fn,
564
+ dict
565
+ }) {
566
+ var domain = toNumberArray(dict.getArray("Domain"));
567
+ var range = toNumberArray(dict.getArray("Range"));
501
568
 
502
569
  if (!domain) {
503
- throw new _util.FormatError('No domain.');
570
+ throw new _util.FormatError("No domain.");
504
571
  }
505
572
 
506
573
  if (!range) {
507
- throw new _util.FormatError('No range.');
574
+ throw new _util.FormatError("No range.");
508
575
  }
509
576
 
510
577
  var lexer = new _ps_parser.PostScriptLexer(fn);
@@ -512,23 +579,25 @@ var PDFFunction = function PDFFunctionClosure() {
512
579
  var code = parser.parse();
513
580
  return [CONSTRUCT_POSTSCRIPT, domain, range, code];
514
581
  },
515
- constructPostScriptFromIR: function constructPostScriptFromIR(_ref13) {
516
- var xref = _ref13.xref,
517
- isEvalSupported = _ref13.isEvalSupported,
518
- IR = _ref13.IR;
582
+
583
+ constructPostScriptFromIR({
584
+ xref,
585
+ isEvalSupported,
586
+ IR
587
+ }) {
519
588
  var domain = IR[1];
520
589
  var range = IR[2];
521
590
  var code = IR[3];
522
591
 
523
- if (isEvalSupported && IsEvalSupportedCached.value) {
524
- var compiled = new PostScriptCompiler().compile(code, domain, range);
592
+ if (isEvalSupported && _util.IsEvalSupportedCached.value) {
593
+ const compiled = new PostScriptCompiler().compile(code, domain, range);
525
594
 
526
595
  if (compiled) {
527
- return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
596
+ return new Function("src", "srcOffset", "dest", "destOffset", compiled);
528
597
  }
529
598
  }
530
599
 
531
- (0, _util.info)('Unable to compile PS function');
600
+ (0, _util.info)("Unable to compile PS function");
532
601
  var numOutputs = range.length >> 1;
533
602
  var numInputs = domain.length >> 1;
534
603
  var evaluator = new PostScriptEvaluator(code);
@@ -538,13 +607,13 @@ var PDFFunction = function PDFFunctionClosure() {
538
607
  var tmpBuf = new Float32Array(numInputs);
539
608
  return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
540
609
  var i, value;
541
- var key = '';
610
+ var key = "";
542
611
  var input = tmpBuf;
543
612
 
544
613
  for (i = 0; i < numInputs; i++) {
545
614
  value = src[srcOffset + i];
546
615
  input[i] = value;
547
- key += value + '_';
616
+ key += value + "_";
548
617
  }
549
618
 
550
619
  var cachedValue = cache[key];
@@ -583,13 +652,14 @@ var PDFFunction = function PDFFunctionClosure() {
583
652
  dest.set(output, destOffset);
584
653
  };
585
654
  }
655
+
586
656
  };
587
657
  }();
588
658
 
589
659
  function isPDFFunction(v) {
590
660
  var fnDict;
591
661
 
592
- if (_typeof(v) !== 'object') {
662
+ if (typeof v !== "object") {
593
663
  return false;
594
664
  } else if ((0, _primitives.isDict)(v)) {
595
665
  fnDict = v;
@@ -599,7 +669,7 @@ function isPDFFunction(v) {
599
669
  return false;
600
670
  }
601
671
 
602
- return fnDict.has('FunctionType');
672
+ return fnDict.has("FunctionType");
603
673
  }
604
674
 
605
675
  var PostScriptStack = function PostScriptStackClosure() {
@@ -612,21 +682,21 @@ var PostScriptStack = function PostScriptStackClosure() {
612
682
  PostScriptStack.prototype = {
613
683
  push: function PostScriptStack_push(value) {
614
684
  if (this.stack.length >= MAX_STACK_SIZE) {
615
- throw new Error('PostScript function stack overflow.');
685
+ throw new Error("PostScript function stack overflow.");
616
686
  }
617
687
 
618
688
  this.stack.push(value);
619
689
  },
620
690
  pop: function PostScriptStack_pop() {
621
691
  if (this.stack.length <= 0) {
622
- throw new Error('PostScript function stack underflow.');
692
+ throw new Error("PostScript function stack underflow.");
623
693
  }
624
694
 
625
695
  return this.stack.pop();
626
696
  },
627
697
  copy: function PostScriptStack_copy(n) {
628
698
  if (this.stack.length + n >= MAX_STACK_SIZE) {
629
- throw new Error('PostScript function stack overflow.');
699
+ throw new Error("PostScript function stack overflow.");
630
700
  }
631
701
 
632
702
  var stack = this.stack;
@@ -685,13 +755,13 @@ var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
685
755
  while (counter < length) {
686
756
  operator = operators[counter++];
687
757
 
688
- if (typeof operator === 'number') {
758
+ if (typeof operator === "number") {
689
759
  stack.push(operator);
690
760
  continue;
691
761
  }
692
762
 
693
763
  switch (operator) {
694
- case 'jz':
764
+ case "jz":
695
765
  b = stack.pop();
696
766
  a = stack.pop();
697
767
 
@@ -701,23 +771,23 @@ var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
701
771
 
702
772
  break;
703
773
 
704
- case 'j':
774
+ case "j":
705
775
  a = stack.pop();
706
776
  counter = a;
707
777
  break;
708
778
 
709
- case 'abs':
779
+ case "abs":
710
780
  a = stack.pop();
711
781
  stack.push(Math.abs(a));
712
782
  break;
713
783
 
714
- case 'add':
784
+ case "add":
715
785
  b = stack.pop();
716
786
  a = stack.pop();
717
787
  stack.push(a + b);
718
788
  break;
719
789
 
720
- case 'and':
790
+ case "and":
721
791
  b = stack.pop();
722
792
  a = stack.pop();
723
793
 
@@ -729,12 +799,12 @@ var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
729
799
 
730
800
  break;
731
801
 
732
- case 'atan':
802
+ case "atan":
733
803
  a = stack.pop();
734
804
  stack.push(Math.atan(a));
735
805
  break;
736
806
 
737
- case 'bitshift':
807
+ case "bitshift":
738
808
  b = stack.pop();
739
809
  a = stack.pop();
740
810
 
@@ -746,133 +816,133 @@ var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
746
816
 
747
817
  break;
748
818
 
749
- case 'ceiling':
819
+ case "ceiling":
750
820
  a = stack.pop();
751
821
  stack.push(Math.ceil(a));
752
822
  break;
753
823
 
754
- case 'copy':
824
+ case "copy":
755
825
  a = stack.pop();
756
826
  stack.copy(a);
757
827
  break;
758
828
 
759
- case 'cos':
829
+ case "cos":
760
830
  a = stack.pop();
761
831
  stack.push(Math.cos(a));
762
832
  break;
763
833
 
764
- case 'cvi':
834
+ case "cvi":
765
835
  a = stack.pop() | 0;
766
836
  stack.push(a);
767
837
  break;
768
838
 
769
- case 'cvr':
839
+ case "cvr":
770
840
  break;
771
841
 
772
- case 'div':
842
+ case "div":
773
843
  b = stack.pop();
774
844
  a = stack.pop();
775
845
  stack.push(a / b);
776
846
  break;
777
847
 
778
- case 'dup':
848
+ case "dup":
779
849
  stack.copy(1);
780
850
  break;
781
851
 
782
- case 'eq':
852
+ case "eq":
783
853
  b = stack.pop();
784
854
  a = stack.pop();
785
855
  stack.push(a === b);
786
856
  break;
787
857
 
788
- case 'exch':
858
+ case "exch":
789
859
  stack.roll(2, 1);
790
860
  break;
791
861
 
792
- case 'exp':
862
+ case "exp":
793
863
  b = stack.pop();
794
864
  a = stack.pop();
795
- stack.push(Math.pow(a, b));
865
+ stack.push(a ** b);
796
866
  break;
797
867
 
798
- case 'false':
868
+ case "false":
799
869
  stack.push(false);
800
870
  break;
801
871
 
802
- case 'floor':
872
+ case "floor":
803
873
  a = stack.pop();
804
874
  stack.push(Math.floor(a));
805
875
  break;
806
876
 
807
- case 'ge':
877
+ case "ge":
808
878
  b = stack.pop();
809
879
  a = stack.pop();
810
880
  stack.push(a >= b);
811
881
  break;
812
882
 
813
- case 'gt':
883
+ case "gt":
814
884
  b = stack.pop();
815
885
  a = stack.pop();
816
886
  stack.push(a > b);
817
887
  break;
818
888
 
819
- case 'idiv':
889
+ case "idiv":
820
890
  b = stack.pop();
821
891
  a = stack.pop();
822
892
  stack.push(a / b | 0);
823
893
  break;
824
894
 
825
- case 'index':
895
+ case "index":
826
896
  a = stack.pop();
827
897
  stack.index(a);
828
898
  break;
829
899
 
830
- case 'le':
900
+ case "le":
831
901
  b = stack.pop();
832
902
  a = stack.pop();
833
903
  stack.push(a <= b);
834
904
  break;
835
905
 
836
- case 'ln':
906
+ case "ln":
837
907
  a = stack.pop();
838
908
  stack.push(Math.log(a));
839
909
  break;
840
910
 
841
- case 'log':
911
+ case "log":
842
912
  a = stack.pop();
843
913
  stack.push(Math.log(a) / Math.LN10);
844
914
  break;
845
915
 
846
- case 'lt':
916
+ case "lt":
847
917
  b = stack.pop();
848
918
  a = stack.pop();
849
919
  stack.push(a < b);
850
920
  break;
851
921
 
852
- case 'mod':
922
+ case "mod":
853
923
  b = stack.pop();
854
924
  a = stack.pop();
855
925
  stack.push(a % b);
856
926
  break;
857
927
 
858
- case 'mul':
928
+ case "mul":
859
929
  b = stack.pop();
860
930
  a = stack.pop();
861
931
  stack.push(a * b);
862
932
  break;
863
933
 
864
- case 'ne':
934
+ case "ne":
865
935
  b = stack.pop();
866
936
  a = stack.pop();
867
937
  stack.push(a !== b);
868
938
  break;
869
939
 
870
- case 'neg':
940
+ case "neg":
871
941
  a = stack.pop();
872
942
  stack.push(-a);
873
943
  break;
874
944
 
875
- case 'not':
945
+ case "not":
876
946
  a = stack.pop();
877
947
 
878
948
  if ((0, _util.isBool)(a)) {
@@ -883,7 +953,7 @@ var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
883
953
 
884
954
  break;
885
955
 
886
- case 'or':
956
+ case "or":
887
957
  b = stack.pop();
888
958
  a = stack.pop();
889
959
 
@@ -895,48 +965,48 @@ var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
895
965
 
896
966
  break;
897
967
 
898
- case 'pop':
968
+ case "pop":
899
969
  stack.pop();
900
970
  break;
901
971
 
902
- case 'roll':
972
+ case "roll":
903
973
  b = stack.pop();
904
974
  a = stack.pop();
905
975
  stack.roll(a, b);
906
976
  break;
907
977
 
908
- case 'round':
978
+ case "round":
909
979
  a = stack.pop();
910
980
  stack.push(Math.round(a));
911
981
  break;
912
982
 
913
- case 'sin':
983
+ case "sin":
914
984
  a = stack.pop();
915
985
  stack.push(Math.sin(a));
916
986
  break;
917
987
 
918
- case 'sqrt':
988
+ case "sqrt":
919
989
  a = stack.pop();
920
990
  stack.push(Math.sqrt(a));
921
991
  break;
922
992
 
923
- case 'sub':
993
+ case "sub":
924
994
  b = stack.pop();
925
995
  a = stack.pop();
926
996
  stack.push(a - b);
927
997
  break;
928
998
 
929
- case 'true':
999
+ case "true":
930
1000
  stack.push(true);
931
1001
  break;
932
1002
 
933
- case 'truncate':
1003
+ case "truncate":
934
1004
  a = stack.pop();
935
1005
  a = a < 0 ? Math.ceil(a) : Math.floor(a);
936
1006
  stack.push(a);
937
1007
  break;
938
1008
 
939
- case 'xor':
1009
+ case "xor":
940
1010
  b = stack.pop();
941
1011
  a = stack.pop();
942
1012
 
@@ -949,7 +1019,7 @@ var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
949
1019
  break;
950
1020
 
951
1021
  default:
952
- throw new _util.FormatError("Unknown operator ".concat(operator));
1022
+ throw new _util.FormatError(`Unknown operator ${operator}`);
953
1023
  }
954
1024
  }
955
1025
 
@@ -967,11 +1037,11 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
967
1037
  }
968
1038
 
969
1039
  AstNode.prototype.visit = function (visitor) {
970
- (0, _util.unreachable)('abstract method');
1040
+ (0, _util.unreachable)("abstract method");
971
1041
  };
972
1042
 
973
1043
  function AstArgument(index, min, max) {
974
- AstNode.call(this, 'args');
1044
+ AstNode.call(this, "args");
975
1045
  this.index = index;
976
1046
  this.min = min;
977
1047
  this.max = max;
@@ -984,7 +1054,7 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
984
1054
  };
985
1055
 
986
1056
  function AstLiteral(number) {
987
- AstNode.call(this, 'literal');
1057
+ AstNode.call(this, "literal");
988
1058
  this.number = number;
989
1059
  this.min = number;
990
1060
  this.max = number;
@@ -997,7 +1067,7 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
997
1067
  };
998
1068
 
999
1069
  function AstBinaryOperation(op, arg1, arg2, min, max) {
1000
- AstNode.call(this, 'binary');
1070
+ AstNode.call(this, "binary");
1001
1071
  this.op = op;
1002
1072
  this.arg1 = arg1;
1003
1073
  this.arg2 = arg2;
@@ -1012,7 +1082,7 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1012
1082
  };
1013
1083
 
1014
1084
  function AstMin(arg, max) {
1015
- AstNode.call(this, 'max');
1085
+ AstNode.call(this, "max");
1016
1086
  this.arg = arg;
1017
1087
  this.min = arg.min;
1018
1088
  this.max = max;
@@ -1025,7 +1095,7 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1025
1095
  };
1026
1096
 
1027
1097
  function AstVariable(index, min, max) {
1028
- AstNode.call(this, 'var');
1098
+ AstNode.call(this, "var");
1029
1099
  this.index = index;
1030
1100
  this.min = min;
1031
1101
  this.max = max;
@@ -1038,7 +1108,7 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1038
1108
  };
1039
1109
 
1040
1110
  function AstVariableDefinition(variable, arg) {
1041
- AstNode.call(this, 'definition');
1111
+ AstNode.call(this, "definition");
1042
1112
  this.variable = variable;
1043
1113
  this.arg = arg;
1044
1114
  }
@@ -1054,67 +1124,74 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1054
1124
  }
1055
1125
 
1056
1126
  ExpressionBuilderVisitor.prototype = {
1057
- visitArgument: function visitArgument(arg) {
1058
- this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
1127
+ visitArgument(arg) {
1128
+ this.parts.push("Math.max(", arg.min, ", Math.min(", arg.max, ", src[srcOffset + ", arg.index, "]))");
1059
1129
  },
1060
- visitVariable: function visitVariable(variable) {
1061
- this.parts.push('v', variable.index);
1130
+
1131
+ visitVariable(variable) {
1132
+ this.parts.push("v", variable.index);
1062
1133
  },
1063
- visitLiteral: function visitLiteral(literal) {
1134
+
1135
+ visitLiteral(literal) {
1064
1136
  this.parts.push(literal.number);
1065
1137
  },
1066
- visitBinaryOperation: function visitBinaryOperation(operation) {
1067
- this.parts.push('(');
1138
+
1139
+ visitBinaryOperation(operation) {
1140
+ this.parts.push("(");
1068
1141
  operation.arg1.visit(this);
1069
- this.parts.push(' ', operation.op, ' ');
1142
+ this.parts.push(" ", operation.op, " ");
1070
1143
  operation.arg2.visit(this);
1071
- this.parts.push(')');
1144
+ this.parts.push(")");
1072
1145
  },
1073
- visitVariableDefinition: function visitVariableDefinition(definition) {
1074
- this.parts.push('var ');
1146
+
1147
+ visitVariableDefinition(definition) {
1148
+ this.parts.push("var ");
1075
1149
  definition.variable.visit(this);
1076
- this.parts.push(' = ');
1150
+ this.parts.push(" = ");
1077
1151
  definition.arg.visit(this);
1078
- this.parts.push(';');
1152
+ this.parts.push(";");
1079
1153
  },
1080
- visitMin: function visitMin(max) {
1081
- this.parts.push('Math.min(');
1154
+
1155
+ visitMin(max) {
1156
+ this.parts.push("Math.min(");
1082
1157
  max.arg.visit(this);
1083
- this.parts.push(', ', max.max, ')');
1158
+ this.parts.push(", ", max.max, ")");
1084
1159
  },
1085
- toString: function toString() {
1086
- return this.parts.join('');
1160
+
1161
+ toString() {
1162
+ return this.parts.join("");
1087
1163
  }
1164
+
1088
1165
  };
1089
1166
 
1090
1167
  function buildAddOperation(num1, num2) {
1091
- if (num2.type === 'literal' && num2.number === 0) {
1168
+ if (num2.type === "literal" && num2.number === 0) {
1092
1169
  return num1;
1093
1170
  }
1094
1171
 
1095
- if (num1.type === 'literal' && num1.number === 0) {
1172
+ if (num1.type === "literal" && num1.number === 0) {
1096
1173
  return num2;
1097
1174
  }
1098
1175
 
1099
- if (num2.type === 'literal' && num1.type === 'literal') {
1176
+ if (num2.type === "literal" && num1.type === "literal") {
1100
1177
  return new AstLiteral(num1.number + num2.number);
1101
1178
  }
1102
1179
 
1103
- return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
1180
+ return new AstBinaryOperation("+", num1, num2, num1.min + num2.min, num1.max + num2.max);
1104
1181
  }
1105
1182
 
1106
1183
  function buildMulOperation(num1, num2) {
1107
- if (num2.type === 'literal') {
1184
+ if (num2.type === "literal") {
1108
1185
  if (num2.number === 0) {
1109
1186
  return new AstLiteral(0);
1110
1187
  } else if (num2.number === 1) {
1111
1188
  return num1;
1112
- } else if (num1.type === 'literal') {
1189
+ } else if (num1.type === "literal") {
1113
1190
  return new AstLiteral(num1.number * num2.number);
1114
1191
  }
1115
1192
  }
1116
1193
 
1117
- if (num1.type === 'literal') {
1194
+ if (num1.type === "literal") {
1118
1195
  if (num1.number === 0) {
1119
1196
  return new AstLiteral(0);
1120
1197
  } else if (num1.number === 1) {
@@ -1124,23 +1201,23 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1124
1201
 
1125
1202
  var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
1126
1203
  var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
1127
- return new AstBinaryOperation('*', num1, num2, min, max);
1204
+ return new AstBinaryOperation("*", num1, num2, min, max);
1128
1205
  }
1129
1206
 
1130
1207
  function buildSubOperation(num1, num2) {
1131
- if (num2.type === 'literal') {
1208
+ if (num2.type === "literal") {
1132
1209
  if (num2.number === 0) {
1133
1210
  return num1;
1134
- } else if (num1.type === 'literal') {
1211
+ } else if (num1.type === "literal") {
1135
1212
  return new AstLiteral(num1.number - num2.number);
1136
1213
  }
1137
1214
  }
1138
1215
 
1139
- if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
1216
+ if (num2.type === "binary" && num2.op === "-" && num1.type === "literal" && num1.number === 1 && num2.arg1.type === "literal" && num2.arg1.number === 1) {
1140
1217
  return num2.arg2;
1141
1218
  }
1142
1219
 
1143
- return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
1220
+ return new AstBinaryOperation("-", num1, num2, num1.min - num2.max, num1.max - num2.min);
1144
1221
  }
1145
1222
 
1146
1223
  function buildMinOperation(num1, max) {
@@ -1158,7 +1235,6 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1158
1235
  PostScriptCompiler.prototype = {
1159
1236
  compile: function PostScriptCompiler_compile(code, domain, range) {
1160
1237
  var stack = [];
1161
- var i, ii;
1162
1238
  var instructions = [];
1163
1239
  var inputSize = domain.length >> 1,
1164
1240
  outputSize = range.length >> 1;
@@ -1166,20 +1242,20 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1166
1242
  var n, j;
1167
1243
  var num1, num2, ast1, ast2, tmpVar, item;
1168
1244
 
1169
- for (i = 0; i < inputSize; i++) {
1245
+ for (let i = 0; i < inputSize; i++) {
1170
1246
  stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
1171
1247
  }
1172
1248
 
1173
- for (i = 0, ii = code.length; i < ii; i++) {
1249
+ for (let i = 0, ii = code.length; i < ii; i++) {
1174
1250
  item = code[i];
1175
1251
 
1176
- if (typeof item === 'number') {
1252
+ if (typeof item === "number") {
1177
1253
  stack.push(new AstLiteral(item));
1178
1254
  continue;
1179
1255
  }
1180
1256
 
1181
1257
  switch (item) {
1182
- case 'add':
1258
+ case "add":
1183
1259
  if (stack.length < 2) {
1184
1260
  return null;
1185
1261
  }
@@ -1189,14 +1265,14 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1189
1265
  stack.push(buildAddOperation(num1, num2));
1190
1266
  break;
1191
1267
 
1192
- case 'cvr':
1268
+ case "cvr":
1193
1269
  if (stack.length < 1) {
1194
1270
  return null;
1195
1271
  }
1196
1272
 
1197
1273
  break;
1198
1274
 
1199
- case 'mul':
1275
+ case "mul":
1200
1276
  if (stack.length < 2) {
1201
1277
  return null;
1202
1278
  }
@@ -1206,7 +1282,7 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1206
1282
  stack.push(buildMulOperation(num1, num2));
1207
1283
  break;
1208
1284
 
1209
- case 'sub':
1285
+ case "sub":
1210
1286
  if (stack.length < 2) {
1211
1287
  return null;
1212
1288
  }
@@ -1216,7 +1292,7 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1216
1292
  stack.push(buildSubOperation(num1, num2));
1217
1293
  break;
1218
1294
 
1219
- case 'exch':
1295
+ case "exch":
1220
1296
  if (stack.length < 2) {
1221
1297
  return null;
1222
1298
  }
@@ -1226,7 +1302,7 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1226
1302
  stack.push(ast1, ast2);
1227
1303
  break;
1228
1304
 
1229
- case 'pop':
1305
+ case "pop":
1230
1306
  if (stack.length < 1) {
1231
1307
  return null;
1232
1308
  }
@@ -1234,14 +1310,14 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1234
1310
  stack.pop();
1235
1311
  break;
1236
1312
 
1237
- case 'index':
1313
+ case "index":
1238
1314
  if (stack.length < 1) {
1239
1315
  return null;
1240
1316
  }
1241
1317
 
1242
1318
  num1 = stack.pop();
1243
1319
 
1244
- if (num1.type !== 'literal') {
1320
+ if (num1.type !== "literal") {
1245
1321
  return null;
1246
1322
  }
1247
1323
 
@@ -1253,7 +1329,7 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1253
1329
 
1254
1330
  ast1 = stack[stack.length - n - 1];
1255
1331
 
1256
- if (ast1.type === 'literal' || ast1.type === 'var') {
1332
+ if (ast1.type === "literal" || ast1.type === "var") {
1257
1333
  stack.push(ast1);
1258
1334
  break;
1259
1335
  }
@@ -1264,12 +1340,12 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1264
1340
  instructions.push(new AstVariableDefinition(tmpVar, ast1));
1265
1341
  break;
1266
1342
 
1267
- case 'dup':
1343
+ case "dup":
1268
1344
  if (stack.length < 1) {
1269
1345
  return null;
1270
1346
  }
1271
1347
 
1272
- if (typeof code[i + 1] === 'number' && code[i + 2] === 'gt' && code[i + 3] === i + 7 && code[i + 4] === 'jz' && code[i + 5] === 'pop' && code[i + 6] === code[i + 1]) {
1348
+ if (typeof code[i + 1] === "number" && code[i + 2] === "gt" && code[i + 3] === i + 7 && code[i + 4] === "jz" && code[i + 5] === "pop" && code[i + 6] === code[i + 1]) {
1273
1349
  num1 = stack.pop();
1274
1350
  stack.push(buildMinOperation(num1, code[i + 1]));
1275
1351
  i += 6;
@@ -1278,7 +1354,7 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1278
1354
 
1279
1355
  ast1 = stack[stack.length - 1];
1280
1356
 
1281
- if (ast1.type === 'literal' || ast1.type === 'var') {
1357
+ if (ast1.type === "literal" || ast1.type === "var") {
1282
1358
  stack.push(ast1);
1283
1359
  break;
1284
1360
  }
@@ -1289,7 +1365,7 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1289
1365
  instructions.push(new AstVariableDefinition(tmpVar, ast1));
1290
1366
  break;
1291
1367
 
1292
- case 'roll':
1368
+ case "roll":
1293
1369
  if (stack.length < 2) {
1294
1370
  return null;
1295
1371
  }
@@ -1297,7 +1373,7 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1297
1373
  num2 = stack.pop();
1298
1374
  num1 = stack.pop();
1299
1375
 
1300
- if (num2.type !== 'literal' || num1.type !== 'literal') {
1376
+ if (num2.type !== "literal" || num1.type !== "literal") {
1301
1377
  return null;
1302
1378
  }
1303
1379
 
@@ -1340,20 +1416,20 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
1340
1416
  var out = [statementBuilder.toString()];
1341
1417
 
1342
1418
  if (min > expr.min) {
1343
- out.unshift('Math.max(', min, ', ');
1344
- out.push(')');
1419
+ out.unshift("Math.max(", min, ", ");
1420
+ out.push(")");
1345
1421
  }
1346
1422
 
1347
1423
  if (max < expr.max) {
1348
- out.unshift('Math.min(', max, ', ');
1349
- out.push(')');
1424
+ out.unshift("Math.min(", max, ", ");
1425
+ out.push(")");
1350
1426
  }
1351
1427
 
1352
- out.unshift('dest[destOffset + ', i, '] = ');
1353
- out.push(';');
1354
- result.push(out.join(''));
1428
+ out.unshift("dest[destOffset + ", i, "] = ");
1429
+ out.push(";");
1430
+ result.push(out.join(""));
1355
1431
  });
1356
- return result.join('\n');
1432
+ return result.join("\n");
1357
1433
  }
1358
1434
  };
1359
1435
  return PostScriptCompiler;