ngannotate-rails 0.9.11 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWE4NWU5NzAyODRkODQ3ZTE3Y2Q1NWM1ODBkMmIyYzkyZmYzMGY2MA==
4
+ NzcwNWRjZWVkYzE0OGFiZmI2MzY0NmJiOTMxM2EzMjZkODllOGY3Ng==
5
5
  data.tar.gz: !binary |-
6
- MWY2ZGNlZTEzZmUwYmZiYzA5MmMzYzIzOGVkMzBkNWVmZWY3NzA3OQ==
6
+ MWMwZjQzNzkyMWY5YjRlOTYxY2Y2MzI5MDM0MWZjMDA2MWU0NGY1Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- N2I1NzE3YzQ2M2FmOGM4NjU4NDViZmQyYzMwZGQ3NDU4OTRlNmM1YTAxNTFk
10
- MGM4MDRmOTBjZDQ1Zjc0M2I3OWI3NWRhYjRhZTU3NzRjMzI5ZTdhZjAzODg2
11
- YmRjMTRlMDBmMTc3ZWI3YmFjMTIzOTMxYzJkNzcyZjU4ZjkyMmY=
9
+ ODg3YTVjOWIxNjk4MmQ0OWEyYzIzN2RlNjNiMDI4NTk0ZjJmNjI4MTdiYWQ2
10
+ MTczMTU2NDRiZWI3MzRjOWM1ZTY0MTQxMWM1NTAwYWY1MjViZTZhODFiYWRi
11
+ MmM2M2MzNWE2YWVlYzc0NDVhYTczMzY4ZGVlNjlmZDc5NDY5MzY=
12
12
  data.tar.gz: !binary |-
13
- ZDJkMGNjYTBkNjJlY2EyYWNhMmJhNzI2Y2UzNmZhZDQ1NjIzMGQzZjk3Yjli
14
- ODNiNjQxYzNlZGQxZTUwY2MzNDEzZDY1MjIyMjQ0OWM2ZDg1NmM1MDc3NWE3
15
- Y2YyMDkzZjJlOWFiNDE1NGRjN2IxN2Y1ZDlhZTU2NzVlOTQ4OTI=
13
+ N2Y4YTA4NGY5MzM4MmU3MDk4ZjBkMjUzZDFmNWU2YTc5NDkyZmUxMGFhMGM4
14
+ YTQ0MjMxMmFlZDQ3NDAwNDhiMjQ5ODhhNzBjOTY0MzY5ZDMzM2Q3ODgyODUx
15
+ YWZmMTBmMDE3ODM1MWJmNzNmZjI1ODY0MzQ0NjZjOThjMjE5ZWY=
data/README.md CHANGED
@@ -43,7 +43,7 @@ Testing assets locally
43
43
 
44
44
  To allow testing precompiled assets locally in development environment.
45
45
 
46
- config/environments/development.yml
46
+ config/environments/development.rb
47
47
 
48
48
  #
49
49
  # to allow testing assets:precompile in development environment
@@ -1,5 +1,5 @@
1
1
  module Ngannotate
2
2
  module Rails
3
- VERSION = "0.9.11"
3
+ VERSION = "0.10.1"
4
4
  end
5
5
  end
data/vendor/ngannotate.js CHANGED
@@ -360,15 +360,80 @@ var objectKeys = Object.keys || function (obj) {
360
360
  return keys;
361
361
  };
362
362
 
363
- },{"util/":3}],2:[function(require,module,exports){
364
- module.exports = function isBuffer(arg) {
365
- return arg && typeof arg === 'object'
366
- && typeof arg.copy === 'function'
367
- && typeof arg.fill === 'function'
368
- && typeof arg.readUInt8 === 'function';
363
+ },{"util/":7}],2:[function(require,module,exports){
364
+ if (typeof Object.create === 'function') {
365
+ // implementation from standard node.js 'util' module
366
+ module.exports = function inherits(ctor, superCtor) {
367
+ ctor.super_ = superCtor
368
+ ctor.prototype = Object.create(superCtor.prototype, {
369
+ constructor: {
370
+ value: ctor,
371
+ enumerable: false,
372
+ writable: true,
373
+ configurable: true
374
+ }
375
+ });
376
+ };
377
+ } else {
378
+ // old school shim for old browsers
379
+ module.exports = function inherits(ctor, superCtor) {
380
+ ctor.super_ = superCtor
381
+ var TempCtor = function () {}
382
+ TempCtor.prototype = superCtor.prototype
383
+ ctor.prototype = new TempCtor()
384
+ ctor.prototype.constructor = ctor
385
+ }
369
386
  }
387
+
370
388
  },{}],3:[function(require,module,exports){
371
- (function (process,global){
389
+ exports.endianness = function () { return 'LE' };
390
+
391
+ exports.hostname = function () {
392
+ if (typeof location !== 'undefined') {
393
+ return location.hostname
394
+ }
395
+ else return '';
396
+ };
397
+
398
+ exports.loadavg = function () { return [] };
399
+
400
+ exports.uptime = function () { return 0 };
401
+
402
+ exports.freemem = function () {
403
+ return Number.MAX_VALUE;
404
+ };
405
+
406
+ exports.totalmem = function () {
407
+ return Number.MAX_VALUE;
408
+ };
409
+
410
+ exports.cpus = function () { return [] };
411
+
412
+ exports.type = function () { return 'Browser' };
413
+
414
+ exports.release = function () {
415
+ if (typeof navigator !== 'undefined') {
416
+ return navigator.appVersion;
417
+ }
418
+ return '';
419
+ };
420
+
421
+ exports.networkInterfaces
422
+ = exports.getNetworkInterfaces
423
+ = function () { return {} };
424
+
425
+ exports.arch = function () { return 'javascript' };
426
+
427
+ exports.platform = function () { return 'browser' };
428
+
429
+ exports.tmpdir = exports.tmpDir = function () {
430
+ return '/tmp';
431
+ };
432
+
433
+ exports.EOL = '\n';
434
+
435
+ },{}],4:[function(require,module,exports){
436
+ (function (process){
372
437
  // Copyright Joyent, Inc. and other Node contributors.
373
438
  //
374
439
  // Permission is hereby granted, free of charge, to any person obtaining a
@@ -390,939 +455,874 @@ module.exports = function isBuffer(arg) {
390
455
  // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
391
456
  // USE OR OTHER DEALINGS IN THE SOFTWARE.
392
457
 
393
- var formatRegExp = /%[sdj%]/g;
394
- exports.format = function(f) {
395
- if (!isString(f)) {
396
- var objects = [];
397
- for (var i = 0; i < arguments.length; i++) {
398
- objects.push(inspect(arguments[i]));
458
+ // resolves . and .. elements in a path array with directory names there
459
+ // must be no slashes, empty elements, or device names (c:\) in the array
460
+ // (so also no leading and trailing slashes - it does not distinguish
461
+ // relative and absolute paths)
462
+ function normalizeArray(parts, allowAboveRoot) {
463
+ // if the path tries to go above the root, `up` ends up > 0
464
+ var up = 0;
465
+ for (var i = parts.length - 1; i >= 0; i--) {
466
+ var last = parts[i];
467
+ if (last === '.') {
468
+ parts.splice(i, 1);
469
+ } else if (last === '..') {
470
+ parts.splice(i, 1);
471
+ up++;
472
+ } else if (up) {
473
+ parts.splice(i, 1);
474
+ up--;
399
475
  }
400
- return objects.join(' ');
401
476
  }
402
477
 
403
- var i = 1;
404
- var args = arguments;
405
- var len = args.length;
406
- var str = String(f).replace(formatRegExp, function(x) {
407
- if (x === '%%') return '%';
408
- if (i >= len) return x;
409
- switch (x) {
410
- case '%s': return String(args[i++]);
411
- case '%d': return Number(args[i++]);
412
- case '%j':
413
- try {
414
- return JSON.stringify(args[i++]);
415
- } catch (_) {
416
- return '[Circular]';
417
- }
418
- default:
419
- return x;
420
- }
421
- });
422
- for (var x = args[i]; i < len; x = args[++i]) {
423
- if (isNull(x) || !isObject(x)) {
424
- str += ' ' + x;
425
- } else {
426
- str += ' ' + inspect(x);
478
+ // if the path is allowed to go above the root, restore leading ..s
479
+ if (allowAboveRoot) {
480
+ for (; up--; up) {
481
+ parts.unshift('..');
427
482
  }
428
483
  }
429
- return str;
430
- };
431
484
 
485
+ return parts;
486
+ }
432
487
 
433
- // Mark that a method should not be used.
434
- // Returns a modified function which warns once by default.
435
- // If --no-deprecation is set, then it is a no-op.
436
- exports.deprecate = function(fn, msg) {
437
- // Allow for deprecating things in the process of starting up.
438
- if (isUndefined(global.process)) {
439
- return function() {
440
- return exports.deprecate(fn, msg).apply(this, arguments);
441
- };
442
- }
488
+ // Split a filename into [root, dir, basename, ext], unix version
489
+ // 'root' is just a slash, or nothing.
490
+ var splitPathRe =
491
+ /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
492
+ var splitPath = function(filename) {
493
+ return splitPathRe.exec(filename).slice(1);
494
+ };
443
495
 
444
- if (process.noDeprecation === true) {
445
- return fn;
446
- }
496
+ // path.resolve([from ...], to)
497
+ // posix version
498
+ exports.resolve = function() {
499
+ var resolvedPath = '',
500
+ resolvedAbsolute = false;
447
501
 
448
- var warned = false;
449
- function deprecated() {
450
- if (!warned) {
451
- if (process.throwDeprecation) {
452
- throw new Error(msg);
453
- } else if (process.traceDeprecation) {
454
- console.trace(msg);
455
- } else {
456
- console.error(msg);
457
- }
458
- warned = true;
502
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
503
+ var path = (i >= 0) ? arguments[i] : process.cwd();
504
+
505
+ // Skip empty and invalid entries
506
+ if (typeof path !== 'string') {
507
+ throw new TypeError('Arguments to path.resolve must be strings');
508
+ } else if (!path) {
509
+ continue;
459
510
  }
460
- return fn.apply(this, arguments);
511
+
512
+ resolvedPath = path + '/' + resolvedPath;
513
+ resolvedAbsolute = path.charAt(0) === '/';
461
514
  }
462
515
 
463
- return deprecated;
464
- };
516
+ // At this point the path should be resolved to a full absolute path, but
517
+ // handle relative paths to be safe (might happen when process.cwd() fails)
465
518
 
519
+ // Normalize the path
520
+ resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
521
+ return !!p;
522
+ }), !resolvedAbsolute).join('/');
466
523
 
467
- var debugs = {};
468
- var debugEnviron;
469
- exports.debuglog = function(set) {
470
- if (isUndefined(debugEnviron))
471
- debugEnviron = process.env.NODE_DEBUG || '';
472
- set = set.toUpperCase();
473
- if (!debugs[set]) {
474
- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
475
- var pid = process.pid;
476
- debugs[set] = function() {
477
- var msg = exports.format.apply(exports, arguments);
478
- console.error('%s %d: %s', set, pid, msg);
479
- };
480
- } else {
481
- debugs[set] = function() {};
482
- }
483
- }
484
- return debugs[set];
524
+ return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
485
525
  };
486
526
 
527
+ // path.normalize(path)
528
+ // posix version
529
+ exports.normalize = function(path) {
530
+ var isAbsolute = exports.isAbsolute(path),
531
+ trailingSlash = substr(path, -1) === '/';
487
532
 
488
- /**
489
- * Echos the value of a value. Trys to print the value out
490
- * in the best way possible given the different types.
491
- *
492
- * @param {Object} obj The object to print out.
493
- * @param {Object} opts Optional options object that alters the output.
494
- */
495
- /* legacy: obj, showHidden, depth, colors*/
496
- function inspect(obj, opts) {
497
- // default options
498
- var ctx = {
499
- seen: [],
500
- stylize: stylizeNoColor
501
- };
502
- // legacy...
503
- if (arguments.length >= 3) ctx.depth = arguments[2];
504
- if (arguments.length >= 4) ctx.colors = arguments[3];
505
- if (isBoolean(opts)) {
506
- // legacy...
507
- ctx.showHidden = opts;
508
- } else if (opts) {
509
- // got an "options" object
510
- exports._extend(ctx, opts);
533
+ // Normalize the path
534
+ path = normalizeArray(filter(path.split('/'), function(p) {
535
+ return !!p;
536
+ }), !isAbsolute).join('/');
537
+
538
+ if (!path && !isAbsolute) {
539
+ path = '.';
540
+ }
541
+ if (path && trailingSlash) {
542
+ path += '/';
511
543
  }
512
- // set default options
513
- if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
514
- if (isUndefined(ctx.depth)) ctx.depth = 2;
515
- if (isUndefined(ctx.colors)) ctx.colors = false;
516
- if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
517
- if (ctx.colors) ctx.stylize = stylizeWithColor;
518
- return formatValue(ctx, obj, ctx.depth);
519
- }
520
- exports.inspect = inspect;
521
544
 
545
+ return (isAbsolute ? '/' : '') + path;
546
+ };
522
547
 
523
- // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
524
- inspect.colors = {
525
- 'bold' : [1, 22],
526
- 'italic' : [3, 23],
527
- 'underline' : [4, 24],
528
- 'inverse' : [7, 27],
529
- 'white' : [37, 39],
530
- 'grey' : [90, 39],
531
- 'black' : [30, 39],
532
- 'blue' : [34, 39],
533
- 'cyan' : [36, 39],
534
- 'green' : [32, 39],
535
- 'magenta' : [35, 39],
536
- 'red' : [31, 39],
537
- 'yellow' : [33, 39]
548
+ // posix version
549
+ exports.isAbsolute = function(path) {
550
+ return path.charAt(0) === '/';
538
551
  };
539
552
 
540
- // Don't use 'blue' not visible on cmd.exe
541
- inspect.styles = {
542
- 'special': 'cyan',
543
- 'number': 'yellow',
544
- 'boolean': 'yellow',
545
- 'undefined': 'grey',
546
- 'null': 'bold',
547
- 'string': 'green',
548
- 'date': 'magenta',
549
- // "name": intentionally not styling
550
- 'regexp': 'red'
553
+ // posix version
554
+ exports.join = function() {
555
+ var paths = Array.prototype.slice.call(arguments, 0);
556
+ return exports.normalize(filter(paths, function(p, index) {
557
+ if (typeof p !== 'string') {
558
+ throw new TypeError('Arguments to path.join must be strings');
559
+ }
560
+ return p;
561
+ }).join('/'));
551
562
  };
552
563
 
553
564
 
554
- function stylizeWithColor(str, styleType) {
555
- var style = inspect.styles[styleType];
556
-
557
- if (style) {
558
- return '\u001b[' + inspect.colors[style][0] + 'm' + str +
559
- '\u001b[' + inspect.colors[style][1] + 'm';
560
- } else {
561
- return str;
562
- }
563
- }
564
-
565
-
566
- function stylizeNoColor(str, styleType) {
567
- return str;
568
- }
569
-
570
-
571
- function arrayToHash(array) {
572
- var hash = {};
573
-
574
- array.forEach(function(val, idx) {
575
- hash[val] = true;
576
- });
577
-
578
- return hash;
579
- }
565
+ // path.relative(from, to)
566
+ // posix version
567
+ exports.relative = function(from, to) {
568
+ from = exports.resolve(from).substr(1);
569
+ to = exports.resolve(to).substr(1);
580
570
 
571
+ function trim(arr) {
572
+ var start = 0;
573
+ for (; start < arr.length; start++) {
574
+ if (arr[start] !== '') break;
575
+ }
581
576
 
582
- function formatValue(ctx, value, recurseTimes) {
583
- // Provide a hook for user-specified inspect functions.
584
- // Check that value is an object with an inspect function on it
585
- if (ctx.customInspect &&
586
- value &&
587
- isFunction(value.inspect) &&
588
- // Filter out the util module, it's inspect function is special
589
- value.inspect !== exports.inspect &&
590
- // Also filter out any prototype objects using the circular check.
591
- !(value.constructor && value.constructor.prototype === value)) {
592
- var ret = value.inspect(recurseTimes, ctx);
593
- if (!isString(ret)) {
594
- ret = formatValue(ctx, ret, recurseTimes);
577
+ var end = arr.length - 1;
578
+ for (; end >= 0; end--) {
579
+ if (arr[end] !== '') break;
595
580
  }
596
- return ret;
597
- }
598
581
 
599
- // Primitive types cannot have properties
600
- var primitive = formatPrimitive(ctx, value);
601
- if (primitive) {
602
- return primitive;
582
+ if (start > end) return [];
583
+ return arr.slice(start, end - start + 1);
603
584
  }
604
585
 
605
- // Look up the keys of the object.
606
- var keys = Object.keys(value);
607
- var visibleKeys = arrayToHash(keys);
586
+ var fromParts = trim(from.split('/'));
587
+ var toParts = trim(to.split('/'));
608
588
 
609
- if (ctx.showHidden) {
610
- keys = Object.getOwnPropertyNames(value);
589
+ var length = Math.min(fromParts.length, toParts.length);
590
+ var samePartsLength = length;
591
+ for (var i = 0; i < length; i++) {
592
+ if (fromParts[i] !== toParts[i]) {
593
+ samePartsLength = i;
594
+ break;
595
+ }
611
596
  }
612
597
 
613
- // IE doesn't make error fields non-enumerable
614
- // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
615
- if (isError(value)
616
- && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
617
- return formatError(value);
598
+ var outputParts = [];
599
+ for (var i = samePartsLength; i < fromParts.length; i++) {
600
+ outputParts.push('..');
618
601
  }
619
602
 
620
- // Some type of object without properties can be shortcutted.
621
- if (keys.length === 0) {
622
- if (isFunction(value)) {
623
- var name = value.name ? ': ' + value.name : '';
624
- return ctx.stylize('[Function' + name + ']', 'special');
625
- }
626
- if (isRegExp(value)) {
627
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
628
- }
629
- if (isDate(value)) {
630
- return ctx.stylize(Date.prototype.toString.call(value), 'date');
631
- }
632
- if (isError(value)) {
633
- return formatError(value);
634
- }
635
- }
603
+ outputParts = outputParts.concat(toParts.slice(samePartsLength));
636
604
 
637
- var base = '', array = false, braces = ['{', '}'];
605
+ return outputParts.join('/');
606
+ };
638
607
 
639
- // Make Array say that they are Array
640
- if (isArray(value)) {
641
- array = true;
642
- braces = ['[', ']'];
643
- }
608
+ exports.sep = '/';
609
+ exports.delimiter = ':';
644
610
 
645
- // Make functions say that they are functions
646
- if (isFunction(value)) {
647
- var n = value.name ? ': ' + value.name : '';
648
- base = ' [Function' + n + ']';
649
- }
611
+ exports.dirname = function(path) {
612
+ var result = splitPath(path),
613
+ root = result[0],
614
+ dir = result[1];
650
615
 
651
- // Make RegExps say that they are RegExps
652
- if (isRegExp(value)) {
653
- base = ' ' + RegExp.prototype.toString.call(value);
616
+ if (!root && !dir) {
617
+ // No dirname whatsoever
618
+ return '.';
654
619
  }
655
620
 
656
- // Make dates with properties first say the date
657
- if (isDate(value)) {
658
- base = ' ' + Date.prototype.toUTCString.call(value);
621
+ if (dir) {
622
+ // It has a dirname, strip trailing slash
623
+ dir = dir.substr(0, dir.length - 1);
659
624
  }
660
625
 
661
- // Make error with message first say the error
662
- if (isError(value)) {
663
- base = ' ' + formatError(value);
664
- }
626
+ return root + dir;
627
+ };
665
628
 
666
- if (keys.length === 0 && (!array || value.length == 0)) {
667
- return braces[0] + base + braces[1];
668
- }
669
629
 
670
- if (recurseTimes < 0) {
671
- if (isRegExp(value)) {
672
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
673
- } else {
674
- return ctx.stylize('[Object]', 'special');
675
- }
630
+ exports.basename = function(path, ext) {
631
+ var f = splitPath(path)[2];
632
+ // TODO: make this comparison case-insensitive on windows?
633
+ if (ext && f.substr(-1 * ext.length) === ext) {
634
+ f = f.substr(0, f.length - ext.length);
676
635
  }
636
+ return f;
637
+ };
677
638
 
678
- ctx.seen.push(value);
679
-
680
- var output;
681
- if (array) {
682
- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
683
- } else {
684
- output = keys.map(function(key) {
685
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
686
- });
687
- }
688
639
 
689
- ctx.seen.pop();
640
+ exports.extname = function(path) {
641
+ return splitPath(path)[3];
642
+ };
690
643
 
691
- return reduceToSingleString(output, base, braces);
644
+ function filter (xs, f) {
645
+ if (xs.filter) return xs.filter(f);
646
+ var res = [];
647
+ for (var i = 0; i < xs.length; i++) {
648
+ if (f(xs[i], i, xs)) res.push(xs[i]);
649
+ }
650
+ return res;
692
651
  }
693
652
 
653
+ // String.prototype.substr - negative index don't work in IE8
654
+ var substr = 'ab'.substr(-1) === 'b'
655
+ ? function (str, start, len) { return str.substr(start, len) }
656
+ : function (str, start, len) {
657
+ if (start < 0) start = str.length + start;
658
+ return str.substr(start, len);
659
+ }
660
+ ;
694
661
 
695
- function formatPrimitive(ctx, value) {
696
- if (isUndefined(value))
697
- return ctx.stylize('undefined', 'undefined');
698
- if (isString(value)) {
699
- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
700
- .replace(/'/g, "\\'")
701
- .replace(/\\"/g, '"') + '\'';
702
- return ctx.stylize(simple, 'string');
703
- }
704
- if (isNumber(value))
705
- return ctx.stylize('' + value, 'number');
706
- if (isBoolean(value))
707
- return ctx.stylize('' + value, 'boolean');
708
- // For some reason typeof null is "object", so special case here.
709
- if (isNull(value))
710
- return ctx.stylize('null', 'null');
711
- }
662
+ }).call(this,require('_process'))
663
+ },{"_process":5}],5:[function(require,module,exports){
664
+ // shim for using process in browser
712
665
 
666
+ var process = module.exports = {};
713
667
 
714
- function formatError(value) {
715
- return '[' + Error.prototype.toString.call(value) + ']';
716
- }
668
+ process.nextTick = (function () {
669
+ var canSetImmediate = typeof window !== 'undefined'
670
+ && window.setImmediate;
671
+ var canPost = typeof window !== 'undefined'
672
+ && window.postMessage && window.addEventListener
673
+ ;
717
674
 
675
+ if (canSetImmediate) {
676
+ return function (f) { return window.setImmediate(f) };
677
+ }
718
678
 
719
- function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
720
- var output = [];
721
- for (var i = 0, l = value.length; i < l; ++i) {
722
- if (hasOwnProperty(value, String(i))) {
723
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
724
- String(i), true));
725
- } else {
726
- output.push('');
727
- }
728
- }
729
- keys.forEach(function(key) {
730
- if (!key.match(/^\d+$/)) {
731
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
732
- key, true));
733
- }
734
- });
735
- return output;
736
- }
737
-
679
+ if (canPost) {
680
+ var queue = [];
681
+ window.addEventListener('message', function (ev) {
682
+ var source = ev.source;
683
+ if ((source === window || source === null) && ev.data === 'process-tick') {
684
+ ev.stopPropagation();
685
+ if (queue.length > 0) {
686
+ var fn = queue.shift();
687
+ fn();
688
+ }
689
+ }
690
+ }, true);
738
691
 
739
- function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
740
- var name, str, desc;
741
- desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
742
- if (desc.get) {
743
- if (desc.set) {
744
- str = ctx.stylize('[Getter/Setter]', 'special');
745
- } else {
746
- str = ctx.stylize('[Getter]', 'special');
747
- }
748
- } else {
749
- if (desc.set) {
750
- str = ctx.stylize('[Setter]', 'special');
751
- }
752
- }
753
- if (!hasOwnProperty(visibleKeys, key)) {
754
- name = '[' + key + ']';
755
- }
756
- if (!str) {
757
- if (ctx.seen.indexOf(desc.value) < 0) {
758
- if (isNull(recurseTimes)) {
759
- str = formatValue(ctx, desc.value, null);
760
- } else {
761
- str = formatValue(ctx, desc.value, recurseTimes - 1);
762
- }
763
- if (str.indexOf('\n') > -1) {
764
- if (array) {
765
- str = str.split('\n').map(function(line) {
766
- return ' ' + line;
767
- }).join('\n').substr(2);
768
- } else {
769
- str = '\n' + str.split('\n').map(function(line) {
770
- return ' ' + line;
771
- }).join('\n');
772
- }
773
- }
774
- } else {
775
- str = ctx.stylize('[Circular]', 'special');
776
- }
777
- }
778
- if (isUndefined(name)) {
779
- if (array && key.match(/^\d+$/)) {
780
- return str;
781
- }
782
- name = JSON.stringify('' + key);
783
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
784
- name = name.substr(1, name.length - 2);
785
- name = ctx.stylize(name, 'name');
786
- } else {
787
- name = name.replace(/'/g, "\\'")
788
- .replace(/\\"/g, '"')
789
- .replace(/(^"|"$)/g, "'");
790
- name = ctx.stylize(name, 'string');
692
+ return function nextTick(fn) {
693
+ queue.push(fn);
694
+ window.postMessage('process-tick', '*');
695
+ };
791
696
  }
792
- }
793
-
794
- return name + ': ' + str;
795
- }
796
-
797
-
798
- function reduceToSingleString(output, base, braces) {
799
- var numLinesEst = 0;
800
- var length = output.reduce(function(prev, cur) {
801
- numLinesEst++;
802
- if (cur.indexOf('\n') >= 0) numLinesEst++;
803
- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
804
- }, 0);
805
697
 
806
- if (length > 60) {
807
- return braces[0] +
808
- (base === '' ? '' : base + '\n ') +
809
- ' ' +
810
- output.join(',\n ') +
811
- ' ' +
812
- braces[1];
813
- }
814
-
815
- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
816
- }
817
-
818
-
819
- // NOTE: These type checking functions intentionally don't use `instanceof`
820
- // because it is fragile and can be easily faked with `Object.create()`.
821
- function isArray(ar) {
822
- return Array.isArray(ar);
823
- }
824
- exports.isArray = isArray;
698
+ return function nextTick(fn) {
699
+ setTimeout(fn, 0);
700
+ };
701
+ })();
825
702
 
826
- function isBoolean(arg) {
827
- return typeof arg === 'boolean';
828
- }
829
- exports.isBoolean = isBoolean;
703
+ process.title = 'browser';
704
+ process.browser = true;
705
+ process.env = {};
706
+ process.argv = [];
830
707
 
831
- function isNull(arg) {
832
- return arg === null;
833
- }
834
- exports.isNull = isNull;
708
+ function noop() {}
835
709
 
836
- function isNullOrUndefined(arg) {
837
- return arg == null;
838
- }
839
- exports.isNullOrUndefined = isNullOrUndefined;
710
+ process.on = noop;
711
+ process.addListener = noop;
712
+ process.once = noop;
713
+ process.off = noop;
714
+ process.removeListener = noop;
715
+ process.removeAllListeners = noop;
716
+ process.emit = noop;
840
717
 
841
- function isNumber(arg) {
842
- return typeof arg === 'number';
718
+ process.binding = function (name) {
719
+ throw new Error('process.binding is not supported');
843
720
  }
844
- exports.isNumber = isNumber;
845
721
 
846
- function isString(arg) {
847
- return typeof arg === 'string';
848
- }
849
- exports.isString = isString;
722
+ // TODO(shtylman)
723
+ process.cwd = function () { return '/' };
724
+ process.chdir = function (dir) {
725
+ throw new Error('process.chdir is not supported');
726
+ };
850
727
 
851
- function isSymbol(arg) {
852
- return typeof arg === 'symbol';
728
+ },{}],6:[function(require,module,exports){
729
+ module.exports = function isBuffer(arg) {
730
+ return arg && typeof arg === 'object'
731
+ && typeof arg.copy === 'function'
732
+ && typeof arg.fill === 'function'
733
+ && typeof arg.readUInt8 === 'function';
853
734
  }
854
- exports.isSymbol = isSymbol;
735
+ },{}],7:[function(require,module,exports){
736
+ (function (process,global){
737
+ // Copyright Joyent, Inc. and other Node contributors.
738
+ //
739
+ // Permission is hereby granted, free of charge, to any person obtaining a
740
+ // copy of this software and associated documentation files (the
741
+ // "Software"), to deal in the Software without restriction, including
742
+ // without limitation the rights to use, copy, modify, merge, publish,
743
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
744
+ // persons to whom the Software is furnished to do so, subject to the
745
+ // following conditions:
746
+ //
747
+ // The above copyright notice and this permission notice shall be included
748
+ // in all copies or substantial portions of the Software.
749
+ //
750
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
751
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
752
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
753
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
754
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
755
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
756
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
855
757
 
856
- function isUndefined(arg) {
857
- return arg === void 0;
858
- }
859
- exports.isUndefined = isUndefined;
758
+ var formatRegExp = /%[sdj%]/g;
759
+ exports.format = function(f) {
760
+ if (!isString(f)) {
761
+ var objects = [];
762
+ for (var i = 0; i < arguments.length; i++) {
763
+ objects.push(inspect(arguments[i]));
764
+ }
765
+ return objects.join(' ');
766
+ }
860
767
 
861
- function isRegExp(re) {
862
- return isObject(re) && objectToString(re) === '[object RegExp]';
863
- }
864
- exports.isRegExp = isRegExp;
768
+ var i = 1;
769
+ var args = arguments;
770
+ var len = args.length;
771
+ var str = String(f).replace(formatRegExp, function(x) {
772
+ if (x === '%%') return '%';
773
+ if (i >= len) return x;
774
+ switch (x) {
775
+ case '%s': return String(args[i++]);
776
+ case '%d': return Number(args[i++]);
777
+ case '%j':
778
+ try {
779
+ return JSON.stringify(args[i++]);
780
+ } catch (_) {
781
+ return '[Circular]';
782
+ }
783
+ default:
784
+ return x;
785
+ }
786
+ });
787
+ for (var x = args[i]; i < len; x = args[++i]) {
788
+ if (isNull(x) || !isObject(x)) {
789
+ str += ' ' + x;
790
+ } else {
791
+ str += ' ' + inspect(x);
792
+ }
793
+ }
794
+ return str;
795
+ };
865
796
 
866
- function isObject(arg) {
867
- return typeof arg === 'object' && arg !== null;
868
- }
869
- exports.isObject = isObject;
870
797
 
871
- function isDate(d) {
872
- return isObject(d) && objectToString(d) === '[object Date]';
873
- }
874
- exports.isDate = isDate;
798
+ // Mark that a method should not be used.
799
+ // Returns a modified function which warns once by default.
800
+ // If --no-deprecation is set, then it is a no-op.
801
+ exports.deprecate = function(fn, msg) {
802
+ // Allow for deprecating things in the process of starting up.
803
+ if (isUndefined(global.process)) {
804
+ return function() {
805
+ return exports.deprecate(fn, msg).apply(this, arguments);
806
+ };
807
+ }
875
808
 
876
- function isError(e) {
877
- return isObject(e) &&
878
- (objectToString(e) === '[object Error]' || e instanceof Error);
879
- }
880
- exports.isError = isError;
809
+ if (process.noDeprecation === true) {
810
+ return fn;
811
+ }
881
812
 
882
- function isFunction(arg) {
883
- return typeof arg === 'function';
884
- }
885
- exports.isFunction = isFunction;
813
+ var warned = false;
814
+ function deprecated() {
815
+ if (!warned) {
816
+ if (process.throwDeprecation) {
817
+ throw new Error(msg);
818
+ } else if (process.traceDeprecation) {
819
+ console.trace(msg);
820
+ } else {
821
+ console.error(msg);
822
+ }
823
+ warned = true;
824
+ }
825
+ return fn.apply(this, arguments);
826
+ }
886
827
 
887
- function isPrimitive(arg) {
888
- return arg === null ||
889
- typeof arg === 'boolean' ||
890
- typeof arg === 'number' ||
891
- typeof arg === 'string' ||
892
- typeof arg === 'symbol' || // ES6 symbol
893
- typeof arg === 'undefined';
894
- }
895
- exports.isPrimitive = isPrimitive;
828
+ return deprecated;
829
+ };
896
830
 
897
- exports.isBuffer = require('./support/isBuffer');
898
831
 
899
- function objectToString(o) {
900
- return Object.prototype.toString.call(o);
901
- }
832
+ var debugs = {};
833
+ var debugEnviron;
834
+ exports.debuglog = function(set) {
835
+ if (isUndefined(debugEnviron))
836
+ debugEnviron = process.env.NODE_DEBUG || '';
837
+ set = set.toUpperCase();
838
+ if (!debugs[set]) {
839
+ if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
840
+ var pid = process.pid;
841
+ debugs[set] = function() {
842
+ var msg = exports.format.apply(exports, arguments);
843
+ console.error('%s %d: %s', set, pid, msg);
844
+ };
845
+ } else {
846
+ debugs[set] = function() {};
847
+ }
848
+ }
849
+ return debugs[set];
850
+ };
902
851
 
903
852
 
904
- function pad(n) {
905
- return n < 10 ? '0' + n.toString(10) : n.toString(10);
853
+ /**
854
+ * Echos the value of a value. Trys to print the value out
855
+ * in the best way possible given the different types.
856
+ *
857
+ * @param {Object} obj The object to print out.
858
+ * @param {Object} opts Optional options object that alters the output.
859
+ */
860
+ /* legacy: obj, showHidden, depth, colors*/
861
+ function inspect(obj, opts) {
862
+ // default options
863
+ var ctx = {
864
+ seen: [],
865
+ stylize: stylizeNoColor
866
+ };
867
+ // legacy...
868
+ if (arguments.length >= 3) ctx.depth = arguments[2];
869
+ if (arguments.length >= 4) ctx.colors = arguments[3];
870
+ if (isBoolean(opts)) {
871
+ // legacy...
872
+ ctx.showHidden = opts;
873
+ } else if (opts) {
874
+ // got an "options" object
875
+ exports._extend(ctx, opts);
876
+ }
877
+ // set default options
878
+ if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
879
+ if (isUndefined(ctx.depth)) ctx.depth = 2;
880
+ if (isUndefined(ctx.colors)) ctx.colors = false;
881
+ if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
882
+ if (ctx.colors) ctx.stylize = stylizeWithColor;
883
+ return formatValue(ctx, obj, ctx.depth);
906
884
  }
885
+ exports.inspect = inspect;
907
886
 
908
887
 
909
- var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
910
- 'Oct', 'Nov', 'Dec'];
911
-
912
- // 26 Feb 16:19:34
913
- function timestamp() {
914
- var d = new Date();
915
- var time = [pad(d.getHours()),
916
- pad(d.getMinutes()),
917
- pad(d.getSeconds())].join(':');
918
- return [d.getDate(), months[d.getMonth()], time].join(' ');
919
- }
920
-
888
+ // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
889
+ inspect.colors = {
890
+ 'bold' : [1, 22],
891
+ 'italic' : [3, 23],
892
+ 'underline' : [4, 24],
893
+ 'inverse' : [7, 27],
894
+ 'white' : [37, 39],
895
+ 'grey' : [90, 39],
896
+ 'black' : [30, 39],
897
+ 'blue' : [34, 39],
898
+ 'cyan' : [36, 39],
899
+ 'green' : [32, 39],
900
+ 'magenta' : [35, 39],
901
+ 'red' : [31, 39],
902
+ 'yellow' : [33, 39]
903
+ };
921
904
 
922
- // log is just a thin wrapper to console.log that prepends a timestamp
923
- exports.log = function() {
924
- console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
905
+ // Don't use 'blue' not visible on cmd.exe
906
+ inspect.styles = {
907
+ 'special': 'cyan',
908
+ 'number': 'yellow',
909
+ 'boolean': 'yellow',
910
+ 'undefined': 'grey',
911
+ 'null': 'bold',
912
+ 'string': 'green',
913
+ 'date': 'magenta',
914
+ // "name": intentionally not styling
915
+ 'regexp': 'red'
925
916
  };
926
917
 
927
918
 
928
- /**
929
- * Inherit the prototype methods from one constructor into another.
930
- *
931
- * The Function.prototype.inherits from lang.js rewritten as a standalone
932
- * function (not on Function.prototype). NOTE: If this file is to be loaded
933
- * during bootstrapping this function needs to be rewritten using some native
934
- * functions as prototype setup using normal JavaScript does not work as
935
- * expected during bootstrapping (see mirror.js in r114903).
936
- *
937
- * @param {function} ctor Constructor function which needs to inherit the
938
- * prototype.
939
- * @param {function} superCtor Constructor function to inherit prototype from.
940
- */
941
- exports.inherits = require('inherits');
942
-
943
- exports._extend = function(origin, add) {
944
- // Don't do anything if add isn't an object
945
- if (!add || !isObject(add)) return origin;
919
+ function stylizeWithColor(str, styleType) {
920
+ var style = inspect.styles[styleType];
946
921
 
947
- var keys = Object.keys(add);
948
- var i = keys.length;
949
- while (i--) {
950
- origin[keys[i]] = add[keys[i]];
922
+ if (style) {
923
+ return '\u001b[' + inspect.colors[style][0] + 'm' + str +
924
+ '\u001b[' + inspect.colors[style][1] + 'm';
925
+ } else {
926
+ return str;
951
927
  }
952
- return origin;
953
- };
954
-
955
- function hasOwnProperty(obj, prop) {
956
- return Object.prototype.hasOwnProperty.call(obj, prop);
957
928
  }
958
929
 
959
- }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
960
- },{"./support/isBuffer":2,"_process":7,"inherits":4}],4:[function(require,module,exports){
961
- if (typeof Object.create === 'function') {
962
- // implementation from standard node.js 'util' module
963
- module.exports = function inherits(ctor, superCtor) {
964
- ctor.super_ = superCtor
965
- ctor.prototype = Object.create(superCtor.prototype, {
966
- constructor: {
967
- value: ctor,
968
- enumerable: false,
969
- writable: true,
970
- configurable: true
971
- }
972
- });
973
- };
974
- } else {
975
- // old school shim for old browsers
976
- module.exports = function inherits(ctor, superCtor) {
977
- ctor.super_ = superCtor
978
- var TempCtor = function () {}
979
- TempCtor.prototype = superCtor.prototype
980
- ctor.prototype = new TempCtor()
981
- ctor.prototype.constructor = ctor
982
- }
930
+
931
+ function stylizeNoColor(str, styleType) {
932
+ return str;
983
933
  }
984
934
 
985
- },{}],5:[function(require,module,exports){
986
- exports.endianness = function () { return 'LE' };
987
935
 
988
- exports.hostname = function () {
989
- if (typeof location !== 'undefined') {
990
- return location.hostname
991
- }
992
- else return '';
993
- };
936
+ function arrayToHash(array) {
937
+ var hash = {};
994
938
 
995
- exports.loadavg = function () { return [] };
939
+ array.forEach(function(val, idx) {
940
+ hash[val] = true;
941
+ });
996
942
 
997
- exports.uptime = function () { return 0 };
943
+ return hash;
944
+ }
998
945
 
999
- exports.freemem = function () {
1000
- return Number.MAX_VALUE;
1001
- };
1002
946
 
1003
- exports.totalmem = function () {
1004
- return Number.MAX_VALUE;
1005
- };
947
+ function formatValue(ctx, value, recurseTimes) {
948
+ // Provide a hook for user-specified inspect functions.
949
+ // Check that value is an object with an inspect function on it
950
+ if (ctx.customInspect &&
951
+ value &&
952
+ isFunction(value.inspect) &&
953
+ // Filter out the util module, it's inspect function is special
954
+ value.inspect !== exports.inspect &&
955
+ // Also filter out any prototype objects using the circular check.
956
+ !(value.constructor && value.constructor.prototype === value)) {
957
+ var ret = value.inspect(recurseTimes, ctx);
958
+ if (!isString(ret)) {
959
+ ret = formatValue(ctx, ret, recurseTimes);
960
+ }
961
+ return ret;
962
+ }
1006
963
 
1007
- exports.cpus = function () { return [] };
964
+ // Primitive types cannot have properties
965
+ var primitive = formatPrimitive(ctx, value);
966
+ if (primitive) {
967
+ return primitive;
968
+ }
1008
969
 
1009
- exports.type = function () { return 'Browser' };
970
+ // Look up the keys of the object.
971
+ var keys = Object.keys(value);
972
+ var visibleKeys = arrayToHash(keys);
1010
973
 
1011
- exports.release = function () {
1012
- if (typeof navigator !== 'undefined') {
1013
- return navigator.appVersion;
974
+ if (ctx.showHidden) {
975
+ keys = Object.getOwnPropertyNames(value);
976
+ }
977
+
978
+ // IE doesn't make error fields non-enumerable
979
+ // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
980
+ if (isError(value)
981
+ && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
982
+ return formatError(value);
983
+ }
984
+
985
+ // Some type of object without properties can be shortcutted.
986
+ if (keys.length === 0) {
987
+ if (isFunction(value)) {
988
+ var name = value.name ? ': ' + value.name : '';
989
+ return ctx.stylize('[Function' + name + ']', 'special');
1014
990
  }
1015
- return '';
1016
- };
991
+ if (isRegExp(value)) {
992
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
993
+ }
994
+ if (isDate(value)) {
995
+ return ctx.stylize(Date.prototype.toString.call(value), 'date');
996
+ }
997
+ if (isError(value)) {
998
+ return formatError(value);
999
+ }
1000
+ }
1017
1001
 
1018
- exports.networkInterfaces
1019
- = exports.getNetworkInterfaces
1020
- = function () { return {} };
1002
+ var base = '', array = false, braces = ['{', '}'];
1021
1003
 
1022
- exports.arch = function () { return 'javascript' };
1004
+ // Make Array say that they are Array
1005
+ if (isArray(value)) {
1006
+ array = true;
1007
+ braces = ['[', ']'];
1008
+ }
1023
1009
 
1024
- exports.platform = function () { return 'browser' };
1010
+ // Make functions say that they are functions
1011
+ if (isFunction(value)) {
1012
+ var n = value.name ? ': ' + value.name : '';
1013
+ base = ' [Function' + n + ']';
1014
+ }
1025
1015
 
1026
- exports.tmpdir = exports.tmpDir = function () {
1027
- return '/tmp';
1028
- };
1016
+ // Make RegExps say that they are RegExps
1017
+ if (isRegExp(value)) {
1018
+ base = ' ' + RegExp.prototype.toString.call(value);
1019
+ }
1029
1020
 
1030
- exports.EOL = '\n';
1021
+ // Make dates with properties first say the date
1022
+ if (isDate(value)) {
1023
+ base = ' ' + Date.prototype.toUTCString.call(value);
1024
+ }
1031
1025
 
1032
- },{}],6:[function(require,module,exports){
1033
- (function (process){
1034
- // Copyright Joyent, Inc. and other Node contributors.
1035
- //
1036
- // Permission is hereby granted, free of charge, to any person obtaining a
1037
- // copy of this software and associated documentation files (the
1038
- // "Software"), to deal in the Software without restriction, including
1039
- // without limitation the rights to use, copy, modify, merge, publish,
1040
- // distribute, sublicense, and/or sell copies of the Software, and to permit
1041
- // persons to whom the Software is furnished to do so, subject to the
1042
- // following conditions:
1043
- //
1044
- // The above copyright notice and this permission notice shall be included
1045
- // in all copies or substantial portions of the Software.
1046
- //
1047
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1048
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1049
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
1050
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
1051
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1052
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
1053
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
1026
+ // Make error with message first say the error
1027
+ if (isError(value)) {
1028
+ base = ' ' + formatError(value);
1029
+ }
1054
1030
 
1055
- // resolves . and .. elements in a path array with directory names there
1056
- // must be no slashes, empty elements, or device names (c:\) in the array
1057
- // (so also no leading and trailing slashes - it does not distinguish
1058
- // relative and absolute paths)
1059
- function normalizeArray(parts, allowAboveRoot) {
1060
- // if the path tries to go above the root, `up` ends up > 0
1061
- var up = 0;
1062
- for (var i = parts.length - 1; i >= 0; i--) {
1063
- var last = parts[i];
1064
- if (last === '.') {
1065
- parts.splice(i, 1);
1066
- } else if (last === '..') {
1067
- parts.splice(i, 1);
1068
- up++;
1069
- } else if (up) {
1070
- parts.splice(i, 1);
1071
- up--;
1072
- }
1031
+ if (keys.length === 0 && (!array || value.length == 0)) {
1032
+ return braces[0] + base + braces[1];
1073
1033
  }
1074
1034
 
1075
- // if the path is allowed to go above the root, restore leading ..s
1076
- if (allowAboveRoot) {
1077
- for (; up--; up) {
1078
- parts.unshift('..');
1035
+ if (recurseTimes < 0) {
1036
+ if (isRegExp(value)) {
1037
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
1038
+ } else {
1039
+ return ctx.stylize('[Object]', 'special');
1079
1040
  }
1080
1041
  }
1081
1042
 
1082
- return parts;
1083
- }
1084
-
1085
- // Split a filename into [root, dir, basename, ext], unix version
1086
- // 'root' is just a slash, or nothing.
1087
- var splitPathRe =
1088
- /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
1089
- var splitPath = function(filename) {
1090
- return splitPathRe.exec(filename).slice(1);
1091
- };
1043
+ ctx.seen.push(value);
1092
1044
 
1093
- // path.resolve([from ...], to)
1094
- // posix version
1095
- exports.resolve = function() {
1096
- var resolvedPath = '',
1097
- resolvedAbsolute = false;
1045
+ var output;
1046
+ if (array) {
1047
+ output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
1048
+ } else {
1049
+ output = keys.map(function(key) {
1050
+ return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
1051
+ });
1052
+ }
1098
1053
 
1099
- for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
1100
- var path = (i >= 0) ? arguments[i] : process.cwd();
1054
+ ctx.seen.pop();
1101
1055
 
1102
- // Skip empty and invalid entries
1103
- if (typeof path !== 'string') {
1104
- throw new TypeError('Arguments to path.resolve must be strings');
1105
- } else if (!path) {
1106
- continue;
1107
- }
1056
+ return reduceToSingleString(output, base, braces);
1057
+ }
1108
1058
 
1109
- resolvedPath = path + '/' + resolvedPath;
1110
- resolvedAbsolute = path.charAt(0) === '/';
1059
+
1060
+ function formatPrimitive(ctx, value) {
1061
+ if (isUndefined(value))
1062
+ return ctx.stylize('undefined', 'undefined');
1063
+ if (isString(value)) {
1064
+ var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
1065
+ .replace(/'/g, "\\'")
1066
+ .replace(/\\"/g, '"') + '\'';
1067
+ return ctx.stylize(simple, 'string');
1111
1068
  }
1069
+ if (isNumber(value))
1070
+ return ctx.stylize('' + value, 'number');
1071
+ if (isBoolean(value))
1072
+ return ctx.stylize('' + value, 'boolean');
1073
+ // For some reason typeof null is "object", so special case here.
1074
+ if (isNull(value))
1075
+ return ctx.stylize('null', 'null');
1076
+ }
1112
1077
 
1113
- // At this point the path should be resolved to a full absolute path, but
1114
- // handle relative paths to be safe (might happen when process.cwd() fails)
1115
1078
 
1116
- // Normalize the path
1117
- resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
1118
- return !!p;
1119
- }), !resolvedAbsolute).join('/');
1079
+ function formatError(value) {
1080
+ return '[' + Error.prototype.toString.call(value) + ']';
1081
+ }
1120
1082
 
1121
- return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
1122
- };
1123
1083
 
1124
- // path.normalize(path)
1125
- // posix version
1126
- exports.normalize = function(path) {
1127
- var isAbsolute = exports.isAbsolute(path),
1128
- trailingSlash = substr(path, -1) === '/';
1084
+ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
1085
+ var output = [];
1086
+ for (var i = 0, l = value.length; i < l; ++i) {
1087
+ if (hasOwnProperty(value, String(i))) {
1088
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
1089
+ String(i), true));
1090
+ } else {
1091
+ output.push('');
1092
+ }
1093
+ }
1094
+ keys.forEach(function(key) {
1095
+ if (!key.match(/^\d+$/)) {
1096
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
1097
+ key, true));
1098
+ }
1099
+ });
1100
+ return output;
1101
+ }
1129
1102
 
1130
- // Normalize the path
1131
- path = normalizeArray(filter(path.split('/'), function(p) {
1132
- return !!p;
1133
- }), !isAbsolute).join('/');
1134
1103
 
1135
- if (!path && !isAbsolute) {
1136
- path = '.';
1104
+ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
1105
+ var name, str, desc;
1106
+ desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
1107
+ if (desc.get) {
1108
+ if (desc.set) {
1109
+ str = ctx.stylize('[Getter/Setter]', 'special');
1110
+ } else {
1111
+ str = ctx.stylize('[Getter]', 'special');
1112
+ }
1113
+ } else {
1114
+ if (desc.set) {
1115
+ str = ctx.stylize('[Setter]', 'special');
1116
+ }
1137
1117
  }
1138
- if (path && trailingSlash) {
1139
- path += '/';
1118
+ if (!hasOwnProperty(visibleKeys, key)) {
1119
+ name = '[' + key + ']';
1140
1120
  }
1141
-
1142
- return (isAbsolute ? '/' : '') + path;
1143
- };
1144
-
1145
- // posix version
1146
- exports.isAbsolute = function(path) {
1147
- return path.charAt(0) === '/';
1148
- };
1149
-
1150
- // posix version
1151
- exports.join = function() {
1152
- var paths = Array.prototype.slice.call(arguments, 0);
1153
- return exports.normalize(filter(paths, function(p, index) {
1154
- if (typeof p !== 'string') {
1155
- throw new TypeError('Arguments to path.join must be strings');
1121
+ if (!str) {
1122
+ if (ctx.seen.indexOf(desc.value) < 0) {
1123
+ if (isNull(recurseTimes)) {
1124
+ str = formatValue(ctx, desc.value, null);
1125
+ } else {
1126
+ str = formatValue(ctx, desc.value, recurseTimes - 1);
1127
+ }
1128
+ if (str.indexOf('\n') > -1) {
1129
+ if (array) {
1130
+ str = str.split('\n').map(function(line) {
1131
+ return ' ' + line;
1132
+ }).join('\n').substr(2);
1133
+ } else {
1134
+ str = '\n' + str.split('\n').map(function(line) {
1135
+ return ' ' + line;
1136
+ }).join('\n');
1137
+ }
1138
+ }
1139
+ } else {
1140
+ str = ctx.stylize('[Circular]', 'special');
1156
1141
  }
1157
- return p;
1158
- }).join('/'));
1159
- };
1160
-
1142
+ }
1143
+ if (isUndefined(name)) {
1144
+ if (array && key.match(/^\d+$/)) {
1145
+ return str;
1146
+ }
1147
+ name = JSON.stringify('' + key);
1148
+ if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
1149
+ name = name.substr(1, name.length - 2);
1150
+ name = ctx.stylize(name, 'name');
1151
+ } else {
1152
+ name = name.replace(/'/g, "\\'")
1153
+ .replace(/\\"/g, '"')
1154
+ .replace(/(^"|"$)/g, "'");
1155
+ name = ctx.stylize(name, 'string');
1156
+ }
1157
+ }
1161
1158
 
1162
- // path.relative(from, to)
1163
- // posix version
1164
- exports.relative = function(from, to) {
1165
- from = exports.resolve(from).substr(1);
1166
- to = exports.resolve(to).substr(1);
1159
+ return name + ': ' + str;
1160
+ }
1167
1161
 
1168
- function trim(arr) {
1169
- var start = 0;
1170
- for (; start < arr.length; start++) {
1171
- if (arr[start] !== '') break;
1172
- }
1173
1162
 
1174
- var end = arr.length - 1;
1175
- for (; end >= 0; end--) {
1176
- if (arr[end] !== '') break;
1177
- }
1163
+ function reduceToSingleString(output, base, braces) {
1164
+ var numLinesEst = 0;
1165
+ var length = output.reduce(function(prev, cur) {
1166
+ numLinesEst++;
1167
+ if (cur.indexOf('\n') >= 0) numLinesEst++;
1168
+ return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
1169
+ }, 0);
1178
1170
 
1179
- if (start > end) return [];
1180
- return arr.slice(start, end - start + 1);
1171
+ if (length > 60) {
1172
+ return braces[0] +
1173
+ (base === '' ? '' : base + '\n ') +
1174
+ ' ' +
1175
+ output.join(',\n ') +
1176
+ ' ' +
1177
+ braces[1];
1181
1178
  }
1182
1179
 
1183
- var fromParts = trim(from.split('/'));
1184
- var toParts = trim(to.split('/'));
1180
+ return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
1181
+ }
1185
1182
 
1186
- var length = Math.min(fromParts.length, toParts.length);
1187
- var samePartsLength = length;
1188
- for (var i = 0; i < length; i++) {
1189
- if (fromParts[i] !== toParts[i]) {
1190
- samePartsLength = i;
1191
- break;
1192
- }
1193
- }
1194
1183
 
1195
- var outputParts = [];
1196
- for (var i = samePartsLength; i < fromParts.length; i++) {
1197
- outputParts.push('..');
1198
- }
1184
+ // NOTE: These type checking functions intentionally don't use `instanceof`
1185
+ // because it is fragile and can be easily faked with `Object.create()`.
1186
+ function isArray(ar) {
1187
+ return Array.isArray(ar);
1188
+ }
1189
+ exports.isArray = isArray;
1199
1190
 
1200
- outputParts = outputParts.concat(toParts.slice(samePartsLength));
1191
+ function isBoolean(arg) {
1192
+ return typeof arg === 'boolean';
1193
+ }
1194
+ exports.isBoolean = isBoolean;
1201
1195
 
1202
- return outputParts.join('/');
1203
- };
1196
+ function isNull(arg) {
1197
+ return arg === null;
1198
+ }
1199
+ exports.isNull = isNull;
1204
1200
 
1205
- exports.sep = '/';
1206
- exports.delimiter = ':';
1201
+ function isNullOrUndefined(arg) {
1202
+ return arg == null;
1203
+ }
1204
+ exports.isNullOrUndefined = isNullOrUndefined;
1207
1205
 
1208
- exports.dirname = function(path) {
1209
- var result = splitPath(path),
1210
- root = result[0],
1211
- dir = result[1];
1206
+ function isNumber(arg) {
1207
+ return typeof arg === 'number';
1208
+ }
1209
+ exports.isNumber = isNumber;
1212
1210
 
1213
- if (!root && !dir) {
1214
- // No dirname whatsoever
1215
- return '.';
1216
- }
1211
+ function isString(arg) {
1212
+ return typeof arg === 'string';
1213
+ }
1214
+ exports.isString = isString;
1217
1215
 
1218
- if (dir) {
1219
- // It has a dirname, strip trailing slash
1220
- dir = dir.substr(0, dir.length - 1);
1221
- }
1216
+ function isSymbol(arg) {
1217
+ return typeof arg === 'symbol';
1218
+ }
1219
+ exports.isSymbol = isSymbol;
1222
1220
 
1223
- return root + dir;
1224
- };
1221
+ function isUndefined(arg) {
1222
+ return arg === void 0;
1223
+ }
1224
+ exports.isUndefined = isUndefined;
1225
1225
 
1226
+ function isRegExp(re) {
1227
+ return isObject(re) && objectToString(re) === '[object RegExp]';
1228
+ }
1229
+ exports.isRegExp = isRegExp;
1226
1230
 
1227
- exports.basename = function(path, ext) {
1228
- var f = splitPath(path)[2];
1229
- // TODO: make this comparison case-insensitive on windows?
1230
- if (ext && f.substr(-1 * ext.length) === ext) {
1231
- f = f.substr(0, f.length - ext.length);
1232
- }
1233
- return f;
1234
- };
1231
+ function isObject(arg) {
1232
+ return typeof arg === 'object' && arg !== null;
1233
+ }
1234
+ exports.isObject = isObject;
1235
+
1236
+ function isDate(d) {
1237
+ return isObject(d) && objectToString(d) === '[object Date]';
1238
+ }
1239
+ exports.isDate = isDate;
1235
1240
 
1241
+ function isError(e) {
1242
+ return isObject(e) &&
1243
+ (objectToString(e) === '[object Error]' || e instanceof Error);
1244
+ }
1245
+ exports.isError = isError;
1236
1246
 
1237
- exports.extname = function(path) {
1238
- return splitPath(path)[3];
1239
- };
1247
+ function isFunction(arg) {
1248
+ return typeof arg === 'function';
1249
+ }
1250
+ exports.isFunction = isFunction;
1240
1251
 
1241
- function filter (xs, f) {
1242
- if (xs.filter) return xs.filter(f);
1243
- var res = [];
1244
- for (var i = 0; i < xs.length; i++) {
1245
- if (f(xs[i], i, xs)) res.push(xs[i]);
1246
- }
1247
- return res;
1252
+ function isPrimitive(arg) {
1253
+ return arg === null ||
1254
+ typeof arg === 'boolean' ||
1255
+ typeof arg === 'number' ||
1256
+ typeof arg === 'string' ||
1257
+ typeof arg === 'symbol' || // ES6 symbol
1258
+ typeof arg === 'undefined';
1248
1259
  }
1260
+ exports.isPrimitive = isPrimitive;
1249
1261
 
1250
- // String.prototype.substr - negative index don't work in IE8
1251
- var substr = 'ab'.substr(-1) === 'b'
1252
- ? function (str, start, len) { return str.substr(start, len) }
1253
- : function (str, start, len) {
1254
- if (start < 0) start = str.length + start;
1255
- return str.substr(start, len);
1256
- }
1257
- ;
1262
+ exports.isBuffer = require('./support/isBuffer');
1258
1263
 
1259
- }).call(this,require('_process'))
1260
- },{"_process":7}],7:[function(require,module,exports){
1261
- // shim for using process in browser
1264
+ function objectToString(o) {
1265
+ return Object.prototype.toString.call(o);
1266
+ }
1262
1267
 
1263
- var process = module.exports = {};
1264
1268
 
1265
- process.nextTick = (function () {
1266
- var canSetImmediate = typeof window !== 'undefined'
1267
- && window.setImmediate;
1268
- var canPost = typeof window !== 'undefined'
1269
- && window.postMessage && window.addEventListener
1270
- ;
1269
+ function pad(n) {
1270
+ return n < 10 ? '0' + n.toString(10) : n.toString(10);
1271
+ }
1271
1272
 
1272
- if (canSetImmediate) {
1273
- return function (f) { return window.setImmediate(f) };
1274
- }
1275
1273
 
1276
- if (canPost) {
1277
- var queue = [];
1278
- window.addEventListener('message', function (ev) {
1279
- var source = ev.source;
1280
- if ((source === window || source === null) && ev.data === 'process-tick') {
1281
- ev.stopPropagation();
1282
- if (queue.length > 0) {
1283
- var fn = queue.shift();
1284
- fn();
1285
- }
1286
- }
1287
- }, true);
1274
+ var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
1275
+ 'Oct', 'Nov', 'Dec'];
1288
1276
 
1289
- return function nextTick(fn) {
1290
- queue.push(fn);
1291
- window.postMessage('process-tick', '*');
1292
- };
1293
- }
1277
+ // 26 Feb 16:19:34
1278
+ function timestamp() {
1279
+ var d = new Date();
1280
+ var time = [pad(d.getHours()),
1281
+ pad(d.getMinutes()),
1282
+ pad(d.getSeconds())].join(':');
1283
+ return [d.getDate(), months[d.getMonth()], time].join(' ');
1284
+ }
1294
1285
 
1295
- return function nextTick(fn) {
1296
- setTimeout(fn, 0);
1297
- };
1298
- })();
1299
1286
 
1300
- process.title = 'browser';
1301
- process.browser = true;
1302
- process.env = {};
1303
- process.argv = [];
1287
+ // log is just a thin wrapper to console.log that prepends a timestamp
1288
+ exports.log = function() {
1289
+ console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
1290
+ };
1304
1291
 
1305
- function noop() {}
1306
1292
 
1307
- process.on = noop;
1308
- process.addListener = noop;
1309
- process.once = noop;
1310
- process.off = noop;
1311
- process.removeListener = noop;
1312
- process.removeAllListeners = noop;
1313
- process.emit = noop;
1293
+ /**
1294
+ * Inherit the prototype methods from one constructor into another.
1295
+ *
1296
+ * The Function.prototype.inherits from lang.js rewritten as a standalone
1297
+ * function (not on Function.prototype). NOTE: If this file is to be loaded
1298
+ * during bootstrapping this function needs to be rewritten using some native
1299
+ * functions as prototype setup using normal JavaScript does not work as
1300
+ * expected during bootstrapping (see mirror.js in r114903).
1301
+ *
1302
+ * @param {function} ctor Constructor function which needs to inherit the
1303
+ * prototype.
1304
+ * @param {function} superCtor Constructor function to inherit prototype from.
1305
+ */
1306
+ exports.inherits = require('inherits');
1314
1307
 
1315
- process.binding = function (name) {
1316
- throw new Error('process.binding is not supported');
1317
- }
1308
+ exports._extend = function(origin, add) {
1309
+ // Don't do anything if add isn't an object
1310
+ if (!add || !isObject(add)) return origin;
1318
1311
 
1319
- // TODO(shtylman)
1320
- process.cwd = function () { return '/' };
1321
- process.chdir = function (dir) {
1322
- throw new Error('process.chdir is not supported');
1312
+ var keys = Object.keys(add);
1313
+ var i = keys.length;
1314
+ while (i--) {
1315
+ origin[keys[i]] = add[keys[i]];
1316
+ }
1317
+ return origin;
1323
1318
  };
1324
1319
 
1325
- },{}],8:[function(require,module,exports){
1320
+ function hasOwnProperty(obj, prop) {
1321
+ return Object.prototype.hasOwnProperty.call(obj, prop);
1322
+ }
1323
+
1324
+ }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
1325
+ },{"./support/isBuffer":6,"_process":5,"inherits":2}],8:[function(require,module,exports){
1326
1326
  "use strict";
1327
1327
 
1328
1328
  var SourceMapGenerator = require("source-map").SourceMapGenerator;
@@ -1561,6 +1561,7 @@ var ngInject = require("./nginject");
1561
1561
  var generateSourcemap = require("./generate-sourcemap");
1562
1562
  var Lut = require("./lut");
1563
1563
  var scopeTools = require("./scopetools");
1564
+ var stringmap = require("stringmap");
1564
1565
 
1565
1566
  var chainedRouteProvider = 1;
1566
1567
  var chainedUrlRouterProvider = 2;
@@ -1584,23 +1585,32 @@ function match(node, ctx, matchPlugins) {
1584
1585
  }
1585
1586
 
1586
1587
  function matchDirectiveReturnObject(node) {
1588
+ // only matches inside directives
1587
1589
  // return { .. controller: function($scope, $timeout), ...}
1588
1590
 
1589
- return node.type === "ReturnStatement" &&
1591
+ return limit("directive", node.type === "ReturnStatement" &&
1590
1592
  node.argument && node.argument.type === "ObjectExpression" &&
1591
- matchProp("controller", node.argument.properties);
1593
+ matchProp("controller", node.argument.properties));
1594
+ }
1595
+
1596
+ function limit(name, node) {
1597
+ if (node) {
1598
+ node.$limitToMethodName = name;
1599
+ }
1600
+ return node;
1592
1601
  }
1593
1602
 
1594
1603
  function matchProviderGet(node) {
1604
+ // only matches inside providers
1595
1605
  // (this|self|that).$get = function($scope, $timeout)
1596
1606
  // { ... $get: function($scope, $timeout), ...}
1597
1607
  var memberExpr;
1598
1608
  var self;
1599
- return (node.type === "AssignmentExpression" && (memberExpr = node.left).type === "MemberExpression" &&
1609
+ return limit("provider", (node.type === "AssignmentExpression" && (memberExpr = node.left).type === "MemberExpression" &&
1600
1610
  memberExpr.property.name === "$get" &&
1601
1611
  ((self = memberExpr.object).type === "ThisExpression" || (self.type === "Identifier" && is.someof(self.name, ["self", "that"]))) &&
1602
1612
  node.right) ||
1603
- (node.type === "ObjectExpression" && matchProp("$get", node.properties));
1613
+ (node.type === "ObjectExpression" && matchProp("$get", node.properties)));
1604
1614
  }
1605
1615
 
1606
1616
  function matchNgRoute(node) {
@@ -1655,6 +1665,9 @@ function matchNgUi(node) {
1655
1665
  // $stateProvider.state("myState", {... resolve: {f: function($scope) {}, ..} ..})
1656
1666
  // $stateProvider.state("myState", {... views: {... somename: {... controller: fn, controllerProvider: fn, templateProvider: fn, resolve: {f: fn}}}})
1657
1667
  //
1668
+ // stateHelperProvider.setNestedState({ sameasregularstate, children: [sameasregularstate, ..]})
1669
+ // stateHelperProvider.setNestedState({ sameasregularstate, children: [sameasregularstate, ..]}, true)
1670
+ //
1658
1671
  // $urlRouterProvider.when(.., function($scope) {})
1659
1672
  //
1660
1673
  // $modal.open({.. controller: fn, resolve: {f: function($scope) {}, ..}});
@@ -1668,9 +1681,9 @@ function matchNgUi(node) {
1668
1681
  // shortcut for $modal.open({.. controller: fn, resolve: {f: function($scope) {}, ..}});
1669
1682
  if (obj.type === "Identifier" && obj.name === "$modal" && method.name === "open" &&
1670
1683
  args.length === 1 && args[0].type === "ObjectExpression") {
1671
- var props$0 = args[0].properties;
1672
- var res$0 = [matchProp("controller", props$0)];
1673
- res$0.push.apply(res$0, matchResolve(props$0));
1684
+ var props = args[0].properties;
1685
+ var res$0 = [matchProp("controller", props)];
1686
+ res$0.push.apply(res$0, matchResolve(props));
1674
1687
  return res$0.filter(Boolean);
1675
1688
  }
1676
1689
 
@@ -1684,53 +1697,76 @@ function matchNgUi(node) {
1684
1697
  return false;
1685
1698
  }
1686
1699
 
1687
- // everything below is for $stateProvider alone
1688
- if (!(obj.$chained === chainedStateProvider || (obj.type === "Identifier" && obj.name === "$stateProvider"))) {
1700
+ // everything below is for $stateProvider and stateHelperProvider alone
1701
+ if (!(obj.$chained === chainedStateProvider || (obj.type === "Identifier" && is.someof(obj.name, ["$stateProvider", "stateHelperProvider"])))) {
1689
1702
  return false;
1690
1703
  }
1691
1704
  node.$chained = chainedStateProvider;
1692
1705
 
1693
- if (method.name !== "state") {
1706
+ if (is.noneof(method.name, ["state", "setNestedState"])) {
1694
1707
  return false;
1695
1708
  }
1696
1709
 
1697
1710
  // $stateProvider.state({ ... }) and $stateProvider.state("name", { ... })
1711
+ // stateHelperProvider.setNestedState({ .. }) and stateHelperProvider.setNestedState({ .. }, true)
1698
1712
  if (!(args.length >= 1 && args.length <= 2)) {
1699
1713
  return false;
1700
1714
  }
1701
1715
 
1702
- var configArg = last(args);
1703
- if (configArg.type !== "ObjectExpression") {
1704
- return false;
1705
- }
1706
-
1707
- var props = configArg.properties;
1708
- var res = [
1709
- matchProp("controller", props),
1710
- matchProp("controllerProvider", props),
1711
- matchProp("templateProvider", props),
1712
- matchProp("onEnter", props),
1713
- matchProp("onExit", props),
1714
- ];
1716
+ var configArg = (method.name === "state" ? last(args) : args[0]);
1715
1717
 
1716
- // {resolve: ..}
1717
- res.push.apply(res, matchResolve(props));
1718
+ var res = [];
1718
1719
 
1719
- // {view: ...}
1720
- var viewObject = matchProp("views", props);
1721
- if (viewObject && viewObject.type === "ObjectExpression") {
1722
- viewObject.properties.forEach(function(prop) {
1723
- if (prop.value.type === "ObjectExpression") {
1724
- res.push(matchProp("controller", prop.value.properties));
1725
- res.push(matchProp("controllerProvider", prop.value.properties));
1726
- res.push(matchProp("templateProvider", prop.value.properties));
1727
- res.push.apply(res, matchResolve(prop.value.properties));
1728
- }
1729
- });
1730
- }
1720
+ recursiveMatch(configArg);
1731
1721
 
1732
1722
  var filteredRes = res.filter(Boolean);
1733
1723
  return (filteredRes.length === 0 ? false : filteredRes);
1724
+
1725
+
1726
+ function recursiveMatch(objectExpressionNode) {
1727
+ if (!objectExpressionNode || objectExpressionNode.type !== "ObjectExpression") {
1728
+ return false;
1729
+ }
1730
+
1731
+ var properties = objectExpressionNode.properties;
1732
+
1733
+ matchStateProps(properties, res);
1734
+
1735
+ var childrenArrayExpression = matchProp("children", properties);
1736
+ var children = childrenArrayExpression && childrenArrayExpression.elements;
1737
+
1738
+ if (!children) {
1739
+ return;
1740
+ }
1741
+ children.forEach(recursiveMatch);
1742
+ }
1743
+
1744
+ function matchStateProps(props, res) {
1745
+ var simple = [
1746
+ matchProp("controller", props),
1747
+ matchProp("controllerProvider", props),
1748
+ matchProp("templateProvider", props),
1749
+ matchProp("onEnter", props),
1750
+ matchProp("onExit", props),
1751
+ ];
1752
+ res.push.apply(res, simple);
1753
+
1754
+ // {resolve: ..}
1755
+ res.push.apply(res, matchResolve(props));
1756
+
1757
+ // {view: ...}
1758
+ var viewObject = matchProp("views", props);
1759
+ if (viewObject && viewObject.type === "ObjectExpression") {
1760
+ viewObject.properties.forEach(function(prop) {
1761
+ if (prop.value.type === "ObjectExpression") {
1762
+ res.push(matchProp("controller", prop.value.properties));
1763
+ res.push(matchProp("controllerProvider", prop.value.properties));
1764
+ res.push(matchProp("templateProvider", prop.value.properties));
1765
+ res.push.apply(res, matchResolve(prop.value.properties));
1766
+ }
1767
+ });
1768
+ }
1769
+ }
1734
1770
  }
1735
1771
 
1736
1772
  function matchHttpProvider(node) {
@@ -1759,7 +1795,7 @@ function matchRegular(node, ctx) {
1759
1795
  if (obj.name === "angular" && method.name === "module") {
1760
1796
  var args$0 = node.arguments;
1761
1797
  if (args$0.length >= 2) {
1762
- last(args$0).$always = true;
1798
+ node.$chained = chainedRegular;
1763
1799
  return last(args$0);
1764
1800
  }
1765
1801
  }
@@ -1780,8 +1816,12 @@ function matchRegular(node, ctx) {
1780
1816
  args.length === 1 && args[0] :
1781
1817
  args.length === 2 && args[0].type === "Literal" && is.string(args[0].value) && args[1]);
1782
1818
 
1783
- if (target) {
1784
- target.$always = true;
1819
+ target.$methodName = method.name;
1820
+
1821
+ if (ctx.rename && args.length === 2 && target) {
1822
+ // for eventual rename purposes
1823
+ var somethingNameLiteral = args[0];
1824
+ return [somethingNameLiteral, target];
1785
1825
  }
1786
1826
  return target;
1787
1827
  }
@@ -1826,16 +1866,23 @@ function matchResolve(props) {
1826
1866
  return [];
1827
1867
  };
1828
1868
 
1829
- function stringify(arr, quot) {
1869
+ function renamedString(ctx, originalString) {
1870
+ if (ctx.rename) {
1871
+ return ctx.rename.get(originalString) || originalString;
1872
+ }
1873
+ return originalString;
1874
+ }
1875
+
1876
+ function stringify(ctx, arr, quot) {
1830
1877
  return "[" + arr.map(function(arg) {
1831
- return quot + arg.name + quot;
1878
+ return quot + renamedString(ctx, arg.name) + quot;
1832
1879
  }).join(", ") + "]";
1833
1880
  }
1834
1881
 
1835
- function insertArray(functionExpression, fragments, quot) {
1882
+ function insertArray(ctx, functionExpression, fragments, quot) {
1836
1883
  var range = functionExpression.range;
1837
1884
 
1838
- var args = stringify(functionExpression.params, quot);
1885
+ var args = stringify(ctx, functionExpression.params, quot);
1839
1886
  fragments.push({
1840
1887
  start: range[0],
1841
1888
  end: range[0],
@@ -1848,13 +1895,14 @@ function insertArray(functionExpression, fragments, quot) {
1848
1895
  });
1849
1896
  }
1850
1897
 
1851
- function replaceArray(array, fragments, quot) {
1898
+ function replaceArray(ctx, array, fragments, quot) {
1852
1899
  var functionExpression = last(array.elements);
1853
1900
 
1854
1901
  if (functionExpression.params.length === 0) {
1855
1902
  return removeArray(array, fragments);
1856
1903
  }
1857
- var args = stringify(functionExpression.params, quot);
1904
+
1905
+ var args = stringify(ctx, functionExpression.params, quot);
1858
1906
  fragments.push({
1859
1907
  start: array.range[0],
1860
1908
  end: functionExpression.range[0],
@@ -1877,49 +1925,128 @@ function removeArray(array, fragments) {
1877
1925
  });
1878
1926
  }
1879
1927
 
1928
+ function renameProviderDeclarationSite(ctx, literalNode, fragments) {
1929
+ fragments.push({
1930
+ start: literalNode.range[0] + 1,
1931
+ end: literalNode.range[1] - 1,
1932
+ str: renamedString(ctx, literalNode.value),
1933
+ });
1934
+ }
1935
+
1880
1936
  function judgeSuspects(ctx) {
1881
- var suspects = ctx.suspects;
1882
1937
  var mode = ctx.mode;
1883
1938
  var fragments = ctx.fragments;
1884
1939
  var quot = ctx.quot;
1885
1940
 
1886
- for (var i = 0; i < suspects.length; i++) {
1887
- var target = suspects[i];
1941
+ var suspects = makeUnique(ctx.suspects, 1);
1888
1942
 
1889
- if (target.$once) {
1890
- continue;
1943
+ for (var n = 0; n < 42; n++) {
1944
+ // could be while(true), above is just a safety-net
1945
+ // in practice it will loop just a couple of times
1946
+ propagateModuleContextAndMethodName(suspects);
1947
+ if (!setChainedAndMethodNameThroughIifesAndReferences(suspects)) {
1948
+ break;
1891
1949
  }
1892
- target.$once = true;
1950
+ }
1893
1951
 
1894
- if (!target.$always) {
1895
- var $caller = target.$caller;
1896
- for (; $caller && $caller.$chained !== chainedRegular; $caller = $caller.$caller) {
1897
- }
1898
- if (!$caller) {
1899
- continue;
1900
- }
1952
+ // create final suspects by jumping, following, uniq'ing
1953
+ var finalSuspects = makeUnique(suspects.map(function(target) {
1954
+ var jumped = jumpOverIife(target);
1955
+ var jumpedAndFollowed = followReference(jumped) || jumped;
1956
+
1957
+ if (target.$limitToMethodName && findOuterMethodName(target) !== target.$limitToMethodName) {
1958
+ return null;
1901
1959
  }
1902
1960
 
1903
- target = jumpOverIife(target);
1904
- var followedTarget = followReference(target);
1905
- if (followedTarget) {
1906
- if (followedTarget.$once) {
1907
- continue;
1908
- }
1909
- followedTarget.$once = true;
1910
- target = followedTarget;
1961
+ return jumpedAndFollowed;
1962
+ }).filter(Boolean), 2);
1963
+
1964
+ finalSuspects.forEach(function(target) {
1965
+ if (target.$chained !== chainedRegular) {
1966
+ return;
1911
1967
  }
1912
1968
 
1913
1969
  if (mode === "rebuild" && isAnnotatedArray(target)) {
1914
- replaceArray(target, fragments, quot);
1970
+ replaceArray(ctx, target, fragments, quot);
1915
1971
  } else if (mode === "remove" && isAnnotatedArray(target)) {
1916
1972
  removeArray(target, fragments);
1917
1973
  } else if (is.someof(mode, ["add", "rebuild"]) && isFunctionExpressionWithArgs(target)) {
1918
- insertArray(target, fragments, quot);
1974
+ insertArray(ctx, target, fragments, quot);
1975
+ } else if (isGenericProviderName(target)) {
1976
+ renameProviderDeclarationSite(ctx, target, fragments);
1919
1977
  } else {
1920
1978
  // if it's not array or function-expression, then it's a candidate for foo.$inject = [..]
1921
1979
  judgeInjectArraySuspect(target, ctx);
1922
1980
  }
1981
+ });
1982
+
1983
+
1984
+ function propagateModuleContextAndMethodName(suspects) {
1985
+ suspects.forEach(function(target) {
1986
+ if (target.$chained !== chainedRegular && isInsideModuleContext(target)) {
1987
+ target.$chained = chainedRegular;
1988
+ }
1989
+
1990
+ if (!target.$methodName) {
1991
+ var methodName = findOuterMethodName(target);
1992
+ if (methodName) {
1993
+ target.$methodName = methodName;
1994
+ }
1995
+ }
1996
+ });
1997
+ }
1998
+
1999
+ function findOuterMethodName(node) {
2000
+ for (; node && !node.$methodName; node = node.$parent) {
2001
+ }
2002
+ return node ? node.$methodName : null;
2003
+ }
2004
+
2005
+ function setChainedAndMethodNameThroughIifesAndReferences(suspects) {
2006
+ var modified = false;
2007
+ suspects.forEach(function(target) {
2008
+ var jumped = jumpOverIife(target);
2009
+ if (jumped !== target) { // we did skip an IIFE
2010
+ if (target.$chained === chainedRegular && jumped.$chained !== chainedRegular) {
2011
+ modified = true;
2012
+ jumped.$chained = chainedRegular;
2013
+ }
2014
+ if (target.$methodName && !jumped.$methodName) {
2015
+ modified = true;
2016
+ jumped.$methodName = target.$methodName;
2017
+ }
2018
+ }
2019
+
2020
+ var jumpedAndFollowed = followReference(jumped) || jumped;
2021
+ if (jumpedAndFollowed !== jumped) { // we did follow a reference
2022
+ if (jumped.$chained === chainedRegular && jumpedAndFollowed.$chained !== chainedRegular) {
2023
+ modified = true;
2024
+ jumpedAndFollowed.$chained = chainedRegular;
2025
+ }
2026
+ if (jumped.$methodName && !jumpedAndFollowed.$methodName) {
2027
+ modified = true;
2028
+ jumpedAndFollowed.$methodName = jumped.$methodName;
2029
+ }
2030
+ }
2031
+ });
2032
+ return modified;
2033
+ }
2034
+
2035
+ function isInsideModuleContext(node) {
2036
+ var $parent = node.$parent;
2037
+ for (; $parent && $parent.$chained !== chainedRegular; $parent = $parent.$parent) {
2038
+ }
2039
+ return Boolean($parent);
2040
+ }
2041
+
2042
+ function makeUnique(suspects, val) {
2043
+ return suspects.filter(function(target) {
2044
+ if (target.$seen === val) {
2045
+ return false;
2046
+ }
2047
+ target.$seen = val;
2048
+ return true;
2049
+ });
1923
2050
  }
1924
2051
  }
1925
2052
 
@@ -1950,10 +2077,36 @@ function followReference(node) {
1950
2077
  return null;
1951
2078
  }
1952
2079
 
2080
+ // O(srclength) so should only be used for debugging purposes, else replace with lut
2081
+ function posToLine(pos, src) {
2082
+ if (pos >= src.length) {
2083
+ pos = src.length - 1;
2084
+ }
2085
+
2086
+ if (pos <= -1) {
2087
+ return -1;
2088
+ }
2089
+
2090
+ var line = 1;
2091
+ for (var i = 0; i < pos; i++) {
2092
+ if (src[i] === "\n") {
2093
+ ++line;
2094
+ }
2095
+ }
2096
+
2097
+ return line;
2098
+ }
2099
+
1953
2100
  function judgeInjectArraySuspect(node, ctx) {
1954
2101
  // /*@ngInject*/ var foo = function($scope) {} and
1955
2102
  // /*@ngInject*/ function foo($scope) {} and
1956
2103
  // /*@ngInject*/ foo.bar[0] = function($scope) {}
2104
+
2105
+ // suspect must be inside of a block or at the top-level (i.e. inside of node.$parent.body[])
2106
+ if (!node.$parent || is.noneof(node.$parent.type, ["Program", "BlockStatement"])) {
2107
+ return;
2108
+ }
2109
+
1957
2110
  var d0 = null;
1958
2111
  var nr0 = node.range[0];
1959
2112
  var nr1 = node.range[1];
@@ -1979,11 +2132,38 @@ function judgeInjectArraySuspect(node, ctx) {
1979
2132
  return src.slice(lineStart, i);
1980
2133
  }
1981
2134
 
1982
- function addRemoveInjectArray(params, posBeforeFunctionDeclaration, posAfterFunctionDeclaration, name) {
2135
+ function addRemoveInjectArray(params, posAtFunctionDeclaration, posAfterFunctionDeclaration, name) {
2136
+ // if an existing something.$inject = [..] exists then is will always be recycled when rebuilding
2137
+
1983
2138
  var indent = getIndent(posAfterFunctionDeclaration);
1984
2139
 
1985
- var nextNode = ctx.lut.findNodeFromPos(posAfterFunctionDeclaration);
1986
- var prevNode = ctx.lut.findNodeBeforePos(posBeforeFunctionDeclaration);
2140
+ var foundSuspectInBody = false;
2141
+ var existingExpressionStatementWithArray = null;
2142
+ var troublesomeReturn = false;
2143
+ node.$parent.body.forEach(function(bnode) {
2144
+ if (bnode === node) {
2145
+ foundSuspectInBody = true;
2146
+ }
2147
+
2148
+ if (hasInjectArray(bnode)) {
2149
+ if (existingExpressionStatementWithArray) {
2150
+ throw fmt("conflicting inject arrays at line {0} and {1}",
2151
+ posToLine(existingExpressionStatementWithArray.range[0], ctx.src),
2152
+ posToLine(bnode.range[0], ctx.src));
2153
+ }
2154
+ existingExpressionStatementWithArray = bnode;
2155
+ }
2156
+
2157
+ // there's a return statement before our function
2158
+ if (!foundSuspectInBody && bnode.type === "ReturnStatement") {
2159
+ troublesomeReturn = bnode;
2160
+ }
2161
+ });
2162
+ assert(foundSuspectInBody);
2163
+
2164
+ if (troublesomeReturn && !existingExpressionStatementWithArray) {
2165
+ posAfterFunctionDeclaration = skipPrevNewline(troublesomeReturn.range[0]);
2166
+ }
1987
2167
 
1988
2168
  function hasInjectArray(node) {
1989
2169
  var lvalue;
@@ -2004,28 +2184,37 @@ function judgeInjectArraySuspect(node, ctx) {
2004
2184
  return pos;
2005
2185
  }
2006
2186
 
2007
- var hasArrayBefore = hasInjectArray(prevNode);
2008
- var hasArrayAfter = hasInjectArray(nextNode);
2187
+ function skipPrevNewline(pos) {
2188
+ var prevLF = ctx.src.lastIndexOf("\n", pos);
2189
+ if (prevLF === -1) {
2190
+ return pos;
2191
+ }
2192
+ if (prevLF >= 1 && ctx.src[prevLF] === "\r") {
2193
+ --prevLF;
2194
+ }
2195
+
2196
+ if (/\S/g.test(ctx.src.slice(prevLF, pos - 1))) {
2197
+ return pos;
2198
+ }
2009
2199
 
2010
- var hasArray = hasArrayBefore || hasArrayAfter;
2011
- var start = hasArrayBefore ? prevNode.range[0]: posAfterFunctionDeclaration;
2012
- var end = hasArrayBefore ? skipNewline(prevNode.range[1]) : nextNode.range[1];
2200
+ return prevLF;
2201
+ }
2013
2202
 
2014
- var str = fmt("{0}{1}{2}.$inject = {3};", EOL, indent, name, ctx.stringify(params, ctx.quot));
2203
+ var str = fmt("{0}{1}{2}.$inject = {3};", EOL, indent, name, ctx.stringify(ctx, params, ctx.quot));
2015
2204
 
2016
- if (ctx.mode === "rebuild" && hasArray) {
2205
+ if (ctx.mode === "rebuild" && existingExpressionStatementWithArray) {
2017
2206
  ctx.fragments.push({
2018
- start: start,
2019
- end: end,
2207
+ start: existingExpressionStatementWithArray.range[0],
2208
+ end: existingExpressionStatementWithArray.range[1],
2020
2209
  str: str,
2021
2210
  });
2022
- } else if (ctx.mode === "remove" && hasArray) {
2211
+ } else if (ctx.mode === "remove" && existingExpressionStatementWithArray) {
2023
2212
  ctx.fragments.push({
2024
- start: start,
2025
- end: end,
2213
+ start: skipPrevNewline(existingExpressionStatementWithArray.range[0]),
2214
+ end: existingExpressionStatementWithArray.range[1],
2026
2215
  str: "",
2027
2216
  });
2028
- } else if (is.someof(ctx.mode, ["add", "rebuild"]) && !hasArray) {
2217
+ } else if (is.someof(ctx.mode, ["add", "rebuild"]) && !existingExpressionStatementWithArray) {
2029
2218
  ctx.fragments.push({
2030
2219
  start: posAfterFunctionDeclaration,
2031
2220
  end: posAfterFunctionDeclaration,
@@ -2052,7 +2241,7 @@ function addModuleContextDependentSuspect(target, ctx) {
2052
2241
  }
2053
2242
 
2054
2243
  function addModuleContextIndependentSuspect(target, ctx) {
2055
- target.$always = true;
2244
+ target.$chained = chainedRegular;
2056
2245
  ctx.suspects.push(target);
2057
2246
  }
2058
2247
 
@@ -2065,6 +2254,9 @@ function isFunctionExpressionWithArgs(node) {
2065
2254
  function isFunctionDeclarationWithArgs(node) {
2066
2255
  return node.type === "FunctionDeclaration" && node.params.length >= 1;
2067
2256
  }
2257
+ function isGenericProviderName(node) {
2258
+ return node.type === "Literal" && is.string(node.value);
2259
+ }
2068
2260
 
2069
2261
  window.annotate = function ngAnnotate(src, options) {
2070
2262
  var mode = (options.add && options.remove ? "rebuild" :
@@ -2077,6 +2269,12 @@ window.annotate = function ngAnnotate(src, options) {
2077
2269
 
2078
2270
  var quot = options.single_quotes ? "'" : '"';
2079
2271
  var re = (options.regexp ? new RegExp(options.regexp) : /^[a-zA-Z0-9_\$\.\s]+$/);
2272
+ var rename = new stringmap();
2273
+ if (options.rename) {
2274
+ options.rename.forEach(function(value) {
2275
+ rename.set(value.from, value.to);
2276
+ });
2277
+ }
2080
2278
  var ast;
2081
2279
  var stats = {};
2082
2280
  try {
@@ -2118,8 +2316,7 @@ window.annotate = function ngAnnotate(src, options) {
2118
2316
  // A suspect node will get annotations added / removed if it
2119
2317
  // fulfills the arrayexpression or functionexpression look,
2120
2318
  // and if it is in the correct context (inside an angular
2121
- // module definition) - alternatively is forced to ignore
2122
- // context with node.$always = true
2319
+ // module definition)
2123
2320
  var suspects = [];
2124
2321
 
2125
2322
  var lut = new Lut(ast, src);
@@ -2134,6 +2331,7 @@ window.annotate = function ngAnnotate(src, options) {
2134
2331
  return src.slice(range[0], range[1]);
2135
2332
  },
2136
2333
  re: re,
2334
+ rename: rename,
2137
2335
  comments: comments,
2138
2336
  fragments: fragments,
2139
2337
  suspects: suspects,
@@ -2163,22 +2361,12 @@ window.annotate = function ngAnnotate(src, options) {
2163
2361
  plugin.init(ctx);
2164
2362
  });
2165
2363
 
2166
- var recentCaller = undefined; // micro-optimization
2167
- var callerIds = [];
2168
2364
  traverse(ast, {pre: function(node) {
2169
- node.$caller = recentCaller;
2170
2365
  if (node.type === "CallExpression") {
2171
- callerIds.push(node);
2172
- recentCaller = node;
2173
2366
  ngInject.inspectCallExpression(node, ctx);
2174
2367
  }
2175
2368
 
2176
2369
  }, post: function(node) {
2177
- if (node === recentCaller) {
2178
- callerIds.pop();
2179
- recentCaller = last(callerIds);
2180
- }
2181
-
2182
2370
  var targets = match(node, ctx, matchPluginsOrNull);
2183
2371
  if (!targets) {
2184
2372
  return;
@@ -2192,7 +2380,13 @@ window.annotate = function ngAnnotate(src, options) {
2192
2380
  }
2193
2381
  }});
2194
2382
 
2195
- judgeSuspects(ctx);
2383
+ try {
2384
+ judgeSuspects(ctx);
2385
+ } catch(e) {
2386
+ return {
2387
+ errors: ["error: " + e],
2388
+ };
2389
+ }
2196
2390
 
2197
2391
  var out = alter(src, fragments);
2198
2392
  var result = {
@@ -2209,7 +2403,7 @@ window.annotate = function ngAnnotate(src, options) {
2209
2403
  return result;
2210
2404
  }
2211
2405
 
2212
- },{"./generate-sourcemap":8,"./lut":9,"./nginject":11,"./scopetools":13,"alter":14,"assert":1,"esprima":15,"ordered-ast-traverse":17,"os":5,"simple-fmt":18,"simple-is":19}],11:[function(require,module,exports){
2406
+ },{"./generate-sourcemap":8,"./lut":9,"./nginject":11,"./scopetools":13,"alter":14,"assert":1,"esprima":15,"ordered-ast-traverse":17,"os":3,"simple-fmt":18,"simple-is":19,"stringmap":31}],11:[function(require,module,exports){
2213
2407
  // nginject-comments.js
2214
2408
  // MIT licensed, see LICENSE file
2215
2409
  // Copyright (c) 2013-2014 Olov Lassus <olov.lassus@gmail.com>
@@ -7672,7 +7866,7 @@ define(function (require, exports, module) {
7672
7866
  this._sourcesContents = {};
7673
7867
  }
7674
7868
  this._sourcesContents[util.toSetString(source)] = aSourceContent;
7675
- } else {
7869
+ } else if (this._sourcesContents) {
7676
7870
  // Remove the source file from the _sourcesContents map.
7677
7871
  // If the _sourcesContents map is empty, set the property to null.
7678
7872
  delete this._sourcesContents[util.toSetString(source)];
@@ -8972,7 +9166,7 @@ function amdefine(module, requireFn) {
8972
9166
  module.exports = amdefine;
8973
9167
 
8974
9168
  }).call(this,require('_process'),"/node_modules/ng-annotate/node_modules/source-map/node_modules/amdefine/amdefine.js")
8975
- },{"_process":7,"path":6}],30:[function(require,module,exports){
9169
+ },{"_process":5,"path":4}],30:[function(require,module,exports){
8976
9170
  //! stable.js 0.1.5, https://github.com/Two-Screen/stable
8977
9171
  //! © 2014 Angry Bytes and contributors. MIT licensed.
8978
9172