ngannotate-rails 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b20b739c3e3030db5fc4395a6a6da23f276ef70
4
- data.tar.gz: 35c93f520f66479af352d0598c47de066ebe5c2e
3
+ metadata.gz: 12cefe78e395a67fad3ac0548108d5c62ea21bb7
4
+ data.tar.gz: b2c747b404ed9335e95d2396610b19839aa39f10
5
5
  SHA512:
6
- metadata.gz: 8e5613df37f327ef44ae601650a71c88cef6aa7617805e4fba78062be0bde33f264389d02dae4e4e70b79fa9ffd570d8aaf9183bcb4f2769eff5f3583545a0db
7
- data.tar.gz: 6b4b6bc7939dd8423538c2df551fbf7f16b9419398a7d0608f563a9c64bc6c7d608b75926d90aaa96384768cc8813d7f4dee501e1ab166c77437ee43a8eeacb9
6
+ metadata.gz: d7e6d415071b07a4be20bfaea6bd33c8fb6e05066184624426a9aadda79a381a39cdef06f688a5fe5607fda288c2f280404f36a4072be69938e9aea1353638dd
7
+ data.tar.gz: f944f5aa7ae8cb120db850f3e3441626d46ecb5f101f1c5ccd35946845522680650a7e8c7957a28000189ad099c8c2799a4baeae90acac6b7ecc2d0cfb640b17
@@ -1,5 +1,5 @@
1
1
  module Ngannotate
2
2
  module Rails
3
- VERSION = "0.13.0"
3
+ VERSION = "0.14.0"
4
4
  end
5
5
  end
data/vendor/ngannotate.js CHANGED
@@ -1,4 +1,6 @@
1
1
  (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(require,module,exports){
2
+
3
+ },{}],2:[function(require,module,exports){
2
4
  // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
3
5
  //
4
6
  // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
@@ -360,7 +362,1303 @@ var objectKeys = Object.keys || function (obj) {
360
362
  return keys;
361
363
  };
362
364
 
363
- },{"util/":7}],2:[function(require,module,exports){
365
+ },{"util/":12}],3:[function(require,module,exports){
366
+ /*!
367
+ * The buffer module from node.js, for the browser.
368
+ *
369
+ * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
370
+ * @license MIT
371
+ */
372
+
373
+ var base64 = require('base64-js')
374
+ var ieee754 = require('ieee754')
375
+ var isArray = require('is-array')
376
+
377
+ exports.Buffer = Buffer
378
+ exports.SlowBuffer = Buffer
379
+ exports.INSPECT_MAX_BYTES = 50
380
+ Buffer.poolSize = 8192 // not used by this implementation
381
+
382
+ var kMaxLength = 0x3fffffff
383
+
384
+ /**
385
+ * If `Buffer.TYPED_ARRAY_SUPPORT`:
386
+ * === true Use Uint8Array implementation (fastest)
387
+ * === false Use Object implementation (most compatible, even IE6)
388
+ *
389
+ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
390
+ * Opera 11.6+, iOS 4.2+.
391
+ *
392
+ * Note:
393
+ *
394
+ * - Implementation must support adding new properties to `Uint8Array` instances.
395
+ * Firefox 4-29 lacked support, fixed in Firefox 30+.
396
+ * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
397
+ *
398
+ * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
399
+ *
400
+ * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
401
+ * incorrect length in some situations.
402
+ *
403
+ * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they will
404
+ * get the Object implementation, which is slower but will work correctly.
405
+ */
406
+ Buffer.TYPED_ARRAY_SUPPORT = (function () {
407
+ try {
408
+ var buf = new ArrayBuffer(0)
409
+ var arr = new Uint8Array(buf)
410
+ arr.foo = function () { return 42 }
411
+ return 42 === arr.foo() && // typed array instances can be augmented
412
+ typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
413
+ new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
414
+ } catch (e) {
415
+ return false
416
+ }
417
+ })()
418
+
419
+ /**
420
+ * Class: Buffer
421
+ * =============
422
+ *
423
+ * The Buffer constructor returns instances of `Uint8Array` that are augmented
424
+ * with function properties for all the node `Buffer` API functions. We use
425
+ * `Uint8Array` so that square bracket notation works as expected -- it returns
426
+ * a single octet.
427
+ *
428
+ * By augmenting the instances, we can avoid modifying the `Uint8Array`
429
+ * prototype.
430
+ */
431
+ function Buffer (subject, encoding, noZero) {
432
+ if (!(this instanceof Buffer))
433
+ return new Buffer(subject, encoding, noZero)
434
+
435
+ var type = typeof subject
436
+
437
+ // Find the length
438
+ var length
439
+ if (type === 'number')
440
+ length = subject > 0 ? subject >>> 0 : 0
441
+ else if (type === 'string') {
442
+ if (encoding === 'base64')
443
+ subject = base64clean(subject)
444
+ length = Buffer.byteLength(subject, encoding)
445
+ } else if (type === 'object' && subject !== null) { // assume object is array-like
446
+ if (subject.type === 'Buffer' && isArray(subject.data))
447
+ subject = subject.data
448
+ length = +subject.length > 0 ? Math.floor(+subject.length) : 0
449
+ } else
450
+ throw new TypeError('must start with number, buffer, array or string')
451
+
452
+ if (this.length > kMaxLength)
453
+ throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
454
+ 'size: 0x' + kMaxLength.toString(16) + ' bytes')
455
+
456
+ var buf
457
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
458
+ // Preferred: Return an augmented `Uint8Array` instance for best performance
459
+ buf = Buffer._augment(new Uint8Array(length))
460
+ } else {
461
+ // Fallback: Return THIS instance of Buffer (created by `new`)
462
+ buf = this
463
+ buf.length = length
464
+ buf._isBuffer = true
465
+ }
466
+
467
+ var i
468
+ if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') {
469
+ // Speed optimization -- use set if we're copying from a typed array
470
+ buf._set(subject)
471
+ } else if (isArrayish(subject)) {
472
+ // Treat array-ish objects as a byte array
473
+ if (Buffer.isBuffer(subject)) {
474
+ for (i = 0; i < length; i++)
475
+ buf[i] = subject.readUInt8(i)
476
+ } else {
477
+ for (i = 0; i < length; i++)
478
+ buf[i] = ((subject[i] % 256) + 256) % 256
479
+ }
480
+ } else if (type === 'string') {
481
+ buf.write(subject, 0, encoding)
482
+ } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT && !noZero) {
483
+ for (i = 0; i < length; i++) {
484
+ buf[i] = 0
485
+ }
486
+ }
487
+
488
+ return buf
489
+ }
490
+
491
+ Buffer.isBuffer = function (b) {
492
+ return !!(b != null && b._isBuffer)
493
+ }
494
+
495
+ Buffer.compare = function (a, b) {
496
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b))
497
+ throw new TypeError('Arguments must be Buffers')
498
+
499
+ var x = a.length
500
+ var y = b.length
501
+ for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {}
502
+ if (i !== len) {
503
+ x = a[i]
504
+ y = b[i]
505
+ }
506
+ if (x < y) return -1
507
+ if (y < x) return 1
508
+ return 0
509
+ }
510
+
511
+ Buffer.isEncoding = function (encoding) {
512
+ switch (String(encoding).toLowerCase()) {
513
+ case 'hex':
514
+ case 'utf8':
515
+ case 'utf-8':
516
+ case 'ascii':
517
+ case 'binary':
518
+ case 'base64':
519
+ case 'raw':
520
+ case 'ucs2':
521
+ case 'ucs-2':
522
+ case 'utf16le':
523
+ case 'utf-16le':
524
+ return true
525
+ default:
526
+ return false
527
+ }
528
+ }
529
+
530
+ Buffer.concat = function (list, totalLength) {
531
+ if (!isArray(list)) throw new TypeError('Usage: Buffer.concat(list[, length])')
532
+
533
+ if (list.length === 0) {
534
+ return new Buffer(0)
535
+ } else if (list.length === 1) {
536
+ return list[0]
537
+ }
538
+
539
+ var i
540
+ if (totalLength === undefined) {
541
+ totalLength = 0
542
+ for (i = 0; i < list.length; i++) {
543
+ totalLength += list[i].length
544
+ }
545
+ }
546
+
547
+ var buf = new Buffer(totalLength)
548
+ var pos = 0
549
+ for (i = 0; i < list.length; i++) {
550
+ var item = list[i]
551
+ item.copy(buf, pos)
552
+ pos += item.length
553
+ }
554
+ return buf
555
+ }
556
+
557
+ Buffer.byteLength = function (str, encoding) {
558
+ var ret
559
+ str = str + ''
560
+ switch (encoding || 'utf8') {
561
+ case 'ascii':
562
+ case 'binary':
563
+ case 'raw':
564
+ ret = str.length
565
+ break
566
+ case 'ucs2':
567
+ case 'ucs-2':
568
+ case 'utf16le':
569
+ case 'utf-16le':
570
+ ret = str.length * 2
571
+ break
572
+ case 'hex':
573
+ ret = str.length >>> 1
574
+ break
575
+ case 'utf8':
576
+ case 'utf-8':
577
+ ret = utf8ToBytes(str).length
578
+ break
579
+ case 'base64':
580
+ ret = base64ToBytes(str).length
581
+ break
582
+ default:
583
+ ret = str.length
584
+ }
585
+ return ret
586
+ }
587
+
588
+ // pre-set for values that may exist in the future
589
+ Buffer.prototype.length = undefined
590
+ Buffer.prototype.parent = undefined
591
+
592
+ // toString(encoding, start=0, end=buffer.length)
593
+ Buffer.prototype.toString = function (encoding, start, end) {
594
+ var loweredCase = false
595
+
596
+ start = start >>> 0
597
+ end = end === undefined || end === Infinity ? this.length : end >>> 0
598
+
599
+ if (!encoding) encoding = 'utf8'
600
+ if (start < 0) start = 0
601
+ if (end > this.length) end = this.length
602
+ if (end <= start) return ''
603
+
604
+ while (true) {
605
+ switch (encoding) {
606
+ case 'hex':
607
+ return hexSlice(this, start, end)
608
+
609
+ case 'utf8':
610
+ case 'utf-8':
611
+ return utf8Slice(this, start, end)
612
+
613
+ case 'ascii':
614
+ return asciiSlice(this, start, end)
615
+
616
+ case 'binary':
617
+ return binarySlice(this, start, end)
618
+
619
+ case 'base64':
620
+ return base64Slice(this, start, end)
621
+
622
+ case 'ucs2':
623
+ case 'ucs-2':
624
+ case 'utf16le':
625
+ case 'utf-16le':
626
+ return utf16leSlice(this, start, end)
627
+
628
+ default:
629
+ if (loweredCase)
630
+ throw new TypeError('Unknown encoding: ' + encoding)
631
+ encoding = (encoding + '').toLowerCase()
632
+ loweredCase = true
633
+ }
634
+ }
635
+ }
636
+
637
+ Buffer.prototype.equals = function (b) {
638
+ if(!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
639
+ return Buffer.compare(this, b) === 0
640
+ }
641
+
642
+ Buffer.prototype.inspect = function () {
643
+ var str = ''
644
+ var max = exports.INSPECT_MAX_BYTES
645
+ if (this.length > 0) {
646
+ str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
647
+ if (this.length > max)
648
+ str += ' ... '
649
+ }
650
+ return '<Buffer ' + str + '>'
651
+ }
652
+
653
+ Buffer.prototype.compare = function (b) {
654
+ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
655
+ return Buffer.compare(this, b)
656
+ }
657
+
658
+ // `get` will be removed in Node 0.13+
659
+ Buffer.prototype.get = function (offset) {
660
+ console.log('.get() is deprecated. Access using array indexes instead.')
661
+ return this.readUInt8(offset)
662
+ }
663
+
664
+ // `set` will be removed in Node 0.13+
665
+ Buffer.prototype.set = function (v, offset) {
666
+ console.log('.set() is deprecated. Access using array indexes instead.')
667
+ return this.writeUInt8(v, offset)
668
+ }
669
+
670
+ function hexWrite (buf, string, offset, length) {
671
+ offset = Number(offset) || 0
672
+ var remaining = buf.length - offset
673
+ if (!length) {
674
+ length = remaining
675
+ } else {
676
+ length = Number(length)
677
+ if (length > remaining) {
678
+ length = remaining
679
+ }
680
+ }
681
+
682
+ // must be an even number of digits
683
+ var strLen = string.length
684
+ if (strLen % 2 !== 0) throw new Error('Invalid hex string')
685
+
686
+ if (length > strLen / 2) {
687
+ length = strLen / 2
688
+ }
689
+ for (var i = 0; i < length; i++) {
690
+ var byte = parseInt(string.substr(i * 2, 2), 16)
691
+ if (isNaN(byte)) throw new Error('Invalid hex string')
692
+ buf[offset + i] = byte
693
+ }
694
+ return i
695
+ }
696
+
697
+ function utf8Write (buf, string, offset, length) {
698
+ var charsWritten = blitBuffer(utf8ToBytes(string), buf, offset, length)
699
+ return charsWritten
700
+ }
701
+
702
+ function asciiWrite (buf, string, offset, length) {
703
+ var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length)
704
+ return charsWritten
705
+ }
706
+
707
+ function binaryWrite (buf, string, offset, length) {
708
+ return asciiWrite(buf, string, offset, length)
709
+ }
710
+
711
+ function base64Write (buf, string, offset, length) {
712
+ var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length)
713
+ return charsWritten
714
+ }
715
+
716
+ function utf16leWrite (buf, string, offset, length) {
717
+ var charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length)
718
+ return charsWritten
719
+ }
720
+
721
+ Buffer.prototype.write = function (string, offset, length, encoding) {
722
+ // Support both (string, offset, length, encoding)
723
+ // and the legacy (string, encoding, offset, length)
724
+ if (isFinite(offset)) {
725
+ if (!isFinite(length)) {
726
+ encoding = length
727
+ length = undefined
728
+ }
729
+ } else { // legacy
730
+ var swap = encoding
731
+ encoding = offset
732
+ offset = length
733
+ length = swap
734
+ }
735
+
736
+ offset = Number(offset) || 0
737
+ var remaining = this.length - offset
738
+ if (!length) {
739
+ length = remaining
740
+ } else {
741
+ length = Number(length)
742
+ if (length > remaining) {
743
+ length = remaining
744
+ }
745
+ }
746
+ encoding = String(encoding || 'utf8').toLowerCase()
747
+
748
+ var ret
749
+ switch (encoding) {
750
+ case 'hex':
751
+ ret = hexWrite(this, string, offset, length)
752
+ break
753
+ case 'utf8':
754
+ case 'utf-8':
755
+ ret = utf8Write(this, string, offset, length)
756
+ break
757
+ case 'ascii':
758
+ ret = asciiWrite(this, string, offset, length)
759
+ break
760
+ case 'binary':
761
+ ret = binaryWrite(this, string, offset, length)
762
+ break
763
+ case 'base64':
764
+ ret = base64Write(this, string, offset, length)
765
+ break
766
+ case 'ucs2':
767
+ case 'ucs-2':
768
+ case 'utf16le':
769
+ case 'utf-16le':
770
+ ret = utf16leWrite(this, string, offset, length)
771
+ break
772
+ default:
773
+ throw new TypeError('Unknown encoding: ' + encoding)
774
+ }
775
+ return ret
776
+ }
777
+
778
+ Buffer.prototype.toJSON = function () {
779
+ return {
780
+ type: 'Buffer',
781
+ data: Array.prototype.slice.call(this._arr || this, 0)
782
+ }
783
+ }
784
+
785
+ function base64Slice (buf, start, end) {
786
+ if (start === 0 && end === buf.length) {
787
+ return base64.fromByteArray(buf)
788
+ } else {
789
+ return base64.fromByteArray(buf.slice(start, end))
790
+ }
791
+ }
792
+
793
+ function utf8Slice (buf, start, end) {
794
+ var res = ''
795
+ var tmp = ''
796
+ end = Math.min(buf.length, end)
797
+
798
+ for (var i = start; i < end; i++) {
799
+ if (buf[i] <= 0x7F) {
800
+ res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
801
+ tmp = ''
802
+ } else {
803
+ tmp += '%' + buf[i].toString(16)
804
+ }
805
+ }
806
+
807
+ return res + decodeUtf8Char(tmp)
808
+ }
809
+
810
+ function asciiSlice (buf, start, end) {
811
+ var ret = ''
812
+ end = Math.min(buf.length, end)
813
+
814
+ for (var i = start; i < end; i++) {
815
+ ret += String.fromCharCode(buf[i])
816
+ }
817
+ return ret
818
+ }
819
+
820
+ function binarySlice (buf, start, end) {
821
+ return asciiSlice(buf, start, end)
822
+ }
823
+
824
+ function hexSlice (buf, start, end) {
825
+ var len = buf.length
826
+
827
+ if (!start || start < 0) start = 0
828
+ if (!end || end < 0 || end > len) end = len
829
+
830
+ var out = ''
831
+ for (var i = start; i < end; i++) {
832
+ out += toHex(buf[i])
833
+ }
834
+ return out
835
+ }
836
+
837
+ function utf16leSlice (buf, start, end) {
838
+ var bytes = buf.slice(start, end)
839
+ var res = ''
840
+ for (var i = 0; i < bytes.length; i += 2) {
841
+ res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
842
+ }
843
+ return res
844
+ }
845
+
846
+ Buffer.prototype.slice = function (start, end) {
847
+ var len = this.length
848
+ start = ~~start
849
+ end = end === undefined ? len : ~~end
850
+
851
+ if (start < 0) {
852
+ start += len;
853
+ if (start < 0)
854
+ start = 0
855
+ } else if (start > len) {
856
+ start = len
857
+ }
858
+
859
+ if (end < 0) {
860
+ end += len
861
+ if (end < 0)
862
+ end = 0
863
+ } else if (end > len) {
864
+ end = len
865
+ }
866
+
867
+ if (end < start)
868
+ end = start
869
+
870
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
871
+ return Buffer._augment(this.subarray(start, end))
872
+ } else {
873
+ var sliceLen = end - start
874
+ var newBuf = new Buffer(sliceLen, undefined, true)
875
+ for (var i = 0; i < sliceLen; i++) {
876
+ newBuf[i] = this[i + start]
877
+ }
878
+ return newBuf
879
+ }
880
+ }
881
+
882
+ /*
883
+ * Need to make sure that buffer isn't trying to write out of bounds.
884
+ */
885
+ function checkOffset (offset, ext, length) {
886
+ if ((offset % 1) !== 0 || offset < 0)
887
+ throw new RangeError('offset is not uint')
888
+ if (offset + ext > length)
889
+ throw new RangeError('Trying to access beyond buffer length')
890
+ }
891
+
892
+ Buffer.prototype.readUInt8 = function (offset, noAssert) {
893
+ if (!noAssert)
894
+ checkOffset(offset, 1, this.length)
895
+ return this[offset]
896
+ }
897
+
898
+ Buffer.prototype.readUInt16LE = function (offset, noAssert) {
899
+ if (!noAssert)
900
+ checkOffset(offset, 2, this.length)
901
+ return this[offset] | (this[offset + 1] << 8)
902
+ }
903
+
904
+ Buffer.prototype.readUInt16BE = function (offset, noAssert) {
905
+ if (!noAssert)
906
+ checkOffset(offset, 2, this.length)
907
+ return (this[offset] << 8) | this[offset + 1]
908
+ }
909
+
910
+ Buffer.prototype.readUInt32LE = function (offset, noAssert) {
911
+ if (!noAssert)
912
+ checkOffset(offset, 4, this.length)
913
+
914
+ return ((this[offset]) |
915
+ (this[offset + 1] << 8) |
916
+ (this[offset + 2] << 16)) +
917
+ (this[offset + 3] * 0x1000000)
918
+ }
919
+
920
+ Buffer.prototype.readUInt32BE = function (offset, noAssert) {
921
+ if (!noAssert)
922
+ checkOffset(offset, 4, this.length)
923
+
924
+ return (this[offset] * 0x1000000) +
925
+ ((this[offset + 1] << 16) |
926
+ (this[offset + 2] << 8) |
927
+ this[offset + 3])
928
+ }
929
+
930
+ Buffer.prototype.readInt8 = function (offset, noAssert) {
931
+ if (!noAssert)
932
+ checkOffset(offset, 1, this.length)
933
+ if (!(this[offset] & 0x80))
934
+ return (this[offset])
935
+ return ((0xff - this[offset] + 1) * -1)
936
+ }
937
+
938
+ Buffer.prototype.readInt16LE = function (offset, noAssert) {
939
+ if (!noAssert)
940
+ checkOffset(offset, 2, this.length)
941
+ var val = this[offset] | (this[offset + 1] << 8)
942
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
943
+ }
944
+
945
+ Buffer.prototype.readInt16BE = function (offset, noAssert) {
946
+ if (!noAssert)
947
+ checkOffset(offset, 2, this.length)
948
+ var val = this[offset + 1] | (this[offset] << 8)
949
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
950
+ }
951
+
952
+ Buffer.prototype.readInt32LE = function (offset, noAssert) {
953
+ if (!noAssert)
954
+ checkOffset(offset, 4, this.length)
955
+
956
+ return (this[offset]) |
957
+ (this[offset + 1] << 8) |
958
+ (this[offset + 2] << 16) |
959
+ (this[offset + 3] << 24)
960
+ }
961
+
962
+ Buffer.prototype.readInt32BE = function (offset, noAssert) {
963
+ if (!noAssert)
964
+ checkOffset(offset, 4, this.length)
965
+
966
+ return (this[offset] << 24) |
967
+ (this[offset + 1] << 16) |
968
+ (this[offset + 2] << 8) |
969
+ (this[offset + 3])
970
+ }
971
+
972
+ Buffer.prototype.readFloatLE = function (offset, noAssert) {
973
+ if (!noAssert)
974
+ checkOffset(offset, 4, this.length)
975
+ return ieee754.read(this, offset, true, 23, 4)
976
+ }
977
+
978
+ Buffer.prototype.readFloatBE = function (offset, noAssert) {
979
+ if (!noAssert)
980
+ checkOffset(offset, 4, this.length)
981
+ return ieee754.read(this, offset, false, 23, 4)
982
+ }
983
+
984
+ Buffer.prototype.readDoubleLE = function (offset, noAssert) {
985
+ if (!noAssert)
986
+ checkOffset(offset, 8, this.length)
987
+ return ieee754.read(this, offset, true, 52, 8)
988
+ }
989
+
990
+ Buffer.prototype.readDoubleBE = function (offset, noAssert) {
991
+ if (!noAssert)
992
+ checkOffset(offset, 8, this.length)
993
+ return ieee754.read(this, offset, false, 52, 8)
994
+ }
995
+
996
+ function checkInt (buf, value, offset, ext, max, min) {
997
+ if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
998
+ if (value > max || value < min) throw new TypeError('value is out of bounds')
999
+ if (offset + ext > buf.length) throw new TypeError('index out of range')
1000
+ }
1001
+
1002
+ Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
1003
+ value = +value
1004
+ offset = offset >>> 0
1005
+ if (!noAssert)
1006
+ checkInt(this, value, offset, 1, 0xff, 0)
1007
+ if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1008
+ this[offset] = value
1009
+ return offset + 1
1010
+ }
1011
+
1012
+ function objectWriteUInt16 (buf, value, offset, littleEndian) {
1013
+ if (value < 0) value = 0xffff + value + 1
1014
+ for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
1015
+ buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
1016
+ (littleEndian ? i : 1 - i) * 8
1017
+ }
1018
+ }
1019
+
1020
+ Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
1021
+ value = +value
1022
+ offset = offset >>> 0
1023
+ if (!noAssert)
1024
+ checkInt(this, value, offset, 2, 0xffff, 0)
1025
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
1026
+ this[offset] = value
1027
+ this[offset + 1] = (value >>> 8)
1028
+ } else objectWriteUInt16(this, value, offset, true)
1029
+ return offset + 2
1030
+ }
1031
+
1032
+ Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) {
1033
+ value = +value
1034
+ offset = offset >>> 0
1035
+ if (!noAssert)
1036
+ checkInt(this, value, offset, 2, 0xffff, 0)
1037
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
1038
+ this[offset] = (value >>> 8)
1039
+ this[offset + 1] = value
1040
+ } else objectWriteUInt16(this, value, offset, false)
1041
+ return offset + 2
1042
+ }
1043
+
1044
+ function objectWriteUInt32 (buf, value, offset, littleEndian) {
1045
+ if (value < 0) value = 0xffffffff + value + 1
1046
+ for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
1047
+ buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
1048
+ }
1049
+ }
1050
+
1051
+ Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) {
1052
+ value = +value
1053
+ offset = offset >>> 0
1054
+ if (!noAssert)
1055
+ checkInt(this, value, offset, 4, 0xffffffff, 0)
1056
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
1057
+ this[offset + 3] = (value >>> 24)
1058
+ this[offset + 2] = (value >>> 16)
1059
+ this[offset + 1] = (value >>> 8)
1060
+ this[offset] = value
1061
+ } else objectWriteUInt32(this, value, offset, true)
1062
+ return offset + 4
1063
+ }
1064
+
1065
+ Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
1066
+ value = +value
1067
+ offset = offset >>> 0
1068
+ if (!noAssert)
1069
+ checkInt(this, value, offset, 4, 0xffffffff, 0)
1070
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
1071
+ this[offset] = (value >>> 24)
1072
+ this[offset + 1] = (value >>> 16)
1073
+ this[offset + 2] = (value >>> 8)
1074
+ this[offset + 3] = value
1075
+ } else objectWriteUInt32(this, value, offset, false)
1076
+ return offset + 4
1077
+ }
1078
+
1079
+ Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
1080
+ value = +value
1081
+ offset = offset >>> 0
1082
+ if (!noAssert)
1083
+ checkInt(this, value, offset, 1, 0x7f, -0x80)
1084
+ if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1085
+ if (value < 0) value = 0xff + value + 1
1086
+ this[offset] = value
1087
+ return offset + 1
1088
+ }
1089
+
1090
+ Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
1091
+ value = +value
1092
+ offset = offset >>> 0
1093
+ if (!noAssert)
1094
+ checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1095
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
1096
+ this[offset] = value
1097
+ this[offset + 1] = (value >>> 8)
1098
+ } else objectWriteUInt16(this, value, offset, true)
1099
+ return offset + 2
1100
+ }
1101
+
1102
+ Buffer.prototype.writeInt16BE = function (value, offset, noAssert) {
1103
+ value = +value
1104
+ offset = offset >>> 0
1105
+ if (!noAssert)
1106
+ checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1107
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
1108
+ this[offset] = (value >>> 8)
1109
+ this[offset + 1] = value
1110
+ } else objectWriteUInt16(this, value, offset, false)
1111
+ return offset + 2
1112
+ }
1113
+
1114
+ Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
1115
+ value = +value
1116
+ offset = offset >>> 0
1117
+ if (!noAssert)
1118
+ checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1119
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
1120
+ this[offset] = value
1121
+ this[offset + 1] = (value >>> 8)
1122
+ this[offset + 2] = (value >>> 16)
1123
+ this[offset + 3] = (value >>> 24)
1124
+ } else objectWriteUInt32(this, value, offset, true)
1125
+ return offset + 4
1126
+ }
1127
+
1128
+ Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
1129
+ value = +value
1130
+ offset = offset >>> 0
1131
+ if (!noAssert)
1132
+ checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1133
+ if (value < 0) value = 0xffffffff + value + 1
1134
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
1135
+ this[offset] = (value >>> 24)
1136
+ this[offset + 1] = (value >>> 16)
1137
+ this[offset + 2] = (value >>> 8)
1138
+ this[offset + 3] = value
1139
+ } else objectWriteUInt32(this, value, offset, false)
1140
+ return offset + 4
1141
+ }
1142
+
1143
+ function checkIEEE754 (buf, value, offset, ext, max, min) {
1144
+ if (value > max || value < min) throw new TypeError('value is out of bounds')
1145
+ if (offset + ext > buf.length) throw new TypeError('index out of range')
1146
+ }
1147
+
1148
+ function writeFloat (buf, value, offset, littleEndian, noAssert) {
1149
+ if (!noAssert)
1150
+ checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
1151
+ ieee754.write(buf, value, offset, littleEndian, 23, 4)
1152
+ return offset + 4
1153
+ }
1154
+
1155
+ Buffer.prototype.writeFloatLE = function (value, offset, noAssert) {
1156
+ return writeFloat(this, value, offset, true, noAssert)
1157
+ }
1158
+
1159
+ Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
1160
+ return writeFloat(this, value, offset, false, noAssert)
1161
+ }
1162
+
1163
+ function writeDouble (buf, value, offset, littleEndian, noAssert) {
1164
+ if (!noAssert)
1165
+ checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
1166
+ ieee754.write(buf, value, offset, littleEndian, 52, 8)
1167
+ return offset + 8
1168
+ }
1169
+
1170
+ Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) {
1171
+ return writeDouble(this, value, offset, true, noAssert)
1172
+ }
1173
+
1174
+ Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
1175
+ return writeDouble(this, value, offset, false, noAssert)
1176
+ }
1177
+
1178
+ // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
1179
+ Buffer.prototype.copy = function (target, target_start, start, end) {
1180
+ var source = this
1181
+
1182
+ if (!start) start = 0
1183
+ if (!end && end !== 0) end = this.length
1184
+ if (!target_start) target_start = 0
1185
+
1186
+ // Copy 0 bytes; we're done
1187
+ if (end === start) return
1188
+ if (target.length === 0 || source.length === 0) return
1189
+
1190
+ // Fatal error conditions
1191
+ if (end < start) throw new TypeError('sourceEnd < sourceStart')
1192
+ if (target_start < 0 || target_start >= target.length)
1193
+ throw new TypeError('targetStart out of bounds')
1194
+ if (start < 0 || start >= source.length) throw new TypeError('sourceStart out of bounds')
1195
+ if (end < 0 || end > source.length) throw new TypeError('sourceEnd out of bounds')
1196
+
1197
+ // Are we oob?
1198
+ if (end > this.length)
1199
+ end = this.length
1200
+ if (target.length - target_start < end - start)
1201
+ end = target.length - target_start + start
1202
+
1203
+ var len = end - start
1204
+
1205
+ if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
1206
+ for (var i = 0; i < len; i++) {
1207
+ target[i + target_start] = this[i + start]
1208
+ }
1209
+ } else {
1210
+ target._set(this.subarray(start, start + len), target_start)
1211
+ }
1212
+ }
1213
+
1214
+ // fill(value, start=0, end=buffer.length)
1215
+ Buffer.prototype.fill = function (value, start, end) {
1216
+ if (!value) value = 0
1217
+ if (!start) start = 0
1218
+ if (!end) end = this.length
1219
+
1220
+ if (end < start) throw new TypeError('end < start')
1221
+
1222
+ // Fill 0 bytes; we're done
1223
+ if (end === start) return
1224
+ if (this.length === 0) return
1225
+
1226
+ if (start < 0 || start >= this.length) throw new TypeError('start out of bounds')
1227
+ if (end < 0 || end > this.length) throw new TypeError('end out of bounds')
1228
+
1229
+ var i
1230
+ if (typeof value === 'number') {
1231
+ for (i = start; i < end; i++) {
1232
+ this[i] = value
1233
+ }
1234
+ } else {
1235
+ var bytes = utf8ToBytes(value.toString())
1236
+ var len = bytes.length
1237
+ for (i = start; i < end; i++) {
1238
+ this[i] = bytes[i % len]
1239
+ }
1240
+ }
1241
+
1242
+ return this
1243
+ }
1244
+
1245
+ /**
1246
+ * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
1247
+ * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
1248
+ */
1249
+ Buffer.prototype.toArrayBuffer = function () {
1250
+ if (typeof Uint8Array !== 'undefined') {
1251
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
1252
+ return (new Buffer(this)).buffer
1253
+ } else {
1254
+ var buf = new Uint8Array(this.length)
1255
+ for (var i = 0, len = buf.length; i < len; i += 1) {
1256
+ buf[i] = this[i]
1257
+ }
1258
+ return buf.buffer
1259
+ }
1260
+ } else {
1261
+ throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
1262
+ }
1263
+ }
1264
+
1265
+ // HELPER FUNCTIONS
1266
+ // ================
1267
+
1268
+ var BP = Buffer.prototype
1269
+
1270
+ /**
1271
+ * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
1272
+ */
1273
+ Buffer._augment = function (arr) {
1274
+ arr.constructor = Buffer
1275
+ arr._isBuffer = true
1276
+
1277
+ // save reference to original Uint8Array get/set methods before overwriting
1278
+ arr._get = arr.get
1279
+ arr._set = arr.set
1280
+
1281
+ // deprecated, will be removed in node 0.13+
1282
+ arr.get = BP.get
1283
+ arr.set = BP.set
1284
+
1285
+ arr.write = BP.write
1286
+ arr.toString = BP.toString
1287
+ arr.toLocaleString = BP.toString
1288
+ arr.toJSON = BP.toJSON
1289
+ arr.equals = BP.equals
1290
+ arr.compare = BP.compare
1291
+ arr.copy = BP.copy
1292
+ arr.slice = BP.slice
1293
+ arr.readUInt8 = BP.readUInt8
1294
+ arr.readUInt16LE = BP.readUInt16LE
1295
+ arr.readUInt16BE = BP.readUInt16BE
1296
+ arr.readUInt32LE = BP.readUInt32LE
1297
+ arr.readUInt32BE = BP.readUInt32BE
1298
+ arr.readInt8 = BP.readInt8
1299
+ arr.readInt16LE = BP.readInt16LE
1300
+ arr.readInt16BE = BP.readInt16BE
1301
+ arr.readInt32LE = BP.readInt32LE
1302
+ arr.readInt32BE = BP.readInt32BE
1303
+ arr.readFloatLE = BP.readFloatLE
1304
+ arr.readFloatBE = BP.readFloatBE
1305
+ arr.readDoubleLE = BP.readDoubleLE
1306
+ arr.readDoubleBE = BP.readDoubleBE
1307
+ arr.writeUInt8 = BP.writeUInt8
1308
+ arr.writeUInt16LE = BP.writeUInt16LE
1309
+ arr.writeUInt16BE = BP.writeUInt16BE
1310
+ arr.writeUInt32LE = BP.writeUInt32LE
1311
+ arr.writeUInt32BE = BP.writeUInt32BE
1312
+ arr.writeInt8 = BP.writeInt8
1313
+ arr.writeInt16LE = BP.writeInt16LE
1314
+ arr.writeInt16BE = BP.writeInt16BE
1315
+ arr.writeInt32LE = BP.writeInt32LE
1316
+ arr.writeInt32BE = BP.writeInt32BE
1317
+ arr.writeFloatLE = BP.writeFloatLE
1318
+ arr.writeFloatBE = BP.writeFloatBE
1319
+ arr.writeDoubleLE = BP.writeDoubleLE
1320
+ arr.writeDoubleBE = BP.writeDoubleBE
1321
+ arr.fill = BP.fill
1322
+ arr.inspect = BP.inspect
1323
+ arr.toArrayBuffer = BP.toArrayBuffer
1324
+
1325
+ return arr
1326
+ }
1327
+
1328
+ var INVALID_BASE64_RE = /[^+\/0-9A-z]/g
1329
+
1330
+ function base64clean (str) {
1331
+ // Node strips out invalid characters like \n and \t from the string, base64-js does not
1332
+ str = stringtrim(str).replace(INVALID_BASE64_RE, '')
1333
+ // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
1334
+ while (str.length % 4 !== 0) {
1335
+ str = str + '='
1336
+ }
1337
+ return str
1338
+ }
1339
+
1340
+ function stringtrim (str) {
1341
+ if (str.trim) return str.trim()
1342
+ return str.replace(/^\s+|\s+$/g, '')
1343
+ }
1344
+
1345
+ function isArrayish (subject) {
1346
+ return isArray(subject) || Buffer.isBuffer(subject) ||
1347
+ subject && typeof subject === 'object' &&
1348
+ typeof subject.length === 'number'
1349
+ }
1350
+
1351
+ function toHex (n) {
1352
+ if (n < 16) return '0' + n.toString(16)
1353
+ return n.toString(16)
1354
+ }
1355
+
1356
+ function utf8ToBytes (str) {
1357
+ var byteArray = []
1358
+ for (var i = 0; i < str.length; i++) {
1359
+ var b = str.charCodeAt(i)
1360
+ if (b <= 0x7F) {
1361
+ byteArray.push(b)
1362
+ } else {
1363
+ var start = i
1364
+ if (b >= 0xD800 && b <= 0xDFFF) i++
1365
+ var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%')
1366
+ for (var j = 0; j < h.length; j++) {
1367
+ byteArray.push(parseInt(h[j], 16))
1368
+ }
1369
+ }
1370
+ }
1371
+ return byteArray
1372
+ }
1373
+
1374
+ function asciiToBytes (str) {
1375
+ var byteArray = []
1376
+ for (var i = 0; i < str.length; i++) {
1377
+ // Node's code seems to be doing this and not & 0x7F..
1378
+ byteArray.push(str.charCodeAt(i) & 0xFF)
1379
+ }
1380
+ return byteArray
1381
+ }
1382
+
1383
+ function utf16leToBytes (str) {
1384
+ var c, hi, lo
1385
+ var byteArray = []
1386
+ for (var i = 0; i < str.length; i++) {
1387
+ c = str.charCodeAt(i)
1388
+ hi = c >> 8
1389
+ lo = c % 256
1390
+ byteArray.push(lo)
1391
+ byteArray.push(hi)
1392
+ }
1393
+
1394
+ return byteArray
1395
+ }
1396
+
1397
+ function base64ToBytes (str) {
1398
+ return base64.toByteArray(str)
1399
+ }
1400
+
1401
+ function blitBuffer (src, dst, offset, length) {
1402
+ for (var i = 0; i < length; i++) {
1403
+ if ((i + offset >= dst.length) || (i >= src.length))
1404
+ break
1405
+ dst[i + offset] = src[i]
1406
+ }
1407
+ return i
1408
+ }
1409
+
1410
+ function decodeUtf8Char (str) {
1411
+ try {
1412
+ return decodeURIComponent(str)
1413
+ } catch (err) {
1414
+ return String.fromCharCode(0xFFFD) // UTF 8 invalid char
1415
+ }
1416
+ }
1417
+
1418
+ },{"base64-js":4,"ieee754":5,"is-array":6}],4:[function(require,module,exports){
1419
+ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
1420
+
1421
+ ;(function (exports) {
1422
+ 'use strict';
1423
+
1424
+ var Arr = (typeof Uint8Array !== 'undefined')
1425
+ ? Uint8Array
1426
+ : Array
1427
+
1428
+ var PLUS = '+'.charCodeAt(0)
1429
+ var SLASH = '/'.charCodeAt(0)
1430
+ var NUMBER = '0'.charCodeAt(0)
1431
+ var LOWER = 'a'.charCodeAt(0)
1432
+ var UPPER = 'A'.charCodeAt(0)
1433
+
1434
+ function decode (elt) {
1435
+ var code = elt.charCodeAt(0)
1436
+ if (code === PLUS)
1437
+ return 62 // '+'
1438
+ if (code === SLASH)
1439
+ return 63 // '/'
1440
+ if (code < NUMBER)
1441
+ return -1 //no match
1442
+ if (code < NUMBER + 10)
1443
+ return code - NUMBER + 26 + 26
1444
+ if (code < UPPER + 26)
1445
+ return code - UPPER
1446
+ if (code < LOWER + 26)
1447
+ return code - LOWER + 26
1448
+ }
1449
+
1450
+ function b64ToByteArray (b64) {
1451
+ var i, j, l, tmp, placeHolders, arr
1452
+
1453
+ if (b64.length % 4 > 0) {
1454
+ throw new Error('Invalid string. Length must be a multiple of 4')
1455
+ }
1456
+
1457
+ // the number of equal signs (place holders)
1458
+ // if there are two placeholders, than the two characters before it
1459
+ // represent one byte
1460
+ // if there is only one, then the three characters before it represent 2 bytes
1461
+ // this is just a cheap hack to not do indexOf twice
1462
+ var len = b64.length
1463
+ placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
1464
+
1465
+ // base64 is 4/3 + up to two characters of the original data
1466
+ arr = new Arr(b64.length * 3 / 4 - placeHolders)
1467
+
1468
+ // if there are placeholders, only get up to the last complete 4 chars
1469
+ l = placeHolders > 0 ? b64.length - 4 : b64.length
1470
+
1471
+ var L = 0
1472
+
1473
+ function push (v) {
1474
+ arr[L++] = v
1475
+ }
1476
+
1477
+ for (i = 0, j = 0; i < l; i += 4, j += 3) {
1478
+ tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
1479
+ push((tmp & 0xFF0000) >> 16)
1480
+ push((tmp & 0xFF00) >> 8)
1481
+ push(tmp & 0xFF)
1482
+ }
1483
+
1484
+ if (placeHolders === 2) {
1485
+ tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
1486
+ push(tmp & 0xFF)
1487
+ } else if (placeHolders === 1) {
1488
+ tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
1489
+ push((tmp >> 8) & 0xFF)
1490
+ push(tmp & 0xFF)
1491
+ }
1492
+
1493
+ return arr
1494
+ }
1495
+
1496
+ function uint8ToBase64 (uint8) {
1497
+ var i,
1498
+ extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
1499
+ output = "",
1500
+ temp, length
1501
+
1502
+ function encode (num) {
1503
+ return lookup.charAt(num)
1504
+ }
1505
+
1506
+ function tripletToBase64 (num) {
1507
+ return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
1508
+ }
1509
+
1510
+ // go through the array every three bytes, we'll deal with trailing stuff later
1511
+ for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
1512
+ temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
1513
+ output += tripletToBase64(temp)
1514
+ }
1515
+
1516
+ // pad the end with zeros, but make sure to not forget the extra bytes
1517
+ switch (extraBytes) {
1518
+ case 1:
1519
+ temp = uint8[uint8.length - 1]
1520
+ output += encode(temp >> 2)
1521
+ output += encode((temp << 4) & 0x3F)
1522
+ output += '=='
1523
+ break
1524
+ case 2:
1525
+ temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
1526
+ output += encode(temp >> 10)
1527
+ output += encode((temp >> 4) & 0x3F)
1528
+ output += encode((temp << 2) & 0x3F)
1529
+ output += '='
1530
+ break
1531
+ }
1532
+
1533
+ return output
1534
+ }
1535
+
1536
+ exports.toByteArray = b64ToByteArray
1537
+ exports.fromByteArray = uint8ToBase64
1538
+ }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
1539
+
1540
+ },{}],5:[function(require,module,exports){
1541
+ exports.read = function(buffer, offset, isLE, mLen, nBytes) {
1542
+ var e, m,
1543
+ eLen = nBytes * 8 - mLen - 1,
1544
+ eMax = (1 << eLen) - 1,
1545
+ eBias = eMax >> 1,
1546
+ nBits = -7,
1547
+ i = isLE ? (nBytes - 1) : 0,
1548
+ d = isLE ? -1 : 1,
1549
+ s = buffer[offset + i];
1550
+
1551
+ i += d;
1552
+
1553
+ e = s & ((1 << (-nBits)) - 1);
1554
+ s >>= (-nBits);
1555
+ nBits += eLen;
1556
+ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
1557
+
1558
+ m = e & ((1 << (-nBits)) - 1);
1559
+ e >>= (-nBits);
1560
+ nBits += mLen;
1561
+ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
1562
+
1563
+ if (e === 0) {
1564
+ e = 1 - eBias;
1565
+ } else if (e === eMax) {
1566
+ return m ? NaN : ((s ? -1 : 1) * Infinity);
1567
+ } else {
1568
+ m = m + Math.pow(2, mLen);
1569
+ e = e - eBias;
1570
+ }
1571
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
1572
+ };
1573
+
1574
+ exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
1575
+ var e, m, c,
1576
+ eLen = nBytes * 8 - mLen - 1,
1577
+ eMax = (1 << eLen) - 1,
1578
+ eBias = eMax >> 1,
1579
+ rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
1580
+ i = isLE ? 0 : (nBytes - 1),
1581
+ d = isLE ? 1 : -1,
1582
+ s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
1583
+
1584
+ value = Math.abs(value);
1585
+
1586
+ if (isNaN(value) || value === Infinity) {
1587
+ m = isNaN(value) ? 1 : 0;
1588
+ e = eMax;
1589
+ } else {
1590
+ e = Math.floor(Math.log(value) / Math.LN2);
1591
+ if (value * (c = Math.pow(2, -e)) < 1) {
1592
+ e--;
1593
+ c *= 2;
1594
+ }
1595
+ if (e + eBias >= 1) {
1596
+ value += rt / c;
1597
+ } else {
1598
+ value += rt * Math.pow(2, 1 - eBias);
1599
+ }
1600
+ if (value * c >= 2) {
1601
+ e++;
1602
+ c /= 2;
1603
+ }
1604
+
1605
+ if (e + eBias >= eMax) {
1606
+ m = 0;
1607
+ e = eMax;
1608
+ } else if (e + eBias >= 1) {
1609
+ m = (value * c - 1) * Math.pow(2, mLen);
1610
+ e = e + eBias;
1611
+ } else {
1612
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
1613
+ e = 0;
1614
+ }
1615
+ }
1616
+
1617
+ for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8);
1618
+
1619
+ e = (e << mLen) | m;
1620
+ eLen += mLen;
1621
+ for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8);
1622
+
1623
+ buffer[offset + i - d] |= s * 128;
1624
+ };
1625
+
1626
+ },{}],6:[function(require,module,exports){
1627
+
1628
+ /**
1629
+ * isArray
1630
+ */
1631
+
1632
+ var isArray = Array.isArray;
1633
+
1634
+ /**
1635
+ * toString
1636
+ */
1637
+
1638
+ var str = Object.prototype.toString;
1639
+
1640
+ /**
1641
+ * Whether or not the given `val`
1642
+ * is an array.
1643
+ *
1644
+ * example:
1645
+ *
1646
+ * isArray([]);
1647
+ * // > true
1648
+ * isArray(arguments);
1649
+ * // > false
1650
+ * isArray('');
1651
+ * // > false
1652
+ *
1653
+ * @param {mixed} val
1654
+ * @return {bool}
1655
+ */
1656
+
1657
+ module.exports = isArray || function (val) {
1658
+ return !! val && '[object Array]' == str.call(val);
1659
+ };
1660
+
1661
+ },{}],7:[function(require,module,exports){
364
1662
  if (typeof Object.create === 'function') {
365
1663
  // implementation from standard node.js 'util' module
366
1664
  module.exports = function inherits(ctor, superCtor) {
@@ -385,7 +1683,7 @@ if (typeof Object.create === 'function') {
385
1683
  }
386
1684
  }
387
1685
 
388
- },{}],3:[function(require,module,exports){
1686
+ },{}],8:[function(require,module,exports){
389
1687
  exports.endianness = function () { return 'LE' };
390
1688
 
391
1689
  exports.hostname = function () {
@@ -432,7 +1730,7 @@ exports.tmpdir = exports.tmpDir = function () {
432
1730
 
433
1731
  exports.EOL = '\n';
434
1732
 
435
- },{}],4:[function(require,module,exports){
1733
+ },{}],9:[function(require,module,exports){
436
1734
  (function (process){
437
1735
  // Copyright Joyent, Inc. and other Node contributors.
438
1736
  //
@@ -660,7 +1958,7 @@ var substr = 'ab'.substr(-1) === 'b'
660
1958
  ;
661
1959
 
662
1960
  }).call(this,require('_process'))
663
- },{"_process":5}],5:[function(require,module,exports){
1961
+ },{"_process":10}],10:[function(require,module,exports){
664
1962
  // shim for using process in browser
665
1963
 
666
1964
  var process = module.exports = {};
@@ -748,14 +2046,14 @@ process.chdir = function (dir) {
748
2046
  throw new Error('process.chdir is not supported');
749
2047
  };
750
2048
 
751
- },{}],6:[function(require,module,exports){
2049
+ },{}],11:[function(require,module,exports){
752
2050
  module.exports = function isBuffer(arg) {
753
2051
  return arg && typeof arg === 'object'
754
2052
  && typeof arg.copy === 'function'
755
2053
  && typeof arg.fill === 'function'
756
2054
  && typeof arg.readUInt8 === 'function';
757
2055
  }
758
- },{}],7:[function(require,module,exports){
2056
+ },{}],12:[function(require,module,exports){
759
2057
  (function (process,global){
760
2058
  // Copyright Joyent, Inc. and other Node contributors.
761
2059
  //
@@ -1345,99 +2643,129 @@ function hasOwnProperty(obj, prop) {
1345
2643
  }
1346
2644
 
1347
2645
  }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
1348
- },{"./support/isBuffer":6,"_process":5,"inherits":2}],8:[function(require,module,exports){
2646
+ },{"./support/isBuffer":11,"_process":10,"inherits":7}],13:[function(require,module,exports){
1349
2647
  "use strict";
1350
2648
 
2649
+ var os = require("os");
2650
+ var convertSourceMap = require("convert-source-map");
2651
+ var SourceMapConsumer = require("source-map").SourceMapConsumer;
1351
2652
  var SourceMapGenerator = require("source-map").SourceMapGenerator;
1352
2653
  var stableSort = require("stable");
1353
2654
 
1354
- function SourceMapper(src, fragments, inFile, sourceRoot) {
2655
+ function SourceMapper(src, nodePositions, fragments, inFile, sourceRoot) {
1355
2656
  this.generator = new SourceMapGenerator({ sourceRoot: sourceRoot });
1356
2657
  this.src = src;
1357
- this.fragments = stableSort(fragments.slice(0), function(a, b) { return a.start - b.start });
2658
+ // stableSort does not mutate input array so no need to copy it
2659
+ this.nodePositions = stableSort(nodePositions, compareLoc);
2660
+ this.fragments = stableSort(fragments, function(a, b) { return a.start - b.start });
1358
2661
  this.inFile = inFile || "source.js";
1359
2662
 
1360
2663
  this.generator.setSourceContent(this.inFile, src);
1361
2664
  }
1362
2665
 
1363
- SourceMapper.prototype.generate = function() {
1364
- var inIndex = 0;
1365
- var inLine = 1;
1366
- var inColumn = 0;
1367
- var outLine = 1;
1368
- var outColumn = 0;
1369
- var createMappingAfterWhitespace = true;
2666
+ SourceMapper.prototype.calculateMappings = function() {
2667
+ var self = this;
1370
2668
 
1371
- while (inIndex < this.src.length) {
1372
- if (createMappingAfterWhitespace && !/\s/.test(this.src[inIndex])) {
1373
- this.addMapping(inLine, inColumn, outLine, outColumn);
1374
- createMappingAfterWhitespace = false;
1375
- }
2669
+ // These offsets represent the difference in coordinates between a node in the source
2670
+ // and the corresponding position in the output.
2671
+ var lineOffset = 0;
2672
+ var columnOffset = 0;
1376
2673
 
1377
- if (this.fragments[0] && this.fragments[0].start === inIndex) {
1378
- this.addMapping(inLine, inColumn, outLine, outColumn);
2674
+ // Since the column position resets to zero after each newline, we have to keep track
2675
+ // of the current line that columnOffset refers to in order to know whether to reset it
2676
+ var currentLine = 0;
1379
2677
 
1380
- // iterate over input string
1381
- for (; inIndex < this.fragments[0].end; inIndex++) {
1382
- if (this.src[inIndex] === '\n') {
1383
- inLine++;
1384
- inColumn = 0;
1385
- } else {
1386
- inColumn++;
1387
- }
1388
- }
2678
+ var frag = 0;
2679
+ var pos = 0;
1389
2680
 
1390
- // iterate over output string
1391
- for (var outIndex = 0; outIndex < this.fragments[0].str.length; outIndex++) {
1392
- if (this.fragments[0].str[outIndex] === '\n') {
1393
- outLine++;
1394
- outColumn = 0;
1395
- } else {
1396
- outColumn++;
1397
- }
2681
+ while (pos < self.nodePositions.length) {
2682
+ while (frag < self.fragments.length &&
2683
+ compareLoc(self.fragments[frag].loc.start, self.nodePositions[pos]) < 1) {
2684
+
2685
+ var fragmentLines = self.fragments[frag].str.split("\n");
2686
+ var addedNewlines = fragmentLines.length - 1;
2687
+
2688
+ var replacedLines = self.fragments[frag].loc.end.line - self.fragments[frag].loc.start.line;
2689
+ var replacedColumns = self.fragments[frag].loc.end.column - self.fragments[frag].loc.start.column;
2690
+
2691
+ // If there were any lines added by the fragment string, the line offset should increase;
2692
+ // If there were any lines removed by the fragment replacement then the line offset should decrease
2693
+ lineOffset = lineOffset + addedNewlines - replacedLines;
2694
+
2695
+ // The column position needs to reset after each newline. So if the fragment added any
2696
+ // newlines then the column offset is the difference between the column of the last line of
2697
+ // the fragment, and the column of the end of the replaced section of the source.
2698
+ // Otherwise we increment or decrement the column offset just like how the line offset works.
2699
+ // Note that "replacedColumns" might be negative in some cases (if the beginning of the source
2700
+ // was further right than the end due to a newline); the math still works out.
2701
+ columnOffset = fragmentLines.length > 1 ?
2702
+ fragmentLines[fragmentLines.length - 1].length - self.fragments[frag].loc.end.column :
2703
+ columnOffset + self.fragments[frag].str.length - replacedColumns;
2704
+
2705
+ currentLine = self.fragments[frag].loc.end.line;
2706
+
2707
+ // Skip creating mappings for any source nodes that were replaced by this fragment (and are thus
2708
+ // no longer a part of the output)
2709
+ while (pos < self.nodePositions.length &&
2710
+ compareLoc(self.fragments[frag].loc.end, self.nodePositions[pos]) > 0) {
2711
+ ++pos;
1398
2712
  }
1399
2713
 
1400
- this.fragments.shift();
1401
- createMappingAfterWhitespace = true;
2714
+ ++frag;
1402
2715
  }
1403
2716
 
1404
- else {
1405
- if (this.src[inIndex] === '\n') {
1406
- inLine++;
1407
- outLine++;
1408
- inColumn = 0;
1409
- outColumn = 0;
1410
- createMappingAfterWhitespace = true;
1411
- } else {
1412
- inColumn++;
1413
- outColumn++;
1414
- }
1415
- inIndex++;
2717
+ if (pos < self.nodePositions.length) {
2718
+ if (currentLine < self.nodePositions[pos].line)
2719
+ columnOffset = 0;
2720
+ self.addMapping(self.nodePositions[pos], {
2721
+ line: self.nodePositions[pos].line + lineOffset,
2722
+ column: self.nodePositions[pos].column + columnOffset
2723
+ });
2724
+ ++pos;
1416
2725
  }
1417
2726
  }
1418
-
1419
- return this.generator.toString();
1420
2727
  }
1421
2728
 
1422
- SourceMapper.prototype.addMapping = function(inLine, inColumn, outLine, outColumn) {
2729
+ SourceMapper.prototype.addMapping = function(input, output) {
1423
2730
  this.generator.addMapping({
1424
2731
  source: this.inFile,
1425
- original: {
1426
- line: inLine,
1427
- column: inColumn
1428
- },
1429
- generated: {
1430
- line: outLine,
1431
- column: outColumn
1432
- }
2732
+ original: input,
2733
+ generated: output
1433
2734
  });
1434
2735
  }
1435
2736
 
1436
- module.exports = function generateSourcemap(src, fragments, inFile, sourceRoot) {
1437
- return new SourceMapper(src, fragments, inFile, sourceRoot).generate();
2737
+ SourceMapper.prototype.applySourceMap = function (consumer) {
2738
+ this.generator.applySourceMap(consumer);
2739
+ }
2740
+
2741
+ SourceMapper.prototype.generate = function () {
2742
+ return this.generator.toString();
2743
+ }
2744
+
2745
+ function compareLoc(a, b) {
2746
+ return (a.line - b.line) || (a.column - b.column);
2747
+ }
2748
+
2749
+ module.exports = function generateSourcemap(result, src, nodePositions, fragments, mapOpts) {
2750
+ var existingMap = convertSourceMap.fromSource(src);
2751
+ src = convertSourceMap.removeMapFileComments(src);
2752
+
2753
+ var mapper = new SourceMapper(src, nodePositions, fragments, mapOpts.inFile, mapOpts.sourceRoot);
2754
+ mapper.calculateMappings();
2755
+
2756
+ if (mapOpts.inline) {
2757
+ if (existingMap)
2758
+ mapper.applySourceMap(new SourceMapConsumer(existingMap.toObject()));
2759
+
2760
+ result.src = convertSourceMap.removeMapFileComments(result.src) +
2761
+ os.EOL +
2762
+ convertSourceMap.fromJSON(mapper.generate()).toComment();
2763
+ } else {
2764
+ result.map = mapper.generate();
2765
+ }
1438
2766
  }
1439
2767
 
1440
- },{"source-map":21,"stable":31}],9:[function(require,module,exports){
2768
+ },{"convert-source-map":21,"os":8,"source-map":27,"stable":37}],14:[function(require,module,exports){
1441
2769
  // lut.js
1442
2770
  // MIT licensed, see LICENSE file
1443
2771
  // Copyright (c) 2013-2014 Olov Lassus <olov.lassus@gmail.com>
@@ -1565,7 +2893,7 @@ function last(arr) {
1565
2893
  return arr[arr.length - 1];
1566
2894
  }
1567
2895
 
1568
- },{"assert":1,"ordered-ast-traverse":18,"simple-is":20}],10:[function(require,module,exports){
2896
+ },{"assert":2,"ordered-ast-traverse":24,"simple-is":26}],15:[function(require,module,exports){
1569
2897
  // ng-annotate-main.js
1570
2898
  // MIT licensed, see LICENSE file
1571
2899
  // Copyright (c) 2013-2014 Olov Lassus <olov.lassus@gmail.com>
@@ -1998,29 +3326,25 @@ function replaceNodeWith(node, newNode) {
1998
3326
  }
1999
3327
 
2000
3328
  function insertArray(ctx, functionExpression, fragments, quot) {
2001
- var range = functionExpression.range;
2002
-
2003
3329
  var args = stringify(ctx, functionExpression.params, quot);
2004
3330
 
2005
- // modify the AST
2006
- /*
2007
- const arrayExpression = parseExpressionOfType(args, "ArrayExpression");
2008
- const parent = functionExpression.$parent;
2009
- replaceNodeWith(functionExpression, arrayExpression);
2010
- arrayExpression.$parent = parent;
2011
- arrayExpression.elements.push(functionExpression)
2012
- functionExpression.$parent = arrayExpression;
2013
- */
2014
-
2015
3331
  fragments.push({
2016
- start: range[0],
2017
- end: range[0],
3332
+ start: functionExpression.range[0],
3333
+ end: functionExpression.range[0],
2018
3334
  str: args.slice(0, -1) + ", ",
3335
+ loc: {
3336
+ start: functionExpression.loc.start,
3337
+ end: functionExpression.loc.start
3338
+ }
2019
3339
  });
2020
3340
  fragments.push({
2021
- start: range[1],
2022
- end: range[1],
3341
+ start: functionExpression.range[1],
3342
+ end: functionExpression.range[1],
2023
3343
  str: "]",
3344
+ loc: {
3345
+ start: functionExpression.loc.end,
3346
+ end: functionExpression.loc.end
3347
+ }
2024
3348
  });
2025
3349
  }
2026
3350
 
@@ -2036,6 +3360,10 @@ function replaceArray(ctx, array, fragments, quot) {
2036
3360
  start: array.range[0],
2037
3361
  end: functionExpression.range[0],
2038
3362
  str: args.slice(0, -1) + ", ",
3363
+ loc: {
3364
+ start: array.loc.start,
3365
+ end: functionExpression.loc.start
3366
+ }
2039
3367
  });
2040
3368
  }
2041
3369
 
@@ -2046,11 +3374,19 @@ function removeArray(array, fragments) {
2046
3374
  start: array.range[0],
2047
3375
  end: functionExpression.range[0],
2048
3376
  str: "",
3377
+ loc: {
3378
+ start: array.loc.start,
3379
+ end: functionExpression.loc.start
3380
+ }
2049
3381
  });
2050
3382
  fragments.push({
2051
3383
  start: functionExpression.range[1],
2052
3384
  end: array.range[1],
2053
3385
  str: "",
3386
+ loc: {
3387
+ start: functionExpression.loc.end,
3388
+ end: array.loc.end
3389
+ }
2054
3390
  });
2055
3391
  }
2056
3392
 
@@ -2059,6 +3395,15 @@ function renameProviderDeclarationSite(ctx, literalNode, fragments) {
2059
3395
  start: literalNode.range[0] + 1,
2060
3396
  end: literalNode.range[1] - 1,
2061
3397
  str: renamedString(ctx, literalNode.value),
3398
+ loc: {
3399
+ start: {
3400
+ line: literalNode.loc.start.line,
3401
+ column: literalNode.loc.start.column + 1
3402
+ }, end: {
3403
+ line: literalNode.loc.end.line,
3404
+ column: literalNode.loc.end.column - 1
3405
+ }
3406
+ }
2062
3407
  });
2063
3408
  }
2064
3409
 
@@ -2267,8 +3612,11 @@ function judgeInjectArraySuspect(node, ctx) {
2267
3612
  return;
2268
3613
  }
2269
3614
 
2270
- var insertPos = onode.range[1];
2271
- var isSemicolonTerminated = (ctx.src[insertPos - 1] === ";");
3615
+ var insertPos = {
3616
+ pos: onode.range[1],
3617
+ loc: onode.loc.end
3618
+ };
3619
+ var isSemicolonTerminated = (ctx.src[insertPos.pos - 1] === ";");
2272
3620
 
2273
3621
  node = jumpOverIife(node);
2274
3622
 
@@ -2276,19 +3624,34 @@ function judgeInjectArraySuspect(node, ctx) {
2276
3624
  // var x = 1, y = function(a,b) {}, z;
2277
3625
 
2278
3626
  assert(declaratorName);
2279
- addRemoveInjectArray(node.params, isSemicolonTerminated ? insertPos : node.range[1], declaratorName);
3627
+ addRemoveInjectArray(
3628
+ node.params,
3629
+ isSemicolonTerminated ? insertPos : {
3630
+ pos: node.range[1],
3631
+ loc: node.loc.end
3632
+ },
3633
+ declaratorName);
2280
3634
 
2281
3635
  } else if (ctx.isFunctionDeclarationWithArgs(node)) {
2282
3636
  // /*@ngInject*/ function foo($scope) {}
2283
3637
 
2284
- addRemoveInjectArray(node.params, insertPos, node.id.name);
3638
+ addRemoveInjectArray(
3639
+ node.params,
3640
+ insertPos,
3641
+ node.id.name);
2285
3642
 
2286
3643
  } else if (node.type === "ExpressionStatement" && node.expression.type === "AssignmentExpression" &&
2287
3644
  ctx.isFunctionExpressionWithArgs(node.expression.right)) {
2288
3645
  // /*@ngInject*/ foo.bar[0] = function($scope) {}
2289
3646
 
2290
3647
  var name = ctx.srcForRange(node.expression.left.range);
2291
- addRemoveInjectArray(node.expression.right.params, isSemicolonTerminated ? insertPos : node.expression.right.range[1], name);
3648
+ addRemoveInjectArray(
3649
+ node.expression.right.params,
3650
+ isSemicolonTerminated ? insertPos : {
3651
+ pos: node.expression.right.range[1],
3652
+ loc: node.expression.right.loc.end
3653
+ },
3654
+ name);
2292
3655
 
2293
3656
  } else if (node = followReference(node)) {
2294
3657
  // node was a reference and followed node now is either a
@@ -2311,7 +3674,7 @@ function judgeInjectArraySuspect(node, ctx) {
2311
3674
  function addRemoveInjectArray(params, posAfterFunctionDeclaration, name) {
2312
3675
  // if an existing something.$inject = [..] exists then is will always be recycled when rebuilding
2313
3676
 
2314
- var indent = getIndent(posAfterFunctionDeclaration);
3677
+ var indent = getIndent(posAfterFunctionDeclaration.pos);
2315
3678
 
2316
3679
  var foundSuspectInBody = false;
2317
3680
  var existingExpressionStatementWithArray = null;
@@ -2338,7 +3701,7 @@ function judgeInjectArraySuspect(node, ctx) {
2338
3701
  assert(foundSuspectInBody);
2339
3702
 
2340
3703
  if (troublesomeReturn && !existingExpressionStatementWithArray) {
2341
- posAfterFunctionDeclaration = skipPrevNewline(troublesomeReturn.range[0]);
3704
+ posAfterFunctionDeclaration = skipPrevNewline(troublesomeReturn.range[0], troublesomeReturn.loc.start);
2342
3705
  }
2343
3706
 
2344
3707
  function hasInjectArray(node) {
@@ -2351,20 +3714,26 @@ function judgeInjectArraySuspect(node, ctx) {
2351
3714
  (lvalue.computed === true && ctx.srcForRange(lvalue.object.range) === name && lvalue.property.type === "Literal" && lvalue.property.value === "$inject")));
2352
3715
  }
2353
3716
 
2354
- function skipPrevNewline(pos) {
3717
+ function skipPrevNewline(pos, loc) {
2355
3718
  var prevLF = ctx.src.lastIndexOf("\n", pos);
2356
3719
  if (prevLF === -1) {
2357
- return pos;
3720
+ return { pos: pos, loc: loc };
2358
3721
  }
2359
3722
  if (prevLF >= 1 && ctx.src[prevLF] === "\r") {
2360
3723
  --prevLF;
2361
3724
  }
2362
3725
 
2363
3726
  if (/\S/g.test(ctx.src.slice(prevLF, pos - 1))) {
2364
- return pos;
3727
+ return { pos: pos, loc: loc };
2365
3728
  }
2366
3729
 
2367
- return prevLF;
3730
+ return {
3731
+ pos: prevLF,
3732
+ loc: {
3733
+ line: loc.line - 1,
3734
+ column: prevLF - ctx.src.lastIndexOf("\n", prevLF)
3735
+ }
3736
+ };
2368
3737
  }
2369
3738
 
2370
3739
  var str = fmt("{0}{1}{2}.$inject = {3};", EOL, indent, name, ctx.stringify(ctx, params, ctx.quot));
@@ -2374,18 +3743,31 @@ function judgeInjectArraySuspect(node, ctx) {
2374
3743
  start: existingExpressionStatementWithArray.range[0],
2375
3744
  end: existingExpressionStatementWithArray.range[1],
2376
3745
  str: str,
3746
+ loc: {
3747
+ start: existingExpressionStatementWithArray.loc.start,
3748
+ end: existingExpressionStatementWithArray.loc.end
3749
+ }
2377
3750
  });
2378
3751
  } else if (ctx.mode === "remove" && existingExpressionStatementWithArray) {
3752
+ var start = skipPrevNewline(existingExpressionStatementWithArray.range[0], existingExpressionStatementWithArray.loc.start);
2379
3753
  ctx.fragments.push({
2380
- start: skipPrevNewline(existingExpressionStatementWithArray.range[0]),
3754
+ start: start.pos,
2381
3755
  end: existingExpressionStatementWithArray.range[1],
2382
3756
  str: "",
3757
+ loc: {
3758
+ start: start.loc,
3759
+ end: existingExpressionStatementWithArray.loc.end
3760
+ }
2383
3761
  });
2384
3762
  } else if (is.someof(ctx.mode, ["add", "rebuild"]) && !existingExpressionStatementWithArray) {
2385
3763
  ctx.fragments.push({
2386
- start: posAfterFunctionDeclaration,
2387
- end: posAfterFunctionDeclaration,
3764
+ start: posAfterFunctionDeclaration.pos,
3765
+ end: posAfterFunctionDeclaration.pos,
2388
3766
  str: str,
3767
+ loc: {
3768
+ start: posAfterFunctionDeclaration.loc,
3769
+ end: posAfterFunctionDeclaration.loc
3770
+ }
2389
3771
  });
2390
3772
  }
2391
3773
  }
@@ -2469,6 +3851,7 @@ window.annotate = function ngAnnotate(src, options) {
2469
3851
  ast = parser(src, {
2470
3852
  range: true,
2471
3853
  comment: true,
3854
+ loc: true,
2472
3855
  });
2473
3856
 
2474
3857
  // Fix Program node range (https://code.google.com/p/esprima/issues/detail?id=541)
@@ -2499,6 +3882,10 @@ window.annotate = function ngAnnotate(src, options) {
2499
3882
  ast.body.push({
2500
3883
  type: "DebuggerStatement",
2501
3884
  range: [ast.range[1], ast.range[1]],
3885
+ loc: {
3886
+ start: ast.loc.end,
3887
+ end: ast.loc.end
3888
+ }
2502
3889
  });
2503
3890
 
2504
3891
  // all source modifications are built up as operations in the
@@ -2512,6 +3899,10 @@ window.annotate = function ngAnnotate(src, options) {
2512
3899
  // module definition)
2513
3900
  var suspects = [];
2514
3901
 
3902
+ // Position information for all nodes in the AST,
3903
+ // used for sourcemap generation
3904
+ var nodePositions = [];
3905
+
2515
3906
  var lut = new Lut(ast, src);
2516
3907
 
2517
3908
  scopeTools.setupScopeAndReferences(ast);
@@ -2535,6 +3926,7 @@ window.annotate = function ngAnnotate(src, options) {
2535
3926
  addModuleContextDependentSuspect: addModuleContextDependentSuspect,
2536
3927
  addModuleContextIndependentSuspect: addModuleContextIndependentSuspect,
2537
3928
  stringify: stringify,
3929
+ nodePositions: nodePositions,
2538
3930
  };
2539
3931
 
2540
3932
  var plugins = options.plugin || [];
@@ -2560,6 +3952,7 @@ window.annotate = function ngAnnotate(src, options) {
2560
3952
  }
2561
3953
 
2562
3954
  }, post: function(node) {
3955
+ ctx.nodePositions.push(node.loc.start);
2563
3956
  var targets = match(node, ctx, matchPluginsOrNull);
2564
3957
  if (!targets) {
2565
3958
  return;
@@ -2588,15 +3981,17 @@ window.annotate = function ngAnnotate(src, options) {
2588
3981
  };
2589
3982
 
2590
3983
  if (options.sourcemap) {
3984
+ if (typeof(options.sourcemap) !== 'object')
3985
+ options.sourcemap = {};
2591
3986
  stats.sourcemap_t0 = Date.now();
2592
- result.map = generateSourcemap(src, fragments, options.inFile, options.sourceroot);
3987
+ generateSourcemap(result, src, nodePositions, fragments, options.sourcemap);
2593
3988
  stats.sourcemap_t1 = Date.now();
2594
3989
  }
2595
3990
 
2596
3991
  return result;
2597
3992
  }
2598
3993
 
2599
- },{"./generate-sourcemap":8,"./lut":9,"./nginject":11,"./scopetools":13,"acorn":14,"alter":15,"assert":1,"esprima":16,"ordered-ast-traverse":18,"os":3,"simple-fmt":19,"simple-is":20,"stringmap":32}],11:[function(require,module,exports){
3994
+ },{"./generate-sourcemap":13,"./lut":14,"./nginject":16,"./scopetools":18,"acorn":19,"alter":20,"assert":2,"esprima":22,"ordered-ast-traverse":24,"os":8,"simple-fmt":25,"simple-is":26,"stringmap":38}],16:[function(require,module,exports){
2600
3995
  // nginject-comments.js
2601
3996
  // MIT licensed, see LICENSE file
2602
3997
  // Copyright (c) 2013-2014 Olov Lassus <olov.lassus@gmail.com>
@@ -2678,7 +4073,7 @@ function nestedObjectValues(node, res) {
2678
4073
  return res;
2679
4074
  }
2680
4075
 
2681
- },{"simple-fmt":19,"simple-is":20}],12:[function(require,module,exports){
4076
+ },{"simple-fmt":25,"simple-is":26}],17:[function(require,module,exports){
2682
4077
  // scope.js
2683
4078
  // MIT licensed, see LICENSE file
2684
4079
  // Copyright (c) 2013-2014 Olov Lassus <olov.lassus@gmail.com>
@@ -2838,7 +4233,7 @@ Scope.prototype.lookup = function(name) {
2838
4233
 
2839
4234
  module.exports = Scope;
2840
4235
 
2841
- },{"assert":1,"simple-fmt":19,"simple-is":20,"stringmap":32,"stringset":33}],13:[function(require,module,exports){
4236
+ },{"assert":2,"simple-fmt":25,"simple-is":26,"stringmap":38,"stringset":39}],18:[function(require,module,exports){
2842
4237
  // scopetools.js
2843
4238
  // MIT licensed, see LICENSE file
2844
4239
  // Copyright (c) 2013-2014 Olov Lassus <olov.lassus@gmail.com>
@@ -3020,7 +4415,7 @@ function isReference(node) {
3020
4415
  true;
3021
4416
  }
3022
4417
 
3023
- },{"./scope":12,"assert":1,"ordered-ast-traverse":18,"simple-is":20}],14:[function(require,module,exports){
4418
+ },{"./scope":17,"assert":2,"ordered-ast-traverse":24,"simple-is":26}],19:[function(require,module,exports){
3024
4419
  // Acorn is a tiny, fast JavaScript parser written in JavaScript.
3025
4420
  //
3026
4421
  // Acorn was written by Marijn Haverbeke and various contributors and
@@ -5609,7 +7004,7 @@ function isReference(node) {
5609
7004
 
5610
7005
  });
5611
7006
 
5612
- },{}],15:[function(require,module,exports){
7007
+ },{}],20:[function(require,module,exports){
5613
7008
  // alter.js
5614
7009
  // MIT licensed, see LICENSE file
5615
7010
  // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
@@ -5656,7 +7051,150 @@ if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
5656
7051
  module.exports = alter;
5657
7052
  }
5658
7053
 
5659
- },{"assert":1,"stable":31}],16:[function(require,module,exports){
7054
+ },{"assert":2,"stable":37}],21:[function(require,module,exports){
7055
+ (function (Buffer){
7056
+ 'use strict';
7057
+ var fs = require('fs');
7058
+ var path = require('path');
7059
+
7060
+ var commentRx = /(?:\/\/|\/\*)[@#][ \t]+sourceMappingURL=data:(?:application|text)\/json;base64,((?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?)(?:[ \t]*\*\/)?$/mg;
7061
+ var mapFileCommentRx =
7062
+ // //# sourceMappingURL=foo.js.map /*# sourceMappingURL=foo.js.map */
7063
+ /(?:\/\/[@#][ \t]+sourceMappingURL=(.+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/mg
7064
+
7065
+ function decodeBase64(base64) {
7066
+ return new Buffer(base64, 'base64').toString();
7067
+ }
7068
+
7069
+ function stripComment(sm) {
7070
+ return sm.split(',').pop();
7071
+ }
7072
+
7073
+ function readFromFileMap(sm, dir) {
7074
+ // NOTE: this will only work on the server since it attempts to read the map file
7075
+
7076
+ var r = mapFileCommentRx.exec(sm);
7077
+ mapFileCommentRx.lastIndex = 0;
7078
+
7079
+ // for some odd reason //# .. captures in 1 and /* .. */ in 2
7080
+ var filename = r[1] || r[2];
7081
+ var filepath = path.join(dir, filename);
7082
+
7083
+ try {
7084
+ return fs.readFileSync(filepath, 'utf8');
7085
+ } catch (e) {
7086
+ throw new Error('An error occurred while trying to read the map file at ' + filepath + '\n' + e);
7087
+ }
7088
+ }
7089
+
7090
+ function Converter (sm, opts) {
7091
+ opts = opts || {};
7092
+ try {
7093
+ if (opts.isFileComment) sm = readFromFileMap(sm, opts.commentFileDir);
7094
+ if (opts.hasComment) sm = stripComment(sm);
7095
+ if (opts.isEncoded) sm = decodeBase64(sm);
7096
+ if (opts.isJSON || opts.isEncoded) sm = JSON.parse(sm);
7097
+
7098
+ this.sourcemap = sm;
7099
+ } catch(e) {
7100
+ console.error(e);
7101
+ return null;
7102
+ }
7103
+ }
7104
+
7105
+ Converter.prototype.toJSON = function (space) {
7106
+ return JSON.stringify(this.sourcemap, null, space);
7107
+ };
7108
+
7109
+ Converter.prototype.toBase64 = function () {
7110
+ var json = this.toJSON();
7111
+ return new Buffer(json).toString('base64');
7112
+ };
7113
+
7114
+ Converter.prototype.toComment = function () {
7115
+ var base64 = this.toBase64();
7116
+ return '//# sourceMappingURL=data:application/json;base64,' + base64;
7117
+ };
7118
+
7119
+ // returns copy instead of original
7120
+ Converter.prototype.toObject = function () {
7121
+ return JSON.parse(this.toJSON());
7122
+ };
7123
+
7124
+ Converter.prototype.addProperty = function (key, value) {
7125
+ if (this.sourcemap.hasOwnProperty(key)) throw new Error('property %s already exists on the sourcemap, use set property instead');
7126
+ return this.setProperty(key, value);
7127
+ };
7128
+
7129
+ Converter.prototype.setProperty = function (key, value) {
7130
+ this.sourcemap[key] = value;
7131
+ return this;
7132
+ };
7133
+
7134
+ Converter.prototype.getProperty = function (key) {
7135
+ return this.sourcemap[key];
7136
+ };
7137
+
7138
+ exports.fromObject = function (obj) {
7139
+ return new Converter(obj);
7140
+ };
7141
+
7142
+ exports.fromJSON = function (json) {
7143
+ return new Converter(json, { isJSON: true });
7144
+ };
7145
+
7146
+ exports.fromBase64 = function (base64) {
7147
+ return new Converter(base64, { isEncoded: true });
7148
+ };
7149
+
7150
+ exports.fromComment = function (comment) {
7151
+ comment = comment
7152
+ .replace(/^\/\*/g, '//')
7153
+ .replace(/\*\/$/g, '');
7154
+
7155
+ return new Converter(comment, { isEncoded: true, hasComment: true });
7156
+ };
7157
+
7158
+ exports.fromMapFileComment = function (comment, dir) {
7159
+ return new Converter(comment, { commentFileDir: dir, isFileComment: true, isJSON: true });
7160
+ };
7161
+
7162
+ // Finds last sourcemap comment in file or returns null if none was found
7163
+ exports.fromSource = function (content) {
7164
+ var m = content.match(commentRx);
7165
+ commentRx.lastIndex = 0;
7166
+ return m ? exports.fromComment(m.pop()) : null;
7167
+ };
7168
+
7169
+ // Finds last sourcemap comment in file or returns null if none was found
7170
+ exports.fromMapFileSource = function (content, dir) {
7171
+ var m = content.match(mapFileCommentRx);
7172
+ mapFileCommentRx.lastIndex = 0;
7173
+ return m ? exports.fromMapFileComment(m.pop(), dir) : null;
7174
+ };
7175
+
7176
+ exports.removeComments = function (src) {
7177
+ commentRx.lastIndex = 0;
7178
+ return src.replace(commentRx, '');
7179
+ };
7180
+
7181
+ exports.removeMapFileComments = function (src) {
7182
+ mapFileCommentRx.lastIndex = 0;
7183
+ return src.replace(mapFileCommentRx, '');
7184
+ };
7185
+
7186
+ exports.__defineGetter__('commentRegex', function () {
7187
+ commentRx.lastIndex = 0;
7188
+ return commentRx;
7189
+ });
7190
+
7191
+ exports.__defineGetter__('mapFileCommentRegex', function () {
7192
+ mapFileCommentRx.lastIndex = 0;
7193
+ return mapFileCommentRx;
7194
+ });
7195
+
7196
+ }).call(this,require("buffer").Buffer)
7197
+ },{"buffer":3,"fs":1,"path":9}],22:[function(require,module,exports){
5660
7198
  /*
5661
7199
  Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
5662
7200
  Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
@@ -9414,7 +10952,7 @@ parseStatement: true, parseSourceElement: true */
9414
10952
  }));
9415
10953
  /* vim: set sw=4 ts=4 et tw=80 : */
9416
10954
 
9417
- },{}],17:[function(require,module,exports){
10955
+ },{}],23:[function(require,module,exports){
9418
10956
  // ordered-esprima-props.js
9419
10957
  // MIT licensed, see LICENSE file
9420
10958
  // Copyright (c) 2014 Olov Lassus <olov.lassus@gmail.com>
@@ -9493,7 +11031,7 @@ module.exports = (function() {
9493
11031
  };
9494
11032
  })();
9495
11033
 
9496
- },{}],18:[function(require,module,exports){
11034
+ },{}],24:[function(require,module,exports){
9497
11035
  // ordered-ast-traverse.js
9498
11036
  // MIT licensed, see LICENSE file
9499
11037
  // Copyright (c) 2014 Olov Lassus <olov.lassus@gmail.com>
@@ -9554,7 +11092,7 @@ if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
9554
11092
  module.exports = traverse;
9555
11093
  }
9556
11094
 
9557
- },{"ordered-esprima-props":17}],19:[function(require,module,exports){
11095
+ },{"ordered-esprima-props":23}],25:[function(require,module,exports){
9558
11096
  // simple-fmt.js
9559
11097
  // MIT licensed, see LICENSE file
9560
11098
  // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
@@ -9589,7 +11127,7 @@ if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
9589
11127
  module.exports = fmt;
9590
11128
  }
9591
11129
 
9592
- },{}],20:[function(require,module,exports){
11130
+ },{}],26:[function(require,module,exports){
9593
11131
  // simple-is.js
9594
11132
  // MIT licensed, see LICENSE file
9595
11133
  // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
@@ -9647,7 +11185,7 @@ if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
9647
11185
  module.exports = is;
9648
11186
  }
9649
11187
 
9650
- },{}],21:[function(require,module,exports){
11188
+ },{}],27:[function(require,module,exports){
9651
11189
  /*
9652
11190
  * Copyright 2009-2011 Mozilla Foundation and contributors
9653
11191
  * Licensed under the New BSD license. See LICENSE.txt or:
@@ -9657,7 +11195,7 @@ exports.SourceMapGenerator = require('./source-map/source-map-generator').Source
9657
11195
  exports.SourceMapConsumer = require('./source-map/source-map-consumer').SourceMapConsumer;
9658
11196
  exports.SourceNode = require('./source-map/source-node').SourceNode;
9659
11197
 
9660
- },{"./source-map/source-map-consumer":26,"./source-map/source-map-generator":27,"./source-map/source-node":28}],22:[function(require,module,exports){
11198
+ },{"./source-map/source-map-consumer":32,"./source-map/source-map-generator":33,"./source-map/source-node":34}],28:[function(require,module,exports){
9661
11199
  /* -*- Mode: js; js-indent-level: 2; -*- */
9662
11200
  /*
9663
11201
  * Copyright 2011 Mozilla Foundation and contributors
@@ -9756,7 +11294,7 @@ define(function (require, exports, module) {
9756
11294
 
9757
11295
  });
9758
11296
 
9759
- },{"./util":29,"amdefine":30}],23:[function(require,module,exports){
11297
+ },{"./util":35,"amdefine":36}],29:[function(require,module,exports){
9760
11298
  /* -*- Mode: js; js-indent-level: 2; -*- */
9761
11299
  /*
9762
11300
  * Copyright 2011 Mozilla Foundation and contributors
@@ -9900,7 +11438,7 @@ define(function (require, exports, module) {
9900
11438
 
9901
11439
  });
9902
11440
 
9903
- },{"./base64":24,"amdefine":30}],24:[function(require,module,exports){
11441
+ },{"./base64":30,"amdefine":36}],30:[function(require,module,exports){
9904
11442
  /* -*- Mode: js; js-indent-level: 2; -*- */
9905
11443
  /*
9906
11444
  * Copyright 2011 Mozilla Foundation and contributors
@@ -9944,7 +11482,7 @@ define(function (require, exports, module) {
9944
11482
 
9945
11483
  });
9946
11484
 
9947
- },{"amdefine":30}],25:[function(require,module,exports){
11485
+ },{"amdefine":36}],31:[function(require,module,exports){
9948
11486
  /* -*- Mode: js; js-indent-level: 2; -*- */
9949
11487
  /*
9950
11488
  * Copyright 2011 Mozilla Foundation and contributors
@@ -10027,7 +11565,7 @@ define(function (require, exports, module) {
10027
11565
 
10028
11566
  });
10029
11567
 
10030
- },{"amdefine":30}],26:[function(require,module,exports){
11568
+ },{"amdefine":36}],32:[function(require,module,exports){
10031
11569
  /* -*- Mode: js; js-indent-level: 2; -*- */
10032
11570
  /*
10033
11571
  * Copyright 2011 Mozilla Foundation and contributors
@@ -10512,7 +12050,7 @@ define(function (require, exports, module) {
10512
12050
 
10513
12051
  });
10514
12052
 
10515
- },{"./array-set":22,"./base64-vlq":23,"./binary-search":25,"./util":29,"amdefine":30}],27:[function(require,module,exports){
12053
+ },{"./array-set":28,"./base64-vlq":29,"./binary-search":31,"./util":35,"amdefine":36}],33:[function(require,module,exports){
10516
12054
  /* -*- Mode: js; js-indent-level: 2; -*- */
10517
12055
  /*
10518
12056
  * Copyright 2011 Mozilla Foundation and contributors
@@ -10915,7 +12453,7 @@ define(function (require, exports, module) {
10915
12453
 
10916
12454
  });
10917
12455
 
10918
- },{"./array-set":22,"./base64-vlq":23,"./util":29,"amdefine":30}],28:[function(require,module,exports){
12456
+ },{"./array-set":28,"./base64-vlq":29,"./util":35,"amdefine":36}],34:[function(require,module,exports){
10919
12457
  /* -*- Mode: js; js-indent-level: 2; -*- */
10920
12458
  /*
10921
12459
  * Copyright 2011 Mozilla Foundation and contributors
@@ -11325,7 +12863,7 @@ define(function (require, exports, module) {
11325
12863
 
11326
12864
  });
11327
12865
 
11328
- },{"./source-map-generator":27,"./util":29,"amdefine":30}],29:[function(require,module,exports){
12866
+ },{"./source-map-generator":33,"./util":35,"amdefine":36}],35:[function(require,module,exports){
11329
12867
  /* -*- Mode: js; js-indent-level: 2; -*- */
11330
12868
  /*
11331
12869
  * Copyright 2011 Mozilla Foundation and contributors
@@ -11646,7 +13184,7 @@ define(function (require, exports, module) {
11646
13184
 
11647
13185
  });
11648
13186
 
11649
- },{"amdefine":30}],30:[function(require,module,exports){
13187
+ },{"amdefine":36}],36:[function(require,module,exports){
11650
13188
  (function (process,__filename){
11651
13189
  /** vim: et:ts=4:sw=4:sts=4
11652
13190
  * @license amdefine 0.1.0 Copyright (c) 2011, The Dojo Foundation All Rights Reserved.
@@ -11949,7 +13487,7 @@ function amdefine(module, requireFn) {
11949
13487
  module.exports = amdefine;
11950
13488
 
11951
13489
  }).call(this,require('_process'),"/node_modules/ng-annotate/node_modules/source-map/node_modules/amdefine/amdefine.js")
11952
- },{"_process":5,"path":4}],31:[function(require,module,exports){
13490
+ },{"_process":10,"path":9}],37:[function(require,module,exports){
11953
13491
  //! stable.js 0.1.5, https://github.com/Two-Screen/stable
11954
13492
  //! © 2014 Angry Bytes and contributors. MIT licensed.
11955
13493
 
@@ -12062,7 +13600,7 @@ else {
12062
13600
 
12063
13601
  })();
12064
13602
 
12065
- },{}],32:[function(require,module,exports){
13603
+ },{}],38:[function(require,module,exports){
12066
13604
  // stringmap.js
12067
13605
  // MIT licensed, see LICENSE file
12068
13606
  // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
@@ -12308,7 +13846,7 @@ if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
12308
13846
  module.exports = StringMap;
12309
13847
  }
12310
13848
 
12311
- },{}],33:[function(require,module,exports){
13849
+ },{}],39:[function(require,module,exports){
12312
13850
  // stringset.js
12313
13851
  // MIT licensed, see LICENSE file
12314
13852
  // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
@@ -12491,4 +14029,4 @@ if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
12491
14029
  module.exports = StringSet;
12492
14030
  }
12493
14031
 
12494
- },{}]},{},[10]);
14032
+ },{}]},{},[15]);