less 4.2.1 → 4.3.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 +731 -495
- package/dist/less.min.js +3 -3
- 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 +112 -22
- package/lib/less/parser/parser.js.map +1 -1
- package/lib/less/tree/atrule.js +121 -33
- package/lib/less/tree/atrule.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/nested-at-rule.js +4 -0
- package/lib/less/tree/nested-at-rule.js.map +1 -1
- package/lib/less/tree/query-in-parens.js +32 -1
- package/lib/less/tree/query-in-parens.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/browser/generator/generate.js +2 -2
- package/test/less-test.js +3 -1
- package/test/mocha-playwright/runner.js +210 -0
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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AO,OAAO,CAAC;AACnB,CAAC,CAAC;AAEF,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,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,IAA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E,EAAE,OAAO,CAAC,OAAI,CAAC;KAC1D;IAED,OAAO,IAAI,OAAO,CAAC,UAAG,IAAI,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,CAA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AI,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 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,9 @@ 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"));
|
|
12
|
+
var selector_1 = tslib_1.__importDefault(require("../tree/selector"));
|
|
13
|
+
var anonymous_1 = tslib_1.__importDefault(require("../tree/anonymous"));
|
|
11
14
|
//
|
|
12
15
|
// less.js - parser
|
|
13
16
|
//
|
|
@@ -52,6 +55,22 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
52
55
|
message: msg
|
|
53
56
|
}, imports);
|
|
54
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
|
+
}
|
|
55
74
|
function expect(arg, msg) {
|
|
56
75
|
// some older browsers return typeof 'function' for RegExp
|
|
57
76
|
var result = (arg instanceof Function) ? arg.call(parsers) : parserInput.$re(arg);
|
|
@@ -759,11 +778,20 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
759
778
|
do {
|
|
760
779
|
option = null;
|
|
761
780
|
elements = null;
|
|
762
|
-
|
|
781
|
+
var first = true;
|
|
782
|
+
while (!(option = parserInput.$re(/^(!?all)(?=\s*(\)|,))/))) {
|
|
763
783
|
e = this.element();
|
|
764
784
|
if (!e) {
|
|
765
785
|
break;
|
|
766
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;
|
|
767
795
|
if (elements) {
|
|
768
796
|
elements.push(e);
|
|
769
797
|
}
|
|
@@ -823,16 +851,23 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
823
851
|
var elements;
|
|
824
852
|
var args;
|
|
825
853
|
var hasParens;
|
|
854
|
+
var parensIndex;
|
|
855
|
+
var parensWS = false;
|
|
826
856
|
if (s !== '.' && s !== '#') {
|
|
827
857
|
return;
|
|
828
858
|
}
|
|
829
859
|
parserInput.save(); // stop us absorbing part of an invalid selector
|
|
830
860
|
elements = this.elements();
|
|
831
861
|
if (elements) {
|
|
862
|
+
parensIndex = parserInput.i;
|
|
832
863
|
if (parserInput.$char('(')) {
|
|
864
|
+
parensWS = parserInput.isWhitespace(-2);
|
|
833
865
|
args = this.args(true).args;
|
|
834
866
|
expectChar(')');
|
|
835
867
|
hasParens = true;
|
|
868
|
+
if (parensWS) {
|
|
869
|
+
warn('Whitespace between a mixin name and parentheses for a mixin call is deprecated', parensIndex, 'DEPRECATED');
|
|
870
|
+
}
|
|
836
871
|
}
|
|
837
872
|
if (getLookup !== false) {
|
|
838
873
|
lookups = this.ruleLookups();
|
|
@@ -856,6 +891,9 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
856
891
|
return new tree_1.default.NamespaceValue(mixin, lookups);
|
|
857
892
|
}
|
|
858
893
|
else {
|
|
894
|
+
if (!hasParens) {
|
|
895
|
+
warn('Calling a mixin without parentheses is deprecated', parensIndex, 'DEPRECATED');
|
|
896
|
+
}
|
|
859
897
|
return mixin;
|
|
860
898
|
}
|
|
861
899
|
}
|
|
@@ -1145,24 +1183,25 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1145
1183
|
expectChar(')');
|
|
1146
1184
|
return new tree_1.default.Quoted('', "alpha(opacity=".concat(value, ")"));
|
|
1147
1185
|
},
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
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
|
+
*/
|
|
1160
1198
|
element: function () {
|
|
1161
1199
|
var e;
|
|
1162
1200
|
var c;
|
|
1163
1201
|
var v;
|
|
1164
1202
|
var index = parserInput.i;
|
|
1165
1203
|
c = this.combinator();
|
|
1204
|
+
/** This selector parser is quite simplistic and will pass a number of invalid selectors. */
|
|
1166
1205
|
e = parserInput.$re(/^(?:\d+\.\d+|\d+)%/) ||
|
|
1167
1206
|
// eslint-disable-next-line no-control-regex
|
|
1168
1207
|
parserInput.$re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) ||
|
|
@@ -1172,9 +1211,26 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1172
1211
|
if (!e) {
|
|
1173
1212
|
parserInput.save();
|
|
1174
1213
|
if (parserInput.$char('(')) {
|
|
1175
|
-
if ((v = this.selector(false))
|
|
1176
|
-
|
|
1177
|
-
parserInput
|
|
1214
|
+
if ((v = this.selector(false))) {
|
|
1215
|
+
var selectors = [];
|
|
1216
|
+
while (parserInput.$char(',')) {
|
|
1217
|
+
selectors.push(v);
|
|
1218
|
+
selectors.push(new anonymous_1.default(','));
|
|
1219
|
+
v = this.selector(false);
|
|
1220
|
+
}
|
|
1221
|
+
selectors.push(v);
|
|
1222
|
+
if (parserInput.$char(')')) {
|
|
1223
|
+
if (selectors.length > 1) {
|
|
1224
|
+
e = new (tree_1.default.Paren)(new selector_1.default(selectors));
|
|
1225
|
+
}
|
|
1226
|
+
else {
|
|
1227
|
+
e = new (tree_1.default.Paren)(v);
|
|
1228
|
+
}
|
|
1229
|
+
parserInput.forget();
|
|
1230
|
+
}
|
|
1231
|
+
else {
|
|
1232
|
+
parserInput.restore('Missing closing \')\'');
|
|
1233
|
+
}
|
|
1178
1234
|
}
|
|
1179
1235
|
else {
|
|
1180
1236
|
parserInput.restore('Missing closing \')\'');
|
|
@@ -1265,6 +1321,9 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1265
1321
|
error('Extend can only be used at the end of selector');
|
|
1266
1322
|
}
|
|
1267
1323
|
c = parserInput.currentChar();
|
|
1324
|
+
if (Array.isArray(e)) {
|
|
1325
|
+
e.forEach(function (ele) { return elements.push(ele); });
|
|
1326
|
+
}
|
|
1268
1327
|
if (elements) {
|
|
1269
1328
|
elements.push(e);
|
|
1270
1329
|
}
|
|
@@ -1439,7 +1498,12 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1439
1498
|
merge = !isVariable && name.length > 1 && name.pop().value;
|
|
1440
1499
|
// Custom property values get permissive parsing
|
|
1441
1500
|
if (name[0].value && name[0].value.slice(0, 2) === '--') {
|
|
1442
|
-
|
|
1501
|
+
if (parserInput.$char(';')) {
|
|
1502
|
+
value = new anonymous_1.default('');
|
|
1503
|
+
}
|
|
1504
|
+
else {
|
|
1505
|
+
value = this.permissiveValue(/[;}]/, true);
|
|
1506
|
+
}
|
|
1443
1507
|
}
|
|
1444
1508
|
// Try to store values as anonymous
|
|
1445
1509
|
// If we need the value later we'll re-parse it in ruleset.parseValue
|
|
@@ -1458,7 +1522,12 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1458
1522
|
important = this.important();
|
|
1459
1523
|
}
|
|
1460
1524
|
else if (isVariable) {
|
|
1461
|
-
|
|
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
|
+
*/
|
|
1462
1531
|
value = this.permissiveValue();
|
|
1463
1532
|
}
|
|
1464
1533
|
}
|
|
@@ -1489,6 +1558,8 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1489
1558
|
* First, it will try to parse comments and entities to reach
|
|
1490
1559
|
* the end. This is mostly like the Expression parser except no
|
|
1491
1560
|
* math is allowed.
|
|
1561
|
+
*
|
|
1562
|
+
* @param {RexExp} untilTokens - Characters to stop parsing at
|
|
1492
1563
|
*/
|
|
1493
1564
|
permissiveValue: function (untilTokens) {
|
|
1494
1565
|
var i;
|
|
@@ -1550,6 +1621,7 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1550
1621
|
parserInput.forget();
|
|
1551
1622
|
return new tree_1.default.Anonymous('', index);
|
|
1552
1623
|
}
|
|
1624
|
+
/** @type {string} */
|
|
1553
1625
|
var item = void 0;
|
|
1554
1626
|
for (i = 0; i < value.length; i++) {
|
|
1555
1627
|
item = value[i];
|
|
@@ -1563,8 +1635,16 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1563
1635
|
}
|
|
1564
1636
|
// Treat like quoted values, but replace vars like unquoted expressions
|
|
1565
1637
|
var quote = new tree_1.default.Quoted('\'', item, true, index, fileInfo);
|
|
1566
|
-
|
|
1567
|
-
|
|
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');
|
|
1645
|
+
}
|
|
1646
|
+
quote.variableRegex = /@([\w-]+)|@{([\w-]+)}/g;
|
|
1647
|
+
quote.propRegex = /\$([\w-]+)|\${([\w-]+)}/g;
|
|
1568
1648
|
result.push(quote);
|
|
1569
1649
|
}
|
|
1570
1650
|
}
|
|
@@ -1853,6 +1933,9 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1853
1933
|
hasUnknown = true;
|
|
1854
1934
|
isRooted = false;
|
|
1855
1935
|
break;
|
|
1936
|
+
case '@starting-style':
|
|
1937
|
+
isRooted = false;
|
|
1938
|
+
break;
|
|
1856
1939
|
default:
|
|
1857
1940
|
hasUnknown = true;
|
|
1858
1941
|
break;
|
|
@@ -1952,7 +2035,14 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
1952
2035
|
break;
|
|
1953
2036
|
}
|
|
1954
2037
|
parserInput.save();
|
|
1955
|
-
op = parserInput.$char('/') || parserInput.$char('*')
|
|
2038
|
+
op = parserInput.$char('/') || parserInput.$char('*');
|
|
2039
|
+
if (!op) {
|
|
2040
|
+
var index = parserInput.i;
|
|
2041
|
+
op = parserInput.$str('./');
|
|
2042
|
+
if (op) {
|
|
2043
|
+
warn('./ operator is deprecated', index, 'DEPRECATED');
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
1956
2046
|
if (!op) {
|
|
1957
2047
|
parserInput.forget();
|
|
1958
2048
|
break;
|
|
@@ -2213,7 +2303,7 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
|
|
2213
2303
|
var index = parserInput.i;
|
|
2214
2304
|
do {
|
|
2215
2305
|
e = this.comment();
|
|
2216
|
-
if (e) {
|
|
2306
|
+
if (e && !e.isLineComment) {
|
|
2217
2307
|
entities.push(e);
|
|
2218
2308
|
continue;
|
|
2219
2309
|
}
|