a zip code crypto-currency system good for red ONLY

previous-map.js 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. 'use strict';
  2. exports.__esModule = true;
  3. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  4. var _sourceMap = require('source-map');
  5. var _sourceMap2 = _interopRequireDefault(_sourceMap);
  6. var _path = require('path');
  7. var _path2 = _interopRequireDefault(_path);
  8. var _fs = require('fs');
  9. var _fs2 = _interopRequireDefault(_fs);
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12. function fromBase64(str) {
  13. if (Buffer) {
  14. if (Buffer.from && Buffer.from !== Uint8Array.from) {
  15. return Buffer.from(str, 'base64').toString();
  16. } else {
  17. return new Buffer(str, 'base64').toString();
  18. }
  19. } else {
  20. return window.atob(str);
  21. }
  22. }
  23. /**
  24. * Source map information from input CSS.
  25. * For example, source map after Sass compiler.
  26. *
  27. * This class will automatically find source map in input CSS or in file system
  28. * near input file (according `from` option).
  29. *
  30. * @example
  31. * const root = postcss.parse(css, { from: 'a.sass.css' });
  32. * root.input.map //=> PreviousMap
  33. */
  34. var PreviousMap = function () {
  35. /**
  36. * @param {string} css - input CSS source
  37. * @param {processOptions} [opts] - {@link Processor#process} options
  38. */
  39. function PreviousMap(css, opts) {
  40. _classCallCheck(this, PreviousMap);
  41. this.loadAnnotation(css);
  42. /**
  43. * @member {boolean} - Was source map inlined by data-uri to input CSS.
  44. */
  45. this.inline = this.startWith(this.annotation, 'data:');
  46. var prev = opts.map ? opts.map.prev : undefined;
  47. var text = this.loadMap(opts.from, prev);
  48. if (text) this.text = text;
  49. }
  50. /**
  51. * Create a instance of `SourceMapGenerator` class
  52. * from the `source-map` library to work with source map information.
  53. *
  54. * It is lazy method, so it will create object only on first call
  55. * and then it will use cache.
  56. *
  57. * @return {SourceMapGenerator} object with source map information
  58. */
  59. PreviousMap.prototype.consumer = function consumer() {
  60. if (!this.consumerCache) {
  61. this.consumerCache = new _sourceMap2.default.SourceMapConsumer(this.text);
  62. }
  63. return this.consumerCache;
  64. };
  65. /**
  66. * Does source map contains `sourcesContent` with input source text.
  67. *
  68. * @return {boolean} Is `sourcesContent` present
  69. */
  70. PreviousMap.prototype.withContent = function withContent() {
  71. return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
  72. };
  73. PreviousMap.prototype.startWith = function startWith(string, start) {
  74. if (!string) return false;
  75. return string.substr(0, start.length) === start;
  76. };
  77. PreviousMap.prototype.loadAnnotation = function loadAnnotation(css) {
  78. var match = css.match(/\/\*\s*# sourceMappingURL=(.*)\s*\*\//);
  79. if (match) this.annotation = match[1].trim();
  80. };
  81. PreviousMap.prototype.decodeInline = function decodeInline(text) {
  82. // data:application/json;charset=utf-8;base64,
  83. // data:application/json;charset=utf8;base64,
  84. // data:application/json;base64,
  85. var baseUri = /^data:application\/json;(?:charset=utf-?8;)?base64,/;
  86. var uri = 'data:application/json,';
  87. if (this.startWith(text, uri)) {
  88. return decodeURIComponent(text.substr(uri.length));
  89. } else if (baseUri.test(text)) {
  90. return fromBase64(text.substr(RegExp.lastMatch.length));
  91. } else {
  92. var encoding = text.match(/data:application\/json;([^,]+),/)[1];
  93. throw new Error('Unsupported source map encoding ' + encoding);
  94. }
  95. };
  96. PreviousMap.prototype.loadMap = function loadMap(file, prev) {
  97. if (prev === false) return false;
  98. if (prev) {
  99. if (typeof prev === 'string') {
  100. return prev;
  101. } else if (typeof prev === 'function') {
  102. var prevPath = prev(file);
  103. if (prevPath && _fs2.default.existsSync && _fs2.default.existsSync(prevPath)) {
  104. return _fs2.default.readFileSync(prevPath, 'utf-8').toString().trim();
  105. } else {
  106. throw new Error('Unable to load previous source map: ' + prevPath.toString());
  107. }
  108. } else if (prev instanceof _sourceMap2.default.SourceMapConsumer) {
  109. return _sourceMap2.default.SourceMapGenerator.fromSourceMap(prev).toString();
  110. } else if (prev instanceof _sourceMap2.default.SourceMapGenerator) {
  111. return prev.toString();
  112. } else if (this.isMap(prev)) {
  113. return JSON.stringify(prev);
  114. } else {
  115. throw new Error('Unsupported previous source map format: ' + prev.toString());
  116. }
  117. } else if (this.inline) {
  118. return this.decodeInline(this.annotation);
  119. } else if (this.annotation) {
  120. var map = this.annotation;
  121. if (file) map = _path2.default.join(_path2.default.dirname(file), map);
  122. this.root = _path2.default.dirname(map);
  123. if (_fs2.default.existsSync && _fs2.default.existsSync(map)) {
  124. return _fs2.default.readFileSync(map, 'utf-8').toString().trim();
  125. } else {
  126. return false;
  127. }
  128. }
  129. };
  130. PreviousMap.prototype.isMap = function isMap(map) {
  131. if ((typeof map === 'undefined' ? 'undefined' : _typeof(map)) !== 'object') return false;
  132. return typeof map.mappings === 'string' || typeof map._mappings === 'string';
  133. };
  134. return PreviousMap;
  135. }();
  136. exports.default = PreviousMap;
  137. module.exports = exports['default'];
  138. //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByZXZpb3VzLW1hcC5lczYiXSwibmFtZXMiOlsiZnJvbUJhc2U2NCIsInN0ciIsIkJ1ZmZlciIsImZyb20iLCJVaW50OEFycmF5IiwidG9TdHJpbmciLCJ3aW5kb3ciLCJhdG9iIiwiUHJldmlvdXNNYXAiLCJjc3MiLCJvcHRzIiwibG9hZEFubm90YXRpb24iLCJpbmxpbmUiLCJzdGFydFdpdGgiLCJhbm5vdGF0aW9uIiwicHJldiIsIm1hcCIsInVuZGVmaW5lZCIsInRleHQiLCJsb2FkTWFwIiwiY29uc3VtZXIiLCJj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aW9uXFwvanNvbjsoPzpjaGFyc2V0PXV0Zi0/ODspP2Jhc2U2NCwvO1xuICAgICAgICBsZXQgdXJpICAgICA9ICdkYXRhOmFwcGxpY2F0aW9uL2pzb24sJztcblxuICAgICAgICBpZiAoIHRoaXMuc3RhcnRXaXRoKHRleHQsIHVyaSkgKSB7XG4gICAgICAgICAgICByZXR1cm4gZGVjb2RlVVJJQ29tcG9uZW50KCB0ZXh0LnN1YnN0cih1cmkubGVuZ3RoKSApO1xuXG4gICAgICAgIH0gZWxzZSBpZiAoIGJhc2VVcmkudGVzdCh0ZXh0KSApIHtcbiAgICAgICAgICAgIHJldHVybiBmcm9tQmFzZTY0KHRleHQuc3Vic3RyKFJlZ0V4cC5sYXN0TWF0Y2gubGVuZ3RoKSk7XG5cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGxldCBlbmNvZGluZyA9IHRleHQubWF0Y2goL2RhdGE6YXBwbGljYXRpb25cXC9qc29uOyhbXixdKyksLylbMV07XG4gICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ1Vuc3VwcG9ydGVkIHNvdXJjZSBtYXAgZW5jb2RpbmcgJyArIGVuY29kaW5nKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGxvYWRNYXAoZmlsZSwgcHJldikge1xuICAgICAgICBpZiAoIHByZXYgPT09IGZhbHNlICkgcmV0dXJuIGZhbHNlO1xuXG4gICAgICAgIGlmICggcHJldiApIHtcbiAgICAgICAgICAgIGlmICggdHlwZW9mIHByZXYgPT09ICdzdHJpbmcnICkge1xuICAgICAgICAgICAgICAgIHJldHVybiBwcmV2O1xuICAgICAgICAgICAgfSBlbHNlIGlmICggdHlwZW9mIHByZXYgPT09ICdmdW5jdGlvbicgKSB7XG4gICAgICAgICAgICAgICAgbGV0IHByZXZQYXRoID0gcHJldihmaWxlKTtcbiAgICAgICAgICAgICAgICBpZiAoIHByZXZQYXRoICYmIGZzLmV4aXN0c1N5bmMgJiYgZnMuZXhpc3RzU3luYyhwcmV2UGF0aCkgKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBmcy5yZWFkRmlsZVN5bmMocHJldlBhdGgsICd1dGYtOCcpLnRvU3RyaW5nKCkudHJpbSgpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignVW5hYmxlIHRvIGxvYWQgcHJldmlvdXMgc291cmNlIG1hcDogJyArXG4gICAgICAgICAgICAgICAgICAgIHByZXZQYXRoLnRvU3RyaW5nKCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSBpZiAoIHByZXYgaW5zdGFuY2VvZiBtb3ppbGxhLlNvdXJjZU1hcENvbnN1bWVyICkge1xuICAgICAgICAgICAgICAgIHJldHVybiBtb3ppbGxhLlNvdXJjZU1hcEdlbmVyYXRvclxuICAgICAgICAgICAgICAgICAgICAuZnJvbVNvdXJjZU1hcChwcmV2KS50b1N0cmluZygpO1xuICAgICAgICAgICAgfSBlbHNlIGlmICggcHJldiBpbnN0YW5jZW9mIG1vemlsbGEuU291cmNlTWFwR2VuZXJhdG9yICkge1xuICAgICAgICAgICAgICAgIHJldHVybiBwcmV2LnRvU3RyaW5nKCk7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKCB0aGlzLmlzTWFwKHByZXYpICkge1xuICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeShwcmV2KTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdVbnN1cHBvcnRlZCBwcmV2aW91cyBzb3VyY2UgbWFwIGZvcm1hdDogJyArXG4gICAgICAgICAgICAgICAgICAgIHByZXYudG9TdHJpbmcoKSk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgfSBlbHNlIGlmICggdGhpcy5pbmxpbmUgKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5kZWNvZGVJbmxpbmUodGhpcy5hbm5vdGF0aW9uKTtcblxuICAgICAgICB9IGVsc2UgaWYgKCB0aGlzLmFubm90YXRpb24gKSB7XG4gICAgICAgICAgICBsZXQgbWFwID0gdGhpcy5hbm5vdGF0aW9uO1xuICAgICAgICAgICAgaWYgKCBmaWxlICkgbWFwID0gcGF0aC5qb2luKHBhdGguZGlybmFtZShmaWxlKSwgbWFwKTtcblxuICAgICAgICAgICAgdGhpcy5yb290ID0gcGF0aC5kaXJuYW1lKG1hcCk7XG4gICAgICAgICAgICBpZiAoIGZzLmV4aXN0c1N5bmMgJiYgZnMuZXhpc3RzU3luYyhtYXApICkge1xuICAgICAgICAgICAgICAgIHJldHVybiBmcy5yZWFkRmlsZVN5bmMobWFwLCAndXRmLTgnKS50b1N0cmluZygpLnRyaW0oKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgaXNNYXAobWFwKSB7XG4gICAgICAgIGlmICggdHlwZW9mIG1hcCAhPT0gJ29iamVjdCcgKSByZXR1cm4gZmFsc2U7XG4gICAgICAgIHJldHVybiB0eXBlb2YgbWFwLm1hcHBpbmdzID09PSAnc3RyaW5nJyB8fFxuICAgICAgICAgICAgICAgdHlwZW9mIG1hcC5fbWFwcGluZ3MgPT09ICdzdHJpbmcnO1xuICAgIH1cbn1cblxuZXhwb3J0IGRlZmF1bHQgUHJldmlvdXNNYXA7XG4iXX0=