1 | "use strict";
|
2 | var __extends = (this && this.__extends) || function (d, b) {
|
3 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
4 | function __() { this.constructor = d; }
|
5 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
6 | };
|
7 | var globalScope;
|
8 | if (typeof window === 'undefined') {
|
9 | if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
|
10 |
|
11 | globalScope = self;
|
12 | }
|
13 | else {
|
14 | globalScope = global;
|
15 | }
|
16 | }
|
17 | else {
|
18 | globalScope = window;
|
19 | }
|
20 | function scheduleMicroTask(fn) {
|
21 | Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
|
22 | }
|
23 | exports.scheduleMicroTask = scheduleMicroTask;
|
24 | exports.IS_DART = false;
|
25 |
|
26 |
|
27 | var _global = globalScope;
|
28 | exports.global = _global;
|
29 | exports.Type = Function;
|
30 | function getTypeNameForDebugging(type) {
|
31 | if (type['name']) {
|
32 | return type['name'];
|
33 | }
|
34 | return typeof type;
|
35 | }
|
36 | exports.getTypeNameForDebugging = getTypeNameForDebugging;
|
37 | exports.Math = _global.Math;
|
38 | exports.Date = _global.Date;
|
39 | var _devMode = true;
|
40 | var _modeLocked = false;
|
41 | function lockMode() {
|
42 | _modeLocked = true;
|
43 | }
|
44 | exports.lockMode = lockMode;
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | function enableProdMode() {
|
55 | if (_modeLocked) {
|
56 |
|
57 | throw 'Cannot enable prod mode after platform setup.';
|
58 | }
|
59 | _devMode = false;
|
60 | }
|
61 | exports.enableProdMode = enableProdMode;
|
62 | function assertionsEnabled() {
|
63 | return _devMode;
|
64 | }
|
65 | exports.assertionsEnabled = assertionsEnabled;
|
66 |
|
67 |
|
68 |
|
69 | _global.assert = function assert(condition) {
|
70 |
|
71 | };
|
72 | function isPresent(obj) {
|
73 | return obj !== undefined && obj !== null;
|
74 | }
|
75 | exports.isPresent = isPresent;
|
76 | function isBlank(obj) {
|
77 | return obj === undefined || obj === null;
|
78 | }
|
79 | exports.isBlank = isBlank;
|
80 | function isBoolean(obj) {
|
81 | return typeof obj === 'boolean';
|
82 | }
|
83 | exports.isBoolean = isBoolean;
|
84 | function isNumber(obj) {
|
85 | return typeof obj === 'number';
|
86 | }
|
87 | exports.isNumber = isNumber;
|
88 | function isString(obj) {
|
89 | return typeof obj === 'string';
|
90 | }
|
91 | exports.isString = isString;
|
92 | function isFunction(obj) {
|
93 | return typeof obj === 'function';
|
94 | }
|
95 | exports.isFunction = isFunction;
|
96 | function isType(obj) {
|
97 | return isFunction(obj);
|
98 | }
|
99 | exports.isType = isType;
|
100 | function isStringMap(obj) {
|
101 | return typeof obj === 'object' && obj !== null;
|
102 | }
|
103 | exports.isStringMap = isStringMap;
|
104 | var STRING_MAP_PROTO = Object.getPrototypeOf({});
|
105 | function isStrictStringMap(obj) {
|
106 | return isStringMap(obj) && Object.getPrototypeOf(obj) === STRING_MAP_PROTO;
|
107 | }
|
108 | exports.isStrictStringMap = isStrictStringMap;
|
109 | function isPromise(obj) {
|
110 | return obj instanceof _global.Promise;
|
111 | }
|
112 | exports.isPromise = isPromise;
|
113 | function isArray(obj) {
|
114 | return Array.isArray(obj);
|
115 | }
|
116 | exports.isArray = isArray;
|
117 | function isDate(obj) {
|
118 | return obj instanceof exports.Date && !isNaN(obj.valueOf());
|
119 | }
|
120 | exports.isDate = isDate;
|
121 | function noop() { }
|
122 | exports.noop = noop;
|
123 | function stringify(token) {
|
124 | if (typeof token === 'string') {
|
125 | return token;
|
126 | }
|
127 | if (token === undefined || token === null) {
|
128 | return '' + token;
|
129 | }
|
130 | if (token.name) {
|
131 | return token.name;
|
132 | }
|
133 | if (token.overriddenName) {
|
134 | return token.overriddenName;
|
135 | }
|
136 | var res = token.toString();
|
137 | var newLineIndex = res.indexOf('\n');
|
138 | return (newLineIndex === -1) ? res : res.substring(0, newLineIndex);
|
139 | }
|
140 | exports.stringify = stringify;
|
141 |
|
142 |
|
143 | function serializeEnum(val) {
|
144 | return val;
|
145 | }
|
146 | exports.serializeEnum = serializeEnum;
|
147 | function deserializeEnum(val, values) {
|
148 | return val;
|
149 | }
|
150 | exports.deserializeEnum = deserializeEnum;
|
151 | function resolveEnumToken(enumValue, val) {
|
152 | return enumValue[val];
|
153 | }
|
154 | exports.resolveEnumToken = resolveEnumToken;
|
155 | var StringWrapper = (function () {
|
156 | function StringWrapper() {
|
157 | }
|
158 | StringWrapper.fromCharCode = function (code) { return String.fromCharCode(code); };
|
159 | StringWrapper.charCodeAt = function (s, index) { return s.charCodeAt(index); };
|
160 | StringWrapper.split = function (s, regExp) { return s.split(regExp); };
|
161 | StringWrapper.equals = function (s, s2) { return s === s2; };
|
162 | StringWrapper.stripLeft = function (s, charVal) {
|
163 | if (s && s.length) {
|
164 | var pos = 0;
|
165 | for (var i = 0; i < s.length; i++) {
|
166 | if (s[i] != charVal)
|
167 | break;
|
168 | pos++;
|
169 | }
|
170 | s = s.substring(pos);
|
171 | }
|
172 | return s;
|
173 | };
|
174 | StringWrapper.stripRight = function (s, charVal) {
|
175 | if (s && s.length) {
|
176 | var pos = s.length;
|
177 | for (var i = s.length - 1; i >= 0; i--) {
|
178 | if (s[i] != charVal)
|
179 | break;
|
180 | pos--;
|
181 | }
|
182 | s = s.substring(0, pos);
|
183 | }
|
184 | return s;
|
185 | };
|
186 | StringWrapper.replace = function (s, from, replace) {
|
187 | return s.replace(from, replace);
|
188 | };
|
189 | StringWrapper.replaceAll = function (s, from, replace) {
|
190 | return s.replace(from, replace);
|
191 | };
|
192 | StringWrapper.slice = function (s, from, to) {
|
193 | if (from === void 0) { from = 0; }
|
194 | if (to === void 0) { to = null; }
|
195 | return s.slice(from, to === null ? undefined : to);
|
196 | };
|
197 | StringWrapper.replaceAllMapped = function (s, from, cb) {
|
198 | return s.replace(from, function () {
|
199 | var matches = [];
|
200 | for (var _i = 0; _i < arguments.length; _i++) {
|
201 | matches[_i - 0] = arguments[_i];
|
202 | }
|
203 |
|
204 | matches.splice(-2, 2);
|
205 |
|
206 | return cb(matches);
|
207 | });
|
208 | };
|
209 | StringWrapper.contains = function (s, substr) { return s.indexOf(substr) != -1; };
|
210 | StringWrapper.compare = function (a, b) {
|
211 | if (a < b) {
|
212 | return -1;
|
213 | }
|
214 | else if (a > b) {
|
215 | return 1;
|
216 | }
|
217 | else {
|
218 | return 0;
|
219 | }
|
220 | };
|
221 | return StringWrapper;
|
222 | }());
|
223 | exports.StringWrapper = StringWrapper;
|
224 | var StringJoiner = (function () {
|
225 | function StringJoiner(parts) {
|
226 | if (parts === void 0) { parts = []; }
|
227 | this.parts = parts;
|
228 | }
|
229 | StringJoiner.prototype.add = function (part) { this.parts.push(part); };
|
230 | StringJoiner.prototype.toString = function () { return this.parts.join(''); };
|
231 | return StringJoiner;
|
232 | }());
|
233 | exports.StringJoiner = StringJoiner;
|
234 | var NumberParseError = (function (_super) {
|
235 | __extends(NumberParseError, _super);
|
236 | function NumberParseError(message) {
|
237 | _super.call(this);
|
238 | this.message = message;
|
239 | }
|
240 | NumberParseError.prototype.toString = function () { return this.message; };
|
241 | return NumberParseError;
|
242 | }(Error));
|
243 | exports.NumberParseError = NumberParseError;
|
244 | var NumberWrapper = (function () {
|
245 | function NumberWrapper() {
|
246 | }
|
247 | NumberWrapper.toFixed = function (n, fractionDigits) { return n.toFixed(fractionDigits); };
|
248 | NumberWrapper.equal = function (a, b) { return a === b; };
|
249 | NumberWrapper.parseIntAutoRadix = function (text) {
|
250 | var result = parseInt(text);
|
251 | if (isNaN(result)) {
|
252 | throw new NumberParseError('Invalid integer literal when parsing ' + text);
|
253 | }
|
254 | return result;
|
255 | };
|
256 | NumberWrapper.parseInt = function (text, radix) {
|
257 | if (radix == 10) {
|
258 | if (/^(\-|\+)?[0-9]+$/.test(text)) {
|
259 | return parseInt(text, radix);
|
260 | }
|
261 | }
|
262 | else if (radix == 16) {
|
263 | if (/^(\-|\+)?[0-9ABCDEFabcdef]+$/.test(text)) {
|
264 | return parseInt(text, radix);
|
265 | }
|
266 | }
|
267 | else {
|
268 | var result = parseInt(text, radix);
|
269 | if (!isNaN(result)) {
|
270 | return result;
|
271 | }
|
272 | }
|
273 | throw new NumberParseError('Invalid integer literal when parsing ' + text + ' in base ' + radix);
|
274 | };
|
275 |
|
276 | NumberWrapper.parseFloat = function (text) { return parseFloat(text); };
|
277 | Object.defineProperty(NumberWrapper, "NaN", {
|
278 | get: function () { return NaN; },
|
279 | enumerable: true,
|
280 | configurable: true
|
281 | });
|
282 | NumberWrapper.isNaN = function (value) { return isNaN(value); };
|
283 | NumberWrapper.isInteger = function (value) { return Number.isInteger(value); };
|
284 | return NumberWrapper;
|
285 | }());
|
286 | exports.NumberWrapper = NumberWrapper;
|
287 | exports.RegExp = _global.RegExp;
|
288 | var RegExpWrapper = (function () {
|
289 | function RegExpWrapper() {
|
290 | }
|
291 | RegExpWrapper.create = function (regExpStr, flags) {
|
292 | if (flags === void 0) { flags = ''; }
|
293 | flags = flags.replace(/g/g, '');
|
294 | return new _global.RegExp(regExpStr, flags + 'g');
|
295 | };
|
296 | RegExpWrapper.firstMatch = function (regExp, input) {
|
297 |
|
298 | regExp.lastIndex = 0;
|
299 | return regExp.exec(input);
|
300 | };
|
301 | RegExpWrapper.test = function (regExp, input) {
|
302 | regExp.lastIndex = 0;
|
303 | return regExp.test(input);
|
304 | };
|
305 | RegExpWrapper.matcher = function (regExp, input) {
|
306 |
|
307 |
|
308 |
|
309 | regExp.lastIndex = 0;
|
310 | return { re: regExp, input: input };
|
311 | };
|
312 | RegExpWrapper.replaceAll = function (regExp, input, replace) {
|
313 | var c = regExp.exec(input);
|
314 | var res = '';
|
315 | regExp.lastIndex = 0;
|
316 | var prev = 0;
|
317 | while (c) {
|
318 | res += input.substring(prev, c.index);
|
319 | res += replace(c);
|
320 | prev = c.index + c[0].length;
|
321 | regExp.lastIndex = prev;
|
322 | c = regExp.exec(input);
|
323 | }
|
324 | res += input.substring(prev);
|
325 | return res;
|
326 | };
|
327 | return RegExpWrapper;
|
328 | }());
|
329 | exports.RegExpWrapper = RegExpWrapper;
|
330 | var RegExpMatcherWrapper = (function () {
|
331 | function RegExpMatcherWrapper() {
|
332 | }
|
333 | RegExpMatcherWrapper.next = function (matcher) {
|
334 | return matcher.re.exec(matcher.input);
|
335 | };
|
336 | return RegExpMatcherWrapper;
|
337 | }());
|
338 | exports.RegExpMatcherWrapper = RegExpMatcherWrapper;
|
339 | var FunctionWrapper = (function () {
|
340 | function FunctionWrapper() {
|
341 | }
|
342 | FunctionWrapper.apply = function (fn, posArgs) { return fn.apply(null, posArgs); };
|
343 | FunctionWrapper.bind = function (fn, scope) { return fn.bind(scope); };
|
344 | return FunctionWrapper;
|
345 | }());
|
346 | exports.FunctionWrapper = FunctionWrapper;
|
347 |
|
348 | function looseIdentical(a, b) {
|
349 | return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b);
|
350 | }
|
351 | exports.looseIdentical = looseIdentical;
|
352 |
|
353 |
|
354 | function getMapKey(value) {
|
355 | return value;
|
356 | }
|
357 | exports.getMapKey = getMapKey;
|
358 | function normalizeBlank(obj) {
|
359 | return isBlank(obj) ? null : obj;
|
360 | }
|
361 | exports.normalizeBlank = normalizeBlank;
|
362 | function normalizeBool(obj) {
|
363 | return isBlank(obj) ? false : obj;
|
364 | }
|
365 | exports.normalizeBool = normalizeBool;
|
366 | function isJsObject(o) {
|
367 | return o !== null && (typeof o === 'function' || typeof o === 'object');
|
368 | }
|
369 | exports.isJsObject = isJsObject;
|
370 | function print(obj) {
|
371 | console.log(obj);
|
372 | }
|
373 | exports.print = print;
|
374 | function warn(obj) {
|
375 | console.warn(obj);
|
376 | }
|
377 | exports.warn = warn;
|
378 |
|
379 | var Json = (function () {
|
380 | function Json() {
|
381 | }
|
382 | Json.parse = function (s) { return _global.JSON.parse(s); };
|
383 | Json.stringify = function (data) {
|
384 |
|
385 | return _global.JSON.stringify(data, null, 2);
|
386 | };
|
387 | return Json;
|
388 | }());
|
389 | exports.Json = Json;
|
390 | var DateWrapper = (function () {
|
391 | function DateWrapper() {
|
392 | }
|
393 | DateWrapper.create = function (year, month, day, hour, minutes, seconds, milliseconds) {
|
394 | if (month === void 0) { month = 1; }
|
395 | if (day === void 0) { day = 1; }
|
396 | if (hour === void 0) { hour = 0; }
|
397 | if (minutes === void 0) { minutes = 0; }
|
398 | if (seconds === void 0) { seconds = 0; }
|
399 | if (milliseconds === void 0) { milliseconds = 0; }
|
400 | return new exports.Date(year, month - 1, day, hour, minutes, seconds, milliseconds);
|
401 | };
|
402 | DateWrapper.fromISOString = function (str) { return new exports.Date(str); };
|
403 | DateWrapper.fromMillis = function (ms) { return new exports.Date(ms); };
|
404 | DateWrapper.toMillis = function (date) { return date.getTime(); };
|
405 | DateWrapper.now = function () { return new exports.Date(); };
|
406 | DateWrapper.toJson = function (date) { return date.toJSON(); };
|
407 | return DateWrapper;
|
408 | }());
|
409 | exports.DateWrapper = DateWrapper;
|
410 | function setValueOnPath(global, path, value) {
|
411 | var parts = path.split('.');
|
412 | var obj = global;
|
413 | while (parts.length > 1) {
|
414 | var name = parts.shift();
|
415 | if (obj.hasOwnProperty(name) && isPresent(obj[name])) {
|
416 | obj = obj[name];
|
417 | }
|
418 | else {
|
419 | obj = obj[name] = {};
|
420 | }
|
421 | }
|
422 | if (obj === undefined || obj === null) {
|
423 | obj = {};
|
424 | }
|
425 | obj[parts.shift()] = value;
|
426 | }
|
427 | exports.setValueOnPath = setValueOnPath;
|
428 | var _symbolIterator = null;
|
429 | function getSymbolIterator() {
|
430 | if (isBlank(_symbolIterator)) {
|
431 | if (isPresent(globalScope.Symbol) && isPresent(Symbol.iterator)) {
|
432 | _symbolIterator = Symbol.iterator;
|
433 | }
|
434 | else {
|
435 |
|
436 | var keys = Object.getOwnPropertyNames(Map.prototype);
|
437 | for (var i = 0; i < keys.length; ++i) {
|
438 | var key = keys[i];
|
439 | if (key !== 'entries' && key !== 'size' &&
|
440 | Map.prototype[key] === Map.prototype['entries']) {
|
441 | _symbolIterator = key;
|
442 | }
|
443 | }
|
444 | }
|
445 | }
|
446 | return _symbolIterator;
|
447 | }
|
448 | exports.getSymbolIterator = getSymbolIterator;
|
449 | function evalExpression(sourceUrl, expr, declarations, vars) {
|
450 | var fnBody = declarations + "\nreturn " + expr + "\n//# sourceURL=" + sourceUrl;
|
451 | var fnArgNames = [];
|
452 | var fnArgValues = [];
|
453 | for (var argName in vars) {
|
454 | fnArgNames.push(argName);
|
455 | fnArgValues.push(vars[argName]);
|
456 | }
|
457 | return new (Function.bind.apply(Function, [void 0].concat(fnArgNames.concat(fnBody))))().apply(void 0, fnArgValues);
|
458 | }
|
459 | exports.evalExpression = evalExpression;
|
460 | function isPrimitive(obj) {
|
461 | return !isJsObject(obj);
|
462 | }
|
463 | exports.isPrimitive = isPrimitive;
|
464 | function hasConstructor(value, type) {
|
465 | return value.constructor === type;
|
466 | }
|
467 | exports.hasConstructor = hasConstructor;
|
468 | function bitWiseOr(values) {
|
469 | return values.reduce(function (a, b) { return a | b; });
|
470 | }
|
471 | exports.bitWiseOr = bitWiseOr;
|
472 | function bitWiseAnd(values) {
|
473 | return values.reduce(function (a, b) { return a & b; });
|
474 | }
|
475 | exports.bitWiseAnd = bitWiseAnd;
|
476 | function escape(s) {
|
477 | return _global.encodeURI(s);
|
478 | }
|
479 | exports.escape = escape;
|
480 |
|
\ | No newline at end of file |