1 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.rollup = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"/www/ROLLUP/rollup/.gobble-build/03-rollup/1/rollup.browser":[function(require,module,exports){
|
2 | (function (process){
|
3 | 'use strict';
|
4 |
|
5 | var MagicString = require('magic-string');
|
6 | MagicString = 'default' in MagicString ? MagicString['default'] : MagicString;
|
7 | var acorn = require('acorn');
|
8 |
|
9 | function readFileSync() {
|
10 | throw new Error('Cannot use sander.readFileSync inside browser');
|
11 | }
|
12 |
|
13 | function writeFile() {
|
14 | throw new Error('Cannot use sander.writeFile inside browser');
|
15 | }
|
16 |
|
17 | var _Promise = window.Promise;
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | var absolutePath = /^(?:\/|(?:[A-Za-z]:)?\\)/;
|
23 |
|
24 | function isAbsolute(path) {
|
25 | return absolutePath.test(path);
|
26 | }
|
27 |
|
28 | function basename(path) {
|
29 | return path.split(/(\/|\\)/).pop();
|
30 | }
|
31 |
|
32 | function dirname(path) {
|
33 | var match = /(\/|\\)[^\/\\]*$/.exec(path);
|
34 | if (!match) return '.';
|
35 |
|
36 | var dir = path.slice(0, -match[0].length);
|
37 |
|
38 |
|
39 | return dir ? dir : '/';
|
40 | }
|
41 |
|
42 | function extname(path) {
|
43 | var match = /\.[^\.]+$/.exec(path);
|
44 | if (!match) return '';
|
45 | return match[0];
|
46 | }
|
47 |
|
48 | function resolve() {
|
49 | for (var _len = arguments.length, paths = Array(_len), _key = 0; _key < _len; _key++) {
|
50 | paths[_key] = arguments[_key];
|
51 | }
|
52 |
|
53 | var resolvedParts = paths.shift().split(/[\/\\]/);
|
54 |
|
55 | paths.forEach(function (path) {
|
56 | if (isAbsolute(path)) {
|
57 | resolvedParts = path.split(/[\/\\]/);
|
58 | } else {
|
59 | var parts = path.split(/[\/\\]/);
|
60 |
|
61 | while (parts[0] && parts[0][0] === '.') {
|
62 | var part = parts.shift();
|
63 | if (part === '..') {
|
64 | resolvedParts.pop();
|
65 | } else if (part !== '.') {
|
66 | throw new Error('Unexpected path part (' + part + ')');
|
67 | }
|
68 | }
|
69 |
|
70 | resolvedParts.push.apply(resolvedParts, parts);
|
71 | }
|
72 | });
|
73 |
|
74 | return resolvedParts.join('/');
|
75 | }
|
76 |
|
77 | var keys = Object.keys;
|
78 |
|
79 | function blank() {
|
80 | return Object.create(null);
|
81 | }
|
82 |
|
83 | function unixizePath(path) {
|
84 | return path.split(/[\/\\]/).join("/");
|
85 | }
|
86 |
|
87 | function getIndentString(magicString, options) {
|
88 | if (!('indent' in options) || options.indent === true) {
|
89 | return magicString.getIndentString();
|
90 | }
|
91 |
|
92 | return options.indent || '';
|
93 | }
|
94 |
|
95 | function badExports(option, keys) {
|
96 | throw new Error('\'' + option + '\' was specified for options.exports, but entry module has following exports: ' + keys.join(', '));
|
97 | }
|
98 | function getExportMode(bundle, exportMode) {
|
99 | var exportKeys = keys(bundle.entryModule.exports);
|
100 |
|
101 | if (exportMode === 'default') {
|
102 | if (exportKeys.length !== 1 || exportKeys[0] !== 'default') {
|
103 | badExports('default', exportKeys);
|
104 | }
|
105 | } else if (exportMode === 'none' && exportKeys.length) {
|
106 | badExports('none', exportKeys);
|
107 | }
|
108 |
|
109 | if (!exportMode || exportMode === 'auto') {
|
110 | if (exportKeys.length === 0) {
|
111 | exportMode = 'none';
|
112 | } else if (exportKeys.length === 1 && exportKeys[0] === 'default') {
|
113 | exportMode = 'default';
|
114 | } else {
|
115 | exportMode = 'named';
|
116 | }
|
117 | }
|
118 |
|
119 | if (!/(?:default|named|none)/.test(exportMode)) {
|
120 | throw new Error('options.exports must be \'default\', \'named\', \'none\', \'auto\', or left unspecified (defaults to \'auto\')');
|
121 | }
|
122 |
|
123 | return exportMode;
|
124 | }
|
125 |
|
126 | function getInteropBlock(bundle) {
|
127 | return bundle.externalModules.filter(function (module) {
|
128 | return module.needsDefault && module.needsNamed;
|
129 | }).map(function (module) {
|
130 | return "var " + module.name + "__default = 'default' in " + module.name + " ? " + module.name + "['default'] : " + module.name + ";";
|
131 | }).join("\n");
|
132 | }
|
133 |
|
134 | function getName(x) {
|
135 | return x.name;
|
136 | }
|
137 |
|
138 | function quoteId(x) {
|
139 | return "'" + x.id + "'";
|
140 | }
|
141 |
|
142 | function req(x) {
|
143 | return "require('" + x.id + "')";
|
144 | }
|
145 |
|
146 | function umd(bundle, magicString, _ref, options) {
|
147 | var exportMode = _ref.exportMode;
|
148 | var indentString = _ref.indentString;
|
149 |
|
150 | if (exportMode !== 'none' && !options.moduleName) {
|
151 | throw new Error('You must supply options.moduleName for UMD bundles');
|
152 | }
|
153 |
|
154 | var globalNames = options.globals || blank();
|
155 |
|
156 | var amdDeps = bundle.externalModules.map(quoteId);
|
157 | var cjsDeps = bundle.externalModules.map(req);
|
158 | var globalDeps = bundle.externalModules.map(function (module) {
|
159 | return 'global.' + (globalNames[module.id] || module.name);
|
160 | });
|
161 |
|
162 | var args = bundle.externalModules.map(getName);
|
163 |
|
164 | if (exportMode === 'named') {
|
165 | amdDeps.unshift('\'exports\'');
|
166 | cjsDeps.unshift('exports');
|
167 | globalDeps.unshift('(global.' + options.moduleName + ' = {})');
|
168 |
|
169 | args.unshift('exports');
|
170 | }
|
171 |
|
172 | var amdParams = (options.moduleId ? '[\'' + options.moduleId + '\'], ' : '') + (amdDeps.length ? '[' + amdDeps.join(', ') + '], ' : '');
|
173 |
|
174 | var cjsExport = exportMode === 'default' ? 'module.exports = ' : '';
|
175 | var defaultExport = exportMode === 'default' ? 'global.' + options.moduleName + ' = ' : '';
|
176 |
|
177 | var intro = ('(function (global, factory) {\n\t\t\ttypeof exports === \'object\' && typeof module !== \'undefined\' ? ' + cjsExport + 'factory(' + cjsDeps.join(', ') + ') :\n\t\t\ttypeof define === \'function\' && define.amd ? define(' + amdParams + 'factory) :\n\t\t\t' + defaultExport + 'factory(' + globalDeps + ');\n\t\t}(this, function (' + args + ') { \'use strict\';\n\n\t\t').replace(/^\t\t/gm, '').replace(/^\t/gm, magicString.getIndentString());
|
178 |
|
179 |
|
180 | var interopBlock = getInteropBlock(bundle);
|
181 | if (interopBlock) magicString.prepend(interopBlock + '\n\n');
|
182 |
|
183 | var exports = bundle.entryModule.exports;
|
184 |
|
185 | var exportBlock = undefined;
|
186 |
|
187 | if (exportMode === 'default') {
|
188 | var canonicalName = bundle.entryModule.getCanonicalName('default');
|
189 | exportBlock = 'return ' + canonicalName + ';';
|
190 | } else {
|
191 | exportBlock = bundle.toExport.map(function (name) {
|
192 | var canonicalName = bundle.entryModule.getCanonicalName(exports[name].localName);
|
193 | return 'exports.' + name + ' = ' + canonicalName + ';';
|
194 | }).join('\n');
|
195 | }
|
196 |
|
197 | if (exportBlock) {
|
198 | magicString.append('\n\n' + exportBlock);
|
199 | }
|
200 |
|
201 | return magicString.trim().indent(indentString).append('\n\n}));').prepend(intro);
|
202 | }
|
203 |
|
204 | function iife(bundle, magicString, _ref, options) {
|
205 | var exportMode = _ref.exportMode;
|
206 | var indentString = _ref.indentString;
|
207 |
|
208 | var globalNames = options.globals || blank();
|
209 |
|
210 | var dependencies = bundle.externalModules.map(function (module) {
|
211 | return globalNames[module.id] || module.name;
|
212 | });
|
213 |
|
214 | var args = bundle.externalModules.map(getName);
|
215 |
|
216 | if (exportMode !== 'none' && !options.moduleName) {
|
217 | throw new Error('You must supply options.moduleName for IIFE bundles');
|
218 | }
|
219 |
|
220 | if (exportMode === 'named') {
|
221 | dependencies.unshift('(this.' + options.moduleName + ' = {})');
|
222 | args.unshift('exports');
|
223 | }
|
224 |
|
225 | var intro = '(function (' + args + ') { \'use strict\';\n\n';
|
226 | var outro = '\n\n})(' + dependencies + ');';
|
227 |
|
228 |
|
229 | var interopBlock = getInteropBlock(bundle);
|
230 | if (interopBlock) magicString.prepend(interopBlock + '\n\n');
|
231 |
|
232 | if (exportMode === 'default') {
|
233 | intro = 'var ' + options.moduleName + ' = ' + intro;
|
234 | magicString.append('\n\nreturn ' + bundle.entryModule.getCanonicalName('default') + ';');
|
235 | }
|
236 |
|
237 |
|
238 |
|
239 | return magicString.indent(indentString).prepend(intro).append(outro);
|
240 | }
|
241 |
|
242 | function es6(bundle, magicString, _ref, options) {
|
243 | var exportMode = _ref.exportMode;
|
244 |
|
245 | var importBlock = bundle.externalModules.map(function (module) {
|
246 | var specifiers = [];
|
247 |
|
248 | if (module.needsDefault) {
|
249 | specifiers.push(module.importedByBundle.filter(function (declaration) {
|
250 | return declaration.name === 'default';
|
251 | })[0].localName);
|
252 | }
|
253 |
|
254 | if (module.needsAll) {
|
255 | specifiers.push('* as ' + module.importedByBundle.filter(function (declaration) {
|
256 | return declaration.name === '*';
|
257 | })[0].localName);
|
258 | }
|
259 |
|
260 | if (module.needsNamed) {
|
261 | specifiers.push('{ ' + module.importedByBundle.filter(function (declaration) {
|
262 | return !/^(default|\*)$/.test(declaration.name);
|
263 | }).map(function (_ref2) {
|
264 | var name = _ref2.name;
|
265 | var localName = _ref2.localName;
|
266 | return name === localName ? name : name + ' as ' + localName;
|
267 | }).join(', ') + ' }');
|
268 | }
|
269 |
|
270 | return specifiers.length ? 'import ' + specifiers.join(', ') + ' from \'' + module.id + '\';' : 'import \'' + module.id + '\';';
|
271 | }).join('\n');
|
272 |
|
273 | if (importBlock) {
|
274 | magicString.prepend(importBlock + '\n\n');
|
275 | }
|
276 |
|
277 | var exports = bundle.entryModule.exports;
|
278 | var exportBlock = keys(exports).map(function (exportedName) {
|
279 | var specifier = exports[exportedName];
|
280 |
|
281 | var canonicalName = bundle.entryModule.getCanonicalName(specifier.localName);
|
282 |
|
283 | if (exportedName === 'default') {
|
284 | return 'export default ' + canonicalName + ';';
|
285 | }
|
286 |
|
287 | return exportedName === canonicalName ? 'export { ' + exportedName + ' };' : 'export { ' + canonicalName + ' as ' + exportedName + ' };';
|
288 | }).join('\n');
|
289 |
|
290 | if (exportBlock) {
|
291 | magicString.append('\n\n' + exportBlock);
|
292 | }
|
293 |
|
294 | return magicString.trim();
|
295 | }
|
296 |
|
297 | function cjs(bundle, magicString, _ref) {
|
298 | var exportMode = _ref.exportMode;
|
299 |
|
300 | var intro = '\'use strict\';\n\n';
|
301 |
|
302 |
|
303 | var importBlock = bundle.externalModules.map(function (module) {
|
304 | var requireStatement = 'var ' + module.name + ' = require(\'' + module.id + '\');';
|
305 |
|
306 | if (module.needsDefault) {
|
307 | requireStatement += '\n' + (module.needsNamed ? 'var ' + module.name + '__default = ' : module.name + ' = ') + ('\'default\' in ' + module.name + ' ? ' + module.name + '[\'default\'] : ' + module.name + ';');
|
308 | }
|
309 |
|
310 | return requireStatement;
|
311 | }).join('\n');
|
312 |
|
313 | if (importBlock) {
|
314 | intro += importBlock + '\n\n';
|
315 | }
|
316 |
|
317 | magicString.prepend(intro);
|
318 |
|
319 | var exportBlock = undefined;
|
320 | if (exportMode === 'default' && bundle.entryModule.exports.default) {
|
321 | exportBlock = 'module.exports = ' + bundle.entryModule.getCanonicalName('default') + ';';
|
322 | } else if (exportMode === 'named') {
|
323 | exportBlock = bundle.toExport.map(function (key) {
|
324 | var specifier = bundle.entryModule.exports[key];
|
325 | var name = bundle.entryModule.getCanonicalName(specifier.localName);
|
326 |
|
327 | return 'exports.' + key + ' = ' + name + ';';
|
328 | }).join('\n');
|
329 | }
|
330 |
|
331 | if (exportBlock) {
|
332 | magicString.append('\n\n' + exportBlock);
|
333 | }
|
334 |
|
335 | return magicString;
|
336 | }
|
337 |
|
338 | function amd(bundle, magicString, _ref, options) {
|
339 | var exportMode = _ref.exportMode;
|
340 | var indentString = _ref.indentString;
|
341 |
|
342 | var deps = bundle.externalModules.map(quoteId);
|
343 | var args = bundle.externalModules.map(getName);
|
344 |
|
345 | if (exportMode === 'named') {
|
346 | args.unshift('exports');
|
347 | deps.unshift('\'exports\'');
|
348 | }
|
349 |
|
350 | var params = (options.moduleId ? '[\'' + options.moduleId + '\'], ' : '') + (deps.length ? '[' + deps.join(', ') + '], ' : '');
|
351 |
|
352 | var intro = 'define(' + params + 'function (' + args.join(', ') + ') { \'use strict\';\n\n';
|
353 |
|
354 |
|
355 | var interopBlock = getInteropBlock(bundle);
|
356 | if (interopBlock) magicString.prepend(interopBlock + '\n\n');
|
357 |
|
358 | var exports = bundle.entryModule.exports;
|
359 |
|
360 | var exportBlock = undefined;
|
361 |
|
362 | if (exportMode === 'default') {
|
363 | exportBlock = 'return ' + bundle.entryModule.getCanonicalName('default') + ';';
|
364 | } else {
|
365 | exportBlock = bundle.toExport.map(function (name) {
|
366 | return 'exports.' + name + ' = ' + exports[name].localName + ';';
|
367 | }).join('\n');
|
368 | }
|
369 |
|
370 | if (exportBlock) magicString.append('\n\n' + exportBlock);
|
371 |
|
372 | return magicString.indent(indentString).append('\n\n});').prepend(intro);
|
373 | }
|
374 |
|
375 | var finalisers = { amd: amd, cjs: cjs, es6: es6, iife: iife, umd: umd };
|
376 |
|
377 | var reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public'.split(' ');
|
378 | var builtins = 'Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl'.split(' ');
|
379 |
|
380 | var blacklisted = blank();
|
381 | reservedWords.concat(builtins).forEach(function (word) {
|
382 | return blacklisted[word] = true;
|
383 | });
|
384 | function makeLegalIdentifier(str) {
|
385 | str = str.replace(/[^$_a-zA-Z0-9]/g, '_');
|
386 | if (/\d/.test(str[0]) || blacklisted[str]) str = '_' + str;
|
387 |
|
388 | return str;
|
389 | }
|
390 |
|
391 | var shouldSkip = undefined;
|
392 | var shouldAbort = undefined;
|
393 | function walk(ast, _ref) {
|
394 | var enter = _ref.enter;
|
395 | var leave = _ref.leave;
|
396 |
|
397 | shouldAbort = false;
|
398 | visit(ast, null, enter, leave);
|
399 | }
|
400 |
|
401 | var context = {
|
402 | skip: function () {
|
403 | return shouldSkip = true;
|
404 | },
|
405 | abort: function () {
|
406 | return shouldAbort = true;
|
407 | }
|
408 | };
|
409 |
|
410 | var childKeys = blank();
|
411 |
|
412 | var toString = Object.prototype.toString;
|
413 |
|
414 | function isArray(thing) {
|
415 | return toString.call(thing) === '[object Array]';
|
416 | }
|
417 |
|
418 | function visit(node, parent, enter, leave) {
|
419 | if (!node || shouldAbort) return;
|
420 |
|
421 | if (enter) {
|
422 | shouldSkip = false;
|
423 | enter.call(context, node, parent);
|
424 | if (shouldSkip || shouldAbort) return;
|
425 | }
|
426 |
|
427 | var keys = childKeys[node.type] || (childKeys[node.type] = Object.keys(node).filter(function (key) {
|
428 | return typeof node[key] === 'object';
|
429 | }));
|
430 |
|
431 | var key = undefined,
|
432 | value = undefined,
|
433 | i = undefined,
|
434 | j = undefined;
|
435 |
|
436 | i = keys.length;
|
437 | while (i--) {
|
438 | key = keys[i];
|
439 | value = node[key];
|
440 |
|
441 | if (isArray(value)) {
|
442 | j = value.length;
|
443 | while (j--) {
|
444 | visit(value[j], node, enter, leave);
|
445 | }
|
446 | } else if (value && value.type) {
|
447 | visit(value, node, enter, leave);
|
448 | }
|
449 | }
|
450 |
|
451 | if (leave && !shouldAbort) {
|
452 | leave(node, parent);
|
453 | }
|
454 | }
|
455 |
|
456 | function sequence(arr, callback) {
|
457 | var len = arr.length;
|
458 | var results = new Array(len);
|
459 |
|
460 | var promise = _Promise.resolve();
|
461 |
|
462 | function next(i) {
|
463 | return promise.then(function () {
|
464 | return callback(arr[i], i);
|
465 | }).then(function (result) {
|
466 | return results[i] = result;
|
467 | });
|
468 | }
|
469 |
|
470 | var i = undefined;
|
471 |
|
472 | for (i = 0; i < len; i += 1) {
|
473 | promise = next(i);
|
474 | }
|
475 |
|
476 | return promise.then(function () {
|
477 | return results;
|
478 | });
|
479 | }
|
480 |
|
481 | function first(arr, fail, callback) {
|
482 | var len = arr.length;
|
483 |
|
484 | var promise = _Promise.reject(fail);
|
485 |
|
486 | function next(i) {
|
487 | return promise.catch(function () {
|
488 | return callback(arr[i], i);
|
489 | });
|
490 | }
|
491 |
|
492 | var i = undefined;
|
493 |
|
494 | for (i = 0; i < len; i += 1) {
|
495 | promise = next(i);
|
496 | }
|
497 |
|
498 | return promise;
|
499 | }
|
500 |
|
501 | function getLocation(source, charIndex) {
|
502 | var lines = source.split('\n');
|
503 | var len = lines.length;
|
504 |
|
505 | var lineStart = 0;
|
506 | var i = undefined;
|
507 |
|
508 | for (i = 0; i < len; i += 1) {
|
509 | var line = lines[i];
|
510 | var lineEnd = lineStart + line.length + 1;
|
511 |
|
512 | if (lineEnd > charIndex) {
|
513 | return { line: i + 1, column: charIndex - lineStart };
|
514 | }
|
515 |
|
516 | lineStart = lineEnd;
|
517 | }
|
518 |
|
519 | throw new Error('Could not determine location of character');
|
520 | }
|
521 |
|
522 | var classCallCheck = function (instance, Constructor) {
|
523 | if (!(instance instanceof Constructor)) {
|
524 | throw new TypeError("Cannot call a class as a function");
|
525 | }
|
526 | };
|
527 |
|
528 | var blockDeclarations = {
|
529 | 'const': true,
|
530 | 'let': true
|
531 | };
|
532 |
|
533 | var Scope = (function () {
|
534 | function Scope(options) {
|
535 | var _this = this;
|
536 |
|
537 | classCallCheck(this, Scope);
|
538 |
|
539 | options = options || {};
|
540 |
|
541 | this.parent = options.parent;
|
542 | this.depth = this.parent ? this.parent.depth + 1 : 0;
|
543 | this.declarations = blank();
|
544 | this.isBlockScope = !!options.block;
|
545 |
|
546 | if (options.params) {
|
547 | options.params.forEach(function (param) {
|
548 | _this.declarations[param.name] = param;
|
549 | });
|
550 | }
|
551 | }
|
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 | Scope.prototype.addDeclaration = function addDeclaration(name, declaration) {
|
564 | var isBlockDeclaration = declaration.type === 'VariableDeclaration' && blockDeclarations[declaration.kind];
|
565 |
|
566 | if (!isBlockDeclaration && this.isBlockScope) {
|
567 |
|
568 |
|
569 | this.parent.addDeclaration(name, declaration);
|
570 | } else {
|
571 | this.declarations[name] = declaration;
|
572 | }
|
573 | };
|
574 |
|
575 | Scope.prototype.contains = function contains(name) {
|
576 | return !!this.getDeclaration(name);
|
577 | };
|
578 |
|
579 | Scope.prototype.findDefiningScope = function findDefiningScope(name) {
|
580 | if (!!this.declarations[name]) {
|
581 | return this;
|
582 | }
|
583 |
|
584 | if (this.parent) {
|
585 | return this.parent.findDefiningScope(name);
|
586 | }
|
587 |
|
588 | return null;
|
589 | };
|
590 |
|
591 | Scope.prototype.getDeclaration = function getDeclaration(name) {
|
592 | return this.declarations[name] || this.parent && this.parent.getDeclaration(name);
|
593 | };
|
594 |
|
595 | return Scope;
|
596 | })();
|
597 |
|
598 | function isIife(node, parent) {
|
599 | return parent && parent.type === 'CallExpression' && node === parent.callee;
|
600 | }
|
601 |
|
602 | var Statement = (function () {
|
603 | function Statement(node, module, start, end) {
|
604 | classCallCheck(this, Statement);
|
605 |
|
606 | this.node = node;
|
607 | this.module = module;
|
608 | this.start = start;
|
609 | this.end = end;
|
610 | this.next = null;
|
611 |
|
612 | this.scope = new Scope();
|
613 | this.defines = blank();
|
614 | this.modifies = blank();
|
615 | this.dependsOn = blank();
|
616 | this.stronglyDependsOn = blank();
|
617 |
|
618 | this.isIncluded = false;
|
619 |
|
620 | this.isImportDeclaration = node.type === 'ImportDeclaration';
|
621 | this.isExportDeclaration = /^Export/.test(node.type);
|
622 | }
|
623 |
|
624 | Statement.prototype.analyse = function analyse() {
|
625 | var _this = this;
|
626 |
|
627 | if (this.isImportDeclaration) return;
|
628 |
|
629 | var scope = this.scope;
|
630 |
|
631 | walk(this.node, {
|
632 | enter: function (node, parent) {
|
633 | var newScope = undefined;
|
634 |
|
635 | switch (node.type) {
|
636 | case 'FunctionExpression':
|
637 | case 'FunctionDeclaration':
|
638 | case 'ArrowFunctionExpression':
|
639 | if (node.type === 'FunctionDeclaration') {
|
640 | scope.addDeclaration(node.id.name, node);
|
641 | }
|
642 |
|
643 | newScope = new Scope({
|
644 | parent: scope,
|
645 | params: node.params,
|
646 | block: false
|
647 | });
|
648 |
|
649 |
|
650 |
|
651 | if (node.type === 'FunctionExpression' && node.id) {
|
652 | newScope.addDeclaration(node.id.name, node);
|
653 | }
|
654 |
|
655 | break;
|
656 |
|
657 | case 'BlockStatement':
|
658 | if (!/Function/.test(parent.type)) {
|
659 | newScope = new Scope({
|
660 | parent: scope,
|
661 | block: true
|
662 | });
|
663 | }
|
664 |
|
665 | break;
|
666 |
|
667 | case 'CatchClause':
|
668 | newScope = new Scope({
|
669 | parent: scope,
|
670 | params: [node.param],
|
671 | block: true
|
672 | });
|
673 |
|
674 | break;
|
675 |
|
676 | case 'VariableDeclaration':
|
677 | node.declarations.forEach(function (declarator) {
|
678 | scope.addDeclaration(declarator.id.name, node);
|
679 | });
|
680 | break;
|
681 |
|
682 | case 'ClassDeclaration':
|
683 | scope.addDeclaration(node.id.name, node);
|
684 | break;
|
685 | }
|
686 |
|
687 | if (newScope) {
|
688 | Object.defineProperty(node, '_scope', { value: newScope });
|
689 | scope = newScope;
|
690 | }
|
691 | },
|
692 | leave: function (node) {
|
693 | if (node._scope) {
|
694 | scope = scope.parent;
|
695 | }
|
696 | }
|
697 | });
|
698 |
|
699 |
|
700 |
|
701 |
|
702 |
|
703 |
|
704 |
|
705 |
|
706 |
|
707 |
|
708 |
|
709 |
|
710 | var depth = 0;
|
711 |
|
712 | if (!this.isImportDeclaration) {
|
713 | walk(this.node, {
|
714 | enter: function (node, parent) {
|
715 | if (node._scope) {
|
716 | if (!scope.isBlockScope && !isIife(node, parent)) depth += 1;
|
717 | scope = node._scope;
|
718 | }
|
719 |
|
720 | _this.checkForReads(scope, node, parent, !depth);
|
721 | _this.checkForWrites(scope, node);
|
722 | },
|
723 | leave: function (node, parent) {
|
724 | if (node._scope) {
|
725 | if (!scope.isBlockScope && !isIife(node, parent)) depth -= 1;
|
726 | scope = scope.parent;
|
727 | }
|
728 | }
|
729 | });
|
730 | }
|
731 |
|
732 | keys(scope.declarations).forEach(function (name) {
|
733 | _this.defines[name] = true;
|
734 | });
|
735 | };
|
736 |
|
737 | Statement.prototype.checkForReads = function checkForReads(scope, node, parent, strong) {
|
738 | if (node.type === 'Identifier') {
|
739 |
|
740 | if (parent.type === 'MemberExpression' && !parent.computed && node !== parent.object) {
|
741 | return;
|
742 | }
|
743 |
|
744 |
|
745 | if (parent.type === 'Property' && node !== parent.value) {
|
746 | return;
|
747 | }
|
748 |
|
749 |
|
750 | if (parent.type === 'MethodDefinition') return;
|
751 |
|
752 | var definingScope = scope.findDefiningScope(node.name);
|
753 |
|
754 | if ((!definingScope || definingScope.depth === 0) && !this.defines[node.name]) {
|
755 | this.dependsOn[node.name] = true;
|
756 | if (strong) this.stronglyDependsOn[node.name] = true;
|
757 | }
|
758 | }
|
759 | };
|
760 |
|
761 | Statement.prototype.checkForWrites = function checkForWrites(scope, node) {
|
762 | var _this2 = this;
|
763 |
|
764 | var addNode = function (node, isAssignment) {
|
765 | var depth = 0;
|
766 |
|
767 | while (node.type === 'MemberExpression') {
|
768 | node = node.object;
|
769 | depth += 1;
|
770 | }
|
771 |
|
772 |
|
773 | if (isAssignment) {
|
774 | var importSpecifier = _this2.module.imports[node.name];
|
775 |
|
776 | if (importSpecifier && !scope.contains(node.name)) {
|
777 | var minDepth = importSpecifier.name === '*' ? 2 :
|
778 | 1;
|
779 |
|
780 | if (depth < minDepth) {
|
781 | var err = new Error('Illegal reassignment to import \'' + node.name + '\'');
|
782 | err.file = _this2.module.id;
|
783 | err.loc = getLocation(_this2.module.magicString.toString(), node.start);
|
784 | throw err;
|
785 | }
|
786 | }
|
787 |
|
788 |
|
789 |
|
790 |
|
791 | if (_this2.module.exports.default && depth === 0 && _this2.module.exports.default.identifier === node.name) {
|
792 |
|
793 |
|
794 | if (!!scope.parent || node.start > _this2.module.exports.default.statement.node.start) {
|
795 | _this2.module.exports.default.isModified = true;
|
796 | }
|
797 | }
|
798 | }
|
799 |
|
800 | if (node.type === 'Identifier') {
|
801 | _this2.modifies[node.name] = true;
|
802 | }
|
803 | };
|
804 |
|
805 | if (node.type === 'AssignmentExpression') {
|
806 | addNode(node.left, true);
|
807 | } else if (node.type === 'UpdateExpression') {
|
808 | addNode(node.argument, true);
|
809 | } else if (node.type === 'CallExpression') {
|
810 | node.arguments.forEach(function (arg) {
|
811 | return addNode(arg, false);
|
812 | });
|
813 |
|
814 |
|
815 | if (node.callee.type === 'MemberExpression') {
|
816 | addNode(node.callee);
|
817 | }
|
818 | }
|
819 | };
|
820 |
|
821 | Statement.prototype.mark = function mark() {
|
822 | var _this3 = this;
|
823 |
|
824 | if (this.isIncluded) return;
|
825 | this.isIncluded = true;
|
826 |
|
827 | var dependencies = Object.keys(this.dependsOn);
|
828 |
|
829 | return sequence(dependencies, function (name) {
|
830 | if (_this3.defines[name]) return;
|
831 | return _this3.module.mark(name);
|
832 | });
|
833 | };
|
834 |
|
835 | Statement.prototype.replaceIdentifiers = function replaceIdentifiers(magicString, names, bundleExports) {
|
836 | var replacementStack = [names];
|
837 | var nameList = keys(names);
|
838 |
|
839 | var deshadowList = [];
|
840 | nameList.forEach(function (name) {
|
841 | var replacement = names[name];
|
842 | deshadowList.push(replacement.split('.')[0]);
|
843 | });
|
844 |
|
845 | var topLevel = true;
|
846 | var depth = 0;
|
847 |
|
848 | walk(this.node, {
|
849 | enter: function (node, parent) {
|
850 | var _this4 = this;
|
851 |
|
852 | if (node._skip) return this.skip();
|
853 |
|
854 | if (/^Function/.test(node.type)) depth += 1;
|
855 |
|
856 |
|
857 | if (node.type === 'ThisExpression' && depth === 0) {
|
858 | magicString.overwrite(node.start, node.end, 'undefined');
|
859 | }
|
860 |
|
861 |
|
862 |
|
863 | if (topLevel) {
|
864 | if (node.type === 'VariableDeclaration') {
|
865 |
|
866 |
|
867 | var _name = node.declarations[0].id.name;
|
868 | if (node.declarations.length === 1 && bundleExports[_name]) {
|
869 | magicString.overwrite(node.start, node.declarations[0].id.end, bundleExports[_name]);
|
870 | node.declarations[0].id._skip = true;
|
871 | }
|
872 |
|
873 |
|
874 | else {
|
875 | var exportInitialisers = node.declarations.map(function (declarator) {
|
876 | return declarator.id.name;
|
877 | }).filter(function (name) {
|
878 | return !!bundleExports[name];
|
879 | }).map(function (name) {
|
880 | return '\n' + bundleExports[name] + ' = ' + name + ';';
|
881 | }).join('');
|
882 |
|
883 | if (exportInitialisers) {
|
884 |
|
885 | try {
|
886 | magicString.insert(node.end, exportInitialisers);
|
887 | } catch (err) {
|
888 | magicString.append(exportInitialisers);
|
889 | }
|
890 | }
|
891 | }
|
892 | }
|
893 | }
|
894 |
|
895 | var scope = node._scope;
|
896 |
|
897 | if (scope) {
|
898 | var _ret = (function () {
|
899 | topLevel = false;
|
900 |
|
901 | var newNames = blank();
|
902 | var hasReplacements = undefined;
|
903 |
|
904 |
|
905 | if (node.id && names[node.id.name] && scope.declarations[node.id.name]) {
|
906 | magicString.overwrite(node.id.start, node.id.end, names[node.id.name]);
|
907 | }
|
908 |
|
909 | keys(names).forEach(function (name) {
|
910 | if (!scope.declarations[name]) {
|
911 | newNames[name] = names[name];
|
912 | hasReplacements = true;
|
913 | }
|
914 | });
|
915 |
|
916 | deshadowList.forEach(function (name) {
|
917 | if (~scope.declarations[name]) {
|
918 |
|
919 | newNames[name] = name + '$$';
|
920 | hasReplacements = true;
|
921 | }
|
922 | });
|
923 |
|
924 | if (!hasReplacements && depth > 0) {
|
925 | return {
|
926 | v: _this4.skip()
|
927 | };
|
928 | }
|
929 |
|
930 | names = newNames;
|
931 | replacementStack.push(newNames);
|
932 | })();
|
933 |
|
934 | if (typeof _ret === 'object') return _ret.v;
|
935 | }
|
936 |
|
937 | if (node.type !== 'Identifier') return;
|
938 |
|
939 |
|
940 | var name = names[node.name];
|
941 | if (!name || name === node.name) return;
|
942 |
|
943 |
|
944 | if (parent.type === 'Property' && parent.shorthand) {
|
945 | magicString.insert(node.end, ': ' + name);
|
946 | parent.key._skip = true;
|
947 | parent.value._skip = true;
|
948 | return;
|
949 | }
|
950 |
|
951 |
|
952 | if (parent.type === 'MemberExpression' && !parent.computed && node !== parent.object) return;
|
953 | if (parent.type === 'Property' && node !== parent.value) return;
|
954 | if (parent.type === 'MethodDefinition' && node === parent.key) return;
|
955 |
|
956 |
|
957 |
|
958 | magicString.overwrite(node.start, node.end, name);
|
959 | },
|
960 |
|
961 | leave: function (node) {
|
962 | if (/^Function/.test(node.type)) depth -= 1;
|
963 |
|
964 | if (node._scope) {
|
965 | replacementStack.pop();
|
966 | names = replacementStack[replacementStack.length - 1];
|
967 | }
|
968 | }
|
969 | });
|
970 |
|
971 | return magicString;
|
972 | };
|
973 |
|
974 | return Statement;
|
975 | })();
|
976 |
|
977 | var emptyArrayPromise = _Promise.resolve([]);
|
978 |
|
979 | function deconflict(name, names) {
|
980 | while (name in names) {
|
981 | name = '_' + name;
|
982 | }
|
983 |
|
984 | return name;
|
985 | }
|
986 |
|
987 | function isEmptyExportedVarDeclaration(node, module, allBundleExports, es6) {
|
988 | if (node.type !== 'VariableDeclaration' || node.declarations[0].init) return false;
|
989 |
|
990 | var name = node.declarations[0].id.name;
|
991 | var canonicalName = module.getCanonicalName(name, es6);
|
992 |
|
993 | return canonicalName in allBundleExports;
|
994 | }
|
995 |
|
996 | var Module = (function () {
|
997 | function Module(_ref) {
|
998 | var id = _ref.id;
|
999 | var source = _ref.source;
|
1000 | var bundle = _ref.bundle;
|
1001 | classCallCheck(this, Module);
|
1002 |
|
1003 | this.source = source;
|
1004 |
|
1005 | this.bundle = bundle;
|
1006 | this.id = id;
|
1007 |
|
1008 |
|
1009 |
|
1010 | this.magicString = new MagicString(source, {
|
1011 | filename: id
|
1012 | });
|
1013 |
|
1014 | this.suggestedNames = blank();
|
1015 | this.comments = [];
|
1016 |
|
1017 | this.statements = this._parse();
|
1018 |
|
1019 |
|
1020 | this.imports = blank();
|
1021 | this.exports = blank();
|
1022 |
|
1023 | this.exportAlls = blank();
|
1024 |
|
1025 |
|
1026 | this.exportDelegates = [];
|
1027 |
|
1028 | this.canonicalNames = blank();
|
1029 |
|
1030 | this.definitions = blank();
|
1031 | this.definitionPromises = blank();
|
1032 | this.modifications = blank();
|
1033 |
|
1034 | this.analyse();
|
1035 | }
|
1036 |
|
1037 | Module.prototype.addExport = function addExport(statement) {
|
1038 | var _this = this;
|
1039 |
|
1040 | var node = statement.node;
|
1041 | var source = node.source && node.source.value;
|
1042 |
|
1043 |
|
1044 |
|
1045 |
|
1046 | if (node.type === 'ExportDefaultDeclaration') {
|
1047 | var isDeclaration = /Declaration$/.test(node.declaration.type);
|
1048 | var isAnonymous = /(?:Class|Function)Expression$/.test(node.declaration.type);
|
1049 |
|
1050 | var declaredName = isDeclaration && node.declaration.id.name;
|
1051 | var identifier = node.declaration.type === 'Identifier' && node.declaration.name;
|
1052 |
|
1053 | this.exports.default = {
|
1054 | statement: statement,
|
1055 | name: 'default',
|
1056 | localName: declaredName || 'default',
|
1057 | declaredName: declaredName,
|
1058 | identifier: identifier,
|
1059 | isDeclaration: isDeclaration,
|
1060 | isAnonymous: isAnonymous,
|
1061 | isModified: false
|
1062 | };
|
1063 | }
|
1064 |
|
1065 |
|
1066 |
|
1067 |
|
1068 | else if (node.type === 'ExportNamedDeclaration') {
|
1069 | if (node.specifiers.length) {
|
1070 |
|
1071 | node.specifiers.forEach(function (specifier) {
|
1072 | var localName = specifier.local.name;
|
1073 | var exportedName = specifier.exported.name;
|
1074 |
|
1075 | _this.exports[exportedName] = {
|
1076 | localName: localName,
|
1077 | exportedName: exportedName
|
1078 | };
|
1079 |
|
1080 |
|
1081 | if (source) {
|
1082 | _this.imports[localName] = {
|
1083 | source: source,
|
1084 | localName: localName,
|
1085 | name: localName
|
1086 | };
|
1087 | }
|
1088 | });
|
1089 | } else {
|
1090 | var declaration = node.declaration;
|
1091 |
|
1092 | var _name = undefined;
|
1093 |
|
1094 | if (declaration.type === 'VariableDeclaration') {
|
1095 |
|
1096 | _name = declaration.declarations[0].id.name;
|
1097 | } else {
|
1098 |
|
1099 | _name = declaration.id.name;
|
1100 | }
|
1101 |
|
1102 | this.exports[_name] = {
|
1103 | statement: statement,
|
1104 | localName: _name,
|
1105 | expression: declaration
|
1106 | };
|
1107 | }
|
1108 | }
|
1109 |
|
1110 |
|
1111 |
|
1112 | else {
|
1113 | this.exportDelegates.push({
|
1114 | statement: statement,
|
1115 | source: source
|
1116 | });
|
1117 | }
|
1118 | };
|
1119 |
|
1120 | Module.prototype.addImport = function addImport(statement) {
|
1121 | var _this2 = this;
|
1122 |
|
1123 | var node = statement.node;
|
1124 | var source = node.source.value;
|
1125 |
|
1126 | node.specifiers.forEach(function (specifier) {
|
1127 | var isDefault = specifier.type === 'ImportDefaultSpecifier';
|
1128 | var isNamespace = specifier.type === 'ImportNamespaceSpecifier';
|
1129 |
|
1130 | var localName = specifier.local.name;
|
1131 | var name = isDefault ? 'default' : isNamespace ? '*' : specifier.imported.name;
|
1132 |
|
1133 | if (_this2.imports[localName]) {
|
1134 | var err = new Error('Duplicated import \'' + localName + '\'');
|
1135 | err.file = _this2.id;
|
1136 | err.loc = getLocation(_this2.source, specifier.start);
|
1137 | throw err;
|
1138 | }
|
1139 |
|
1140 | _this2.imports[localName] = {
|
1141 | source: source,
|
1142 | name: name,
|
1143 | localName: localName
|
1144 | };
|
1145 | });
|
1146 | };
|
1147 |
|
1148 | Module.prototype.analyse = function analyse() {
|
1149 | var _this3 = this;
|
1150 |
|
1151 |
|
1152 | this.statements.forEach(function (statement) {
|
1153 | if (statement.isImportDeclaration) _this3.addImport(statement);else if (statement.isExportDeclaration) _this3.addExport(statement);
|
1154 |
|
1155 | statement.analyse();
|
1156 |
|
1157 |
|
1158 | keys(statement.defines).forEach(function (name) {
|
1159 | _this3.definitions[name] = statement;
|
1160 | });
|
1161 |
|
1162 | keys(statement.modifies).forEach(function (name) {
|
1163 | (_this3.modifications[name] || (_this3.modifications[name] = [])).push(statement);
|
1164 | });
|
1165 | });
|
1166 |
|
1167 |
|
1168 |
|
1169 | this.statements.forEach(function (statement) {
|
1170 | keys(statement.dependsOn).forEach(function (name) {
|
1171 | if (!_this3.definitions[name] && !_this3.imports[name]) {
|
1172 | _this3.bundle.assumedGlobals[name] = true;
|
1173 | }
|
1174 | });
|
1175 | });
|
1176 | };
|
1177 |
|
1178 | Module.prototype.consolidateDependencies = function consolidateDependencies() {
|
1179 | var _this4 = this;
|
1180 |
|
1181 | var strongDependencies = blank();
|
1182 |
|
1183 | this.statements.forEach(function (statement) {
|
1184 | if (statement.isImportDeclaration && !statement.node.specifiers.length && !statement.module.isExternal) {
|
1185 |
|
1186 | strongDependencies[statement.module.id] = statement.module;
|
1187 | }
|
1188 |
|
1189 | keys(statement.stronglyDependsOn).forEach(function (name) {
|
1190 | if (statement.defines[name]) return;
|
1191 |
|
1192 | var exportAllDeclaration = _this4.exportAlls[name];
|
1193 |
|
1194 | if (exportAllDeclaration && exportAllDeclaration.module && !exportAllDeclaration.module.isExternal) {
|
1195 | strongDependencies[exportAllDeclaration.module.id] = exportAllDeclaration.module;
|
1196 | return;
|
1197 | }
|
1198 |
|
1199 | var importDeclaration = _this4.imports[name];
|
1200 |
|
1201 | if (importDeclaration && importDeclaration.module && !importDeclaration.module.isExternal) {
|
1202 | strongDependencies[importDeclaration.module.id] = importDeclaration.module;
|
1203 | }
|
1204 | });
|
1205 | });
|
1206 |
|
1207 | var weakDependencies = blank();
|
1208 |
|
1209 | this.statements.forEach(function (statement) {
|
1210 | keys(statement.dependsOn).forEach(function (name) {
|
1211 | if (statement.defines[name]) return;
|
1212 |
|
1213 | var importDeclaration = _this4.imports[name];
|
1214 |
|
1215 | if (importDeclaration && importDeclaration.module && !importDeclaration.module.isExternal) {
|
1216 | weakDependencies[importDeclaration.module.id] = importDeclaration.module;
|
1217 | }
|
1218 | });
|
1219 | });
|
1220 |
|
1221 | return { strongDependencies: strongDependencies, weakDependencies: weakDependencies };
|
1222 | };
|
1223 |
|
1224 | Module.prototype.findDefiningStatement = function findDefiningStatement(name) {
|
1225 | if (this.definitions[name]) return this.definitions[name];
|
1226 |
|
1227 |
|
1228 |
|
1229 | var importDeclaration = this.imports[name];
|
1230 | if (!importDeclaration) return null;
|
1231 |
|
1232 | return _Promise.resolve(importDeclaration.module || this.bundle.fetchModule(importDeclaration.source, this.id)).then(function (module) {
|
1233 | importDeclaration.module = module;
|
1234 | return module.findDefiningStatement(name);
|
1235 | });
|
1236 | };
|
1237 |
|
1238 | Module.prototype.findDeclaration = function findDeclaration(localName) {
|
1239 | var importDeclaration = this.imports[localName];
|
1240 |
|
1241 |
|
1242 | if (importDeclaration) {
|
1243 | var _module = importDeclaration.module;
|
1244 |
|
1245 | if (_module.isExternal) return null;
|
1246 |
|
1247 | var exportDeclaration = _module.exports[importDeclaration.name];
|
1248 | return _module.findDeclaration(exportDeclaration.localName);
|
1249 | }
|
1250 |
|
1251 |
|
1252 | var i = this.statements.length;
|
1253 | while (i--) {
|
1254 | var declaration = this.statements[i].scope.declarations[localName];
|
1255 | if (declaration) {
|
1256 | return declaration;
|
1257 | }
|
1258 | }
|
1259 |
|
1260 | return null;
|
1261 | };
|
1262 |
|
1263 | Module.prototype.getCanonicalName = function getCanonicalName(localName, es6) {
|
1264 |
|
1265 | if (localName === 'default' && (this.exports.default.isModified || !this.suggestedNames.default)) {
|
1266 | var canonicalName = makeLegalIdentifier(this.id.replace(dirname(this.bundle.entryModule.id) + '/', '').replace(/\.js$/, ''));
|
1267 | return deconflict(canonicalName, this.definitions);
|
1268 | }
|
1269 |
|
1270 | if (this.suggestedNames[localName]) {
|
1271 | localName = this.suggestedNames[localName];
|
1272 | }
|
1273 |
|
1274 | var id = localName + (es6 ? '-es6' : '');
|
1275 |
|
1276 | if (!this.canonicalNames[id]) {
|
1277 | var canonicalName = undefined;
|
1278 |
|
1279 | if (this.imports[localName]) {
|
1280 | var importDeclaration = this.imports[localName];
|
1281 | var _module2 = importDeclaration.module;
|
1282 |
|
1283 | if (importDeclaration.name === '*') {
|
1284 | canonicalName = _module2.suggestedNames['*'];
|
1285 | } else {
|
1286 | var exporterLocalName = undefined;
|
1287 |
|
1288 | if (_module2.isExternal) {
|
1289 | exporterLocalName = importDeclaration.name;
|
1290 | } else {
|
1291 | var exportDeclaration = _module2.exports[importDeclaration.name];
|
1292 |
|
1293 |
|
1294 | if (exportDeclaration) {
|
1295 | exporterLocalName = exportDeclaration.localName;
|
1296 | } else {
|
1297 |
|
1298 | exporterLocalName = importDeclaration.name;
|
1299 | }
|
1300 | }
|
1301 |
|
1302 | canonicalName = _module2.getCanonicalName(exporterLocalName, es6);
|
1303 | }
|
1304 | } else {
|
1305 | canonicalName = localName;
|
1306 | }
|
1307 |
|
1308 | this.canonicalNames[id] = canonicalName;
|
1309 | }
|
1310 |
|
1311 | return this.canonicalNames[id];
|
1312 | };
|
1313 |
|
1314 | Module.prototype.mark = function mark(name) {
|
1315 | var _this5 = this;
|
1316 |
|
1317 |
|
1318 | if (this.definitionPromises[name]) {
|
1319 | return emptyArrayPromise;
|
1320 | }
|
1321 |
|
1322 | var promise = undefined;
|
1323 |
|
1324 |
|
1325 | if (this.imports[name]) {
|
1326 | (function () {
|
1327 | var importDeclaration = _this5.imports[name];
|
1328 |
|
1329 | promise = _this5.bundle.fetchModule(importDeclaration.source, _this5.id).then(function (module) {
|
1330 | importDeclaration.module = module;
|
1331 |
|
1332 |
|
1333 | if (importDeclaration.name === 'default') {
|
1334 |
|
1335 | var localName = importDeclaration.localName;
|
1336 | var suggestion = _this5.suggestedNames[localName] || localName;
|
1337 |
|
1338 |
|
1339 | while (!module.isExternal && module.imports[suggestion]) {
|
1340 | suggestion = '_' + suggestion;
|
1341 | }
|
1342 |
|
1343 | module.suggestName('default', suggestion);
|
1344 | } else if (importDeclaration.name === '*') {
|
1345 | var localName = importDeclaration.localName;
|
1346 | var suggestion = _this5.suggestedNames[localName] || localName;
|
1347 | module.suggestName('*', suggestion);
|
1348 | module.suggestName('default', suggestion + '__default');
|
1349 | }
|
1350 |
|
1351 | if (module.isExternal) {
|
1352 | if (importDeclaration.name === 'default') {
|
1353 | module.needsDefault = true;
|
1354 | } else if (importDeclaration.name === '*') {
|
1355 | module.needsAll = true;
|
1356 | } else {
|
1357 | module.needsNamed = true;
|
1358 | }
|
1359 |
|
1360 | module.importedByBundle.push(importDeclaration);
|
1361 | return emptyArrayPromise;
|
1362 | }
|
1363 |
|
1364 | if (importDeclaration.name === '*') {
|
1365 |
|
1366 | if (! ~_this5.bundle.internalNamespaceModules.indexOf(module)) {
|
1367 | _this5.bundle.internalNamespaceModules.push(module);
|
1368 | }
|
1369 |
|
1370 | return module.markAllStatements();
|
1371 | }
|
1372 |
|
1373 | var exportDeclaration = module.exports[importDeclaration.name];
|
1374 |
|
1375 | if (!exportDeclaration) {
|
1376 | var _ret2 = (function () {
|
1377 | var noExport = new Error('Module ' + module.id + ' does not export ' + importDeclaration.name + ' (imported by ' + _this5.id + ')');
|
1378 |
|
1379 |
|
1380 | return {
|
1381 | v: first(module.exportDelegates, noExport, function (declaration) {
|
1382 | return module.bundle.fetchModule(declaration.source, module.id).then(function (submodule) {
|
1383 | declaration.module = submodule;
|
1384 |
|
1385 | return submodule.mark(name).then(function (result) {
|
1386 | if (!result.length) throw noExport;
|
1387 |
|
1388 |
|
1389 |
|
1390 | module.exportAlls[name] = declaration;
|
1391 |
|
1392 | declaration.statement.dependsOn[name] = declaration.statement.stronglyDependsOn[name] = result;
|
1393 |
|
1394 | return result;
|
1395 | });
|
1396 | });
|
1397 | })
|
1398 | };
|
1399 | })();
|
1400 |
|
1401 | if (typeof _ret2 === 'object') return _ret2.v;
|
1402 | }
|
1403 |
|
1404 | exportDeclaration.isUsed = true;
|
1405 | return module.mark(exportDeclaration.localName);
|
1406 | });
|
1407 | })();
|
1408 | }
|
1409 |
|
1410 |
|
1411 | else if (name === 'default' && this.exports.default.isDeclaration) {
|
1412 |
|
1413 |
|
1414 | promise = this.mark(this.exports.default.name);
|
1415 | } else {
|
1416 | (function () {
|
1417 | var statement = undefined;
|
1418 |
|
1419 | statement = name === 'default' ? _this5.exports.default.statement : _this5.definitions[name];
|
1420 | promise = statement && !statement.isIncluded ? statement.mark() : emptyArrayPromise;
|
1421 |
|
1422 |
|
1423 |
|
1424 |
|
1425 |
|
1426 |
|
1427 | if (name === 'default' && _this5.exports.default.identifier && _this5.exports.default.isModified) {
|
1428 | (function () {
|
1429 | var defaultExportStatement = _this5.exports.default.statement;
|
1430 | promise = promise.then(function (statements) {
|
1431 |
|
1432 |
|
1433 | statements.splice(statements.indexOf(defaultExportStatement), 1);
|
1434 |
|
1435 | var i = statements.length;
|
1436 | var inserted = false;
|
1437 |
|
1438 | while (i--) {
|
1439 | if (statements[i].module === _this5 && statements[i].index < defaultExportStatement.index) {
|
1440 | statements.splice(i + 1, 0, defaultExportStatement);
|
1441 | inserted = true;
|
1442 | break;
|
1443 | }
|
1444 | }
|
1445 |
|
1446 | if (!inserted) statements.push(statement);
|
1447 | return statements;
|
1448 | });
|
1449 | })();
|
1450 | }
|
1451 | })();
|
1452 | }
|
1453 |
|
1454 | this.definitionPromises[name] = promise || emptyArrayPromise;
|
1455 | return this.definitionPromises[name];
|
1456 | };
|
1457 |
|
1458 | Module.prototype.markAllStatements = function markAllStatements(isEntryModule) {
|
1459 | var _this6 = this;
|
1460 |
|
1461 | return sequence(this.statements, function (statement) {
|
1462 | if (statement.isIncluded) return;
|
1463 |
|
1464 |
|
1465 | if (statement.isImportDeclaration) {
|
1466 |
|
1467 |
|
1468 | if (!statement.node.specifiers.length) {
|
1469 | return _this6.bundle.fetchModule(statement.node.source.value, _this6.id).then(function (module) {
|
1470 | statement.module = module;
|
1471 | if (module.isExternal) {
|
1472 | return;
|
1473 | }
|
1474 | return module.markAllStatements();
|
1475 | });
|
1476 | }
|
1477 |
|
1478 | return;
|
1479 | }
|
1480 |
|
1481 |
|
1482 | if (statement.node.type === 'ExportNamedDeclaration' && statement.node.specifiers.length) {
|
1483 |
|
1484 | if (isEntryModule) {
|
1485 | return statement.mark();
|
1486 | }
|
1487 |
|
1488 | return;
|
1489 | }
|
1490 |
|
1491 |
|
1492 | return statement.mark();
|
1493 | });
|
1494 | };
|
1495 |
|
1496 |
|
1497 |
|
1498 | Module.prototype._parse = function _parse() {
|
1499 | var _this7 = this;
|
1500 |
|
1501 |
|
1502 |
|
1503 | var ast = undefined;
|
1504 |
|
1505 | try {
|
1506 | ast = acorn.parse(this.source, {
|
1507 | ecmaVersion: 6,
|
1508 | sourceType: 'module',
|
1509 | onComment: function (block, text, start, end) {
|
1510 | return _this7.comments.push({ block: block, text: text, start: start, end: end });
|
1511 | }
|
1512 | });
|
1513 | } catch (err) {
|
1514 | err.code = 'PARSE_ERROR';
|
1515 | err.file = this.id;
|
1516 | throw err;
|
1517 | }
|
1518 |
|
1519 | walk(ast, {
|
1520 | enter: function (node) {
|
1521 | _this7.magicString.addSourcemapLocation(node.start);
|
1522 | _this7.magicString.addSourcemapLocation(node.end);
|
1523 | }
|
1524 | });
|
1525 |
|
1526 | var statements = [];
|
1527 | var lastChar = 0;
|
1528 | var commentIndex = 0;
|
1529 |
|
1530 | ast.body.forEach(function (node) {
|
1531 |
|
1532 |
|
1533 |
|
1534 | if (node.type === 'VariableDeclaration' && node.declarations.length > 1) {
|
1535 |
|
1536 | _this7.magicString.remove(node.start, node.declarations[0].start);
|
1537 |
|
1538 | node.declarations.forEach(function (declarator, i) {
|
1539 | var start = declarator.start;
|
1540 | var end = declarator.end;
|
1541 |
|
1542 | var syntheticNode = {
|
1543 | type: 'VariableDeclaration',
|
1544 | kind: node.kind,
|
1545 | start: start,
|
1546 | end: end,
|
1547 | declarations: [declarator],
|
1548 | isSynthetic: true
|
1549 | };
|
1550 |
|
1551 | var statement = new Statement(syntheticNode, _this7, start, end);
|
1552 | statements.push(statement);
|
1553 | });
|
1554 |
|
1555 | lastChar = node.end;
|
1556 | } else {
|
1557 | var comment = undefined;
|
1558 | do {
|
1559 | comment = _this7.comments[commentIndex];
|
1560 | if (!comment) break;
|
1561 | if (comment.start > node.start) break;
|
1562 | commentIndex += 1;
|
1563 | } while (comment.end < lastChar);
|
1564 |
|
1565 | var start = comment ? Math.min(comment.start, node.start) : node.start;
|
1566 | var end = node.end;
|
1567 |
|
1568 | var statement = new Statement(node, _this7, start, end);
|
1569 | statements.push(statement);
|
1570 |
|
1571 | lastChar = end;
|
1572 | }
|
1573 | });
|
1574 |
|
1575 | statements.forEach(function (statement, i) {
|
1576 | var nextStatement = statements[i + 1];
|
1577 | statement.next = nextStatement ? nextStatement.start : statement.end;
|
1578 | });
|
1579 |
|
1580 | return statements;
|
1581 | };
|
1582 |
|
1583 | Module.prototype.rename = function rename(name, replacement) {
|
1584 |
|
1585 | this.canonicalNames[name] = this.canonicalNames[name + '-es6'] = replacement;
|
1586 | };
|
1587 |
|
1588 | Module.prototype.render = function render(allBundleExports, format) {
|
1589 | var magicString = this.magicString.clone();
|
1590 |
|
1591 | var previousIndex = -1;
|
1592 | var previousMargin = 0;
|
1593 |
|
1594 | this.statements.forEach(function (statement, i) {
|
1595 | if (!statement.isIncluded) {
|
1596 | magicString.remove(statement.start, statement.next);
|
1597 | return;
|
1598 | }
|
1599 |
|
1600 |
|
1601 | if (statement.node.type === 'ExportNamedDeclaration') {
|
1602 |
|
1603 | if (statement.node.specifiers.length) {
|
1604 | magicString.remove(statement.start, statement.next);
|
1605 | return;
|
1606 | };
|
1607 |
|
1608 |
|
1609 | if (isEmptyExportedVarDeclaration(statement.node.declaration, statement.module, allBundleExports, format === 'es6')) {
|
1610 | magicString.remove(statement.start, statement.next);
|
1611 | return;
|
1612 | }
|
1613 | }
|
1614 |
|
1615 |
|
1616 |
|
1617 | if (isEmptyExportedVarDeclaration(statement.node, statement.module, allBundleExports, format === 'es6')) {
|
1618 | magicString.remove(statement.start, statement.next);
|
1619 | return;
|
1620 | }
|
1621 |
|
1622 |
|
1623 | if (statement.node.isSynthetic) {
|
1624 | magicString.insert(statement.start, statement.node.kind + ' ');
|
1625 | magicString.overwrite(statement.end, statement.next, ';\n');
|
1626 | }
|
1627 |
|
1628 | var replacements = blank();
|
1629 | var bundleExports = blank();
|
1630 |
|
1631 | keys(statement.dependsOn).concat(keys(statement.defines)).forEach(function (name) {
|
1632 | var canonicalName = statement.module.getCanonicalName(name, format === 'es6');
|
1633 |
|
1634 | if (allBundleExports[canonicalName]) {
|
1635 | bundleExports[name] = replacements[name] = allBundleExports[canonicalName];
|
1636 | } else if (name !== canonicalName) {
|
1637 | replacements[name] = canonicalName;
|
1638 | }
|
1639 | });
|
1640 |
|
1641 | statement.replaceIdentifiers(magicString, replacements, bundleExports);
|
1642 |
|
1643 |
|
1644 | if (statement.isExportDeclaration) {
|
1645 |
|
1646 | if (statement.node.type === 'ExportNamedDeclaration' && statement.node.declaration.type === 'VariableDeclaration') {
|
1647 | magicString.remove(statement.node.start, statement.node.declaration.start);
|
1648 | }
|
1649 |
|
1650 |
|
1651 |
|
1652 | else if (statement.node.declaration.id) {
|
1653 | magicString.remove(statement.node.start, statement.node.declaration.start);
|
1654 | } else if (statement.node.type === 'ExportDefaultDeclaration') {
|
1655 | var _module3 = statement.module;
|
1656 | var canonicalName = _module3.getCanonicalName('default', format === 'es6');
|
1657 |
|
1658 | if (statement.node.declaration.type === 'Identifier' && canonicalName === _module3.getCanonicalName(statement.node.declaration.name, format === 'es6')) {
|
1659 | magicString.remove(statement.start, statement.next);
|
1660 | return;
|
1661 | }
|
1662 |
|
1663 |
|
1664 | if (statement.node.declaration.type === 'FunctionExpression') {
|
1665 | magicString.overwrite(statement.node.start, statement.node.declaration.start + 8, 'function ' + canonicalName);
|
1666 | } else {
|
1667 | magicString.overwrite(statement.node.start, statement.node.declaration.start, 'var ' + canonicalName + ' = ');
|
1668 | }
|
1669 | } else {
|
1670 | throw new Error('Unhandled export');
|
1671 | }
|
1672 | }
|
1673 | });
|
1674 |
|
1675 | return magicString.trim();
|
1676 | };
|
1677 |
|
1678 | Module.prototype.suggestName = function suggestName(defaultOrBatch, suggestion) {
|
1679 |
|
1680 | var shouldDeconflict = this.exports.default && this.exports.default.isAnonymous;
|
1681 |
|
1682 | if (shouldDeconflict) suggestion = deconflict(suggestion, this.definitions);
|
1683 |
|
1684 | if (!this.suggestedNames[defaultOrBatch]) {
|
1685 | this.suggestedNames[defaultOrBatch] = makeLegalIdentifier(suggestion);
|
1686 | }
|
1687 | };
|
1688 |
|
1689 | return Module;
|
1690 | })();
|
1691 |
|
1692 | var ExternalModule = (function () {
|
1693 | function ExternalModule(id) {
|
1694 | classCallCheck(this, ExternalModule);
|
1695 |
|
1696 | this.id = id;
|
1697 | this.name = null;
|
1698 |
|
1699 | this.isExternal = true;
|
1700 | this.importedByBundle = [];
|
1701 |
|
1702 | this.canonicalNames = blank();
|
1703 | this.suggestedNames = blank();
|
1704 |
|
1705 | this.needsDefault = false;
|
1706 |
|
1707 |
|
1708 |
|
1709 |
|
1710 |
|
1711 |
|
1712 | this.needsNamed = false;
|
1713 | this.needsAll = false;
|
1714 | }
|
1715 |
|
1716 | ExternalModule.prototype.findDefiningStatement = function findDefiningStatement() {
|
1717 | return null;
|
1718 | };
|
1719 |
|
1720 | ExternalModule.prototype.getCanonicalName = function getCanonicalName(name, es6) {
|
1721 | if (name === 'default') {
|
1722 | return this.needsNamed && !es6 ? this.name + '__default' : this.name;
|
1723 | }
|
1724 |
|
1725 | if (name === '*') {
|
1726 | return this.name;
|
1727 | }
|
1728 |
|
1729 | return es6 ? this.canonicalNames[name] || name : this.name + '.' + name;
|
1730 | };
|
1731 |
|
1732 | ExternalModule.prototype.rename = function rename(name, replacement) {
|
1733 | this.canonicalNames[name] = replacement;
|
1734 | };
|
1735 |
|
1736 | ExternalModule.prototype.suggestName = function suggestName(exportName, suggestion) {
|
1737 | if (!this.suggestedNames[exportName]) {
|
1738 | this.suggestedNames[exportName] = suggestion;
|
1739 | }
|
1740 | };
|
1741 |
|
1742 | return ExternalModule;
|
1743 | })();
|
1744 |
|
1745 | function ensureArray(thing) {
|
1746 | if (Array.isArray(thing)) return thing;
|
1747 | if (thing == undefined) return [];
|
1748 | return [thing];
|
1749 | }
|
1750 |
|
1751 | function defaultResolver(importee, importer, options) {
|
1752 |
|
1753 | if (isAbsolute(importee)) return importee;
|
1754 |
|
1755 |
|
1756 | if (importer === undefined) return resolve(process.cwd(), importee);
|
1757 |
|
1758 |
|
1759 | if (importee[0] !== '.') {
|
1760 |
|
1761 | if (~options.external.indexOf(importee)) return null;
|
1762 |
|
1763 | return options.resolveExternal(importee, importer, options);
|
1764 | }
|
1765 |
|
1766 | return resolve(dirname(importer), importee).replace(/\.js$/, '') + '.js';
|
1767 | }
|
1768 |
|
1769 | function defaultExternalResolver(id, importer) {
|
1770 |
|
1771 | var root = absolutePath.exec(importer)[0];
|
1772 | var dir = dirname(importer);
|
1773 |
|
1774 | while (dir !== root) {
|
1775 | var pkgPath = resolve(dir, 'node_modules', id, 'package.json');
|
1776 | var pkgJson = undefined;
|
1777 |
|
1778 | try {
|
1779 | pkgJson = readFileSync(pkgPath).toString();
|
1780 | } catch (err) {}
|
1781 |
|
1782 | if (pkgJson) {
|
1783 | var pkg = undefined;
|
1784 |
|
1785 | try {
|
1786 | pkg = JSON.parse(pkgJson);
|
1787 | } catch (err) {
|
1788 | throw new Error('Malformed JSON: ' + pkgPath);
|
1789 | }
|
1790 |
|
1791 | var main = pkg['jsnext:main'];
|
1792 |
|
1793 | if (!main) {
|
1794 | throw new Error('Package ' + id + ' does not have a jsnext:main field, and so cannot be included in your rollup. Try adding it as an external module instead (e.g. options.external = [\'' + id + '\']). See https://github.com/rollup/rollup/wiki/jsnext:main for more info');
|
1795 | }
|
1796 |
|
1797 | return resolve(dirname(pkgPath), main).replace(/\.js$/, '') + '.js';
|
1798 | }
|
1799 |
|
1800 | dir = dirname(dir);
|
1801 | }
|
1802 |
|
1803 | throw new Error('Could not find package ' + id + ' (required by ' + importer + ')');
|
1804 | }
|
1805 |
|
1806 | function defaultLoader(id, options) {
|
1807 |
|
1808 | var source = readFileSync(id, { encoding: 'utf-8' });
|
1809 |
|
1810 | return options.transform.reduce(function (source, transformer) {
|
1811 | return transformer(source, id);
|
1812 | }, source);
|
1813 | }
|
1814 |
|
1815 | var Bundle = (function () {
|
1816 | function Bundle(options) {
|
1817 | classCallCheck(this, Bundle);
|
1818 |
|
1819 | this.entry = options.entry;
|
1820 | this.entryModule = null;
|
1821 |
|
1822 | this.resolveId = options.resolveId || defaultResolver;
|
1823 | this.load = options.load || defaultLoader;
|
1824 |
|
1825 | this.resolveOptions = {
|
1826 | external: ensureArray(options.external),
|
1827 | resolveExternal: options.resolveExternal || defaultExternalResolver
|
1828 | };
|
1829 |
|
1830 | this.loadOptions = {
|
1831 | transform: ensureArray(options.transform)
|
1832 | };
|
1833 |
|
1834 | this.varExports = blank();
|
1835 | this.toExport = null;
|
1836 |
|
1837 | this.modulePromises = blank();
|
1838 | this.modules = [];
|
1839 |
|
1840 | this.statements = null;
|
1841 | this.externalModules = [];
|
1842 | this.internalNamespaceModules = [];
|
1843 | this.assumedGlobals = blank();
|
1844 | }
|
1845 |
|
1846 | Bundle.prototype.build = function build() {
|
1847 | var _this = this;
|
1848 |
|
1849 | return this.fetchModule(this.entry, undefined).then(function (entryModule) {
|
1850 | var defaultExport = entryModule.exports.default;
|
1851 |
|
1852 | _this.entryModule = entryModule;
|
1853 |
|
1854 | if (defaultExport) {
|
1855 |
|
1856 |
|
1857 | if (defaultExport.declaredName) {
|
1858 | entryModule.suggestName('default', defaultExport.declaredName);
|
1859 | }
|
1860 |
|
1861 |
|
1862 |
|
1863 | else {
|
1864 | (function () {
|
1865 | var defaultExportName = makeLegalIdentifier(basename(_this.entryModule.id).slice(0, -extname(_this.entryModule.id).length));
|
1866 |
|
1867 |
|
1868 | var topLevelNames = [];
|
1869 | entryModule.statements.forEach(function (statement) {
|
1870 | keys(statement.defines).forEach(function (name) {
|
1871 | return topLevelNames.push(name);
|
1872 | });
|
1873 | });
|
1874 |
|
1875 | while (~topLevelNames.indexOf(defaultExportName)) {
|
1876 | defaultExportName = '_' + defaultExportName;
|
1877 | }
|
1878 |
|
1879 | entryModule.suggestName('default', defaultExportName);
|
1880 | })();
|
1881 | }
|
1882 | }
|
1883 |
|
1884 | return entryModule.markAllStatements(true);
|
1885 | }).then(function () {
|
1886 | return _this.markAllModifierStatements();
|
1887 | }).then(function () {
|
1888 | _this.orderedModules = _this.sort();
|
1889 | });
|
1890 | };
|
1891 |
|
1892 | Bundle.prototype.deconflict = function deconflict(es6) {
|
1893 | var _this2 = this;
|
1894 |
|
1895 | var definers = blank();
|
1896 | var conflicts = blank();
|
1897 |
|
1898 |
|
1899 | this.externalModules.forEach(function (module) {
|
1900 |
|
1901 | var name = makeLegalIdentifier(module.suggestedNames['*'] || module.suggestedNames.default || module.id);
|
1902 |
|
1903 | if (definers[name]) {
|
1904 | conflicts[name] = true;
|
1905 | } else {
|
1906 | definers[name] = [];
|
1907 | }
|
1908 |
|
1909 | definers[name].push(module);
|
1910 | module.name = name;
|
1911 | _this2.assumedGlobals[name] = true;
|
1912 | });
|
1913 |
|
1914 |
|
1915 | this.orderedModules.forEach(function (module) {
|
1916 | module.statements.forEach(function (statement) {
|
1917 | var names = keys(statement.defines);
|
1918 |
|
1919 |
|
1920 |
|
1921 |
|
1922 | if (statement.node.type === 'ExportDefaultDeclaration') {
|
1923 | var _name = module.getCanonicalName('default', es6);
|
1924 |
|
1925 | var isProxy = statement.node.declaration && statement.node.declaration.type === 'Identifier';
|
1926 | var shouldDeconflict = !isProxy || module.getCanonicalName(statement.node.declaration.name, es6) !== _name;
|
1927 |
|
1928 | if (shouldDeconflict && ! ~names.indexOf(_name)) {
|
1929 | names.push(_name);
|
1930 | }
|
1931 | }
|
1932 |
|
1933 | names.forEach(function (name) {
|
1934 | if (definers[name]) {
|
1935 | conflicts[name] = true;
|
1936 | } else {
|
1937 | definers[name] = [];
|
1938 | }
|
1939 |
|
1940 |
|
1941 |
|
1942 | definers[name].push(module);
|
1943 | });
|
1944 | });
|
1945 | });
|
1946 |
|
1947 |
|
1948 | keys(this.assumedGlobals).forEach(function (name) {
|
1949 | if (definers[name]) {
|
1950 | conflicts[name] = true;
|
1951 | }
|
1952 | });
|
1953 |
|
1954 |
|
1955 | keys(conflicts).forEach(function (name) {
|
1956 | var modules = definers[name];
|
1957 |
|
1958 | if (!_this2.assumedGlobals[name]) {
|
1959 |
|
1960 |
|
1961 |
|
1962 | modules.pop();
|
1963 | }
|
1964 |
|
1965 | modules.forEach(function (module) {
|
1966 | var replacement = getSafeName(name);
|
1967 | module.rename(name, replacement);
|
1968 | });
|
1969 | });
|
1970 |
|
1971 | function getSafeName(name) {
|
1972 | while (conflicts[name]) {
|
1973 | name = '_' + name;
|
1974 | }
|
1975 |
|
1976 | conflicts[name] = true;
|
1977 | return name;
|
1978 | }
|
1979 | };
|
1980 |
|
1981 | Bundle.prototype.fetchModule = function fetchModule(importee, importer) {
|
1982 | var _this3 = this;
|
1983 |
|
1984 | return _Promise.resolve(this.resolveId(importee, importer, this.resolveOptions)).then(function (id) {
|
1985 | if (!id) {
|
1986 |
|
1987 | if (!_this3.modulePromises[importee]) {
|
1988 | var _module = new ExternalModule(importee);
|
1989 | _this3.externalModules.push(_module);
|
1990 | _this3.modulePromises[importee] = _Promise.resolve(_module);
|
1991 | }
|
1992 |
|
1993 | return _this3.modulePromises[importee];
|
1994 | }
|
1995 |
|
1996 | if (!_this3.modulePromises[id]) {
|
1997 | _this3.modulePromises[id] = _Promise.resolve(_this3.load(id, _this3.loadOptions)).then(function (source) {
|
1998 | var module = new Module({
|
1999 | id: id,
|
2000 | source: source,
|
2001 | bundle: _this3
|
2002 | });
|
2003 |
|
2004 | _this3.modules.push(module);
|
2005 |
|
2006 | return module;
|
2007 | });
|
2008 | }
|
2009 |
|
2010 | return _this3.modulePromises[id];
|
2011 | });
|
2012 | };
|
2013 |
|
2014 | Bundle.prototype.markAllModifierStatements = function markAllModifierStatements() {
|
2015 | var _this4 = this;
|
2016 |
|
2017 | var settled = true;
|
2018 | var promises = [];
|
2019 |
|
2020 | this.modules.forEach(function (module) {
|
2021 | module.statements.forEach(function (statement) {
|
2022 | if (statement.isIncluded) return;
|
2023 |
|
2024 | keys(statement.modifies).forEach(function (name) {
|
2025 | var definingStatement = module.definitions[name];
|
2026 | var exportDeclaration = module.exports[name] || module.exports.default && module.exports.default.identifier === name && module.exports.default;
|
2027 |
|
2028 | var shouldMark = definingStatement && definingStatement.isIncluded || exportDeclaration && exportDeclaration.isUsed;
|
2029 |
|
2030 | if (shouldMark) {
|
2031 | settled = false;
|
2032 | promises.push(statement.mark());
|
2033 | return;
|
2034 | }
|
2035 |
|
2036 |
|
2037 | var importDeclaration = module.imports[name];
|
2038 | if (!importDeclaration) return;
|
2039 |
|
2040 | var promise = _Promise.resolve(importDeclaration.module || _this4.fetchModule(importDeclaration.source, module.id)).then(function (module) {
|
2041 | importDeclaration.module = module;
|
2042 | var exportDeclaration = module.exports[importDeclaration.name];
|
2043 |
|
2044 | return module.findDefiningStatement(exportDeclaration.localName);
|
2045 | }).then(function (definingStatement) {
|
2046 | if (!definingStatement) return;
|
2047 |
|
2048 | settled = false;
|
2049 | return statement.mark();
|
2050 | });
|
2051 |
|
2052 | promises.push(promise);
|
2053 | });
|
2054 | });
|
2055 | });
|
2056 |
|
2057 | return _Promise.all(promises).then(function () {
|
2058 | if (!settled) return _this4.markAllModifierStatements();
|
2059 | });
|
2060 | };
|
2061 |
|
2062 | Bundle.prototype.render = function render() {
|
2063 | var _this5 = this;
|
2064 |
|
2065 | var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
|
2066 |
|
2067 | var format = options.format || 'es6';
|
2068 | this.deconflict(format === 'es6');
|
2069 |
|
2070 |
|
2071 |
|
2072 |
|
2073 |
|
2074 |
|
2075 |
|
2076 |
|
2077 |
|
2078 |
|
2079 |
|
2080 |
|
2081 |
|
2082 |
|
2083 |
|
2084 |
|
2085 | var allBundleExports = blank();
|
2086 |
|
2087 | if (format !== 'es6') {
|
2088 | keys(this.entryModule.exports).forEach(function (key) {
|
2089 | var exportDeclaration = _this5.entryModule.exports[key];
|
2090 |
|
2091 | var originalDeclaration = _this5.entryModule.findDeclaration(exportDeclaration.localName);
|
2092 |
|
2093 | if (originalDeclaration && originalDeclaration.type === 'VariableDeclaration') {
|
2094 | var canonicalName = _this5.entryModule.getCanonicalName(exportDeclaration.localName, false);
|
2095 |
|
2096 | allBundleExports[canonicalName] = 'exports.' + key;
|
2097 | _this5.varExports[key] = true;
|
2098 | }
|
2099 | });
|
2100 | }
|
2101 |
|
2102 |
|
2103 |
|
2104 | this.toExport = keys(this.entryModule.exports).filter(function (key) {
|
2105 | return !_this5.varExports[key];
|
2106 | });
|
2107 |
|
2108 | var magicString = new MagicString.Bundle({ separator: '\n\n' });
|
2109 |
|
2110 | this.orderedModules.forEach(function (module) {
|
2111 | var source = module.render(allBundleExports, format);
|
2112 | if (source.toString().length) {
|
2113 | magicString.addSource(source);
|
2114 | }
|
2115 | });
|
2116 |
|
2117 |
|
2118 | var indentString = magicString.getIndentString();
|
2119 | var namespaceBlock = this.internalNamespaceModules.map(function (module) {
|
2120 | var exportKeys = keys(module.exports);
|
2121 |
|
2122 | return 'var ' + module.getCanonicalName('*', format === 'es6') + ' = {\n' + exportKeys.map(function (key) {
|
2123 | return indentString + 'get ' + key + ' () { return ' + module.getCanonicalName(key, format === 'es6') + '; }';
|
2124 | }).join(',\n') + '\n};\n\n';
|
2125 | }).join('');
|
2126 |
|
2127 | magicString.prepend(namespaceBlock);
|
2128 |
|
2129 | var finalise = finalisers[format];
|
2130 |
|
2131 | if (!finalise) {
|
2132 | throw new Error('You must specify an output type - valid options are ' + keys(finalisers).join(', '));
|
2133 | }
|
2134 |
|
2135 | magicString = finalise(this, magicString.trim(), {
|
2136 |
|
2137 | exportMode: getExportMode(this, options.exports),
|
2138 |
|
2139 |
|
2140 | indentString: getIndentString(magicString, options)
|
2141 | }, options);
|
2142 |
|
2143 | var code = magicString.toString();
|
2144 | var map = null;
|
2145 |
|
2146 | if (options.sourceMap) {
|
2147 | var file = options.sourceMapFile || options.dest;
|
2148 | map = magicString.generateMap({
|
2149 | includeContent: true,
|
2150 | file
|
2151 |
|
2152 | : file });
|
2153 |
|
2154 | map.sources = map.sources.map(unixizePath);
|
2155 | }
|
2156 |
|
2157 | return { code: code, map: map };
|
2158 | };
|
2159 |
|
2160 | Bundle.prototype.sort = function sort() {
|
2161 | var seen = {};
|
2162 | var ordered = [];
|
2163 | var hasCycles = undefined;
|
2164 |
|
2165 | var strongDeps = {};
|
2166 | var stronglyDependsOn = {};
|
2167 |
|
2168 | function visit(module) {
|
2169 | seen[module.id] = true;
|
2170 |
|
2171 | var _module$consolidateDependencies = module.consolidateDependencies();
|
2172 |
|
2173 | var strongDependencies = _module$consolidateDependencies.strongDependencies;
|
2174 | var weakDependencies = _module$consolidateDependencies.weakDependencies;
|
2175 |
|
2176 | strongDeps[module.id] = [];
|
2177 | stronglyDependsOn[module.id] = {};
|
2178 |
|
2179 | keys(strongDependencies).forEach(function (id) {
|
2180 | var imported = strongDependencies[id];
|
2181 |
|
2182 | strongDeps[module.id].push(imported);
|
2183 |
|
2184 | if (seen[id]) {
|
2185 |
|
2186 |
|
2187 | hasCycles = true;
|
2188 | return;
|
2189 | }
|
2190 |
|
2191 | visit(imported);
|
2192 | });
|
2193 |
|
2194 | keys(weakDependencies).forEach(function (id) {
|
2195 | var imported = weakDependencies[id];
|
2196 |
|
2197 | if (seen[id]) {
|
2198 |
|
2199 |
|
2200 | hasCycles = true;
|
2201 | return;
|
2202 | }
|
2203 |
|
2204 | visit(imported);
|
2205 | });
|
2206 |
|
2207 |
|
2208 | function addStrongDependencies(dependency) {
|
2209 | if (stronglyDependsOn[module.id][dependency.id]) return;
|
2210 |
|
2211 | stronglyDependsOn[module.id][dependency.id] = true;
|
2212 | strongDeps[dependency.id].forEach(addStrongDependencies);
|
2213 | }
|
2214 |
|
2215 | strongDeps[module.id].forEach(addStrongDependencies);
|
2216 |
|
2217 | ordered.push(module);
|
2218 | }
|
2219 |
|
2220 | visit(this.entryModule);
|
2221 |
|
2222 | if (hasCycles) {
|
2223 | var unordered = ordered;
|
2224 | ordered = [];
|
2225 |
|
2226 |
|
2227 | unordered.forEach(function (module) {
|
2228 |
|
2229 | strongDeps[module.id].forEach(place);
|
2230 |
|
2231 | function place(dep) {
|
2232 | if (!stronglyDependsOn[dep.id][module.id] && ! ~ordered.indexOf(dep)) {
|
2233 | strongDeps[dep.id].forEach(place);
|
2234 | ordered.push(dep);
|
2235 | }
|
2236 | }
|
2237 |
|
2238 | if (! ~ordered.indexOf(module)) {
|
2239 | ordered.push(module);
|
2240 | }
|
2241 | });
|
2242 | }
|
2243 |
|
2244 | return ordered;
|
2245 | };
|
2246 |
|
2247 | return Bundle;
|
2248 | })();
|
2249 |
|
2250 | var SOURCEMAPPING_URL = 'sourceMa';
|
2251 | SOURCEMAPPING_URL += 'ppingURL';
|
2252 | function rollup(options) {
|
2253 | if (!options || !options.entry) {
|
2254 | throw new Error('You must supply options.entry to rollup');
|
2255 | }
|
2256 |
|
2257 | var bundle = new Bundle(options);
|
2258 |
|
2259 | return bundle.build().then(function () {
|
2260 | return {
|
2261 | generate: function (options) {
|
2262 | return bundle.render(options);
|
2263 | },
|
2264 | write: function (options) {
|
2265 | if (!options || !options.dest) {
|
2266 | throw new Error('You must supply options.dest to bundle.write');
|
2267 | }
|
2268 |
|
2269 | var dest = options.dest;
|
2270 |
|
2271 | var _bundle$render = bundle.render(options);
|
2272 |
|
2273 | var code = _bundle$render.code;
|
2274 | var map = _bundle$render.map;
|
2275 |
|
2276 | var promises = [];
|
2277 |
|
2278 | if (options.sourceMap) {
|
2279 | var url = undefined;
|
2280 |
|
2281 | if (options.sourceMap === 'inline') {
|
2282 | url = map.toUrl();
|
2283 | } else {
|
2284 | url = basename(dest) + '.map';
|
2285 | promises.push(writeFile(dest + '.map', map.toString()));
|
2286 | }
|
2287 |
|
2288 | code += '\n//# ' + SOURCEMAPPING_URL + '=' + url;
|
2289 | }
|
2290 |
|
2291 | promises.push(writeFile(dest, code));
|
2292 | return Promise.all(promises);
|
2293 | }
|
2294 | };
|
2295 | });
|
2296 | }
|
2297 |
|
2298 | exports.rollup = rollup;
|
2299 | }).call(this,require('_process'))
|
2300 |
|
2301 | },{"_process":"/www/ROLLUP/rollup/node_modules/gobble-browserify/node_modules/browserify/node_modules/process/browser.js","acorn":"/www/ROLLUP/rollup/node_modules/acorn/dist/acorn.js","magic-string":"/www/ROLLUP/rollup/node_modules/magic-string/dist/magic-string.js"}],"/www/ROLLUP/rollup/node_modules/acorn/dist/acorn.js":[function(require,module,exports){
|
2302 | (function (global){
|
2303 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.acorn = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
|
2304 |
|
2305 |
|
2306 |
|
2307 |
|
2308 |
|
2309 |
|
2310 |
|
2311 |
|
2312 |
|
2313 | "use strict";
|
2314 |
|
2315 | exports.parse = parse;
|
2316 |
|
2317 |
|
2318 |
|
2319 |
|
2320 |
|
2321 | exports.parseExpressionAt = parseExpressionAt;
|
2322 |
|
2323 |
|
2324 |
|
2325 |
|
2326 | exports.tokenizer = tokenizer;
|
2327 | exports.__esModule = true;
|
2328 |
|
2329 |
|
2330 |
|
2331 |
|
2332 |
|
2333 |
|
2334 |
|
2335 |
|
2336 |
|
2337 |
|
2338 |
|
2339 |
|
2340 |
|
2341 |
|
2342 |
|
2343 |
|
2344 |
|
2345 |
|
2346 |
|
2347 |
|
2348 |
|
2349 | var _state = _dereq_("./state");
|
2350 |
|
2351 | var Parser = _state.Parser;
|
2352 |
|
2353 | var _options = _dereq_("./options");
|
2354 |
|
2355 | var getOptions = _options.getOptions;
|
2356 |
|
2357 | _dereq_("./parseutil");
|
2358 |
|
2359 | _dereq_("./statement");
|
2360 |
|
2361 | _dereq_("./lval");
|
2362 |
|
2363 | _dereq_("./expression");
|
2364 |
|
2365 | exports.Parser = _state.Parser;
|
2366 | exports.plugins = _state.plugins;
|
2367 | exports.defaultOptions = _options.defaultOptions;
|
2368 |
|
2369 | var _location = _dereq_("./location");
|
2370 |
|
2371 | exports.SourceLocation = _location.SourceLocation;
|
2372 | exports.getLineInfo = _location.getLineInfo;
|
2373 | exports.Node = _dereq_("./node").Node;
|
2374 |
|
2375 | var _tokentype = _dereq_("./tokentype");
|
2376 |
|
2377 | exports.TokenType = _tokentype.TokenType;
|
2378 | exports.tokTypes = _tokentype.types;
|
2379 |
|
2380 | var _tokencontext = _dereq_("./tokencontext");
|
2381 |
|
2382 | exports.TokContext = _tokencontext.TokContext;
|
2383 | exports.tokContexts = _tokencontext.types;
|
2384 |
|
2385 | var _identifier = _dereq_("./identifier");
|
2386 |
|
2387 | exports.isIdentifierChar = _identifier.isIdentifierChar;
|
2388 | exports.isIdentifierStart = _identifier.isIdentifierStart;
|
2389 | exports.Token = _dereq_("./tokenize").Token;
|
2390 |
|
2391 | var _whitespace = _dereq_("./whitespace");
|
2392 |
|
2393 | exports.isNewLine = _whitespace.isNewLine;
|
2394 | exports.lineBreak = _whitespace.lineBreak;
|
2395 | exports.lineBreakG = _whitespace.lineBreakG;
|
2396 | var version = "1.2.2";exports.version = version;
|
2397 |
|
2398 | function parse(input, options) {
|
2399 | var p = parser(options, input);
|
2400 | var startPos = p.pos,
|
2401 | startLoc = p.options.locations && p.curPosition();
|
2402 | p.nextToken();
|
2403 | return p.parseTopLevel(p.options.program || p.startNodeAt(startPos, startLoc));
|
2404 | }
|
2405 |
|
2406 | function parseExpressionAt(input, pos, options) {
|
2407 | var p = parser(options, input, pos);
|
2408 | p.nextToken();
|
2409 | return p.parseExpression();
|
2410 | }
|
2411 |
|
2412 | function tokenizer(input, options) {
|
2413 | return parser(options, input);
|
2414 | }
|
2415 |
|
2416 | function parser(options, input) {
|
2417 | return new Parser(getOptions(options), String(input));
|
2418 | }
|
2419 |
|
2420 | },{"./expression":6,"./identifier":7,"./location":8,"./lval":9,"./node":10,"./options":11,"./parseutil":12,"./state":13,"./statement":14,"./tokencontext":15,"./tokenize":16,"./tokentype":17,"./whitespace":19}],2:[function(_dereq_,module,exports){
|
2421 | if (typeof Object.create === 'function') {
|
2422 |
|
2423 | module.exports = function inherits(ctor, superCtor) {
|
2424 | ctor.super_ = superCtor
|
2425 | ctor.prototype = Object.create(superCtor.prototype, {
|
2426 | constructor: {
|
2427 | value: ctor,
|
2428 | enumerable: false,
|
2429 | writable: true,
|
2430 | configurable: true
|
2431 | }
|
2432 | });
|
2433 | };
|
2434 | } else {
|
2435 |
|
2436 | module.exports = function inherits(ctor, superCtor) {
|
2437 | ctor.super_ = superCtor
|
2438 | var TempCtor = function () {}
|
2439 | TempCtor.prototype = superCtor.prototype
|
2440 | ctor.prototype = new TempCtor()
|
2441 | ctor.prototype.constructor = ctor
|
2442 | }
|
2443 | }
|
2444 |
|
2445 | },{}],3:[function(_dereq_,module,exports){
|
2446 |
|
2447 |
|
2448 | var process = module.exports = {};
|
2449 | var queue = [];
|
2450 | var draining = false;
|
2451 |
|
2452 | function drainQueue() {
|
2453 | if (draining) {
|
2454 | return;
|
2455 | }
|
2456 | draining = true;
|
2457 | var currentQueue;
|
2458 | var len = queue.length;
|
2459 | while(len) {
|
2460 | currentQueue = queue;
|
2461 | queue = [];
|
2462 | var i = -1;
|
2463 | while (++i < len) {
|
2464 | currentQueue[i]();
|
2465 | }
|
2466 | len = queue.length;
|
2467 | }
|
2468 | draining = false;
|
2469 | }
|
2470 | process.nextTick = function (fun) {
|
2471 | queue.push(fun);
|
2472 | if (!draining) {
|
2473 | setTimeout(drainQueue, 0);
|
2474 | }
|
2475 | };
|
2476 |
|
2477 | process.title = 'browser';
|
2478 | process.browser = true;
|
2479 | process.env = {};
|
2480 | process.argv = [];
|
2481 | process.version = '';
|
2482 | process.versions = {};
|
2483 |
|
2484 | function noop() {}
|
2485 |
|
2486 | process.on = noop;
|
2487 | process.addListener = noop;
|
2488 | process.once = noop;
|
2489 | process.off = noop;
|
2490 | process.removeListener = noop;
|
2491 | process.removeAllListeners = noop;
|
2492 | process.emit = noop;
|
2493 |
|
2494 | process.binding = function (name) {
|
2495 | throw new Error('process.binding is not supported');
|
2496 | };
|
2497 |
|
2498 |
|
2499 | process.cwd = function () { return '/' };
|
2500 | process.chdir = function (dir) {
|
2501 | throw new Error('process.chdir is not supported');
|
2502 | };
|
2503 | process.umask = function() { return 0; };
|
2504 |
|
2505 | },{}],4:[function(_dereq_,module,exports){
|
2506 | module.exports = function isBuffer(arg) {
|
2507 | return arg && typeof arg === 'object'
|
2508 | && typeof arg.copy === 'function'
|
2509 | && typeof arg.fill === 'function'
|
2510 | && typeof arg.readUInt8 === 'function';
|
2511 | }
|
2512 | },{}],5:[function(_dereq_,module,exports){
|
2513 | (function (process,global){
|
2514 |
|
2515 |
|
2516 |
|
2517 |
|
2518 |
|
2519 |
|
2520 |
|
2521 |
|
2522 |
|
2523 |
|
2524 |
|
2525 |
|
2526 |
|
2527 |
|
2528 |
|
2529 |
|
2530 |
|
2531 |
|
2532 |
|
2533 |
|
2534 |
|
2535 | var formatRegExp = /%[sdj%]/g;
|
2536 | exports.format = function(f) {
|
2537 | if (!isString(f)) {
|
2538 | var objects = [];
|
2539 | for (var i = 0; i < arguments.length; i++) {
|
2540 | objects.push(inspect(arguments[i]));
|
2541 | }
|
2542 | return objects.join(' ');
|
2543 | }
|
2544 |
|
2545 | var i = 1;
|
2546 | var args = arguments;
|
2547 | var len = args.length;
|
2548 | var str = String(f).replace(formatRegExp, function(x) {
|
2549 | if (x === '%%') return '%';
|
2550 | if (i >= len) return x;
|
2551 | switch (x) {
|
2552 | case '%s': return String(args[i++]);
|
2553 | case '%d': return Number(args[i++]);
|
2554 | case '%j':
|
2555 | try {
|
2556 | return JSON.stringify(args[i++]);
|
2557 | } catch (_) {
|
2558 | return '[Circular]';
|
2559 | }
|
2560 | default:
|
2561 | return x;
|
2562 | }
|
2563 | });
|
2564 | for (var x = args[i]; i < len; x = args[++i]) {
|
2565 | if (isNull(x) || !isObject(x)) {
|
2566 | str += ' ' + x;
|
2567 | } else {
|
2568 | str += ' ' + inspect(x);
|
2569 | }
|
2570 | }
|
2571 | return str;
|
2572 | };
|
2573 |
|
2574 |
|
2575 |
|
2576 |
|
2577 |
|
2578 | exports.deprecate = function(fn, msg) {
|
2579 |
|
2580 | if (isUndefined(global.process)) {
|
2581 | return function() {
|
2582 | return exports.deprecate(fn, msg).apply(this, arguments);
|
2583 | };
|
2584 | }
|
2585 |
|
2586 | if (process.noDeprecation === true) {
|
2587 | return fn;
|
2588 | }
|
2589 |
|
2590 | var warned = false;
|
2591 | function deprecated() {
|
2592 | if (!warned) {
|
2593 | if (process.throwDeprecation) {
|
2594 | throw new Error(msg);
|
2595 | } else if (process.traceDeprecation) {
|
2596 | console.trace(msg);
|
2597 | } else {
|
2598 | console.error(msg);
|
2599 | }
|
2600 | warned = true;
|
2601 | }
|
2602 | return fn.apply(this, arguments);
|
2603 | }
|
2604 |
|
2605 | return deprecated;
|
2606 | };
|
2607 |
|
2608 |
|
2609 | var debugs = {};
|
2610 | var debugEnviron;
|
2611 | exports.debuglog = function(set) {
|
2612 | if (isUndefined(debugEnviron))
|
2613 | debugEnviron = process.env.NODE_DEBUG || '';
|
2614 | set = set.toUpperCase();
|
2615 | if (!debugs[set]) {
|
2616 | if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
|
2617 | var pid = process.pid;
|
2618 | debugs[set] = function() {
|
2619 | var msg = exports.format.apply(exports, arguments);
|
2620 | console.error('%s %d: %s', set, pid, msg);
|
2621 | };
|
2622 | } else {
|
2623 | debugs[set] = function() {};
|
2624 | }
|
2625 | }
|
2626 | return debugs[set];
|
2627 | };
|
2628 |
|
2629 |
|
2630 | /**
|
2631 | * Echos the value of a value. Trys to print the value out
|
2632 | * in the best way possible given the different types.
|
2633 | *
|
2634 | * @param {Object} obj The object to print out.
|
2635 | * @param {Object} opts Optional options object that alters the output.
|
2636 | */
|
2637 |
|
2638 | function inspect(obj, opts) {
|
2639 |
|
2640 | var ctx = {
|
2641 | seen: [],
|
2642 | stylize: stylizeNoColor
|
2643 | };
|
2644 |
|
2645 | if (arguments.length >= 3) ctx.depth = arguments[2];
|
2646 | if (arguments.length >= 4) ctx.colors = arguments[3];
|
2647 | if (isBoolean(opts)) {
|
2648 |
|
2649 | ctx.showHidden = opts;
|
2650 | } else if (opts) {
|
2651 |
|
2652 | exports._extend(ctx, opts);
|
2653 | }
|
2654 |
|
2655 | if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
|
2656 | if (isUndefined(ctx.depth)) ctx.depth = 2;
|
2657 | if (isUndefined(ctx.colors)) ctx.colors = false;
|
2658 | if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
|
2659 | if (ctx.colors) ctx.stylize = stylizeWithColor;
|
2660 | return formatValue(ctx, obj, ctx.depth);
|
2661 | }
|
2662 | exports.inspect = inspect;
|
2663 |
|
2664 |
|
2665 |
|
2666 | inspect.colors = {
|
2667 | 'bold' : [1, 22],
|
2668 | 'italic' : [3, 23],
|
2669 | 'underline' : [4, 24],
|
2670 | 'inverse' : [7, 27],
|
2671 | 'white' : [37, 39],
|
2672 | 'grey' : [90, 39],
|
2673 | 'black' : [30, 39],
|
2674 | 'blue' : [34, 39],
|
2675 | 'cyan' : [36, 39],
|
2676 | 'green' : [32, 39],
|
2677 | 'magenta' : [35, 39],
|
2678 | 'red' : [31, 39],
|
2679 | 'yellow' : [33, 39]
|
2680 | };
|
2681 |
|
2682 |
|
2683 | inspect.styles = {
|
2684 | 'special': 'cyan',
|
2685 | 'number': 'yellow',
|
2686 | 'boolean': 'yellow',
|
2687 | 'undefined': 'grey',
|
2688 | 'null': 'bold',
|
2689 | 'string': 'green',
|
2690 | 'date': 'magenta',
|
2691 |
|
2692 | 'regexp': 'red'
|
2693 | };
|
2694 |
|
2695 |
|
2696 | function stylizeWithColor(str, styleType) {
|
2697 | var style = inspect.styles[styleType];
|
2698 |
|
2699 | if (style) {
|
2700 | return '\u001b[' + inspect.colors[style][0] + 'm' + str +
|
2701 | '\u001b[' + inspect.colors[style][1] + 'm';
|
2702 | } else {
|
2703 | return str;
|
2704 | }
|
2705 | }
|
2706 |
|
2707 |
|
2708 | function stylizeNoColor(str, styleType) {
|
2709 | return str;
|
2710 | }
|
2711 |
|
2712 |
|
2713 | function arrayToHash(array) {
|
2714 | var hash = {};
|
2715 |
|
2716 | array.forEach(function(val, idx) {
|
2717 | hash[val] = true;
|
2718 | });
|
2719 |
|
2720 | return hash;
|
2721 | }
|
2722 |
|
2723 |
|
2724 | function formatValue(ctx, value, recurseTimes) {
|
2725 |
|
2726 |
|
2727 | if (ctx.customInspect &&
|
2728 | value &&
|
2729 | isFunction(value.inspect) &&
|
2730 |
|
2731 | value.inspect !== exports.inspect &&
|
2732 |
|
2733 | !(value.constructor && value.constructor.prototype === value)) {
|
2734 | var ret = value.inspect(recurseTimes, ctx);
|
2735 | if (!isString(ret)) {
|
2736 | ret = formatValue(ctx, ret, recurseTimes);
|
2737 | }
|
2738 | return ret;
|
2739 | }
|
2740 |
|
2741 |
|
2742 | var primitive = formatPrimitive(ctx, value);
|
2743 | if (primitive) {
|
2744 | return primitive;
|
2745 | }
|
2746 |
|
2747 |
|
2748 | var keys = Object.keys(value);
|
2749 | var visibleKeys = arrayToHash(keys);
|
2750 |
|
2751 | if (ctx.showHidden) {
|
2752 | keys = Object.getOwnPropertyNames(value);
|
2753 | }
|
2754 |
|
2755 |
|
2756 |
|
2757 | if (isError(value)
|
2758 | && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
|
2759 | return formatError(value);
|
2760 | }
|
2761 |
|
2762 |
|
2763 | if (keys.length === 0) {
|
2764 | if (isFunction(value)) {
|
2765 | var name = value.name ? ': ' + value.name : '';
|
2766 | return ctx.stylize('[Function' + name + ']', 'special');
|
2767 | }
|
2768 | if (isRegExp(value)) {
|
2769 | return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
2770 | }
|
2771 | if (isDate(value)) {
|
2772 | return ctx.stylize(Date.prototype.toString.call(value), 'date');
|
2773 | }
|
2774 | if (isError(value)) {
|
2775 | return formatError(value);
|
2776 | }
|
2777 | }
|
2778 |
|
2779 | var base = '', array = false, braces = ['{', '}'];
|
2780 |
|
2781 |
|
2782 | if (isArray(value)) {
|
2783 | array = true;
|
2784 | braces = ['[', ']'];
|
2785 | }
|
2786 |
|
2787 |
|
2788 | if (isFunction(value)) {
|
2789 | var n = value.name ? ': ' + value.name : '';
|
2790 | base = ' [Function' + n + ']';
|
2791 | }
|
2792 |
|
2793 |
|
2794 | if (isRegExp(value)) {
|
2795 | base = ' ' + RegExp.prototype.toString.call(value);
|
2796 | }
|
2797 |
|
2798 |
|
2799 | if (isDate(value)) {
|
2800 | base = ' ' + Date.prototype.toUTCString.call(value);
|
2801 | }
|
2802 |
|
2803 |
|
2804 | if (isError(value)) {
|
2805 | base = ' ' + formatError(value);
|
2806 | }
|
2807 |
|
2808 | if (keys.length === 0 && (!array || value.length == 0)) {
|
2809 | return braces[0] + base + braces[1];
|
2810 | }
|
2811 |
|
2812 | if (recurseTimes < 0) {
|
2813 | if (isRegExp(value)) {
|
2814 | return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
2815 | } else {
|
2816 | return ctx.stylize('[Object]', 'special');
|
2817 | }
|
2818 | }
|
2819 |
|
2820 | ctx.seen.push(value);
|
2821 |
|
2822 | var output;
|
2823 | if (array) {
|
2824 | output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
2825 | } else {
|
2826 | output = keys.map(function(key) {
|
2827 | return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
2828 | });
|
2829 | }
|
2830 |
|
2831 | ctx.seen.pop();
|
2832 |
|
2833 | return reduceToSingleString(output, base, braces);
|
2834 | }
|
2835 |
|
2836 |
|
2837 | function formatPrimitive(ctx, value) {
|
2838 | if (isUndefined(value))
|
2839 | return ctx.stylize('undefined', 'undefined');
|
2840 | if (isString(value)) {
|
2841 | var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
2842 | .replace(/'/g, "\\'")
|
2843 | .replace(/\\"/g, '"') + '\'';
|
2844 | return ctx.stylize(simple, 'string');
|
2845 | }
|
2846 | if (isNumber(value))
|
2847 | return ctx.stylize('' + value, 'number');
|
2848 | if (isBoolean(value))
|
2849 | return ctx.stylize('' + value, 'boolean');
|
2850 |
|
2851 | if (isNull(value))
|
2852 | return ctx.stylize('null', 'null');
|
2853 | }
|
2854 |
|
2855 |
|
2856 | function formatError(value) {
|
2857 | return '[' + Error.prototype.toString.call(value) + ']';
|
2858 | }
|
2859 |
|
2860 |
|
2861 | function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
2862 | var output = [];
|
2863 | for (var i = 0, l = value.length; i < l; ++i) {
|
2864 | if (hasOwnProperty(value, String(i))) {
|
2865 | output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
2866 | String(i), true));
|
2867 | } else {
|
2868 | output.push('');
|
2869 | }
|
2870 | }
|
2871 | keys.forEach(function(key) {
|
2872 | if (!key.match(/^\d+$/)) {
|
2873 | output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
2874 | key, true));
|
2875 | }
|
2876 | });
|
2877 | return output;
|
2878 | }
|
2879 |
|
2880 |
|
2881 | function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
2882 | var name, str, desc;
|
2883 | desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
|
2884 | if (desc.get) {
|
2885 | if (desc.set) {
|
2886 | str = ctx.stylize('[Getter/Setter]', 'special');
|
2887 | } else {
|
2888 | str = ctx.stylize('[Getter]', 'special');
|
2889 | }
|
2890 | } else {
|
2891 | if (desc.set) {
|
2892 | str = ctx.stylize('[Setter]', 'special');
|
2893 | }
|
2894 | }
|
2895 | if (!hasOwnProperty(visibleKeys, key)) {
|
2896 | name = '[' + key + ']';
|
2897 | }
|
2898 | if (!str) {
|
2899 | if (ctx.seen.indexOf(desc.value) < 0) {
|
2900 | if (isNull(recurseTimes)) {
|
2901 | str = formatValue(ctx, desc.value, null);
|
2902 | } else {
|
2903 | str = formatValue(ctx, desc.value, recurseTimes - 1);
|
2904 | }
|
2905 | if (str.indexOf('\n') > -1) {
|
2906 | if (array) {
|
2907 | str = str.split('\n').map(function(line) {
|
2908 | return ' ' + line;
|
2909 | }).join('\n').substr(2);
|
2910 | } else {
|
2911 | str = '\n' + str.split('\n').map(function(line) {
|
2912 | return ' ' + line;
|
2913 | }).join('\n');
|
2914 | }
|
2915 | }
|
2916 | } else {
|
2917 | str = ctx.stylize('[Circular]', 'special');
|
2918 | }
|
2919 | }
|
2920 | if (isUndefined(name)) {
|
2921 | if (array && key.match(/^\d+$/)) {
|
2922 | return str;
|
2923 | }
|
2924 | name = JSON.stringify('' + key);
|
2925 | if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
2926 | name = name.substr(1, name.length - 2);
|
2927 | name = ctx.stylize(name, 'name');
|
2928 | } else {
|
2929 | name = name.replace(/'/g, "\\'")
|
2930 | .replace(/\\"/g, '"')
|
2931 | .replace(/(^"|"$)/g, "'");
|
2932 | name = ctx.stylize(name, 'string');
|
2933 | }
|
2934 | }
|
2935 |
|
2936 | return name + ': ' + str;
|
2937 | }
|
2938 |
|
2939 |
|
2940 | function reduceToSingleString(output, base, braces) {
|
2941 | var numLinesEst = 0;
|
2942 | var length = output.reduce(function(prev, cur) {
|
2943 | numLinesEst++;
|
2944 | if (cur.indexOf('\n') >= 0) numLinesEst++;
|
2945 | return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
|
2946 | }, 0);
|
2947 |
|
2948 | if (length > 60) {
|
2949 | return braces[0] +
|
2950 | (base === '' ? '' : base + '\n ') +
|
2951 | ' ' +
|
2952 | output.join(',\n ') +
|
2953 | ' ' +
|
2954 | braces[1];
|
2955 | }
|
2956 |
|
2957 | return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
2958 | }
|
2959 |
|
2960 |
|
2961 |
|
2962 |
|
2963 | function isArray(ar) {
|
2964 | return Array.isArray(ar);
|
2965 | }
|
2966 | exports.isArray = isArray;
|
2967 |
|
2968 | function isBoolean(arg) {
|
2969 | return typeof arg === 'boolean';
|
2970 | }
|
2971 | exports.isBoolean = isBoolean;
|
2972 |
|
2973 | function isNull(arg) {
|
2974 | return arg === null;
|
2975 | }
|
2976 | exports.isNull = isNull;
|
2977 |
|
2978 | function isNullOrUndefined(arg) {
|
2979 | return arg == null;
|
2980 | }
|
2981 | exports.isNullOrUndefined = isNullOrUndefined;
|
2982 |
|
2983 | function isNumber(arg) {
|
2984 | return typeof arg === 'number';
|
2985 | }
|
2986 | exports.isNumber = isNumber;
|
2987 |
|
2988 | function isString(arg) {
|
2989 | return typeof arg === 'string';
|
2990 | }
|
2991 | exports.isString = isString;
|
2992 |
|
2993 | function isSymbol(arg) {
|
2994 | return typeof arg === 'symbol';
|
2995 | }
|
2996 | exports.isSymbol = isSymbol;
|
2997 |
|
2998 | function isUndefined(arg) {
|
2999 | return arg === void 0;
|
3000 | }
|
3001 | exports.isUndefined = isUndefined;
|
3002 |
|
3003 | function isRegExp(re) {
|
3004 | return isObject(re) && objectToString(re) === '[object RegExp]';
|
3005 | }
|
3006 | exports.isRegExp = isRegExp;
|
3007 |
|
3008 | function isObject(arg) {
|
3009 | return typeof arg === 'object' && arg !== null;
|
3010 | }
|
3011 | exports.isObject = isObject;
|
3012 |
|
3013 | function isDate(d) {
|
3014 | return isObject(d) && objectToString(d) === '[object Date]';
|
3015 | }
|
3016 | exports.isDate = isDate;
|
3017 |
|
3018 | function isError(e) {
|
3019 | return isObject(e) &&
|
3020 | (objectToString(e) === '[object Error]' || e instanceof Error);
|
3021 | }
|
3022 | exports.isError = isError;
|
3023 |
|
3024 | function isFunction(arg) {
|
3025 | return typeof arg === 'function';
|
3026 | }
|
3027 | exports.isFunction = isFunction;
|
3028 |
|
3029 | function isPrimitive(arg) {
|
3030 | return arg === null ||
|
3031 | typeof arg === 'boolean' ||
|
3032 | typeof arg === 'number' ||
|
3033 | typeof arg === 'string' ||
|
3034 | typeof arg === 'symbol' ||
|
3035 | typeof arg === 'undefined';
|
3036 | }
|
3037 | exports.isPrimitive = isPrimitive;
|
3038 |
|
3039 | exports.isBuffer = _dereq_('./support/isBuffer');
|
3040 |
|
3041 | function objectToString(o) {
|
3042 | return Object.prototype.toString.call(o);
|
3043 | }
|
3044 |
|
3045 |
|
3046 | function pad(n) {
|
3047 | return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
3048 | }
|
3049 |
|
3050 |
|
3051 | var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
3052 | 'Oct', 'Nov', 'Dec'];
|
3053 |
|
3054 |
|
3055 | function timestamp() {
|
3056 | var d = new Date();
|
3057 | var time = [pad(d.getHours()),
|
3058 | pad(d.getMinutes()),
|
3059 | pad(d.getSeconds())].join(':');
|
3060 | return [d.getDate(), months[d.getMonth()], time].join(' ');
|
3061 | }
|
3062 |
|
3063 |
|
3064 |
|
3065 | exports.log = function() {
|
3066 | console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
|
3067 | };
|
3068 |
|
3069 |
|
3070 |
|
3071 |
|
3072 |
|
3073 |
|
3074 |
|
3075 |
|
3076 |
|
3077 |
|
3078 |
|
3079 |
|
3080 |
|
3081 |
|
3082 |
|
3083 | exports.inherits = _dereq_('inherits');
|
3084 |
|
3085 | exports._extend = function(origin, add) {
|
3086 |
|
3087 | if (!add || !isObject(add)) return origin;
|
3088 |
|
3089 | var keys = Object.keys(add);
|
3090 | var i = keys.length;
|
3091 | while (i--) {
|
3092 | origin[keys[i]] = add[keys[i]];
|
3093 | }
|
3094 | return origin;
|
3095 | };
|
3096 |
|
3097 | function hasOwnProperty(obj, prop) {
|
3098 | return Object.prototype.hasOwnProperty.call(obj, prop);
|
3099 | }
|
3100 |
|
3101 | }).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
3102 | },{"./support/isBuffer":4,"_process":3,"inherits":2}],6:[function(_dereq_,module,exports){
|
3103 |
|
3104 |
|
3105 |
|
3106 |
|
3107 |
|
3108 |
|
3109 |
|
3110 |
|
3111 |
|
3112 |
|
3113 |
|
3114 |
|
3115 |
|
3116 |
|
3117 |
|
3118 |
|
3119 |
|
3120 |
|
3121 | "use strict";
|
3122 |
|
3123 | var tt = _dereq_("./tokentype").types;
|
3124 |
|
3125 | var Parser = _dereq_("./state").Parser;
|
3126 |
|
3127 | var reservedWords = _dereq_("./identifier").reservedWords;
|
3128 |
|
3129 | var has = _dereq_("./util").has;
|
3130 |
|
3131 | var pp = Parser.prototype;
|
3132 |
|
3133 |
|
3134 |
|
3135 |
|
3136 |
|
3137 |
|
3138 | pp.checkPropClash = function (prop, propHash) {
|
3139 | if (this.options.ecmaVersion >= 6) return;
|
3140 | var key = prop.key,
|
3141 | name = undefined;
|
3142 | switch (key.type) {
|
3143 | case "Identifier":
|
3144 | name = key.name;break;
|
3145 | case "Literal":
|
3146 | name = String(key.value);break;
|
3147 | default:
|
3148 | return;
|
3149 | }
|
3150 | var kind = prop.kind || "init",
|
3151 | other = undefined;
|
3152 | if (has(propHash, name)) {
|
3153 | other = propHash[name];
|
3154 | var isGetSet = kind !== "init";
|
3155 | if ((this.strict || isGetSet) && other[kind] || !(isGetSet ^ other.init)) this.raise(key.start, "Redefinition of property");
|
3156 | } else {
|
3157 | other = propHash[name] = {
|
3158 | init: false,
|
3159 | get: false,
|
3160 | set: false
|
3161 | };
|
3162 | }
|
3163 | other[kind] = true;
|
3164 | };
|
3165 |
|
3166 | // ### Expression parsing
|
3167 |
|
3168 | // These nest, from the most general expression type at the top to
|
3169 | // 'atomic', nondivisible expression types at the bottom. Most of
|
3170 | // the functions will simply let the function(s) below them parse,
|
3171 | // and, *if* the syntactic construct they handle is present, wrap
|
3172 | // the AST node that the inner parser gave them in another node.
|
3173 |
|
3174 | // Parse a full expression. The optional arguments are used to
|
3175 | // forbid the `in` operator (in for loops initalization expressions)
|
3176 | // and provide reference for storing '=' operator inside shorthand
|
3177 | // property assignment in contexts where both object expression
|
3178 | // and object pattern might appear (so it's possible to raise
|
3179 | // delayed syntax error at correct position).
|
3180 |
|
3181 | pp.parseExpression = function (noIn, refShorthandDefaultPos) {
|
3182 | var startPos = this.start,
|
3183 | startLoc = this.startLoc;
|
3184 | var expr = this.parseMaybeAssign(noIn, refShorthandDefaultPos);
|
3185 | if (this.type === tt.comma) {
|
3186 | var node = this.startNodeAt(startPos, startLoc);
|
3187 | node.expressions = [expr];
|
3188 | while (this.eat(tt.comma)) node.expressions.push(this.parseMaybeAssign(noIn, refShorthandDefaultPos));
|
3189 | return this.finishNode(node, "SequenceExpression");
|
3190 | }
|
3191 | return expr;
|
3192 | };
|
3193 |
|
3194 |
|
3195 |
|
3196 |
|
3197 | pp.parseMaybeAssign = function (noIn, refShorthandDefaultPos, afterLeftParse) {
|
3198 | if (this.type == tt._yield && this.inGenerator) return this.parseYield();
|
3199 |
|
3200 | var failOnShorthandAssign = undefined;
|
3201 | if (!refShorthandDefaultPos) {
|
3202 | refShorthandDefaultPos = { start: 0 };
|
3203 | failOnShorthandAssign = true;
|
3204 | } else {
|
3205 | failOnShorthandAssign = false;
|
3206 | }
|
3207 | var startPos = this.start,
|
3208 | startLoc = this.startLoc;
|
3209 | if (this.type == tt.parenL || this.type == tt.name) this.potentialArrowAt = this.start;
|
3210 | var left = this.parseMaybeConditional(noIn, refShorthandDefaultPos);
|
3211 | if (afterLeftParse) left = afterLeftParse.call(this, left, startPos, startLoc);
|
3212 | if (this.type.isAssign) {
|
3213 | var node = this.startNodeAt(startPos, startLoc);
|
3214 | node.operator = this.value;
|
3215 | node.left = this.type === tt.eq ? this.toAssignable(left) : left;
|
3216 | refShorthandDefaultPos.start = 0;
|
3217 | this.checkLVal(left);
|
3218 | this.next();
|
3219 | node.right = this.parseMaybeAssign(noIn);
|
3220 | return this.finishNode(node, "AssignmentExpression");
|
3221 | } else if (failOnShorthandAssign && refShorthandDefaultPos.start) {
|
3222 | this.unexpected(refShorthandDefaultPos.start);
|
3223 | }
|
3224 | return left;
|
3225 | };
|
3226 |
|
3227 |
|
3228 |
|
3229 | pp.parseMaybeConditional = function (noIn, refShorthandDefaultPos) {
|
3230 | var startPos = this.start,
|
3231 | startLoc = this.startLoc;
|
3232 | var expr = this.parseExprOps(noIn, refShorthandDefaultPos);
|
3233 | if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
|
3234 | if (this.eat(tt.question)) {
|
3235 | var node = this.startNodeAt(startPos, startLoc);
|
3236 | node.test = expr;
|
3237 | node.consequent = this.parseMaybeAssign();
|
3238 | this.expect(tt.colon);
|
3239 | node.alternate = this.parseMaybeAssign(noIn);
|
3240 | return this.finishNode(node, "ConditionalExpression");
|
3241 | }
|
3242 | return expr;
|
3243 | };
|
3244 |
|
3245 |
|
3246 |
|
3247 | pp.parseExprOps = function (noIn, refShorthandDefaultPos) {
|
3248 | var startPos = this.start,
|
3249 | startLoc = this.startLoc;
|
3250 | var expr = this.parseMaybeUnary(refShorthandDefaultPos);
|
3251 | if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
|
3252 | return this.parseExprOp(expr, startPos, startLoc, -1, noIn);
|
3253 | };
|
3254 |
|
3255 |
|
3256 |
|
3257 |
|
3258 |
|
3259 |
|
3260 |
|
3261 | pp.parseExprOp = function (left, leftStartPos, leftStartLoc, minPrec, noIn) {
|
3262 | var prec = this.type.binop;
|
3263 | if (Array.isArray(leftStartPos)) {
|
3264 | if (this.options.locations && noIn === undefined) {
|
3265 |
|
3266 | noIn = minPrec;
|
3267 | minPrec = leftStartLoc;
|
3268 |
|
3269 | leftStartLoc = leftStartPos[1];
|
3270 | leftStartPos = leftStartPos[0];
|
3271 | }
|
3272 | }
|
3273 | if (prec != null && (!noIn || this.type !== tt._in)) {
|
3274 | if (prec > minPrec) {
|
3275 | var node = this.startNodeAt(leftStartPos, leftStartLoc);
|
3276 | node.left = left;
|
3277 | node.operator = this.value;
|
3278 | var op = this.type;
|
3279 | this.next();
|
3280 | var startPos = this.start,
|
3281 | startLoc = this.startLoc;
|
3282 | node.right = this.parseExprOp(this.parseMaybeUnary(), startPos, startLoc, prec, noIn);
|
3283 | this.finishNode(node, op === tt.logicalOR || op === tt.logicalAND ? "LogicalExpression" : "BinaryExpression");
|
3284 | return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn);
|
3285 | }
|
3286 | }
|
3287 | return left;
|
3288 | };
|
3289 |
|
3290 |
|
3291 |
|
3292 | pp.parseMaybeUnary = function (refShorthandDefaultPos) {
|
3293 | if (this.type.prefix) {
|
3294 | var node = this.startNode(),
|
3295 | update = this.type === tt.incDec;
|
3296 | node.operator = this.value;
|
3297 | node.prefix = true;
|
3298 | this.next();
|
3299 | node.argument = this.parseMaybeUnary();
|
3300 | if (refShorthandDefaultPos && refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start);
|
3301 | if (update) this.checkLVal(node.argument);else if (this.strict && node.operator === "delete" && node.argument.type === "Identifier") this.raise(node.start, "Deleting local variable in strict mode");
|
3302 | return this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
|
3303 | }
|
3304 | var startPos = this.start,
|
3305 | startLoc = this.startLoc;
|
3306 | var expr = this.parseExprSubscripts(refShorthandDefaultPos);
|
3307 | if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
|
3308 | while (this.type.postfix && !this.canInsertSemicolon()) {
|
3309 | var node = this.startNodeAt(startPos, startLoc);
|
3310 | node.operator = this.value;
|
3311 | node.prefix = false;
|
3312 | node.argument = expr;
|
3313 | this.checkLVal(expr);
|
3314 | this.next();
|
3315 | expr = this.finishNode(node, "UpdateExpression");
|
3316 | }
|
3317 | return expr;
|
3318 | };
|
3319 |
|
3320 |
|
3321 |
|
3322 | pp.parseExprSubscripts = function (refShorthandDefaultPos) {
|
3323 | var startPos = this.start,
|
3324 | startLoc = this.startLoc;
|
3325 | var expr = this.parseExprAtom(refShorthandDefaultPos);
|
3326 | if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
|
3327 | return this.parseSubscripts(expr, startPos, startLoc);
|
3328 | };
|
3329 |
|
3330 | pp.parseSubscripts = function (base, startPos, startLoc, noCalls) {
|
3331 | if (Array.isArray(startPos)) {
|
3332 | if (this.options.locations && noCalls === undefined) {
|
3333 |
|
3334 | noCalls = startLoc;
|
3335 |
|
3336 | startLoc = startPos[1];
|
3337 | startPos = startPos[0];
|
3338 | }
|
3339 | }
|
3340 | for (;;) {
|
3341 | if (this.eat(tt.dot)) {
|
3342 | var node = this.startNodeAt(startPos, startLoc);
|
3343 | node.object = base;
|
3344 | node.property = this.parseIdent(true);
|
3345 | node.computed = false;
|
3346 | base = this.finishNode(node, "MemberExpression");
|
3347 | } else if (this.eat(tt.bracketL)) {
|
3348 | var node = this.startNodeAt(startPos, startLoc);
|
3349 | node.object = base;
|
3350 | node.property = this.parseExpression();
|
3351 | node.computed = true;
|
3352 | this.expect(tt.bracketR);
|
3353 | base = this.finishNode(node, "MemberExpression");
|
3354 | } else if (!noCalls && this.eat(tt.parenL)) {
|
3355 | var node = this.startNodeAt(startPos, startLoc);
|
3356 | node.callee = base;
|
3357 | node.arguments = this.parseExprList(tt.parenR, false);
|
3358 | base = this.finishNode(node, "CallExpression");
|
3359 | } else if (this.type === tt.backQuote) {
|
3360 | var node = this.startNodeAt(startPos, startLoc);
|
3361 | node.tag = base;
|
3362 | node.quasi = this.parseTemplate();
|
3363 | base = this.finishNode(node, "TaggedTemplateExpression");
|
3364 | } else {
|
3365 | return base;
|
3366 | }
|
3367 | }
|
3368 | };
|
3369 |
|
3370 |
|
3371 |
|
3372 |
|
3373 |
|
3374 |
|
3375 | pp.parseExprAtom = function (refShorthandDefaultPos) {
|
3376 | var node = undefined,
|
3377 | canBeArrow = this.potentialArrowAt == this.start;
|
3378 | switch (this.type) {
|
3379 | case tt._this:
|
3380 | case tt._super:
|
3381 | var type = this.type === tt._this ? "ThisExpression" : "Super";
|
3382 | node = this.startNode();
|
3383 | this.next();
|
3384 | return this.finishNode(node, type);
|
3385 |
|
3386 | case tt._yield:
|
3387 | if (this.inGenerator) this.unexpected();
|
3388 |
|
3389 | case tt.name:
|
3390 | var startPos = this.start,
|
3391 | startLoc = this.startLoc;
|
3392 | var id = this.parseIdent(this.type !== tt.name);
|
3393 | if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id]);
|
3394 | return id;
|
3395 |
|
3396 | case tt.regexp:
|
3397 | var value = this.value;
|
3398 | node = this.parseLiteral(value.value);
|
3399 | node.regex = { pattern: value.pattern, flags: value.flags };
|
3400 | return node;
|
3401 |
|
3402 | case tt.num:case tt.string:
|
3403 | return this.parseLiteral(this.value);
|
3404 |
|
3405 | case tt._null:case tt._true:case tt._false:
|
3406 | node = this.startNode();
|
3407 | node.value = this.type === tt._null ? null : this.type === tt._true;
|
3408 | node.raw = this.type.keyword;
|
3409 | this.next();
|
3410 | return this.finishNode(node, "Literal");
|
3411 |
|
3412 | case tt.parenL:
|
3413 | return this.parseParenAndDistinguishExpression(canBeArrow);
|
3414 |
|
3415 | case tt.bracketL:
|
3416 | node = this.startNode();
|
3417 | this.next();
|
3418 |
|
3419 | if (this.options.ecmaVersion >= 7 && this.type === tt._for) {
|
3420 | return this.parseComprehension(node, false);
|
3421 | }
|
3422 | node.elements = this.parseExprList(tt.bracketR, true, true, refShorthandDefaultPos);
|
3423 | return this.finishNode(node, "ArrayExpression");
|
3424 |
|
3425 | case tt.braceL:
|
3426 | return this.parseObj(false, refShorthandDefaultPos);
|
3427 |
|
3428 | case tt._function:
|
3429 | node = this.startNode();
|
3430 | this.next();
|
3431 | return this.parseFunction(node, false);
|
3432 |
|
3433 | case tt._class:
|
3434 | return this.parseClass(this.startNode(), false);
|
3435 |
|
3436 | case tt._new:
|
3437 | return this.parseNew();
|
3438 |
|
3439 | case tt.backQuote:
|
3440 | return this.parseTemplate();
|
3441 |
|
3442 | default:
|
3443 | this.unexpected();
|
3444 | }
|
3445 | };
|
3446 |
|
3447 | pp.parseLiteral = function (value) {
|
3448 | var node = this.startNode();
|
3449 | node.value = value;
|
3450 | node.raw = this.input.slice(this.start, this.end);
|
3451 | this.next();
|
3452 | return this.finishNode(node, "Literal");
|
3453 | };
|
3454 |
|
3455 | pp.parseParenExpression = function () {
|
3456 | this.expect(tt.parenL);
|
3457 | var val = this.parseExpression();
|
3458 | this.expect(tt.parenR);
|
3459 | return val;
|
3460 | };
|
3461 |
|
3462 | pp.parseParenAndDistinguishExpression = function (canBeArrow) {
|
3463 | var startPos = this.start,
|
3464 | startLoc = this.startLoc,
|
3465 | val = undefined;
|
3466 | if (this.options.ecmaVersion >= 6) {
|
3467 | this.next();
|
3468 |
|
3469 | if (this.options.ecmaVersion >= 7 && this.type === tt._for) {
|
3470 | return this.parseComprehension(this.startNodeAt(startPos, startLoc), true);
|
3471 | }
|
3472 |
|
3473 | var innerStartPos = this.start,
|
3474 | innerStartLoc = this.startLoc;
|
3475 | var exprList = [],
|
3476 | first = true;
|
3477 | var refShorthandDefaultPos = { start: 0 },
|
3478 | spreadStart = undefined,
|
3479 | innerParenStart = undefined;
|
3480 | while (this.type !== tt.parenR) {
|
3481 | first ? first = false : this.expect(tt.comma);
|
3482 | if (this.type === tt.ellipsis) {
|
3483 | spreadStart = this.start;
|
3484 | exprList.push(this.parseParenItem(this.parseRest()));
|
3485 | break;
|
3486 | } else {
|
3487 | if (this.type === tt.parenL && !innerParenStart) {
|
3488 | innerParenStart = this.start;
|
3489 | }
|
3490 | exprList.push(this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem));
|
3491 | }
|
3492 | }
|
3493 | var innerEndPos = this.start,
|
3494 | innerEndLoc = this.startLoc;
|
3495 | this.expect(tt.parenR);
|
3496 |
|
3497 | if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {
|
3498 | if (innerParenStart) this.unexpected(innerParenStart);
|
3499 | return this.parseParenArrowList(startPos, startLoc, exprList);
|
3500 | }
|
3501 |
|
3502 | if (!exprList.length) this.unexpected(this.lastTokStart);
|
3503 | if (spreadStart) this.unexpected(spreadStart);
|
3504 | if (refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start);
|
3505 |
|
3506 | if (exprList.length > 1) {
|
3507 | val = this.startNodeAt(innerStartPos, innerStartLoc);
|
3508 | val.expressions = exprList;
|
3509 | this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
|
3510 | } else {
|
3511 | val = exprList[0];
|
3512 | }
|
3513 | } else {
|
3514 | val = this.parseParenExpression();
|
3515 | }
|
3516 |
|
3517 | if (this.options.preserveParens) {
|
3518 | var par = this.startNodeAt(startPos, startLoc);
|
3519 | par.expression = val;
|
3520 | return this.finishNode(par, "ParenthesizedExpression");
|
3521 | } else {
|
3522 | return val;
|
3523 | }
|
3524 | };
|
3525 |
|
3526 | pp.parseParenItem = function (item) {
|
3527 | return item;
|
3528 | };
|
3529 |
|
3530 | pp.parseParenArrowList = function (startPos, startLoc, exprList) {
|
3531 | return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList);
|
3532 | };
|
3533 |
|
3534 |
|
3535 |
|
3536 |
|
3537 |
|
3538 | var empty = [];
|
3539 |
|
3540 | pp.parseNew = function () {
|
3541 | var node = this.startNode();
|
3542 | var meta = this.parseIdent(true);
|
3543 | if (this.options.ecmaVersion >= 6 && this.eat(tt.dot)) {
|
3544 | node.meta = meta;
|
3545 | node.property = this.parseIdent(true);
|
3546 | if (node.property.name !== "target") this.raise(node.property.start, "The only valid meta property for new is new.target");
|
3547 | return this.finishNode(node, "MetaProperty");
|
3548 | }
|
3549 | var startPos = this.start,
|
3550 | startLoc = this.startLoc;
|
3551 | node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true);
|
3552 | if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, false);else node.arguments = empty;
|
3553 | return this.finishNode(node, "NewExpression");
|
3554 | };
|
3555 |
|
3556 |
|
3557 |
|
3558 | pp.parseTemplateElement = function () {
|
3559 | var elem = this.startNode();
|
3560 | elem.value = {
|
3561 | raw: this.input.slice(this.start, this.end),
|
3562 | cooked: this.value
|
3563 | };
|
3564 | this.next();
|
3565 | elem.tail = this.type === tt.backQuote;
|
3566 | return this.finishNode(elem, "TemplateElement");
|
3567 | };
|
3568 |
|
3569 | pp.parseTemplate = function () {
|
3570 | var node = this.startNode();
|
3571 | this.next();
|
3572 | node.expressions = [];
|
3573 | var curElt = this.parseTemplateElement();
|
3574 | node.quasis = [curElt];
|
3575 | while (!curElt.tail) {
|
3576 | this.expect(tt.dollarBraceL);
|
3577 | node.expressions.push(this.parseExpression());
|
3578 | this.expect(tt.braceR);
|
3579 | node.quasis.push(curElt = this.parseTemplateElement());
|
3580 | }
|
3581 | this.next();
|
3582 | return this.finishNode(node, "TemplateLiteral");
|
3583 | };
|
3584 |
|
3585 |
|
3586 |
|
3587 | pp.parseObj = function (isPattern, refShorthandDefaultPos) {
|
3588 | var node = this.startNode(),
|
3589 | first = true,
|
3590 | propHash = {};
|
3591 | node.properties = [];
|
3592 | this.next();
|
3593 | while (!this.eat(tt.braceR)) {
|
3594 | if (!first) {
|
3595 | this.expect(tt.comma);
|
3596 | if (this.afterTrailingComma(tt.braceR)) break;
|
3597 | } else first = false;
|
3598 |
|
3599 | var prop = this.startNode(),
|
3600 | isGenerator = undefined,
|
3601 | startPos = undefined,
|
3602 | startLoc = undefined;
|
3603 | if (this.options.ecmaVersion >= 6) {
|
3604 | prop.method = false;
|
3605 | prop.shorthand = false;
|
3606 | if (isPattern || refShorthandDefaultPos) {
|
3607 | startPos = this.start;
|
3608 | startLoc = this.startLoc;
|
3609 | }
|
3610 | if (!isPattern) isGenerator = this.eat(tt.star);
|
3611 | }
|
3612 | this.parsePropertyName(prop);
|
3613 | this.parsePropertyValue(prop, isPattern, isGenerator, startPos, startLoc, refShorthandDefaultPos);
|
3614 | this.checkPropClash(prop, propHash);
|
3615 | node.properties.push(this.finishNode(prop, "Property"));
|
3616 | }
|
3617 | return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression");
|
3618 | };
|
3619 |
|
3620 | pp.parsePropertyValue = function (prop, isPattern, isGenerator, startPos, startLoc, refShorthandDefaultPos) {
|
3621 | if (this.eat(tt.colon)) {
|
3622 | prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refShorthandDefaultPos);
|
3623 | prop.kind = "init";
|
3624 | } else if (this.options.ecmaVersion >= 6 && this.type === tt.parenL) {
|
3625 | if (isPattern) this.unexpected();
|
3626 | prop.kind = "init";
|
3627 | prop.method = true;
|
3628 | prop.value = this.parseMethod(isGenerator);
|
3629 | } else if (this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && (this.type != tt.comma && this.type != tt.braceR)) {
|
3630 | if (isGenerator || isPattern) this.unexpected();
|
3631 | prop.kind = prop.key.name;
|
3632 | this.parsePropertyName(prop);
|
3633 | prop.value = this.parseMethod(false);
|
3634 | } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
|
3635 | prop.kind = "init";
|
3636 | if (isPattern) {
|
3637 | if (this.isKeyword(prop.key.name) || this.strict && (reservedWords.strictBind(prop.key.name) || reservedWords.strict(prop.key.name)) || !this.options.allowReserved && this.isReservedWord(prop.key.name)) this.raise(prop.key.start, "Binding " + prop.key.name);
|
3638 | prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
|
3639 | } else if (this.type === tt.eq && refShorthandDefaultPos) {
|
3640 | if (!refShorthandDefaultPos.start) refShorthandDefaultPos.start = this.start;
|
3641 | prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
|
3642 | } else {
|
3643 | prop.value = prop.key;
|
3644 | }
|
3645 | prop.shorthand = true;
|
3646 | } else this.unexpected();
|
3647 | };
|
3648 |
|
3649 | pp.parsePropertyName = function (prop) {
|
3650 | if (this.options.ecmaVersion >= 6) {
|
3651 | if (this.eat(tt.bracketL)) {
|
3652 | prop.computed = true;
|
3653 | prop.key = this.parseMaybeAssign();
|
3654 | this.expect(tt.bracketR);
|
3655 | return prop.key;
|
3656 | } else {
|
3657 | prop.computed = false;
|
3658 | }
|
3659 | }
|
3660 | return prop.key = this.type === tt.num || this.type === tt.string ? this.parseExprAtom() : this.parseIdent(true);
|
3661 | };
|
3662 |
|
3663 |
|
3664 |
|
3665 | pp.initFunction = function (node) {
|
3666 | node.id = null;
|
3667 | if (this.options.ecmaVersion >= 6) {
|
3668 | node.generator = false;
|
3669 | node.expression = false;
|
3670 | }
|
3671 | };
|
3672 |
|
3673 |
|
3674 |
|
3675 | pp.parseMethod = function (isGenerator) {
|
3676 | var node = this.startNode();
|
3677 | this.initFunction(node);
|
3678 | this.expect(tt.parenL);
|
3679 | node.params = this.parseBindingList(tt.parenR, false, false);
|
3680 | var allowExpressionBody = undefined;
|
3681 | if (this.options.ecmaVersion >= 6) {
|
3682 | node.generator = isGenerator;
|
3683 | allowExpressionBody = true;
|
3684 | } else {
|
3685 | allowExpressionBody = false;
|
3686 | }
|
3687 | this.parseFunctionBody(node, allowExpressionBody);
|
3688 | return this.finishNode(node, "FunctionExpression");
|
3689 | };
|
3690 |
|
3691 |
|
3692 |
|
3693 | pp.parseArrowExpression = function (node, params) {
|
3694 | this.initFunction(node);
|
3695 | node.params = this.toAssignableList(params, true);
|
3696 | this.parseFunctionBody(node, true);
|
3697 | return this.finishNode(node, "ArrowFunctionExpression");
|
3698 | };
|
3699 |
|
3700 |
|
3701 |
|
3702 | pp.parseFunctionBody = function (node, allowExpression) {
|
3703 | var isExpression = allowExpression && this.type !== tt.braceL;
|
3704 |
|
3705 | if (isExpression) {
|
3706 | node.body = this.parseMaybeAssign();
|
3707 | node.expression = true;
|
3708 | } else {
|
3709 |
|
3710 |
|
3711 | var oldInFunc = this.inFunction,
|
3712 | oldInGen = this.inGenerator,
|
3713 | oldLabels = this.labels;
|
3714 | this.inFunction = true;this.inGenerator = node.generator;this.labels = [];
|
3715 | node.body = this.parseBlock(true);
|
3716 | node.expression = false;
|
3717 | this.inFunction = oldInFunc;this.inGenerator = oldInGen;this.labels = oldLabels;
|
3718 | }
|
3719 |
|
3720 |
|
3721 |
|
3722 |
|
3723 | if (this.strict || !isExpression && node.body.body.length && this.isUseStrict(node.body.body[0])) {
|
3724 | var nameHash = {},
|
3725 | oldStrict = this.strict;
|
3726 | this.strict = true;
|
3727 | if (node.id) this.checkLVal(node.id, true);
|
3728 | for (var i = 0; i < node.params.length; i++) {
|
3729 | this.checkLVal(node.params[i], true, nameHash);
|
3730 | }this.strict = oldStrict;
|
3731 | }
|
3732 | };
|
3733 |
|
3734 |
|
3735 |
|
3736 |
|
3737 |
|
3738 |
|
3739 |
|
3740 | pp.parseExprList = function (close, allowTrailingComma, allowEmpty, refShorthandDefaultPos) {
|
3741 | var elts = [],
|
3742 | first = true;
|
3743 | while (!this.eat(close)) {
|
3744 | if (!first) {
|
3745 | this.expect(tt.comma);
|
3746 | if (allowTrailingComma && this.afterTrailingComma(close)) break;
|
3747 | } else first = false;
|
3748 |
|
3749 | if (allowEmpty && this.type === tt.comma) {
|
3750 | elts.push(null);
|
3751 | } else {
|
3752 | if (this.type === tt.ellipsis) elts.push(this.parseSpread(refShorthandDefaultPos));else elts.push(this.parseMaybeAssign(false, refShorthandDefaultPos));
|
3753 | }
|
3754 | }
|
3755 | return elts;
|
3756 | };
|
3757 |
|
3758 |
|
3759 |
|
3760 |
|
3761 |
|
3762 | pp.parseIdent = function (liberal) {
|
3763 | var node = this.startNode();
|
3764 | if (liberal && this.options.allowReserved == "never") liberal = false;
|
3765 | if (this.type === tt.name) {
|
3766 | if (!liberal && (!this.options.allowReserved && this.isReservedWord(this.value) || this.strict && reservedWords.strict(this.value) && (this.options.ecmaVersion >= 6 || this.input.slice(this.start, this.end).indexOf("\\") == -1))) this.raise(this.start, "The keyword '" + this.value + "' is reserved");
|
3767 | node.name = this.value;
|
3768 | } else if (liberal && this.type.keyword) {
|
3769 | node.name = this.type.keyword;
|
3770 | } else {
|
3771 | this.unexpected();
|
3772 | }
|
3773 | this.next();
|
3774 | return this.finishNode(node, "Identifier");
|
3775 | };
|
3776 |
|
3777 |
|
3778 |
|
3779 | pp.parseYield = function () {
|
3780 | var node = this.startNode();
|
3781 | this.next();
|
3782 | if (this.type == tt.semi || this.canInsertSemicolon() || this.type != tt.star && !this.type.startsExpr) {
|
3783 | node.delegate = false;
|
3784 | node.argument = null;
|
3785 | } else {
|
3786 | node.delegate = this.eat(tt.star);
|
3787 | node.argument = this.parseMaybeAssign();
|
3788 | }
|
3789 | return this.finishNode(node, "YieldExpression");
|
3790 | };
|
3791 |
|
3792 |
|
3793 |
|
3794 | pp.parseComprehension = function (node, isGenerator) {
|
3795 | node.blocks = [];
|
3796 | while (this.type === tt._for) {
|
3797 | var block = this.startNode();
|
3798 | this.next();
|
3799 | this.expect(tt.parenL);
|
3800 | block.left = this.parseBindingAtom();
|
3801 | this.checkLVal(block.left, true);
|
3802 | this.expectContextual("of");
|
3803 | block.right = this.parseExpression();
|
3804 | this.expect(tt.parenR);
|
3805 | node.blocks.push(this.finishNode(block, "ComprehensionBlock"));
|
3806 | }
|
3807 | node.filter = this.eat(tt._if) ? this.parseParenExpression() : null;
|
3808 | node.body = this.parseExpression();
|
3809 | this.expect(isGenerator ? tt.parenR : tt.bracketR);
|
3810 | node.generator = isGenerator;
|
3811 | return this.finishNode(node, "ComprehensionExpression");
|
3812 | };
|
3813 |
|
3814 | },{"./identifier":7,"./state":13,"./tokentype":17,"./util":18}],7:[function(_dereq_,module,exports){
|
3815 |
|
3816 |
|
3817 |
|
3818 |
|
3819 | "use strict";
|
3820 |
|
3821 | exports.isIdentifierStart = isIdentifierStart;
|
3822 |
|
3823 |
|
3824 |
|
3825 | exports.isIdentifierChar = isIdentifierChar;
|
3826 | exports.__esModule = true;
|
3827 |
|
3828 |
|
3829 |
|
3830 |
|
3831 |
|
3832 |
|
3833 |
|
3834 |
|
3835 |
|
3836 | function makePredicate(words) {
|
3837 | words = words.split(" ");
|
3838 | var f = "",
|
3839 | cats = [];
|
3840 | out: for (var i = 0; i < words.length; ++i) {
|
3841 | for (var j = 0; j < cats.length; ++j) {
|
3842 | if (cats[j][0].length == words[i].length) {
|
3843 | cats[j].push(words[i]);
|
3844 | continue out;
|
3845 | }
|
3846 | }cats.push([words[i]]);
|
3847 | }
|
3848 | function compareTo(arr) {
|
3849 | if (arr.length == 1) {
|
3850 | return f += "return str === " + JSON.stringify(arr[0]) + ";";
|
3851 | }f += "switch(str){";
|
3852 | for (var i = 0; i < arr.length; ++i) {
|
3853 | f += "case " + JSON.stringify(arr[i]) + ":";
|
3854 | }f += "return true}return false;";
|
3855 | }
|
3856 |
|
3857 |
|
3858 |
|
3859 |
|
3860 | if (cats.length > 3) {
|
3861 | cats.sort(function (a, b) {
|
3862 | return b.length - a.length;
|
3863 | });
|
3864 | f += "switch(str.length){";
|
3865 | for (var i = 0; i < cats.length; ++i) {
|
3866 | var cat = cats[i];
|
3867 | f += "case " + cat[0].length + ":";
|
3868 | compareTo(cat);
|
3869 | }
|
3870 | f += "}"
|
3871 |
|
3872 |
|
3873 |
|
3874 | ;
|
3875 | } else {
|
3876 | compareTo(words);
|
3877 | }
|
3878 | return new Function("str", f);
|
3879 | }
|
3880 |
|
3881 |
|
3882 |
|
3883 | var reservedWords = {
|
3884 | 3: makePredicate("abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile"),
|
3885 | 5: makePredicate("class enum extends super const export import"),
|
3886 | 6: makePredicate("enum await"),
|
3887 | strict: makePredicate("implements interface let package private protected public static yield"),
|
3888 | strictBind: makePredicate("eval arguments")
|
3889 | };
|
3890 |
|
3891 | exports.reservedWords = reservedWords;
|
3892 |
|
3893 |
|
3894 | var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this";
|
3895 |
|
3896 | var keywords = {
|
3897 | 5: makePredicate(ecma5AndLessKeywords),
|
3898 | 6: makePredicate(ecma5AndLessKeywords + " let const class extends export import yield super")
|
3899 | };
|
3900 |
|
3901 | exports.keywords = keywords;
|
3902 |
|
3903 |
|
3904 |
|
3905 |
|
3906 |
|
3907 |
|
3908 |
|
3909 |
|
3910 | var nonASCIIidentifierStartChars = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠ-ࢲऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞭꞰꞱꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭟꭤꭥꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ";
|
3911 | var nonASCIIidentifierChars = "·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣤ-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഁ-ഃാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏ᦰ-ᧀᧈᧉ᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳸᳹᷀-᷵᷼-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-꣄꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︭︳︴﹍-﹏0-9_";
|
3912 |
|
3913 | var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
|
3914 | var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
|
3915 |
|
3916 | nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
|
3917 |
|
3918 |
|
3919 |
|
3920 |
|
3921 |
|
3922 |
|
3923 | var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 17, 26, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 99, 39, 9, 51, 157, 310, 10, 21, 11, 7, 153, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 98, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 26, 45, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 955, 52, 76, 44, 33, 24, 27, 35, 42, 34, 4, 0, 13, 47, 15, 3, 22, 0, 38, 17, 2, 24, 133, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 32, 4, 287, 47, 21, 1, 2, 0, 185, 46, 82, 47, 21, 0, 60, 42, 502, 63, 32, 0, 449, 56, 1288, 920, 104, 110, 2962, 1070, 13266, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 881, 68, 12, 0, 67, 12, 16481, 1, 3071, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 4149, 196, 1340, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42710, 42, 4148, 12, 221, 16355, 541];
|
3924 | var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 1306, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 52, 0, 13, 2, 49, 13, 16, 9, 83, 11, 168, 11, 6, 9, 8, 2, 57, 0, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 316, 19, 13, 9, 214, 6, 3, 8, 112, 16, 16, 9, 82, 12, 9, 9, 535, 9, 20855, 9, 135, 4, 60, 6, 26, 9, 1016, 45, 17, 3, 19723, 1, 5319, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 4305, 6, 792618, 239];
|
3925 |
|
3926 |
|
3927 |
|
3928 |
|
3929 | function isInAstralSet(code, set) {
|
3930 | var pos = 65536;
|
3931 | for (var i = 0; i < set.length; i += 2) {
|
3932 | pos += set[i];
|
3933 | if (pos > code) {
|
3934 | return false;
|
3935 | }pos += set[i + 1];
|
3936 | if (pos >= code) {
|
3937 | return true;
|
3938 | }
|
3939 | }
|
3940 | }
|
3941 | function isIdentifierStart(code, astral) {
|
3942 | if (code < 65) {
|
3943 | return code === 36;
|
3944 | }if (code < 91) {
|
3945 | return true;
|
3946 | }if (code < 97) {
|
3947 | return code === 95;
|
3948 | }if (code < 123) {
|
3949 | return true;
|
3950 | }if (code <= 65535) {
|
3951 | return code >= 170 && nonASCIIidentifierStart.test(String.fromCharCode(code));
|
3952 | }if (astral === false) {
|
3953 | return false;
|
3954 | }return isInAstralSet(code, astralIdentifierStartCodes);
|
3955 | }
|
3956 |
|
3957 | function isIdentifierChar(code, astral) {
|
3958 | if (code < 48) {
|
3959 | return code === 36;
|
3960 | }if (code < 58) {
|
3961 | return true;
|
3962 | }if (code < 65) {
|
3963 | return false;
|
3964 | }if (code < 91) {
|
3965 | return true;
|
3966 | }if (code < 97) {
|
3967 | return code === 95;
|
3968 | }if (code < 123) {
|
3969 | return true;
|
3970 | }if (code <= 65535) {
|
3971 | return code >= 170 && nonASCIIidentifier.test(String.fromCharCode(code));
|
3972 | }if (astral === false) {
|
3973 | return false;
|
3974 | }return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
|
3975 | }
|
3976 |
|
3977 | },{}],8:[function(_dereq_,module,exports){
|
3978 | "use strict";
|
3979 |
|
3980 | var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
3981 |
|
3982 |
|
3983 |
|
3984 |
|
3985 |
|
3986 |
|
3987 |
|
3988 | exports.getLineInfo = getLineInfo;
|
3989 | exports.__esModule = true;
|
3990 |
|
3991 | var Parser = _dereq_("./state").Parser;
|
3992 |
|
3993 | var lineBreakG = _dereq_("./whitespace").lineBreakG;
|
3994 |
|
3995 | var deprecate = _dereq_("util").deprecate;
|
3996 |
|
3997 |
|
3998 |
|
3999 |
|
4000 | var Position = exports.Position = (function () {
|
4001 | function Position(line, col) {
|
4002 | _classCallCheck(this, Position);
|
4003 |
|
4004 | this.line = line;
|
4005 | this.column = col;
|
4006 | }
|
4007 |
|
4008 | Position.prototype.offset = function offset(n) {
|
4009 | return new Position(this.line, this.column + n);
|
4010 | };
|
4011 |
|
4012 | return Position;
|
4013 | })();
|
4014 |
|
4015 | var SourceLocation = exports.SourceLocation = function SourceLocation(p, start, end) {
|
4016 | _classCallCheck(this, SourceLocation);
|
4017 |
|
4018 | this.start = start;
|
4019 | this.end = end;
|
4020 | if (p.sourceFile !== null) this.source = p.sourceFile;
|
4021 | };
|
4022 |
|
4023 | function getLineInfo(input, offset) {
|
4024 | for (var line = 1, cur = 0;;) {
|
4025 | lineBreakG.lastIndex = cur;
|
4026 | var match = lineBreakG.exec(input);
|
4027 | if (match && match.index < offset) {
|
4028 | ++line;
|
4029 | cur = match.index + match[0].length;
|
4030 | } else {
|
4031 | return new Position(line, offset - cur);
|
4032 | }
|
4033 | }
|
4034 | }
|
4035 |
|
4036 | var pp = Parser.prototype;
|
4037 |
|
4038 |
|
4039 |
|
4040 |
|
4041 |
|
4042 |
|
4043 |
|
4044 | pp.raise = function (pos, message) {
|
4045 | var loc = getLineInfo(this.input, pos);
|
4046 | message += " (" + loc.line + ":" + loc.column + ")";
|
4047 | var err = new SyntaxError(message);
|
4048 | err.pos = pos;err.loc = loc;err.raisedAt = this.pos;
|
4049 | throw err;
|
4050 | };
|
4051 |
|
4052 | pp.curPosition = function () {
|
4053 | return new Position(this.curLine, this.pos - this.lineStart);
|
4054 | };
|
4055 |
|
4056 | pp.markPosition = function () {
|
4057 | return this.options.locations ? [this.start, this.startLoc] : this.start;
|
4058 | };
|
4059 |
|
4060 | },{"./state":13,"./whitespace":19,"util":5}],9:[function(_dereq_,module,exports){
|
4061 | "use strict";
|
4062 |
|
4063 | var tt = _dereq_("./tokentype").types;
|
4064 |
|
4065 | var Parser = _dereq_("./state").Parser;
|
4066 |
|
4067 | var reservedWords = _dereq_("./identifier").reservedWords;
|
4068 |
|
4069 | var has = _dereq_("./util").has;
|
4070 |
|
4071 | var pp = Parser.prototype;
|
4072 |
|
4073 |
|
4074 |
|
4075 |
|
4076 | pp.toAssignable = function (node, isBinding) {
|
4077 | if (this.options.ecmaVersion >= 6 && node) {
|
4078 | switch (node.type) {
|
4079 | case "Identifier":
|
4080 | case "ObjectPattern":
|
4081 | case "ArrayPattern":
|
4082 | case "AssignmentPattern":
|
4083 | break;
|
4084 |
|
4085 | case "ObjectExpression":
|
4086 | node.type = "ObjectPattern";
|
4087 | for (var i = 0; i < node.properties.length; i++) {
|
4088 | var prop = node.properties[i];
|
4089 | if (prop.kind !== "init") this.raise(prop.key.start, "Object pattern can't contain getter or setter");
|
4090 | this.toAssignable(prop.value, isBinding);
|
4091 | }
|
4092 | break;
|
4093 |
|
4094 | case "ArrayExpression":
|
4095 | node.type = "ArrayPattern";
|
4096 | this.toAssignableList(node.elements, isBinding);
|
4097 | break;
|
4098 |
|
4099 | case "AssignmentExpression":
|
4100 | if (node.operator === "=") {
|
4101 | node.type = "AssignmentPattern";
|
4102 | } else {
|
4103 | this.raise(node.left.end, "Only '=' operator can be used for specifying default value.");
|
4104 | }
|
4105 | break;
|
4106 |
|
4107 | case "ParenthesizedExpression":
|
4108 | node.expression = this.toAssignable(node.expression, isBinding);
|
4109 | break;
|
4110 |
|
4111 | case "MemberExpression":
|
4112 | if (!isBinding) break;
|
4113 |
|
4114 | default:
|
4115 | this.raise(node.start, "Assigning to rvalue");
|
4116 | }
|
4117 | }
|
4118 | return node;
|
4119 | };
|
4120 |
|
4121 |
|
4122 |
|
4123 | pp.toAssignableList = function (exprList, isBinding) {
|
4124 | var end = exprList.length;
|
4125 | if (end) {
|
4126 | var last = exprList[end - 1];
|
4127 | if (last && last.type == "RestElement") {
|
4128 | --end;
|
4129 | } else if (last && last.type == "SpreadElement") {
|
4130 | last.type = "RestElement";
|
4131 | var arg = last.argument;
|
4132 | this.toAssignable(arg, isBinding);
|
4133 | if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern") this.unexpected(arg.start);
|
4134 | --end;
|
4135 | }
|
4136 | }
|
4137 | for (var i = 0; i < end; i++) {
|
4138 | var elt = exprList[i];
|
4139 | if (elt) this.toAssignable(elt, isBinding);
|
4140 | }
|
4141 | return exprList;
|
4142 | };
|
4143 |
|
4144 |
|
4145 |
|
4146 | pp.parseSpread = function (refShorthandDefaultPos) {
|
4147 | var node = this.startNode();
|
4148 | this.next();
|
4149 | node.argument = this.parseMaybeAssign(refShorthandDefaultPos);
|
4150 | return this.finishNode(node, "SpreadElement");
|
4151 | };
|
4152 |
|
4153 | pp.parseRest = function () {
|
4154 | var node = this.startNode();
|
4155 | this.next();
|
4156 | node.argument = this.type === tt.name || this.type === tt.bracketL ? this.parseBindingAtom() : this.unexpected();
|
4157 | return this.finishNode(node, "RestElement");
|
4158 | };
|
4159 |
|
4160 |
|
4161 |
|
4162 | pp.parseBindingAtom = function () {
|
4163 | if (this.options.ecmaVersion < 6) return this.parseIdent();
|
4164 | switch (this.type) {
|
4165 | case tt.name:
|
4166 | return this.parseIdent();
|
4167 |
|
4168 | case tt.bracketL:
|
4169 | var node = this.startNode();
|
4170 | this.next();
|
4171 | node.elements = this.parseBindingList(tt.bracketR, true, true);
|
4172 | return this.finishNode(node, "ArrayPattern");
|
4173 |
|
4174 | case tt.braceL:
|
4175 | return this.parseObj(true);
|
4176 |
|
4177 | default:
|
4178 | this.unexpected();
|
4179 | }
|
4180 | };
|
4181 |
|
4182 | pp.parseBindingList = function (close, allowEmpty, allowTrailingComma) {
|
4183 | var elts = [],
|
4184 | first = true;
|
4185 | while (!this.eat(close)) {
|
4186 | if (first) first = false;else this.expect(tt.comma);
|
4187 | if (allowEmpty && this.type === tt.comma) {
|
4188 | elts.push(null);
|
4189 | } else if (allowTrailingComma && this.afterTrailingComma(close)) {
|
4190 | break;
|
4191 | } else if (this.type === tt.ellipsis) {
|
4192 | var rest = this.parseRest();
|
4193 | this.parseBindingListItem(rest);
|
4194 | elts.push(rest);
|
4195 | this.expect(close);
|
4196 | break;
|
4197 | } else {
|
4198 | var elem = this.parseMaybeDefault(this.start, this.startLoc);
|
4199 | this.parseBindingListItem(elem);
|
4200 | elts.push(elem);
|
4201 | }
|
4202 | }
|
4203 | return elts;
|
4204 | };
|
4205 |
|
4206 | pp.parseBindingListItem = function (param) {
|
4207 | return param;
|
4208 | };
|
4209 |
|
4210 |
|
4211 |
|
4212 | pp.parseMaybeDefault = function (startPos, startLoc, left) {
|
4213 | if (Array.isArray(startPos)) {
|
4214 | if (this.options.locations && noCalls === undefined) {
|
4215 |
|
4216 | left = startLoc;
|
4217 |
|
4218 | startLoc = startPos[1];
|
4219 | startPos = startPos[0];
|
4220 | }
|
4221 | }
|
4222 | left = left || this.parseBindingAtom();
|
4223 | if (!this.eat(tt.eq)) return left;
|
4224 | var node = this.startNodeAt(startPos, startLoc);
|
4225 | node.operator = "=";
|
4226 | node.left = left;
|
4227 | node.right = this.parseMaybeAssign();
|
4228 | return this.finishNode(node, "AssignmentPattern");
|
4229 | };
|
4230 |
|
4231 |
|
4232 |
|
4233 |
|
4234 | pp.checkLVal = function (expr, isBinding, checkClashes) {
|
4235 | switch (expr.type) {
|
4236 | case "Identifier":
|
4237 | if (this.strict && (reservedWords.strictBind(expr.name) || reservedWords.strict(expr.name))) this.raise(expr.start, (isBinding ? "Binding " : "Assigning to ") + expr.name + " in strict mode");
|
4238 | if (checkClashes) {
|
4239 | if (has(checkClashes, expr.name)) this.raise(expr.start, "Argument name clash in strict mode");
|
4240 | checkClashes[expr.name] = true;
|
4241 | }
|
4242 | break;
|
4243 |
|
4244 | case "MemberExpression":
|
4245 | if (isBinding) this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " member expression");
|
4246 | break;
|
4247 |
|
4248 | case "ObjectPattern":
|
4249 | for (var i = 0; i < expr.properties.length; i++) {
|
4250 | this.checkLVal(expr.properties[i].value, isBinding, checkClashes);
|
4251 | }break;
|
4252 |
|
4253 | case "ArrayPattern":
|
4254 | for (var i = 0; i < expr.elements.length; i++) {
|
4255 | var elem = expr.elements[i];
|
4256 | if (elem) this.checkLVal(elem, isBinding, checkClashes);
|
4257 | }
|
4258 | break;
|
4259 |
|
4260 | case "AssignmentPattern":
|
4261 | this.checkLVal(expr.left, isBinding, checkClashes);
|
4262 | break;
|
4263 |
|
4264 | case "RestElement":
|
4265 | this.checkLVal(expr.argument, isBinding, checkClashes);
|
4266 | break;
|
4267 |
|
4268 | case "ParenthesizedExpression":
|
4269 | this.checkLVal(expr.expression, isBinding, checkClashes);
|
4270 | break;
|
4271 |
|
4272 | default:
|
4273 | this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " rvalue");
|
4274 | }
|
4275 | };
|
4276 |
|
4277 | },{"./identifier":7,"./state":13,"./tokentype":17,"./util":18}],10:[function(_dereq_,module,exports){
|
4278 | "use strict";
|
4279 |
|
4280 | var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
4281 |
|
4282 | exports.__esModule = true;
|
4283 |
|
4284 | var Parser = _dereq_("./state").Parser;
|
4285 |
|
4286 | var SourceLocation = _dereq_("./location").SourceLocation;
|
4287 |
|
4288 |
|
4289 |
|
4290 | var pp = Parser.prototype;
|
4291 |
|
4292 | var Node = exports.Node = function Node() {
|
4293 | _classCallCheck(this, Node);
|
4294 | };
|
4295 |
|
4296 | pp.startNode = function () {
|
4297 | var node = new Node();
|
4298 | node.start = this.start;
|
4299 | if (this.options.locations) node.loc = new SourceLocation(this, this.startLoc);
|
4300 | if (this.options.directSourceFile) node.sourceFile = this.options.directSourceFile;
|
4301 | if (this.options.ranges) node.range = [this.start, 0];
|
4302 | return node;
|
4303 | };
|
4304 |
|
4305 | pp.startNodeAt = function (pos, loc) {
|
4306 | var node = new Node();
|
4307 | if (Array.isArray(pos)) {
|
4308 | if (this.options.locations && loc === undefined) {
|
4309 |
|
4310 | loc = pos[1];
|
4311 | pos = pos[0];
|
4312 | }
|
4313 | }
|
4314 | node.start = pos;
|
4315 | if (this.options.locations) node.loc = new SourceLocation(this, loc);
|
4316 | if (this.options.directSourceFile) node.sourceFile = this.options.directSourceFile;
|
4317 | if (this.options.ranges) node.range = [pos, 0];
|
4318 | return node;
|
4319 | };
|
4320 |
|
4321 |
|
4322 |
|
4323 | pp.finishNode = function (node, type) {
|
4324 | node.type = type;
|
4325 | node.end = this.lastTokEnd;
|
4326 | if (this.options.locations) node.loc.end = this.lastTokEndLoc;
|
4327 | if (this.options.ranges) node.range[1] = this.lastTokEnd;
|
4328 | return node;
|
4329 | };
|
4330 |
|
4331 |
|
4332 |
|
4333 | pp.finishNodeAt = function (node, type, pos, loc) {
|
4334 | node.type = type;
|
4335 | if (Array.isArray(pos)) {
|
4336 | if (this.options.locations && loc === undefined) {
|
4337 |
|
4338 | loc = pos[1];
|
4339 | pos = pos[0];
|
4340 | }
|
4341 | }
|
4342 | node.end = pos;
|
4343 | if (this.options.locations) node.loc.end = loc;
|
4344 | if (this.options.ranges) node.range[1] = pos;
|
4345 | return node;
|
4346 | };
|
4347 |
|
4348 | },{"./location":8,"./state":13}],11:[function(_dereq_,module,exports){
|
4349 |
|
4350 |
|
4351 |
|
4352 |
|
4353 | "use strict";
|
4354 |
|
4355 | exports.getOptions = getOptions;
|
4356 | exports.__esModule = true;
|
4357 |
|
4358 | var _util = _dereq_("./util");
|
4359 |
|
4360 | var has = _util.has;
|
4361 | var isArray = _util.isArray;
|
4362 |
|
4363 | var SourceLocation = _dereq_("./location").SourceLocation;
|
4364 |
|
4365 |
|
4366 |
|
4367 |
|
4368 | var defaultOptions = {
|
4369 |
|
4370 |
|
4371 |
|
4372 |
|
4373 | ecmaVersion: 5,
|
4374 |
|
4375 | sourceType: "script",
|
4376 |
|
4377 |
|
4378 |
|
4379 |
|
4380 |
|
4381 | onInsertedSemicolon: null,
|
4382 |
|
4383 |
|
4384 | onTrailingComma: null,
|
4385 |
|
4386 |
|
4387 |
|
4388 |
|
4389 | allowReserved: true,
|
4390 |
|
4391 |
|
4392 | allowReturnOutsideFunction: false,
|
4393 |
|
4394 |
|
4395 | allowImportExportEverywhere: false,
|
4396 |
|
4397 |
|
4398 | allowHashBang: false,
|
4399 |
|
4400 |
|
4401 |
|
4402 |
|
4403 | locations: false,
|
4404 |
|
4405 |
|
4406 |
|
4407 |
|
4408 |
|
4409 | onToken: null,
|
4410 |
|
4411 |
|
4412 |
|
4413 |
|
4414 |
|
4415 |
|
4416 |
|
4417 |
|
4418 |
|
4419 |
|
4420 | onComment: null,
|
4421 |
|
4422 |
|
4423 |
|
4424 |
|
4425 |
|
4426 |
|
4427 |
|
4428 |
|
4429 | ranges: false,
|
4430 |
|
4431 |
|
4432 |
|
4433 |
|
4434 |
|
4435 | program: null,
|
4436 |
|
4437 |
|
4438 | sourceFile: null,
|
4439 |
|
4440 |
|
4441 | directSourceFile: null,
|
4442 |
|
4443 |
|
4444 | preserveParens: false,
|
4445 | plugins: {}
|
4446 | };exports.defaultOptions = defaultOptions;
|
4447 |
|
4448 | function getOptions(opts) {
|
4449 | var options = {};
|
4450 | for (var opt in defaultOptions) {
|
4451 | options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt];
|
4452 | }if (isArray(options.onToken)) {
|
4453 | (function () {
|
4454 | var tokens = options.onToken;
|
4455 | options.onToken = function (token) {
|
4456 | return tokens.push(token);
|
4457 | };
|
4458 | })();
|
4459 | }
|
4460 | if (isArray(options.onComment)) options.onComment = pushComment(options, options.onComment);
|
4461 |
|
4462 | return options;
|
4463 | }
|
4464 |
|
4465 | function pushComment(options, array) {
|
4466 | return function (block, text, start, end, startLoc, endLoc) {
|
4467 | var comment = {
|
4468 | type: block ? "Block" : "Line",
|
4469 | value: text,
|
4470 | start: start,
|
4471 | end: end
|
4472 | };
|
4473 | if (options.locations) comment.loc = new SourceLocation(this, startLoc, endLoc);
|
4474 | if (options.ranges) comment.range = [start, end];
|
4475 | array.push(comment);
|
4476 | };
|
4477 | }
|
4478 |
|
4479 | },{"./location":8,"./util":18}],12:[function(_dereq_,module,exports){
|
4480 | "use strict";
|
4481 |
|
4482 | var tt = _dereq_("./tokentype").types;
|
4483 |
|
4484 | var Parser = _dereq_("./state").Parser;
|
4485 |
|
4486 | var lineBreak = _dereq_("./whitespace").lineBreak;
|
4487 |
|
4488 | var pp = Parser.prototype;
|
4489 |
|
4490 |
|
4491 |
|
4492 |
|
4493 |
|
4494 | pp.isUseStrict = function (stmt) {
|
4495 | return this.options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && stmt.expression.value === "use strict";
|
4496 | };
|
4497 |
|
4498 |
|
4499 |
|
4500 |
|
4501 | pp.eat = function (type) {
|
4502 | if (this.type === type) {
|
4503 | this.next();
|
4504 | return true;
|
4505 | } else {
|
4506 | return false;
|
4507 | }
|
4508 | };
|
4509 |
|
4510 |
|
4511 |
|
4512 | pp.isContextual = function (name) {
|
4513 | return this.type === tt.name && this.value === name;
|
4514 | };
|
4515 |
|
4516 |
|
4517 |
|
4518 | pp.eatContextual = function (name) {
|
4519 | return this.value === name && this.eat(tt.name);
|
4520 | };
|
4521 |
|
4522 |
|
4523 |
|
4524 | pp.expectContextual = function (name) {
|
4525 | if (!this.eatContextual(name)) this.unexpected();
|
4526 | };
|
4527 |
|
4528 |
|
4529 |
|
4530 | pp.canInsertSemicolon = function () {
|
4531 | return this.type === tt.eof || this.type === tt.braceR || lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
|
4532 | };
|
4533 |
|
4534 | pp.insertSemicolon = function () {
|
4535 | if (this.canInsertSemicolon()) {
|
4536 | if (this.options.onInsertedSemicolon) this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc);
|
4537 | return true;
|
4538 | }
|
4539 | };
|
4540 |
|
4541 |
|
4542 |
|
4543 |
|
4544 | pp.semicolon = function () {
|
4545 | if (!this.eat(tt.semi) && !this.insertSemicolon()) this.unexpected();
|
4546 | };
|
4547 |
|
4548 | pp.afterTrailingComma = function (tokType) {
|
4549 | if (this.type == tokType) {
|
4550 | if (this.options.onTrailingComma) this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc);
|
4551 | this.next();
|
4552 | return true;
|
4553 | }
|
4554 | };
|
4555 |
|
4556 |
|
4557 |
|
4558 |
|
4559 | pp.expect = function (type) {
|
4560 | this.eat(type) || this.unexpected();
|
4561 | };
|
4562 |
|
4563 |
|
4564 |
|
4565 | pp.unexpected = function (pos) {
|
4566 | this.raise(pos != null ? pos : this.start, "Unexpected token");
|
4567 | };
|
4568 |
|
4569 | },{"./state":13,"./tokentype":17,"./whitespace":19}],13:[function(_dereq_,module,exports){
|
4570 | "use strict";
|
4571 |
|
4572 | exports.Parser = Parser;
|
4573 | exports.__esModule = true;
|
4574 |
|
4575 | var _identifier = _dereq_("./identifier");
|
4576 |
|
4577 | var reservedWords = _identifier.reservedWords;
|
4578 | var keywords = _identifier.keywords;
|
4579 |
|
4580 | var tt = _dereq_("./tokentype").types;
|
4581 |
|
4582 | var lineBreak = _dereq_("./whitespace").lineBreak;
|
4583 |
|
4584 | function Parser(options, input, startPos) {
|
4585 | this.options = options;
|
4586 | this.sourceFile = this.options.sourceFile || null;
|
4587 | this.isKeyword = keywords[this.options.ecmaVersion >= 6 ? 6 : 5];
|
4588 | this.isReservedWord = reservedWords[this.options.ecmaVersion];
|
4589 | this.input = input;
|
4590 |
|
4591 |
|
4592 | this.loadPlugins(this.options.plugins);
|
4593 |
|
4594 |
|
4595 |
|
4596 |
|
4597 | if (startPos) {
|
4598 | this.pos = startPos;
|
4599 | this.lineStart = Math.max(0, this.input.lastIndexOf("\n", startPos));
|
4600 | this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
|
4601 | } else {
|
4602 | this.pos = this.lineStart = 0;
|
4603 | this.curLine = 1;
|
4604 | }
|
4605 |
|
4606 |
|
4607 |
|
4608 | this.type = tt.eof;
|
4609 |
|
4610 | this.value = null;
|
4611 |
|
4612 | this.start = this.end = this.pos;
|
4613 |
|
4614 |
|
4615 | this.startLoc = this.endLoc = null;
|
4616 |
|
4617 |
|
4618 | this.lastTokEndLoc = this.lastTokStartLoc = null;
|
4619 | this.lastTokStart = this.lastTokEnd = this.pos;
|
4620 |
|
4621 |
|
4622 |
|
4623 |
|
4624 | this.context = this.initialContext();
|
4625 | this.exprAllowed = true;
|
4626 |
|
4627 |
|
4628 | this.strict = this.inModule = this.options.sourceType === "module";
|
4629 |
|
4630 |
|
4631 | this.potentialArrowAt = -1;
|
4632 |
|
4633 |
|
4634 | this.inFunction = this.inGenerator = false;
|
4635 |
|
4636 | this.labels = [];
|
4637 |
|
4638 |
|
4639 | if (this.pos === 0 && this.options.allowHashBang && this.input.slice(0, 2) === "#!") this.skipLineComment(2);
|
4640 | }
|
4641 |
|
4642 | Parser.prototype.extend = function (name, f) {
|
4643 | this[name] = f(this[name]);
|
4644 | };
|
4645 |
|
4646 |
|
4647 |
|
4648 | var plugins = {};
|
4649 |
|
4650 | exports.plugins = plugins;
|
4651 | Parser.prototype.loadPlugins = function (plugins) {
|
4652 | for (var _name in plugins) {
|
4653 | var plugin = exports.plugins[_name];
|
4654 | if (!plugin) throw new Error("Plugin '" + _name + "' not found");
|
4655 | plugin(this, plugins[_name]);
|
4656 | }
|
4657 | };
|
4658 |
|
4659 | },{"./identifier":7,"./tokentype":17,"./whitespace":19}],14:[function(_dereq_,module,exports){
|
4660 | "use strict";
|
4661 |
|
4662 | var tt = _dereq_("./tokentype").types;
|
4663 |
|
4664 | var Parser = _dereq_("./state").Parser;
|
4665 |
|
4666 | var lineBreak = _dereq_("./whitespace").lineBreak;
|
4667 |
|
4668 | var pp = Parser.prototype;
|
4669 |
|
4670 |
|
4671 |
|
4672 |
|
4673 |
|
4674 |
|
4675 |
|
4676 |
|
4677 | pp.parseTopLevel = function (node) {
|
4678 | var first = true;
|
4679 | if (!node.body) node.body = [];
|
4680 | while (this.type !== tt.eof) {
|
4681 | var stmt = this.parseStatement(true, true);
|
4682 | node.body.push(stmt);
|
4683 | if (first && this.isUseStrict(stmt)) this.setStrict(true);
|
4684 | first = false;
|
4685 | }
|
4686 | this.next();
|
4687 | if (this.options.ecmaVersion >= 6) {
|
4688 | node.sourceType = this.options.sourceType;
|
4689 | }
|
4690 | return this.finishNode(node, "Program");
|
4691 | };
|
4692 |
|
4693 | var loopLabel = { kind: "loop" },
|
4694 | switchLabel = { kind: "switch" };
|
4695 |
|
4696 |
|
4697 |
|
4698 |
|
4699 |
|
4700 |
|
4701 |
|
4702 |
|
4703 | pp.parseStatement = function (declaration, topLevel) {
|
4704 | var starttype = this.type,
|
4705 | node = this.startNode();
|
4706 |
|
4707 |
|
4708 |
|
4709 |
|
4710 |
|
4711 | switch (starttype) {
|
4712 | case tt._break:case tt._continue:
|
4713 | return this.parseBreakContinueStatement(node, starttype.keyword);
|
4714 | case tt._debugger:
|
4715 | return this.parseDebuggerStatement(node);
|
4716 | case tt._do:
|
4717 | return this.parseDoStatement(node);
|
4718 | case tt._for:
|
4719 | return this.parseForStatement(node);
|
4720 | case tt._function:
|
4721 | if (!declaration && this.options.ecmaVersion >= 6) this.unexpected();
|
4722 | return this.parseFunctionStatement(node);
|
4723 | case tt._class:
|
4724 | if (!declaration) this.unexpected();
|
4725 | return this.parseClass(node, true);
|
4726 | case tt._if:
|
4727 | return this.parseIfStatement(node);
|
4728 | case tt._return:
|
4729 | return this.parseReturnStatement(node);
|
4730 | case tt._switch:
|
4731 | return this.parseSwitchStatement(node);
|
4732 | case tt._throw:
|
4733 | return this.parseThrowStatement(node);
|
4734 | case tt._try:
|
4735 | return this.parseTryStatement(node);
|
4736 | case tt._let:case tt._const:
|
4737 | if (!declaration) this.unexpected();
|
4738 | case tt._var:
|
4739 | return this.parseVarStatement(node, starttype);
|
4740 | case tt._while:
|
4741 | return this.parseWhileStatement(node);
|
4742 | case tt._with:
|
4743 | return this.parseWithStatement(node);
|
4744 | case tt.braceL:
|
4745 | return this.parseBlock();
|
4746 | case tt.semi:
|
4747 | return this.parseEmptyStatement(node);
|
4748 | case tt._export:
|
4749 | case tt._import:
|
4750 | if (!this.options.allowImportExportEverywhere) {
|
4751 | if (!topLevel) this.raise(this.start, "'import' and 'export' may only appear at the top level");
|
4752 | if (!this.inModule) this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");
|
4753 | }
|
4754 | return starttype === tt._import ? this.parseImport(node) : this.parseExport(node);
|
4755 |
|
4756 |
|
4757 |
|
4758 |
|
4759 |
|
4760 |
|
4761 | default:
|
4762 | var maybeName = this.value,
|
4763 | expr = this.parseExpression();
|
4764 | if (starttype === tt.name && expr.type === "Identifier" && this.eat(tt.colon)) return this.parseLabeledStatement(node, maybeName, expr);else return this.parseExpressionStatement(node, expr);
|
4765 | }
|
4766 | };
|
4767 |
|
4768 | pp.parseBreakContinueStatement = function (node, keyword) {
|
4769 | var isBreak = keyword == "break";
|
4770 | this.next();
|
4771 | if (this.eat(tt.semi) || this.insertSemicolon()) node.label = null;else if (this.type !== tt.name) this.unexpected();else {
|
4772 | node.label = this.parseIdent();
|
4773 | this.semicolon();
|
4774 | }
|
4775 |
|
4776 |
|
4777 |
|
4778 | for (var i = 0; i < this.labels.length; ++i) {
|
4779 | var lab = this.labels[i];
|
4780 | if (node.label == null || lab.name === node.label.name) {
|
4781 | if (lab.kind != null && (isBreak || lab.kind === "loop")) break;
|
4782 | if (node.label && isBreak) break;
|
4783 | }
|
4784 | }
|
4785 | if (i === this.labels.length) this.raise(node.start, "Unsyntactic " + keyword);
|
4786 | return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
|
4787 | };
|
4788 |
|
4789 | pp.parseDebuggerStatement = function (node) {
|
4790 | this.next();
|
4791 | this.semicolon();
|
4792 | return this.finishNode(node, "DebuggerStatement");
|
4793 | };
|
4794 |
|
4795 | pp.parseDoStatement = function (node) {
|
4796 | this.next();
|
4797 | this.labels.push(loopLabel);
|
4798 | node.body = this.parseStatement(false);
|
4799 | this.labels.pop();
|
4800 | this.expect(tt._while);
|
4801 | node.test = this.parseParenExpression();
|
4802 | if (this.options.ecmaVersion >= 6) this.eat(tt.semi);else this.semicolon();
|
4803 | return this.finishNode(node, "DoWhileStatement");
|
4804 | };
|
4805 |
|
4806 |
|
4807 |
|
4808 |
|
4809 |
|
4810 |
|
4811 |
|
4812 |
|
4813 |
|
4814 | pp.parseForStatement = function (node) {
|
4815 | this.next();
|
4816 | this.labels.push(loopLabel);
|
4817 | this.expect(tt.parenL);
|
4818 | if (this.type === tt.semi) return this.parseFor(node, null);
|
4819 | if (this.type === tt._var || this.type === tt._let || this.type === tt._const) {
|
4820 | var _init = this.startNode(),
|
4821 | varKind = this.type;
|
4822 | this.next();
|
4823 | this.parseVar(_init, true, varKind);
|
4824 | this.finishNode(_init, "VariableDeclaration");
|
4825 | if ((this.type === tt._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) && _init.declarations.length === 1 && !(varKind !== tt._var && _init.declarations[0].init)) return this.parseForIn(node, _init);
|
4826 | return this.parseFor(node, _init);
|
4827 | }
|
4828 | var refShorthandDefaultPos = { start: 0 };
|
4829 | var init = this.parseExpression(true, refShorthandDefaultPos);
|
4830 | if (this.type === tt._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) {
|
4831 | this.toAssignable(init);
|
4832 | this.checkLVal(init);
|
4833 | return this.parseForIn(node, init);
|
4834 | } else if (refShorthandDefaultPos.start) {
|
4835 | this.unexpected(refShorthandDefaultPos.start);
|
4836 | }
|
4837 | return this.parseFor(node, init);
|
4838 | };
|
4839 |
|
4840 | pp.parseFunctionStatement = function (node) {
|
4841 | this.next();
|
4842 | return this.parseFunction(node, true);
|
4843 | };
|
4844 |
|
4845 | pp.parseIfStatement = function (node) {
|
4846 | this.next();
|
4847 | node.test = this.parseParenExpression();
|
4848 | node.consequent = this.parseStatement(false);
|
4849 | node.alternate = this.eat(tt._else) ? this.parseStatement(false) : null;
|
4850 | return this.finishNode(node, "IfStatement");
|
4851 | };
|
4852 |
|
4853 | pp.parseReturnStatement = function (node) {
|
4854 | if (!this.inFunction && !this.options.allowReturnOutsideFunction) this.raise(this.start, "'return' outside of function");
|
4855 | this.next();
|
4856 |
|
4857 |
|
4858 |
|
4859 |
|
4860 |
|
4861 | if (this.eat(tt.semi) || this.insertSemicolon()) node.argument = null;else {
|
4862 | node.argument = this.parseExpression();this.semicolon();
|
4863 | }
|
4864 | return this.finishNode(node, "ReturnStatement");
|
4865 | };
|
4866 |
|
4867 | pp.parseSwitchStatement = function (node) {
|
4868 | this.next();
|
4869 | node.discriminant = this.parseParenExpression();
|
4870 | node.cases = [];
|
4871 | this.expect(tt.braceL);
|
4872 | this.labels.push(switchLabel);
|
4873 |
|
4874 |
|
4875 |
|
4876 |
|
4877 |
|
4878 | for (var cur, sawDefault; this.type != tt.braceR;) {
|
4879 | if (this.type === tt._case || this.type === tt._default) {
|
4880 | var isCase = this.type === tt._case;
|
4881 | if (cur) this.finishNode(cur, "SwitchCase");
|
4882 | node.cases.push(cur = this.startNode());
|
4883 | cur.consequent = [];
|
4884 | this.next();
|
4885 | if (isCase) {
|
4886 | cur.test = this.parseExpression();
|
4887 | } else {
|
4888 | if (sawDefault) this.raise(this.lastTokStart, "Multiple default clauses");
|
4889 | sawDefault = true;
|
4890 | cur.test = null;
|
4891 | }
|
4892 | this.expect(tt.colon);
|
4893 | } else {
|
4894 | if (!cur) this.unexpected();
|
4895 | cur.consequent.push(this.parseStatement(true));
|
4896 | }
|
4897 | }
|
4898 | if (cur) this.finishNode(cur, "SwitchCase");
|
4899 | this.next();
|
4900 | this.labels.pop();
|
4901 | return this.finishNode(node, "SwitchStatement");
|
4902 | };
|
4903 |
|
4904 | pp.parseThrowStatement = function (node) {
|
4905 | this.next();
|
4906 | if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) this.raise(this.lastTokEnd, "Illegal newline after throw");
|
4907 | node.argument = this.parseExpression();
|
4908 | this.semicolon();
|
4909 | return this.finishNode(node, "ThrowStatement");
|
4910 | };
|
4911 |
|
4912 |
|
4913 |
|
4914 | var empty = [];
|
4915 |
|
4916 | pp.parseTryStatement = function (node) {
|
4917 | this.next();
|
4918 | node.block = this.parseBlock();
|
4919 | node.handler = null;
|
4920 | if (this.type === tt._catch) {
|
4921 | var clause = this.startNode();
|
4922 | this.next();
|
4923 | this.expect(tt.parenL);
|
4924 | clause.param = this.parseBindingAtom();
|
4925 | this.checkLVal(clause.param, true);
|
4926 | this.expect(tt.parenR);
|
4927 | clause.guard = null;
|
4928 | clause.body = this.parseBlock();
|
4929 | node.handler = this.finishNode(clause, "CatchClause");
|
4930 | }
|
4931 | node.guardedHandlers = empty;
|
4932 | node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null;
|
4933 | if (!node.handler && !node.finalizer) this.raise(node.start, "Missing catch or finally clause");
|
4934 | return this.finishNode(node, "TryStatement");
|
4935 | };
|
4936 |
|
4937 | pp.parseVarStatement = function (node, kind) {
|
4938 | this.next();
|
4939 | this.parseVar(node, false, kind);
|
4940 | this.semicolon();
|
4941 | return this.finishNode(node, "VariableDeclaration");
|
4942 | };
|
4943 |
|
4944 | pp.parseWhileStatement = function (node) {
|
4945 | this.next();
|
4946 | node.test = this.parseParenExpression();
|
4947 | this.labels.push(loopLabel);
|
4948 | node.body = this.parseStatement(false);
|
4949 | this.labels.pop();
|
4950 | return this.finishNode(node, "WhileStatement");
|
4951 | };
|
4952 |
|
4953 | pp.parseWithStatement = function (node) {
|
4954 | if (this.strict) this.raise(this.start, "'with' in strict mode");
|
4955 | this.next();
|
4956 | node.object = this.parseParenExpression();
|
4957 | node.body = this.parseStatement(false);
|
4958 | return this.finishNode(node, "WithStatement");
|
4959 | };
|
4960 |
|
4961 | pp.parseEmptyStatement = function (node) {
|
4962 | this.next();
|
4963 | return this.finishNode(node, "EmptyStatement");
|
4964 | };
|
4965 |
|
4966 | pp.parseLabeledStatement = function (node, maybeName, expr) {
|
4967 | for (var i = 0; i < this.labels.length; ++i) {
|
4968 | if (this.labels[i].name === maybeName) this.raise(expr.start, "Label '" + maybeName + "' is already declared");
|
4969 | }var kind = this.type.isLoop ? "loop" : this.type === tt._switch ? "switch" : null;
|
4970 | this.labels.push({ name: maybeName, kind: kind });
|
4971 | node.body = this.parseStatement(true);
|
4972 | this.labels.pop();
|
4973 | node.label = expr;
|
4974 | return this.finishNode(node, "LabeledStatement");
|
4975 | };
|
4976 |
|
4977 | pp.parseExpressionStatement = function (node, expr) {
|
4978 | node.expression = expr;
|
4979 | this.semicolon();
|
4980 | return this.finishNode(node, "ExpressionStatement");
|
4981 | };
|
4982 |
|
4983 |
|
4984 |
|
4985 |
|
4986 |
|
4987 | pp.parseBlock = function (allowStrict) {
|
4988 | var node = this.startNode(),
|
4989 | first = true,
|
4990 | oldStrict = undefined;
|
4991 | node.body = [];
|
4992 | this.expect(tt.braceL);
|
4993 | while (!this.eat(tt.braceR)) {
|
4994 | var stmt = this.parseStatement(true);
|
4995 | node.body.push(stmt);
|
4996 | if (first && allowStrict && this.isUseStrict(stmt)) {
|
4997 | oldStrict = this.strict;
|
4998 | this.setStrict(this.strict = true);
|
4999 | }
|
5000 | first = false;
|
5001 | }
|
5002 | if (oldStrict === false) this.setStrict(false);
|
5003 | return this.finishNode(node, "BlockStatement");
|
5004 | };
|
5005 |
|
5006 |
|
5007 |
|
5008 |
|
5009 |
|
5010 | pp.parseFor = function (node, init) {
|
5011 | node.init = init;
|
5012 | this.expect(tt.semi);
|
5013 | node.test = this.type === tt.semi ? null : this.parseExpression();
|
5014 | this.expect(tt.semi);
|
5015 | node.update = this.type === tt.parenR ? null : this.parseExpression();
|
5016 | this.expect(tt.parenR);
|
5017 | node.body = this.parseStatement(false);
|
5018 | this.labels.pop();
|
5019 | return this.finishNode(node, "ForStatement");
|
5020 | };
|
5021 |
|
5022 |
|
5023 |
|
5024 |
|
5025 | pp.parseForIn = function (node, init) {
|
5026 | var type = this.type === tt._in ? "ForInStatement" : "ForOfStatement";
|
5027 | this.next();
|
5028 | node.left = init;
|
5029 | node.right = this.parseExpression();
|
5030 | this.expect(tt.parenR);
|
5031 | node.body = this.parseStatement(false);
|
5032 | this.labels.pop();
|
5033 | return this.finishNode(node, type);
|
5034 | };
|
5035 |
|
5036 |
|
5037 |
|
5038 | pp.parseVar = function (node, isFor, kind) {
|
5039 | node.declarations = [];
|
5040 | node.kind = kind.keyword;
|
5041 | for (;;) {
|
5042 | var decl = this.startNode();
|
5043 | this.parseVarId(decl);
|
5044 | if (this.eat(tt.eq)) {
|
5045 | decl.init = this.parseMaybeAssign(isFor);
|
5046 | } else if (kind === tt._const && !(this.type === tt._in || this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
|
5047 | this.unexpected();
|
5048 | } else if (decl.id.type != "Identifier" && !(isFor && (this.type === tt._in || this.isContextual("of")))) {
|
5049 | this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
|
5050 | } else {
|
5051 | decl.init = null;
|
5052 | }
|
5053 | node.declarations.push(this.finishNode(decl, "VariableDeclarator"));
|
5054 | if (!this.eat(tt.comma)) break;
|
5055 | }
|
5056 | return node;
|
5057 | };
|
5058 |
|
5059 | pp.parseVarId = function (decl) {
|
5060 | decl.id = this.parseBindingAtom();
|
5061 | this.checkLVal(decl.id, true);
|
5062 | };
|
5063 |
|
5064 |
|
5065 |
|
5066 |
|
5067 | pp.parseFunction = function (node, isStatement, allowExpressionBody) {
|
5068 | this.initFunction(node);
|
5069 | if (this.options.ecmaVersion >= 6) node.generator = this.eat(tt.star);
|
5070 | if (isStatement || this.type === tt.name) node.id = this.parseIdent();
|
5071 | this.parseFunctionParams(node);
|
5072 | this.parseFunctionBody(node, allowExpressionBody);
|
5073 | return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");
|
5074 | };
|
5075 |
|
5076 | pp.parseFunctionParams = function (node) {
|
5077 | this.expect(tt.parenL);
|
5078 | node.params = this.parseBindingList(tt.parenR, false, false);
|
5079 | };
|
5080 |
|
5081 |
|
5082 |
|
5083 |
|
5084 | pp.parseClass = function (node, isStatement) {
|
5085 | this.next();
|
5086 | this.parseClassId(node, isStatement);
|
5087 | this.parseClassSuper(node);
|
5088 | var classBody = this.startNode();
|
5089 | var hadConstructor = false;
|
5090 | classBody.body = [];
|
5091 | this.expect(tt.braceL);
|
5092 | while (!this.eat(tt.braceR)) {
|
5093 | if (this.eat(tt.semi)) continue;
|
5094 | var method = this.startNode();
|
5095 | var isGenerator = this.eat(tt.star);
|
5096 | var isMaybeStatic = this.type === tt.name && this.value === "static";
|
5097 | this.parsePropertyName(method);
|
5098 | method["static"] = isMaybeStatic && this.type !== tt.parenL;
|
5099 | if (method["static"]) {
|
5100 | if (isGenerator) this.unexpected();
|
5101 | isGenerator = this.eat(tt.star);
|
5102 | this.parsePropertyName(method);
|
5103 | }
|
5104 | method.kind = "method";
|
5105 | if (!method.computed) {
|
5106 | var key = method.key;
|
5107 |
|
5108 | var isGetSet = false;
|
5109 | if (!isGenerator && key.type === "Identifier" && this.type !== tt.parenL && (key.name === "get" || key.name === "set")) {
|
5110 | isGetSet = true;
|
5111 | method.kind = key.name;
|
5112 | key = this.parsePropertyName(method);
|
5113 | }
|
5114 | if (!method["static"] && (key.type === "Identifier" && key.name === "constructor" || key.type === "Literal" && key.value === "constructor")) {
|
5115 | if (hadConstructor) this.raise(key.start, "Duplicate constructor in the same class");
|
5116 | if (isGetSet) this.raise(key.start, "Constructor can't have get/set modifier");
|
5117 | if (isGenerator) this.raise(key.start, "Constructor can't be a generator");
|
5118 | method.kind = "constructor";
|
5119 | hadConstructor = true;
|
5120 | }
|
5121 | }
|
5122 | this.parseClassMethod(classBody, method, isGenerator);
|
5123 | }
|
5124 | node.body = this.finishNode(classBody, "ClassBody");
|
5125 | return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
|
5126 | };
|
5127 |
|
5128 | pp.parseClassMethod = function (classBody, method, isGenerator) {
|
5129 | method.value = this.parseMethod(isGenerator);
|
5130 | classBody.body.push(this.finishNode(method, "MethodDefinition"));
|
5131 | };
|
5132 |
|
5133 | pp.parseClassId = function (node, isStatement) {
|
5134 | node.id = this.type === tt.name ? this.parseIdent() : isStatement ? this.unexpected() : null;
|
5135 | };
|
5136 |
|
5137 | pp.parseClassSuper = function (node) {
|
5138 | node.superClass = this.eat(tt._extends) ? this.parseExprSubscripts() : null;
|
5139 | };
|
5140 |
|
5141 |
|
5142 |
|
5143 | pp.parseExport = function (node) {
|
5144 | this.next();
|
5145 |
|
5146 | if (this.eat(tt.star)) {
|
5147 | this.expectContextual("from");
|
5148 | node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();
|
5149 | this.semicolon();
|
5150 | return this.finishNode(node, "ExportAllDeclaration");
|
5151 | }
|
5152 | if (this.eat(tt._default)) {
|
5153 |
|
5154 | var expr = this.parseMaybeAssign();
|
5155 | var needsSemi = true;
|
5156 | if (expr.type == "FunctionExpression" || expr.type == "ClassExpression") {
|
5157 | needsSemi = false;
|
5158 | if (expr.id) {
|
5159 | expr.type = expr.type == "FunctionExpression" ? "FunctionDeclaration" : "ClassDeclaration";
|
5160 | }
|
5161 | }
|
5162 | node.declaration = expr;
|
5163 | if (needsSemi) this.semicolon();
|
5164 | return this.finishNode(node, "ExportDefaultDeclaration");
|
5165 | }
|
5166 |
|
5167 | if (this.shouldParseExportStatement()) {
|
5168 | node.declaration = this.parseStatement(true);
|
5169 | node.specifiers = [];
|
5170 | node.source = null;
|
5171 | } else {
|
5172 |
|
5173 | node.declaration = null;
|
5174 | node.specifiers = this.parseExportSpecifiers();
|
5175 | if (this.eatContextual("from")) {
|
5176 | node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();
|
5177 | } else {
|
5178 | node.source = null;
|
5179 | }
|
5180 | this.semicolon();
|
5181 | }
|
5182 | return this.finishNode(node, "ExportNamedDeclaration");
|
5183 | };
|
5184 |
|
5185 | pp.shouldParseExportStatement = function () {
|
5186 | return this.type.keyword;
|
5187 | };
|
5188 |
|
5189 |
|
5190 |
|
5191 | pp.parseExportSpecifiers = function () {
|
5192 | var nodes = [],
|
5193 | first = true;
|
5194 |
|
5195 | this.expect(tt.braceL);
|
5196 | while (!this.eat(tt.braceR)) {
|
5197 | if (!first) {
|
5198 | this.expect(tt.comma);
|
5199 | if (this.afterTrailingComma(tt.braceR)) break;
|
5200 | } else first = false;
|
5201 |
|
5202 | var node = this.startNode();
|
5203 | node.local = this.parseIdent(this.type === tt._default);
|
5204 | node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local;
|
5205 | nodes.push(this.finishNode(node, "ExportSpecifier"));
|
5206 | }
|
5207 | return nodes;
|
5208 | };
|
5209 |
|
5210 |
|
5211 |
|
5212 | pp.parseImport = function (node) {
|
5213 | this.next();
|
5214 |
|
5215 | if (this.type === tt.string) {
|
5216 | node.specifiers = empty;
|
5217 | node.source = this.parseExprAtom();
|
5218 | node.kind = "";
|
5219 | } else {
|
5220 | node.specifiers = this.parseImportSpecifiers();
|
5221 | this.expectContextual("from");
|
5222 | node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();
|
5223 | }
|
5224 | this.semicolon();
|
5225 | return this.finishNode(node, "ImportDeclaration");
|
5226 | };
|
5227 |
|
5228 |
|
5229 |
|
5230 | pp.parseImportSpecifiers = function () {
|
5231 | var nodes = [],
|
5232 | first = true;
|
5233 | if (this.type === tt.name) {
|
5234 |
|
5235 | var node = this.startNode();
|
5236 | node.local = this.parseIdent();
|
5237 | this.checkLVal(node.local, true);
|
5238 | nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
|
5239 | if (!this.eat(tt.comma)) return nodes;
|
5240 | }
|
5241 | if (this.type === tt.star) {
|
5242 | var node = this.startNode();
|
5243 | this.next();
|
5244 | this.expectContextual("as");
|
5245 | node.local = this.parseIdent();
|
5246 | this.checkLVal(node.local, true);
|
5247 | nodes.push(this.finishNode(node, "ImportNamespaceSpecifier"));
|
5248 | return nodes;
|
5249 | }
|
5250 | this.expect(tt.braceL);
|
5251 | while (!this.eat(tt.braceR)) {
|
5252 | if (!first) {
|
5253 | this.expect(tt.comma);
|
5254 | if (this.afterTrailingComma(tt.braceR)) break;
|
5255 | } else first = false;
|
5256 |
|
5257 | var node = this.startNode();
|
5258 | node.imported = this.parseIdent(true);
|
5259 | node.local = this.eatContextual("as") ? this.parseIdent() : node.imported;
|
5260 | this.checkLVal(node.local, true);
|
5261 | nodes.push(this.finishNode(node, "ImportSpecifier"));
|
5262 | }
|
5263 | return nodes;
|
5264 | };
|
5265 |
|
5266 | },{"./state":13,"./tokentype":17,"./whitespace":19}],15:[function(_dereq_,module,exports){
|
5267 | "use strict";
|
5268 |
|
5269 | var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
5270 |
|
5271 | exports.__esModule = true;
|
5272 |
|
5273 |
|
5274 |
|
5275 |
|
5276 | var Parser = _dereq_("./state").Parser;
|
5277 |
|
5278 | var tt = _dereq_("./tokentype").types;
|
5279 |
|
5280 | var lineBreak = _dereq_("./whitespace").lineBreak;
|
5281 |
|
5282 | var TokContext = exports.TokContext = function TokContext(token, isExpr, preserveSpace, override) {
|
5283 | _classCallCheck(this, TokContext);
|
5284 |
|
5285 | this.token = token;
|
5286 | this.isExpr = isExpr;
|
5287 | this.preserveSpace = preserveSpace;
|
5288 | this.override = override;
|
5289 | };
|
5290 |
|
5291 | var types = {
|
5292 | b_stat: new TokContext("{", false),
|
5293 | b_expr: new TokContext("{", true),
|
5294 | b_tmpl: new TokContext("${", true),
|
5295 | p_stat: new TokContext("(", false),
|
5296 | p_expr: new TokContext("(", true),
|
5297 | q_tmpl: new TokContext("`", true, true, function (p) {
|
5298 | return p.readTmplToken();
|
5299 | }),
|
5300 | f_expr: new TokContext("function", true)
|
5301 | };
|
5302 |
|
5303 | exports.types = types;
|
5304 | var pp = Parser.prototype;
|
5305 |
|
5306 | pp.initialContext = function () {
|
5307 | return [types.b_stat];
|
5308 | };
|
5309 |
|
5310 | pp.braceIsBlock = function (prevType) {
|
5311 | var parent = undefined;
|
5312 | if (prevType === tt.colon && (parent = this.curContext()).token == "{") return !parent.isExpr;
|
5313 | if (prevType === tt._return) return lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
|
5314 | if (prevType === tt._else || prevType === tt.semi || prevType === tt.eof) return true;
|
5315 | if (prevType == tt.braceL) return this.curContext() === types.b_stat;
|
5316 | return !this.exprAllowed;
|
5317 | };
|
5318 |
|
5319 | pp.updateContext = function (prevType) {
|
5320 | var update = undefined,
|
5321 | type = this.type;
|
5322 | if (type.keyword && prevType == tt.dot) this.exprAllowed = false;else if (update = type.updateContext) update.call(this, prevType);else this.exprAllowed = type.beforeExpr;
|
5323 | };
|
5324 |
|
5325 |
|
5326 |
|
5327 | tt.parenR.updateContext = tt.braceR.updateContext = function () {
|
5328 | if (this.context.length == 1) {
|
5329 | this.exprAllowed = true;
|
5330 | return;
|
5331 | }
|
5332 | var out = this.context.pop();
|
5333 | if (out === types.b_stat && this.curContext() === types.f_expr) {
|
5334 | this.context.pop();
|
5335 | this.exprAllowed = false;
|
5336 | } else if (out === types.b_tmpl) {
|
5337 | this.exprAllowed = true;
|
5338 | } else {
|
5339 | this.exprAllowed = !out.isExpr;
|
5340 | }
|
5341 | };
|
5342 |
|
5343 | tt.braceL.updateContext = function (prevType) {
|
5344 | this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr);
|
5345 | this.exprAllowed = true;
|
5346 | };
|
5347 |
|
5348 | tt.dollarBraceL.updateContext = function () {
|
5349 | this.context.push(types.b_tmpl);
|
5350 | this.exprAllowed = true;
|
5351 | };
|
5352 |
|
5353 | tt.parenL.updateContext = function (prevType) {
|
5354 | var statementParens = prevType === tt._if || prevType === tt._for || prevType === tt._with || prevType === tt._while;
|
5355 | this.context.push(statementParens ? types.p_stat : types.p_expr);
|
5356 | this.exprAllowed = true;
|
5357 | };
|
5358 |
|
5359 | tt.incDec.updateContext = function () {};
|
5360 |
|
5361 | tt._function.updateContext = function () {
|
5362 | if (this.curContext() !== types.b_stat) this.context.push(types.f_expr);
|
5363 | this.exprAllowed = false;
|
5364 | };
|
5365 |
|
5366 | tt.backQuote.updateContext = function () {
|
5367 | if (this.curContext() === types.q_tmpl) this.context.pop();else this.context.push(types.q_tmpl);
|
5368 | this.exprAllowed = false;
|
5369 | };
|
5370 |
|
5371 |
|
5372 |
|
5373 | },{"./state":13,"./tokentype":17,"./whitespace":19}],16:[function(_dereq_,module,exports){
|
5374 | "use strict";
|
5375 |
|
5376 | var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
5377 |
|
5378 | exports.__esModule = true;
|
5379 |
|
5380 | var _identifier = _dereq_("./identifier");
|
5381 |
|
5382 | var isIdentifierStart = _identifier.isIdentifierStart;
|
5383 | var isIdentifierChar = _identifier.isIdentifierChar;
|
5384 |
|
5385 | var _tokentype = _dereq_("./tokentype");
|
5386 |
|
5387 | var tt = _tokentype.types;
|
5388 | var keywordTypes = _tokentype.keywords;
|
5389 |
|
5390 | var Parser = _dereq_("./state").Parser;
|
5391 |
|
5392 | var SourceLocation = _dereq_("./location").SourceLocation;
|
5393 |
|
5394 | var _whitespace = _dereq_("./whitespace");
|
5395 |
|
5396 | var lineBreak = _whitespace.lineBreak;
|
5397 | var lineBreakG = _whitespace.lineBreakG;
|
5398 | var isNewLine = _whitespace.isNewLine;
|
5399 | var nonASCIIwhitespace = _whitespace.nonASCIIwhitespace;
|
5400 |
|
5401 |
|
5402 |
|
5403 |
|
5404 |
|
5405 | var Token = exports.Token = function Token(p) {
|
5406 | _classCallCheck(this, Token);
|
5407 |
|
5408 | this.type = p.type;
|
5409 | this.value = p.value;
|
5410 | this.start = p.start;
|
5411 | this.end = p.end;
|
5412 | if (p.options.locations) this.loc = new SourceLocation(p, p.startLoc, p.endLoc);
|
5413 | if (p.options.ranges) this.range = [p.start, p.end];
|
5414 | };
|
5415 |
|
5416 |
|
5417 |
|
5418 | var pp = Parser.prototype;
|
5419 |
|
5420 |
|
5421 | var isRhino = typeof Packages !== "undefined";
|
5422 |
|
5423 |
|
5424 |
|
5425 | pp.next = function () {
|
5426 | if (this.options.onToken) this.options.onToken(new Token(this));
|
5427 |
|
5428 | this.lastTokEnd = this.end;
|
5429 | this.lastTokStart = this.start;
|
5430 | this.lastTokEndLoc = this.endLoc;
|
5431 | this.lastTokStartLoc = this.startLoc;
|
5432 | this.nextToken();
|
5433 | };
|
5434 |
|
5435 | pp.getToken = function () {
|
5436 | this.next();
|
5437 | return new Token(this);
|
5438 | };
|
5439 |
|
5440 |
|
5441 | if (typeof Symbol !== "undefined") pp[Symbol.iterator] = function () {
|
5442 | var self = this;
|
5443 | return { next: function next() {
|
5444 | var token = self.getToken();
|
5445 | return {
|
5446 | done: token.type === tt.eof,
|
5447 | value: token
|
5448 | };
|
5449 | } };
|
5450 | };
|
5451 |
|
5452 |
|
5453 |
|
5454 |
|
5455 | pp.setStrict = function (strict) {
|
5456 | this.strict = strict;
|
5457 | if (this.type !== tt.num && this.type !== tt.string) return;
|
5458 | this.pos = this.start;
|
5459 | if (this.options.locations) {
|
5460 | while (this.pos < this.lineStart) {
|
5461 | this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1;
|
5462 | --this.curLine;
|
5463 | }
|
5464 | }
|
5465 | this.nextToken();
|
5466 | };
|
5467 |
|
5468 | pp.curContext = function () {
|
5469 | return this.context[this.context.length - 1];
|
5470 | };
|
5471 |
|
5472 |
|
5473 |
|
5474 |
|
5475 | pp.nextToken = function () {
|
5476 | var curContext = this.curContext();
|
5477 | if (!curContext || !curContext.preserveSpace) this.skipSpace();
|
5478 |
|
5479 | this.start = this.pos;
|
5480 | if (this.options.locations) this.startLoc = this.curPosition();
|
5481 | if (this.pos >= this.input.length) return this.finishToken(tt.eof);
|
5482 |
|
5483 | if (curContext.override) return curContext.override(this);else this.readToken(this.fullCharCodeAtPos());
|
5484 | };
|
5485 |
|
5486 | pp.readToken = function (code) {
|
5487 |
|
5488 |
|
5489 | if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 ) return this.readWord();
|
5490 |
|
5491 | return this.getTokenFromCode(code);
|
5492 | };
|
5493 |
|
5494 | pp.fullCharCodeAtPos = function () {
|
5495 | var code = this.input.charCodeAt(this.pos);
|
5496 | if (code <= 55295 || code >= 57344) return code;
|
5497 | var next = this.input.charCodeAt(this.pos + 1);
|
5498 | return (code << 10) + next - 56613888;
|
5499 | };
|
5500 |
|
5501 | pp.skipBlockComment = function () {
|
5502 | var startLoc = this.options.onComment && this.options.locations && this.curPosition();
|
5503 | var start = this.pos,
|
5504 | end = this.input.indexOf("*/", this.pos += 2);
|
5505 | if (end === -1) this.raise(this.pos - 2, "Unterminated comment");
|
5506 | this.pos = end + 2;
|
5507 | if (this.options.locations) {
|
5508 | lineBreakG.lastIndex = start;
|
5509 | var match = undefined;
|
5510 | while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {
|
5511 | ++this.curLine;
|
5512 | this.lineStart = match.index + match[0].length;
|
5513 | }
|
5514 | }
|
5515 | if (this.options.onComment) this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, startLoc, this.options.locations && this.curPosition());
|
5516 | };
|
5517 |
|
5518 | pp.skipLineComment = function (startSkip) {
|
5519 | var start = this.pos;
|
5520 | var startLoc = this.options.onComment && this.options.locations && this.curPosition();
|
5521 | var ch = this.input.charCodeAt(this.pos += startSkip);
|
5522 | while (this.pos < this.input.length && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) {
|
5523 | ++this.pos;
|
5524 | ch = this.input.charCodeAt(this.pos);
|
5525 | }
|
5526 | if (this.options.onComment) this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, startLoc, this.options.locations && this.curPosition());
|
5527 | };
|
5528 |
|
5529 |
|
5530 |
|
5531 |
|
5532 | pp.skipSpace = function () {
|
5533 | while (this.pos < this.input.length) {
|
5534 | var ch = this.input.charCodeAt(this.pos);
|
5535 | if (ch === 32) {
|
5536 |
|
5537 | ++this.pos;
|
5538 | } else if (ch === 13) {
|
5539 | ++this.pos;
|
5540 | var next = this.input.charCodeAt(this.pos);
|
5541 | if (next === 10) {
|
5542 | ++this.pos;
|
5543 | }
|
5544 | if (this.options.locations) {
|
5545 | ++this.curLine;
|
5546 | this.lineStart = this.pos;
|
5547 | }
|
5548 | } else if (ch === 10 || ch === 8232 || ch === 8233) {
|
5549 | ++this.pos;
|
5550 | if (this.options.locations) {
|
5551 | ++this.curLine;
|
5552 | this.lineStart = this.pos;
|
5553 | }
|
5554 | } else if (ch > 8 && ch < 14) {
|
5555 | ++this.pos;
|
5556 | } else if (ch === 47) {
|
5557 |
|
5558 | var next = this.input.charCodeAt(this.pos + 1);
|
5559 | if (next === 42) {
|
5560 |
|
5561 | this.skipBlockComment();
|
5562 | } else if (next === 47) {
|
5563 |
|
5564 | this.skipLineComment(2);
|
5565 | } else break;
|
5566 | } else if (ch === 160) {
|
5567 |
|
5568 | ++this.pos;
|
5569 | } else if (ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
|
5570 | ++this.pos;
|
5571 | } else {
|
5572 | break;
|
5573 | }
|
5574 | }
|
5575 | };
|
5576 |
|
5577 |
|
5578 |
|
5579 |
|
5580 |
|
5581 |
|
5582 | pp.finishToken = function (type, val) {
|
5583 | this.end = this.pos;
|
5584 | if (this.options.locations) this.endLoc = this.curPosition();
|
5585 | var prevType = this.type;
|
5586 | this.type = type;
|
5587 | this.value = val;
|
5588 |
|
5589 | this.updateContext(prevType);
|
5590 | };
|
5591 |
|
5592 |
|
5593 |
|
5594 |
|
5595 |
|
5596 |
|
5597 |
|
5598 |
|
5599 |
|
5600 |
|
5601 | pp.readToken_dot = function () {
|
5602 | var next = this.input.charCodeAt(this.pos + 1);
|
5603 | if (next >= 48 && next <= 57) return this.readNumber(true);
|
5604 | var next2 = this.input.charCodeAt(this.pos + 2);
|
5605 | if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) {
|
5606 |
|
5607 | this.pos += 3;
|
5608 | return this.finishToken(tt.ellipsis);
|
5609 | } else {
|
5610 | ++this.pos;
|
5611 | return this.finishToken(tt.dot);
|
5612 | }
|
5613 | };
|
5614 |
|
5615 | pp.readToken_slash = function () {
|
5616 |
|
5617 | var next = this.input.charCodeAt(this.pos + 1);
|
5618 | if (this.exprAllowed) {
|
5619 | ++this.pos;return this.readRegexp();
|
5620 | }
|
5621 | if (next === 61) return this.finishOp(tt.assign, 2);
|
5622 | return this.finishOp(tt.slash, 1);
|
5623 | };
|
5624 |
|
5625 | pp.readToken_mult_modulo = function (code) {
|
5626 |
|
5627 | var next = this.input.charCodeAt(this.pos + 1);
|
5628 | if (next === 61) return this.finishOp(tt.assign, 2);
|
5629 | return this.finishOp(code === 42 ? tt.star : tt.modulo, 1);
|
5630 | };
|
5631 |
|
5632 | pp.readToken_pipe_amp = function (code) {
|
5633 |
|
5634 | var next = this.input.charCodeAt(this.pos + 1);
|
5635 | if (next === code) return this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2);
|
5636 | if (next === 61) return this.finishOp(tt.assign, 2);
|
5637 | return this.finishOp(code === 124 ? tt.bitwiseOR : tt.bitwiseAND, 1);
|
5638 | };
|
5639 |
|
5640 | pp.readToken_caret = function () {
|
5641 |
|
5642 | var next = this.input.charCodeAt(this.pos + 1);
|
5643 | if (next === 61) return this.finishOp(tt.assign, 2);
|
5644 | return this.finishOp(tt.bitwiseXOR, 1);
|
5645 | };
|
5646 |
|
5647 | pp.readToken_plus_min = function (code) {
|
5648 |
|
5649 | var next = this.input.charCodeAt(this.pos + 1);
|
5650 | if (next === code) {
|
5651 | if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 && lineBreak.test(this.input.slice(this.lastTokEnd, this.pos))) {
|
5652 |
|
5653 | this.skipLineComment(3);
|
5654 | this.skipSpace();
|
5655 | return this.nextToken();
|
5656 | }
|
5657 | return this.finishOp(tt.incDec, 2);
|
5658 | }
|
5659 | if (next === 61) return this.finishOp(tt.assign, 2);
|
5660 | return this.finishOp(tt.plusMin, 1);
|
5661 | };
|
5662 |
|
5663 | pp.readToken_lt_gt = function (code) {
|
5664 |
|
5665 | var next = this.input.charCodeAt(this.pos + 1);
|
5666 | var size = 1;
|
5667 | if (next === code) {
|
5668 | size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
|
5669 | if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1);
|
5670 | return this.finishOp(tt.bitShift, size);
|
5671 | }
|
5672 | if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 && this.input.charCodeAt(this.pos + 3) == 45) {
|
5673 | if (this.inModule) this.unexpected();
|
5674 |
|
5675 | this.skipLineComment(4);
|
5676 | this.skipSpace();
|
5677 | return this.nextToken();
|
5678 | }
|
5679 | if (next === 61) size = this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2;
|
5680 | return this.finishOp(tt.relational, size);
|
5681 | };
|
5682 |
|
5683 | pp.readToken_eq_excl = function (code) {
|
5684 |
|
5685 | var next = this.input.charCodeAt(this.pos + 1);
|
5686 | if (next === 61) return this.finishOp(tt.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2);
|
5687 | if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) {
|
5688 |
|
5689 | this.pos += 2;
|
5690 | return this.finishToken(tt.arrow);
|
5691 | }
|
5692 | return this.finishOp(code === 61 ? tt.eq : tt.prefix, 1);
|
5693 | };
|
5694 |
|
5695 | pp.getTokenFromCode = function (code) {
|
5696 | switch (code) {
|
5697 |
|
5698 |
|
5699 | case 46:
|
5700 |
|
5701 | return this.readToken_dot();
|
5702 |
|
5703 |
|
5704 | case 40:
|
5705 | ++this.pos;return this.finishToken(tt.parenL);
|
5706 | case 41:
|
5707 | ++this.pos;return this.finishToken(tt.parenR);
|
5708 | case 59:
|
5709 | ++this.pos;return this.finishToken(tt.semi);
|
5710 | case 44:
|
5711 | ++this.pos;return this.finishToken(tt.comma);
|
5712 | case 91:
|
5713 | ++this.pos;return this.finishToken(tt.bracketL);
|
5714 | case 93:
|
5715 | ++this.pos;return this.finishToken(tt.bracketR);
|
5716 | case 123:
|
5717 | ++this.pos;return this.finishToken(tt.braceL);
|
5718 | case 125:
|
5719 | ++this.pos;return this.finishToken(tt.braceR);
|
5720 | case 58:
|
5721 | ++this.pos;return this.finishToken(tt.colon);
|
5722 | case 63:
|
5723 | ++this.pos;return this.finishToken(tt.question);
|
5724 |
|
5725 | case 96:
|
5726 |
|
5727 | if (this.options.ecmaVersion < 6) break;
|
5728 | ++this.pos;
|
5729 | return this.finishToken(tt.backQuote);
|
5730 |
|
5731 | case 48:
|
5732 |
|
5733 | var next = this.input.charCodeAt(this.pos + 1);
|
5734 | if (next === 120 || next === 88) return this.readRadixNumber(16);
|
5735 | if (this.options.ecmaVersion >= 6) {
|
5736 | if (next === 111 || next === 79) return this.readRadixNumber(8);
|
5737 | if (next === 98 || next === 66) return this.readRadixNumber(2);
|
5738 | }
|
5739 |
|
5740 |
|
5741 | case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:
|
5742 |
|
5743 | return this.readNumber(false);
|
5744 |
|
5745 |
|
5746 | case 34:case 39:
|
5747 |
|
5748 | return this.readString(code);
|
5749 |
|
5750 |
|
5751 |
|
5752 |
|
5753 |
|
5754 |
|
5755 | case 47:
|
5756 |
|
5757 | return this.readToken_slash();
|
5758 |
|
5759 | case 37:case 42:
|
5760 |
|
5761 | return this.readToken_mult_modulo(code);
|
5762 |
|
5763 | case 124:case 38:
|
5764 |
|
5765 | return this.readToken_pipe_amp(code);
|
5766 |
|
5767 | case 94:
|
5768 |
|
5769 | return this.readToken_caret();
|
5770 |
|
5771 | case 43:case 45:
|
5772 |
|
5773 | return this.readToken_plus_min(code);
|
5774 |
|
5775 | case 60:case 62:
|
5776 |
|
5777 | return this.readToken_lt_gt(code);
|
5778 |
|
5779 | case 61:case 33:
|
5780 |
|
5781 | return this.readToken_eq_excl(code);
|
5782 |
|
5783 | case 126:
|
5784 |
|
5785 | return this.finishOp(tt.prefix, 1);
|
5786 | }
|
5787 |
|
5788 | this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
|
5789 | };
|
5790 |
|
5791 | pp.finishOp = function (type, size) {
|
5792 | var str = this.input.slice(this.pos, this.pos + size);
|
5793 | this.pos += size;
|
5794 | return this.finishToken(type, str);
|
5795 | };
|
5796 |
|
5797 | var regexpUnicodeSupport = false;
|
5798 | try {
|
5799 | new RegExp("", "u");regexpUnicodeSupport = true;
|
5800 | } catch (e) {}
|
5801 |
|
5802 |
|
5803 |
|
5804 |
|
5805 | pp.readRegexp = function () {
|
5806 | var escaped = undefined,
|
5807 | inClass = undefined,
|
5808 | start = this.pos;
|
5809 | for (;;) {
|
5810 | if (this.pos >= this.input.length) this.raise(start, "Unterminated regular expression");
|
5811 | var ch = this.input.charAt(this.pos);
|
5812 | if (lineBreak.test(ch)) this.raise(start, "Unterminated regular expression");
|
5813 | if (!escaped) {
|
5814 | if (ch === "[") inClass = true;else if (ch === "]" && inClass) inClass = false;else if (ch === "/" && !inClass) break;
|
5815 | escaped = ch === "\\";
|
5816 | } else escaped = false;
|
5817 | ++this.pos;
|
5818 | }
|
5819 | var content = this.input.slice(start, this.pos);
|
5820 | ++this.pos;
|
5821 |
|
5822 |
|
5823 | var mods = this.readWord1();
|
5824 | var tmp = content;
|
5825 | if (mods) {
|
5826 | var validFlags = /^[gmsiy]*$/;
|
5827 | if (this.options.ecmaVersion >= 6) validFlags = /^[gmsiyu]*$/;
|
5828 | if (!validFlags.test(mods)) this.raise(start, "Invalid regular expression flag");
|
5829 | if (mods.indexOf("u") >= 0 && !regexpUnicodeSupport) {
|
5830 |
|
5831 |
|
5832 |
|
5833 |
|
5834 |
|
5835 |
|
5836 |
|
5837 |
|
5838 | tmp = tmp.replace(/\\u([a-fA-F0-9]{4})|\\u\{([0-9a-fA-F]+)\}|[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x");
|
5839 | }
|
5840 | }
|
5841 |
|
5842 | var value = null;
|
5843 |
|
5844 |
|
5845 | if (!isRhino) {
|
5846 | try {
|
5847 | new RegExp(tmp);
|
5848 | } catch (e) {
|
5849 | if (e instanceof SyntaxError) this.raise(start, "Error parsing regular expression: " + e.message);
|
5850 | this.raise(e);
|
5851 | }
|
5852 |
|
5853 |
|
5854 | try {
|
5855 | value = new RegExp(content, mods);
|
5856 | } catch (err) {}
|
5857 | }
|
5858 | return this.finishToken(tt.regexp, { pattern: content, flags: mods, value: value });
|
5859 | };
|
5860 |
|
5861 |
|
5862 |
|
5863 |
|
5864 |
|
5865 | pp.readInt = function (radix, len) {
|
5866 | var start = this.pos,
|
5867 | total = 0;
|
5868 | for (var i = 0, e = len == null ? Infinity : len; i < e; ++i) {
|
5869 | var code = this.input.charCodeAt(this.pos),
|
5870 | val = undefined;
|
5871 | if (code >= 97) val = code - 97 + 10;
|
5872 | else if (code >= 65) val = code - 65 + 10;
|
5873 | else if (code >= 48 && code <= 57) val = code - 48;
|
5874 | else val = Infinity;
|
5875 | if (val >= radix) break;
|
5876 | ++this.pos;
|
5877 | total = total * radix + val;
|
5878 | }
|
5879 | if (this.pos === start || len != null && this.pos - start !== len) return null;
|
5880 |
|
5881 | return total;
|
5882 | };
|
5883 |
|
5884 | pp.readRadixNumber = function (radix) {
|
5885 | this.pos += 2;
|
5886 | var val = this.readInt(radix);
|
5887 | if (val == null) this.raise(this.start + 2, "Expected number in radix " + radix);
|
5888 | if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");
|
5889 | return this.finishToken(tt.num, val);
|
5890 | };
|
5891 |
|
5892 |
|
5893 |
|
5894 | pp.readNumber = function (startsWithDot) {
|
5895 | var start = this.pos,
|
5896 | isFloat = false,
|
5897 | octal = this.input.charCodeAt(this.pos) === 48;
|
5898 | if (!startsWithDot && this.readInt(10) === null) this.raise(start, "Invalid number");
|
5899 | if (this.input.charCodeAt(this.pos) === 46) {
|
5900 | ++this.pos;
|
5901 | this.readInt(10);
|
5902 | isFloat = true;
|
5903 | }
|
5904 | var next = this.input.charCodeAt(this.pos);
|
5905 | if (next === 69 || next === 101) {
|
5906 |
|
5907 | next = this.input.charCodeAt(++this.pos);
|
5908 | if (next === 43 || next === 45) ++this.pos;
|
5909 | if (this.readInt(10) === null) this.raise(start, "Invalid number");
|
5910 | isFloat = true;
|
5911 | }
|
5912 | if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");
|
5913 |
|
5914 | var str = this.input.slice(start, this.pos),
|
5915 | val = undefined;
|
5916 | if (isFloat) val = parseFloat(str);else if (!octal || str.length === 1) val = parseInt(str, 10);else if (/[89]/.test(str) || this.strict) this.raise(start, "Invalid number");else val = parseInt(str, 8);
|
5917 | return this.finishToken(tt.num, val);
|
5918 | };
|
5919 |
|
5920 |
|
5921 |
|
5922 | pp.readCodePoint = function () {
|
5923 | var ch = this.input.charCodeAt(this.pos),
|
5924 | code = undefined;
|
5925 |
|
5926 | if (ch === 123) {
|
5927 | if (this.options.ecmaVersion < 6) this.unexpected();
|
5928 | ++this.pos;
|
5929 | code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
|
5930 | ++this.pos;
|
5931 | if (code > 1114111) this.unexpected();
|
5932 | } else {
|
5933 | code = this.readHexChar(4);
|
5934 | }
|
5935 | return code;
|
5936 | };
|
5937 |
|
5938 | function codePointToString(code) {
|
5939 |
|
5940 | if (code <= 65535) {
|
5941 | return String.fromCharCode(code);
|
5942 | }return String.fromCharCode((code - 65536 >> 10) + 55296, (code - 65536 & 1023) + 56320);
|
5943 | }
|
5944 |
|
5945 | pp.readString = function (quote) {
|
5946 | var out = "",
|
5947 | chunkStart = ++this.pos;
|
5948 | for (;;) {
|
5949 | if (this.pos >= this.input.length) this.raise(this.start, "Unterminated string constant");
|
5950 | var ch = this.input.charCodeAt(this.pos);
|
5951 | if (ch === quote) break;
|
5952 | if (ch === 92) {
|
5953 |
|
5954 | out += this.input.slice(chunkStart, this.pos);
|
5955 | out += this.readEscapedChar();
|
5956 | chunkStart = this.pos;
|
5957 | } else {
|
5958 | if (isNewLine(ch)) this.raise(this.start, "Unterminated string constant");
|
5959 | ++this.pos;
|
5960 | }
|
5961 | }
|
5962 | out += this.input.slice(chunkStart, this.pos++);
|
5963 | return this.finishToken(tt.string, out);
|
5964 | };
|
5965 |
|
5966 |
|
5967 |
|
5968 | pp.readTmplToken = function () {
|
5969 | var out = "",
|
5970 | chunkStart = this.pos;
|
5971 | for (;;) {
|
5972 | if (this.pos >= this.input.length) this.raise(this.start, "Unterminated template");
|
5973 | var ch = this.input.charCodeAt(this.pos);
|
5974 | if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) {
|
5975 |
|
5976 | if (this.pos === this.start && this.type === tt.template) {
|
5977 | if (ch === 36) {
|
5978 | this.pos += 2;
|
5979 | return this.finishToken(tt.dollarBraceL);
|
5980 | } else {
|
5981 | ++this.pos;
|
5982 | return this.finishToken(tt.backQuote);
|
5983 | }
|
5984 | }
|
5985 | out += this.input.slice(chunkStart, this.pos);
|
5986 | return this.finishToken(tt.template, out);
|
5987 | }
|
5988 | if (ch === 92) {
|
5989 |
|
5990 | out += this.input.slice(chunkStart, this.pos);
|
5991 | out += this.readEscapedChar();
|
5992 | chunkStart = this.pos;
|
5993 | } else if (isNewLine(ch)) {
|
5994 | out += this.input.slice(chunkStart, this.pos);
|
5995 | ++this.pos;
|
5996 | if (ch === 13 && this.input.charCodeAt(this.pos) === 10) {
|
5997 | ++this.pos;
|
5998 | out += "\n";
|
5999 | } else {
|
6000 | out += String.fromCharCode(ch);
|
6001 | }
|
6002 | if (this.options.locations) {
|
6003 | ++this.curLine;
|
6004 | this.lineStart = this.pos;
|
6005 | }
|
6006 | chunkStart = this.pos;
|
6007 | } else {
|
6008 | ++this.pos;
|
6009 | }
|
6010 | }
|
6011 | };
|
6012 |
|
6013 |
|
6014 |
|
6015 | pp.readEscapedChar = function () {
|
6016 | var ch = this.input.charCodeAt(++this.pos);
|
6017 | var octal = /^[0-7]+/.exec(this.input.slice(this.pos, this.pos + 3));
|
6018 | if (octal) octal = octal[0];
|
6019 | while (octal && parseInt(octal, 8) > 255) octal = octal.slice(0, -1);
|
6020 | if (octal === "0") octal = null;
|
6021 | ++this.pos;
|
6022 | if (octal) {
|
6023 | if (this.strict) this.raise(this.pos - 2, "Octal literal in strict mode");
|
6024 | this.pos += octal.length - 1;
|
6025 | return String.fromCharCode(parseInt(octal, 8));
|
6026 | } else {
|
6027 | switch (ch) {
|
6028 | case 110:
|
6029 | return "\n";
|
6030 | case 114:
|
6031 | return "\r";
|
6032 | case 120:
|
6033 | return String.fromCharCode(this.readHexChar(2));
|
6034 | case 117:
|
6035 | return codePointToString(this.readCodePoint());
|
6036 | case 116:
|
6037 | return "\t";
|
6038 | case 98:
|
6039 | return "\b";
|
6040 | case 118:
|
6041 | return "\u000b";
|
6042 | case 102:
|
6043 | return "\f";
|
6044 | case 48:
|
6045 | return "\u0000";
|
6046 | case 13:
|
6047 | if (this.input.charCodeAt(this.pos) === 10) ++this.pos;
|
6048 | case 10:
|
6049 |
|
6050 | if (this.options.locations) {
|
6051 | this.lineStart = this.pos;++this.curLine;
|
6052 | }
|
6053 | return "";
|
6054 | default:
|
6055 | return String.fromCharCode(ch);
|
6056 | }
|
6057 | }
|
6058 | };
|
6059 |
|
6060 |
|
6061 |
|
6062 | pp.readHexChar = function (len) {
|
6063 | var n = this.readInt(16, len);
|
6064 | if (n === null) this.raise(this.start, "Bad character escape sequence");
|
6065 | return n;
|
6066 | };
|
6067 |
|
6068 |
|
6069 |
|
6070 |
|
6071 |
|
6072 | var containsEsc;
|
6073 |
|
6074 |
|
6075 |
|
6076 |
|
6077 |
|
6078 |
|
6079 |
|
6080 | pp.readWord1 = function () {
|
6081 | containsEsc = false;
|
6082 | var word = "",
|
6083 | first = true,
|
6084 | chunkStart = this.pos;
|
6085 | var astral = this.options.ecmaVersion >= 6;
|
6086 | while (this.pos < this.input.length) {
|
6087 | var ch = this.fullCharCodeAtPos();
|
6088 | if (isIdentifierChar(ch, astral)) {
|
6089 | this.pos += ch <= 65535 ? 1 : 2;
|
6090 | } else if (ch === 92) {
|
6091 |
|
6092 | containsEsc = true;
|
6093 | word += this.input.slice(chunkStart, this.pos);
|
6094 | var escStart = this.pos;
|
6095 | if (this.input.charCodeAt(++this.pos) != 117)
|
6096 | this.raise(this.pos, "Expecting Unicode escape sequence \\uXXXX");
|
6097 | ++this.pos;
|
6098 | var esc = this.readCodePoint();
|
6099 | if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral)) this.raise(escStart, "Invalid Unicode escape");
|
6100 | word += codePointToString(esc);
|
6101 | chunkStart = this.pos;
|
6102 | } else {
|
6103 | break;
|
6104 | }
|
6105 | first = false;
|
6106 | }
|
6107 | return word + this.input.slice(chunkStart, this.pos);
|
6108 | };
|
6109 |
|
6110 |
|
6111 |
|
6112 |
|
6113 | pp.readWord = function () {
|
6114 | var word = this.readWord1();
|
6115 | var type = tt.name;
|
6116 | if ((this.options.ecmaVersion >= 6 || !containsEsc) && this.isKeyword(word)) type = keywordTypes[word];
|
6117 | return this.finishToken(type, word);
|
6118 | };
|
6119 |
|
6120 | },{"./identifier":7,"./location":8,"./state":13,"./tokentype":17,"./whitespace":19}],17:[function(_dereq_,module,exports){
|
6121 | "use strict";
|
6122 |
|
6123 | var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
6124 |
|
6125 | exports.__esModule = true;
|
6126 |
|
6127 |
|
6128 |
|
6129 |
|
6130 |
|
6131 |
|
6132 |
|
6133 |
|
6134 |
|
6135 |
|
6136 |
|
6137 |
|
6138 |
|
6139 |
|
6140 |
|
6141 |
|
6142 |
|
6143 |
|
6144 | var TokenType = exports.TokenType = function TokenType(label) {
|
6145 | var conf = arguments[1] === undefined ? {} : arguments[1];
|
6146 |
|
6147 | _classCallCheck(this, TokenType);
|
6148 |
|
6149 | this.label = label;
|
6150 | this.keyword = conf.keyword;
|
6151 | this.beforeExpr = !!conf.beforeExpr;
|
6152 | this.startsExpr = !!conf.startsExpr;
|
6153 | this.isLoop = !!conf.isLoop;
|
6154 | this.isAssign = !!conf.isAssign;
|
6155 | this.prefix = !!conf.prefix;
|
6156 | this.postfix = !!conf.postfix;
|
6157 | this.binop = conf.binop || null;
|
6158 | this.updateContext = null;
|
6159 | };
|
6160 |
|
6161 | function binop(name, prec) {
|
6162 | return new TokenType(name, { beforeExpr: true, binop: prec });
|
6163 | }
|
6164 | var beforeExpr = { beforeExpr: true },
|
6165 | startsExpr = { startsExpr: true };
|
6166 |
|
6167 | var types = {
|
6168 | num: new TokenType("num", startsExpr),
|
6169 | regexp: new TokenType("regexp", startsExpr),
|
6170 | string: new TokenType("string", startsExpr),
|
6171 | name: new TokenType("name", startsExpr),
|
6172 | eof: new TokenType("eof"),
|
6173 |
|
6174 |
|
6175 | bracketL: new TokenType("[", { beforeExpr: true, startsExpr: true }),
|
6176 | bracketR: new TokenType("]"),
|
6177 | braceL: new TokenType("{", { beforeExpr: true, startsExpr: true }),
|
6178 | braceR: new TokenType("}"),
|
6179 | parenL: new TokenType("(", { beforeExpr: true, startsExpr: true }),
|
6180 | parenR: new TokenType(")"),
|
6181 | comma: new TokenType(",", beforeExpr),
|
6182 | semi: new TokenType(";", beforeExpr),
|
6183 | colon: new TokenType(":", beforeExpr),
|
6184 | dot: new TokenType("."),
|
6185 | question: new TokenType("?", beforeExpr),
|
6186 | arrow: new TokenType("=>", beforeExpr),
|
6187 | template: new TokenType("template"),
|
6188 | ellipsis: new TokenType("...", beforeExpr),
|
6189 | backQuote: new TokenType("`", startsExpr),
|
6190 | dollarBraceL: new TokenType("${", { beforeExpr: true, startsExpr: true }),
|
6191 |
|
6192 |
|
6193 |
|
6194 |
|
6195 |
|
6196 |
|
6197 |
|
6198 |
|
6199 |
|
6200 |
|
6201 |
|
6202 |
|
6203 |
|
6204 |
|
6205 |
|
6206 | eq: new TokenType("=", { beforeExpr: true, isAssign: true }),
|
6207 | assign: new TokenType("_=", { beforeExpr: true, isAssign: true }),
|
6208 | incDec: new TokenType("++/--", { prefix: true, postfix: true, startsExpr: true }),
|
6209 | prefix: new TokenType("prefix", { beforeExpr: true, prefix: true, startsExpr: true }),
|
6210 | logicalOR: binop("||", 1),
|
6211 | logicalAND: binop("&&", 2),
|
6212 | bitwiseOR: binop("|", 3),
|
6213 | bitwiseXOR: binop("^", 4),
|
6214 | bitwiseAND: binop("&", 5),
|
6215 | equality: binop("==/!=", 6),
|
6216 | relational: binop("</>", 7),
|
6217 | bitShift: binop("<</>>", 8),
|
6218 | plusMin: new TokenType("+/-", { beforeExpr: true, binop: 9, prefix: true, startsExpr: true }),
|
6219 | modulo: binop("%", 10),
|
6220 | star: binop("*", 10),
|
6221 | slash: binop("/", 10)
|
6222 | };
|
6223 |
|
6224 | exports.types = types;
|
6225 |
|
6226 |
|
6227 | var keywords = {};
|
6228 |
|
6229 | exports.keywords = keywords;
|
6230 |
|
6231 | function kw(name) {
|
6232 | var options = arguments[1] === undefined ? {} : arguments[1];
|
6233 |
|
6234 | options.keyword = name;
|
6235 | keywords[name] = types["_" + name] = new TokenType(name, options);
|
6236 | }
|
6237 |
|
6238 | kw("break");
|
6239 | kw("case", beforeExpr);
|
6240 | kw("catch");
|
6241 | kw("continue");
|
6242 | kw("debugger");
|
6243 | kw("default");
|
6244 | kw("do", { isLoop: true });
|
6245 | kw("else", beforeExpr);
|
6246 | kw("finally");
|
6247 | kw("for", { isLoop: true });
|
6248 | kw("function", startsExpr);
|
6249 | kw("if");
|
6250 | kw("return", beforeExpr);
|
6251 | kw("switch");
|
6252 | kw("throw", beforeExpr);
|
6253 | kw("try");
|
6254 | kw("var");
|
6255 | kw("let");
|
6256 | kw("const");
|
6257 | kw("while", { isLoop: true });
|
6258 | kw("with");
|
6259 | kw("new", { beforeExpr: true, startsExpr: true });
|
6260 | kw("this", startsExpr);
|
6261 | kw("super", startsExpr);
|
6262 | kw("class");
|
6263 | kw("extends", beforeExpr);
|
6264 | kw("export");
|
6265 | kw("import");
|
6266 | kw("yield", { beforeExpr: true, startsExpr: true });
|
6267 | kw("null", startsExpr);
|
6268 | kw("true", startsExpr);
|
6269 | kw("false", startsExpr);
|
6270 | kw("in", { beforeExpr: true, binop: 7 });
|
6271 | kw("instanceof", { beforeExpr: true, binop: 7 });
|
6272 | kw("typeof", { beforeExpr: true, prefix: true, startsExpr: true });
|
6273 | kw("void", { beforeExpr: true, prefix: true, startsExpr: true });
|
6274 | kw("delete", { beforeExpr: true, prefix: true, startsExpr: true });
|
6275 |
|
6276 | },{}],18:[function(_dereq_,module,exports){
|
6277 | "use strict";
|
6278 |
|
6279 | exports.isArray = isArray;
|
6280 |
|
6281 |
|
6282 |
|
6283 | exports.has = has;
|
6284 | exports.__esModule = true;
|
6285 |
|
6286 | function isArray(obj) {
|
6287 | return Object.prototype.toString.call(obj) === "[object Array]";
|
6288 | }
|
6289 |
|
6290 | function has(obj, propName) {
|
6291 | return Object.prototype.hasOwnProperty.call(obj, propName);
|
6292 | }
|
6293 |
|
6294 | },{}],19:[function(_dereq_,module,exports){
|
6295 | "use strict";
|
6296 |
|
6297 | exports.isNewLine = isNewLine;
|
6298 | exports.__esModule = true;
|
6299 |
|
6300 |
|
6301 |
|
6302 | var lineBreak = /\r\n?|\n|\u2028|\u2029/;
|
6303 | exports.lineBreak = lineBreak;
|
6304 | var lineBreakG = new RegExp(lineBreak.source, "g");
|
6305 |
|
6306 | exports.lineBreakG = lineBreakG;
|
6307 |
|
6308 | function isNewLine(code) {
|
6309 | return code === 10 || code === 13 || code === 8232 || code == 8233;
|
6310 | }
|
6311 |
|
6312 | var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
|
6313 | exports.nonASCIIwhitespace = nonASCIIwhitespace;
|
6314 |
|
6315 | },{}]},{},[1])(1)
|
6316 | });
|
6317 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
6318 |
|
6319 | },{}],"/www/ROLLUP/rollup/node_modules/gobble-browserify/node_modules/browserify/node_modules/buffer/index.js":[function(require,module,exports){
|
6320 |
|
6321 |
|
6322 |
|
6323 |
|
6324 |
|
6325 |
|
6326 |
|
6327 | var base64 = require('base64-js')
|
6328 | var ieee754 = require('ieee754')
|
6329 | var isArray = require('is-array')
|
6330 |
|
6331 | exports.Buffer = Buffer
|
6332 | exports.SlowBuffer = SlowBuffer
|
6333 | exports.INSPECT_MAX_BYTES = 50
|
6334 | Buffer.poolSize = 8192
|
6335 |
|
6336 | var rootParent = {}
|
6337 |
|
6338 |
|
6339 |
|
6340 |
|
6341 |
|
6342 |
|
6343 |
|
6344 |
|
6345 |
|
6346 |
|
6347 |
|
6348 |
|
6349 |
|
6350 |
|
6351 |
|
6352 |
|
6353 |
|
6354 |
|
6355 |
|
6356 |
|
6357 |
|
6358 |
|
6359 |
|
6360 | Buffer.TYPED_ARRAY_SUPPORT = (function () {
|
6361 | function Foo () {}
|
6362 | try {
|
6363 | var buf = new ArrayBuffer(0)
|
6364 | var arr = new Uint8Array(buf)
|
6365 | arr.foo = function () { return 42 }
|
6366 | arr.constructor = Foo
|
6367 | return arr.foo() === 42 &&
|
6368 | arr.constructor === Foo &&
|
6369 | typeof arr.subarray === 'function' &&
|
6370 | new Uint8Array(1).subarray(1, 1).byteLength === 0
|
6371 | } catch (e) {
|
6372 | return false
|
6373 | }
|
6374 | })()
|
6375 |
|
6376 | function kMaxLength () {
|
6377 | return Buffer.TYPED_ARRAY_SUPPORT
|
6378 | ? 0x7fffffff
|
6379 | : 0x3fffffff
|
6380 | }
|
6381 |
|
6382 |
|
6383 |
|
6384 |
|
6385 |
|
6386 |
|
6387 |
|
6388 |
|
6389 |
|
6390 |
|
6391 |
|
6392 |
|
6393 |
|
6394 | function Buffer (arg) {
|
6395 | if (!(this instanceof Buffer)) {
|
6396 |
|
6397 | if (arguments.length > 1) return new Buffer(arg, arguments[1])
|
6398 | return new Buffer(arg)
|
6399 | }
|
6400 |
|
6401 | this.length = 0
|
6402 | this.parent = undefined
|
6403 |
|
6404 |
|
6405 | if (typeof arg === 'number') {
|
6406 | return fromNumber(this, arg)
|
6407 | }
|
6408 |
|
6409 |
|
6410 | if (typeof arg === 'string') {
|
6411 | return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8')
|
6412 | }
|
6413 |
|
6414 |
|
6415 | return fromObject(this, arg)
|
6416 | }
|
6417 |
|
6418 | function fromNumber (that, length) {
|
6419 | that = allocate(that, length < 0 ? 0 : checked(length) | 0)
|
6420 | if (!Buffer.TYPED_ARRAY_SUPPORT) {
|
6421 | for (var i = 0; i < length; i++) {
|
6422 | that[i] = 0
|
6423 | }
|
6424 | }
|
6425 | return that
|
6426 | }
|
6427 |
|
6428 | function fromString (that, string, encoding) {
|
6429 | if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8'
|
6430 |
|
6431 |
|
6432 | var length = byteLength(string, encoding) | 0
|
6433 | that = allocate(that, length)
|
6434 |
|
6435 | that.write(string, encoding)
|
6436 | return that
|
6437 | }
|
6438 |
|
6439 | function fromObject (that, object) {
|
6440 | if (Buffer.isBuffer(object)) return fromBuffer(that, object)
|
6441 |
|
6442 | if (isArray(object)) return fromArray(that, object)
|
6443 |
|
6444 | if (object == null) {
|
6445 | throw new TypeError('must start with number, buffer, array or string')
|
6446 | }
|
6447 |
|
6448 | if (typeof ArrayBuffer !== 'undefined' && object.buffer instanceof ArrayBuffer) {
|
6449 | return fromTypedArray(that, object)
|
6450 | }
|
6451 |
|
6452 | if (object.length) return fromArrayLike(that, object)
|
6453 |
|
6454 | return fromJsonObject(that, object)
|
6455 | }
|
6456 |
|
6457 | function fromBuffer (that, buffer) {
|
6458 | var length = checked(buffer.length) | 0
|
6459 | that = allocate(that, length)
|
6460 | buffer.copy(that, 0, 0, length)
|
6461 | return that
|
6462 | }
|
6463 |
|
6464 | function fromArray (that, array) {
|
6465 | var length = checked(array.length) | 0
|
6466 | that = allocate(that, length)
|
6467 | for (var i = 0; i < length; i += 1) {
|
6468 | that[i] = array[i] & 255
|
6469 | }
|
6470 | return that
|
6471 | }
|
6472 |
|
6473 |
|
6474 | function fromTypedArray (that, array) {
|
6475 | var length = checked(array.length) | 0
|
6476 | that = allocate(that, length)
|
6477 |
|
6478 |
|
6479 |
|
6480 | for (var i = 0; i < length; i += 1) {
|
6481 | that[i] = array[i] & 255
|
6482 | }
|
6483 | return that
|
6484 | }
|
6485 |
|
6486 | function fromArrayLike (that, array) {
|
6487 | var length = checked(array.length) | 0
|
6488 | that = allocate(that, length)
|
6489 | for (var i = 0; i < length; i += 1) {
|
6490 | that[i] = array[i] & 255
|
6491 | }
|
6492 | return that
|
6493 | }
|
6494 |
|
6495 |
|
6496 |
|
6497 | function fromJsonObject (that, object) {
|
6498 | var array
|
6499 | var length = 0
|
6500 |
|
6501 | if (object.type === 'Buffer' && isArray(object.data)) {
|
6502 | array = object.data
|
6503 | length = checked(array.length) | 0
|
6504 | }
|
6505 | that = allocate(that, length)
|
6506 |
|
6507 | for (var i = 0; i < length; i += 1) {
|
6508 | that[i] = array[i] & 255
|
6509 | }
|
6510 | return that
|
6511 | }
|
6512 |
|
6513 | function allocate (that, length) {
|
6514 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6515 |
|
6516 | that = Buffer._augment(new Uint8Array(length))
|
6517 | } else {
|
6518 |
|
6519 | that.length = length
|
6520 | that._isBuffer = true
|
6521 | }
|
6522 |
|
6523 | var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1
|
6524 | if (fromPool) that.parent = rootParent
|
6525 |
|
6526 | return that
|
6527 | }
|
6528 |
|
6529 | function checked (length) {
|
6530 |
|
6531 |
|
6532 | if (length >= kMaxLength()) {
|
6533 | throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
6534 | 'size: 0x' + kMaxLength().toString(16) + ' bytes')
|
6535 | }
|
6536 | return length | 0
|
6537 | }
|
6538 |
|
6539 | function SlowBuffer (subject, encoding) {
|
6540 | if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding)
|
6541 |
|
6542 | var buf = new Buffer(subject, encoding)
|
6543 | delete buf.parent
|
6544 | return buf
|
6545 | }
|
6546 |
|
6547 | Buffer.isBuffer = function isBuffer (b) {
|
6548 | return !!(b != null && b._isBuffer)
|
6549 | }
|
6550 |
|
6551 | Buffer.compare = function compare (a, b) {
|
6552 | if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
6553 | throw new TypeError('Arguments must be Buffers')
|
6554 | }
|
6555 |
|
6556 | if (a === b) return 0
|
6557 |
|
6558 | var x = a.length
|
6559 | var y = b.length
|
6560 |
|
6561 | var i = 0
|
6562 | var len = Math.min(x, y)
|
6563 | while (i < len) {
|
6564 | if (a[i] !== b[i]) break
|
6565 |
|
6566 | ++i
|
6567 | }
|
6568 |
|
6569 | if (i !== len) {
|
6570 | x = a[i]
|
6571 | y = b[i]
|
6572 | }
|
6573 |
|
6574 | if (x < y) return -1
|
6575 | if (y < x) return 1
|
6576 | return 0
|
6577 | }
|
6578 |
|
6579 | Buffer.isEncoding = function isEncoding (encoding) {
|
6580 | switch (String(encoding).toLowerCase()) {
|
6581 | case 'hex':
|
6582 | case 'utf8':
|
6583 | case 'utf-8':
|
6584 | case 'ascii':
|
6585 | case 'binary':
|
6586 | case 'base64':
|
6587 | case 'raw':
|
6588 | case 'ucs2':
|
6589 | case 'ucs-2':
|
6590 | case 'utf16le':
|
6591 | case 'utf-16le':
|
6592 | return true
|
6593 | default:
|
6594 | return false
|
6595 | }
|
6596 | }
|
6597 |
|
6598 | Buffer.concat = function concat (list, length) {
|
6599 | if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
|
6600 |
|
6601 | if (list.length === 0) {
|
6602 | return new Buffer(0)
|
6603 | } else if (list.length === 1) {
|
6604 | return list[0]
|
6605 | }
|
6606 |
|
6607 | var i
|
6608 | if (length === undefined) {
|
6609 | length = 0
|
6610 | for (i = 0; i < list.length; i++) {
|
6611 | length += list[i].length
|
6612 | }
|
6613 | }
|
6614 |
|
6615 | var buf = new Buffer(length)
|
6616 | var pos = 0
|
6617 | for (i = 0; i < list.length; i++) {
|
6618 | var item = list[i]
|
6619 | item.copy(buf, pos)
|
6620 | pos += item.length
|
6621 | }
|
6622 | return buf
|
6623 | }
|
6624 |
|
6625 | function byteLength (string, encoding) {
|
6626 | if (typeof string !== 'string') string = '' + string
|
6627 |
|
6628 | var len = string.length
|
6629 | if (len === 0) return 0
|
6630 |
|
6631 |
|
6632 | var loweredCase = false
|
6633 | for (;;) {
|
6634 | switch (encoding) {
|
6635 | case 'ascii':
|
6636 | case 'binary':
|
6637 |
|
6638 | case 'raw':
|
6639 | case 'raws':
|
6640 | return len
|
6641 | case 'utf8':
|
6642 | case 'utf-8':
|
6643 | return utf8ToBytes(string).length
|
6644 | case 'ucs2':
|
6645 | case 'ucs-2':
|
6646 | case 'utf16le':
|
6647 | case 'utf-16le':
|
6648 | return len * 2
|
6649 | case 'hex':
|
6650 | return len >>> 1
|
6651 | case 'base64':
|
6652 | return base64ToBytes(string).length
|
6653 | default:
|
6654 | if (loweredCase) return utf8ToBytes(string).length
|
6655 | encoding = ('' + encoding).toLowerCase()
|
6656 | loweredCase = true
|
6657 | }
|
6658 | }
|
6659 | }
|
6660 | Buffer.byteLength = byteLength
|
6661 |
|
6662 |
|
6663 | Buffer.prototype.length = undefined
|
6664 | Buffer.prototype.parent = undefined
|
6665 |
|
6666 | function slowToString (encoding, start, end) {
|
6667 | var loweredCase = false
|
6668 |
|
6669 | start = start | 0
|
6670 | end = end === undefined || end === Infinity ? this.length : end | 0
|
6671 |
|
6672 | if (!encoding) encoding = 'utf8'
|
6673 | if (start < 0) start = 0
|
6674 | if (end > this.length) end = this.length
|
6675 | if (end <= start) return ''
|
6676 |
|
6677 | while (true) {
|
6678 | switch (encoding) {
|
6679 | case 'hex':
|
6680 | return hexSlice(this, start, end)
|
6681 |
|
6682 | case 'utf8':
|
6683 | case 'utf-8':
|
6684 | return utf8Slice(this, start, end)
|
6685 |
|
6686 | case 'ascii':
|
6687 | return asciiSlice(this, start, end)
|
6688 |
|
6689 | case 'binary':
|
6690 | return binarySlice(this, start, end)
|
6691 |
|
6692 | case 'base64':
|
6693 | return base64Slice(this, start, end)
|
6694 |
|
6695 | case 'ucs2':
|
6696 | case 'ucs-2':
|
6697 | case 'utf16le':
|
6698 | case 'utf-16le':
|
6699 | return utf16leSlice(this, start, end)
|
6700 |
|
6701 | default:
|
6702 | if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
6703 | encoding = (encoding + '').toLowerCase()
|
6704 | loweredCase = true
|
6705 | }
|
6706 | }
|
6707 | }
|
6708 |
|
6709 | Buffer.prototype.toString = function toString () {
|
6710 | var length = this.length | 0
|
6711 | if (length === 0) return ''
|
6712 | if (arguments.length === 0) return utf8Slice(this, 0, length)
|
6713 | return slowToString.apply(this, arguments)
|
6714 | }
|
6715 |
|
6716 | Buffer.prototype.equals = function equals (b) {
|
6717 | if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
6718 | if (this === b) return true
|
6719 | return Buffer.compare(this, b) === 0
|
6720 | }
|
6721 |
|
6722 | Buffer.prototype.inspect = function inspect () {
|
6723 | var str = ''
|
6724 | var max = exports.INSPECT_MAX_BYTES
|
6725 | if (this.length > 0) {
|
6726 | str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
|
6727 | if (this.length > max) str += ' ... '
|
6728 | }
|
6729 | return '<Buffer ' + str + '>'
|
6730 | }
|
6731 |
|
6732 | Buffer.prototype.compare = function compare (b) {
|
6733 | if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
6734 | if (this === b) return 0
|
6735 | return Buffer.compare(this, b)
|
6736 | }
|
6737 |
|
6738 | Buffer.prototype.indexOf = function indexOf (val, byteOffset) {
|
6739 | if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff
|
6740 | else if (byteOffset < -0x80000000) byteOffset = -0x80000000
|
6741 | byteOffset >>= 0
|
6742 |
|
6743 | if (this.length === 0) return -1
|
6744 | if (byteOffset >= this.length) return -1
|
6745 |
|
6746 |
|
6747 | if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
|
6748 |
|
6749 | if (typeof val === 'string') {
|
6750 | if (val.length === 0) return -1
|
6751 | return String.prototype.indexOf.call(this, val, byteOffset)
|
6752 | }
|
6753 | if (Buffer.isBuffer(val)) {
|
6754 | return arrayIndexOf(this, val, byteOffset)
|
6755 | }
|
6756 | if (typeof val === 'number') {
|
6757 | if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
|
6758 | return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
|
6759 | }
|
6760 | return arrayIndexOf(this, [ val ], byteOffset)
|
6761 | }
|
6762 |
|
6763 | function arrayIndexOf (arr, val, byteOffset) {
|
6764 | var foundIndex = -1
|
6765 | for (var i = 0; byteOffset + i < arr.length; i++) {
|
6766 | if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) {
|
6767 | if (foundIndex === -1) foundIndex = i
|
6768 | if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex
|
6769 | } else {
|
6770 | foundIndex = -1
|
6771 | }
|
6772 | }
|
6773 | return -1
|
6774 | }
|
6775 |
|
6776 | throw new TypeError('val must be string, number or Buffer')
|
6777 | }
|
6778 |
|
6779 |
|
6780 | Buffer.prototype.get = function get (offset) {
|
6781 | console.log('.get() is deprecated. Access using array indexes instead.')
|
6782 | return this.readUInt8(offset)
|
6783 | }
|
6784 |
|
6785 |
|
6786 | Buffer.prototype.set = function set (v, offset) {
|
6787 | console.log('.set() is deprecated. Access using array indexes instead.')
|
6788 | return this.writeUInt8(v, offset)
|
6789 | }
|
6790 |
|
6791 | function hexWrite (buf, string, offset, length) {
|
6792 | offset = Number(offset) || 0
|
6793 | var remaining = buf.length - offset
|
6794 | if (!length) {
|
6795 | length = remaining
|
6796 | } else {
|
6797 | length = Number(length)
|
6798 | if (length > remaining) {
|
6799 | length = remaining
|
6800 | }
|
6801 | }
|
6802 |
|
6803 |
|
6804 | var strLen = string.length
|
6805 | if (strLen % 2 !== 0) throw new Error('Invalid hex string')
|
6806 |
|
6807 | if (length > strLen / 2) {
|
6808 | length = strLen / 2
|
6809 | }
|
6810 | for (var i = 0; i < length; i++) {
|
6811 | var parsed = parseInt(string.substr(i * 2, 2), 16)
|
6812 | if (isNaN(parsed)) throw new Error('Invalid hex string')
|
6813 | buf[offset + i] = parsed
|
6814 | }
|
6815 | return i
|
6816 | }
|
6817 |
|
6818 | function utf8Write (buf, string, offset, length) {
|
6819 | return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
6820 | }
|
6821 |
|
6822 | function asciiWrite (buf, string, offset, length) {
|
6823 | return blitBuffer(asciiToBytes(string), buf, offset, length)
|
6824 | }
|
6825 |
|
6826 | function binaryWrite (buf, string, offset, length) {
|
6827 | return asciiWrite(buf, string, offset, length)
|
6828 | }
|
6829 |
|
6830 | function base64Write (buf, string, offset, length) {
|
6831 | return blitBuffer(base64ToBytes(string), buf, offset, length)
|
6832 | }
|
6833 |
|
6834 | function ucs2Write (buf, string, offset, length) {
|
6835 | return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
6836 | }
|
6837 |
|
6838 | Buffer.prototype.write = function write (string, offset, length, encoding) {
|
6839 |
|
6840 | if (offset === undefined) {
|
6841 | encoding = 'utf8'
|
6842 | length = this.length
|
6843 | offset = 0
|
6844 |
|
6845 | } else if (length === undefined && typeof offset === 'string') {
|
6846 | encoding = offset
|
6847 | length = this.length
|
6848 | offset = 0
|
6849 |
|
6850 | } else if (isFinite(offset)) {
|
6851 | offset = offset | 0
|
6852 | if (isFinite(length)) {
|
6853 | length = length | 0
|
6854 | if (encoding === undefined) encoding = 'utf8'
|
6855 | } else {
|
6856 | encoding = length
|
6857 | length = undefined
|
6858 | }
|
6859 |
|
6860 | } else {
|
6861 | var swap = encoding
|
6862 | encoding = offset
|
6863 | offset = length | 0
|
6864 | length = swap
|
6865 | }
|
6866 |
|
6867 | var remaining = this.length - offset
|
6868 | if (length === undefined || length > remaining) length = remaining
|
6869 |
|
6870 | if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
6871 | throw new RangeError('attempt to write outside buffer bounds')
|
6872 | }
|
6873 |
|
6874 | if (!encoding) encoding = 'utf8'
|
6875 |
|
6876 | var loweredCase = false
|
6877 | for (;;) {
|
6878 | switch (encoding) {
|
6879 | case 'hex':
|
6880 | return hexWrite(this, string, offset, length)
|
6881 |
|
6882 | case 'utf8':
|
6883 | case 'utf-8':
|
6884 | return utf8Write(this, string, offset, length)
|
6885 |
|
6886 | case 'ascii':
|
6887 | return asciiWrite(this, string, offset, length)
|
6888 |
|
6889 | case 'binary':
|
6890 | return binaryWrite(this, string, offset, length)
|
6891 |
|
6892 | case 'base64':
|
6893 |
|
6894 | return base64Write(this, string, offset, length)
|
6895 |
|
6896 | case 'ucs2':
|
6897 | case 'ucs-2':
|
6898 | case 'utf16le':
|
6899 | case 'utf-16le':
|
6900 | return ucs2Write(this, string, offset, length)
|
6901 |
|
6902 | default:
|
6903 | if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
6904 | encoding = ('' + encoding).toLowerCase()
|
6905 | loweredCase = true
|
6906 | }
|
6907 | }
|
6908 | }
|
6909 |
|
6910 | Buffer.prototype.toJSON = function toJSON () {
|
6911 | return {
|
6912 | type: 'Buffer',
|
6913 | data: Array.prototype.slice.call(this._arr || this, 0)
|
6914 | }
|
6915 | }
|
6916 |
|
6917 | function base64Slice (buf, start, end) {
|
6918 | if (start === 0 && end === buf.length) {
|
6919 | return base64.fromByteArray(buf)
|
6920 | } else {
|
6921 | return base64.fromByteArray(buf.slice(start, end))
|
6922 | }
|
6923 | }
|
6924 |
|
6925 | function utf8Slice (buf, start, end) {
|
6926 | var res = ''
|
6927 | var tmp = ''
|
6928 | end = Math.min(buf.length, end)
|
6929 |
|
6930 | for (var i = start; i < end; i++) {
|
6931 | if (buf[i] <= 0x7F) {
|
6932 | res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
|
6933 | tmp = ''
|
6934 | } else {
|
6935 | tmp += '%' + buf[i].toString(16)
|
6936 | }
|
6937 | }
|
6938 |
|
6939 | return res + decodeUtf8Char(tmp)
|
6940 | }
|
6941 |
|
6942 | function asciiSlice (buf, start, end) {
|
6943 | var ret = ''
|
6944 | end = Math.min(buf.length, end)
|
6945 |
|
6946 | for (var i = start; i < end; i++) {
|
6947 | ret += String.fromCharCode(buf[i] & 0x7F)
|
6948 | }
|
6949 | return ret
|
6950 | }
|
6951 |
|
6952 | function binarySlice (buf, start, end) {
|
6953 | var ret = ''
|
6954 | end = Math.min(buf.length, end)
|
6955 |
|
6956 | for (var i = start; i < end; i++) {
|
6957 | ret += String.fromCharCode(buf[i])
|
6958 | }
|
6959 | return ret
|
6960 | }
|
6961 |
|
6962 | function hexSlice (buf, start, end) {
|
6963 | var len = buf.length
|
6964 |
|
6965 | if (!start || start < 0) start = 0
|
6966 | if (!end || end < 0 || end > len) end = len
|
6967 |
|
6968 | var out = ''
|
6969 | for (var i = start; i < end; i++) {
|
6970 | out += toHex(buf[i])
|
6971 | }
|
6972 | return out
|
6973 | }
|
6974 |
|
6975 | function utf16leSlice (buf, start, end) {
|
6976 | var bytes = buf.slice(start, end)
|
6977 | var res = ''
|
6978 | for (var i = 0; i < bytes.length; i += 2) {
|
6979 | res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
|
6980 | }
|
6981 | return res
|
6982 | }
|
6983 |
|
6984 | Buffer.prototype.slice = function slice (start, end) {
|
6985 | var len = this.length
|
6986 | start = ~~start
|
6987 | end = end === undefined ? len : ~~end
|
6988 |
|
6989 | if (start < 0) {
|
6990 | start += len
|
6991 | if (start < 0) start = 0
|
6992 | } else if (start > len) {
|
6993 | start = len
|
6994 | }
|
6995 |
|
6996 | if (end < 0) {
|
6997 | end += len
|
6998 | if (end < 0) end = 0
|
6999 | } else if (end > len) {
|
7000 | end = len
|
7001 | }
|
7002 |
|
7003 | if (end < start) end = start
|
7004 |
|
7005 | var newBuf
|
7006 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
7007 | newBuf = Buffer._augment(this.subarray(start, end))
|
7008 | } else {
|
7009 | var sliceLen = end - start
|
7010 | newBuf = new Buffer(sliceLen, undefined)
|
7011 | for (var i = 0; i < sliceLen; i++) {
|
7012 | newBuf[i] = this[i + start]
|
7013 | }
|
7014 | }
|
7015 |
|
7016 | if (newBuf.length) newBuf.parent = this.parent || this
|
7017 |
|
7018 | return newBuf
|
7019 | }
|
7020 |
|
7021 |
|
7022 |
|
7023 |
|
7024 | function checkOffset (offset, ext, length) {
|
7025 | if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
7026 | if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
7027 | }
|
7028 |
|
7029 | Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
7030 | offset = offset | 0
|
7031 | byteLength = byteLength | 0
|
7032 | if (!noAssert) checkOffset(offset, byteLength, this.length)
|
7033 |
|
7034 | var val = this[offset]
|
7035 | var mul = 1
|
7036 | var i = 0
|
7037 | while (++i < byteLength && (mul *= 0x100)) {
|
7038 | val += this[offset + i] * mul
|
7039 | }
|
7040 |
|
7041 | return val
|
7042 | }
|
7043 |
|
7044 | Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
7045 | offset = offset | 0
|
7046 | byteLength = byteLength | 0
|
7047 | if (!noAssert) {
|
7048 | checkOffset(offset, byteLength, this.length)
|
7049 | }
|
7050 |
|
7051 | var val = this[offset + --byteLength]
|
7052 | var mul = 1
|
7053 | while (byteLength > 0 && (mul *= 0x100)) {
|
7054 | val += this[offset + --byteLength] * mul
|
7055 | }
|
7056 |
|
7057 | return val
|
7058 | }
|
7059 |
|
7060 | Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
7061 | if (!noAssert) checkOffset(offset, 1, this.length)
|
7062 | return this[offset]
|
7063 | }
|
7064 |
|
7065 | Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
7066 | if (!noAssert) checkOffset(offset, 2, this.length)
|
7067 | return this[offset] | (this[offset + 1] << 8)
|
7068 | }
|
7069 |
|
7070 | Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
7071 | if (!noAssert) checkOffset(offset, 2, this.length)
|
7072 | return (this[offset] << 8) | this[offset + 1]
|
7073 | }
|
7074 |
|
7075 | Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
7076 | if (!noAssert) checkOffset(offset, 4, this.length)
|
7077 |
|
7078 | return ((this[offset]) |
|
7079 | (this[offset + 1] << 8) |
|
7080 | (this[offset + 2] << 16)) +
|
7081 | (this[offset + 3] * 0x1000000)
|
7082 | }
|
7083 |
|
7084 | Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
7085 | if (!noAssert) checkOffset(offset, 4, this.length)
|
7086 |
|
7087 | return (this[offset] * 0x1000000) +
|
7088 | ((this[offset + 1] << 16) |
|
7089 | (this[offset + 2] << 8) |
|
7090 | this[offset + 3])
|
7091 | }
|
7092 |
|
7093 | Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
7094 | offset = offset | 0
|
7095 | byteLength = byteLength | 0
|
7096 | if (!noAssert) checkOffset(offset, byteLength, this.length)
|
7097 |
|
7098 | var val = this[offset]
|
7099 | var mul = 1
|
7100 | var i = 0
|
7101 | while (++i < byteLength && (mul *= 0x100)) {
|
7102 | val += this[offset + i] * mul
|
7103 | }
|
7104 | mul *= 0x80
|
7105 |
|
7106 | if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
7107 |
|
7108 | return val
|
7109 | }
|
7110 |
|
7111 | Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
7112 | offset = offset | 0
|
7113 | byteLength = byteLength | 0
|
7114 | if (!noAssert) checkOffset(offset, byteLength, this.length)
|
7115 |
|
7116 | var i = byteLength
|
7117 | var mul = 1
|
7118 | var val = this[offset + --i]
|
7119 | while (i > 0 && (mul *= 0x100)) {
|
7120 | val += this[offset + --i] * mul
|
7121 | }
|
7122 | mul *= 0x80
|
7123 |
|
7124 | if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
7125 |
|
7126 | return val
|
7127 | }
|
7128 |
|
7129 | Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
7130 | if (!noAssert) checkOffset(offset, 1, this.length)
|
7131 | if (!(this[offset] & 0x80)) return (this[offset])
|
7132 | return ((0xff - this[offset] + 1) * -1)
|
7133 | }
|
7134 |
|
7135 | Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
7136 | if (!noAssert) checkOffset(offset, 2, this.length)
|
7137 | var val = this[offset] | (this[offset + 1] << 8)
|
7138 | return (val & 0x8000) ? val | 0xFFFF0000 : val
|
7139 | }
|
7140 |
|
7141 | Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
7142 | if (!noAssert) checkOffset(offset, 2, this.length)
|
7143 | var val = this[offset + 1] | (this[offset] << 8)
|
7144 | return (val & 0x8000) ? val | 0xFFFF0000 : val
|
7145 | }
|
7146 |
|
7147 | Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
7148 | if (!noAssert) checkOffset(offset, 4, this.length)
|
7149 |
|
7150 | return (this[offset]) |
|
7151 | (this[offset + 1] << 8) |
|
7152 | (this[offset + 2] << 16) |
|
7153 | (this[offset + 3] << 24)
|
7154 | }
|
7155 |
|
7156 | Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
7157 | if (!noAssert) checkOffset(offset, 4, this.length)
|
7158 |
|
7159 | return (this[offset] << 24) |
|
7160 | (this[offset + 1] << 16) |
|
7161 | (this[offset + 2] << 8) |
|
7162 | (this[offset + 3])
|
7163 | }
|
7164 |
|
7165 | Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
7166 | if (!noAssert) checkOffset(offset, 4, this.length)
|
7167 | return ieee754.read(this, offset, true, 23, 4)
|
7168 | }
|
7169 |
|
7170 | Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
7171 | if (!noAssert) checkOffset(offset, 4, this.length)
|
7172 | return ieee754.read(this, offset, false, 23, 4)
|
7173 | }
|
7174 |
|
7175 | Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
7176 | if (!noAssert) checkOffset(offset, 8, this.length)
|
7177 | return ieee754.read(this, offset, true, 52, 8)
|
7178 | }
|
7179 |
|
7180 | Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
7181 | if (!noAssert) checkOffset(offset, 8, this.length)
|
7182 | return ieee754.read(this, offset, false, 52, 8)
|
7183 | }
|
7184 |
|
7185 | function checkInt (buf, value, offset, ext, max, min) {
|
7186 | if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
|
7187 | if (value > max || value < min) throw new RangeError('value is out of bounds')
|
7188 | if (offset + ext > buf.length) throw new RangeError('index out of range')
|
7189 | }
|
7190 |
|
7191 | Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
7192 | value = +value
|
7193 | offset = offset | 0
|
7194 | byteLength = byteLength | 0
|
7195 | if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
|
7196 |
|
7197 | var mul = 1
|
7198 | var i = 0
|
7199 | this[offset] = value & 0xFF
|
7200 | while (++i < byteLength && (mul *= 0x100)) {
|
7201 | this[offset + i] = (value / mul) & 0xFF
|
7202 | }
|
7203 |
|
7204 | return offset + byteLength
|
7205 | }
|
7206 |
|
7207 | Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
7208 | value = +value
|
7209 | offset = offset | 0
|
7210 | byteLength = byteLength | 0
|
7211 | if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
|
7212 |
|
7213 | var i = byteLength - 1
|
7214 | var mul = 1
|
7215 | this[offset + i] = value & 0xFF
|
7216 | while (--i >= 0 && (mul *= 0x100)) {
|
7217 | this[offset + i] = (value / mul) & 0xFF
|
7218 | }
|
7219 |
|
7220 | return offset + byteLength
|
7221 | }
|
7222 |
|
7223 | Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
7224 | value = +value
|
7225 | offset = offset | 0
|
7226 | if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
|
7227 | if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
7228 | this[offset] = value
|
7229 | return offset + 1
|
7230 | }
|
7231 |
|
7232 | function objectWriteUInt16 (buf, value, offset, littleEndian) {
|
7233 | if (value < 0) value = 0xffff + value + 1
|
7234 | for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
|
7235 | buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
|
7236 | (littleEndian ? i : 1 - i) * 8
|
7237 | }
|
7238 | }
|
7239 |
|
7240 | Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
7241 | value = +value
|
7242 | offset = offset | 0
|
7243 | if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
7244 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
7245 | this[offset] = value
|
7246 | this[offset + 1] = (value >>> 8)
|
7247 | } else {
|
7248 | objectWriteUInt16(this, value, offset, true)
|
7249 | }
|
7250 | return offset + 2
|
7251 | }
|
7252 |
|
7253 | Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
7254 | value = +value
|
7255 | offset = offset | 0
|
7256 | if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
7257 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
7258 | this[offset] = (value >>> 8)
|
7259 | this[offset + 1] = value
|
7260 | } else {
|
7261 | objectWriteUInt16(this, value, offset, false)
|
7262 | }
|
7263 | return offset + 2
|
7264 | }
|
7265 |
|
7266 | function objectWriteUInt32 (buf, value, offset, littleEndian) {
|
7267 | if (value < 0) value = 0xffffffff + value + 1
|
7268 | for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
|
7269 | buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
|
7270 | }
|
7271 | }
|
7272 |
|
7273 | Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
7274 | value = +value
|
7275 | offset = offset | 0
|
7276 | if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
7277 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
7278 | this[offset + 3] = (value >>> 24)
|
7279 | this[offset + 2] = (value >>> 16)
|
7280 | this[offset + 1] = (value >>> 8)
|
7281 | this[offset] = value
|
7282 | } else {
|
7283 | objectWriteUInt32(this, value, offset, true)
|
7284 | }
|
7285 | return offset + 4
|
7286 | }
|
7287 |
|
7288 | Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
7289 | value = +value
|
7290 | offset = offset | 0
|
7291 | if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
7292 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
7293 | this[offset] = (value >>> 24)
|
7294 | this[offset + 1] = (value >>> 16)
|
7295 | this[offset + 2] = (value >>> 8)
|
7296 | this[offset + 3] = value
|
7297 | } else {
|
7298 | objectWriteUInt32(this, value, offset, false)
|
7299 | }
|
7300 | return offset + 4
|
7301 | }
|
7302 |
|
7303 | Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
7304 | value = +value
|
7305 | offset = offset | 0
|
7306 | if (!noAssert) {
|
7307 | var limit = Math.pow(2, 8 * byteLength - 1)
|
7308 |
|
7309 | checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
7310 | }
|
7311 |
|
7312 | var i = 0
|
7313 | var mul = 1
|
7314 | var sub = value < 0 ? 1 : 0
|
7315 | this[offset] = value & 0xFF
|
7316 | while (++i < byteLength && (mul *= 0x100)) {
|
7317 | this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
7318 | }
|
7319 |
|
7320 | return offset + byteLength
|
7321 | }
|
7322 |
|
7323 | Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
7324 | value = +value
|
7325 | offset = offset | 0
|
7326 | if (!noAssert) {
|
7327 | var limit = Math.pow(2, 8 * byteLength - 1)
|
7328 |
|
7329 | checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
7330 | }
|
7331 |
|
7332 | var i = byteLength - 1
|
7333 | var mul = 1
|
7334 | var sub = value < 0 ? 1 : 0
|
7335 | this[offset + i] = value & 0xFF
|
7336 | while (--i >= 0 && (mul *= 0x100)) {
|
7337 | this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
7338 | }
|
7339 |
|
7340 | return offset + byteLength
|
7341 | }
|
7342 |
|
7343 | Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
7344 | value = +value
|
7345 | offset = offset | 0
|
7346 | if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
|
7347 | if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
7348 | if (value < 0) value = 0xff + value + 1
|
7349 | this[offset] = value
|
7350 | return offset + 1
|
7351 | }
|
7352 |
|
7353 | Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
7354 | value = +value
|
7355 | offset = offset | 0
|
7356 | if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
7357 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
7358 | this[offset] = value
|
7359 | this[offset + 1] = (value >>> 8)
|
7360 | } else {
|
7361 | objectWriteUInt16(this, value, offset, true)
|
7362 | }
|
7363 | return offset + 2
|
7364 | }
|
7365 |
|
7366 | Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
7367 | value = +value
|
7368 | offset = offset | 0
|
7369 | if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
7370 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
7371 | this[offset] = (value >>> 8)
|
7372 | this[offset + 1] = value
|
7373 | } else {
|
7374 | objectWriteUInt16(this, value, offset, false)
|
7375 | }
|
7376 | return offset + 2
|
7377 | }
|
7378 |
|
7379 | Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
7380 | value = +value
|
7381 | offset = offset | 0
|
7382 | if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
7383 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
7384 | this[offset] = value
|
7385 | this[offset + 1] = (value >>> 8)
|
7386 | this[offset + 2] = (value >>> 16)
|
7387 | this[offset + 3] = (value >>> 24)
|
7388 | } else {
|
7389 | objectWriteUInt32(this, value, offset, true)
|
7390 | }
|
7391 | return offset + 4
|
7392 | }
|
7393 |
|
7394 | Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
7395 | value = +value
|
7396 | offset = offset | 0
|
7397 | if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
7398 | if (value < 0) value = 0xffffffff + value + 1
|
7399 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
7400 | this[offset] = (value >>> 24)
|
7401 | this[offset + 1] = (value >>> 16)
|
7402 | this[offset + 2] = (value >>> 8)
|
7403 | this[offset + 3] = value
|
7404 | } else {
|
7405 | objectWriteUInt32(this, value, offset, false)
|
7406 | }
|
7407 | return offset + 4
|
7408 | }
|
7409 |
|
7410 | function checkIEEE754 (buf, value, offset, ext, max, min) {
|
7411 | if (value > max || value < min) throw new RangeError('value is out of bounds')
|
7412 | if (offset + ext > buf.length) throw new RangeError('index out of range')
|
7413 | if (offset < 0) throw new RangeError('index out of range')
|
7414 | }
|
7415 |
|
7416 | function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
7417 | if (!noAssert) {
|
7418 | checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
7419 | }
|
7420 | ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
7421 | return offset + 4
|
7422 | }
|
7423 |
|
7424 | Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
7425 | return writeFloat(this, value, offset, true, noAssert)
|
7426 | }
|
7427 |
|
7428 | Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
7429 | return writeFloat(this, value, offset, false, noAssert)
|
7430 | }
|
7431 |
|
7432 | function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
7433 | if (!noAssert) {
|
7434 | checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
7435 | }
|
7436 | ieee754.write(buf, value, offset, littleEndian, 52, 8)
|
7437 | return offset + 8
|
7438 | }
|
7439 |
|
7440 | Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
7441 | return writeDouble(this, value, offset, true, noAssert)
|
7442 | }
|
7443 |
|
7444 | Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
7445 | return writeDouble(this, value, offset, false, noAssert)
|
7446 | }
|
7447 |
|
7448 |
|
7449 | Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
7450 | if (!start) start = 0
|
7451 | if (!end && end !== 0) end = this.length
|
7452 | if (targetStart >= target.length) targetStart = target.length
|
7453 | if (!targetStart) targetStart = 0
|
7454 | if (end > 0 && end < start) end = start
|
7455 |
|
7456 |
|
7457 | if (end === start) return 0
|
7458 | if (target.length === 0 || this.length === 0) return 0
|
7459 |
|
7460 |
|
7461 | if (targetStart < 0) {
|
7462 | throw new RangeError('targetStart out of bounds')
|
7463 | }
|
7464 | if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
|
7465 | if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
7466 |
|
7467 |
|
7468 | if (end > this.length) end = this.length
|
7469 | if (target.length - targetStart < end - start) {
|
7470 | end = target.length - targetStart + start
|
7471 | }
|
7472 |
|
7473 | var len = end - start
|
7474 |
|
7475 | if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
|
7476 | for (var i = 0; i < len; i++) {
|
7477 | target[i + targetStart] = this[i + start]
|
7478 | }
|
7479 | } else {
|
7480 | target._set(this.subarray(start, start + len), targetStart)
|
7481 | }
|
7482 |
|
7483 | return len
|
7484 | }
|
7485 |
|
7486 |
|
7487 | Buffer.prototype.fill = function fill (value, start, end) {
|
7488 | if (!value) value = 0
|
7489 | if (!start) start = 0
|
7490 | if (!end) end = this.length
|
7491 |
|
7492 | if (end < start) throw new RangeError('end < start')
|
7493 |
|
7494 |
|
7495 | if (end === start) return
|
7496 | if (this.length === 0) return
|
7497 |
|
7498 | if (start < 0 || start >= this.length) throw new RangeError('start out of bounds')
|
7499 | if (end < 0 || end > this.length) throw new RangeError('end out of bounds')
|
7500 |
|
7501 | var i
|
7502 | if (typeof value === 'number') {
|
7503 | for (i = start; i < end; i++) {
|
7504 | this[i] = value
|
7505 | }
|
7506 | } else {
|
7507 | var bytes = utf8ToBytes(value.toString())
|
7508 | var len = bytes.length
|
7509 | for (i = start; i < end; i++) {
|
7510 | this[i] = bytes[i % len]
|
7511 | }
|
7512 | }
|
7513 |
|
7514 | return this
|
7515 | }
|
7516 |
|
7517 |
|
7518 |
|
7519 |
|
7520 |
|
7521 | Buffer.prototype.toArrayBuffer = function toArrayBuffer () {
|
7522 | if (typeof Uint8Array !== 'undefined') {
|
7523 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
7524 | return (new Buffer(this)).buffer
|
7525 | } else {
|
7526 | var buf = new Uint8Array(this.length)
|
7527 | for (var i = 0, len = buf.length; i < len; i += 1) {
|
7528 | buf[i] = this[i]
|
7529 | }
|
7530 | return buf.buffer
|
7531 | }
|
7532 | } else {
|
7533 | throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
|
7534 | }
|
7535 | }
|
7536 |
|
7537 |
|
7538 |
|
7539 |
|
7540 | var BP = Buffer.prototype
|
7541 |
|
7542 |
|
7543 |
|
7544 |
|
7545 | Buffer._augment = function _augment (arr) {
|
7546 | arr.constructor = Buffer
|
7547 | arr._isBuffer = true
|
7548 |
|
7549 |
|
7550 | arr._set = arr.set
|
7551 |
|
7552 |
|
7553 | arr.get = BP.get
|
7554 | arr.set = BP.set
|
7555 |
|
7556 | arr.write = BP.write
|
7557 | arr.toString = BP.toString
|
7558 | arr.toLocaleString = BP.toString
|
7559 | arr.toJSON = BP.toJSON
|
7560 | arr.equals = BP.equals
|
7561 | arr.compare = BP.compare
|
7562 | arr.indexOf = BP.indexOf
|
7563 | arr.copy = BP.copy
|
7564 | arr.slice = BP.slice
|
7565 | arr.readUIntLE = BP.readUIntLE
|
7566 | arr.readUIntBE = BP.readUIntBE
|
7567 | arr.readUInt8 = BP.readUInt8
|
7568 | arr.readUInt16LE = BP.readUInt16LE
|
7569 | arr.readUInt16BE = BP.readUInt16BE
|
7570 | arr.readUInt32LE = BP.readUInt32LE
|
7571 | arr.readUInt32BE = BP.readUInt32BE
|
7572 | arr.readIntLE = BP.readIntLE
|
7573 | arr.readIntBE = BP.readIntBE
|
7574 | arr.readInt8 = BP.readInt8
|
7575 | arr.readInt16LE = BP.readInt16LE
|
7576 | arr.readInt16BE = BP.readInt16BE
|
7577 | arr.readInt32LE = BP.readInt32LE
|
7578 | arr.readInt32BE = BP.readInt32BE
|
7579 | arr.readFloatLE = BP.readFloatLE
|
7580 | arr.readFloatBE = BP.readFloatBE
|
7581 | arr.readDoubleLE = BP.readDoubleLE
|
7582 | arr.readDoubleBE = BP.readDoubleBE
|
7583 | arr.writeUInt8 = BP.writeUInt8
|
7584 | arr.writeUIntLE = BP.writeUIntLE
|
7585 | arr.writeUIntBE = BP.writeUIntBE
|
7586 | arr.writeUInt16LE = BP.writeUInt16LE
|
7587 | arr.writeUInt16BE = BP.writeUInt16BE
|
7588 | arr.writeUInt32LE = BP.writeUInt32LE
|
7589 | arr.writeUInt32BE = BP.writeUInt32BE
|
7590 | arr.writeIntLE = BP.writeIntLE
|
7591 | arr.writeIntBE = BP.writeIntBE
|
7592 | arr.writeInt8 = BP.writeInt8
|
7593 | arr.writeInt16LE = BP.writeInt16LE
|
7594 | arr.writeInt16BE = BP.writeInt16BE
|
7595 | arr.writeInt32LE = BP.writeInt32LE
|
7596 | arr.writeInt32BE = BP.writeInt32BE
|
7597 | arr.writeFloatLE = BP.writeFloatLE
|
7598 | arr.writeFloatBE = BP.writeFloatBE
|
7599 | arr.writeDoubleLE = BP.writeDoubleLE
|
7600 | arr.writeDoubleBE = BP.writeDoubleBE
|
7601 | arr.fill = BP.fill
|
7602 | arr.inspect = BP.inspect
|
7603 | arr.toArrayBuffer = BP.toArrayBuffer
|
7604 |
|
7605 | return arr
|
7606 | }
|
7607 |
|
7608 | var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g
|
7609 |
|
7610 | function base64clean (str) {
|
7611 |
|
7612 | str = stringtrim(str).replace(INVALID_BASE64_RE, '')
|
7613 |
|
7614 | if (str.length < 2) return ''
|
7615 |
|
7616 | while (str.length % 4 !== 0) {
|
7617 | str = str + '='
|
7618 | }
|
7619 | return str
|
7620 | }
|
7621 |
|
7622 | function stringtrim (str) {
|
7623 | if (str.trim) return str.trim()
|
7624 | return str.replace(/^\s+|\s+$/g, '')
|
7625 | }
|
7626 |
|
7627 | function toHex (n) {
|
7628 | if (n < 16) return '0' + n.toString(16)
|
7629 | return n.toString(16)
|
7630 | }
|
7631 |
|
7632 | function utf8ToBytes (string, units) {
|
7633 | units = units || Infinity
|
7634 | var codePoint
|
7635 | var length = string.length
|
7636 | var leadSurrogate = null
|
7637 | var bytes = []
|
7638 | var i = 0
|
7639 |
|
7640 | for (; i < length; i++) {
|
7641 | codePoint = string.charCodeAt(i)
|
7642 |
|
7643 |
|
7644 | if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
7645 |
|
7646 | if (leadSurrogate) {
|
7647 |
|
7648 | if (codePoint < 0xDC00) {
|
7649 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
7650 | leadSurrogate = codePoint
|
7651 | continue
|
7652 | } else {
|
7653 |
|
7654 | codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000
|
7655 | leadSurrogate = null
|
7656 | }
|
7657 | } else {
|
7658 |
|
7659 |
|
7660 | if (codePoint > 0xDBFF) {
|
7661 |
|
7662 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
7663 | continue
|
7664 | } else if (i + 1 === length) {
|
7665 |
|
7666 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
7667 | continue
|
7668 | } else {
|
7669 |
|
7670 | leadSurrogate = codePoint
|
7671 | continue
|
7672 | }
|
7673 | }
|
7674 | } else if (leadSurrogate) {
|
7675 |
|
7676 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
7677 | leadSurrogate = null
|
7678 | }
|
7679 |
|
7680 |
|
7681 | if (codePoint < 0x80) {
|
7682 | if ((units -= 1) < 0) break
|
7683 | bytes.push(codePoint)
|
7684 | } else if (codePoint < 0x800) {
|
7685 | if ((units -= 2) < 0) break
|
7686 | bytes.push(
|
7687 | codePoint >> 0x6 | 0xC0,
|
7688 | codePoint & 0x3F | 0x80
|
7689 | )
|
7690 | } else if (codePoint < 0x10000) {
|
7691 | if ((units -= 3) < 0) break
|
7692 | bytes.push(
|
7693 | codePoint >> 0xC | 0xE0,
|
7694 | codePoint >> 0x6 & 0x3F | 0x80,
|
7695 | codePoint & 0x3F | 0x80
|
7696 | )
|
7697 | } else if (codePoint < 0x200000) {
|
7698 | if ((units -= 4) < 0) break
|
7699 | bytes.push(
|
7700 | codePoint >> 0x12 | 0xF0,
|
7701 | codePoint >> 0xC & 0x3F | 0x80,
|
7702 | codePoint >> 0x6 & 0x3F | 0x80,
|
7703 | codePoint & 0x3F | 0x80
|
7704 | )
|
7705 | } else {
|
7706 | throw new Error('Invalid code point')
|
7707 | }
|
7708 | }
|
7709 |
|
7710 | return bytes
|
7711 | }
|
7712 |
|
7713 | function asciiToBytes (str) {
|
7714 | var byteArray = []
|
7715 | for (var i = 0; i < str.length; i++) {
|
7716 |
|
7717 | byteArray.push(str.charCodeAt(i) & 0xFF)
|
7718 | }
|
7719 | return byteArray
|
7720 | }
|
7721 |
|
7722 | function utf16leToBytes (str, units) {
|
7723 | var c, hi, lo
|
7724 | var byteArray = []
|
7725 | for (var i = 0; i < str.length; i++) {
|
7726 | if ((units -= 2) < 0) break
|
7727 |
|
7728 | c = str.charCodeAt(i)
|
7729 | hi = c >> 8
|
7730 | lo = c % 256
|
7731 | byteArray.push(lo)
|
7732 | byteArray.push(hi)
|
7733 | }
|
7734 |
|
7735 | return byteArray
|
7736 | }
|
7737 |
|
7738 | function base64ToBytes (str) {
|
7739 | return base64.toByteArray(base64clean(str))
|
7740 | }
|
7741 |
|
7742 | function blitBuffer (src, dst, offset, length) {
|
7743 | for (var i = 0; i < length; i++) {
|
7744 | if ((i + offset >= dst.length) || (i >= src.length)) break
|
7745 | dst[i + offset] = src[i]
|
7746 | }
|
7747 | return i
|
7748 | }
|
7749 |
|
7750 | function decodeUtf8Char (str) {
|
7751 | try {
|
7752 | return decodeURIComponent(str)
|
7753 | } catch (err) {
|
7754 | return String.fromCharCode(0xFFFD)
|
7755 | }
|
7756 | }
|
7757 |
|
7758 | },{"base64-js":"/www/ROLLUP/rollup/node_modules/gobble-browserify/node_modules/browserify/node_modules/buffer/node_modules/base64-js/lib/b64.js","ieee754":"/www/ROLLUP/rollup/node_modules/gobble-browserify/node_modules/browserify/node_modules/buffer/node_modules/ieee754/index.js","is-array":"/www/ROLLUP/rollup/node_modules/gobble-browserify/node_modules/browserify/node_modules/buffer/node_modules/is-array/index.js"}],"/www/ROLLUP/rollup/node_modules/gobble-browserify/node_modules/browserify/node_modules/buffer/node_modules/base64-js/lib/b64.js":[function(require,module,exports){
|
7759 | var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
7760 |
|
7761 | ;(function (exports) {
|
7762 | 'use strict';
|
7763 |
|
7764 | var Arr = (typeof Uint8Array !== 'undefined')
|
7765 | ? Uint8Array
|
7766 | : Array
|
7767 |
|
7768 | var PLUS = '+'.charCodeAt(0)
|
7769 | var SLASH = '/'.charCodeAt(0)
|
7770 | var NUMBER = '0'.charCodeAt(0)
|
7771 | var LOWER = 'a'.charCodeAt(0)
|
7772 | var UPPER = 'A'.charCodeAt(0)
|
7773 | var PLUS_URL_SAFE = '-'.charCodeAt(0)
|
7774 | var SLASH_URL_SAFE = '_'.charCodeAt(0)
|
7775 |
|
7776 | function decode (elt) {
|
7777 | var code = elt.charCodeAt(0)
|
7778 | if (code === PLUS ||
|
7779 | code === PLUS_URL_SAFE)
|
7780 | return 62
|
7781 | if (code === SLASH ||
|
7782 | code === SLASH_URL_SAFE)
|
7783 | return 63
|
7784 | if (code < NUMBER)
|
7785 | return -1
|
7786 | if (code < NUMBER + 10)
|
7787 | return code - NUMBER + 26 + 26
|
7788 | if (code < UPPER + 26)
|
7789 | return code - UPPER
|
7790 | if (code < LOWER + 26)
|
7791 | return code - LOWER + 26
|
7792 | }
|
7793 |
|
7794 | function b64ToByteArray (b64) {
|
7795 | var i, j, l, tmp, placeHolders, arr
|
7796 |
|
7797 | if (b64.length % 4 > 0) {
|
7798 | throw new Error('Invalid string. Length must be a multiple of 4')
|
7799 | }
|
7800 |
|
7801 |
|
7802 |
|
7803 |
|
7804 |
|
7805 |
|
7806 | var len = b64.length
|
7807 | placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
|
7808 |
|
7809 |
|
7810 | arr = new Arr(b64.length * 3 / 4 - placeHolders)
|
7811 |
|
7812 |
|
7813 | l = placeHolders > 0 ? b64.length - 4 : b64.length
|
7814 |
|
7815 | var L = 0
|
7816 |
|
7817 | function push (v) {
|
7818 | arr[L++] = v
|
7819 | }
|
7820 |
|
7821 | for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
7822 | tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
|
7823 | push((tmp & 0xFF0000) >> 16)
|
7824 | push((tmp & 0xFF00) >> 8)
|
7825 | push(tmp & 0xFF)
|
7826 | }
|
7827 |
|
7828 | if (placeHolders === 2) {
|
7829 | tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
|
7830 | push(tmp & 0xFF)
|
7831 | } else if (placeHolders === 1) {
|
7832 | tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
|
7833 | push((tmp >> 8) & 0xFF)
|
7834 | push(tmp & 0xFF)
|
7835 | }
|
7836 |
|
7837 | return arr
|
7838 | }
|
7839 |
|
7840 | function uint8ToBase64 (uint8) {
|
7841 | var i,
|
7842 | extraBytes = uint8.length % 3,
|
7843 | output = "",
|
7844 | temp, length
|
7845 |
|
7846 | function encode (num) {
|
7847 | return lookup.charAt(num)
|
7848 | }
|
7849 |
|
7850 | function tripletToBase64 (num) {
|
7851 | return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
|
7852 | }
|
7853 |
|
7854 |
|
7855 | for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
|
7856 | temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
|
7857 | output += tripletToBase64(temp)
|
7858 | }
|
7859 |
|
7860 |
|
7861 | switch (extraBytes) {
|
7862 | case 1:
|
7863 | temp = uint8[uint8.length - 1]
|
7864 | output += encode(temp >> 2)
|
7865 | output += encode((temp << 4) & 0x3F)
|
7866 | output += '=='
|
7867 | break
|
7868 | case 2:
|
7869 | temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
|
7870 | output += encode(temp >> 10)
|
7871 | output += encode((temp >> 4) & 0x3F)
|
7872 | output += encode((temp << 2) & 0x3F)
|
7873 | output += '='
|
7874 | break
|
7875 | }
|
7876 |
|
7877 | return output
|
7878 | }
|
7879 |
|
7880 | exports.toByteArray = b64ToByteArray
|
7881 | exports.fromByteArray = uint8ToBase64
|
7882 | }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
|
7883 |
|
7884 | },{}],"/www/ROLLUP/rollup/node_modules/gobble-browserify/node_modules/browserify/node_modules/buffer/node_modules/ieee754/index.js":[function(require,module,exports){
|
7885 | exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
7886 | var e, m
|
7887 | var eLen = nBytes * 8 - mLen - 1
|
7888 | var eMax = (1 << eLen) - 1
|
7889 | var eBias = eMax >> 1
|
7890 | var nBits = -7
|
7891 | var i = isLE ? (nBytes - 1) : 0
|
7892 | var d = isLE ? -1 : 1
|
7893 | var s = buffer[offset + i]
|
7894 |
|
7895 | i += d
|
7896 |
|
7897 | e = s & ((1 << (-nBits)) - 1)
|
7898 | s >>= (-nBits)
|
7899 | nBits += eLen
|
7900 | for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
|
7901 |
|
7902 | m = e & ((1 << (-nBits)) - 1)
|
7903 | e >>= (-nBits)
|
7904 | nBits += mLen
|
7905 | for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
|
7906 |
|
7907 | if (e === 0) {
|
7908 | e = 1 - eBias
|
7909 | } else if (e === eMax) {
|
7910 | return m ? NaN : ((s ? -1 : 1) * Infinity)
|
7911 | } else {
|
7912 | m = m + Math.pow(2, mLen)
|
7913 | e = e - eBias
|
7914 | }
|
7915 | return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
7916 | }
|
7917 |
|
7918 | exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
7919 | var e, m, c
|
7920 | var eLen = nBytes * 8 - mLen - 1
|
7921 | var eMax = (1 << eLen) - 1
|
7922 | var eBias = eMax >> 1
|
7923 | var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
|
7924 | var i = isLE ? 0 : (nBytes - 1)
|
7925 | var d = isLE ? 1 : -1
|
7926 | var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
|
7927 |
|
7928 | value = Math.abs(value)
|
7929 |
|
7930 | if (isNaN(value) || value === Infinity) {
|
7931 | m = isNaN(value) ? 1 : 0
|
7932 | e = eMax
|
7933 | } else {
|
7934 | e = Math.floor(Math.log(value) / Math.LN2)
|
7935 | if (value * (c = Math.pow(2, -e)) < 1) {
|
7936 | e--
|
7937 | c *= 2
|
7938 | }
|
7939 | if (e + eBias >= 1) {
|
7940 | value += rt / c
|
7941 | } else {
|
7942 | value += rt * Math.pow(2, 1 - eBias)
|
7943 | }
|
7944 | if (value * c >= 2) {
|
7945 | e++
|
7946 | c /= 2
|
7947 | }
|
7948 |
|
7949 | if (e + eBias >= eMax) {
|
7950 | m = 0
|
7951 | e = eMax
|
7952 | } else if (e + eBias >= 1) {
|
7953 | m = (value * c - 1) * Math.pow(2, mLen)
|
7954 | e = e + eBias
|
7955 | } else {
|
7956 | m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
|
7957 | e = 0
|
7958 | }
|
7959 | }
|
7960 |
|
7961 | for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
7962 |
|
7963 | e = (e << mLen) | m
|
7964 | eLen += mLen
|
7965 | for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
7966 |
|
7967 | buffer[offset + i - d] |= s * 128
|
7968 | }
|
7969 |
|
7970 | },{}],"/www/ROLLUP/rollup/node_modules/gobble-browserify/node_modules/browserify/node_modules/buffer/node_modules/is-array/index.js":[function(require,module,exports){
|
7971 |
|
7972 |
|
7973 |
|
7974 |
|
7975 |
|
7976 | var isArray = Array.isArray;
|
7977 |
|
7978 |
|
7979 |
|
7980 |
|
7981 |
|
7982 | var str = Object.prototype.toString;
|
7983 |
|
7984 |
|
7985 |
|
7986 |
|
7987 |
|
7988 |
|
7989 |
|
7990 |
|
7991 |
|
7992 |
|
7993 |
|
7994 |
|
7995 |
|
7996 |
|
7997 |
|
7998 |
|
7999 |
|
8000 |
|
8001 | module.exports = isArray || function (val) {
|
8002 | return !! val && '[object Array]' == str.call(val);
|
8003 | };
|
8004 |
|
8005 | },{}],"/www/ROLLUP/rollup/node_modules/gobble-browserify/node_modules/browserify/node_modules/process/browser.js":[function(require,module,exports){
|
8006 |
|
8007 |
|
8008 | var process = module.exports = {};
|
8009 | var queue = [];
|
8010 | var draining = false;
|
8011 | var currentQueue;
|
8012 | var queueIndex = -1;
|
8013 |
|
8014 | function cleanUpNextTick() {
|
8015 | draining = false;
|
8016 | if (currentQueue.length) {
|
8017 | queue = currentQueue.concat(queue);
|
8018 | } else {
|
8019 | queueIndex = -1;
|
8020 | }
|
8021 | if (queue.length) {
|
8022 | drainQueue();
|
8023 | }
|
8024 | }
|
8025 |
|
8026 | function drainQueue() {
|
8027 | if (draining) {
|
8028 | return;
|
8029 | }
|
8030 | var timeout = setTimeout(cleanUpNextTick);
|
8031 | draining = true;
|
8032 |
|
8033 | var len = queue.length;
|
8034 | while(len) {
|
8035 | currentQueue = queue;
|
8036 | queue = [];
|
8037 | while (++queueIndex < len) {
|
8038 | currentQueue[queueIndex].run();
|
8039 | }
|
8040 | queueIndex = -1;
|
8041 | len = queue.length;
|
8042 | }
|
8043 | currentQueue = null;
|
8044 | draining = false;
|
8045 | clearTimeout(timeout);
|
8046 | }
|
8047 |
|
8048 | process.nextTick = function (fun) {
|
8049 | var args = new Array(arguments.length - 1);
|
8050 | if (arguments.length > 1) {
|
8051 | for (var i = 1; i < arguments.length; i++) {
|
8052 | args[i - 1] = arguments[i];
|
8053 | }
|
8054 | }
|
8055 | queue.push(new Item(fun, args));
|
8056 | if (queue.length === 1 && !draining) {
|
8057 | setTimeout(drainQueue, 0);
|
8058 | }
|
8059 | };
|
8060 |
|
8061 |
|
8062 | function Item(fun, array) {
|
8063 | this.fun = fun;
|
8064 | this.array = array;
|
8065 | }
|
8066 | Item.prototype.run = function () {
|
8067 | this.fun.apply(null, this.array);
|
8068 | };
|
8069 | process.title = 'browser';
|
8070 | process.browser = true;
|
8071 | process.env = {};
|
8072 | process.argv = [];
|
8073 | process.version = '';
|
8074 | process.versions = {};
|
8075 |
|
8076 | function noop() {}
|
8077 |
|
8078 | process.on = noop;
|
8079 | process.addListener = noop;
|
8080 | process.once = noop;
|
8081 | process.off = noop;
|
8082 | process.removeListener = noop;
|
8083 | process.removeAllListeners = noop;
|
8084 | process.emit = noop;
|
8085 |
|
8086 | process.binding = function (name) {
|
8087 | throw new Error('process.binding is not supported');
|
8088 | };
|
8089 |
|
8090 |
|
8091 | process.cwd = function () { return '/' };
|
8092 | process.chdir = function (dir) {
|
8093 | throw new Error('process.chdir is not supported');
|
8094 | };
|
8095 | process.umask = function() { return 0; };
|
8096 |
|
8097 | },{}],"/www/ROLLUP/rollup/node_modules/magic-string/dist/magic-string.js":[function(require,module,exports){
|
8098 | (function (Buffer){
|
8099 | (function (global, factory) {
|
8100 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('vlq')) :
|
8101 | typeof define === 'function' && define.amd ? define(['vlq'], factory) :
|
8102 | global.MagicString = factory(vlq);
|
8103 | }(this, function (vlq) { 'use strict';
|
8104 |
|
8105 | function getRelativePath(from, to) {
|
8106 | var fromParts = from.split(/[\/\\]/);
|
8107 | var toParts = to.split(/[\/\\]/);
|
8108 |
|
8109 | fromParts.pop();
|
8110 |
|
8111 | while (fromParts[0] === toParts[0]) {
|
8112 | fromParts.shift();
|
8113 | toParts.shift();
|
8114 | }
|
8115 |
|
8116 | if (fromParts.length) {
|
8117 | var i = fromParts.length;
|
8118 | while (i--) fromParts[i] = '..';
|
8119 | }
|
8120 |
|
8121 | return fromParts.concat(toParts).join('/');
|
8122 | }
|
8123 | var _btoa;
|
8124 |
|
8125 | if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
|
8126 | _btoa = window.btoa;
|
8127 | } else if (typeof Buffer === 'function') {
|
8128 | _btoa = function (str) {
|
8129 | return new Buffer(str).toString('base64');
|
8130 | };
|
8131 | } else {
|
8132 | throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
|
8133 | }
|
8134 |
|
8135 | var btoa = _btoa;
|
8136 | function __classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
8137 |
|
8138 | var SourceMap = (function () {
|
8139 | function SourceMap(properties) {
|
8140 | __classCallCheck(this, SourceMap);
|
8141 |
|
8142 | this.version = 3;
|
8143 |
|
8144 | this.file = properties.file;
|
8145 | this.sources = properties.sources;
|
8146 | this.sourcesContent = properties.sourcesContent;
|
8147 | this.names = properties.names;
|
8148 | this.mappings = properties.mappings;
|
8149 | }
|
8150 |
|
8151 | SourceMap.prototype.toString = function toString() {
|
8152 | return JSON.stringify(this);
|
8153 | };
|
8154 |
|
8155 | SourceMap.prototype.toUrl = function toUrl() {
|
8156 | return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
|
8157 | };
|
8158 |
|
8159 | return SourceMap;
|
8160 | })();
|
8161 |
|
8162 | function getSemis(str) {
|
8163 | return new Array(str.split('\n').length).join(';');
|
8164 | }
|
8165 |
|
8166 | function adjust(mappings, start, end, d) {
|
8167 | var i = end;
|
8168 |
|
8169 | if (!d) return;
|
8170 |
|
8171 | while (i-- > start) {
|
8172 | if (~mappings[i]) {
|
8173 | mappings[i] += d;
|
8174 | }
|
8175 | }
|
8176 | }
|
8177 |
|
8178 | var warned = false;
|
8179 |
|
8180 | function blank(mappings, start, i) {
|
8181 | while (i-- > start) {
|
8182 | mappings[i] = -1;
|
8183 | }
|
8184 | }
|
8185 |
|
8186 | function reverse(mappings, i) {
|
8187 | var result, location;
|
8188 |
|
8189 | result = new Uint32Array(i);
|
8190 |
|
8191 | while (i--) {
|
8192 | result[i] = -1;
|
8193 | }
|
8194 |
|
8195 | i = mappings.length;
|
8196 | while (i--) {
|
8197 | location = mappings[i];
|
8198 |
|
8199 | if (~location) {
|
8200 | result[location] = i;
|
8201 | }
|
8202 | }
|
8203 |
|
8204 | return result;
|
8205 | }
|
8206 |
|
8207 | function getLocation(locations, char) {
|
8208 | var i;
|
8209 |
|
8210 | i = locations.length;
|
8211 | while (i--) {
|
8212 | if (locations[i] <= char) {
|
8213 | return {
|
8214 | line: i,
|
8215 | column: char - locations[i]
|
8216 | };
|
8217 | }
|
8218 | }
|
8219 |
|
8220 | throw new Error('Character out of bounds');
|
8221 | }
|
8222 |
|
8223 | function invert(str, mappings) {
|
8224 | var inverted = new Uint32Array(str.length),
|
8225 | i;
|
8226 |
|
8227 |
|
8228 | i = str.length;
|
8229 | while (i--) {
|
8230 | inverted[i] = -1;
|
8231 | }
|
8232 |
|
8233 |
|
8234 | i = mappings.length;
|
8235 | while (i--) {
|
8236 | if (~mappings[i]) {
|
8237 | inverted[mappings[i]] = i;
|
8238 | }
|
8239 | }
|
8240 |
|
8241 | return inverted;
|
8242 | }
|
8243 |
|
8244 | function encodeMappings(original, str, mappings, hires, sourcemapLocations, sourceIndex, offsets) {
|
8245 |
|
8246 | var lineStart = 0;
|
8247 | var locations = original.split('\n').map(function (line) {
|
8248 | var start = lineStart;
|
8249 | lineStart += line.length + 1;
|
8250 |
|
8251 | return start;
|
8252 | });
|
8253 |
|
8254 | var inverseMappings = invert(str, mappings);
|
8255 |
|
8256 | var charOffset = 0;
|
8257 | var lines = str.split('\n').map(function (line) {
|
8258 | var segments = [];
|
8259 |
|
8260 | var char = undefined;
|
8261 | var origin = undefined;
|
8262 | var lastOrigin = undefined;
|
8263 | var location = undefined;
|
8264 |
|
8265 | var i = undefined;
|
8266 |
|
8267 | var len = line.length;
|
8268 | for (i = 0; i < len; i += 1) {
|
8269 | char = i + charOffset;
|
8270 | origin = inverseMappings[char];
|
8271 |
|
8272 | if (! ~origin) {
|
8273 | if (! ~lastOrigin) {} else {
|
8274 | segments.push({
|
8275 | generatedCodeColumn: i,
|
8276 | sourceIndex: sourceIndex,
|
8277 | sourceCodeLine: 0,
|
8278 | sourceCodeColumn: 0
|
8279 | });
|
8280 | }
|
8281 | } else {
|
8282 | if (!hires && origin === lastOrigin + 1 && !sourcemapLocations[origin]) {} else {
|
8283 | location = getLocation(locations, origin);
|
8284 |
|
8285 | segments.push({
|
8286 | generatedCodeColumn: i,
|
8287 | sourceIndex: sourceIndex,
|
8288 | sourceCodeLine: location.line,
|
8289 | sourceCodeColumn: location.column
|
8290 | });
|
8291 | }
|
8292 | }
|
8293 |
|
8294 | lastOrigin = origin;
|
8295 | }
|
8296 |
|
8297 | charOffset += line.length + 1;
|
8298 | return segments;
|
8299 | });
|
8300 |
|
8301 | offsets = offsets || {};
|
8302 |
|
8303 | offsets.sourceIndex = offsets.sourceIndex || 0;
|
8304 | offsets.sourceCodeLine = offsets.sourceCodeLine || 0;
|
8305 | offsets.sourceCodeColumn = offsets.sourceCodeColumn || 0;
|
8306 |
|
8307 | var encoded = lines.map(function (segments) {
|
8308 | var generatedCodeColumn = 0;
|
8309 |
|
8310 | return segments.map(function (segment) {
|
8311 | var arr = [segment.generatedCodeColumn - generatedCodeColumn, segment.sourceIndex - offsets.sourceIndex, segment.sourceCodeLine - offsets.sourceCodeLine, segment.sourceCodeColumn - offsets.sourceCodeColumn];
|
8312 |
|
8313 | generatedCodeColumn = segment.generatedCodeColumn;
|
8314 | offsets.sourceIndex = segment.sourceIndex;
|
8315 | offsets.sourceCodeLine = segment.sourceCodeLine;
|
8316 | offsets.sourceCodeColumn = segment.sourceCodeColumn;
|
8317 |
|
8318 | return vlq.encode(arr);
|
8319 | }).join(',');
|
8320 | }).join(';');
|
8321 |
|
8322 | return encoded;
|
8323 | }
|
8324 |
|
8325 | function guessIndent(code) {
|
8326 | var lines = code.split('\n');
|
8327 |
|
8328 | var tabbed = lines.filter(function (line) {
|
8329 | return /^\t+/.test(line);
|
8330 | });
|
8331 | var spaced = lines.filter(function (line) {
|
8332 | return /^ {2,}/.test(line);
|
8333 | });
|
8334 |
|
8335 | if (tabbed.length === 0 && spaced.length === 0) {
|
8336 | return null;
|
8337 | }
|
8338 |
|
8339 |
|
8340 |
|
8341 |
|
8342 | if (tabbed.length >= spaced.length) {
|
8343 | return '\t';
|
8344 | }
|
8345 |
|
8346 |
|
8347 | var min = spaced.reduce(function (previous, current) {
|
8348 | var numSpaces = /^ +/.exec(current)[0].length;
|
8349 | return Math.min(numSpaces, previous);
|
8350 | }, Infinity);
|
8351 |
|
8352 | return new Array(min + 1).join(' ');
|
8353 | }
|
8354 |
|
8355 | function initMappings(i) {
|
8356 | var mappings = new Uint32Array(i);
|
8357 |
|
8358 | while (i--) {
|
8359 | mappings[i] = i;
|
8360 | }
|
8361 |
|
8362 | return mappings;
|
8363 | }
|
8364 |
|
8365 | function ___classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
8366 |
|
8367 | var MagicString = (function () {
|
8368 | function MagicString(string) {
|
8369 | var options = arguments[1] === undefined ? {} : arguments[1];
|
8370 |
|
8371 | ___classCallCheck(this, MagicString);
|
8372 |
|
8373 | this.original = this.str = string;
|
8374 | this.mappings = initMappings(string.length);
|
8375 |
|
8376 | this.filename = options.filename;
|
8377 | this.indentExclusionRanges = options.indentExclusionRanges;
|
8378 |
|
8379 | this.sourcemapLocations = {};
|
8380 |
|
8381 | this.indentStr = guessIndent(string);
|
8382 | }
|
8383 |
|
8384 | MagicString.prototype.addSourcemapLocation = function addSourcemapLocation(char) {
|
8385 | this.sourcemapLocations[char] = true;
|
8386 | };
|
8387 |
|
8388 | MagicString.prototype.append = function append(content) {
|
8389 | if (typeof content !== 'string') {
|
8390 | throw new TypeError('appended content must be a string');
|
8391 | }
|
8392 |
|
8393 | this.str += content;
|
8394 | return this;
|
8395 | };
|
8396 |
|
8397 | MagicString.prototype.clone = function clone() {
|
8398 | var clone, i;
|
8399 |
|
8400 | clone = new MagicString(this.original, { filename: this.filename });
|
8401 | clone.str = this.str;
|
8402 |
|
8403 | i = clone.mappings.length;
|
8404 | while (i--) {
|
8405 | clone.mappings[i] = this.mappings[i];
|
8406 | }
|
8407 |
|
8408 | if (this.indentExclusionRanges) {
|
8409 | clone.indentExclusionRanges = typeof this.indentExclusionRanges[0] === 'number' ? [this.indentExclusionRanges[0], this.indentExclusionRanges[1]] : this.indentExclusionRanges.map(function (_ref) {
|
8410 | var start = _ref[0];
|
8411 | var end = _ref[1];
|
8412 | return [start, end];
|
8413 | });
|
8414 | }
|
8415 |
|
8416 | Object.keys(this.sourcemapLocations).forEach(function (loc) {
|
8417 | clone.sourcemapLocations[loc] = true;
|
8418 | });
|
8419 |
|
8420 | return clone;
|
8421 | };
|
8422 |
|
8423 | MagicString.prototype.generateMap = function generateMap(options) {
|
8424 | options = options || {};
|
8425 |
|
8426 | return new SourceMap({
|
8427 | file: options.file ? options.file.split(/[\/\\]/).pop() : null,
|
8428 | sources: [options.source ? getRelativePath(options.file || '', options.source) : null],
|
8429 | sourcesContent: options.includeContent ? [this.original] : [null],
|
8430 | names: [],
|
8431 | mappings: this.getMappings(options.hires, 0)
|
8432 | });
|
8433 | };
|
8434 |
|
8435 | MagicString.prototype.getIndentString = function getIndentString() {
|
8436 | return this.indentStr === null ? '\t' : this.indentStr;
|
8437 | };
|
8438 |
|
8439 | MagicString.prototype.getMappings = function getMappings(hires, sourceIndex, offsets) {
|
8440 | return encodeMappings(this.original, this.str, this.mappings, hires, this.sourcemapLocations, sourceIndex, offsets);
|
8441 | };
|
8442 |
|
8443 | MagicString.prototype.indent = function indent(indentStr, options) {
|
8444 | var self = this,
|
8445 | mappings = this.mappings,
|
8446 | reverseMappings = reverse(mappings, this.str.length),
|
8447 | pattern = /^[^\r\n]/gm,
|
8448 | match,
|
8449 | inserts = [],
|
8450 | adjustments,
|
8451 | exclusions,
|
8452 | lastEnd,
|
8453 | i;
|
8454 |
|
8455 | if (typeof indentStr === 'object') {
|
8456 | options = indentStr;
|
8457 | indentStr = undefined;
|
8458 | }
|
8459 |
|
8460 | indentStr = indentStr !== undefined ? indentStr : this.indentStr || '\t';
|
8461 |
|
8462 | if (indentStr === '') return this;
|
8463 |
|
8464 | options = options || {};
|
8465 |
|
8466 |
|
8467 | if (options.exclude) {
|
8468 | exclusions = typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
|
8469 |
|
8470 | exclusions = exclusions.map(function (range) {
|
8471 | var rangeStart, rangeEnd;
|
8472 |
|
8473 | rangeStart = self.locate(range[0]);
|
8474 | rangeEnd = self.locate(range[1]);
|
8475 |
|
8476 | if (rangeStart === null || rangeEnd === null) {
|
8477 | throw new Error('Cannot use indices of replaced characters as exclusion ranges');
|
8478 | }
|
8479 |
|
8480 | return [rangeStart, rangeEnd];
|
8481 | });
|
8482 |
|
8483 | exclusions.sort(function (a, b) {
|
8484 | return a[0] - b[0];
|
8485 | });
|
8486 |
|
8487 |
|
8488 | lastEnd = -1;
|
8489 | exclusions.forEach(function (range) {
|
8490 | if (range[0] < lastEnd) {
|
8491 | throw new Error('Exclusion ranges cannot overlap');
|
8492 | }
|
8493 |
|
8494 | lastEnd = range[1];
|
8495 | });
|
8496 | }
|
8497 |
|
8498 | var indentStart = options.indentStart !== false;
|
8499 |
|
8500 | if (!exclusions) {
|
8501 | this.str = this.str.replace(pattern, function (match, index) {
|
8502 | if (!indentStart && index === 0) {
|
8503 | return match;
|
8504 | }
|
8505 |
|
8506 | inserts.push(index);
|
8507 | return indentStr + match;
|
8508 | });
|
8509 | } else {
|
8510 | this.str = this.str.replace(pattern, function (match, index) {
|
8511 | if (!indentStart && index === 0 || isExcluded(index - 1)) {
|
8512 | return match;
|
8513 | }
|
8514 |
|
8515 | inserts.push(index);
|
8516 | return indentStr + match;
|
8517 | });
|
8518 | }
|
8519 |
|
8520 | adjustments = inserts.map(function (index) {
|
8521 | var origin;
|
8522 |
|
8523 | do {
|
8524 | origin = reverseMappings[index++];
|
8525 | } while (! ~origin && index < self.str.length);
|
8526 |
|
8527 | return origin;
|
8528 | });
|
8529 |
|
8530 | i = adjustments.length;
|
8531 | lastEnd = this.mappings.length;
|
8532 | while (i--) {
|
8533 | adjust(self.mappings, adjustments[i], lastEnd, (i + 1) * indentStr.length);
|
8534 | lastEnd = adjustments[i];
|
8535 | }
|
8536 |
|
8537 | return this;
|
8538 |
|
8539 | function isExcluded(index) {
|
8540 | var i = exclusions.length,
|
8541 | range;
|
8542 |
|
8543 | while (i--) {
|
8544 | range = exclusions[i];
|
8545 |
|
8546 | if (range[1] < index) {
|
8547 | return false;
|
8548 | }
|
8549 |
|
8550 | if (range[0] <= index) {
|
8551 | return true;
|
8552 | }
|
8553 | }
|
8554 | }
|
8555 | };
|
8556 |
|
8557 | MagicString.prototype.insert = function insert(index, content) {
|
8558 | if (typeof content !== 'string') {
|
8559 | throw new TypeError('inserted content must be a string');
|
8560 | }
|
8561 |
|
8562 | if (index === this.original.length) {
|
8563 | this.append(content);
|
8564 | } else {
|
8565 | var mapped = this.locate(index);
|
8566 |
|
8567 | if (mapped === null) {
|
8568 | throw new Error('Cannot insert at replaced character index: ' + index);
|
8569 | }
|
8570 |
|
8571 | this.str = this.str.substr(0, mapped) + content + this.str.substr(mapped);
|
8572 | adjust(this.mappings, index, this.mappings.length, content.length);
|
8573 | }
|
8574 |
|
8575 | return this;
|
8576 | };
|
8577 |
|
8578 |
|
8579 |
|
8580 | MagicString.prototype.locate = function locate(character) {
|
8581 | var loc;
|
8582 |
|
8583 | if (character < 0 || character > this.mappings.length) {
|
8584 | throw new Error('Character is out of bounds');
|
8585 | }
|
8586 |
|
8587 | loc = this.mappings[character];
|
8588 | return ~loc ? loc : null;
|
8589 | };
|
8590 |
|
8591 | MagicString.prototype.locateOrigin = function locateOrigin(character) {
|
8592 | var i;
|
8593 |
|
8594 | if (character < 0 || character >= this.str.length) {
|
8595 | throw new Error('Character is out of bounds');
|
8596 | }
|
8597 |
|
8598 | i = this.mappings.length;
|
8599 | while (i--) {
|
8600 | if (this.mappings[i] === character) {
|
8601 | return i;
|
8602 | }
|
8603 | }
|
8604 |
|
8605 | return null;
|
8606 | };
|
8607 |
|
8608 | MagicString.prototype.overwrite = function overwrite(start, end, content) {
|
8609 | if (typeof content !== 'string') {
|
8610 | throw new TypeError('replacement content must be a string');
|
8611 | }
|
8612 |
|
8613 | var firstChar, lastChar, d;
|
8614 |
|
8615 | firstChar = this.locate(start);
|
8616 | lastChar = this.locate(end - 1);
|
8617 |
|
8618 | if (firstChar === null || lastChar === null) {
|
8619 | throw new Error('Cannot overwrite the same content twice: \'' + this.original.slice(start, end).replace(/\n/g, '\\n') + '\'');
|
8620 | }
|
8621 |
|
8622 | if (firstChar > lastChar + 1) {
|
8623 | throw new Error('BUG! First character mapped to a position after the last character: ' + '[' + start + ', ' + end + '] -> [' + firstChar + ', ' + (lastChar + 1) + ']');
|
8624 | }
|
8625 |
|
8626 | this.str = this.str.substr(0, firstChar) + content + this.str.substring(lastChar + 1);
|
8627 |
|
8628 | d = content.length - (lastChar + 1 - firstChar);
|
8629 |
|
8630 | blank(this.mappings, start, end);
|
8631 | adjust(this.mappings, end, this.mappings.length, d);
|
8632 | return this;
|
8633 | };
|
8634 |
|
8635 | MagicString.prototype.prepend = function prepend(content) {
|
8636 | this.str = content + this.str;
|
8637 | adjust(this.mappings, 0, this.mappings.length, content.length);
|
8638 | return this;
|
8639 | };
|
8640 |
|
8641 | MagicString.prototype.remove = function remove(start, end) {
|
8642 | var loc, d, i, currentStart, currentEnd;
|
8643 |
|
8644 | if (start < 0 || end > this.mappings.length) {
|
8645 | throw new Error('Character is out of bounds');
|
8646 | }
|
8647 |
|
8648 | d = 0;
|
8649 | currentStart = -1;
|
8650 | currentEnd = -1;
|
8651 | for (i = start; i < end; i += 1) {
|
8652 | loc = this.mappings[i];
|
8653 |
|
8654 | if (~loc) {
|
8655 | if (! ~currentStart) {
|
8656 | currentStart = loc;
|
8657 | }
|
8658 |
|
8659 | currentEnd = loc + 1;
|
8660 |
|
8661 | this.mappings[i] = -1;
|
8662 | d += 1;
|
8663 | }
|
8664 | }
|
8665 |
|
8666 | this.str = this.str.slice(0, currentStart) + this.str.slice(currentEnd);
|
8667 |
|
8668 | adjust(this.mappings, end, this.mappings.length, -d);
|
8669 | return this;
|
8670 | };
|
8671 |
|
8672 | MagicString.prototype.replace = function replace(start, end, content) {
|
8673 | if (!warned) {
|
8674 | console.warn('magicString.replace(...) is deprecated. Use magicString.overwrite(...) instead');
|
8675 | warned = true;
|
8676 | }
|
8677 |
|
8678 | return this.overwrite(start, end, content);
|
8679 | };
|
8680 |
|
8681 | MagicString.prototype.slice = function slice(start) {
|
8682 | var end = arguments[1] === undefined ? this.original.length : arguments[1];
|
8683 |
|
8684 | var firstChar, lastChar;
|
8685 |
|
8686 | while (start < 0) start += this.original.length;
|
8687 | while (end < 0) end += this.original.length;
|
8688 |
|
8689 | firstChar = this.locate(start);
|
8690 | lastChar = this.locate(end - 1) + 1;
|
8691 |
|
8692 | if (firstChar === null || lastChar === null) {
|
8693 | throw new Error('Cannot use replaced characters as slice anchors');
|
8694 | }
|
8695 |
|
8696 | return this.str.slice(firstChar, lastChar);
|
8697 | };
|
8698 |
|
8699 | MagicString.prototype.snip = function snip(start, end) {
|
8700 | var clone = this.clone();
|
8701 | clone.remove(0, start);
|
8702 | clone.remove(end, clone.original.length);
|
8703 |
|
8704 | return clone;
|
8705 | };
|
8706 |
|
8707 | MagicString.prototype.toString = function toString() {
|
8708 | return this.str;
|
8709 | };
|
8710 |
|
8711 | MagicString.prototype.trimLines = function trimLines() {
|
8712 | return this.trim('[\\r\\n]');
|
8713 | };
|
8714 |
|
8715 | MagicString.prototype.trim = function trim(charType) {
|
8716 | return this.trimStart(charType).trimEnd(charType);
|
8717 | };
|
8718 |
|
8719 | MagicString.prototype.trimEnd = function trimEnd(charType) {
|
8720 | var self = this;
|
8721 | var rx = new RegExp((charType || '\\s') + '+$');
|
8722 |
|
8723 | this.str = this.str.replace(rx, function (trailing, index, str) {
|
8724 | var strLength = str.length,
|
8725 | length = trailing.length,
|
8726 | i,
|
8727 | chars = [];
|
8728 |
|
8729 | i = strLength;
|
8730 | while (i-- > strLength - length) {
|
8731 | chars.push(self.locateOrigin(i));
|
8732 | }
|
8733 |
|
8734 | i = chars.length;
|
8735 | while (i--) {
|
8736 | if (chars[i] !== null) {
|
8737 | self.mappings[chars[i]] = -1;
|
8738 | }
|
8739 | }
|
8740 |
|
8741 | return '';
|
8742 | });
|
8743 |
|
8744 | return this;
|
8745 | };
|
8746 |
|
8747 | MagicString.prototype.trimStart = function trimStart(charType) {
|
8748 | var self = this;
|
8749 | var rx = new RegExp('^' + (charType || '\\s') + '+');
|
8750 |
|
8751 | this.str = this.str.replace(rx, function (leading) {
|
8752 | var length = leading.length,
|
8753 | i,
|
8754 | chars = [],
|
8755 | adjustmentStart = 0;
|
8756 |
|
8757 | i = length;
|
8758 | while (i--) {
|
8759 | chars.push(self.locateOrigin(i));
|
8760 | }
|
8761 |
|
8762 | i = chars.length;
|
8763 | while (i--) {
|
8764 | if (chars[i] !== null) {
|
8765 | self.mappings[chars[i]] = -1;
|
8766 | adjustmentStart += 1;
|
8767 | }
|
8768 | }
|
8769 |
|
8770 | adjust(self.mappings, adjustmentStart, self.mappings.length, -length);
|
8771 |
|
8772 | return '';
|
8773 | });
|
8774 |
|
8775 | return this;
|
8776 | };
|
8777 |
|
8778 | return MagicString;
|
8779 | })();
|
8780 |
|
8781 | var hasOwnProp = Object.prototype.hasOwnProperty;
|
8782 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
8783 |
|
8784 | var Bundle = (function () {
|
8785 | function Bundle() {
|
8786 | var options = arguments[0] === undefined ? {} : arguments[0];
|
8787 |
|
8788 | _classCallCheck(this, Bundle);
|
8789 |
|
8790 | this.intro = options.intro || '';
|
8791 | this.outro = options.outro || '';
|
8792 | this.separator = options.separator !== undefined ? options.separator : '\n';
|
8793 |
|
8794 | this.sources = [];
|
8795 |
|
8796 | this.uniqueSources = [];
|
8797 | this.uniqueSourceIndexByFilename = {};
|
8798 | }
|
8799 |
|
8800 | Bundle.prototype.addSource = function addSource(source) {
|
8801 | if (source instanceof MagicString) {
|
8802 | return this.addSource({
|
8803 | content: source,
|
8804 | filename: source.filename,
|
8805 | separator: this.separator
|
8806 | });
|
8807 | }
|
8808 |
|
8809 | if (typeof source !== 'object' || !source.content) {
|
8810 | throw new Error('bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`');
|
8811 | }
|
8812 |
|
8813 | ['filename', 'indentExclusionRanges', 'separator'].forEach(function (option) {
|
8814 | if (!hasOwnProp.call(source, option)) source[option] = source.content[option];
|
8815 | });
|
8816 |
|
8817 | if (source.separator === undefined) {
|
8818 |
|
8819 | source.separator = this.separator;
|
8820 | }
|
8821 |
|
8822 | if (source.filename) {
|
8823 | if (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) {
|
8824 | this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length;
|
8825 | this.uniqueSources.push({ filename: source.filename, content: source.content.original });
|
8826 | } else {
|
8827 | var uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
|
8828 | if (source.content.original !== uniqueSource.content) {
|
8829 | throw new Error('Illegal source: same filename (' + source.filename + '), different contents');
|
8830 | }
|
8831 | }
|
8832 | }
|
8833 |
|
8834 | this.sources.push(source);
|
8835 | return this;
|
8836 | };
|
8837 |
|
8838 | Bundle.prototype.append = function append(str, options) {
|
8839 | this.addSource({
|
8840 | content: new MagicString(str),
|
8841 | separator: options && options.separator || ''
|
8842 | });
|
8843 |
|
8844 | return this;
|
8845 | };
|
8846 |
|
8847 | Bundle.prototype.clone = function clone() {
|
8848 | var bundle = new Bundle({
|
8849 | intro: this.intro,
|
8850 | outro: this.outro,
|
8851 | separator: this.separator
|
8852 | });
|
8853 |
|
8854 | this.sources.forEach(function (source) {
|
8855 | bundle.addSource({
|
8856 | filename: source.filename,
|
8857 | content: source.content.clone(),
|
8858 | separator: source.separator
|
8859 | });
|
8860 | });
|
8861 |
|
8862 | return bundle;
|
8863 | };
|
8864 |
|
8865 | Bundle.prototype.generateMap = function generateMap(options) {
|
8866 | var _this = this;
|
8867 |
|
8868 | var offsets = {};
|
8869 |
|
8870 | var encoded = getSemis(this.intro) + this.sources.map(function (source, i) {
|
8871 | var prefix = i > 0 ? getSemis(source.separator) || ',' : '';
|
8872 | var mappings = undefined;
|
8873 |
|
8874 |
|
8875 | if (!source.filename) {
|
8876 | mappings = getSemis(source.content.toString());
|
8877 | } else {
|
8878 | var sourceIndex = _this.uniqueSourceIndexByFilename[source.filename];
|
8879 | mappings = source.content.getMappings(options.hires, sourceIndex, offsets);
|
8880 | }
|
8881 |
|
8882 | return prefix + mappings;
|
8883 | }).join('') + getSemis(this.outro);
|
8884 |
|
8885 | return new SourceMap({
|
8886 | file: options.file ? options.file.split(/[\/\\]/).pop() : null,
|
8887 | sources: this.uniqueSources.map(function (source) {
|
8888 | return options.file ? getRelativePath(options.file, source.filename) : source.filename;
|
8889 | }),
|
8890 | sourcesContent: this.uniqueSources.map(function (source) {
|
8891 | return options.includeContent ? source.content : null;
|
8892 | }),
|
8893 | names: [],
|
8894 | mappings: encoded
|
8895 | });
|
8896 | };
|
8897 |
|
8898 | Bundle.prototype.getIndentString = function getIndentString() {
|
8899 | var indentStringCounts = {};
|
8900 |
|
8901 | this.sources.forEach(function (source) {
|
8902 | var indentStr = source.content.indentStr;
|
8903 |
|
8904 | if (indentStr === null) return;
|
8905 |
|
8906 | if (!indentStringCounts[indentStr]) indentStringCounts[indentStr] = 0;
|
8907 | indentStringCounts[indentStr] += 1;
|
8908 | });
|
8909 |
|
8910 | return Object.keys(indentStringCounts).sort(function (a, b) {
|
8911 | return indentStringCounts[a] - indentStringCounts[b];
|
8912 | })[0] || '\t';
|
8913 | };
|
8914 |
|
8915 | Bundle.prototype.indent = function indent(indentStr) {
|
8916 | var _this2 = this;
|
8917 |
|
8918 | if (!arguments.length) {
|
8919 | indentStr = this.getIndentString();
|
8920 | }
|
8921 |
|
8922 | if (indentStr === '') return this;
|
8923 |
|
8924 | var trailingNewline = !this.intro || this.intro.slice(-1) === '\n';
|
8925 |
|
8926 | this.sources.forEach(function (source, i) {
|
8927 | var separator = source.separator !== undefined ? source.separator : _this2.separator;
|
8928 | var indentStart = trailingNewline || i > 0 && /\r?\n$/.test(separator);
|
8929 |
|
8930 | source.content.indent(indentStr, {
|
8931 | exclude: source.indentExclusionRanges,
|
8932 | indentStart: indentStart
|
8933 | });
|
8934 |
|
8935 | trailingNewline = source.content.str.slice(0, -1) === '\n';
|
8936 | });
|
8937 |
|
8938 | if (this.intro) {
|
8939 | this.intro = indentStr + this.intro.replace(/^[^\n]/gm, function (match, index) {
|
8940 | return index > 0 ? indentStr + match : match;
|
8941 | });
|
8942 | }
|
8943 |
|
8944 | this.outro = this.outro.replace(/^[^\n]/gm, indentStr + '$&');
|
8945 |
|
8946 | return this;
|
8947 | };
|
8948 |
|
8949 | Bundle.prototype.prepend = function prepend(str) {
|
8950 | this.intro = str + this.intro;
|
8951 | return this;
|
8952 | };
|
8953 |
|
8954 | Bundle.prototype.toString = function toString() {
|
8955 | var _this3 = this;
|
8956 |
|
8957 | var body = this.sources.map(function (source, i) {
|
8958 | var separator = source.separator !== undefined ? source.separator : _this3.separator;
|
8959 | var str = (i > 0 ? separator : '') + source.content.toString();
|
8960 |
|
8961 | return str;
|
8962 | }).join('');
|
8963 |
|
8964 | return this.intro + body + this.outro;
|
8965 | };
|
8966 |
|
8967 | Bundle.prototype.trimLines = function trimLines() {
|
8968 | return this.trim('[\\r\\n]');
|
8969 | };
|
8970 |
|
8971 | Bundle.prototype.trim = function trim(charType) {
|
8972 | return this.trimStart(charType).trimEnd(charType);
|
8973 | };
|
8974 |
|
8975 | Bundle.prototype.trimStart = function trimStart(charType) {
|
8976 | var rx = new RegExp('^' + (charType || '\\s') + '+');
|
8977 | this.intro = this.intro.replace(rx, '');
|
8978 |
|
8979 | if (!this.intro) {
|
8980 | var source = undefined;
|
8981 | var i = 0;
|
8982 |
|
8983 | do {
|
8984 | source = this.sources[i];
|
8985 |
|
8986 | if (!source) {
|
8987 | this.outro = this.outro.replace(rx, '');
|
8988 | break;
|
8989 | }
|
8990 |
|
8991 | source.content.trimStart();
|
8992 | i += 1;
|
8993 | } while (source.content.str === '');
|
8994 | }
|
8995 |
|
8996 | return this;
|
8997 | };
|
8998 |
|
8999 | Bundle.prototype.trimEnd = function trimEnd(charType) {
|
9000 | var rx = new RegExp((charType || '\\s') + '+$');
|
9001 | this.outro = this.outro.replace(rx, '');
|
9002 |
|
9003 | if (!this.outro) {
|
9004 | var source = undefined;
|
9005 | var i = this.sources.length - 1;
|
9006 |
|
9007 | do {
|
9008 | source = this.sources[i];
|
9009 |
|
9010 | if (!source) {
|
9011 | this.intro = this.intro.replace(rx, '');
|
9012 | break;
|
9013 | }
|
9014 |
|
9015 | source.content.trimEnd(charType);
|
9016 | i -= 1;
|
9017 | } while (source.content.str === '');
|
9018 | }
|
9019 |
|
9020 | return this;
|
9021 | };
|
9022 |
|
9023 | return Bundle;
|
9024 | })();
|
9025 |
|
9026 | MagicString.Bundle = Bundle;
|
9027 |
|
9028 | var index = MagicString;
|
9029 |
|
9030 | return index;
|
9031 |
|
9032 | }));
|
9033 | }).call(this,require("buffer").Buffer)
|
9034 |
|
9035 | },{"buffer":"/www/ROLLUP/rollup/node_modules/gobble-browserify/node_modules/browserify/node_modules/buffer/index.js","vlq":"/www/ROLLUP/rollup/node_modules/magic-string/node_modules/vlq/dist/vlq.js"}],"/www/ROLLUP/rollup/node_modules/magic-string/node_modules/vlq/dist/vlq.js":[function(require,module,exports){
|
9036 | (function (global, factory) {
|
9037 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
9038 | typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
9039 | factory((global.vlq = {}))
|
9040 | }(this, function (exports) { 'use strict';
|
9041 |
|
9042 | exports.decode = decode;
|
9043 | exports.encode = encode;
|
9044 |
|
9045 | var charToInteger = {};
|
9046 | var integerToChar = {};
|
9047 |
|
9048 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split( '' ).forEach( function ( char, i ) {
|
9049 | charToInteger[ char ] = i;
|
9050 | integerToChar[ i ] = char;
|
9051 | });
|
9052 |
|
9053 | function decode ( string ) {
|
9054 | var result = [],
|
9055 | len = string.length,
|
9056 | i,
|
9057 | hasContinuationBit,
|
9058 | shift = 0,
|
9059 | value = 0,
|
9060 | integer,
|
9061 | shouldNegate;
|
9062 |
|
9063 | for ( i = 0; i < len; i += 1 ) {
|
9064 | integer = charToInteger[ string[i] ];
|
9065 |
|
9066 | if ( integer === undefined ) {
|
9067 | throw new Error( 'Invalid character (' + string[i] + ')' );
|
9068 | }
|
9069 |
|
9070 | hasContinuationBit = integer & 32;
|
9071 |
|
9072 | integer &= 31;
|
9073 | value += integer << shift;
|
9074 |
|
9075 | if ( hasContinuationBit ) {
|
9076 | shift += 5;
|
9077 | } else {
|
9078 | shouldNegate = value & 1;
|
9079 | value >>= 1;
|
9080 |
|
9081 | result.push( shouldNegate ? -value : value );
|
9082 |
|
9083 |
|
9084 | value = shift = 0;
|
9085 | }
|
9086 | }
|
9087 |
|
9088 | return result;
|
9089 | }
|
9090 |
|
9091 | function encode ( value ) {
|
9092 | var result, i;
|
9093 |
|
9094 | if ( typeof value === 'number' ) {
|
9095 | result = encodeInteger( value );
|
9096 | } else {
|
9097 | result = '';
|
9098 | for ( i = 0; i < value.length; i += 1 ) {
|
9099 | result += encodeInteger( value[i] );
|
9100 | }
|
9101 | }
|
9102 |
|
9103 | return result;
|
9104 | }
|
9105 |
|
9106 | function encodeInteger ( num ) {
|
9107 | var result = '', clamped;
|
9108 |
|
9109 | if ( num < 0 ) {
|
9110 | num = ( -num << 1 ) | 1;
|
9111 | } else {
|
9112 | num <<= 1;
|
9113 | }
|
9114 |
|
9115 | do {
|
9116 | clamped = num & 31;
|
9117 | num >>= 5;
|
9118 |
|
9119 | if ( num > 0 ) {
|
9120 | clamped |= 32;
|
9121 | }
|
9122 |
|
9123 | result += integerToChar[ clamped ];
|
9124 | } while ( num > 0 );
|
9125 |
|
9126 | return result;
|
9127 | }
|
9128 |
|
9129 | }));
|
9130 | },{}]},{},["/www/ROLLUP/rollup/.gobble-build/03-rollup/1/rollup.browser"])("/www/ROLLUP/rollup/.gobble-build/03-rollup/1/rollup.browser")
|
9131 | });
|
9132 |
|