| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389 |
- /* AUTO-GENERATED. DO NOT MODIFY. */
- /*
- The MIT License (MIT)
- Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- CSS Beautifier
- ---------------
- Written by Harutyun Amirjanyan, (amirjanyan@gmail.com)
- Based on code initially developed by: Einar Lielmanis, <einar@beautifier.io>
- https://beautifier.io/
- Usage:
- css_beautify(source_text);
- css_beautify(source_text, options);
- The options are (default in brackets):
- indent_size (4) — indentation size,
- indent_char (space) — character to indent with,
- selector_separator_newline (true) - separate selectors with newline or
- not (e.g. "a,\nbr" or "a, br")
- end_with_newline (false) - end with a newline
- newline_between_rules (true) - add a new line after every css rule
- space_around_selector_separator (false) - ensure space around selector separators:
- '>', '+', '~' (e.g. "a>b" -> "a > b")
- e.g
- css_beautify(css_source_text, {
- 'indent_size': 1,
- 'indent_char': '\t',
- 'selector_separator': ' ',
- 'end_with_newline': false,
- 'newline_between_rules': true,
- 'space_around_selector_separator': true
- });
- */
- // http://www.w3.org/TR/CSS21/syndata.html#tokenization
- // http://www.w3.org/TR/css3-syntax/
- (function() {
- /* GENERATED_BUILD_OUTPUT */
- var legacy_beautify_css =
- /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
- /******/ }
- /******/ };
- /******/
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = function(exports) {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/
- /******/ // create a fake namespace object
- /******/ // mode & 1: value is a module id, require it
- /******/ // mode & 2: merge all properties of value into the ns
- /******/ // mode & 4: return value when already ns object
- /******/ // mode & 8|1: behave like require
- /******/ __webpack_require__.t = function(value, mode) {
- /******/ if(mode & 1) value = __webpack_require__(value);
- /******/ if(mode & 8) return value;
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
- /******/ var ns = Object.create(null);
- /******/ __webpack_require__.r(ns);
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
- /******/ return ns;
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 12);
- /******/ })
- /************************************************************************/
- /******/ ([
- /* 0 */,
- /* 1 */,
- /* 2 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /*jshint node:true */
- /*
- The MIT License (MIT)
- Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- */
- function OutputLine(parent) {
- this.__parent = parent;
- this.__character_count = 0;
- // use indent_count as a marker for this.__lines that have preserved indentation
- this.__indent_count = -1;
- this.__alignment_count = 0;
- this.__items = [];
- }
- OutputLine.prototype.item = function(index) {
- if (index < 0) {
- return this.__items[this.__items.length + index];
- } else {
- return this.__items[index];
- }
- };
- OutputLine.prototype.has_match = function(pattern) {
- for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) {
- if (this.__items[lastCheckedOutput].match(pattern)) {
- return true;
- }
- }
- return false;
- };
- OutputLine.prototype.set_indent = function(indent, alignment) {
- this.__indent_count = indent || 0;
- this.__alignment_count = alignment || 0;
- this.__character_count = this.__parent.baseIndentLength + this.__alignment_count + this.__indent_count * this.__parent.indent_length;
- };
- OutputLine.prototype.get_character_count = function() {
- return this.__character_count;
- };
- OutputLine.prototype.is_empty = function() {
- return this.__items.length === 0;
- };
- OutputLine.prototype.last = function() {
- if (!this.is_empty()) {
- return this.__items[this.__items.length - 1];
- } else {
- return null;
- }
- };
- OutputLine.prototype.push = function(item) {
- this.__items.push(item);
- this.__character_count += item.length;
- };
- OutputLine.prototype.push_raw = function(item) {
- this.push(item);
- var last_newline_index = item.lastIndexOf('\n');
- if (last_newline_index !== -1) {
- this.__character_count = item.length - last_newline_index;
- }
- };
- OutputLine.prototype.pop = function() {
- var item = null;
- if (!this.is_empty()) {
- item = this.__items.pop();
- this.__character_count -= item.length;
- }
- return item;
- };
- OutputLine.prototype.remove_indent = function() {
- if (this.__indent_count > 0) {
- this.__indent_count -= 1;
- this.__character_count -= this.__parent.indent_length;
- }
- };
- OutputLine.prototype.trim = function() {
- while (this.last() === ' ') {
- this.__items.pop();
- this.__character_count -= 1;
- }
- };
- OutputLine.prototype.toString = function() {
- var result = '';
- if (!this.is_empty()) {
- if (this.__indent_count >= 0) {
- result = this.__parent.get_indent_string(this.__indent_count);
- }
- if (this.__alignment_count >= 0) {
- result += this.__parent.get_alignment_string(this.__alignment_count);
- }
- result += this.__items.join('');
- }
- return result;
- };
- function IndentCache(base_string, level_string) {
- this.__cache = [base_string];
- this.__level_string = level_string;
- }
- IndentCache.prototype.__ensure_cache = function(level) {
- while (level >= this.__cache.length) {
- this.__cache.push(this.__cache[this.__cache.length - 1] + this.__level_string);
- }
- };
- IndentCache.prototype.get_level_string = function(level) {
- this.__ensure_cache(level);
- return this.__cache[level];
- };
- function Output(options, baseIndentString) {
- var indent_string = options.indent_char;
- if (options.indent_size > 1) {
- indent_string = new Array(options.indent_size + 1).join(options.indent_char);
- }
- // Set to null to continue support for auto detection of base indent level.
- baseIndentString = baseIndentString || '';
- if (options.indent_level > 0) {
- baseIndentString = new Array(options.indent_level + 1).join(indent_string);
- }
- this.__indent_cache = new IndentCache(baseIndentString, indent_string);
- this.__alignment_cache = new IndentCache('', ' ');
- this.baseIndentLength = baseIndentString.length;
- this.indent_length = indent_string.length;
- this.raw = false;
- this._end_with_newline = options.end_with_newline;
- this.__lines = [];
- this.previous_line = null;
- this.current_line = null;
- this.space_before_token = false;
- // initialize
- this.__add_outputline();
- }
- Output.prototype.__add_outputline = function() {
- this.previous_line = this.current_line;
- this.current_line = new OutputLine(this);
- this.__lines.push(this.current_line);
- };
- Output.prototype.get_line_number = function() {
- return this.__lines.length;
- };
- Output.prototype.get_indent_string = function(level) {
- return this.__indent_cache.get_level_string(level);
- };
- Output.prototype.get_alignment_string = function(level) {
- return this.__alignment_cache.get_level_string(level);
- };
- Output.prototype.is_empty = function() {
- return !this.previous_line && this.current_line.is_empty();
- };
- Output.prototype.add_new_line = function(force_newline) {
- // never newline at the start of file
- // otherwise, newline only if we didn't just add one or we're forced
- if (this.is_empty() ||
- (!force_newline && this.just_added_newline())) {
- return false;
- }
- // if raw output is enabled, don't print additional newlines,
- // but still return True as though you had
- if (!this.raw) {
- this.__add_outputline();
- }
- return true;
- };
- Output.prototype.get_code = function(eol) {
- var sweet_code = this.__lines.join('\n').replace(/[\r\n\t ]+$/, '');
- if (this._end_with_newline) {
- sweet_code += '\n';
- }
- if (eol !== '\n') {
- sweet_code = sweet_code.replace(/[\n]/g, eol);
- }
- return sweet_code;
- };
- Output.prototype.set_indent = function(indent, alignment) {
- indent = indent || 0;
- alignment = alignment || 0;
- // Never indent your first output indent at the start of the file
- if (this.__lines.length > 1) {
- this.current_line.set_indent(indent, alignment);
- return true;
- }
- this.current_line.set_indent();
- return false;
- };
- Output.prototype.add_raw_token = function(token) {
- for (var x = 0; x < token.newlines; x++) {
- this.__add_outputline();
- }
- this.current_line.push(token.whitespace_before);
- this.current_line.push_raw(token.text);
- this.space_before_token = false;
- };
- Output.prototype.add_token = function(printable_token) {
- this.add_space_before_token();
- this.current_line.push(printable_token);
- };
- Output.prototype.add_space_before_token = function() {
- if (this.space_before_token && !this.just_added_newline()) {
- this.current_line.push(' ');
- }
- this.space_before_token = false;
- };
- Output.prototype.remove_indent = function(index) {
- var output_length = this.__lines.length;
- while (index < output_length) {
- this.__lines[index].remove_indent();
- index++;
- }
- };
- Output.prototype.trim = function(eat_newlines) {
- eat_newlines = (eat_newlines === undefined) ? false : eat_newlines;
- this.current_line.trim(this.indent_string, this.baseIndentString);
- while (eat_newlines && this.__lines.length > 1 &&
- this.current_line.is_empty()) {
- this.__lines.pop();
- this.current_line = this.__lines[this.__lines.length - 1];
- this.current_line.trim();
- }
- this.previous_line = this.__lines.length > 1 ?
- this.__lines[this.__lines.length - 2] : null;
- };
- Output.prototype.just_added_newline = function() {
- return this.current_line.is_empty();
- };
- Output.prototype.just_added_blankline = function() {
- return this.is_empty() ||
- (this.current_line.is_empty() && this.previous_line.is_empty());
- };
- Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) {
- var index = this.__lines.length - 2;
- while (index >= 0) {
- var potentialEmptyLine = this.__lines[index];
- if (potentialEmptyLine.is_empty()) {
- break;
- } else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 &&
- potentialEmptyLine.item(-1) !== ends_with) {
- this.__lines.splice(index + 1, 0, new OutputLine(this));
- this.previous_line = this.__lines[this.__lines.length - 2];
- break;
- }
- index--;
- }
- };
- module.exports.Output = Output;
- /***/ }),
- /* 3 */,
- /* 4 */,
- /* 5 */,
- /* 6 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /*jshint node:true */
- /*
- The MIT License (MIT)
- Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- */
- function Options(options, merge_child_field) {
- this.raw_options = _mergeOpts(options, merge_child_field);
- // Support passing the source text back with no change
- this.disabled = this._get_boolean('disabled');
- this.eol = this._get_characters('eol', 'auto');
- this.end_with_newline = this._get_boolean('end_with_newline');
- this.indent_size = this._get_number('indent_size', 4);
- this.indent_char = this._get_characters('indent_char', ' ');
- this.indent_level = this._get_number('indent_level');
- this.preserve_newlines = this._get_boolean('preserve_newlines', true);
- this.max_preserve_newlines = this._get_number('max_preserve_newlines', 32786);
- if (!this.preserve_newlines) {
- this.max_preserve_newlines = 0;
- }
- this.indent_with_tabs = this._get_boolean('indent_with_tabs');
- if (this.indent_with_tabs) {
- this.indent_char = '\t';
- this.indent_size = 1;
- }
- // Backwards compat with 1.3.x
- this.wrap_line_length = this._get_number('wrap_line_length', this._get_number('max_char'));
- }
- Options.prototype._get_array = function(name, default_value) {
- var option_value = this.raw_options[name];
- var result = default_value || [];
- if (typeof option_value === 'object') {
- if (option_value !== null && typeof option_value.concat === 'function') {
- result = option_value.concat();
- }
- } else if (typeof option_value === 'string') {
- result = option_value.split(/[^a-zA-Z0-9_\/\-]+/);
- }
- return result;
- };
- Options.prototype._get_boolean = function(name, default_value) {
- var option_value = this.raw_options[name];
- var result = option_value === undefined ? !!default_value : !!option_value;
- return result;
- };
- Options.prototype._get_characters = function(name, default_value) {
- var option_value = this.raw_options[name];
- var result = default_value || '';
- if (typeof option_value === 'string') {
- result = option_value.replace(/\\r/, '\r').replace(/\\n/, '\n').replace(/\\t/, '\t');
- }
- return result;
- };
- Options.prototype._get_number = function(name, default_value) {
- var option_value = this.raw_options[name];
- default_value = parseInt(default_value, 10);
- if (isNaN(default_value)) {
- default_value = 0;
- }
- var result = parseInt(option_value, 10);
- if (isNaN(result)) {
- result = default_value;
- }
- return result;
- };
- Options.prototype._get_selection = function(name, selection_list, default_value) {
- var result = this._get_selection_list(name, selection_list, default_value);
- if (result.length !== 1) {
- throw new Error(
- "Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" +
- selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
- }
- return result[0];
- };
- Options.prototype._get_selection_list = function(name, selection_list, default_value) {
- if (!selection_list || selection_list.length === 0) {
- throw new Error("Selection list cannot be empty.");
- }
- default_value = default_value || [selection_list[0]];
- if (!this._is_valid_selection(default_value, selection_list)) {
- throw new Error("Invalid Default Value!");
- }
- var result = this._get_array(name, default_value);
- if (!this._is_valid_selection(result, selection_list)) {
- throw new Error(
- "Invalid Option Value: The option '" + name + "' can contain only the following values:\n" +
- selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
- }
- return result;
- };
- Options.prototype._is_valid_selection = function(result, selection_list) {
- return result.length && selection_list.length &&
- !result.some(function(item) { return selection_list.indexOf(item) === -1; });
- };
- // merges child options up with the parent options object
- // Example: obj = {a: 1, b: {a: 2}}
- // mergeOpts(obj, 'b')
- //
- // Returns: {a: 2}
- function _mergeOpts(allOptions, childFieldName) {
- var finalOpts = {};
- allOptions = _normalizeOpts(allOptions);
- var name;
- for (name in allOptions) {
- if (name !== childFieldName) {
- finalOpts[name] = allOptions[name];
- }
- }
- //merge in the per type settings for the childFieldName
- if (childFieldName && allOptions[childFieldName]) {
- for (name in allOptions[childFieldName]) {
- finalOpts[name] = allOptions[childFieldName][name];
- }
- }
- return finalOpts;
- }
- function _normalizeOpts(options) {
- var convertedOpts = {};
- var key;
- for (key in options) {
- var newKey = key.replace(/-/g, "_");
- convertedOpts[newKey] = options[key];
- }
- return convertedOpts;
- }
- module.exports.Options = Options;
- module.exports.normalizeOpts = _normalizeOpts;
- module.exports.mergeOpts = _mergeOpts;
- /***/ }),
- /* 7 */,
- /* 8 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /*jshint node:true */
- /*
- The MIT License (MIT)
- Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- */
- function InputScanner(input_string) {
- this.__input = input_string || '';
- this.__input_length = this.__input.length;
- this.__position = 0;
- }
- InputScanner.prototype.restart = function() {
- this.__position = 0;
- };
- InputScanner.prototype.back = function() {
- if (this.__position > 0) {
- this.__position -= 1;
- }
- };
- InputScanner.prototype.hasNext = function() {
- return this.__position < this.__input_length;
- };
- InputScanner.prototype.next = function() {
- var val = null;
- if (this.hasNext()) {
- val = this.__input.charAt(this.__position);
- this.__position += 1;
- }
- return val;
- };
- InputScanner.prototype.peek = function(index) {
- var val = null;
- index = index || 0;
- index += this.__position;
- if (index >= 0 && index < this.__input_length) {
- val = this.__input.charAt(index);
- }
- return val;
- };
- InputScanner.prototype.test = function(pattern, index) {
- index = index || 0;
- index += this.__position;
- pattern.lastIndex = index;
- if (index >= 0 && index < this.__input_length) {
- var pattern_match = pattern.exec(this.__input);
- return pattern_match && pattern_match.index === index;
- } else {
- return false;
- }
- };
- InputScanner.prototype.testChar = function(pattern, index) {
- // test one character regex match
- var val = this.peek(index);
- return val !== null && pattern.test(val);
- };
- InputScanner.prototype.match = function(pattern) {
- pattern.lastIndex = this.__position;
- var pattern_match = pattern.exec(this.__input);
- if (pattern_match && pattern_match.index === this.__position) {
- this.__position += pattern_match[0].length;
- } else {
- pattern_match = null;
- }
- return pattern_match;
- };
- InputScanner.prototype.read = function(pattern) {
- var val = '';
- var match = this.match(pattern);
- if (match) {
- val = match[0];
- }
- return val;
- };
- InputScanner.prototype.readUntil = function(pattern, include_match) {
- var val = '';
- var match_index = this.__position;
- pattern.lastIndex = this.__position;
- var pattern_match = pattern.exec(this.__input);
- if (pattern_match) {
- if (include_match) {
- match_index = pattern_match.index + pattern_match[0].length;
- } else {
- match_index = pattern_match.index;
- }
- } else {
- match_index = this.__input_length;
- }
- val = this.__input.substring(this.__position, match_index);
- this.__position = match_index;
- return val;
- };
- InputScanner.prototype.readUntilAfter = function(pattern) {
- return this.readUntil(pattern, true);
- };
- /* css beautifier legacy helpers */
- InputScanner.prototype.peekUntilAfter = function(pattern) {
- var start = this.__position;
- var val = this.readUntilAfter(pattern);
- this.__position = start;
- return val;
- };
- InputScanner.prototype.lookBack = function(testVal) {
- var start = this.__position - 1;
- return start >= testVal.length && this.__input.substring(start - testVal.length, start)
- .toLowerCase() === testVal;
- };
- module.exports.InputScanner = InputScanner;
- /***/ }),
- /* 9 */,
- /* 10 */,
- /* 11 */,
- /* 12 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /*jshint node:true */
- /*
- The MIT License (MIT)
- Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- */
- var Beautifier = __webpack_require__(13).Beautifier,
- Options = __webpack_require__(14).Options;
- function css_beautify(source_text, options) {
- var beautifier = new Beautifier(source_text, options);
- return beautifier.beautify();
- }
- module.exports = css_beautify;
- module.exports.defaultOptions = function() {
- return new Options();
- };
- /***/ }),
- /* 13 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /*jshint node:true */
- /*
- The MIT License (MIT)
- Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- */
- var Options = __webpack_require__(14).Options;
- var Output = __webpack_require__(2).Output;
- var InputScanner = __webpack_require__(8).InputScanner;
- var lineBreak = /\r\n|[\r\n]/;
- var allLineBreaks = /\r\n|[\r\n]/g;
- // tokenizer
- var whitespaceChar = /\s/;
- var whitespacePattern = /(?:\s|\n)+/g;
- var block_comment_pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g;
- var comment_pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g;
- function Beautifier(source_text, options) {
- this._source_text = source_text || '';
- // Allow the setting of language/file-type specific options
- // with inheritance of overall settings
- this._options = new Options(options);
- this._ch = null;
- this._input = null;
- // https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
- this.NESTED_AT_RULE = {
- "@page": true,
- "@font-face": true,
- "@keyframes": true,
- // also in CONDITIONAL_GROUP_RULE below
- "@media": true,
- "@supports": true,
- "@document": true
- };
- this.CONDITIONAL_GROUP_RULE = {
- "@media": true,
- "@supports": true,
- "@document": true
- };
- }
- Beautifier.prototype.eatString = function(endChars) {
- var result = '';
- this._ch = this._input.next();
- while (this._ch) {
- result += this._ch;
- if (this._ch === "\\") {
- result += this._input.next();
- } else if (endChars.indexOf(this._ch) !== -1 || this._ch === "\n") {
- break;
- }
- this._ch = this._input.next();
- }
- return result;
- };
- // Skips any white space in the source text from the current position.
- // When allowAtLeastOneNewLine is true, will output new lines for each
- // newline character found; if the user has preserve_newlines off, only
- // the first newline will be output
- Beautifier.prototype.eatWhitespace = function(allowAtLeastOneNewLine) {
- var result = whitespaceChar.test(this._input.peek());
- var isFirstNewLine = true;
- while (whitespaceChar.test(this._input.peek())) {
- this._ch = this._input.next();
- if (allowAtLeastOneNewLine && this._ch === '\n') {
- if (this._options.preserve_newlines || isFirstNewLine) {
- isFirstNewLine = false;
- this._output.add_new_line(true);
- }
- }
- }
- return result;
- };
- // Nested pseudo-class if we are insideRule
- // and the next special character found opens
- // a new block
- Beautifier.prototype.foundNestedPseudoClass = function() {
- var openParen = 0;
- var i = 1;
- var ch = this._input.peek(i);
- while (ch) {
- if (ch === "{") {
- return true;
- } else if (ch === '(') {
- // pseudoclasses can contain ()
- openParen += 1;
- } else if (ch === ')') {
- if (openParen === 0) {
- return false;
- }
- openParen -= 1;
- } else if (ch === ";" || ch === "}") {
- return false;
- }
- i++;
- ch = this._input.peek(i);
- }
- return false;
- };
- Beautifier.prototype.print_string = function(output_string) {
- if (this._output.just_added_newline()) {
- this._output.set_indent(this._indentLevel);
- }
- this._output.add_token(output_string);
- };
- Beautifier.prototype.preserveSingleSpace = function(isAfterSpace) {
- if (isAfterSpace) {
- this._output.space_before_token = true;
- }
- };
- Beautifier.prototype.indent = function() {
- this._indentLevel++;
- };
- Beautifier.prototype.outdent = function() {
- if (this._indentLevel > 0) {
- this._indentLevel--;
- }
- };
- /*_____________________--------------------_____________________*/
- Beautifier.prototype.beautify = function() {
- if (this._options.disabled) {
- return this._source_text;
- }
- var source_text = this._source_text;
- var eol = this._options.eol;
- if (eol === 'auto') {
- eol = '\n';
- if (source_text && lineBreak.test(source_text || '')) {
- eol = source_text.match(lineBreak)[0];
- }
- }
- // HACK: newline parsing inconsistent. This brute force normalizes the this._input.
- source_text = source_text.replace(allLineBreaks, '\n');
- // reset
- var baseIndentString = source_text.match(/^[\t ]*/)[0];
- this._output = new Output(this._options, baseIndentString);
- this._input = new InputScanner(source_text);
- this._indentLevel = 0;
- this._nestedLevel = 0;
- this._ch = null;
- var parenLevel = 0;
- var insideRule = false;
- // This is the value side of a property value pair (blue in the following ex)
- // label { content: blue }
- var insidePropertyValue = false;
- var enteringConditionalGroup = false;
- var insideAtExtend = false;
- var insideAtImport = false;
- var topCharacter = this._ch;
- while (true) {
- var whitespace = this._input.read(whitespacePattern);
- var isAfterSpace = whitespace !== '';
- var previous_ch = topCharacter;
- this._ch = this._input.next();
- topCharacter = this._ch;
- if (!this._ch) {
- break;
- } else if (this._ch === '/' && this._input.peek() === '*') {
- // /* css comment */
- // Always start block comments on a new line.
- // This handles scenarios where a block comment immediately
- // follows a property definition on the same line or where
- // minified code is being beautified.
- this._output.add_new_line();
- this._input.back();
- this.print_string(this._input.read(block_comment_pattern));
- // Ensures any new lines following the comment are preserved
- this.eatWhitespace(true);
- // Block comments are followed by a new line so they don't
- // share a line with other properties
- this._output.add_new_line();
- } else if (this._ch === '/' && this._input.peek() === '/') {
- // // single line comment
- // Preserves the space before a comment
- // on the same line as a rule
- this._output.space_before_token = true;
- this._input.back();
- this.print_string(this._input.read(comment_pattern));
- // Ensures any new lines following the comment are preserved
- this.eatWhitespace(true);
- } else if (this._ch === '@') {
- this.preserveSingleSpace(isAfterSpace);
- // deal with less propery mixins @{...}
- if (this._input.peek() === '{') {
- this.print_string(this._ch + this.eatString('}'));
- } else {
- this.print_string(this._ch);
- // strip trailing space, if present, for hash property checks
- var variableOrRule = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
- if (variableOrRule.match(/[ :]$/)) {
- // we have a variable or pseudo-class, add it and insert one space before continuing
- variableOrRule = this.eatString(": ").replace(/\s$/, '');
- this.print_string(variableOrRule);
- this._output.space_before_token = true;
- }
- variableOrRule = variableOrRule.replace(/\s$/, '');
- if (variableOrRule === 'extend') {
- insideAtExtend = true;
- } else if (variableOrRule === 'import') {
- insideAtImport = true;
- }
- // might be a nesting at-rule
- if (variableOrRule in this.NESTED_AT_RULE) {
- this._nestedLevel += 1;
- if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
- enteringConditionalGroup = true;
- }
- // might be less variable
- } else if (!insideRule && parenLevel === 0 && variableOrRule.indexOf(':') !== -1) {
- insidePropertyValue = true;
- this.indent();
- }
- }
- } else if (this._ch === '#' && this._input.peek() === '{') {
- this.preserveSingleSpace(isAfterSpace);
- this.print_string(this._ch + this.eatString('}'));
- } else if (this._ch === '{') {
- if (insidePropertyValue) {
- insidePropertyValue = false;
- this.outdent();
- }
- this.indent();
- this._output.space_before_token = true;
- this.print_string(this._ch);
- // when entering conditional groups, only rulesets are allowed
- if (enteringConditionalGroup) {
- enteringConditionalGroup = false;
- insideRule = (this._indentLevel > this._nestedLevel);
- } else {
- // otherwise, declarations are also allowed
- insideRule = (this._indentLevel >= this._nestedLevel);
- }
- if (this._options.newline_between_rules && insideRule) {
- if (this._output.previous_line && this._output.previous_line.item(-1) !== '{') {
- this._output.ensure_empty_line_above('/', ',');
- }
- }
- this.eatWhitespace(true);
- this._output.add_new_line();
- } else if (this._ch === '}') {
- this.outdent();
- this._output.add_new_line();
- if (previous_ch === '{') {
- this._output.trim(true);
- }
- insideAtImport = false;
- insideAtExtend = false;
- if (insidePropertyValue) {
- this.outdent();
- insidePropertyValue = false;
- }
- this.print_string(this._ch);
- insideRule = false;
- if (this._nestedLevel) {
- this._nestedLevel--;
- }
- this.eatWhitespace(true);
- this._output.add_new_line();
- if (this._options.newline_between_rules && !this._output.just_added_blankline()) {
- if (this._input.peek() !== '}') {
- this._output.add_new_line(true);
- }
- }
- } else if (this._ch === ":") {
- if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend) {
- // 'property: value' delimiter
- // which could be in a conditional group query
- this.print_string(':');
- if (!insidePropertyValue) {
- insidePropertyValue = true;
- this._output.space_before_token = true;
- this.eatWhitespace(true);
- this.indent();
- }
- } else {
- // sass/less parent reference don't use a space
- // sass nested pseudo-class don't use a space
- // preserve space before pseudoclasses/pseudoelements, as it means "in any child"
- if (this._input.lookBack(" ")) {
- this._output.space_before_token = true;
- }
- if (this._input.peek() === ":") {
- // pseudo-element
- this._ch = this._input.next();
- this.print_string("::");
- } else {
- // pseudo-class
- this.print_string(':');
- }
- }
- } else if (this._ch === '"' || this._ch === '\'') {
- this.preserveSingleSpace(isAfterSpace);
- this.print_string(this._ch + this.eatString(this._ch));
- this.eatWhitespace(true);
- } else if (this._ch === ';') {
- if (insidePropertyValue) {
- this.outdent();
- insidePropertyValue = false;
- }
- insideAtExtend = false;
- insideAtImport = false;
- this.print_string(this._ch);
- this.eatWhitespace(true);
- // This maintains single line comments on the same
- // line. Block comments are also affected, but
- // a new line is always output before one inside
- // that section
- if (this._input.peek() !== '/') {
- this._output.add_new_line();
- }
- } else if (this._ch === '(') { // may be a url
- if (this._input.lookBack("url")) {
- this.print_string(this._ch);
- this.eatWhitespace();
- this._ch = this._input.next();
- if (this._ch === ')' || this._ch === '"' || this._ch === '\'') {
- this._input.back();
- parenLevel++;
- } else if (this._ch) {
- this.print_string(this._ch + this.eatString(')'));
- }
- } else {
- parenLevel++;
- this.preserveSingleSpace(isAfterSpace);
- this.print_string(this._ch);
- this.eatWhitespace();
- }
- } else if (this._ch === ')') {
- this.print_string(this._ch);
- parenLevel--;
- } else if (this._ch === ',') {
- this.print_string(this._ch);
- this.eatWhitespace(true);
- if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel < 1 && !insideAtImport) {
- this._output.add_new_line();
- } else {
- this._output.space_before_token = true;
- }
- } else if ((this._ch === '>' || this._ch === '+' || this._ch === '~') && !insidePropertyValue && parenLevel < 1) {
- //handle combinator spacing
- if (this._options.space_around_combinator) {
- this._output.space_before_token = true;
- this.print_string(this._ch);
- this._output.space_before_token = true;
- } else {
- this.print_string(this._ch);
- this.eatWhitespace();
- // squash extra whitespace
- if (this._ch && whitespaceChar.test(this._ch)) {
- this._ch = '';
- }
- }
- } else if (this._ch === ']') {
- this.print_string(this._ch);
- } else if (this._ch === '[') {
- this.preserveSingleSpace(isAfterSpace);
- this.print_string(this._ch);
- } else if (this._ch === '=') { // no whitespace before or after
- this.eatWhitespace();
- this.print_string('=');
- if (whitespaceChar.test(this._ch)) {
- this._ch = '';
- }
- } else if (this._ch === '!') { // !important
- this.print_string(' ');
- this.print_string(this._ch);
- } else {
- this.preserveSingleSpace(isAfterSpace);
- this.print_string(this._ch);
- }
- }
- var sweetCode = this._output.get_code(eol);
- return sweetCode;
- };
- module.exports.Beautifier = Beautifier;
- /***/ }),
- /* 14 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /*jshint node:true */
- /*
- The MIT License (MIT)
- Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- */
- var BaseOptions = __webpack_require__(6).Options;
- function Options(options) {
- BaseOptions.call(this, options, 'css');
- this.selector_separator_newline = this._get_boolean('selector_separator_newline', true);
- this.newline_between_rules = this._get_boolean('newline_between_rules', true);
- var space_around_selector_separator = this._get_boolean('space_around_selector_separator');
- this.space_around_combinator = this._get_boolean('space_around_combinator') || space_around_selector_separator;
- }
- Options.prototype = new BaseOptions();
- module.exports.Options = Options;
- /***/ })
- /******/ ]);
- var css_beautify = legacy_beautify_css;
- /* Footer */
- if (typeof define === "function" && define.amd) {
- // Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- )
- define([], function() {
- return {
- css_beautify: css_beautify
- };
- });
- } else if (typeof exports !== "undefined") {
- // Add support for CommonJS. Just put this file somewhere on your require.paths
- // and you will be able to `var html_beautify = require("beautify").html_beautify`.
- exports.css_beautify = css_beautify;
- } else if (typeof window !== "undefined") {
- // If we're running a web page and don't have either of the above, add our one global
- window.css_beautify = css_beautify;
- } else if (typeof global !== "undefined") {
- // If we don't even have window, try global.
- global.css_beautify = css_beautify;
- }
- }());
|