mirror of
https://github.com/thangisme/notes.git
synced 2024-11-01 06:27:23 -04:00
1 line
4.6 KiB
JavaScript
1 line
4.6 KiB
JavaScript
|
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var s=0;s<t.length;s++){var r=t[s];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,s,r){return s&&e(t.prototype,s),r&&e(t,r),t}}(),_comment=require("postcss/lib/comment"),_comment2=_interopRequireDefault(_comment),_parser=require("postcss/lib/parser"),_parser2=_interopRequireDefault(_parser),_rule=require("./rule"),_rule2=_interopRequireDefault(_rule),_findExtendRule=require("./find-extend-rule"),_findExtendRule2=_interopRequireDefault(_findExtendRule),_isMixinToken=require("./is-mixin-token"),_isMixinToken2=_interopRequireDefault(_isMixinToken),_lessTokenize=require("./less-tokenize"),_lessTokenize2=_interopRequireDefault(_lessTokenize),blockCommentEndPattern=/\*\/$/,LessParser=function(e){function t(){return _classCallCheck(this,t),_possibleConstructorReturn(this,Object.getPrototypeOf(t).apply(this,arguments))}return _inherits(t,e),_createClass(t,[{key:"tokenize",value:function(){this.tokens=(0,_lessTokenize2["default"])(this.input)}},{key:"rule",value:function(e){e.pop();var t=new _rule2["default"];this.init(t,e[0][2],e[0][3]),t.raws.between=this.spacesFromEnd(e),this.raw(t,"selector",e),this.current=t}},{key:"comment",value:function(e){var t=new _comment2["default"],s=e[1],r=s.slice(2).replace(blockCommentEndPattern,"");if(this.init(t,e[2],e[3]),t.source.end={line:e[4],column:e[5]},t.raws.content=s,t.raws.begin=s[0]+s[1],t.inline="inline"===e[6],t.block=!t.inline,/^\s*$/.test(r))t.text="",t.raws.left=r,t.raws.right="";else{var i=r.match(/^(\s*)([^]*[^\s])(\s*)$/);t.text=i[2],t.raws.left=i[1]||" ",t.raws.right=i[3]||" "}}},{key:"createRule",value:function(e){this.rule(this.tokens.slice(e.start,this.pos+1)),e.params[0]&&(e.isMixin||e.isExtendRule)&&this.raw(this.current,"params",e.params)}},{key:"createDeclaration",value:function(e){this.decl(this.tokens.slice(e.start,this.pos+1))}},{key:"ruleWithoutBody",value:function(e){this.createRule(e),this.current.ruleWithoutBody=!0,delete this.current.nodes,this.current.extendRule=this.current.selector.indexOf("&:extend")>=0,this.current.important=this.current.selector.indexOf("!important")>=0,this.pos--,this.end(this.tokens[this.pos])}},{key:"processEndOfRule",value:function(e){var t=e.start;if(e.isExtendRule||e.isMixin)return this.ruleWithoutBody(e),!0;if(e.colon){if(e.isEndOfBlock)for(;this.pos>t;){var s=this.tokens[this.pos][0];if("space"!==s&&"comment"!==s)break;this.pos-=1}return this.createDeclaration({start:t}),!0}return!1}},{key:"word",value:function(){var e=!1,t=!1,s=null,r=0,i=this.pos,n=(0,_isMixinToken2["default"])(this.tokens[i]),o=Boolean((0,_findExtendRule2["default"])(this.tokens,i)),a=[];for(this.pos+=1;this.pos<this.tokens.length;){var u=this.tokens[this.pos],l=u[0];if("("===l)s||(s=u),r+=1;else if(0===r){if(";"===l){var c=this.processEndOfRule({start:i,params:a,colon:t,isMixin:n,isExtendRule:o});if(c)return;break}if("{"===l)return void this.createRule({start:i,params:a,isMixin:n});if("}"===l){this.pos-=1,e=!0;break}":"===l&&(t=!0)}else")"===l&&(r-=1,0===r&&(s=null));(r||"brackets"===l||a[0])&&a.push(u),this.pos+=1}if(this.pos===this.tokens.length&&(this.pos-=1,e=!0),r>0&&this.unclosedBracket(s),e){var h=this.processEndOfRule({start:i,params:a,colon:t,isMixin:n,isExtendRule:o,isEndOfBl
|