You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
260 KiB

4 years ago
  1. !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t=t||self).prettierPlugins=t.prettierPlugins||{},t.prettierPlugins.babylon={}))}(this,(function(t){"use strict";var e=function(t,e){var s=new SyntaxError(t+" ("+e.start.line+":"+e.start.column+")");return s.loc=e,s};function s(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function i(t,e){return t(e={exports:{}},e.exports),e.exports}var a,r=Object.freeze({__proto__:null,default:{EOL:"\n"}}),n=i((function(t){t.exports=function(t){if("string"!=typeof t)throw new TypeError("Expected a string");var e=t.match(/(?:\r?\n)/g)||[];if(0===e.length)return null;var s=e.filter((function(t){return"\r\n"===t})).length;return s>e.length-s?"\r\n":"\n"},t.exports.graceful=function(e){return t.exports(e)||"\n"}})),o=(n.graceful,(a=r)&&a.default||a),h=i((function(t,e){function s(){var t=o;return s=function(){return t},t}function i(){var t,e=(t=n)&&t.__esModule?t:{default:t};return i=function(){return e},e}Object.defineProperty(e,"__esModule",{value:!0}),e.extract=function(t){var e=t.match(h);return e?e[0].trimLeft():""},e.strip=function(t){var e=t.match(h);return e&&e[0]?t.substring(e[0].length):t},e.parse=function(t){return f(t).pragmas},e.parseWithComments=f,e.print=function(t){var e=t.comments,a=void 0===e?"":e,r=t.pragmas,n=void 0===r?{}:r,o=(0,i().default)(a)||s().EOL,h=Object.keys(n),u=h.map((function(t){return m(t,n[t])})).reduce((function(t,e){return t.concat(e)}),[]).map((function(t){return" * "+t+o})).join("");if(!a){if(0===h.length)return"";if(1===h.length&&!Array.isArray(n[h[0]])){var l=n[h[0]];return"".concat("/**"," ").concat(m(h[0],l)[0]).concat(" */")}}var c=a.split(o).map((function(t){return"".concat(" *"," ").concat(t)})).join(o)+o;return"/**"+o+(a?c:"")+(a&&h.length?" *"+o:"")+u+" */"};var a=/\*\/$/,r=/^\/\*\*/,h=/^\s*(\/\*\*?(.|\r?\n)*?\*\/)/,u=/(^|\s+)\/\/([^\r\n]*)/g,l=/^(\r?\n)+/,c=/(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g,p=/(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g,d=/(\r?\n|^) *\* ?/g;function f(t){var e=(0,i().default)(t)||s().EOL;t=t.replace(r,"").replace(a,"").replace(d,"$1");for(var n="";n!==t;)n=t,t=t.replace(c,"".concat(e,"$1 $2").concat(e));t=t.replace(l,"").trimRight();for(var o,h=Object.create(null),f=t.replace(p,"").replace(l,"").trimRight();o=p.exec(t);){var m=o[2].replace(u,"");"string"==typeof h[o[1]]||Array.isArray(h[o[1]])?h[o[1]]=[].concat(h[o[1]],m):h[o[1]]=m}return{comments:f,pragmas:h}}function m(t,e){return[].concat(e).map((function(e){return"@".concat(t," ").concat(e).trim()}))}}));s(h);h.extract,h.strip,h.parse,h.parseWithComments,h.print;var u=function(t){var e=Object.keys(h.parse(h.extract(t)));return-1!==e.indexOf("prettier")||-1!==e.indexOf("format")},l=function(t){return t.length>0?t[t.length-1]:null};var c={locStart:function t(e,s){return!(s=s||{}).ignoreDecorators&&e.declaration&&e.declaration.decorators&&e.declaration.decorators.length>0?t(e.declaration.decorators[0]):!s.ignoreDecorators&&e.decorators&&e.decorators.length>0?t(e.decorators[0]):e.__location?e.__location.startOffset:e.range?e.range[0]:"number"==typeof e.start?e.start:e.loc?e.loc.start:null},locEnd:function t(e){var s=e.nodes&&l(e.nodes);if(s&&e.source&&!e.source.end&&(e=s),e.__location)return e.__location.endOffset;var i=e.range?e.range[1]:"number"==typeof e.end?e.end:null;return e.typeAnnotation?Math.max(i,t(e.typeAnnotation)):e.loc&&!i?e.loc.end:i}};function p(t){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function d(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function f(t,e){for(var s=0;s<e.length;s++){var i=e[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function m(t,e,s){return e&&f(t.prototype,e),s&&f(t,s),t}function y(t,e)