@vaadin-component-factory/vcf-pdf-viewer 0.9.0 → 1.0.0

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.
Files changed (172) hide show
  1. package/README.md +1 -1
  2. package/package.json +42 -26
  3. package/{src/display → pdfjs/dist}/display_utils.js +344 -139
  4. package/{src/display → pdfjs/dist}/fetch_stream.js +115 -97
  5. package/pdfjs/dist/l10n_utils.js +140 -0
  6. package/{src/shared → pdfjs/dist}/message_handler.js +243 -259
  7. package/{src/display → pdfjs/dist}/network.js +149 -87
  8. package/{src/display/content_disposition.js → pdfjs/dist/network_utils.js} +167 -55
  9. package/{src/display → pdfjs/dist}/node_stream.js +133 -98
  10. package/pdfjs/dist/pdf.js +12778 -0
  11. package/pdfjs/dist/pdf_link_service.js +638 -0
  12. package/pdfjs/dist/pdf_rendering_queue.js +199 -0
  13. package/pdfjs/dist/pdf_thumbnail_viewer.js +819 -0
  14. package/pdfjs/dist/pdf_viewer.js +3598 -0
  15. package/pdfjs/dist/ui_utils.js +1033 -0
  16. package/{src/shared → pdfjs/dist}/util.js +301 -287
  17. package/pdfjs/dist/worker.js +62813 -0
  18. package/src/vcf-pdf-viewer.js +98 -46
  19. package/theme/lumo/vcf-pdf-viewer-styles.js +4 -4
  20. package/theme/material/vcf-pdf-viewer-styles.js +4 -4
  21. package/theme/material/vcf-pdf-viewer.js +2 -2
  22. package/src/core/.eslintrc +0 -13
  23. package/src/core/annotation.js +0 -2948
  24. package/src/core/arithmetic_decoder.js +0 -182
  25. package/src/core/ascii_85_stream.js +0 -98
  26. package/src/core/ascii_hex_stream.js +0 -79
  27. package/src/core/base_stream.js +0 -110
  28. package/src/core/bidi.js +0 -438
  29. package/src/core/calibri_factors.js +0 -308
  30. package/src/core/catalog.js +0 -1459
  31. package/src/core/ccitt.js +0 -1062
  32. package/src/core/ccitt_stream.js +0 -60
  33. package/src/core/cff_font.js +0 -116
  34. package/src/core/cff_parser.js +0 -1949
  35. package/src/core/charsets.js +0 -119
  36. package/src/core/chunked_stream.js +0 -557
  37. package/src/core/cmap.js +0 -1039
  38. package/src/core/colorspace.js +0 -1533
  39. package/src/core/core_utils.js +0 -464
  40. package/src/core/crypto.js +0 -1900
  41. package/src/core/decode_stream.js +0 -170
  42. package/src/core/decrypt_stream.js +0 -59
  43. package/src/core/default_appearance.js +0 -99
  44. package/src/core/document.js +0 -1456
  45. package/src/core/encodings.js +0 -301
  46. package/src/core/evaluator.js +0 -4601
  47. package/src/core/file_spec.js +0 -108
  48. package/src/core/flate_stream.js +0 -402
  49. package/src/core/font_renderer.js +0 -882
  50. package/src/core/fonts.js +0 -3260
  51. package/src/core/fonts_utils.js +0 -221
  52. package/src/core/function.js +0 -1257
  53. package/src/core/glyf.js +0 -706
  54. package/src/core/glyphlist.js +0 -4558
  55. package/src/core/helvetica_factors.js +0 -353
  56. package/src/core/image.js +0 -802
  57. package/src/core/image_utils.js +0 -291
  58. package/src/core/jbig2.js +0 -2572
  59. package/src/core/jbig2_stream.js +0 -73
  60. package/src/core/jpeg_stream.js +0 -105
  61. package/src/core/jpg.js +0 -1416
  62. package/src/core/jpx.js +0 -2343
  63. package/src/core/jpx_stream.js +0 -87
  64. package/src/core/liberationsans_widths.js +0 -221
  65. package/src/core/lzw_stream.js +0 -150
  66. package/src/core/metadata_parser.js +0 -146
  67. package/src/core/metrics.js +0 -2970
  68. package/src/core/murmurhash3.js +0 -139
  69. package/src/core/myriadpro_factors.js +0 -290
  70. package/src/core/name_number_tree.js +0 -153
  71. package/src/core/object_loader.js +0 -149
  72. package/src/core/opentype_file_builder.js +0 -154
  73. package/src/core/operator_list.js +0 -734
  74. package/src/core/parser.js +0 -1416
  75. package/src/core/pattern.js +0 -985
  76. package/src/core/pdf_manager.js +0 -217
  77. package/src/core/predictor_stream.js +0 -238
  78. package/src/core/primitives.js +0 -402
  79. package/src/core/ps_parser.js +0 -272
  80. package/src/core/run_length_stream.js +0 -61
  81. package/src/core/segoeui_factors.js +0 -308
  82. package/src/core/standard_fonts.js +0 -817
  83. package/src/core/stream.js +0 -103
  84. package/src/core/struct_tree.js +0 -335
  85. package/src/core/to_unicode_map.js +0 -103
  86. package/src/core/type1_font.js +0 -421
  87. package/src/core/type1_parser.js +0 -776
  88. package/src/core/unicode.js +0 -1649
  89. package/src/core/worker.js +0 -848
  90. package/src/core/worker_stream.js +0 -135
  91. package/src/core/writer.js +0 -278
  92. package/src/core/xfa/bind.js +0 -652
  93. package/src/core/xfa/builder.js +0 -207
  94. package/src/core/xfa/config.js +0 -1926
  95. package/src/core/xfa/connection_set.js +0 -202
  96. package/src/core/xfa/data.js +0 -82
  97. package/src/core/xfa/datasets.js +0 -76
  98. package/src/core/xfa/factory.js +0 -111
  99. package/src/core/xfa/fonts.js +0 -181
  100. package/src/core/xfa/formcalc_lexer.js +0 -385
  101. package/src/core/xfa/formcalc_parser.js +0 -1340
  102. package/src/core/xfa/html_utils.js +0 -639
  103. package/src/core/xfa/layout.js +0 -383
  104. package/src/core/xfa/locale_set.js +0 -345
  105. package/src/core/xfa/namespaces.js +0 -81
  106. package/src/core/xfa/parser.js +0 -184
  107. package/src/core/xfa/setup.js +0 -38
  108. package/src/core/xfa/signature.js +0 -40
  109. package/src/core/xfa/som.js +0 -338
  110. package/src/core/xfa/stylesheet.js +0 -40
  111. package/src/core/xfa/template.js +0 -6260
  112. package/src/core/xfa/text.js +0 -290
  113. package/src/core/xfa/unknown.js +0 -29
  114. package/src/core/xfa/utils.js +0 -217
  115. package/src/core/xfa/xdp.js +0 -59
  116. package/src/core/xfa/xfa_object.js +0 -1130
  117. package/src/core/xfa/xhtml.js +0 -543
  118. package/src/core/xfa_fonts.js +0 -208
  119. package/src/core/xml_parser.js +0 -507
  120. package/src/core/xref.js +0 -899
  121. package/src/display/annotation_layer.js +0 -2107
  122. package/src/display/annotation_storage.js +0 -113
  123. package/src/display/api.js +0 -3292
  124. package/src/display/base_factory.js +0 -180
  125. package/src/display/canvas.js +0 -2828
  126. package/src/display/font_loader.js +0 -484
  127. package/src/display/metadata.js +0 -41
  128. package/src/display/network_utils.js +0 -100
  129. package/src/display/node_utils.js +0 -83
  130. package/src/display/optional_content_config.js +0 -189
  131. package/src/display/pattern_helper.js +0 -659
  132. package/src/display/svg.js +0 -1709
  133. package/src/display/text_layer.js +0 -847
  134. package/src/display/transport_stream.js +0 -303
  135. package/src/display/worker_options.js +0 -40
  136. package/src/display/xfa_layer.js +0 -204
  137. package/src/doc_helper.js +0 -25
  138. package/src/images/logo.svg +0 -41
  139. package/src/interfaces.js +0 -169
  140. package/src/license_header.js +0 -14
  141. package/src/license_header_libre.js +0 -21
  142. package/src/pdf.image_decoders.js +0 -46
  143. package/src/pdf.js +0 -146
  144. package/src/pdf.sandbox.external.js +0 -181
  145. package/src/pdf.sandbox.js +0 -151
  146. package/src/pdf.scripting.js +0 -25
  147. package/src/pdf.worker.entry.js +0 -19
  148. package/src/pdf.worker.js +0 -23
  149. package/src/scripting_api/aform.js +0 -608
  150. package/src/scripting_api/app.js +0 -621
  151. package/src/scripting_api/color.js +0 -129
  152. package/src/scripting_api/common.js +0 -58
  153. package/src/scripting_api/console.js +0 -38
  154. package/src/scripting_api/constants.js +0 -208
  155. package/src/scripting_api/doc.js +0 -1195
  156. package/src/scripting_api/error.js +0 -23
  157. package/src/scripting_api/event.js +0 -232
  158. package/src/scripting_api/field.js +0 -620
  159. package/src/scripting_api/fullscreen.js +0 -145
  160. package/src/scripting_api/initialization.js +0 -223
  161. package/src/scripting_api/pdf_object.js +0 -24
  162. package/src/scripting_api/print_params.js +0 -146
  163. package/src/scripting_api/proxy.js +0 -139
  164. package/src/scripting_api/thermometer.js +0 -69
  165. package/src/scripting_api/util.js +0 -581
  166. package/src/shared/.eslintrc +0 -13
  167. package/src/shared/cffStandardStrings.js +0 -311
  168. package/src/shared/compatibility.js +0 -114
  169. package/src/shared/fonts_utils.js +0 -429
  170. package/src/shared/is_node.js +0 -27
  171. package/src/shared/scripting_utils.js +0 -85
  172. package/src/worker_loader.js +0 -32
@@ -1,69 +0,0 @@
1
- /* Copyright 2020 Mozilla Foundation
2
- *
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
-
16
- import { PDFObject } from "./pdf_object.js";
17
-
18
- class Thermometer extends PDFObject {
19
- constructor(data) {
20
- super(data);
21
-
22
- this._cancelled = false;
23
- this._duration = 100;
24
- this._text = "";
25
- this._value = 0;
26
- }
27
-
28
- get cancelled() {
29
- return this._cancelled;
30
- }
31
-
32
- set cancelled(_) {
33
- throw new Error("thermometer.cancelled is read-only");
34
- }
35
-
36
- get duration() {
37
- return this._duration;
38
- }
39
-
40
- set duration(val) {
41
- this._duration = val;
42
- }
43
-
44
- get text() {
45
- return this._text;
46
- }
47
-
48
- set text(val) {
49
- this._text = val;
50
- }
51
-
52
- get value() {
53
- return this._value;
54
- }
55
-
56
- set value(val) {
57
- this._value = val;
58
- }
59
-
60
- begin() {
61
- /* TODO */
62
- }
63
-
64
- end() {
65
- /* TODO */
66
- }
67
- }
68
-
69
- export { Thermometer };
@@ -1,581 +0,0 @@
1
- /* Copyright 2020 Mozilla Foundation
2
- *
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
-
16
- import { PDFObject } from "./pdf_object.js";
17
-
18
- class Util extends PDFObject {
19
- constructor(data) {
20
- super(data);
21
-
22
- this._scandCache = new Map();
23
- this._months = [
24
- "January",
25
- "February",
26
- "March",
27
- "April",
28
- "May",
29
- "June",
30
- "July",
31
- "August",
32
- "September",
33
- "October",
34
- "November",
35
- "December",
36
- ];
37
- this._days = [
38
- "Sunday",
39
- "Monday",
40
- "Tuesday",
41
- "Wednesday",
42
- "Thursday",
43
- "Friday",
44
- "Saturday",
45
- ];
46
- this.MILLISECONDS_IN_DAY = 86400000;
47
- this.MILLISECONDS_IN_WEEK = 604800000;
48
-
49
- // used with crackURL
50
- this._externalCall = data.externalCall;
51
- }
52
-
53
- printf(...args) {
54
- if (args.length === 0) {
55
- throw new Error("Invalid number of params in printf");
56
- }
57
-
58
- if (typeof args[0] !== "string") {
59
- throw new TypeError("First argument of printf must be a string");
60
- }
61
-
62
- const pattern = /%(,[0-4])?([+ 0#]+)?([0-9]+)?(\.[0-9]+)?(.)/g;
63
- const PLUS = 1;
64
- const SPACE = 2;
65
- const ZERO = 4;
66
- const HASH = 8;
67
- let i = 0;
68
- return args[0].replace(
69
- pattern,
70
- function (match, nDecSep, cFlags, nWidth, nPrecision, cConvChar) {
71
- // cConvChar must be one of d, f, s, x
72
- if (
73
- cConvChar !== "d" &&
74
- cConvChar !== "f" &&
75
- cConvChar !== "s" &&
76
- cConvChar !== "x"
77
- ) {
78
- const buf = ["%"];
79
- for (const str of [nDecSep, cFlags, nWidth, nPrecision, cConvChar]) {
80
- if (str) {
81
- buf.push(str);
82
- }
83
- }
84
- return buf.join("");
85
- }
86
-
87
- i++;
88
- if (i === args.length) {
89
- throw new Error("Not enough arguments in printf");
90
- }
91
- const arg = args[i];
92
-
93
- if (cConvChar === "s") {
94
- return arg.toString();
95
- }
96
-
97
- let flags = 0;
98
- if (cFlags) {
99
- for (const flag of cFlags) {
100
- switch (flag) {
101
- case "+":
102
- flags |= PLUS;
103
- break;
104
- case " ":
105
- flags |= SPACE;
106
- break;
107
- case "0":
108
- flags |= ZERO;
109
- break;
110
- case "#":
111
- flags |= HASH;
112
- break;
113
- }
114
- }
115
- }
116
- cFlags = flags;
117
-
118
- if (nWidth) {
119
- nWidth = parseInt(nWidth);
120
- }
121
-
122
- let intPart = Math.trunc(arg);
123
-
124
- if (cConvChar === "x") {
125
- let hex = Math.abs(intPart).toString(16).toUpperCase();
126
- if (nWidth !== undefined) {
127
- hex = hex.padStart(nWidth, cFlags & ZERO ? "0" : " ");
128
- }
129
- if (cFlags & HASH) {
130
- hex = `0x${hex}`;
131
- }
132
- return hex;
133
- }
134
-
135
- if (nPrecision) {
136
- nPrecision = parseInt(nPrecision.substring(1));
137
- }
138
-
139
- nDecSep = nDecSep ? nDecSep.substring(1) : "0";
140
- const separators = {
141
- 0: [",", "."],
142
- 1: ["", "."],
143
- 2: [".", ","],
144
- 3: ["", ","],
145
- 4: ["'", "."],
146
- };
147
- const [thousandSep, decimalSep] = separators[nDecSep];
148
-
149
- let decPart = "";
150
- if (cConvChar === "f") {
151
- if (nPrecision !== undefined) {
152
- decPart = Math.abs(arg - intPart).toFixed(nPrecision);
153
- } else {
154
- decPart = Math.abs(arg - intPart).toString();
155
- }
156
- if (decPart.length > 2) {
157
- decPart = `${decimalSep}${decPart.substring(2)}`;
158
- } else if (cFlags & HASH) {
159
- decPart = ".";
160
- } else {
161
- decPart = "";
162
- }
163
- }
164
-
165
- let sign = "";
166
- if (intPart < 0) {
167
- sign = "-";
168
- intPart = -intPart;
169
- } else if (cFlags & PLUS) {
170
- sign = "+";
171
- } else if (cFlags & SPACE) {
172
- sign = " ";
173
- }
174
-
175
- if (thousandSep && intPart >= 1000) {
176
- const buf = [];
177
- while (true) {
178
- buf.push((intPart % 1000).toString().padStart(3, "0"));
179
- intPart = Math.trunc(intPart / 1000);
180
- if (intPart < 1000) {
181
- buf.push(intPart.toString());
182
- break;
183
- }
184
- }
185
- intPart = buf.reverse().join(thousandSep);
186
- } else {
187
- intPart = intPart.toString();
188
- }
189
-
190
- let n = `${intPart}${decPart}`;
191
- if (nWidth !== undefined) {
192
- n = n.padStart(nWidth - sign.length, cFlags & ZERO ? "0" : " ");
193
- }
194
-
195
- return `${sign}${n}`;
196
- }
197
- );
198
- }
199
-
200
- iconStreamFromIcon() {
201
- /* Not implemented */
202
- }
203
-
204
- printd(cFormat, oDate) {
205
- switch (cFormat) {
206
- case 0:
207
- return this.printd("D:yyyymmddHHMMss", oDate);
208
- case 1:
209
- return this.printd("yyyy.mm.dd HH:MM:ss", oDate);
210
- case 2:
211
- return this.printd("m/d/yy h:MM:ss tt", oDate);
212
- }
213
-
214
- const handlers = {
215
- mmmm: data => {
216
- return this._months[data.month];
217
- },
218
- mmm: data => {
219
- return this._months[data.month].substring(0, 3);
220
- },
221
- mm: data => {
222
- return (data.month + 1).toString().padStart(2, "0");
223
- },
224
- m: data => {
225
- return (data.month + 1).toString();
226
- },
227
- dddd: data => {
228
- return this._days[data.dayOfWeek];
229
- },
230
- ddd: data => {
231
- return this._days[data.dayOfWeek].substring(0, 3);
232
- },
233
- dd: data => {
234
- return data.day.toString().padStart(2, "0");
235
- },
236
- d: data => {
237
- return data.day.toString();
238
- },
239
- yyyy: data => {
240
- return data.year.toString();
241
- },
242
- yy: data => {
243
- return (data.year % 100).toString().padStart(2, "0");
244
- },
245
- HH: data => {
246
- return data.hours.toString().padStart(2, "0");
247
- },
248
- H: data => {
249
- return data.hours.toString();
250
- },
251
- hh: data => {
252
- return (1 + ((data.hours + 11) % 12)).toString().padStart(2, "0");
253
- },
254
- h: data => {
255
- return (1 + ((data.hours + 11) % 12)).toString();
256
- },
257
- MM: data => {
258
- return data.minutes.toString().padStart(2, "0");
259
- },
260
- M: data => {
261
- return data.minutes.toString();
262
- },
263
- ss: data => {
264
- return data.seconds.toString().padStart(2, "0");
265
- },
266
- s: data => {
267
- return data.seconds.toString();
268
- },
269
- tt: data => {
270
- return data.hours < 12 ? "am" : "pm";
271
- },
272
- t: data => {
273
- return data.hours < 12 ? "a" : "p";
274
- },
275
- };
276
-
277
- const data = {
278
- year: oDate.getFullYear(),
279
- month: oDate.getMonth(),
280
- day: oDate.getDate(),
281
- dayOfWeek: oDate.getDay(),
282
- hours: oDate.getHours(),
283
- minutes: oDate.getMinutes(),
284
- seconds: oDate.getSeconds(),
285
- };
286
-
287
- const patterns =
288
- /(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t|\\.)/g;
289
- return cFormat.replace(patterns, function (match, pattern) {
290
- if (pattern in handlers) {
291
- return handlers[pattern](data);
292
- }
293
- return pattern.charCodeAt(1);
294
- });
295
- }
296
-
297
- printx(cFormat, cSource) {
298
- // case
299
- const handlers = [x => x, x => x.toUpperCase(), x => x.toLowerCase()];
300
- const buf = [];
301
- let i = 0;
302
- const ii = cSource.length;
303
- let currCase = handlers[0];
304
- let escaped = false;
305
-
306
- for (const command of cFormat) {
307
- if (escaped) {
308
- buf.push(command);
309
- escaped = false;
310
- continue;
311
- }
312
- if (i >= ii) {
313
- break;
314
- }
315
- switch (command) {
316
- case "?":
317
- buf.push(currCase(cSource.charAt(i++)));
318
- break;
319
- case "X":
320
- while (i < ii) {
321
- const char = cSource.charAt(i++);
322
- if (
323
- ("a" <= char && char <= "z") ||
324
- ("A" <= char && char <= "Z") ||
325
- ("0" <= char && char <= "9")
326
- ) {
327
- buf.push(currCase(char));
328
- break;
329
- }
330
- }
331
- break;
332
- case "A":
333
- while (i < ii) {
334
- const char = cSource.charAt(i++);
335
- if (("a" <= char && char <= "z") || ("A" <= char && char <= "Z")) {
336
- buf.push(currCase(char));
337
- break;
338
- }
339
- }
340
- break;
341
- case "9":
342
- while (i < ii) {
343
- const char = cSource.charAt(i++);
344
- if ("0" <= char && char <= "9") {
345
- buf.push(char);
346
- break;
347
- }
348
- }
349
- break;
350
- case "*":
351
- while (i < ii) {
352
- buf.push(currCase(cSource.charAt(i++)));
353
- }
354
- break;
355
- case "\\":
356
- escaped = true;
357
- break;
358
- case ">":
359
- currCase = handlers[1];
360
- break;
361
- case "<":
362
- currCase = handlers[2];
363
- break;
364
- case "=":
365
- currCase = handlers[0];
366
- break;
367
- default:
368
- buf.push(command);
369
- }
370
- }
371
-
372
- return buf.join("");
373
- }
374
-
375
- scand(cFormat, cDate) {
376
- if (cDate === "") {
377
- return new Date();
378
- }
379
-
380
- switch (cFormat) {
381
- case 0:
382
- return this.scand("D:yyyymmddHHMMss", cDate);
383
- case 1:
384
- return this.scand("yyyy.mm.dd HH:MM:ss", cDate);
385
- case 2:
386
- return this.scand("m/d/yy h:MM:ss tt", cDate);
387
- }
388
-
389
- if (!this._scandCache.has(cFormat)) {
390
- const months = this._months;
391
- const days = this._days;
392
-
393
- const handlers = {
394
- mmmm: {
395
- pattern: `(${months.join("|")})`,
396
- action: (value, data) => {
397
- data.month = months.indexOf(value);
398
- },
399
- },
400
- mmm: {
401
- pattern: `(${months.map(month => month.substring(0, 3)).join("|")})`,
402
- action: (value, data) => {
403
- data.month = months.findIndex(
404
- month => month.substring(0, 3) === value
405
- );
406
- },
407
- },
408
- mm: {
409
- pattern: `([0-9]{2})`,
410
- action: (value, data) => {
411
- data.month = parseInt(value) - 1;
412
- },
413
- },
414
- m: {
415
- pattern: `([0-9]{1,2})`,
416
- action: (value, data) => {
417
- data.month = parseInt(value) - 1;
418
- },
419
- },
420
- dddd: {
421
- pattern: `(${days.join("|")})`,
422
- action: (value, data) => {
423
- data.day = days.indexOf(value);
424
- },
425
- },
426
- ddd: {
427
- pattern: `(${days.map(day => day.substring(0, 3)).join("|")})`,
428
- action: (value, data) => {
429
- data.day = days.findIndex(day => day.substring(0, 3) === value);
430
- },
431
- },
432
- dd: {
433
- pattern: "([0-9]{2})",
434
- action: (value, data) => {
435
- data.day = parseInt(value);
436
- },
437
- },
438
- d: {
439
- pattern: "([0-9]{1,2})",
440
- action: (value, data) => {
441
- data.day = parseInt(value);
442
- },
443
- },
444
- yyyy: {
445
- pattern: "([0-9]{4})",
446
- action: (value, data) => {
447
- data.year = parseInt(value);
448
- },
449
- },
450
- yy: {
451
- pattern: "([0-9]{2})",
452
- action: (value, data) => {
453
- data.year = 2000 + parseInt(value);
454
- },
455
- },
456
- HH: {
457
- pattern: "([0-9]{2})",
458
- action: (value, data) => {
459
- data.hours = parseInt(value);
460
- },
461
- },
462
- H: {
463
- pattern: "([0-9]{1,2})",
464
- action: (value, data) => {
465
- data.hours = parseInt(value);
466
- },
467
- },
468
- hh: {
469
- pattern: "([0-9]{2})",
470
- action: (value, data) => {
471
- data.hours = parseInt(value);
472
- },
473
- },
474
- h: {
475
- pattern: "([0-9]{1,2})",
476
- action: (value, data) => {
477
- data.hours = parseInt(value);
478
- },
479
- },
480
- MM: {
481
- pattern: "([0-9]{2})",
482
- action: (value, data) => {
483
- data.minutes = parseInt(value);
484
- },
485
- },
486
- M: {
487
- pattern: "([0-9]{1,2})",
488
- action: (value, data) => {
489
- data.minutes = parseInt(value);
490
- },
491
- },
492
- ss: {
493
- pattern: "([0-9]{2})",
494
- action: (value, data) => {
495
- data.seconds = parseInt(value);
496
- },
497
- },
498
- s: {
499
- pattern: "([0-9]{1,2})",
500
- action: (value, data) => {
501
- data.seconds = parseInt(value);
502
- },
503
- },
504
- tt: {
505
- pattern: "([aApP][mM])",
506
- action: (value, data) => {
507
- const char = value.charAt(0);
508
- data.am = char === "a" || char === "A";
509
- },
510
- },
511
- t: {
512
- pattern: "([aApP])",
513
- action: (value, data) => {
514
- data.am = value === "a" || value === "A";
515
- },
516
- },
517
- };
518
-
519
- // escape the string
520
- const escapedFormat = cFormat.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");
521
- const patterns =
522
- /(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t)/g;
523
- const actions = [];
524
-
525
- const re = escapedFormat.replace(
526
- patterns,
527
- function (match, patternElement) {
528
- const { pattern, action } = handlers[patternElement];
529
- actions.push(action);
530
- return pattern;
531
- }
532
- );
533
-
534
- this._scandCache.set(cFormat, [re, actions]);
535
- }
536
-
537
- const [re, actions] = this._scandCache.get(cFormat);
538
-
539
- const matches = new RegExp(re, "g").exec(cDate);
540
- if (!matches || matches.length !== actions.length + 1) {
541
- return null;
542
- }
543
-
544
- const data = {
545
- year: 0,
546
- month: 0,
547
- day: 0,
548
- hours: 0,
549
- minutes: 0,
550
- seconds: 0,
551
- am: null,
552
- };
553
- actions.forEach((action, i) => action(matches[i + 1], data));
554
- if (data.am !== null) {
555
- data.hours = (data.hours % 12) + (data.am ? 0 : 12);
556
- }
557
-
558
- return new Date(
559
- data.year,
560
- data.month,
561
- data.day,
562
- data.hours,
563
- data.minutes,
564
- data.seconds
565
- );
566
- }
567
-
568
- spansToXML() {
569
- /* Not implemented */
570
- }
571
-
572
- stringFromStream() {
573
- /* Not implemented */
574
- }
575
-
576
- xmlToSpans() {
577
- /* Not implemented */
578
- }
579
- }
580
-
581
- export { Util };
@@ -1,13 +0,0 @@
1
- {
2
- "parserOptions": {
3
- "ecmaVersion": 2017,
4
- },
5
-
6
- "extends": [
7
- "../../.eslintrc"
8
- ],
9
-
10
- "env": {
11
- "es2017": true,
12
- },
13
- }