1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | 'use strict';
|
23 |
|
24 | Object.defineProperty(exports, "__esModule", {
|
25 | value: true
|
26 | });
|
27 |
|
28 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
29 |
|
30 | var EOF = {};
|
31 | var Name = function NameClosure() {
|
32 | function Name(name) {
|
33 | this.name = name;
|
34 | }
|
35 | Name.prototype = {};
|
36 | var nameCache = Object.create(null);
|
37 | Name.get = function Name_get(name) {
|
38 | var nameValue = nameCache[name];
|
39 | return nameValue ? nameValue : nameCache[name] = new Name(name);
|
40 | };
|
41 | return Name;
|
42 | }();
|
43 | var Cmd = function CmdClosure() {
|
44 | function Cmd(cmd) {
|
45 | this.cmd = cmd;
|
46 | }
|
47 | Cmd.prototype = {};
|
48 | var cmdCache = Object.create(null);
|
49 | Cmd.get = function Cmd_get(cmd) {
|
50 | var cmdValue = cmdCache[cmd];
|
51 | return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
|
52 | };
|
53 | return Cmd;
|
54 | }();
|
55 | var Dict = function DictClosure() {
|
56 | var nonSerializable = function nonSerializableClosure() {
|
57 | return nonSerializable;
|
58 | };
|
59 | function Dict(xref) {
|
60 | this._map = Object.create(null);
|
61 | this.xref = xref;
|
62 | this.objId = null;
|
63 | this.suppressEncryption = false;
|
64 | this.__nonSerializable__ = nonSerializable;
|
65 | }
|
66 | Dict.prototype = {
|
67 | assignXref: function Dict_assignXref(newXref) {
|
68 | this.xref = newXref;
|
69 | },
|
70 | get: function Dict_get(key1, key2, key3) {
|
71 | var value;
|
72 | var xref = this.xref,
|
73 | suppressEncryption = this.suppressEncryption;
|
74 | if (typeof (value = this._map[key1]) !== 'undefined' || key1 in this._map || typeof key2 === 'undefined') {
|
75 | return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
|
76 | }
|
77 | if (typeof (value = this._map[key2]) !== 'undefined' || key2 in this._map || typeof key3 === 'undefined') {
|
78 | return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
|
79 | }
|
80 | value = this._map[key3] || null;
|
81 | return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
|
82 | },
|
83 | getAsync: function Dict_getAsync(key1, key2, key3) {
|
84 | var value;
|
85 | var xref = this.xref,
|
86 | suppressEncryption = this.suppressEncryption;
|
87 | if (typeof (value = this._map[key1]) !== 'undefined' || key1 in this._map || typeof key2 === 'undefined') {
|
88 | if (xref) {
|
89 | return xref.fetchIfRefAsync(value, suppressEncryption);
|
90 | }
|
91 | return Promise.resolve(value);
|
92 | }
|
93 | if (typeof (value = this._map[key2]) !== 'undefined' || key2 in this._map || typeof key3 === 'undefined') {
|
94 | if (xref) {
|
95 | return xref.fetchIfRefAsync(value, suppressEncryption);
|
96 | }
|
97 | return Promise.resolve(value);
|
98 | }
|
99 | value = this._map[key3] || null;
|
100 | if (xref) {
|
101 | return xref.fetchIfRefAsync(value, suppressEncryption);
|
102 | }
|
103 | return Promise.resolve(value);
|
104 | },
|
105 | getArray: function Dict_getArray(key1, key2, key3) {
|
106 | var value = this.get(key1, key2, key3);
|
107 | var xref = this.xref,
|
108 | suppressEncryption = this.suppressEncryption;
|
109 | if (!Array.isArray(value) || !xref) {
|
110 | return value;
|
111 | }
|
112 | value = value.slice();
|
113 | for (var i = 0, ii = value.length; i < ii; i++) {
|
114 | if (!isRef(value[i])) {
|
115 | continue;
|
116 | }
|
117 | value[i] = xref.fetch(value[i], suppressEncryption);
|
118 | }
|
119 | return value;
|
120 | },
|
121 | getRaw: function Dict_getRaw(key) {
|
122 | return this._map[key];
|
123 | },
|
124 | getKeys: function Dict_getKeys() {
|
125 | return Object.keys(this._map);
|
126 | },
|
127 | set: function Dict_set(key, value) {
|
128 | this._map[key] = value;
|
129 | },
|
130 | has: function Dict_has(key) {
|
131 | return key in this._map;
|
132 | },
|
133 | forEach: function Dict_forEach(callback) {
|
134 | for (var key in this._map) {
|
135 | callback(key, this.get(key));
|
136 | }
|
137 | }
|
138 | };
|
139 | Dict.empty = new Dict(null);
|
140 | Dict.merge = function (xref, dictArray) {
|
141 | var mergedDict = new Dict(xref);
|
142 | for (var i = 0, ii = dictArray.length; i < ii; i++) {
|
143 | var dict = dictArray[i];
|
144 | if (!isDict(dict)) {
|
145 | continue;
|
146 | }
|
147 | for (var keyName in dict._map) {
|
148 | if (mergedDict._map[keyName] !== undefined) {
|
149 | continue;
|
150 | }
|
151 | mergedDict._map[keyName] = dict._map[keyName];
|
152 | }
|
153 | }
|
154 | return mergedDict;
|
155 | };
|
156 | return Dict;
|
157 | }();
|
158 | var Ref = function RefClosure() {
|
159 | function Ref(num, gen) {
|
160 | this.num = num;
|
161 | this.gen = gen;
|
162 | }
|
163 | Ref.prototype = {
|
164 | toString: function Ref_toString() {
|
165 | var str = this.num + 'R';
|
166 | if (this.gen !== 0) {
|
167 | str += this.gen;
|
168 | }
|
169 | return str;
|
170 | }
|
171 | };
|
172 | return Ref;
|
173 | }();
|
174 | var RefSet = function RefSetClosure() {
|
175 | function RefSet() {
|
176 | this.dict = Object.create(null);
|
177 | }
|
178 | RefSet.prototype = {
|
179 | has: function RefSet_has(ref) {
|
180 | return ref.toString() in this.dict;
|
181 | },
|
182 | put: function RefSet_put(ref) {
|
183 | this.dict[ref.toString()] = true;
|
184 | },
|
185 | remove: function RefSet_remove(ref) {
|
186 | delete this.dict[ref.toString()];
|
187 | }
|
188 | };
|
189 | return RefSet;
|
190 | }();
|
191 | var RefSetCache = function RefSetCacheClosure() {
|
192 | function RefSetCache() {
|
193 | this.dict = Object.create(null);
|
194 | }
|
195 | RefSetCache.prototype = {
|
196 | get: function RefSetCache_get(ref) {
|
197 | return this.dict[ref.toString()];
|
198 | },
|
199 | has: function RefSetCache_has(ref) {
|
200 | return ref.toString() in this.dict;
|
201 | },
|
202 | put: function RefSetCache_put(ref, obj) {
|
203 | this.dict[ref.toString()] = obj;
|
204 | },
|
205 | putAlias: function RefSetCache_putAlias(ref, aliasRef) {
|
206 | this.dict[ref.toString()] = this.get(aliasRef);
|
207 | },
|
208 | forEach: function RefSetCache_forEach(fn, thisArg) {
|
209 | for (var i in this.dict) {
|
210 | fn.call(thisArg, this.dict[i]);
|
211 | }
|
212 | },
|
213 | clear: function RefSetCache_clear() {
|
214 | this.dict = Object.create(null);
|
215 | }
|
216 | };
|
217 | return RefSetCache;
|
218 | }();
|
219 | function isEOF(v) {
|
220 | return v === EOF;
|
221 | }
|
222 | function isName(v, name) {
|
223 | return v instanceof Name && (name === undefined || v.name === name);
|
224 | }
|
225 | function isCmd(v, cmd) {
|
226 | return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
|
227 | }
|
228 | function isDict(v, type) {
|
229 | return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
|
230 | }
|
231 | function isRef(v) {
|
232 | return v instanceof Ref;
|
233 | }
|
234 | function isRefsEqual(v1, v2) {
|
235 | return v1.num === v2.num && v1.gen === v2.gen;
|
236 | }
|
237 | function isStream(v) {
|
238 | return (typeof v === 'undefined' ? 'undefined' : _typeof(v)) === 'object' && v !== null && v.getBytes !== undefined;
|
239 | }
|
240 | exports.EOF = EOF;
|
241 | exports.Cmd = Cmd;
|
242 | exports.Dict = Dict;
|
243 | exports.Name = Name;
|
244 | exports.Ref = Ref;
|
245 | exports.RefSet = RefSet;
|
246 | exports.RefSetCache = RefSetCache;
|
247 | exports.isEOF = isEOF;
|
248 | exports.isCmd = isCmd;
|
249 | exports.isDict = isDict;
|
250 | exports.isName = isName;
|
251 | exports.isRef = isRef;
|
252 | exports.isRefsEqual = isRefsEqual;
|
253 | exports.isStream = isStream; |
\ | No newline at end of file |