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

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 (174) hide show
  1. package/README.md +1 -1
  2. package/package.json +33 -18
  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/get.js +1857 -0
  6. package/pdfjs/dist/index.js +767 -0
  7. package/pdfjs/dist/l10n_utils.js +140 -0
  8. package/{src/shared → pdfjs/dist}/message_handler.js +243 -259
  9. package/{src/display → pdfjs/dist}/network.js +149 -87
  10. package/{src/display/content_disposition.js → pdfjs/dist/network_utils.js} +167 -55
  11. package/{src/display → pdfjs/dist}/node_stream.js +133 -98
  12. package/pdfjs/dist/pdf.js +12778 -0
  13. package/pdfjs/dist/pdf_link_service.js +638 -0
  14. package/pdfjs/dist/pdf_rendering_queue.js +199 -0
  15. package/pdfjs/dist/pdf_thumbnail_viewer.js +819 -0
  16. package/pdfjs/dist/pdf_viewer.js +3598 -0
  17. package/pdfjs/dist/typeof.js +100 -0
  18. package/pdfjs/dist/ui_utils.js +1033 -0
  19. package/{src/shared → pdfjs/dist}/util.js +301 -287
  20. package/pdfjs/dist/worker.js +62813 -0
  21. package/src/vcf-pdf-viewer.js +77 -27
  22. package/theme/lumo/vcf-pdf-viewer-styles.js +1 -1
  23. package/theme/material/vcf-pdf-viewer.js +2 -2
  24. package/src/core/.eslintrc +0 -13
  25. package/src/core/annotation.js +0 -2948
  26. package/src/core/arithmetic_decoder.js +0 -182
  27. package/src/core/ascii_85_stream.js +0 -98
  28. package/src/core/ascii_hex_stream.js +0 -79
  29. package/src/core/base_stream.js +0 -110
  30. package/src/core/bidi.js +0 -438
  31. package/src/core/calibri_factors.js +0 -308
  32. package/src/core/catalog.js +0 -1459
  33. package/src/core/ccitt.js +0 -1062
  34. package/src/core/ccitt_stream.js +0 -60
  35. package/src/core/cff_font.js +0 -116
  36. package/src/core/cff_parser.js +0 -1949
  37. package/src/core/charsets.js +0 -119
  38. package/src/core/chunked_stream.js +0 -557
  39. package/src/core/cmap.js +0 -1039
  40. package/src/core/colorspace.js +0 -1533
  41. package/src/core/core_utils.js +0 -464
  42. package/src/core/crypto.js +0 -1900
  43. package/src/core/decode_stream.js +0 -170
  44. package/src/core/decrypt_stream.js +0 -59
  45. package/src/core/default_appearance.js +0 -99
  46. package/src/core/document.js +0 -1456
  47. package/src/core/encodings.js +0 -301
  48. package/src/core/evaluator.js +0 -4601
  49. package/src/core/file_spec.js +0 -108
  50. package/src/core/flate_stream.js +0 -402
  51. package/src/core/font_renderer.js +0 -882
  52. package/src/core/fonts.js +0 -3260
  53. package/src/core/fonts_utils.js +0 -221
  54. package/src/core/function.js +0 -1257
  55. package/src/core/glyf.js +0 -706
  56. package/src/core/glyphlist.js +0 -4558
  57. package/src/core/helvetica_factors.js +0 -353
  58. package/src/core/image.js +0 -802
  59. package/src/core/image_utils.js +0 -291
  60. package/src/core/jbig2.js +0 -2572
  61. package/src/core/jbig2_stream.js +0 -73
  62. package/src/core/jpeg_stream.js +0 -105
  63. package/src/core/jpg.js +0 -1416
  64. package/src/core/jpx.js +0 -2343
  65. package/src/core/jpx_stream.js +0 -87
  66. package/src/core/liberationsans_widths.js +0 -221
  67. package/src/core/lzw_stream.js +0 -150
  68. package/src/core/metadata_parser.js +0 -146
  69. package/src/core/metrics.js +0 -2970
  70. package/src/core/murmurhash3.js +0 -139
  71. package/src/core/myriadpro_factors.js +0 -290
  72. package/src/core/name_number_tree.js +0 -153
  73. package/src/core/object_loader.js +0 -149
  74. package/src/core/opentype_file_builder.js +0 -154
  75. package/src/core/operator_list.js +0 -734
  76. package/src/core/parser.js +0 -1416
  77. package/src/core/pattern.js +0 -985
  78. package/src/core/pdf_manager.js +0 -217
  79. package/src/core/predictor_stream.js +0 -238
  80. package/src/core/primitives.js +0 -402
  81. package/src/core/ps_parser.js +0 -272
  82. package/src/core/run_length_stream.js +0 -61
  83. package/src/core/segoeui_factors.js +0 -308
  84. package/src/core/standard_fonts.js +0 -817
  85. package/src/core/stream.js +0 -103
  86. package/src/core/struct_tree.js +0 -335
  87. package/src/core/to_unicode_map.js +0 -103
  88. package/src/core/type1_font.js +0 -421
  89. package/src/core/type1_parser.js +0 -776
  90. package/src/core/unicode.js +0 -1649
  91. package/src/core/worker.js +0 -848
  92. package/src/core/worker_stream.js +0 -135
  93. package/src/core/writer.js +0 -278
  94. package/src/core/xfa/bind.js +0 -652
  95. package/src/core/xfa/builder.js +0 -207
  96. package/src/core/xfa/config.js +0 -1926
  97. package/src/core/xfa/connection_set.js +0 -202
  98. package/src/core/xfa/data.js +0 -82
  99. package/src/core/xfa/datasets.js +0 -76
  100. package/src/core/xfa/factory.js +0 -111
  101. package/src/core/xfa/fonts.js +0 -181
  102. package/src/core/xfa/formcalc_lexer.js +0 -385
  103. package/src/core/xfa/formcalc_parser.js +0 -1340
  104. package/src/core/xfa/html_utils.js +0 -639
  105. package/src/core/xfa/layout.js +0 -383
  106. package/src/core/xfa/locale_set.js +0 -345
  107. package/src/core/xfa/namespaces.js +0 -81
  108. package/src/core/xfa/parser.js +0 -184
  109. package/src/core/xfa/setup.js +0 -38
  110. package/src/core/xfa/signature.js +0 -40
  111. package/src/core/xfa/som.js +0 -338
  112. package/src/core/xfa/stylesheet.js +0 -40
  113. package/src/core/xfa/template.js +0 -6260
  114. package/src/core/xfa/text.js +0 -290
  115. package/src/core/xfa/unknown.js +0 -29
  116. package/src/core/xfa/utils.js +0 -217
  117. package/src/core/xfa/xdp.js +0 -59
  118. package/src/core/xfa/xfa_object.js +0 -1130
  119. package/src/core/xfa/xhtml.js +0 -543
  120. package/src/core/xfa_fonts.js +0 -208
  121. package/src/core/xml_parser.js +0 -507
  122. package/src/core/xref.js +0 -899
  123. package/src/display/annotation_layer.js +0 -2107
  124. package/src/display/annotation_storage.js +0 -113
  125. package/src/display/api.js +0 -3292
  126. package/src/display/base_factory.js +0 -180
  127. package/src/display/canvas.js +0 -2828
  128. package/src/display/font_loader.js +0 -484
  129. package/src/display/metadata.js +0 -41
  130. package/src/display/network_utils.js +0 -100
  131. package/src/display/node_utils.js +0 -83
  132. package/src/display/optional_content_config.js +0 -189
  133. package/src/display/pattern_helper.js +0 -659
  134. package/src/display/svg.js +0 -1709
  135. package/src/display/text_layer.js +0 -847
  136. package/src/display/transport_stream.js +0 -303
  137. package/src/display/worker_options.js +0 -40
  138. package/src/display/xfa_layer.js +0 -204
  139. package/src/doc_helper.js +0 -25
  140. package/src/images/logo.svg +0 -41
  141. package/src/interfaces.js +0 -169
  142. package/src/license_header.js +0 -14
  143. package/src/license_header_libre.js +0 -21
  144. package/src/pdf.image_decoders.js +0 -46
  145. package/src/pdf.js +0 -146
  146. package/src/pdf.sandbox.external.js +0 -181
  147. package/src/pdf.sandbox.js +0 -151
  148. package/src/pdf.scripting.js +0 -25
  149. package/src/pdf.worker.entry.js +0 -19
  150. package/src/pdf.worker.js +0 -23
  151. package/src/scripting_api/aform.js +0 -608
  152. package/src/scripting_api/app.js +0 -621
  153. package/src/scripting_api/color.js +0 -129
  154. package/src/scripting_api/common.js +0 -58
  155. package/src/scripting_api/console.js +0 -38
  156. package/src/scripting_api/constants.js +0 -208
  157. package/src/scripting_api/doc.js +0 -1195
  158. package/src/scripting_api/error.js +0 -23
  159. package/src/scripting_api/event.js +0 -232
  160. package/src/scripting_api/field.js +0 -620
  161. package/src/scripting_api/fullscreen.js +0 -145
  162. package/src/scripting_api/initialization.js +0 -223
  163. package/src/scripting_api/pdf_object.js +0 -24
  164. package/src/scripting_api/print_params.js +0 -146
  165. package/src/scripting_api/proxy.js +0 -139
  166. package/src/scripting_api/thermometer.js +0 -69
  167. package/src/scripting_api/util.js +0 -581
  168. package/src/shared/.eslintrc +0 -13
  169. package/src/shared/cffStandardStrings.js +0 -311
  170. package/src/shared/compatibility.js +0 -114
  171. package/src/shared/fonts_utils.js +0 -429
  172. package/src/shared/is_node.js +0 -27
  173. package/src/shared/scripting_utils.js +0 -85
  174. package/src/worker_loader.js +0 -32
@@ -1,103 +0,0 @@
1
- /* Copyright 2012 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 { BaseStream } from "./base_stream.js";
17
- import { stringToBytes } from "../shared/util.js";
18
-
19
- class Stream extends BaseStream {
20
- constructor(arrayBuffer, start, length, dict) {
21
- super();
22
-
23
- this.bytes =
24
- arrayBuffer instanceof Uint8Array
25
- ? arrayBuffer
26
- : new Uint8Array(arrayBuffer);
27
- this.start = start || 0;
28
- this.pos = this.start;
29
- this.end = start + length || this.bytes.length;
30
- this.dict = dict;
31
- }
32
-
33
- get length() {
34
- return this.end - this.start;
35
- }
36
-
37
- get isEmpty() {
38
- return this.length === 0;
39
- }
40
-
41
- getByte() {
42
- if (this.pos >= this.end) {
43
- return -1;
44
- }
45
- return this.bytes[this.pos++];
46
- }
47
-
48
- getBytes(length, forceClamped = false) {
49
- const bytes = this.bytes;
50
- const pos = this.pos;
51
- const strEnd = this.end;
52
-
53
- if (!length) {
54
- const subarray = bytes.subarray(pos, strEnd);
55
- // `this.bytes` is always a `Uint8Array` here.
56
- return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
57
- }
58
- let end = pos + length;
59
- if (end > strEnd) {
60
- end = strEnd;
61
- }
62
- this.pos = end;
63
- const subarray = bytes.subarray(pos, end);
64
- // `this.bytes` is always a `Uint8Array` here.
65
- return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
66
- }
67
-
68
- getByteRange(begin, end) {
69
- if (begin < 0) {
70
- begin = 0;
71
- }
72
- if (end > this.end) {
73
- end = this.end;
74
- }
75
- return this.bytes.subarray(begin, end);
76
- }
77
-
78
- reset() {
79
- this.pos = this.start;
80
- }
81
-
82
- moveStart() {
83
- this.start = this.pos;
84
- }
85
-
86
- makeSubStream(start, length, dict = null) {
87
- return new Stream(this.bytes.buffer, start, length, dict);
88
- }
89
- }
90
-
91
- class StringStream extends Stream {
92
- constructor(str) {
93
- super(stringToBytes(str));
94
- }
95
- }
96
-
97
- class NullStream extends Stream {
98
- constructor() {
99
- super(new Uint8Array(0));
100
- }
101
- }
102
-
103
- export { NullStream, Stream, StringStream };
@@ -1,335 +0,0 @@
1
- /* Copyright 2021 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 { isDict, isName, isRef } from "./primitives.js";
17
- import { isString, stringToPDFString, warn } from "../shared/util.js";
18
- import { NumberTree } from "./name_number_tree.js";
19
-
20
- const MAX_DEPTH = 40;
21
-
22
- const StructElementType = {
23
- PAGE_CONTENT: "PAGE_CONTENT",
24
- STREAM_CONTENT: "STREAM_CONTENT",
25
- OBJECT: "OBJECT",
26
- ELEMENT: "ELEMENT",
27
- };
28
-
29
- class StructTreeRoot {
30
- constructor(rootDict) {
31
- this.dict = rootDict;
32
- this.roleMap = new Map();
33
- }
34
-
35
- init() {
36
- this.readRoleMap();
37
- }
38
-
39
- readRoleMap() {
40
- const roleMapDict = this.dict.get("RoleMap");
41
- if (!isDict(roleMapDict)) {
42
- return;
43
- }
44
- roleMapDict.forEach((key, value) => {
45
- if (!isName(value)) {
46
- return;
47
- }
48
- this.roleMap.set(key, value.name);
49
- });
50
- }
51
- }
52
-
53
- /**
54
- * Instead of loading the whole tree we load just the page's relevant structure
55
- * elements, which means we need a wrapper structure to represent the tree.
56
- */
57
- class StructElementNode {
58
- constructor(tree, dict) {
59
- this.tree = tree;
60
- this.dict = dict;
61
- this.kids = [];
62
- this.parseKids();
63
- }
64
-
65
- get role() {
66
- const nameObj = this.dict.get("S");
67
- const name = isName(nameObj) ? nameObj.name : "";
68
- const { root } = this.tree;
69
- if (root.roleMap.has(name)) {
70
- return root.roleMap.get(name);
71
- }
72
- return name;
73
- }
74
-
75
- parseKids() {
76
- let pageObjId = null;
77
- const objRef = this.dict.getRaw("Pg");
78
- if (isRef(objRef)) {
79
- pageObjId = objRef.toString();
80
- }
81
- const kids = this.dict.get("K");
82
- if (Array.isArray(kids)) {
83
- for (const kid of kids) {
84
- const element = this.parseKid(pageObjId, kid);
85
- if (element) {
86
- this.kids.push(element);
87
- }
88
- }
89
- } else {
90
- const element = this.parseKid(pageObjId, kids);
91
- if (element) {
92
- this.kids.push(element);
93
- }
94
- }
95
- }
96
-
97
- parseKid(pageObjId, kid) {
98
- // A direct link to content, the integer is an mcid.
99
- if (Number.isInteger(kid)) {
100
- if (this.tree.pageDict.objId !== pageObjId) {
101
- return null;
102
- }
103
-
104
- return new StructElement({
105
- type: StructElementType.PAGE_CONTENT,
106
- mcid: kid,
107
- pageObjId,
108
- });
109
- }
110
-
111
- // Find the dictionary for the kid.
112
- let kidDict = null;
113
- if (isRef(kid)) {
114
- kidDict = this.dict.xref.fetch(kid);
115
- } else if (isDict(kid)) {
116
- kidDict = kid;
117
- }
118
- if (!kidDict) {
119
- return null;
120
- }
121
- const pageRef = kidDict.getRaw("Pg");
122
- if (isRef(pageRef)) {
123
- pageObjId = pageRef.toString();
124
- }
125
-
126
- const type = isName(kidDict.get("Type")) ? kidDict.get("Type").name : null;
127
- if (type === "MCR") {
128
- if (this.tree.pageDict.objId !== pageObjId) {
129
- return null;
130
- }
131
- return new StructElement({
132
- type: StructElementType.STREAM_CONTENT,
133
- refObjId: isRef(kidDict.getRaw("Stm"))
134
- ? kidDict.getRaw("Stm").toString()
135
- : null,
136
- pageObjId,
137
- mcid: kidDict.get("MCID"),
138
- });
139
- }
140
-
141
- if (type === "OBJR") {
142
- if (this.tree.pageDict.objId !== pageObjId) {
143
- return null;
144
- }
145
- return new StructElement({
146
- type: StructElementType.OBJECT,
147
- refObjId: isRef(kidDict.getRaw("Obj"))
148
- ? kidDict.getRaw("Obj").toString()
149
- : null,
150
- pageObjId,
151
- });
152
- }
153
-
154
- return new StructElement({
155
- type: StructElementType.ELEMENT,
156
- dict: kidDict,
157
- });
158
- }
159
- }
160
-
161
- class StructElement {
162
- constructor({
163
- type,
164
- dict = null,
165
- mcid = null,
166
- pageObjId = null,
167
- refObjId = null,
168
- }) {
169
- this.type = type;
170
- this.dict = dict;
171
- this.mcid = mcid;
172
- this.pageObjId = pageObjId;
173
- this.refObjId = refObjId;
174
- this.parentNode = null;
175
- }
176
- }
177
-
178
- class StructTreePage {
179
- constructor(structTreeRoot, pageDict) {
180
- this.root = structTreeRoot;
181
- this.rootDict = structTreeRoot ? structTreeRoot.dict : null;
182
- this.pageDict = pageDict;
183
- this.nodes = [];
184
- }
185
-
186
- parse() {
187
- if (!this.root || !this.rootDict) {
188
- return;
189
- }
190
-
191
- const parentTree = this.rootDict.get("ParentTree");
192
- if (!parentTree) {
193
- return;
194
- }
195
- const id = this.pageDict.get("StructParents");
196
- if (!Number.isInteger(id)) {
197
- return;
198
- }
199
- const numberTree = new NumberTree(parentTree, this.rootDict.xref);
200
- const parentArray = numberTree.get(id);
201
- if (!Array.isArray(parentArray)) {
202
- return;
203
- }
204
- const map = new Map();
205
- for (const ref of parentArray) {
206
- if (isRef(ref)) {
207
- this.addNode(this.rootDict.xref.fetch(ref), map);
208
- }
209
- }
210
- }
211
-
212
- addNode(dict, map, level = 0) {
213
- if (level > MAX_DEPTH) {
214
- warn("StructTree MAX_DEPTH reached.");
215
- return null;
216
- }
217
-
218
- if (map.has(dict)) {
219
- return map.get(dict);
220
- }
221
-
222
- const element = new StructElementNode(this, dict);
223
- map.set(dict, element);
224
-
225
- const parent = dict.get("P");
226
-
227
- if (!parent || isName(parent.get("Type"), "StructTreeRoot")) {
228
- if (!this.addTopLevelNode(dict, element)) {
229
- map.delete(dict);
230
- }
231
- return element;
232
- }
233
-
234
- const parentNode = this.addNode(parent, map, level + 1);
235
- if (!parentNode) {
236
- return element;
237
- }
238
- let save = false;
239
- for (const kid of parentNode.kids) {
240
- if (kid.type === StructElementType.ELEMENT && kid.dict === dict) {
241
- kid.parentNode = element;
242
- save = true;
243
- }
244
- }
245
- if (!save) {
246
- map.delete(dict);
247
- }
248
- return element;
249
- }
250
-
251
- addTopLevelNode(dict, element) {
252
- const obj = this.rootDict.get("K");
253
- if (!obj) {
254
- return false;
255
- }
256
-
257
- if (isDict(obj)) {
258
- if (obj.objId !== dict.objId) {
259
- return false;
260
- }
261
- this.nodes[0] = element;
262
- return true;
263
- }
264
-
265
- if (!Array.isArray(obj)) {
266
- return true;
267
- }
268
- let save = false;
269
- for (let i = 0; i < obj.length; i++) {
270
- const kidRef = obj[i];
271
- if (kidRef && kidRef.toString() === dict.objId) {
272
- this.nodes[i] = element;
273
- save = true;
274
- }
275
- }
276
- return save;
277
- }
278
-
279
- /**
280
- * Convert the tree structure into a simplifed object literal that can
281
- * be sent to the main thread.
282
- * @returns {Object}
283
- */
284
- get serializable() {
285
- function nodeToSerializable(node, parent, level = 0) {
286
- if (level > MAX_DEPTH) {
287
- warn("StructTree too deep to be fully serialized.");
288
- return;
289
- }
290
- const obj = Object.create(null);
291
- obj.role = node.role;
292
- obj.children = [];
293
- parent.children.push(obj);
294
- const alt = node.dict.get("Alt");
295
- if (isString(alt)) {
296
- obj.alt = stringToPDFString(alt);
297
- }
298
-
299
- for (const kid of node.kids) {
300
- const kidElement =
301
- kid.type === StructElementType.ELEMENT ? kid.parentNode : null;
302
- if (kidElement) {
303
- nodeToSerializable(kidElement, obj, level + 1);
304
- continue;
305
- } else if (
306
- kid.type === StructElementType.PAGE_CONTENT ||
307
- kid.type === StructElementType.STREAM_CONTENT
308
- ) {
309
- obj.children.push({
310
- type: "content",
311
- id: `page${kid.pageObjId}_mcid${kid.mcid}`,
312
- });
313
- } else if (kid.type === StructElementType.OBJECT) {
314
- obj.children.push({
315
- type: "object",
316
- id: kid.refObjId,
317
- });
318
- }
319
- }
320
- }
321
-
322
- const root = Object.create(null);
323
- root.children = [];
324
- root.role = "Root";
325
- for (const child of this.nodes) {
326
- if (!child) {
327
- continue;
328
- }
329
- nodeToSerializable(child, root);
330
- }
331
- return root;
332
- }
333
- }
334
-
335
- export { StructTreePage, StructTreeRoot };
@@ -1,103 +0,0 @@
1
- /* Copyright 2012 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 { unreachable } from "../shared/util.js";
17
-
18
- class ToUnicodeMap {
19
- constructor(cmap = []) {
20
- // The elements of this._map can be integers or strings, depending on how
21
- // `cmap` was created.
22
- this._map = cmap;
23
- }
24
-
25
- get length() {
26
- return this._map.length;
27
- }
28
-
29
- forEach(callback) {
30
- for (const charCode in this._map) {
31
- callback(charCode, this._map[charCode].charCodeAt(0));
32
- }
33
- }
34
-
35
- has(i) {
36
- return this._map[i] !== undefined;
37
- }
38
-
39
- get(i) {
40
- return this._map[i];
41
- }
42
-
43
- charCodeOf(value) {
44
- // `Array.prototype.indexOf` is *extremely* inefficient for arrays which
45
- // are both very sparse and very large (see issue8372.pdf).
46
- const map = this._map;
47
- if (map.length <= 0x10000) {
48
- return map.indexOf(value);
49
- }
50
- for (const charCode in map) {
51
- if (map[charCode] === value) {
52
- return charCode | 0;
53
- }
54
- }
55
- return -1;
56
- }
57
-
58
- amend(map) {
59
- for (const charCode in map) {
60
- this._map[charCode] = map[charCode];
61
- }
62
- }
63
- }
64
-
65
- class IdentityToUnicodeMap {
66
- constructor(firstChar, lastChar) {
67
- this.firstChar = firstChar;
68
- this.lastChar = lastChar;
69
- }
70
-
71
- get length() {
72
- return this.lastChar + 1 - this.firstChar;
73
- }
74
-
75
- forEach(callback) {
76
- for (let i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
77
- callback(i, i);
78
- }
79
- }
80
-
81
- has(i) {
82
- return this.firstChar <= i && i <= this.lastChar;
83
- }
84
-
85
- get(i) {
86
- if (this.firstChar <= i && i <= this.lastChar) {
87
- return String.fromCharCode(i);
88
- }
89
- return undefined;
90
- }
91
-
92
- charCodeOf(v) {
93
- return Number.isInteger(v) && v >= this.firstChar && v <= this.lastChar
94
- ? v
95
- : -1;
96
- }
97
-
98
- amend(map) {
99
- unreachable("Should not call amend()");
100
- }
101
- }
102
-
103
- export { IdentityToUnicodeMap, ToUnicodeMap };