less 4.2.2 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Gruntfile.js +0 -2
- package/LICENSE +177 -0
- package/bin/lessc +30 -23
- package/dist/less.js +768 -489
- package/dist/less.min.js +2 -2
- package/dist/less.min.js.map +1 -1
- package/lib/less/contexts.js +2 -1
- package/lib/less/contexts.js.map +1 -1
- package/lib/less/less-error.js +12 -8
- package/lib/less/less-error.js.map +1 -1
- package/lib/less/parser/parser.js +120 -21
- package/lib/less/parser/parser.js.map +1 -1
- package/lib/less/tree/atrule.js +131 -33
- package/lib/less/tree/atrule.js.map +1 -1
- package/lib/less/tree/expression.js +2 -0
- package/lib/less/tree/expression.js.map +1 -1
- package/lib/less/tree/extend.js +1 -0
- package/lib/less/tree/extend.js.map +1 -1
- package/lib/less/tree/import.js +55 -1
- package/lib/less/tree/import.js.map +1 -1
- package/lib/less/tree/quoted.js +4 -4
- package/lib/less/tree/quoted.js.map +1 -1
- package/lib/less/visitors/extend-visitor.js +6 -1
- package/lib/less/visitors/extend-visitor.js.map +1 -1
- package/lib/less/visitors/import-visitor.js +14 -1
- package/lib/less/visitors/import-visitor.js.map +1 -1
- package/lib/less/visitors/join-selector-visitor.js +4 -1
- package/lib/less/visitors/join-selector-visitor.js.map +1 -1
- package/lib/less-node/lessc-helper.js +1 -0
- package/lib/less-node/lessc-helper.js.map +1 -1
- package/package.json +138 -140
- package/test/less-test.js +3 -1
package/lib/less/contexts.js
CHANGED
|
@@ -33,7 +33,8 @@ var parseCopyProperties = [
|
|
|
33
33
|
// context
|
|
34
34
|
'processImports',
|
|
35
35
|
// Used by the import manager to stop multiple import visitors being created.
|
|
36
|
-
'pluginManager'
|
|
36
|
+
'pluginManager',
|
|
37
|
+
'quiet', // option - whether to log warnings
|
|
37
38
|
];
|
|
38
39
|
contexts.Parse = function (options) {
|
|
39
40
|
copyFromOriginal(options, this, parseCopyProperties);
|
package/lib/less/contexts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contexts.js","sourceRoot":"","sources":["../../src/less/contexts.js"],"names":[],"mappings":";;;AAAA,IAAM,QAAQ,GAAG,EAAE,CAAC;AACpB,kBAAe,QAAQ,CAAC;AACxB,6DAAyC;AAEzC,IAAM,gBAAgB,GAAG,SAAS,gBAAgB,CAAC,QAAQ,EAAE,WAAW,EAAE,gBAAgB;IACtF,IAAI,CAAC,QAAQ,EAAE;QAAE,OAAO;KAAE;IAE1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC9C,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE;YACrE,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;SACpE;KACJ;AACL,CAAC,CAAC;AAEF;;GAEG;AACH,IAAM,mBAAmB,GAAG;IACxB,UAAU;IACV,OAAO;IACP,aAAa;IACb,UAAU;IACV,eAAe;IACf,UAAU;IACV,iBAAiB;IACjB,UAAU;IACV,YAAY;IACZ,YAAY;IACZ,MAAM;IACN,cAAc;IACd,UAAU;IACV,gBAAgB;IAChB,6EAA6E;IAC7E,eAAe,
|
|
1
|
+
{"version":3,"file":"contexts.js","sourceRoot":"","sources":["../../src/less/contexts.js"],"names":[],"mappings":";;;AAAA,IAAM,QAAQ,GAAG,EAAE,CAAC;AACpB,kBAAe,QAAQ,CAAC;AACxB,6DAAyC;AAEzC,IAAM,gBAAgB,GAAG,SAAS,gBAAgB,CAAC,QAAQ,EAAE,WAAW,EAAE,gBAAgB;IACtF,IAAI,CAAC,QAAQ,EAAE;QAAE,OAAO;KAAE;IAE1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,C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aAAa,GAAG,UAAU,IAAI;IAClD,IAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;IAC3C,IAAI,OAAO,CAAC;IAEZ,IAAI,GAAG,EAAE,CAAC;IACV,OAAO,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1B,OAAO,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC;QACzB,QAAS,OAAO,EAAG;YACf,KAAK,GAAG;gBACJ,MAAM;YACV,KAAK,IAAI;gBACL,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE;oBACzD,IAAI,CAAC,IAAI,CAAE,OAAO,CAAE,CAAC;iBACxB;qBAAM;oBACH,IAAI,CAAC,GAAG,EAAE,CAAC;iBACd;gBACD,MAAM;YACV;gBACI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACnB,MAAM;SACb;KACJ;IAED,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,SAAS,cAAc,CAAC,IAAI;IACxB,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAI;IAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;AAClC,CAAC;AAED,qCAAqC","sourcesContent":["const contexts = {};\nexport default contexts;\nimport * as Constants from './constants';\n\nconst copyFromOriginal = function copyFromOriginal(original, destination, propertiesToCopy) {\n if (!original) { return; }\n\n for (let i = 0; i < propertiesToCopy.length; i++) {\n if (Object.prototype.hasOwnProperty.call(original, propertiesToCopy[i])) {\n destination[propertiesToCopy[i]] = original[propertiesToCopy[i]];\n }\n }\n};\n\n/*\n parse is used whilst parsing\n */\nconst parseCopyProperties = [\n // options\n 'paths', // option - unmodified - paths to search for imports on\n 'rewriteUrls', // option - whether to adjust URL's to be relative\n 'rootpath', // option - rootpath to append to URL's\n 'strictImports', // option -\n 'insecure', // option - whether to allow imports from insecure ssl hosts\n 'dumpLineNumbers', // option - whether to dump line numbers\n 'compress', // option - whether to compress\n 'syncImport', // option - whether to import synchronously\n 'chunkInput', // option - whether to chunk input. more performant but causes parse issues.\n 'mime', // browser only - mime type for sheet import\n 'useFileCache', // browser only - whether to use the per file session cache\n // context\n 'processImports', // option & context - whether to process imports. if false then imports will not be imported.\n // Used by the import manager to stop multiple import visitors being created.\n 'pluginManager', // Used as the plugin manager for the session\n 'quiet', // option - whether to log warnings\n];\n\ncontexts.Parse = function(options) {\n copyFromOriginal(options, this, parseCopyProperties);\n\n if (typeof this.paths === 'string') { this.paths = [this.paths]; }\n};\n\nconst evalCopyProperties = [\n 'paths', // additional include paths\n 'compress', // whether to compress\n 'math', // whether math has to be within parenthesis\n 'strictUnits', // whether units need to evaluate correctly\n 'sourceMap', // whether to output a source map\n 'importMultiple', // whether we are currently importing multiple copies\n 'urlArgs', // whether to add args into url tokens\n 'javascriptEnabled', // option - whether Inline JavaScript is enabled. if undefined, defaults to false\n 'pluginManager', // Used as the plugin manager for the session\n 'importantScope', // used to bubble up !important statements\n 'rewriteUrls' // option - whether to adjust URL's to be relative\n];\n\ncontexts.Eval = function(options, frames) {\n copyFromOriginal(options, this, evalCopyProperties);\n\n if (typeof this.paths === 'string') { this.paths = [this.paths]; }\n\n this.frames = frames || [];\n this.importantScope = this.importantScope || [];\n};\n\ncontexts.Eval.prototype.enterCalc = function () {\n if (!this.calcStack) {\n this.calcStack = [];\n }\n this.calcStack.push(true);\n this.inCalc = true;\n};\n\ncontexts.Eval.prototype.exitCalc = function () {\n this.calcStack.pop();\n if (!this.calcStack.length) {\n this.inCalc = false;\n }\n};\n\ncontexts.Eval.prototype.inParenthesis = function () {\n if (!this.parensStack) {\n this.parensStack = [];\n }\n this.parensStack.push(true);\n};\n\ncontexts.Eval.prototype.outOfParenthesis = function () {\n this.parensStack.pop();\n};\n\ncontexts.Eval.prototype.inCalc = false;\ncontexts.Eval.prototype.mathOn = true;\ncontexts.Eval.prototype.isMathOn = function (op) {\n if (!this.mathOn) {\n return false;\n }\n if (op === '/' && this.math !== Constants.Math.ALWAYS && (!this.parensStack || !this.parensStack.length)) {\n return false;\n }\n if (this.math > Constants.Math.PARENS_DIVISION) {\n return this.parensStack && this.parensStack.length;\n }\n return true;\n};\n\ncontexts.Eval.prototype.pathRequiresRewrite = function (path) {\n const isRelative = this.rewriteUrls === Constants.RewriteUrls.LOCAL ? isPathLocalRelative : isPathRelative;\n\n return isRelative(path);\n};\n\ncontexts.Eval.prototype.rewritePath = function (path, rootpath) {\n let newPath;\n\n rootpath = rootpath || '';\n newPath = this.normalizePath(rootpath + path);\n\n // If a path was explicit relative and the rootpath was not an absolute path\n // we must ensure that the new path is also explicit relative.\n if (isPathLocalRelative(path) &&\n isPathRelative(rootpath) &&\n isPathLocalRelative(newPath) === false) {\n newPath = `./${newPath}`;\n }\n\n return newPath;\n};\n\ncontexts.Eval.prototype.normalizePath = function (path) {\n const segments = path.split('/').reverse();\n let segment;\n\n path = [];\n while (segments.length !== 0) {\n segment = segments.pop();\n switch ( segment ) {\n case '.':\n break;\n case '..':\n if ((path.length === 0) || (path[path.length - 1] === '..')) {\n path.push( segment );\n } else {\n path.pop();\n }\n break;\n default:\n path.push(segment);\n break;\n }\n }\n\n return path.join('/');\n};\n\nfunction isPathRelative(path) {\n return !/^(?:[a-z-]+:|\\/|#)/i.test(path);\n}\n\nfunction isPathLocalRelative(path) {\n return path.charAt(0) === '.';\n}\n\n// todo - do the same for the toCSS ?\n"]}
|
package/lib/less/less-error.js
CHANGED
|
@@ -95,20 +95,24 @@ LessError.prototype.constructor = LessError;
|
|
|
95
95
|
* @returns {string}
|
|
96
96
|
*/
|
|
97
97
|
LessError.prototype.toString = function (options) {
|
|
98
|
+
var _a;
|
|
98
99
|
options = options || {};
|
|
100
|
+
var isWarning = ((_a = this.type) !== null && _a !== void 0 ? _a : '').toLowerCase().includes('warning');
|
|
101
|
+
var type = isWarning ? this.type : "".concat(this.type, "Error");
|
|
102
|
+
var color = isWarning ? 'yellow' : 'red';
|
|
99
103
|
var message = '';
|
|
100
104
|
var extract = this.extract || [];
|
|
101
105
|
var error = [];
|
|
102
106
|
var stylize = function (str) { return str; };
|
|
103
107
|
if (options.stylize) {
|
|
104
|
-
var
|
|
105
|
-
if (
|
|
106
|
-
throw Error("options.stylize should be a function, got a ".concat(
|
|
108
|
+
var type_1 = typeof options.stylize;
|
|
109
|
+
if (type_1 !== 'function') {
|
|
110
|
+
throw Error("options.stylize should be a function, got a ".concat(type_1, "!"));
|
|
107
111
|
}
|
|
108
112
|
stylize = options.stylize;
|
|
109
113
|
}
|
|
110
114
|
if (this.line !== null) {
|
|
111
|
-
if (typeof extract[0] === 'string') {
|
|
115
|
+
if (!isWarning && typeof extract[0] === 'string') {
|
|
112
116
|
error.push(stylize("".concat(this.line - 1, " ").concat(extract[0]), 'grey'));
|
|
113
117
|
}
|
|
114
118
|
if (typeof extract[1] === 'string') {
|
|
@@ -120,21 +124,21 @@ LessError.prototype.toString = function (options) {
|
|
|
120
124
|
}
|
|
121
125
|
error.push(errorTxt);
|
|
122
126
|
}
|
|
123
|
-
if (typeof extract[2] === 'string') {
|
|
127
|
+
if (!isWarning && typeof extract[2] === 'string') {
|
|
124
128
|
error.push(stylize("".concat(this.line + 1, " ").concat(extract[2]), 'grey'));
|
|
125
129
|
}
|
|
126
130
|
error = "".concat(error.join('\n') + stylize('', 'reset'), "\n");
|
|
127
131
|
}
|
|
128
|
-
message += stylize("".concat(
|
|
132
|
+
message += stylize("".concat(type, ": ").concat(this.message), color);
|
|
129
133
|
if (this.filename) {
|
|
130
|
-
message += stylize(' in ',
|
|
134
|
+
message += stylize(' in ', color) + this.filename;
|
|
131
135
|
}
|
|
132
136
|
if (this.line) {
|
|
133
137
|
message += stylize(" on line ".concat(this.line, ", column ").concat(this.column + 1, ":"), 'grey');
|
|
134
138
|
}
|
|
135
139
|
message += "\n".concat(error);
|
|
136
140
|
if (this.callLine) {
|
|
137
|
-
message += "".concat(stylize('from ',
|
|
141
|
+
message += "".concat(stylize('from ', color) + (this.filename || ''), "/n");
|
|
138
142
|
message += "".concat(stylize(this.callLine, 'grey'), " ").concat(this.callExtract, "/n");
|
|
139
143
|
}
|
|
140
144
|
return message;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"less-error.js","sourceRoot":"","sources":["../../src/less/less-error.js"],"names":[],"mappings":";;;AAAA,qDAAiC;AAEjC,IAAM,aAAa,GAAG,oCAAoC,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,IAAM,SAAS,GAAG,UAAS,CAAC,EAAE,cAAc,EAAE,eAAe;IACzD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEjB,IAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,IAAI,eAAe,CAAC;IAE/C,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC;IACzB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;IAErB,IAAI,cAAc,IAAI,QAAQ,EAAE;QAC5B,IAAM,KAAK,GAAG,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAChD,IAAM,GAAG,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC9C,IAAI,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACpB,IAAM,GAAG,GAAI,GAAG,CAAC,MAAM,CAAC;QACxB,IAAM,QAAQ,GAAG,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC;QACjE,IAAM,KAAK,GAAG,KAAK,CAAC,CA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AI,CAAC,IAAI,oBAAU,IAAI,CAAC,OAAO,CAAE,EAAE,KAAK,CAAC,CAAC;IAChE,IAAI,IAAI,CAAC,QAAQ,EAAE;QACf,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;KACrD;IACD,IAAI,IAAI,CAAC,IAAI,EAAE;QACX,OAAO,IAAI,OAAO,CAAC,mBAAY,IAAI,CAAC,IAAI,sBAAY,IAAI,CAAC,MAAM,GAAG,CAAC,MAAG,EAAE,MAAM,CAAC,CAAC;KACnF;IAED,OAAO,IAAI,YAAK,KAAK,CAAE,CAAC;IAExB,IAAI,IAAI,CAAC,QAAQ,EAAE;QACf,OAAO,IAAI,UAAG,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,OAAI,CAAC;QAClE,OAAO,IAAI,UAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,cAAI,IAAI,CAAC,WAAW,OAAI,CAAC;KACxE;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["import * as utils from './utils';\n\nconst anonymousFunc = /(<anonymous>|Function):(\\d+):(\\d+)/;\n\n/**\n * This is a centralized class of any error that could be thrown internally (mostly by the parser).\n * Besides standard .message it keeps some additional data like a path to the file where the error\n * occurred along with line and column numbers.\n *\n * @class\n * @extends Error\n * @type {module.LessError}\n *\n * @prop {string} type\n * @prop {string} filename\n * @prop {number} index\n * @prop {number} line\n * @prop {number} column\n * @prop {number} callLine\n * @prop {number} callExtract\n * @prop {string[]} extract\n *\n * @param {Object} e - An error object to wrap around or just a descriptive object\n * @param {Object} fileContentMap - An object with file contents in 'contents' property (like importManager) @todo - move to fileManager?\n * @param {string} [currentFilename]\n */\nconst LessError = function(e, fileContentMap, currentFilename) {\n Error.call(this);\n\n const filename = e.filename || currentFilename;\n\n this.message = e.message;\n this.stack = e.stack;\n\n if (fileContentMap && filename) {\n const input = fileContentMap.contents[filename];\n const loc = utils.getLocation(e.index, input);\n var line = loc.line;\n const col = loc.column;\n const callLine = e.call && utils.getLocation(e.call, input).line;\n const lines = input ? input.split('\\n') : '';\n\n this.type = e.type || 'Syntax';\n this.filename = filename;\n this.index = e.index;\n this.line = typeof line === 'number' ? line + 1 : null;\n this.column = col;\n\n if (!this.line && this.stack) {\n const found = this.stack.match(anonymousFunc);\n\n /**\n * We have to figure out how this environment stringifies anonymous functions\n * so we can correctly map plugin errors.\n * \n * Note, in Node 8, the output of anonymous funcs varied based on parameters\n * being present or not, so we inject dummy params.\n */\n const func = new Function('a', 'throw new Error()');\n let lineAdjust = 0;\n try {\n func();\n } catch (e) {\n const match = e.stack.match(anonymousFunc);\n lineAdjust = 1 - parseInt(match[2]);\n }\n\n if (found) {\n if (found[2]) {\n this.line = parseInt(found[2]) + lineAdjust;\n }\n if (found[3]) {\n this.column = parseInt(found[3]);\n }\n }\n }\n\n this.callLine = callLine + 1;\n this.callExtract = lines[callLine];\n\n this.extract = [\n lines[this.line - 2],\n lines[this.line - 1],\n lines[this.line]\n ];\n }\n\n};\n\nif (typeof Object.create === 'undefined') {\n const F = function () {};\n F.prototype = Error.prototype;\n LessError.prototype = new F();\n} else {\n LessError.prototype = Object.create(Error.prototype);\n}\n\nLessError.prototype.constructor = LessError;\n\n/**\n * An overridden version of the default Object.prototype.toString\n * which uses additional information to create a helpful message.\n *\n * @param {Object} options\n * @returns {string}\n */\nLessError.prototype.toString = function(options) {\n options = options || {};\n\n let message = '';\n const extract = this.extract || [];\n let error = [];\n let stylize = function (str) { return str; };\n if (options.stylize) {\n const type = typeof options.stylize;\n if (type !== 'function') {\n throw Error(`options.stylize should be a function, got a ${type}!`);\n }\n stylize = options.stylize;\n }\n\n if (this.line !== null) {\n if (typeof extract[0] === 'string') {\n error.push(stylize(`${this.line - 1} ${extract[0]}`, 'grey'));\n }\n\n if (typeof extract[1] === 'string') {\n let errorTxt = `${this.line} `;\n if (extract[1]) {\n errorTxt += extract[1].slice(0, this.column) +\n stylize(stylize(stylize(extract[1].substr(this.column, 1), 'bold') +\n extract[1].slice(this.column + 1), 'red'), 'inverse');\n }\n error.push(errorTxt);\n }\n\n if (typeof extract[2] === 'string') {\n error.push(stylize(`${this.line + 1} ${extract[2]}`, 'grey'));\n }\n error = `${error.join('\\n') + stylize('', 'reset')}\\n`;\n }\n\n message += stylize(`${this.type}Error: ${this.message}`, 'red');\n if (this.filename) {\n message += stylize(' in ', 'red') + this.filename;\n }\n if (this.line) {\n message += stylize(` on line ${this.line}, column ${this.column + 1}:`, 'grey');\n }\n\n message += `\\n${error}`;\n\n if (this.callLine) {\n message += `${stylize('from ', 'red') + (this.filename || '')}/n`;\n message += `${stylize(this.callLine, 'grey')} ${this.callExtract}/n`;\n }\n\n return message;\n};\n\nexport default LessError;"]}
|
|
1
|
+
{"version":3,"file":"less-error.js","sourceRoot":"","sources":["../../src/less/less-error.js"],"names":[],"mappings":";;;AAAA,qDAAiC;AAEjC,IAAM,aAAa,GAAG,oCAAoC,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,IAAM,SAAS,GAAG,UAAS,CAAC,EAAE,cAAc,EAAE,eAAe;IACzD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEjB,IAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,IAAI,eAAe,CAAC;IAE/C,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC;IACzB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;IAErB,IAAI,cAAc,IAAI,QAAQ,EAAE;QAC5B,IAAM,KAAK,GAAG,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAChD,IAAM,GAAG,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC9C,IAAI,IAAI,G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CAAC,cAAI,IAAI,CAAC,WAAW,OAAI,CAAC;KACxE;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["import * as utils from './utils';\n\nconst anonymousFunc = /(<anonymous>|Function):(\\d+):(\\d+)/;\n\n/**\n * This is a centralized class of any error that could be thrown internally (mostly by the parser).\n * Besides standard .message it keeps some additional data like a path to the file where the error\n * occurred along with line and column numbers.\n *\n * @class\n * @extends Error\n * @type {module.LessError}\n *\n * @prop {string} type\n * @prop {string} filename\n * @prop {number} index\n * @prop {number} line\n * @prop {number} column\n * @prop {number} callLine\n * @prop {number} callExtract\n * @prop {string[]} extract\n *\n * @param {Object} e - An error object to wrap around or just a descriptive object\n * @param {Object} fileContentMap - An object with file contents in 'contents' property (like importManager) @todo - move to fileManager?\n * @param {string} [currentFilename]\n */\nconst LessError = function(e, fileContentMap, currentFilename) {\n Error.call(this);\n\n const filename = e.filename || currentFilename;\n\n this.message = e.message;\n this.stack = e.stack;\n\n if (fileContentMap && filename) {\n const input = fileContentMap.contents[filename];\n const loc = utils.getLocation(e.index, input);\n var line = loc.line;\n const col = loc.column;\n const callLine = e.call && utils.getLocation(e.call, input).line;\n const lines = input ? input.split('\\n') : '';\n\n this.type = e.type || 'Syntax';\n this.filename = filename;\n this.index = e.index;\n this.line = typeof line === 'number' ? line + 1 : null;\n this.column = col;\n\n if (!this.line && this.stack) {\n const found = this.stack.match(anonymousFunc);\n\n /**\n * We have to figure out how this environment stringifies anonymous functions\n * so we can correctly map plugin errors.\n * \n * Note, in Node 8, the output of anonymous funcs varied based on parameters\n * being present or not, so we inject dummy params.\n */\n const func = new Function('a', 'throw new Error()');\n let lineAdjust = 0;\n try {\n func();\n } catch (e) {\n const match = e.stack.match(anonymousFunc);\n lineAdjust = 1 - parseInt(match[2]);\n }\n\n if (found) {\n if (found[2]) {\n this.line = parseInt(found[2]) + lineAdjust;\n }\n if (found[3]) {\n this.column = parseInt(found[3]);\n }\n }\n }\n\n this.callLine = callLine + 1;\n this.callExtract = lines[callLine];\n\n this.extract = [\n lines[this.line - 2],\n lines[this.line - 1],\n lines[this.line]\n ];\n }\n\n};\n\nif (typeof Object.create === 'undefined') {\n const F = function () {};\n F.prototype = Error.prototype;\n LessError.prototype = new F();\n} else {\n LessError.prototype = Object.create(Error.prototype);\n}\n\nLessError.prototype.constructor = LessError;\n\n/**\n * An overridden version of the default Object.prototype.toString\n * which uses additional information to create a helpful message.\n *\n * @param {Object} options\n * @returns {string}\n */\nLessError.prototype.toString = function(options) {\n options = options || {};\n const isWarning = (this.type ?? '').toLowerCase().includes('warning');\n const type = isWarning ? this.type : `${this.type}Error`;\n const color = isWarning ? 'yellow' : 'red';\n\n let message = '';\n const extract = this.extract || [];\n let error = [];\n let stylize = function (str) { return str; };\n if (options.stylize) {\n const type = typeof options.stylize;\n if (type !== 'function') {\n throw Error(`options.stylize should be a function, got a ${type}!`);\n }\n stylize = options.stylize;\n }\n\n if (this.line !== null) {\n if (!isWarning && typeof extract[0] === 'string') {\n error.push(stylize(`${this.line - 1} ${extract[0]}`, 'grey'));\n }\n\n if (typeof extract[1] === 'string') {\n let errorTxt = `${this.line} `;\n if (extract[1]) {\n errorTxt += extract[1].slice(0, this.column) +\n stylize(stylize(stylize(extract[1].substr(this.column, 1), 'bold') +\n extract[1].slice(this.column + 1), 'red'), 'inverse');\n }\n error.push(errorTxt);\n }\n\n if (!isWarning && typeof extract[2] === 'string') {\n error.push(stylize(`${this.line + 1} ${extract[2]}`, 'grey'));\n }\n error = `${error.join('\\n') + stylize('', 'reset')}\\n`;\n }\n\n message += stylize(`${type}: ${this.message}`, color);\n if (this.filename) {\n message += stylize(' in ', color) + this.filename;\n }\n if (this.line) {\n message += stylize(` on line ${this.line}, column ${this.column + 1}:`, 'grey');\n }\n\n message += `\\n${error}`;\n\n if (this.callLine) {\n message += `${stylize('from ', color) + (this.filename || '')}/n`;\n message += `${stylize(this.callLine, 'grey')} ${this.callExtract}/n`;\n }\n\n return message;\n};\n\nexport default LessError;"]}
|
|
@@ -8,6 +8,7 @@ var parser_input_1 = tslib_1.__importDefault(require("./parser-input"));
|
|
|
8
8
|
var utils = tslib_1.__importStar(require("../utils"));
|
|
9
9
|
var function_registry_1 = tslib_1.__importDefault(require("../functions/function-registry"));
|
|
10
10
|
var atrule_syntax_1 = require("../tree/atrule-syntax");
|
|
11
|
+
var logger_1 = tslib_1.__importDefault(require("../logger"));
|
|
11
12
|
var selector_1 = tslib_1.__importDefault(require("../tree/selector"));
|
|
12
13
|
var anonymous_1 = tslib_1.__importDefault(require("../tree/anonymous"));
|
|
13
14
|
//
|
|
@@ -54,6 +55,22 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
54
55
|
message: msg
|
|
55
56
|
}, imports);
|
|
56
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @param {string} msg
|
|
61
|
+
* @param {number} index
|
|
62
|
+
* @param {string} type
|
|
63
|
+
*/
|
|
64
|
+
function warn(msg, index, type) {
|
|
65
|
+
if (!context.quiet) {
|
|
66
|
+
logger_1.default.warn((new less_error_1.default({
|
|
67
|
+
index: index !== null && index !== void 0 ? index : parserInput.i,
|
|
68
|
+
filename: fileInfo.filename,
|
|
69
|
+
type: type ? "".concat(type.toUpperCase(), " WARNING") : 'WARNING',
|
|
70
|
+
message: msg
|
|
71
|
+
}, imports)).toString());
|
|
72
|
+
}
|
|
73
|
+
}
|
|
57
74
|
function expect(arg, msg) {
|
|
58
75
|
// some older browsers return typeof 'function' for RegExp
|
|
59
76
|
var result = (arg instanceof Function) ? arg.call(parsers) : parserInput.$re(arg);
|
|
@@ -761,11 +778,20 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
761
778
|
do {
|
|
762
779
|
option = null;
|
|
763
780
|
elements = null;
|
|
764
|
-
|
|
781
|
+
var first = true;
|
|
782
|
+
while (!(option = parserInput.$re(/^(!?all)(?=\s*(\)|,))/))) {
|
|
765
783
|
e = this.element();
|
|
766
784
|
if (!e) {
|
|
767
785
|
break;
|
|
768
786
|
}
|
|
787
|
+
/**
|
|
788
|
+
* @note - This will not catch selectors in pseudos like :is() and :where() because
|
|
789
|
+
* they don't currently parse their contents as selectors.
|
|
790
|
+
*/
|
|
791
|
+
if (!first && e.combinator.value) {
|
|
792
|
+
warn('Targeting complex selectors can have unexpected behavior, and this behavior may change in the future.', index);
|
|
793
|
+
}
|
|
794
|
+
first = false;
|
|
769
795
|
if (elements) {
|
|
770
796
|
elements.push(e);
|
|
771
797
|
}
|
|
@@ -825,16 +851,23 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
825
851
|
var elements;
|
|
826
852
|
var args;
|
|
827
853
|
var hasParens;
|
|
854
|
+
var parensIndex;
|
|
855
|
+
var parensWS = false;
|
|
828
856
|
if (s !== '.' && s !== '#') {
|
|
829
857
|
return;
|
|
830
858
|
}
|
|
831
859
|
parserInput.save(); // stop us absorbing part of an invalid selector
|
|
832
860
|
elements = this.elements();
|
|
833
861
|
if (elements) {
|
|
862
|
+
parensIndex = parserInput.i;
|
|
834
863
|
if (parserInput.$char('(')) {
|
|
864
|
+
parensWS = parserInput.isWhitespace(-2);
|
|
835
865
|
args = this.args(true).args;
|
|
836
866
|
expectChar(')');
|
|
837
867
|
hasParens = true;
|
|
868
|
+
if (parensWS) {
|
|
869
|
+
warn('Whitespace between a mixin name and parentheses for a mixin call is deprecated', parensIndex, 'DEPRECATED');
|
|
870
|
+
}
|
|
838
871
|
}
|
|
839
872
|
if (getLookup !== false) {
|
|
840
873
|
lookups = this.ruleLookups();
|
|
@@ -858,6 +891,9 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
858
891
|
return new tree_1.default.NamespaceValue(mixin, lookups);
|
|
859
892
|
}
|
|
860
893
|
else {
|
|
894
|
+
if (!hasParens) {
|
|
895
|
+
warn('Calling a mixin without parentheses is deprecated', parensIndex, 'DEPRECATED');
|
|
896
|
+
}
|
|
861
897
|
return mixin;
|
|
862
898
|
}
|
|
863
899
|
}
|
|
@@ -1147,24 +1183,25 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1147
1183
|
expectChar(')');
|
|
1148
1184
|
return new tree_1.default.Quoted('', "alpha(opacity=".concat(value, ")"));
|
|
1149
1185
|
},
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1186
|
+
/**
|
|
1187
|
+
* A Selector Element
|
|
1188
|
+
*
|
|
1189
|
+
* div
|
|
1190
|
+
* + h1
|
|
1191
|
+
* #socks
|
|
1192
|
+
* input[type="text"]
|
|
1193
|
+
*
|
|
1194
|
+
* Elements are the building blocks for Selectors,
|
|
1195
|
+
* they are made out of a `Combinator` (see combinator rule),
|
|
1196
|
+
* and an element name, such as a tag a class, or `*`.
|
|
1197
|
+
*/
|
|
1162
1198
|
element: function () {
|
|
1163
1199
|
var e;
|
|
1164
1200
|
var c;
|
|
1165
1201
|
var v;
|
|
1166
1202
|
var index = parserInput.i;
|
|
1167
1203
|
c = this.combinator();
|
|
1204
|
+
/** This selector parser is quite simplistic and will pass a number of invalid selectors. */
|
|
1168
1205
|
e = parserInput.$re(/^(?:\d+\.\d+|\d+)%/) ||
|
|
1169
1206
|
// eslint-disable-next-line no-control-regex
|
|
1170
1207
|
parserInput.$re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) ||
|
|
@@ -1465,7 +1502,7 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1465
1502
|
value = new anonymous_1.default('');
|
|
1466
1503
|
}
|
|
1467
1504
|
else {
|
|
1468
|
-
value = this.permissiveValue(/[;}]
|
|
1505
|
+
value = this.permissiveValue(/[;}]/, true);
|
|
1469
1506
|
}
|
|
1470
1507
|
}
|
|
1471
1508
|
// Try to store values as anonymous
|
|
@@ -1485,7 +1522,12 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1485
1522
|
important = this.important();
|
|
1486
1523
|
}
|
|
1487
1524
|
else if (isVariable) {
|
|
1488
|
-
|
|
1525
|
+
/**
|
|
1526
|
+
* As a last resort, try permissiveValue
|
|
1527
|
+
*
|
|
1528
|
+
* @todo - This has created some knock-on problems of not
|
|
1529
|
+
* flagging incorrect syntax or detecting user intent.
|
|
1530
|
+
*/
|
|
1489
1531
|
value = this.permissiveValue();
|
|
1490
1532
|
}
|
|
1491
1533
|
}
|
|
@@ -1516,6 +1558,8 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1516
1558
|
* First, it will try to parse comments and entities to reach
|
|
1517
1559
|
* the end. This is mostly like the Expression parser except no
|
|
1518
1560
|
* math is allowed.
|
|
1561
|
+
*
|
|
1562
|
+
* @param {RexExp} untilTokens - Characters to stop parsing at
|
|
1519
1563
|
*/
|
|
1520
1564
|
permissiveValue: function (untilTokens) {
|
|
1521
1565
|
var i;
|
|
@@ -1577,6 +1621,7 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1577
1621
|
parserInput.forget();
|
|
1578
1622
|
return new tree_1.default.Anonymous('', index);
|
|
1579
1623
|
}
|
|
1624
|
+
/** @type {string} */
|
|
1580
1625
|
var item = void 0;
|
|
1581
1626
|
for (i = 0; i < value.length; i++) {
|
|
1582
1627
|
item = value[i];
|
|
@@ -1590,10 +1635,16 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1590
1635
|
}
|
|
1591
1636
|
// Treat like quoted values, but replace vars like unquoted expressions
|
|
1592
1637
|
var quote = new tree_1.default.Quoted('\'', item, true, index, fileInfo);
|
|
1593
|
-
|
|
1594
|
-
|
|
1638
|
+
var variableRegex = /@([\w-]+)/g;
|
|
1639
|
+
var propRegex = /\$([\w-]+)/g;
|
|
1640
|
+
if (variableRegex.test(item)) {
|
|
1641
|
+
warn('@[ident] in unknown values will not be evaluated as variables in the future. Use @{[ident]}', index, 'DEPRECATED');
|
|
1642
|
+
}
|
|
1643
|
+
if (propRegex.test(item)) {
|
|
1644
|
+
warn('$[ident] in unknown values will not be evaluated as property references in the future. Use ${[ident]}', index, 'DEPRECATED');
|
|
1595
1645
|
}
|
|
1596
|
-
quote.
|
|
1646
|
+
quote.variableRegex = /@([\w-]+)|@{([\w-]+)}/g;
|
|
1647
|
+
quote.propRegex = /\$([\w-]+)|\${([\w-]+)}/g;
|
|
1597
1648
|
result.push(quote);
|
|
1598
1649
|
}
|
|
1599
1650
|
}
|
|
@@ -1848,6 +1899,7 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1848
1899
|
var hasUnknown;
|
|
1849
1900
|
var hasBlock = true;
|
|
1850
1901
|
var isRooted = true;
|
|
1902
|
+
var isKeywordList = false;
|
|
1851
1903
|
if (parserInput.currentChar() !== '@') {
|
|
1852
1904
|
return;
|
|
1853
1905
|
}
|
|
@@ -1882,6 +1934,12 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1882
1934
|
hasUnknown = true;
|
|
1883
1935
|
isRooted = false;
|
|
1884
1936
|
break;
|
|
1937
|
+
case '@starting-style':
|
|
1938
|
+
isRooted = false;
|
|
1939
|
+
break;
|
|
1940
|
+
case '@layer':
|
|
1941
|
+
isRooted = false;
|
|
1942
|
+
break;
|
|
1885
1943
|
default:
|
|
1886
1944
|
hasUnknown = true;
|
|
1887
1945
|
break;
|
|
@@ -1913,8 +1971,33 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1913
1971
|
}
|
|
1914
1972
|
if (hasBlock) {
|
|
1915
1973
|
rules = this.blockRuleset();
|
|
1974
|
+
parserInput.save();
|
|
1975
|
+
if (!rules && !isRooted) {
|
|
1976
|
+
value = this.entity();
|
|
1977
|
+
rules = this.blockRuleset();
|
|
1978
|
+
}
|
|
1979
|
+
if (!rules && !isRooted) {
|
|
1980
|
+
parserInput.restore();
|
|
1981
|
+
var e = [];
|
|
1982
|
+
value = this.entity();
|
|
1983
|
+
while (parserInput.$char(',')) {
|
|
1984
|
+
e.push(value);
|
|
1985
|
+
value = this.entity();
|
|
1986
|
+
}
|
|
1987
|
+
if (value && e.length > 0) {
|
|
1988
|
+
e.push(value);
|
|
1989
|
+
value = e;
|
|
1990
|
+
isKeywordList = true;
|
|
1991
|
+
}
|
|
1992
|
+
else {
|
|
1993
|
+
rules = this.blockRuleset();
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
else {
|
|
1997
|
+
parserInput.forget();
|
|
1998
|
+
}
|
|
1916
1999
|
}
|
|
1917
|
-
if (rules || (!hasBlock && value && parserInput.$char(';'))) {
|
|
2000
|
+
if (rules || isKeywordList || (!hasBlock && value && parserInput.$char(';'))) {
|
|
1918
2001
|
parserInput.forget();
|
|
1919
2002
|
return new (tree_1.default.AtRule)(name, value, rules, index + currentIndex, fileInfo, context.dumpLineNumbers ? getDebugInfo(index) : null, isRooted);
|
|
1920
2003
|
}
|
|
@@ -1967,6 +2050,15 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1967
2050
|
}
|
|
1968
2051
|
parserInput.restore();
|
|
1969
2052
|
},
|
|
2053
|
+
colorOperand: function () {
|
|
2054
|
+
parserInput.save();
|
|
2055
|
+
// hsl or rgb or lch operand
|
|
2056
|
+
var match = parserInput.$re(/^[lchrgbs]\s+/);
|
|
2057
|
+
if (match) {
|
|
2058
|
+
return new tree_1.default.Keyword(match[0]);
|
|
2059
|
+
}
|
|
2060
|
+
parserInput.restore();
|
|
2061
|
+
},
|
|
1970
2062
|
multiplication: function () {
|
|
1971
2063
|
var m;
|
|
1972
2064
|
var a;
|
|
@@ -1981,7 +2073,14 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1981
2073
|
break;
|
|
1982
2074
|
}
|
|
1983
2075
|
parserInput.save();
|
|
1984
|
-
op = parserInput.$char('/') || parserInput.$char('*')
|
|
2076
|
+
op = parserInput.$char('/') || parserInput.$char('*');
|
|
2077
|
+
if (!op) {
|
|
2078
|
+
var index = parserInput.i;
|
|
2079
|
+
op = parserInput.$str('./');
|
|
2080
|
+
if (op) {
|
|
2081
|
+
warn('./ operator is deprecated', index, 'DEPRECATED');
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
1985
2084
|
if (!op) {
|
|
1986
2085
|
parserInput.forget();
|
|
1987
2086
|
break;
|
|
@@ -2221,7 +2320,7 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
2221
2320
|
entities.color() || entities.variable() ||
|
|
2222
2321
|
entities.property() || entities.call() ||
|
|
2223
2322
|
entities.quoted(true) || entities.colorKeyword() ||
|
|
2224
|
-
entities.mixinLookup();
|
|
2323
|
+
this.colorOperand() || entities.mixinLookup();
|
|
2225
2324
|
if (negate) {
|
|
2226
2325
|
o.parensInOp = true;
|
|
2227
2326
|
o = new (tree_1.default.Negative)(o);
|