| /** | ||
| * Deprecation registry for Less.js | ||
| * | ||
| * Each deprecation has a unique ID and description. | ||
| * Repetition limiting caps warnings at 5 per deprecation type per parse. | ||
| * Use --quiet-deprecations to suppress all deprecation warnings. | ||
| */ | ||
| const deprecations = { | ||
| 'mixin-call-no-parens': { | ||
| description: 'Calling a mixin without parentheses is deprecated.' | ||
| }, | ||
| 'mixin-call-whitespace': { | ||
| description: 'Whitespace between a mixin name and parentheses for a mixin call is deprecated.' | ||
| }, | ||
| 'dot-slash-operator': { | ||
| description: 'The ./ operator is deprecated.' | ||
| }, | ||
| 'variable-in-unknown-value': { | ||
| description: '@[ident] in custom property values is treated as literal text.' | ||
| }, | ||
| 'property-in-unknown-value': { | ||
| description: '$[ident] in custom property values is treated as literal text.' | ||
| }, | ||
| 'js-eval': { | ||
| description: 'Inline JavaScript evaluation (backtick expressions) is deprecated and will be removed in Less 5.x.' | ||
| }, | ||
| 'at-plugin': { | ||
| description: 'The @plugin directive is deprecated and will be replaced in Less 5.x.' | ||
| }, | ||
| 'dump-line-numbers': { | ||
| description: 'The dumpLineNumbers option is deprecated and will be removed in Less 5.x.' | ||
| }, | ||
| 'math-always': { | ||
| description: '--math=always is deprecated and will be removed in Less 5.x.' | ||
| } | ||
| }; | ||
| const MAX_REPETITIONS = 5; | ||
| class DeprecationHandler { | ||
| constructor() { | ||
| /** @type {Record<string, number>} */ | ||
| this._counts = {}; | ||
| } | ||
| /** @param {string} deprecationId */ | ||
| shouldWarn(deprecationId) { | ||
| if (!deprecationId) { return true; } | ||
| const count = (this._counts[deprecationId] || 0) + 1; | ||
| this._counts[deprecationId] = count; | ||
| return count <= MAX_REPETITIONS; | ||
| } | ||
| /** @param {{ warn: (msg: string) => void }} logger */ | ||
| summarize(logger) { | ||
| for (const id of Object.keys(this._counts)) { | ||
| const omitted = this._counts[id] - MAX_REPETITIONS; | ||
| if (omitted > 0) { | ||
| logger.warn(`${omitted} repetitive "${id}" deprecation warning(s) omitted.`); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| export { deprecations, DeprecationHandler, MAX_REPETITIONS }; | ||
| export default { deprecations, DeprecationHandler }; |
| export interface Environment { | ||
| /** | ||
| * Converts a string to a base 64 string | ||
| */ | ||
| encodeBase64(str: string): string | ||
| /** | ||
| * Lookup the mime-type of a filename | ||
| */ | ||
| mimeLookup(filename: string): string | ||
| /** | ||
| * Look up the charset of a mime type | ||
| * @param mime | ||
| */ | ||
| charsetLookup(mime: string): string | ||
| /** | ||
| * Gets a source map generator | ||
| * | ||
| * @todo - Figure out precise type | ||
| */ | ||
| getSourceMapGenerator(): any | ||
| } |
| import type { Environment } from './environment-api' | ||
| export interface FileManager { | ||
| /** | ||
| * Given the full path to a file, return the path component | ||
| * Provided by AbstractFileManager | ||
| */ | ||
| getPath(filename: string): string | ||
| /** | ||
| * Append a .less extension if appropriate. Only called if less thinks one could be added. | ||
| * Provided by AbstractFileManager | ||
| */ | ||
| tryAppendLessExtension(filename: string): string | ||
| /** | ||
| * Whether the rootpath should be converted to be absolute. | ||
| * The browser ovverides this to return true because urls must be absolute. | ||
| * Provided by AbstractFileManager (returns false) | ||
| */ | ||
| alwaysMakePathsAbsolute(): boolean | ||
| /** | ||
| * Returns whether a path is absolute | ||
| * Provided by AbstractFileManager | ||
| */ | ||
| isPathAbsolute(path: string): boolean | ||
| /** | ||
| * joins together 2 paths | ||
| * Provided by AbstractFileManager | ||
| */ | ||
| join(basePath: string, laterPath: string): string | ||
| /** | ||
| * Returns the difference between 2 paths | ||
| * E.g. url = a/ baseUrl = a/b/ returns ../ | ||
| * url = a/b/ baseUrl = a/ returns b/ | ||
| * Provided by AbstractFileManager | ||
| */ | ||
| pathDiff(url: string, baseUrl: string): string | ||
| /** | ||
| * Returns whether this file manager supports this file for syncronous file retrieval | ||
| * If true is returned, loadFileSync will then be called with the file. | ||
| * Provided by AbstractFileManager (returns false) | ||
| * | ||
| * @todo - Narrow Options type | ||
| */ | ||
| supportsSync( | ||
| filename: string, | ||
| currentDirectory: string, | ||
| options: Record<string, any>, | ||
| environment: Environment | ||
| ): boolean | ||
| /** | ||
| * If file manager supports async file retrieval for this file type | ||
| */ | ||
| supports( | ||
| filename: string, | ||
| currentDirectory: string, | ||
| options: Record<string, any>, | ||
| environment: Environment | ||
| ): boolean | ||
| /** | ||
| * Loads a file asynchronously. | ||
| */ | ||
| loadFile( | ||
| filename: string, | ||
| currentDirectory: string, | ||
| options: Record<string, any>, | ||
| environment: Environment | ||
| ): Promise<{ filename: string, contents: string }> | ||
| /** | ||
| * Loads a file synchronously. Expects an immediate return with an object | ||
| */ | ||
| loadFileSync( | ||
| filename: string, | ||
| currentDirectory: string, | ||
| options: Record<string, any>, | ||
| environment: Environment | ||
| ): { error?: unknown, filename: string, contents: string } | ||
| } |
| // @ts-check | ||
| import Expression from './expression.js'; | ||
| import Value from './value.js'; | ||
| import Node from './node.js'; | ||
| /** | ||
| * Merges declarations with merge flags (+ or ,) into combined values. | ||
| * Used by both the ToCSSVisitor and AtRule eval. | ||
| * @param {Node[]} rules | ||
| */ | ||
| export default function mergeRules(rules) { | ||
| if (!rules) { | ||
| return; | ||
| } | ||
| /** @type {Record<string, Array<Node & { merge: string, name: string, value: Node, important: string }>>} */ | ||
| const groups = {}; | ||
| /** @type {Array<Array<Node & { merge: string, name: string, value: Node, important: string }>>} */ | ||
| const groupsArr = []; | ||
| for (let i = 0; i < rules.length; i++) { | ||
| const rule = /** @type {Node & { merge: string, name: string }} */ (rules[i]); | ||
| if (rule.merge) { | ||
| const key = rule.name; | ||
| groups[key] ? rules.splice(i--, 1) : | ||
| groupsArr.push(groups[key] = []); | ||
| groups[key].push(/** @type {Node & { merge: string, name: string, value: Node, important: string }} */ (rule)); | ||
| } | ||
| } | ||
| groupsArr.forEach(group => { | ||
| if (group.length > 0) { | ||
| const result = group[0]; | ||
| /** @type {Node[]} */ | ||
| let space = []; | ||
| const comma = [new Expression(space)]; | ||
| group.forEach(rule => { | ||
| if ((rule.merge === '+') && (space.length > 0)) { | ||
| comma.push(new Expression(space = [])); | ||
| } | ||
| space.push(rule.value); | ||
| result.important = result.important || rule.important; | ||
| }); | ||
| result.value = new Value(comma); | ||
| } | ||
| }); | ||
| } |
@@ -1,12 +0,17 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var utils_1 = require("./utils"); | ||
| var browser_1 = tslib_1.__importDefault(require("./browser")); | ||
| exports.default = (function (window, options) { | ||
| import {addDataAttr} from './utils.js'; | ||
| import browser from './browser.js'; | ||
| /** | ||
| * @param {Window} window | ||
| * @param {Record<string, *>} options | ||
| */ | ||
| export default (window, options) => { | ||
| // use options from the current script tag data attribues | ||
| (0, utils_1.addDataAttr)(options, browser_1.default.currentScript(window)); | ||
| addDataAttr(options, browser.currentScript(window)); | ||
| if (options.isFileProtocol === undefined) { | ||
| options.isFileProtocol = /^(file|(chrome|safari)(-extension)?|resource|qrc|app):/.test(window.location.protocol); | ||
| } | ||
| // Load styles asynchronously (default: false) | ||
@@ -20,25 +25,30 @@ // | ||
| options.fileAsync = options.fileAsync || false; | ||
| // Interval between watch polls | ||
| options.poll = options.poll || (options.isFileProtocol ? 1000 : 1500); | ||
| options.env = options.env || (window.location.hostname == '127.0.0.1' || | ||
| window.location.hostname == '0.0.0.0' || | ||
| window.location.hostname == '0.0.0.0' || | ||
| window.location.hostname == 'localhost' || | ||
| (window.location.port && | ||
| window.location.port.length > 0) || | ||
| options.isFileProtocol ? 'development' | ||
| window.location.port.length > 0) || | ||
| options.isFileProtocol ? 'development' | ||
| : 'production'); | ||
| var dumpLineNumbers = /!dumpLineNumbers:(comments|mediaquery|all)/.exec(window.location.hash); | ||
| const dumpLineNumbers = /!dumpLineNumbers:(comments|mediaquery|all)/.exec(window.location.hash); | ||
| if (dumpLineNumbers) { | ||
| options.dumpLineNumbers = dumpLineNumbers[1]; | ||
| } | ||
| if (options.useFileCache === undefined) { | ||
| options.useFileCache = true; | ||
| } | ||
| if (options.onReady === undefined) { | ||
| options.onReady = true; | ||
| } | ||
| if (options.relativeUrls) { | ||
| options.rewriteUrls = 'all'; | ||
| } | ||
| }); | ||
| //# sourceMappingURL=add-default-options.js.map | ||
| }; |
@@ -1,4 +0,1 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| /** | ||
@@ -9,8 +6,10 @@ * Kicks off less and compiles any stylesheets | ||
| */ | ||
| var default_options_1 = tslib_1.__importDefault(require("../less/default-options")); | ||
| var add_default_options_1 = tslib_1.__importDefault(require("./add-default-options")); | ||
| var index_1 = tslib_1.__importDefault(require("./index")); | ||
| var options = (0, default_options_1.default)(); | ||
| import defaultOptions from '../less/default-options.js'; | ||
| import addDefaultOptions from './add-default-options.js'; | ||
| import root from './index.js'; | ||
| const options = defaultOptions(); | ||
| if (window.less) { | ||
| for (var key in window.less) { | ||
| for (const key in window.less) { | ||
| if (Object.prototype.hasOwnProperty.call(window.less, key)) { | ||
@@ -21,13 +20,19 @@ options[key] = window.less[key]; | ||
| } | ||
| (0, add_default_options_1.default)(window, options); | ||
| addDefaultOptions(window, options); | ||
| options.plugins = options.plugins || []; | ||
| if (window.LESS_PLUGINS) { | ||
| options.plugins = options.plugins.concat(window.LESS_PLUGINS); | ||
| } | ||
| var less = (0, index_1.default)(window, options); | ||
| exports.default = less; | ||
| const less = root(window, options); | ||
| export default less; | ||
| window.less = less; | ||
| var css; | ||
| var head; | ||
| var style; | ||
| let css; | ||
| let head; | ||
| let style; | ||
| // Always restore page visibility | ||
@@ -42,2 +47,3 @@ function resolveOrReject(data) { | ||
| } | ||
| if (options.onReady) { | ||
@@ -52,9 +58,10 @@ if (/!watch/.test(window.location.hash)) { | ||
| style = document.createElement('style'); | ||
| style.type = 'text/css'; | ||
| if (style.styleSheet) { | ||
| style.styleSheet.cssText = css; | ||
| } | ||
| else { | ||
| } else { | ||
| style.appendChild(document.createTextNode(css)); | ||
| } | ||
| head.appendChild(style); | ||
@@ -65,2 +72,1 @@ } | ||
| } | ||
| //# sourceMappingURL=bootstrap.js.map |
@@ -1,16 +0,17 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var utils = tslib_1.__importStar(require("./utils")); | ||
| exports.default = { | ||
| import * as utils from './utils.js'; | ||
| export default { | ||
| createCSS: function (document, styles, sheet) { | ||
| // Strip the query-string | ||
| var href = sheet.href || ''; | ||
| const href = sheet.href || ''; | ||
| // If there is no title set, use the filename, minus the extension | ||
| var id = "less:".concat(sheet.title || utils.extractId(href)); | ||
| const id = `less:${sheet.title || utils.extractId(href)}`; | ||
| // If this has already been inserted into the DOM, we may need to replace it | ||
| var oldStyleNode = document.getElementById(id); | ||
| var keepOldStyleNode = false; | ||
| const oldStyleNode = document.getElementById(id); | ||
| let keepOldStyleNode = false; | ||
| // Create a new stylesheet node for insertion or (if necessary) replacement | ||
| var styleNode = document.createElement('style'); | ||
| const styleNode = document.createElement('style'); | ||
| styleNode.setAttribute('type', 'text/css'); | ||
@@ -21,4 +22,6 @@ if (sheet.media) { | ||
| styleNode.id = id; | ||
| if (!styleNode.styleSheet) { | ||
| styleNode.appendChild(document.createTextNode(styles)); | ||
| // If new contents match contents of oldStyleNode, don't replace oldStyleNode | ||
@@ -28,11 +31,12 @@ keepOldStyleNode = (oldStyleNode !== null && oldStyleNode.childNodes.length > 0 && styleNode.childNodes.length > 0 && | ||
| } | ||
| var head = document.getElementsByTagName('head')[0]; | ||
| const head = document.getElementsByTagName('head')[0]; | ||
| // If there is no oldStyleNode, just append; otherwise, only append if we need | ||
| // to replace oldStyleNode with an updated stylesheet | ||
| if (oldStyleNode === null || keepOldStyleNode === false) { | ||
| var nextEl = sheet && sheet.nextSibling || null; | ||
| const nextEl = sheet && sheet.nextSibling || null; | ||
| if (nextEl) { | ||
| nextEl.parentNode.insertBefore(styleNode, nextEl); | ||
| } | ||
| else { | ||
| } else { | ||
| head.appendChild(styleNode); | ||
@@ -44,2 +48,3 @@ } | ||
| } | ||
| // For IE. | ||
@@ -51,4 +56,3 @@ // This needs to happen *after* the style element is added to the DOM, otherwise IE 7 and 8 may crash. | ||
| styleNode.styleSheet.cssText = styles; | ||
| } | ||
| catch (e) { | ||
| } catch (e) { | ||
| throw new Error('Couldn\'t reassign styleSheet.cssText.'); | ||
@@ -58,6 +62,6 @@ } | ||
| }, | ||
| currentScript: function (window) { | ||
| var document = window.document; | ||
| return document.currentScript || (function () { | ||
| var scripts = document.getElementsByTagName('script'); | ||
| currentScript: function(window) { | ||
| const document = window.document; | ||
| return document.currentScript || (() => { | ||
| const scripts = document.getElementsByTagName('script'); | ||
| return scripts[scripts.length - 1]; | ||
@@ -67,2 +71,1 @@ })(); | ||
| }; | ||
| //# sourceMappingURL=browser.js.map |
@@ -1,35 +0,34 @@ | ||
| "use strict"; | ||
| // Cache system is a bit outdated and could do with work | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.default = (function (window, options, logger) { | ||
| var cache = null; | ||
| export default (window, options, logger) => { | ||
| let cache = null; | ||
| if (options.env !== 'development') { | ||
| try { | ||
| cache = (typeof window.localStorage === 'undefined') ? null : window.localStorage; | ||
| } | ||
| catch (_) { } | ||
| } catch (_) {} | ||
| } | ||
| return { | ||
| setCSS: function (path, lastModified, modifyVars, styles) { | ||
| setCSS: function(path, lastModified, modifyVars, styles) { | ||
| if (cache) { | ||
| logger.info("saving ".concat(path, " to cache.")); | ||
| logger.info(`saving ${path} to cache.`); | ||
| try { | ||
| cache.setItem(path, styles); | ||
| cache.setItem("".concat(path, ":timestamp"), lastModified); | ||
| cache.setItem(`${path}:timestamp`, lastModified); | ||
| if (modifyVars) { | ||
| cache.setItem("".concat(path, ":vars"), JSON.stringify(modifyVars)); | ||
| cache.setItem(`${path}:vars`, JSON.stringify(modifyVars)); | ||
| } | ||
| } | ||
| catch (e) { | ||
| } catch (e) { | ||
| // TODO - could do with adding more robust error handling | ||
| logger.error("failed to save \"".concat(path, "\" to local storage for caching.")); | ||
| logger.error(`failed to save "${path}" to local storage for caching.`); | ||
| } | ||
| } | ||
| }, | ||
| getCSS: function (path, webInfo, modifyVars) { | ||
| var css = cache && cache.getItem(path); | ||
| var timestamp = cache && cache.getItem("".concat(path, ":timestamp")); | ||
| var vars = cache && cache.getItem("".concat(path, ":vars")); | ||
| getCSS: function(path, webInfo, modifyVars) { | ||
| const css = cache && cache.getItem(path); | ||
| const timestamp = cache && cache.getItem(`${path}:timestamp`); | ||
| let vars = cache && cache.getItem(`${path}:vars`); | ||
| modifyVars = modifyVars || {}; | ||
| vars = vars || '{}'; // if not set, treat as the JSON representation of an empty object | ||
| if (timestamp && webInfo.lastModified && | ||
@@ -44,3 +43,2 @@ (new Date(webInfo.lastModified).valueOf() === | ||
| }; | ||
| }); | ||
| //# sourceMappingURL=cache.js.map | ||
| }; |
@@ -1,21 +0,23 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var utils = tslib_1.__importStar(require("./utils")); | ||
| var browser_1 = tslib_1.__importDefault(require("./browser")); | ||
| exports.default = (function (window, less, options) { | ||
| import * as utils from './utils.js'; | ||
| import browser from './browser.js'; | ||
| export default (window, less, options) => { | ||
| function errorHTML(e, rootHref) { | ||
| var id = "less-error-message:".concat(utils.extractId(rootHref || '')); | ||
| var template = '<li><label>{line}</label><pre class="{class}">{content}</pre></li>'; | ||
| var elem = window.document.createElement('div'); | ||
| var timer; | ||
| var content; | ||
| var errors = []; | ||
| var filename = e.filename || rootHref; | ||
| var filenameNoPath = filename.match(/([^/]+(\?.*)?)$/)[1]; | ||
| elem.id = id; | ||
| const id = `less-error-message:${utils.extractId(rootHref || '')}`; | ||
| const template = '<li><label>{line}</label><pre class="{class}">{content}</pre></li>'; | ||
| const elem = window.document.createElement('div'); | ||
| let timer; | ||
| let content; | ||
| const errors = []; | ||
| const filename = e.filename || rootHref; | ||
| const filenameNoPath = filename.match(/([^/]+(\?.*)?)$/)[1]; | ||
| elem.id = id; | ||
| elem.className = 'less-error-message'; | ||
| content = "<h3>".concat(e.type || 'Syntax', "Error: ").concat(e.message || 'There is an error in your .less file') + | ||
| "</h3><p>in <a href=\"".concat(filename, "\">").concat(filenameNoPath, "</a> "); | ||
| var errorline = function (e, i, classname) { | ||
| content = `<h3>${e.type || 'Syntax'}Error: ${e.message || 'There is an error in your .less file'}` + | ||
| `</h3><p>in <a href="${filename}">${filenameNoPath}</a> `; | ||
| const errorline = (e, i, classname) => { | ||
| if (e.extract[i] !== undefined) { | ||
@@ -27,2 +29,3 @@ errors.push(template.replace(/\{line\}/, (parseInt(e.line, 10) || 0) + (i - 1)) | ||
| }; | ||
| if (e.line) { | ||
@@ -32,10 +35,11 @@ errorline(e, 0, ''); | ||
| errorline(e, 2, ''); | ||
| content += "on line ".concat(e.line, ", column ").concat(e.column + 1, ":</p><ul>").concat(errors.join(''), "</ul>"); | ||
| content += `on line ${e.line}, column ${e.column + 1}:</p><ul>${errors.join('')}</ul>`; | ||
| } | ||
| if (e.stack && (e.extract || options.logLevel >= 4)) { | ||
| content += "<br/>Stack Trace</br />".concat(e.stack.split('\n').slice(1).join('<br/>')); | ||
| content += `<br/>Stack Trace</br />${e.stack.split('\n').slice(1).join('<br/>')}`; | ||
| } | ||
| elem.innerHTML = content; | ||
| // CSS for error messages | ||
| browser_1.default.createCSS(window.document, [ | ||
| browser.createCSS(window.document, [ | ||
| '.less-error-message ul, .less-error-message li {', | ||
@@ -78,2 +82,3 @@ 'list-style-type: none;', | ||
| ].join('\n'), { title: 'error-message' }); | ||
| elem.style.cssText = [ | ||
@@ -90,11 +95,11 @@ 'font-family: Arial, sans-serif', | ||
| ].join(';'); | ||
| if (options.env === 'development') { | ||
| timer = setInterval(function () { | ||
| var document = window.document; | ||
| var body = document.body; | ||
| timer = setInterval(() => { | ||
| const document = window.document; | ||
| const body = document.body; | ||
| if (body) { | ||
| if (document.getElementById(id)) { | ||
| body.replaceChild(elem, document.getElementById(id)); | ||
| } | ||
| else { | ||
| } else { | ||
| body.insertBefore(elem, body.firstChild); | ||
@@ -107,4 +112,5 @@ } | ||
| } | ||
| function removeErrorHTML(path) { | ||
| var node = window.document.getElementById("less-error-message:".concat(utils.extractId(path))); | ||
| const node = window.document.getElementById(`less-error-message:${utils.extractId(path)}`); | ||
| if (node) { | ||
@@ -114,22 +120,24 @@ node.parentNode.removeChild(node); | ||
| } | ||
| function removeErrorConsole() { | ||
| // no action | ||
| } | ||
| function removeError(path) { | ||
| if (!options.errorReporting || options.errorReporting === 'html') { | ||
| removeErrorHTML(path); | ||
| } | ||
| else if (options.errorReporting === 'console') { | ||
| } else if (options.errorReporting === 'console') { | ||
| removeErrorConsole(path); | ||
| } | ||
| else if (typeof options.errorReporting === 'function') { | ||
| } else if (typeof options.errorReporting === 'function') { | ||
| options.errorReporting('remove', path); | ||
| } | ||
| } | ||
| function errorConsole(e, rootHref) { | ||
| var template = '{line} {content}'; | ||
| var filename = e.filename || rootHref; | ||
| var errors = []; | ||
| var content = "".concat(e.type || 'Syntax', "Error: ").concat(e.message || 'There is an error in your .less file', " in ").concat(filename); | ||
| var errorline = function (e, i, classname) { | ||
| const template = '{line} {content}'; | ||
| const filename = e.filename || rootHref; | ||
| const errors = []; | ||
| let content = `${e.type || 'Syntax'}Error: ${e.message || 'There is an error in your .less file'} in ${filename}`; | ||
| const errorline = (e, i, classname) => { | ||
| if (e.extract[i] !== undefined) { | ||
@@ -141,2 +149,3 @@ errors.push(template.replace(/\{line\}/, (parseInt(e.line, 10) || 0) + (i - 1)) | ||
| }; | ||
| if (e.line) { | ||
@@ -146,20 +155,20 @@ errorline(e, 0, ''); | ||
| errorline(e, 2, ''); | ||
| content += " on line ".concat(e.line, ", column ").concat(e.column + 1, ":\n").concat(errors.join('\n')); | ||
| content += ` on line ${e.line}, column ${e.column + 1}:\n${errors.join('\n')}`; | ||
| } | ||
| if (e.stack && (e.extract || options.logLevel >= 4)) { | ||
| content += "\nStack Trace\n".concat(e.stack); | ||
| content += `\nStack Trace\n${e.stack}`; | ||
| } | ||
| less.logger.error(content); | ||
| } | ||
| function error(e, rootHref) { | ||
| if (!options.errorReporting || options.errorReporting === 'html') { | ||
| errorHTML(e, rootHref); | ||
| } | ||
| else if (options.errorReporting === 'console') { | ||
| } else if (options.errorReporting === 'console') { | ||
| errorConsole(e, rootHref); | ||
| } | ||
| else if (typeof options.errorReporting === 'function') { | ||
| } else if (typeof options.errorReporting === 'function') { | ||
| options.errorReporting('add', e, rootHref); | ||
| } | ||
| } | ||
| return { | ||
@@ -169,3 +178,2 @@ add: error, | ||
| }; | ||
| }); | ||
| //# sourceMappingURL=error-reporting.js.map | ||
| }; |
@@ -1,15 +0,15 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var abstract_file_manager_js_1 = tslib_1.__importDefault(require("../less/environment/abstract-file-manager.js")); | ||
| var options; | ||
| var logger; | ||
| var fileCache = {}; | ||
| import AbstractFileManager from '../less/environment/abstract-file-manager.js'; | ||
| let options; | ||
| let logger; | ||
| let fileCache = {}; | ||
| // TODOS - move log somewhere. pathDiff and doing something similar in node. use pathDiff in the other browser file for the initial load | ||
| var FileManager = function () { }; | ||
| FileManager.prototype = Object.assign(new abstract_file_manager_js_1.default(), { | ||
| alwaysMakePathsAbsolute: function () { | ||
| const FileManager = function() {} | ||
| FileManager.prototype = Object.assign(new AbstractFileManager(), { | ||
| alwaysMakePathsAbsolute() { | ||
| return true; | ||
| }, | ||
| join: function (basePath, laterPath) { | ||
| join(basePath, laterPath) { | ||
| if (!basePath) { | ||
@@ -20,30 +20,32 @@ return laterPath; | ||
| }, | ||
| doXHR: function (url, type, callback, errback) { | ||
| var xhr = new XMLHttpRequest(); | ||
| var async = options.isFileProtocol ? options.fileAsync : true; | ||
| doXHR(url, type, callback, errback) { | ||
| const xhr = new XMLHttpRequest(); | ||
| const async = options.isFileProtocol ? options.fileAsync : true; | ||
| if (typeof xhr.overrideMimeType === 'function') { | ||
| xhr.overrideMimeType('text/css'); | ||
| } | ||
| logger.debug("XHR: Getting '".concat(url, "'")); | ||
| logger.debug(`XHR: Getting '${url}'`); | ||
| xhr.open('GET', url, async); | ||
| xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5'); | ||
| xhr.send(null); | ||
| function handleResponse(xhr, callback, errback) { | ||
| if (xhr.status >= 200 && xhr.status < 300) { | ||
| callback(xhr.responseText, xhr.getResponseHeader('Last-Modified')); | ||
| } | ||
| else if (typeof errback === 'function') { | ||
| callback(xhr.responseText, | ||
| xhr.getResponseHeader('Last-Modified')); | ||
| } else if (typeof errback === 'function') { | ||
| errback(xhr.status, url); | ||
| } | ||
| } | ||
| if (options.isFileProtocol && !options.fileAsync) { | ||
| if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 300)) { | ||
| callback(xhr.responseText); | ||
| } | ||
| else { | ||
| } else { | ||
| errback(xhr.status, url); | ||
| } | ||
| } | ||
| else if (async) { | ||
| xhr.onreadystatechange = function () { | ||
| } else if (async) { | ||
| xhr.onreadystatechange = () => { | ||
| if (xhr.readyState == 4) { | ||
@@ -53,43 +55,51 @@ handleResponse(xhr, callback, errback); | ||
| }; | ||
| } | ||
| else { | ||
| } else { | ||
| handleResponse(xhr, callback, errback); | ||
| } | ||
| }, | ||
| supports: function () { | ||
| supports() { | ||
| return true; | ||
| }, | ||
| clearFileCache: function () { | ||
| clearFileCache() { | ||
| fileCache = {}; | ||
| }, | ||
| loadFile: function (filename, currentDirectory, options) { | ||
| loadFile(filename, currentDirectory, options) { | ||
| // TODO: Add prefix support like less-node? | ||
| // What about multiple paths? | ||
| if (currentDirectory && !this.isPathAbsolute(filename)) { | ||
| filename = currentDirectory + filename; | ||
| } | ||
| filename = options.ext ? this.tryAppendExtension(filename, options.ext) : filename; | ||
| options = options || {}; | ||
| // sheet may be set to the stylesheet for the initial load or a collection of properties including | ||
| // some context variables for imports | ||
| var hrefParts = this.extractUrlParts(filename, window.location.href); | ||
| var href = hrefParts.url; | ||
| var self = this; | ||
| return new Promise(function (resolve, reject) { | ||
| const hrefParts = this.extractUrlParts(filename, window.location.href); | ||
| const href = hrefParts.url; | ||
| const self = this; | ||
| return new Promise((resolve, reject) => { | ||
| if (options.useFileCache && fileCache[href]) { | ||
| try { | ||
| var lessText = fileCache[href]; | ||
| return resolve({ contents: lessText, filename: href, webInfo: { lastModified: new Date() } }); | ||
| const lessText = fileCache[href]; | ||
| return resolve({ contents: lessText, filename: href, webInfo: { lastModified: new Date() }}); | ||
| } catch (e) { | ||
| return reject({ filename: href, message: `Error loading file ${href} error was ${e.message}` }); | ||
| } | ||
| catch (e) { | ||
| return reject({ filename: href, message: "Error loading file ".concat(href, " error was ").concat(e.message) }); | ||
| } | ||
| } | ||
| self.doXHR(href, options.mime, function doXHRCallback(data, lastModified) { | ||
| // per file cache | ||
| fileCache[href] = data; | ||
| // Use remote copy (re-parse) | ||
| resolve({ contents: data, filename: href, webInfo: { lastModified: lastModified } }); | ||
| resolve({ contents: data, filename: href, webInfo: { lastModified }}); | ||
| }, function doXHRError(status, url) { | ||
| reject({ type: 'File', message: "'".concat(url, "' wasn't found (").concat(status, ")"), href: href }); | ||
| reject({ type: 'File', message: `'${url}' wasn't found (${status})`, href }); | ||
| }); | ||
@@ -99,7 +109,7 @@ }); | ||
| }); | ||
| exports.default = (function (opts, log) { | ||
| export default (opts, log) => { | ||
| options = opts; | ||
| logger = log; | ||
| return FileManager; | ||
| }); | ||
| //# sourceMappingURL=file-manager.js.map | ||
| } |
@@ -1,6 +0,5 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var function_registry_1 = tslib_1.__importDefault(require("./../less/functions/function-registry")); | ||
| exports.default = (function () { | ||
| import functionRegistry from './../less/functions/function-registry.js'; | ||
| export default () => { | ||
| function imageSize() { | ||
@@ -12,12 +11,13 @@ throw { | ||
| } | ||
| var imageFunctions = { | ||
| 'image-size': function (filePathNode) { | ||
| const imageFunctions = { | ||
| 'image-size': function(filePathNode) { | ||
| imageSize(this, filePathNode); | ||
| return -1; | ||
| }, | ||
| 'image-width': function (filePathNode) { | ||
| 'image-width': function(filePathNode) { | ||
| imageSize(this, filePathNode); | ||
| return -1; | ||
| }, | ||
| 'image-height': function (filePathNode) { | ||
| 'image-height': function(filePathNode) { | ||
| imageSize(this, filePathNode); | ||
@@ -27,4 +27,4 @@ return -1; | ||
| }; | ||
| function_registry_1.default.addMultiple(imageFunctions); | ||
| }); | ||
| //# sourceMappingURL=image-size.js.map | ||
| functionRegistry.addMultiple(imageFunctions); | ||
| }; |
+131
-105
@@ -1,4 +0,1 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| // | ||
@@ -8,25 +5,34 @@ // index.js | ||
| // | ||
| var utils_1 = require("./utils"); | ||
| var less_1 = tslib_1.__importDefault(require("../less")); | ||
| var browser_1 = tslib_1.__importDefault(require("./browser")); | ||
| var file_manager_1 = tslib_1.__importDefault(require("./file-manager")); | ||
| var plugin_loader_1 = tslib_1.__importDefault(require("./plugin-loader")); | ||
| var log_listener_1 = tslib_1.__importDefault(require("./log-listener")); | ||
| var error_reporting_1 = tslib_1.__importDefault(require("./error-reporting")); | ||
| var cache_1 = tslib_1.__importDefault(require("./cache")); | ||
| var image_size_1 = tslib_1.__importDefault(require("./image-size")); | ||
| exports.default = (function (window, options) { | ||
| var document = window.document; | ||
| var less = (0, less_1.default)(); | ||
| import {addDataAttr} from './utils.js'; | ||
| import lessRoot from '../less/index.js'; | ||
| import browser from './browser.js'; | ||
| import FM from './file-manager.js'; | ||
| import PluginLoader from './plugin-loader.js'; | ||
| import LogListener from './log-listener.js'; | ||
| import ErrorReporting from './error-reporting.js'; | ||
| import Cache from './cache.js'; | ||
| import ImageSize from './image-size.js'; | ||
| import pkg from '../../package.json'; | ||
| /** | ||
| * @param {Window} window | ||
| * @param {Object} options | ||
| */ | ||
| export default (window, options) => { | ||
| const document = window.document; | ||
| const less = lessRoot(undefined, undefined, pkg.version); | ||
| less.options = options; | ||
| var environment = less.environment; | ||
| var FileManager = (0, file_manager_1.default)(options, less.logger); | ||
| var fileManager = new FileManager(); | ||
| const environment = less.environment; | ||
| const FileManager = FM(options, less.logger); | ||
| const fileManager = new FileManager(); | ||
| environment.addFileManager(fileManager); | ||
| less.FileManager = FileManager; | ||
| less.PluginLoader = plugin_loader_1.default; | ||
| (0, log_listener_1.default)(less, options); | ||
| var errors = (0, error_reporting_1.default)(window, less, options); | ||
| var cache = less.cache = options.cache || (0, cache_1.default)(window, options, less.logger); | ||
| (0, image_size_1.default)(less.environment); | ||
| less.PluginLoader = PluginLoader; | ||
| LogListener(less, options); | ||
| const errors = ErrorReporting(window, less, options); | ||
| const cache = less.cache = options.cache || Cache(window, options, less.logger); | ||
| ImageSize(less.environment); | ||
| // Setup user functions - Deprecate? | ||
@@ -36,6 +42,8 @@ if (options.functions) { | ||
| } | ||
| var typePattern = /^text\/(x-)?less$/; | ||
| const typePattern = /^text\/(x-)?less$/; | ||
| function clone(obj) { | ||
| var cloned = {}; | ||
| for (var prop in obj) { | ||
| const cloned = {}; | ||
| for (const prop in obj) { | ||
| if (Object.prototype.hasOwnProperty.call(obj, prop)) { | ||
@@ -47,51 +55,49 @@ cloned[prop] = obj[prop]; | ||
| } | ||
| // only really needed for phantom | ||
| function bind(func, thisArg) { | ||
| var curryArgs = Array.prototype.slice.call(arguments, 2); | ||
| return function () { | ||
| var args = curryArgs.concat(Array.prototype.slice.call(arguments, 0)); | ||
| return func.apply(thisArg, args); | ||
| }; | ||
| } | ||
| function loadStyles(modifyVars) { | ||
| var styles = document.getElementsByTagName('style'); | ||
| var style; | ||
| for (var i = 0; i < styles.length; i++) { | ||
| style = styles[i]; | ||
| const styles = document.getElementsByTagName('style'); | ||
| for (let style of styles) { | ||
| if (style.type.match(typePattern)) { | ||
| var instanceOptions = clone(options); | ||
| instanceOptions.modifyVars = modifyVars; | ||
| var lessText = style.innerHTML || ''; | ||
| instanceOptions.filename = document.location.href.replace(/#.*$/, ''); | ||
| const instanceOptions = { | ||
| ...clone(options), | ||
| modifyVars, | ||
| filename: document.location.href.replace(/#.*$/, '') | ||
| } | ||
| const lessText = style.innerHTML || ''; | ||
| /* jshint loopfunc:true */ | ||
| // use closure to store current style | ||
| less.render(lessText, instanceOptions, bind(function (style, e, result) { | ||
| if (e) { | ||
| errors.add(e, 'inline'); | ||
| } | ||
| else { | ||
| less.render(lessText, instanceOptions, (err, result) => { | ||
| if (err) { | ||
| errors.add(err, 'inline'); | ||
| } else { | ||
| style.type = 'text/css'; | ||
| if (style.styleSheet) { | ||
| style.styleSheet.cssText = result.css; | ||
| } | ||
| else { | ||
| } else { | ||
| style.innerHTML = result.css; | ||
| } | ||
| } | ||
| }, null, style)); | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) { | ||
| var instanceOptions = clone(options); | ||
| (0, utils_1.addDataAttr)(instanceOptions, sheet); | ||
| const instanceOptions = clone(options); | ||
| addDataAttr(instanceOptions, sheet); | ||
| instanceOptions.mime = sheet.type; | ||
| if (modifyVars) { | ||
| instanceOptions.modifyVars = modifyVars; | ||
| } | ||
| function loadInitialFileCallback(loadedFile) { | ||
| var data = loadedFile.contents; | ||
| var path = loadedFile.filename; | ||
| var webInfo = loadedFile.webInfo; | ||
| var newFileInfo = { | ||
| const data = loadedFile.contents; | ||
| const path = loadedFile.filename; | ||
| const webInfo = loadedFile.webInfo; | ||
| const newFileInfo = { | ||
| currentDirectory: fileManager.getPath(path), | ||
@@ -102,7 +108,10 @@ filename: path, | ||
| }; | ||
| newFileInfo.entryPath = newFileInfo.currentDirectory; | ||
| newFileInfo.rootpath = instanceOptions.rootpath || newFileInfo.currentDirectory; | ||
| if (webInfo) { | ||
| webInfo.remaining = remaining; | ||
| var css = cache.getCSS(path, webInfo, instanceOptions.modifyVars); | ||
| const css = cache.getCSS(path, webInfo, instanceOptions.modifyVars); | ||
| if (!reload && css) { | ||
@@ -113,12 +122,14 @@ webInfo.local = true; | ||
| } | ||
| } | ||
| // TODO add tests around how this behaves when reloading | ||
| errors.remove(path); | ||
| instanceOptions.rootFileInfo = newFileInfo; | ||
| less.render(data, instanceOptions, function (e, result) { | ||
| less.render(data, instanceOptions, (e, result) => { | ||
| if (e) { | ||
| e.href = path; | ||
| callback(e); | ||
| } | ||
| else { | ||
| } else { | ||
| cache.setCSS(sheet.href, webInfo.lastModified, instanceOptions.modifyVars, result.css); | ||
@@ -129,18 +140,22 @@ callback(null, result.css, data, sheet, webInfo, path); | ||
| } | ||
| fileManager.loadFile(sheet.href, null, instanceOptions, environment) | ||
| .then(function (loadedFile) { | ||
| loadInitialFileCallback(loadedFile); | ||
| }).catch(function (err) { | ||
| console.log(err); | ||
| callback(err); | ||
| }); | ||
| .then(loadedFile => { | ||
| loadInitialFileCallback(loadedFile); | ||
| }).catch(err => { | ||
| console.log(err); | ||
| callback(err); | ||
| }); | ||
| } | ||
| function loadStyleSheets(callback, reload, modifyVars) { | ||
| for (var i = 0; i < less.sheets.length; i++) { | ||
| for (let i = 0; i < less.sheets.length; i++) { | ||
| loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1), modifyVars); | ||
| } | ||
| } | ||
| function initRunningMode() { | ||
| if (less.env === 'development') { | ||
| less.watchTimer = setInterval(function () { | ||
| less.watchTimer = setInterval(() => { | ||
| if (less.watchMode) { | ||
@@ -152,9 +167,8 @@ fileManager.clearFileCache(); | ||
| // eslint-disable-next-line no-unused-vars | ||
| loadStyleSheets(function (e, css, _, sheet, webInfo) { | ||
| loadStyleSheets((e, css, _, sheet, webInfo) => { | ||
| if (e) { | ||
| errors.add(e, e.href || sheet.href); | ||
| } else if (css) { | ||
| browser.createCSS(window.document, css, sheet); | ||
| } | ||
| else if (css) { | ||
| browser_1.default.createCSS(window.document, css, sheet); | ||
| } | ||
| }); | ||
@@ -165,2 +179,3 @@ } | ||
| } | ||
| // | ||
@@ -170,3 +185,3 @@ // Watch mode | ||
| less.watch = function () { | ||
| if (!less.watchMode) { | ||
| if (!less.watchMode ) { | ||
| less.env = 'development'; | ||
@@ -178,3 +193,5 @@ initRunningMode(); | ||
| }; | ||
| less.unwatch = function () { clearInterval(less.watchTimer); this.watchMode = false; return false; }; | ||
| less.unwatch = function () {clearInterval(less.watchTimer); this.watchMode = false; return false; }; | ||
| // | ||
@@ -184,6 +201,7 @@ // Synchronously get all <link> tags with the 'rel' attribute set to | ||
| // | ||
| less.registerStylesheetsImmediately = function () { | ||
| var links = document.getElementsByTagName('link'); | ||
| less.registerStylesheetsImmediately = () => { | ||
| const links = document.getElementsByTagName('link'); | ||
| less.sheets = []; | ||
| for (var i = 0; i < links.length; i++) { | ||
| for (let i = 0; i < links.length; i++) { | ||
| if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) && | ||
@@ -195,2 +213,3 @@ (links[i].type.match(typePattern)))) { | ||
| }; | ||
| // | ||
@@ -200,6 +219,7 @@ // Asynchronously get all <link> tags with the 'rel' attribute set to | ||
| // | ||
| less.registerStylesheets = function () { return new Promise(function (resolve) { | ||
| less.registerStylesheets = () => new Promise((resolve) => { | ||
| less.registerStylesheetsImmediately(); | ||
| resolve(); | ||
| }); }; | ||
| }); | ||
| // | ||
@@ -209,16 +229,20 @@ // With this function, it's possible to alter variables and re-render | ||
| // | ||
| less.modifyVars = function (record) { return less.refresh(true, record, false); }; | ||
| less.refresh = function (reload, modifyVars, clearFileCache) { | ||
| less.modifyVars = record => less.refresh(true, record, false); | ||
| less.refresh = (reload, modifyVars, clearFileCache) => { | ||
| if ((reload || clearFileCache) && clearFileCache !== false) { | ||
| fileManager.clearFileCache(); | ||
| } | ||
| return new Promise(function (resolve, reject) { | ||
| var startTime; | ||
| var endTime; | ||
| var totalMilliseconds; | ||
| var remainingSheets; | ||
| return new Promise((resolve, reject) => { | ||
| let startTime; | ||
| let endTime; | ||
| let totalMilliseconds; | ||
| let remainingSheets; | ||
| startTime = endTime = new Date(); | ||
| // Set counter for remaining unprocessed sheets | ||
| remainingSheets = less.sheets.length; | ||
| if (remainingSheets === 0) { | ||
| endTime = new Date(); | ||
@@ -228,11 +252,11 @@ totalMilliseconds = endTime - startTime; | ||
| resolve({ | ||
| startTime: startTime, | ||
| endTime: endTime, | ||
| totalMilliseconds: totalMilliseconds, | ||
| startTime, | ||
| endTime, | ||
| totalMilliseconds, | ||
| sheets: less.sheets.length | ||
| }); | ||
| } | ||
| else { | ||
| } else { | ||
| // Relies on less.sheets array, callback seems to be guaranteed to be called for every element of the array | ||
| loadStyleSheets(function (e, css, _, sheet, webInfo) { | ||
| loadStyleSheets((e, css, _, sheet, webInfo) => { | ||
| if (e) { | ||
@@ -244,19 +268,20 @@ errors.add(e, e.href || sheet.href); | ||
| if (webInfo.local) { | ||
| less.logger.info("Loading ".concat(sheet.href, " from cache.")); | ||
| less.logger.info(`Loading ${sheet.href} from cache.`); | ||
| } else { | ||
| less.logger.info(`Rendered ${sheet.href} successfully.`); | ||
| } | ||
| else { | ||
| less.logger.info("Rendered ".concat(sheet.href, " successfully.")); | ||
| } | ||
| browser_1.default.createCSS(window.document, css, sheet); | ||
| less.logger.info("CSS for ".concat(sheet.href, " generated in ").concat(new Date() - endTime, "ms")); | ||
| browser.createCSS(window.document, css, sheet); | ||
| less.logger.info(`CSS for ${sheet.href} generated in ${new Date() - endTime}ms`); | ||
| // Count completed sheet | ||
| remainingSheets--; | ||
| // Check if the last remaining sheet was processed and then call the promise | ||
| if (remainingSheets === 0) { | ||
| totalMilliseconds = new Date() - startTime; | ||
| less.logger.info("Less has finished. CSS generated in ".concat(totalMilliseconds, "ms")); | ||
| less.logger.info(`Less has finished. CSS generated in ${totalMilliseconds}ms`); | ||
| resolve({ | ||
| startTime: startTime, | ||
| endTime: endTime, | ||
| totalMilliseconds: totalMilliseconds, | ||
| startTime, | ||
| endTime, | ||
| totalMilliseconds, | ||
| sheets: less.sheets.length | ||
@@ -268,8 +293,9 @@ }); | ||
| } | ||
| loadStyles(modifyVars); | ||
| }); | ||
| }; | ||
| less.refreshStyles = loadStyles; | ||
| return less; | ||
| }); | ||
| //# sourceMappingURL=index.js.map | ||
| }; |
@@ -1,8 +0,7 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.default = (function (less, options) { | ||
| var logLevel_debug = 4; | ||
| var logLevel_info = 3; | ||
| var logLevel_warn = 2; | ||
| var logLevel_error = 1; | ||
| export default (less, options) => { | ||
| const logLevel_debug = 4; | ||
| const logLevel_info = 3; | ||
| const logLevel_warn = 2; | ||
| const logLevel_error = 1; | ||
| // The amount of logging in the javascript console. | ||
@@ -14,31 +13,31 @@ // 3 - Debug, information and errors | ||
| // Defaults to 2 | ||
| options.logLevel = typeof options.logLevel !== 'undefined' ? options.logLevel : (options.env === 'development' ? logLevel_info : logLevel_error); | ||
| options.logLevel = typeof options.logLevel !== 'undefined' ? options.logLevel : (options.env === 'development' ? logLevel_info : logLevel_error); | ||
| if (!options.loggers) { | ||
| options.loggers = [{ | ||
| debug: function (msg) { | ||
| if (options.logLevel >= logLevel_debug) { | ||
| console.log(msg); | ||
| } | ||
| }, | ||
| info: function (msg) { | ||
| if (options.logLevel >= logLevel_info) { | ||
| console.log(msg); | ||
| } | ||
| }, | ||
| warn: function (msg) { | ||
| if (options.logLevel >= logLevel_warn) { | ||
| console.warn(msg); | ||
| } | ||
| }, | ||
| error: function (msg) { | ||
| if (options.logLevel >= logLevel_error) { | ||
| console.error(msg); | ||
| } | ||
| debug: function(msg) { | ||
| if (options.logLevel >= logLevel_debug) { | ||
| console.log(msg); | ||
| } | ||
| }]; | ||
| }, | ||
| info: function(msg) { | ||
| if (options.logLevel >= logLevel_info) { | ||
| console.log(msg); | ||
| } | ||
| }, | ||
| warn: function(msg) { | ||
| if (options.logLevel >= logLevel_warn) { | ||
| console.warn(msg); | ||
| } | ||
| }, | ||
| error: function(msg) { | ||
| if (options.logLevel >= logLevel_error) { | ||
| console.error(msg); | ||
| } | ||
| } | ||
| }]; | ||
| } | ||
| for (var i = 0; i < options.loggers.length; i++) { | ||
| for (let i = 0; i < options.loggers.length; i++) { | ||
| less.logger.addListener(options.loggers[i]); | ||
| } | ||
| }); | ||
| //# sourceMappingURL=log-listener.js.map | ||
| }; |
@@ -1,18 +0,17 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| /** | ||
| * @todo Add tests for browser `@plugin` | ||
| */ | ||
| var abstract_plugin_loader_js_1 = tslib_1.__importDefault(require("../less/environment/abstract-plugin-loader.js")); | ||
| import AbstractPluginLoader from '../less/environment/abstract-plugin-loader.js'; | ||
| /** | ||
| * Browser Plugin Loader | ||
| */ | ||
| var PluginLoader = function (less) { | ||
| const PluginLoader = function(less) { | ||
| this.less = less; | ||
| // Should we shim this.require for browser? Probably not? | ||
| }; | ||
| PluginLoader.prototype = Object.assign(new abstract_plugin_loader_js_1.default(), { | ||
| loadPlugin: function (filename, basePath, context, environment, fileManager) { | ||
| return new Promise(function (fulfill, reject) { | ||
| PluginLoader.prototype = Object.assign(new AbstractPluginLoader(), { | ||
| loadPlugin(filename, basePath, context, environment, fileManager) { | ||
| return new Promise((fulfill, reject) => { | ||
| fileManager.loadFile(filename, basePath, context, environment) | ||
@@ -23,3 +22,4 @@ .then(fulfill).catch(reject); | ||
| }); | ||
| exports.default = PluginLoader; | ||
| //# sourceMappingURL=plugin-loader.js.map | ||
| export default PluginLoader; | ||
@@ -1,27 +0,27 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.addDataAttr = exports.extractId = void 0; | ||
| function extractId(href) { | ||
| return href.replace(/^[a-z-]+:\/+?[^/]+/, '') // Remove protocol & domain | ||
| .replace(/[?&]livereload=\w+/, '') // Remove LiveReload cachebuster | ||
| .replace(/^\//, '') // Remove root / | ||
| .replace(/\.[a-zA-Z]+$/, '') // Remove simple extension | ||
| .replace(/[^.\w-]+/g, '-') // Replace illegal characters | ||
| .replace(/\./g, ':'); // Replace dots with colons(for valid id) | ||
| /** @param {string} href */ | ||
| export function extractId(href) { | ||
| return href.replace(/^[a-z-]+:\/+?[^/]+/, '') // Remove protocol & domain | ||
| .replace(/[?&]livereload=\w+/, '') // Remove LiveReload cachebuster | ||
| .replace(/^\//, '') // Remove root / | ||
| .replace(/\.[a-zA-Z]+$/, '') // Remove simple extension | ||
| .replace(/[^.\w-]+/g, '-') // Replace illegal characters | ||
| .replace(/\./g, ':'); // Replace dots with colons(for valid id) | ||
| } | ||
| exports.extractId = extractId; | ||
| function addDataAttr(options, tag) { | ||
| if (!tag) { | ||
| return; | ||
| } // in case of tag is null or undefined | ||
| for (var opt in tag.dataset) { | ||
| /** | ||
| * @param {Record<string, *>} options | ||
| * @param {HTMLElement | null} tag | ||
| */ | ||
| export function addDataAttr(options, tag) { | ||
| if (!tag) {return;} // in case of tag is null or undefined | ||
| for (const opt in tag.dataset) { | ||
| if (Object.prototype.hasOwnProperty.call(tag.dataset, opt)) { | ||
| if (opt === 'env' || opt === 'dumpLineNumbers' || opt === 'rootpath' || opt === 'errorReporting') { | ||
| options[opt] = tag.dataset[opt]; | ||
| } | ||
| else { | ||
| } else { | ||
| try { | ||
| options[opt] = JSON.parse(tag.dataset[opt]); | ||
| } | ||
| catch (_) { } | ||
| catch (_) {} | ||
| } | ||
@@ -31,3 +31,1 @@ } | ||
| } | ||
| exports.addDataAttr = addDataAttr; | ||
| //# sourceMappingURL=utils.js.map |
@@ -1,19 +0,43 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.default = { | ||
| import { createRequire } from 'module'; | ||
| const require = createRequire(import.meta.url); | ||
| class SourceMapGeneratorFallback { | ||
| addMapping(){} | ||
| setSourceContent(){} | ||
| toJSON(){ | ||
| return null; | ||
| } | ||
| }; | ||
| export default { | ||
| encodeBase64: function encodeBase64(str) { | ||
| // Avoid Buffer constructor on newer versions of Node.js. | ||
| var buffer = (Buffer.from ? Buffer.from(str) : (new Buffer(str))); | ||
| const buffer = (Buffer.from ? Buffer.from(str) : (new Buffer(str))); | ||
| return buffer.toString('base64'); | ||
| }, | ||
| mimeLookup: function (filename) { | ||
| return require('mime').lookup(filename); | ||
| try { | ||
| const mimeModule = require('mime'); | ||
| return mimeModule ? mimeModule.lookup(filename) : "application/octet-stream"; | ||
| } catch (e) { | ||
| return "application/octet-stream"; | ||
| } | ||
| }, | ||
| charsetLookup: function (mime) { | ||
| return require('mime').charsets.lookup(mime); | ||
| try { | ||
| const mimeModule = require('mime'); | ||
| return mimeModule ? mimeModule.charsets.lookup(mime) : undefined; | ||
| } catch (e) { | ||
| return undefined; | ||
| } | ||
| }, | ||
| getSourceMapGenerator: function getSourceMapGenerator() { | ||
| return require('source-map').SourceMapGenerator; | ||
| try { | ||
| const sourceMapModule = require('source-map'); | ||
| return sourceMapModule ? sourceMapModule.SourceMapGenerator : SourceMapGeneratorFallback; | ||
| } catch (e) { | ||
| return SourceMapGeneratorFallback; | ||
| } | ||
| } | ||
| }; | ||
| //# sourceMappingURL=environment.js.map |
@@ -1,35 +0,40 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var path_1 = tslib_1.__importDefault(require("path")); | ||
| var fs_1 = tslib_1.__importDefault(require("./fs")); | ||
| var abstract_file_manager_js_1 = tslib_1.__importDefault(require("../less/environment/abstract-file-manager.js")); | ||
| var FileManager = function () { }; | ||
| FileManager.prototype = Object.assign(new abstract_file_manager_js_1.default(), { | ||
| supports: function () { | ||
| import path from 'path'; | ||
| import { createRequire } from 'module'; | ||
| import fs from './fs.js'; | ||
| import AbstractFileManager from '../less/environment/abstract-file-manager.js'; | ||
| const require = createRequire(import.meta.url); | ||
| const FileManager = function() {} | ||
| FileManager.prototype = Object.assign(new AbstractFileManager(), { | ||
| supports() { | ||
| return true; | ||
| }, | ||
| supportsSync: function () { | ||
| supportsSync() { | ||
| return true; | ||
| }, | ||
| loadFile: function (filename, currentDirectory, options, environment, callback) { | ||
| var fullFilename; | ||
| var isAbsoluteFilename = this.isPathAbsolute(filename); | ||
| var filenamesTried = []; | ||
| var self = this; | ||
| var prefix = filename.slice(0, 1); | ||
| var explicit = prefix === '.' || prefix === '/'; | ||
| var result = null; | ||
| var isNodeModule = false; | ||
| var npmPrefix = 'npm://'; | ||
| loadFile(filename, currentDirectory, options, environment, callback) { | ||
| let fullFilename; | ||
| const isAbsoluteFilename = this.isPathAbsolute(filename); | ||
| const filenamesTried = []; | ||
| const self = this; | ||
| const prefix = filename.slice(0, 1); | ||
| const explicit = prefix === '.' || prefix === '/'; | ||
| let result = null; | ||
| let isNodeModule = false; | ||
| const npmPrefix = 'npm://'; | ||
| options = options || {}; | ||
| var paths = isAbsoluteFilename ? [''] : [currentDirectory]; | ||
| if (options.paths) { | ||
| paths.push.apply(paths, options.paths); | ||
| } | ||
| if (!isAbsoluteFilename && paths.indexOf('.') === -1) { | ||
| paths.push('.'); | ||
| } | ||
| var prefixes = options.prefixes || ['']; | ||
| var fileParts = this.extractUrlParts(filename); | ||
| const paths = isAbsoluteFilename ? [''] : [currentDirectory]; | ||
| if (options.paths) { paths.push.apply(paths, options.paths); } | ||
| if (!isAbsoluteFilename && paths.indexOf('.') === -1) { paths.push('.'); } | ||
| const prefixes = options.prefixes || ['']; | ||
| const fileParts = this.extractUrlParts(filename); | ||
| if (options.syncImport) { | ||
@@ -50,2 +55,3 @@ getFileData(returnData, returnData); | ||
| } | ||
| function returnData(data) { | ||
@@ -59,6 +65,8 @@ if (!data.filename) { | ||
| } | ||
| function getFileData(fulfill, reject) { | ||
| (function tryPathIndex(i) { | ||
| function tryWithExtension() { | ||
| var extFilename = options.ext ? self.tryAppendExtension(fullFilename, options.ext) : fullFilename; | ||
| const extFilename = options.ext ? self.tryAppendExtension(fullFilename, options.ext) : fullFilename; | ||
| if (extFilename !== fullFilename && !explicit && paths[i] === '.') { | ||
@@ -83,5 +91,12 @@ try { | ||
| fullFilename = fileParts.rawPath + prefixes[j] + fileParts.filename; | ||
| if (paths[i]) { | ||
| fullFilename = path_1.default.join(paths[i], fullFilename); | ||
| if (paths[i].startsWith('#')) { | ||
| // Handling paths starting with '#' | ||
| fullFilename = paths[i].substr(1) + fullFilename; | ||
| }else{ | ||
| fullFilename = path.join(paths[i], fullFilename); | ||
| } | ||
| } | ||
| if (!explicit && paths[i] === '.') { | ||
@@ -99,4 +114,5 @@ try { | ||
| tryWithExtension(); | ||
| } | ||
| var readFileArgs = [fullFilename]; | ||
| } | ||
| const readFileArgs = [fullFilename]; | ||
| if (!options.rawBuffer) { | ||
@@ -107,4 +123,4 @@ readFileArgs.push('utf-8'); | ||
| try { | ||
| var data = fs_1.default.readFileSync.apply(this, readFileArgs); | ||
| fulfill({ contents: data, filename: fullFilename }); | ||
| const data = fs.readFileSync.apply(this, readFileArgs); | ||
| fulfill({ contents: data, filename: fullFilename}); | ||
| } | ||
@@ -117,11 +133,12 @@ catch (e) { | ||
| else { | ||
| readFileArgs.push(function (e, data) { | ||
| readFileArgs.push(function(e, data) { | ||
| if (e) { | ||
| filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename); | ||
| return tryPrefix(j + 1); | ||
| } | ||
| fulfill({ contents: data, filename: fullFilename }); | ||
| } | ||
| fulfill({ contents: data, filename: fullFilename}); | ||
| }); | ||
| fs_1.default.readFile.apply(this, readFileArgs); | ||
| fs.readFile.apply(this, readFileArgs); | ||
| } | ||
| } | ||
@@ -132,10 +149,10 @@ else { | ||
| })(0); | ||
| } else { | ||
| reject({ type: 'File', message: `'${filename}' wasn't found. Tried - ${filenamesTried.join(',')}` }); | ||
| } | ||
| else { | ||
| reject({ type: 'File', message: "'".concat(filename, "' wasn't found. Tried - ").concat(filenamesTried.join(',')) }); | ||
| } | ||
| }(0)); | ||
| } | ||
| }, | ||
| loadFileSync: function (filename, currentDirectory, options, environment) { | ||
| loadFileSync(filename, currentDirectory, options, environment) { | ||
| options.syncImport = true; | ||
@@ -145,3 +162,3 @@ return this.loadFile(filename, currentDirectory, options, environment); | ||
| }); | ||
| exports.default = FileManager; | ||
| //# sourceMappingURL=file-manager.js.map | ||
| export default FileManager; |
+11
-8
@@ -1,11 +0,14 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var fs; | ||
| /** @typedef {import('fs')} FS */ | ||
| import nodeFs from 'fs'; | ||
| import { createRequire } from 'module'; | ||
| const require = createRequire(import.meta.url); | ||
| /** @type {FS} */ | ||
| let fs; | ||
| try { | ||
| fs = require('graceful-fs'); | ||
| } catch (e) { | ||
| fs = nodeFs; | ||
| } | ||
| catch (e) { | ||
| fs = require('fs'); | ||
| } | ||
| exports.default = fs; | ||
| //# sourceMappingURL=fs.js.map | ||
| export default fs; |
@@ -1,50 +0,59 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var dimension_1 = tslib_1.__importDefault(require("../less/tree/dimension")); | ||
| var expression_1 = tslib_1.__importDefault(require("../less/tree/expression")); | ||
| var function_registry_1 = tslib_1.__importDefault(require("./../less/functions/function-registry")); | ||
| exports.default = (function (environment) { | ||
| import { createRequire } from 'module'; | ||
| import Dimension from '../less/tree/dimension.js'; | ||
| import Expression from '../less/tree/expression.js'; | ||
| import functionRegistry from './../less/functions/function-registry.js'; | ||
| const require = createRequire(import.meta.url); | ||
| export default environment => { | ||
| function imageSize(functionContext, filePathNode) { | ||
| var filePath = filePathNode.value; | ||
| var currentFileInfo = functionContext.currentFileInfo; | ||
| var currentDirectory = currentFileInfo.rewriteUrls ? | ||
| let filePath = filePathNode.value; | ||
| const currentFileInfo = functionContext.currentFileInfo; | ||
| const currentDirectory = currentFileInfo.rewriteUrls ? | ||
| currentFileInfo.currentDirectory : currentFileInfo.entryPath; | ||
| var fragmentStart = filePath.indexOf('#'); | ||
| const fragmentStart = filePath.indexOf('#'); | ||
| if (fragmentStart !== -1) { | ||
| filePath = filePath.slice(0, fragmentStart); | ||
| } | ||
| var fileManager = environment.getFileManager(filePath, currentDirectory, functionContext.context, environment, true); | ||
| const fileManager = environment.getFileManager(filePath, currentDirectory, functionContext.context, environment, true); | ||
| if (!fileManager) { | ||
| throw { | ||
| type: 'File', | ||
| message: "Can not set up FileManager for ".concat(filePathNode) | ||
| message: `Can not set up FileManager for ${filePathNode}` | ||
| }; | ||
| } | ||
| var fileSync = fileManager.loadFileSync(filePath, currentDirectory, functionContext.context, environment); | ||
| const fileSync = fileManager.loadFileSync(filePath, currentDirectory, functionContext.context, environment); | ||
| if (fileSync.error) { | ||
| throw fileSync.error; | ||
| } | ||
| var sizeOf = require('image-size'); | ||
| return sizeOf(fileSync.filename); | ||
| const sizeOf = require('image-size'); | ||
| return sizeOf ? sizeOf(fileSync.filename) : {width: 0, height: 0}; | ||
| } | ||
| var imageFunctions = { | ||
| 'image-size': function (filePathNode) { | ||
| var size = imageSize(this, filePathNode); | ||
| return new expression_1.default([ | ||
| new dimension_1.default(size.width, 'px'), | ||
| new dimension_1.default(size.height, 'px') | ||
| const imageFunctions = { | ||
| 'image-size': function(filePathNode) { | ||
| const size = imageSize(this, filePathNode); | ||
| return new Expression([ | ||
| new Dimension(size.width, 'px'), | ||
| new Dimension(size.height, 'px') | ||
| ]); | ||
| }, | ||
| 'image-width': function (filePathNode) { | ||
| var size = imageSize(this, filePathNode); | ||
| return new dimension_1.default(size.width, 'px'); | ||
| 'image-width': function(filePathNode) { | ||
| const size = imageSize(this, filePathNode); | ||
| return new Dimension(size.width, 'px'); | ||
| }, | ||
| 'image-height': function (filePathNode) { | ||
| var size = imageSize(this, filePathNode); | ||
| return new dimension_1.default(size.height, 'px'); | ||
| 'image-height': function(filePathNode) { | ||
| const size = imageSize(this, filePathNode); | ||
| return new Dimension(size.height, 'px'); | ||
| } | ||
| }; | ||
| function_registry_1.default.addMultiple(imageFunctions); | ||
| }); | ||
| //# sourceMappingURL=image-size.js.map | ||
| functionRegistry.addMultiple(imageFunctions); | ||
| }; |
+28
-19
@@ -1,22 +0,31 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var environment_1 = tslib_1.__importDefault(require("./environment")); | ||
| var file_manager_1 = tslib_1.__importDefault(require("./file-manager")); | ||
| var url_file_manager_1 = tslib_1.__importDefault(require("./url-file-manager")); | ||
| var less_1 = tslib_1.__importDefault(require("../less")); | ||
| var less = (0, less_1.default)(environment_1.default, [new file_manager_1.default(), new url_file_manager_1.default()]); | ||
| var lessc_helper_1 = tslib_1.__importDefault(require("./lessc-helper")); | ||
| import { createRequire } from 'module'; | ||
| import environment from './environment.js'; | ||
| import FileManager from './file-manager.js'; | ||
| import UrlFileManager from './url-file-manager.js'; | ||
| import createFromEnvironment from '../less/index.js'; | ||
| import lesscHelper from './lessc-helper.js'; | ||
| import PluginLoader from './plugin-loader.js'; | ||
| import fs from './fs.js'; | ||
| import defaultOptions from '../less/default-options.js'; | ||
| import imageSize from './image-size.js'; | ||
| const require = createRequire(import.meta.url); | ||
| const { version } = require('../../package.json'); | ||
| const less = createFromEnvironment(environment, [new FileManager(), new UrlFileManager()], version); | ||
| // allow people to create less with their own environment | ||
| less.createFromEnvironment = less_1.default; | ||
| less.lesscHelper = lessc_helper_1.default; | ||
| less.PluginLoader = require('./plugin-loader').default; | ||
| less.fs = require('./fs').default; | ||
| less.FileManager = file_manager_1.default; | ||
| less.UrlFileManager = url_file_manager_1.default; | ||
| less.createFromEnvironment = createFromEnvironment; | ||
| less.lesscHelper = lesscHelper; | ||
| less.PluginLoader = PluginLoader; | ||
| less.fs = fs; | ||
| less.FileManager = FileManager; | ||
| less.UrlFileManager = UrlFileManager; | ||
| // Set up options | ||
| less.options = require('../less/default-options').default(); | ||
| less.options = defaultOptions(); | ||
| // provide image-size functionality | ||
| require('./image-size').default(less.environment); | ||
| exports.default = less; | ||
| //# sourceMappingURL=index.js.map | ||
| imageSize(less.environment); | ||
| export default less; |
| // lessc_helper.js | ||
| // | ||
| // helper functions for lessc | ||
| var lessc_helper = { | ||
| const lessc_helper = { | ||
| // Stylize a string | ||
| stylize: function (str, style) { | ||
| var styles = { | ||
| 'reset': [0, 0], | ||
| 'bold': [1, 22], | ||
| 'inverse': [7, 27], | ||
| 'underline': [4, 24], | ||
| 'yellow': [33, 39], | ||
| 'green': [32, 39], | ||
| 'red': [31, 39], | ||
| 'grey': [90, 39] | ||
| stylize : function(str, style) { | ||
| const styles = { | ||
| 'reset' : [0, 0], | ||
| 'bold' : [1, 22], | ||
| 'inverse' : [7, 27], | ||
| 'underline' : [4, 24], | ||
| 'yellow' : [33, 39], | ||
| 'green' : [32, 39], | ||
| 'red' : [31, 39], | ||
| 'grey' : [90, 39] | ||
| }; | ||
| return "\u001B[".concat(styles[style][0], "m").concat(str, "\u001B[").concat(styles[style][1], "m"); | ||
| return `\x1b[${styles[style][0]}m${str}\x1b[${styles[style][1]}m`; | ||
| }, | ||
| // Print command line options | ||
| printUsage: function () { | ||
| printUsage: function() { | ||
| console.log('usage: lessc [option option=parameter ...] <source> [destination]'); | ||
@@ -71,2 +73,4 @@ console.log(''); | ||
| console.log(''); | ||
| console.log(' --quiet-deprecations Suppress deprecation warnings only (keeps other warnings).'); | ||
| console.log(''); | ||
| console.log('-------------------------- Deprecated ----------------'); | ||
@@ -90,9 +94,4 @@ console.log(' -sm=on|off Legacy parens-only math. Use --math'); | ||
| }; | ||
| // Exports helper functions | ||
| // eslint-disable-next-line no-prototype-builtins | ||
| for (var h in lessc_helper) { | ||
| if (lessc_helper.hasOwnProperty(h)) { | ||
| exports[h] = lessc_helper[h]; | ||
| } | ||
| } | ||
| //# sourceMappingURL=lessc-helper.js.map | ||
| export const { stylize, printUsage } = lessc_helper; | ||
| export default lessc_helper; |
@@ -1,17 +0,18 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var path_1 = tslib_1.__importDefault(require("path")); | ||
| var abstract_plugin_loader_js_1 = tslib_1.__importDefault(require("../less/environment/abstract-plugin-loader.js")); | ||
| import path from 'path'; | ||
| import { createRequire } from 'module'; | ||
| import AbstractPluginLoader from '../less/environment/abstract-plugin-loader.js'; | ||
| const require = createRequire(import.meta.url); | ||
| /** | ||
| * Node Plugin Loader | ||
| */ | ||
| var PluginLoader = function (less) { | ||
| const PluginLoader = function(less) { | ||
| this.less = less; | ||
| this.require = function (prefix) { | ||
| prefix = path_1.default.dirname(prefix); | ||
| return function (id) { | ||
| var str = id.substr(0, 2); | ||
| this.require = prefix => { | ||
| prefix = path.dirname(prefix); | ||
| return id => { | ||
| const str = id.slice(0, 2); | ||
| if (str === '..' || str === './') { | ||
| return require(path_1.default.join(prefix, id)); | ||
| return require(path.join(prefix, id)); | ||
| } | ||
@@ -24,22 +25,27 @@ else { | ||
| }; | ||
| PluginLoader.prototype = Object.assign(new abstract_plugin_loader_js_1.default(), { | ||
| loadPlugin: function (filename, basePath, context, environment, fileManager) { | ||
| var prefix = filename.slice(0, 1); | ||
| var explicit = prefix === '.' || prefix === '/' || filename.slice(-3).toLowerCase() === '.js'; | ||
| PluginLoader.prototype = Object.assign(new AbstractPluginLoader(), { | ||
| loadPlugin(filename, basePath, context, environment, fileManager) { | ||
| const prefix = filename.slice(0, 1); | ||
| const explicit = prefix === '.' || prefix === '/' || filename.slice(-3).toLowerCase() === '.js'; | ||
| if (!explicit) { | ||
| context.prefixes = ['less-plugin-', '']; | ||
| } | ||
| if (context.syncImport) { | ||
| return fileManager.loadFileSync(filename, basePath, context, environment); | ||
| } | ||
| return new Promise(function (fulfill, reject) { | ||
| fileManager.loadFile(filename, basePath, context, environment).then(function (data) { | ||
| try { | ||
| fulfill(data); | ||
| return new Promise((fulfill, reject) => { | ||
| fileManager.loadFile(filename, basePath, context, environment).then( | ||
| data => { | ||
| try { | ||
| fulfill(data); | ||
| } | ||
| catch (e) { | ||
| console.log(e); | ||
| reject(e); | ||
| } | ||
| } | ||
| catch (e) { | ||
| console.log(e); | ||
| reject(e); | ||
| } | ||
| }).catch(function (err) { | ||
| ).catch(err => { | ||
| reject(err); | ||
@@ -49,3 +55,4 @@ }); | ||
| }, | ||
| loadPluginSync: function (filename, basePath, context, environment, fileManager) { | ||
| loadPluginSync(filename, basePath, context, environment, fileManager) { | ||
| context.syncImport = true; | ||
@@ -55,3 +62,4 @@ return this.loadPlugin(filename, basePath, context, environment, fileManager); | ||
| }); | ||
| exports.default = PluginLoader; | ||
| //# sourceMappingURL=plugin-loader.js.map | ||
| export default PluginLoader; | ||
@@ -1,4 +0,1 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| /* eslint-disable no-unused-vars */ | ||
@@ -9,21 +6,23 @@ /** | ||
| */ | ||
| var isUrlRe = /^(?:https?:)?\/\//i; | ||
| var url_1 = tslib_1.__importDefault(require("url")); | ||
| var request; | ||
| var abstract_file_manager_js_1 = tslib_1.__importDefault(require("../less/environment/abstract-file-manager.js")); | ||
| var logger_1 = tslib_1.__importDefault(require("../less/logger")); | ||
| var UrlFileManager = function () { }; | ||
| UrlFileManager.prototype = Object.assign(new abstract_file_manager_js_1.default(), { | ||
| supports: function (filename, currentDirectory, options, environment) { | ||
| return isUrlRe.test(filename) || isUrlRe.test(currentDirectory); | ||
| import { createRequire } from 'module'; | ||
| const require = createRequire(import.meta.url); | ||
| const isUrlRe = /^(?:https?:)?\/\//i; | ||
| import url from 'url'; | ||
| let request; | ||
| import AbstractFileManager from '../less/environment/abstract-file-manager.js'; | ||
| import logger from '../less/logger.js'; | ||
| const UrlFileManager = function() {} | ||
| UrlFileManager.prototype = Object.assign(new AbstractFileManager(), { | ||
| supports(filename, currentDirectory, options, environment) { | ||
| return isUrlRe.test( filename ) || isUrlRe.test(currentDirectory); | ||
| }, | ||
| loadFile: function (filename, currentDirectory, options, environment) { | ||
| return new Promise(function (fulfill, reject) { | ||
| loadFile(filename, currentDirectory, options, environment) { | ||
| return new Promise((fulfill, reject) => { | ||
| if (request === undefined) { | ||
| try { | ||
| request = require('needle'); | ||
| } | ||
| catch (e) { | ||
| request = null; | ||
| } | ||
| try { request = require('needle'); } | ||
| catch (e) { request = null; } | ||
| } | ||
@@ -34,15 +33,18 @@ if (!request) { | ||
| } | ||
| var urlStr = isUrlRe.test(filename) ? filename : url_1.default.resolve(currentDirectory, filename); | ||
| let urlStr = isUrlRe.test( filename ) ? filename : url.resolve(currentDirectory, filename); | ||
| /** native-request currently has a bug */ | ||
| var hackUrlStr = urlStr.indexOf('?') === -1 ? urlStr + '?' : urlStr; | ||
| request.get(hackUrlStr, { follow_max: 5 }, function (err, resp, body) { | ||
| const hackUrlStr = urlStr.indexOf('?') === -1 ? urlStr + '?' : urlStr | ||
| request.get(hackUrlStr, { follow_max: 5 }, (err, resp, body) => { | ||
| if (err || resp && resp.statusCode >= 400) { | ||
| var message = resp && resp.statusCode === 404 | ||
| ? "resource '".concat(urlStr, "' was not found\n") | ||
| : "resource '".concat(urlStr, "' gave this Error:\n ").concat(err || resp.statusMessage || resp.statusCode, "\n"); | ||
| reject({ type: 'File', message: message }); | ||
| const message = resp && resp.statusCode === 404 | ||
| ? `resource '${urlStr}' was not found\n` | ||
| : `resource '${urlStr}' gave this Error:\n ${err || resp.statusMessage || resp.statusCode}\n`; | ||
| reject({ type: 'File', message }); | ||
| return; | ||
| } | ||
| if (resp.statusCode >= 300) { | ||
| reject({ type: 'File', message: "resource '".concat(urlStr, "' caused too many redirects") }); | ||
| reject({ type: 'File', message: `resource '${urlStr}' caused too many redirects` }); | ||
| return; | ||
@@ -52,3 +54,3 @@ } | ||
| if (!body) { | ||
| logger_1.default.warn("Warning: Empty body (HTTP ".concat(resp.statusCode, ") returned by \"").concat(urlStr, "\"")); | ||
| logger.warn(`Warning: Empty body (HTTP ${resp.statusCode}) returned by "${urlStr}"`); | ||
| } | ||
@@ -60,3 +62,3 @@ fulfill({ contents: body || '', filename: urlStr }); | ||
| }); | ||
| exports.default = UrlFileManager; | ||
| //# sourceMappingURL=url-file-manager.js.map | ||
| export default UrlFileManager; |
@@ -1,5 +0,3 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.RewriteUrls = exports.Math = void 0; | ||
| exports.Math = { | ||
| export const Math = { | ||
| ALWAYS: 0, | ||
@@ -10,7 +8,7 @@ PARENS_DIVISION: 1, | ||
| }; | ||
| exports.RewriteUrls = { | ||
| export const RewriteUrls = { | ||
| OFF: 0, | ||
| LOCAL: 1, | ||
| ALL: 2 | ||
| }; | ||
| //# sourceMappingURL=constants.js.map | ||
| }; |
+71
-55
@@ -1,12 +0,9 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var contexts = {}; | ||
| exports.default = contexts; | ||
| var Constants = tslib_1.__importStar(require("./constants")); | ||
| var copyFromOriginal = function copyFromOriginal(original, destination, propertiesToCopy) { | ||
| if (!original) { | ||
| return; | ||
| } | ||
| for (var i = 0; i < propertiesToCopy.length; i++) { | ||
| const contexts = {}; | ||
| export default contexts; | ||
| import * as Constants from './constants.js'; | ||
| const copyFromOriginal = function copyFromOriginal(original, destination, propertiesToCopy) { | ||
| if (!original) { return; } | ||
| for (let i = 0; i < propertiesToCopy.length; i++) { | ||
| if (Object.prototype.hasOwnProperty.call(original, propertiesToCopy[i])) { | ||
@@ -17,50 +14,55 @@ destination[propertiesToCopy[i]] = original[propertiesToCopy[i]]; | ||
| }; | ||
| /* | ||
| parse is used whilst parsing | ||
| */ | ||
| var parseCopyProperties = [ | ||
| const parseCopyProperties = [ | ||
| // options | ||
| 'paths', | ||
| 'rewriteUrls', | ||
| 'rootpath', | ||
| 'strictImports', | ||
| 'insecure', | ||
| 'dumpLineNumbers', | ||
| 'compress', | ||
| 'syncImport', | ||
| 'mime', | ||
| 'useFileCache', | ||
| 'paths', // option - unmodified - paths to search for imports on | ||
| 'rewriteUrls', // option - whether to adjust URL's to be relative | ||
| 'rootpath', // option - rootpath to append to URL's | ||
| 'strictImports', // option - | ||
| 'insecure', // option - whether to allow imports from insecure ssl hosts | ||
| 'dumpLineNumbers', // option - @deprecated The dumpLineNumbers option is deprecated. Use sourcemaps instead. All modes ('comments', 'mediaquery', 'all') will be removed in a future version. | ||
| 'compress', // option - whether to compress | ||
| 'syncImport', // option - whether to import synchronously | ||
| 'mime', // browser only - mime type for sheet import | ||
| 'useFileCache', // browser only - whether to use the per file session cache | ||
| // context | ||
| 'processImports', | ||
| 'processImports', // option & context - whether to process imports. if false then imports will not be imported. | ||
| // Used by the import manager to stop multiple import visitors being created. | ||
| 'pluginManager', | ||
| 'quiet', // option - whether to log warnings | ||
| 'pluginManager', // Used as the plugin manager for the session | ||
| 'quiet', // option - whether to log warnings | ||
| 'quietDeprecations', // option - whether to suppress deprecation warnings only | ||
| ]; | ||
| contexts.Parse = function (options) { | ||
| contexts.Parse = function(options) { | ||
| copyFromOriginal(options, this, parseCopyProperties); | ||
| if (typeof this.paths === 'string') { | ||
| this.paths = [this.paths]; | ||
| } | ||
| if (typeof this.paths === 'string') { this.paths = [this.paths]; } | ||
| }; | ||
| var evalCopyProperties = [ | ||
| 'paths', | ||
| 'compress', | ||
| 'math', | ||
| 'strictUnits', | ||
| 'sourceMap', | ||
| 'importMultiple', | ||
| 'urlArgs', | ||
| 'javascriptEnabled', | ||
| 'pluginManager', | ||
| 'importantScope', | ||
| 'rewriteUrls' // option - whether to adjust URL's to be relative | ||
| const evalCopyProperties = [ | ||
| 'paths', // additional include paths | ||
| 'compress', // whether to compress | ||
| 'math', // whether math has to be within parenthesis | ||
| 'strictUnits', // whether units need to evaluate correctly | ||
| 'sourceMap', // whether to output a source map | ||
| 'importMultiple', // whether we are currently importing multiple copies | ||
| 'urlArgs', // whether to add args into url tokens | ||
| 'javascriptEnabled', // option - whether Inline JavaScript is enabled. if undefined, defaults to false | ||
| 'pluginManager', // Used as the plugin manager for the session | ||
| 'importantScope', // used to bubble up !important statements | ||
| 'rewriteUrls' // option - whether to adjust URL's to be relative | ||
| ]; | ||
| contexts.Eval = function (options, frames) { | ||
| contexts.Eval = function(options, frames) { | ||
| copyFromOriginal(options, this, evalCopyProperties); | ||
| if (typeof this.paths === 'string') { | ||
| this.paths = [this.paths]; | ||
| } | ||
| if (typeof this.paths === 'string') { this.paths = [this.paths]; } | ||
| this.frames = frames || []; | ||
| this.importantScope = this.importantScope || []; | ||
| }; | ||
| contexts.Eval.prototype.enterCalc = function () { | ||
@@ -73,2 +75,3 @@ if (!this.calcStack) { | ||
| }; | ||
| contexts.Eval.prototype.exitCalc = function () { | ||
@@ -80,2 +83,3 @@ this.calcStack.pop(); | ||
| }; | ||
| contexts.Eval.prototype.inParenthesis = function () { | ||
@@ -87,5 +91,7 @@ if (!this.parensStack) { | ||
| }; | ||
| contexts.Eval.prototype.outOfParenthesis = function () { | ||
| this.parensStack.pop(); | ||
| }; | ||
| contexts.Eval.prototype.inCalc = false; | ||
@@ -105,10 +111,15 @@ contexts.Eval.prototype.mathOn = true; | ||
| }; | ||
| contexts.Eval.prototype.pathRequiresRewrite = function (path) { | ||
| var isRelative = this.rewriteUrls === Constants.RewriteUrls.LOCAL ? isPathLocalRelative : isPathRelative; | ||
| const isRelative = this.rewriteUrls === Constants.RewriteUrls.LOCAL ? isPathLocalRelative : isPathRelative; | ||
| return isRelative(path); | ||
| }; | ||
| contexts.Eval.prototype.rewritePath = function (path, rootpath) { | ||
| var newPath; | ||
| let newPath; | ||
| rootpath = rootpath || ''; | ||
| newPath = this.normalizePath(rootpath + path); | ||
| // If a path was explicit relative and the rootpath was not an absolute path | ||
@@ -119,13 +130,16 @@ // we must ensure that the new path is also explicit relative. | ||
| isPathLocalRelative(newPath) === false) { | ||
| newPath = "./".concat(newPath); | ||
| newPath = `./${newPath}`; | ||
| } | ||
| return newPath; | ||
| }; | ||
| contexts.Eval.prototype.normalizePath = function (path) { | ||
| var segments = path.split('/').reverse(); | ||
| var segment; | ||
| const segments = path.split('/').reverse(); | ||
| let segment; | ||
| path = []; | ||
| while (segments.length !== 0) { | ||
| segment = segments.pop(); | ||
| switch (segment) { | ||
| switch ( segment ) { | ||
| case '.': | ||
@@ -135,5 +149,4 @@ break; | ||
| if ((path.length === 0) || (path[path.length - 1] === '..')) { | ||
| path.push(segment); | ||
| } | ||
| else { | ||
| path.push( segment ); | ||
| } else { | ||
| path.pop(); | ||
@@ -147,11 +160,14 @@ } | ||
| } | ||
| return path.join('/'); | ||
| }; | ||
| function isPathRelative(path) { | ||
| return !/^(?:[a-z-]+:|\/|#)/i.test(path); | ||
| } | ||
| function isPathLocalRelative(path) { | ||
| return path.charAt(0) === '.'; | ||
| } | ||
| // todo - do the same for the toCSS ? | ||
| //# sourceMappingURL=contexts.js.map |
+150
-153
@@ -1,153 +0,150 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.default = { | ||
| 'aliceblue': '#f0f8ff', | ||
| 'antiquewhite': '#faebd7', | ||
| 'aqua': '#00ffff', | ||
| 'aquamarine': '#7fffd4', | ||
| 'azure': '#f0ffff', | ||
| 'beige': '#f5f5dc', | ||
| 'bisque': '#ffe4c4', | ||
| 'black': '#000000', | ||
| 'blanchedalmond': '#ffebcd', | ||
| 'blue': '#0000ff', | ||
| 'blueviolet': '#8a2be2', | ||
| 'brown': '#a52a2a', | ||
| 'burlywood': '#deb887', | ||
| 'cadetblue': '#5f9ea0', | ||
| 'chartreuse': '#7fff00', | ||
| 'chocolate': '#d2691e', | ||
| 'coral': '#ff7f50', | ||
| 'cornflowerblue': '#6495ed', | ||
| 'cornsilk': '#fff8dc', | ||
| 'crimson': '#dc143c', | ||
| 'cyan': '#00ffff', | ||
| 'darkblue': '#00008b', | ||
| 'darkcyan': '#008b8b', | ||
| 'darkgoldenrod': '#b8860b', | ||
| 'darkgray': '#a9a9a9', | ||
| 'darkgrey': '#a9a9a9', | ||
| 'darkgreen': '#006400', | ||
| 'darkkhaki': '#bdb76b', | ||
| 'darkmagenta': '#8b008b', | ||
| 'darkolivegreen': '#556b2f', | ||
| 'darkorange': '#ff8c00', | ||
| 'darkorchid': '#9932cc', | ||
| 'darkred': '#8b0000', | ||
| 'darksalmon': '#e9967a', | ||
| 'darkseagreen': '#8fbc8f', | ||
| 'darkslateblue': '#483d8b', | ||
| 'darkslategray': '#2f4f4f', | ||
| 'darkslategrey': '#2f4f4f', | ||
| 'darkturquoise': '#00ced1', | ||
| 'darkviolet': '#9400d3', | ||
| 'deeppink': '#ff1493', | ||
| 'deepskyblue': '#00bfff', | ||
| 'dimgray': '#696969', | ||
| 'dimgrey': '#696969', | ||
| 'dodgerblue': '#1e90ff', | ||
| 'firebrick': '#b22222', | ||
| 'floralwhite': '#fffaf0', | ||
| 'forestgreen': '#228b22', | ||
| 'fuchsia': '#ff00ff', | ||
| 'gainsboro': '#dcdcdc', | ||
| 'ghostwhite': '#f8f8ff', | ||
| 'gold': '#ffd700', | ||
| 'goldenrod': '#daa520', | ||
| 'gray': '#808080', | ||
| 'grey': '#808080', | ||
| 'green': '#008000', | ||
| 'greenyellow': '#adff2f', | ||
| 'honeydew': '#f0fff0', | ||
| 'hotpink': '#ff69b4', | ||
| 'indianred': '#cd5c5c', | ||
| 'indigo': '#4b0082', | ||
| 'ivory': '#fffff0', | ||
| 'khaki': '#f0e68c', | ||
| 'lavender': '#e6e6fa', | ||
| 'lavenderblush': '#fff0f5', | ||
| 'lawngreen': '#7cfc00', | ||
| 'lemonchiffon': '#fffacd', | ||
| 'lightblue': '#add8e6', | ||
| 'lightcoral': '#f08080', | ||
| 'lightcyan': '#e0ffff', | ||
| 'lightgoldenrodyellow': '#fafad2', | ||
| 'lightgray': '#d3d3d3', | ||
| 'lightgrey': '#d3d3d3', | ||
| 'lightgreen': '#90ee90', | ||
| 'lightpink': '#ffb6c1', | ||
| 'lightsalmon': '#ffa07a', | ||
| 'lightseagreen': '#20b2aa', | ||
| 'lightskyblue': '#87cefa', | ||
| 'lightslategray': '#778899', | ||
| 'lightslategrey': '#778899', | ||
| 'lightsteelblue': '#b0c4de', | ||
| 'lightyellow': '#ffffe0', | ||
| 'lime': '#00ff00', | ||
| 'limegreen': '#32cd32', | ||
| 'linen': '#faf0e6', | ||
| 'magenta': '#ff00ff', | ||
| 'maroon': '#800000', | ||
| 'mediumaquamarine': '#66cdaa', | ||
| 'mediumblue': '#0000cd', | ||
| 'mediumorchid': '#ba55d3', | ||
| 'mediumpurple': '#9370d8', | ||
| 'mediumseagreen': '#3cb371', | ||
| 'mediumslateblue': '#7b68ee', | ||
| 'mediumspringgreen': '#00fa9a', | ||
| 'mediumturquoise': '#48d1cc', | ||
| 'mediumvioletred': '#c71585', | ||
| 'midnightblue': '#191970', | ||
| 'mintcream': '#f5fffa', | ||
| 'mistyrose': '#ffe4e1', | ||
| 'moccasin': '#ffe4b5', | ||
| 'navajowhite': '#ffdead', | ||
| 'navy': '#000080', | ||
| 'oldlace': '#fdf5e6', | ||
| 'olive': '#808000', | ||
| 'olivedrab': '#6b8e23', | ||
| 'orange': '#ffa500', | ||
| 'orangered': '#ff4500', | ||
| 'orchid': '#da70d6', | ||
| 'palegoldenrod': '#eee8aa', | ||
| 'palegreen': '#98fb98', | ||
| 'paleturquoise': '#afeeee', | ||
| 'palevioletred': '#d87093', | ||
| 'papayawhip': '#ffefd5', | ||
| 'peachpuff': '#ffdab9', | ||
| 'peru': '#cd853f', | ||
| 'pink': '#ffc0cb', | ||
| 'plum': '#dda0dd', | ||
| 'powderblue': '#b0e0e6', | ||
| 'purple': '#800080', | ||
| 'rebeccapurple': '#663399', | ||
| 'red': '#ff0000', | ||
| 'rosybrown': '#bc8f8f', | ||
| 'royalblue': '#4169e1', | ||
| 'saddlebrown': '#8b4513', | ||
| 'salmon': '#fa8072', | ||
| 'sandybrown': '#f4a460', | ||
| 'seagreen': '#2e8b57', | ||
| 'seashell': '#fff5ee', | ||
| 'sienna': '#a0522d', | ||
| 'silver': '#c0c0c0', | ||
| 'skyblue': '#87ceeb', | ||
| 'slateblue': '#6a5acd', | ||
| 'slategray': '#708090', | ||
| 'slategrey': '#708090', | ||
| 'snow': '#fffafa', | ||
| 'springgreen': '#00ff7f', | ||
| 'steelblue': '#4682b4', | ||
| 'tan': '#d2b48c', | ||
| 'teal': '#008080', | ||
| 'thistle': '#d8bfd8', | ||
| 'tomato': '#ff6347', | ||
| 'turquoise': '#40e0d0', | ||
| 'violet': '#ee82ee', | ||
| 'wheat': '#f5deb3', | ||
| 'white': '#ffffff', | ||
| 'whitesmoke': '#f5f5f5', | ||
| 'yellow': '#ffff00', | ||
| 'yellowgreen': '#9acd32' | ||
| }; | ||
| //# sourceMappingURL=colors.js.map | ||
| export default { | ||
| 'aliceblue':'#f0f8ff', | ||
| 'antiquewhite':'#faebd7', | ||
| 'aqua':'#00ffff', | ||
| 'aquamarine':'#7fffd4', | ||
| 'azure':'#f0ffff', | ||
| 'beige':'#f5f5dc', | ||
| 'bisque':'#ffe4c4', | ||
| 'black':'#000000', | ||
| 'blanchedalmond':'#ffebcd', | ||
| 'blue':'#0000ff', | ||
| 'blueviolet':'#8a2be2', | ||
| 'brown':'#a52a2a', | ||
| 'burlywood':'#deb887', | ||
| 'cadetblue':'#5f9ea0', | ||
| 'chartreuse':'#7fff00', | ||
| 'chocolate':'#d2691e', | ||
| 'coral':'#ff7f50', | ||
| 'cornflowerblue':'#6495ed', | ||
| 'cornsilk':'#fff8dc', | ||
| 'crimson':'#dc143c', | ||
| 'cyan':'#00ffff', | ||
| 'darkblue':'#00008b', | ||
| 'darkcyan':'#008b8b', | ||
| 'darkgoldenrod':'#b8860b', | ||
| 'darkgray':'#a9a9a9', | ||
| 'darkgrey':'#a9a9a9', | ||
| 'darkgreen':'#006400', | ||
| 'darkkhaki':'#bdb76b', | ||
| 'darkmagenta':'#8b008b', | ||
| 'darkolivegreen':'#556b2f', | ||
| 'darkorange':'#ff8c00', | ||
| 'darkorchid':'#9932cc', | ||
| 'darkred':'#8b0000', | ||
| 'darksalmon':'#e9967a', | ||
| 'darkseagreen':'#8fbc8f', | ||
| 'darkslateblue':'#483d8b', | ||
| 'darkslategray':'#2f4f4f', | ||
| 'darkslategrey':'#2f4f4f', | ||
| 'darkturquoise':'#00ced1', | ||
| 'darkviolet':'#9400d3', | ||
| 'deeppink':'#ff1493', | ||
| 'deepskyblue':'#00bfff', | ||
| 'dimgray':'#696969', | ||
| 'dimgrey':'#696969', | ||
| 'dodgerblue':'#1e90ff', | ||
| 'firebrick':'#b22222', | ||
| 'floralwhite':'#fffaf0', | ||
| 'forestgreen':'#228b22', | ||
| 'fuchsia':'#ff00ff', | ||
| 'gainsboro':'#dcdcdc', | ||
| 'ghostwhite':'#f8f8ff', | ||
| 'gold':'#ffd700', | ||
| 'goldenrod':'#daa520', | ||
| 'gray':'#808080', | ||
| 'grey':'#808080', | ||
| 'green':'#008000', | ||
| 'greenyellow':'#adff2f', | ||
| 'honeydew':'#f0fff0', | ||
| 'hotpink':'#ff69b4', | ||
| 'indianred':'#cd5c5c', | ||
| 'indigo':'#4b0082', | ||
| 'ivory':'#fffff0', | ||
| 'khaki':'#f0e68c', | ||
| 'lavender':'#e6e6fa', | ||
| 'lavenderblush':'#fff0f5', | ||
| 'lawngreen':'#7cfc00', | ||
| 'lemonchiffon':'#fffacd', | ||
| 'lightblue':'#add8e6', | ||
| 'lightcoral':'#f08080', | ||
| 'lightcyan':'#e0ffff', | ||
| 'lightgoldenrodyellow':'#fafad2', | ||
| 'lightgray':'#d3d3d3', | ||
| 'lightgrey':'#d3d3d3', | ||
| 'lightgreen':'#90ee90', | ||
| 'lightpink':'#ffb6c1', | ||
| 'lightsalmon':'#ffa07a', | ||
| 'lightseagreen':'#20b2aa', | ||
| 'lightskyblue':'#87cefa', | ||
| 'lightslategray':'#778899', | ||
| 'lightslategrey':'#778899', | ||
| 'lightsteelblue':'#b0c4de', | ||
| 'lightyellow':'#ffffe0', | ||
| 'lime':'#00ff00', | ||
| 'limegreen':'#32cd32', | ||
| 'linen':'#faf0e6', | ||
| 'magenta':'#ff00ff', | ||
| 'maroon':'#800000', | ||
| 'mediumaquamarine':'#66cdaa', | ||
| 'mediumblue':'#0000cd', | ||
| 'mediumorchid':'#ba55d3', | ||
| 'mediumpurple':'#9370d8', | ||
| 'mediumseagreen':'#3cb371', | ||
| 'mediumslateblue':'#7b68ee', | ||
| 'mediumspringgreen':'#00fa9a', | ||
| 'mediumturquoise':'#48d1cc', | ||
| 'mediumvioletred':'#c71585', | ||
| 'midnightblue':'#191970', | ||
| 'mintcream':'#f5fffa', | ||
| 'mistyrose':'#ffe4e1', | ||
| 'moccasin':'#ffe4b5', | ||
| 'navajowhite':'#ffdead', | ||
| 'navy':'#000080', | ||
| 'oldlace':'#fdf5e6', | ||
| 'olive':'#808000', | ||
| 'olivedrab':'#6b8e23', | ||
| 'orange':'#ffa500', | ||
| 'orangered':'#ff4500', | ||
| 'orchid':'#da70d6', | ||
| 'palegoldenrod':'#eee8aa', | ||
| 'palegreen':'#98fb98', | ||
| 'paleturquoise':'#afeeee', | ||
| 'palevioletred':'#d87093', | ||
| 'papayawhip':'#ffefd5', | ||
| 'peachpuff':'#ffdab9', | ||
| 'peru':'#cd853f', | ||
| 'pink':'#ffc0cb', | ||
| 'plum':'#dda0dd', | ||
| 'powderblue':'#b0e0e6', | ||
| 'purple':'#800080', | ||
| 'rebeccapurple':'#663399', | ||
| 'red':'#ff0000', | ||
| 'rosybrown':'#bc8f8f', | ||
| 'royalblue':'#4169e1', | ||
| 'saddlebrown':'#8b4513', | ||
| 'salmon':'#fa8072', | ||
| 'sandybrown':'#f4a460', | ||
| 'seagreen':'#2e8b57', | ||
| 'seashell':'#fff5ee', | ||
| 'sienna':'#a0522d', | ||
| 'silver':'#c0c0c0', | ||
| 'skyblue':'#87ceeb', | ||
| 'slateblue':'#6a5acd', | ||
| 'slategray':'#708090', | ||
| 'slategrey':'#708090', | ||
| 'snow':'#fffafa', | ||
| 'springgreen':'#00ff7f', | ||
| 'steelblue':'#4682b4', | ||
| 'tan':'#d2b48c', | ||
| 'teal':'#008080', | ||
| 'thistle':'#d8bfd8', | ||
| 'tomato':'#ff6347', | ||
| 'turquoise':'#40e0d0', | ||
| 'violet':'#ee82ee', | ||
| 'wheat':'#f5deb3', | ||
| 'white':'#ffffff', | ||
| 'whitesmoke':'#f5f5f5', | ||
| 'yellow':'#ffff00', | ||
| 'yellowgreen':'#9acd32' | ||
| }; |
@@ -1,7 +0,4 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var colors_1 = tslib_1.__importDefault(require("./colors")); | ||
| var unit_conversions_1 = tslib_1.__importDefault(require("./unit-conversions")); | ||
| exports.default = { colors: colors_1.default, unitConversions: unit_conversions_1.default }; | ||
| //# sourceMappingURL=index.js.map | ||
| import colors from './colors.js'; | ||
| import unitConversions from './unit-conversions.js'; | ||
| export default { colors, unitConversions }; |
@@ -1,4 +0,2 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.default = { | ||
| export default { | ||
| length: { | ||
@@ -23,3 +21,2 @@ 'm': 1, | ||
| } | ||
| }; | ||
| //# sourceMappingURL=unit-conversions.js.map | ||
| }; |
@@ -1,30 +0,34 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| // Export a new default each time | ||
| function default_1() { | ||
| export default function() { | ||
| return { | ||
| /* Inline Javascript - @plugin still allowed */ | ||
| javascriptEnabled: false, | ||
| /* Outputs a makefile import dependency list to stdout. */ | ||
| depends: false, | ||
| /* (DEPRECATED) Compress using less built-in compression. | ||
| * This does an okay job but does not utilise all the tricks of | ||
| /* (DEPRECATED) Compress using less built-in compression. | ||
| * This does an okay job but does not utilise all the tricks of | ||
| * dedicated css compression. */ | ||
| compress: false, | ||
| /* Runs the less parser and just reports errors without any output. */ | ||
| lint: false, | ||
| /* Sets available include paths. | ||
| * If the file in an @import rule does not exist at that exact location, | ||
| * less will look for it at the location(s) passed to this option. | ||
| * You might use this for instance to specify a path to a library which | ||
| * If the file in an @import rule does not exist at that exact location, | ||
| * less will look for it at the location(s) passed to this option. | ||
| * You might use this for instance to specify a path to a library which | ||
| * you want to be referenced simply and relatively in the less files. */ | ||
| paths: [], | ||
| /* color output in the terminal */ | ||
| color: true, | ||
| /** | ||
| * @deprecated This option has confusing behavior and may be removed in a future version. | ||
| * | ||
| * | ||
| * When true, prevents @import statements for .less files from being evaluated inside | ||
| * selector blocks (rulesets). The imports are silently ignored and not output. | ||
| * | ||
| * | ||
| * Behavior: | ||
@@ -34,27 +38,31 @@ * - @import at root level: Always processed | ||
| * - @import inside selector blocks (.class, #id, etc.): NOT processed (silently ignored) | ||
| * | ||
| * | ||
| * When false (default): All @import statements are processed regardless of context. | ||
| * | ||
| * | ||
| * Note: Despite the name "strict", this option does NOT throw an error when imports | ||
| * are used in selector blocks - it silently ignores them. This is confusing | ||
| * behavior that may catch users off guard. | ||
| * | ||
| * | ||
| * Note: Only affects .less file imports. CSS imports (url(...) or .css files) are | ||
| * always output as CSS @import statements regardless of this setting. | ||
| * | ||
| * | ||
| * @see https://github.com/less/less.js/issues/656 | ||
| */ | ||
| strictImports: false, | ||
| /* Allow Imports from Insecure HTTPS Hosts */ | ||
| insecure: false, | ||
| /* Allows you to add a path to every generated import and url in your css. | ||
| * This does not affect less import statements that are processed, just ones | ||
| /* Allows you to add a path to every generated import and url in your css. | ||
| * This does not affect less import statements that are processed, just ones | ||
| * that are left in the output css. */ | ||
| rootpath: '', | ||
| /* By default URLs are kept as-is, so if you import a file in a sub-directory | ||
| * that references an image, exactly the same URL will be output in the css. | ||
| * This option allows you to re-write URL's in imported files so that the | ||
| /* By default URLs are kept as-is, so if you import a file in a sub-directory | ||
| * that references an image, exactly the same URL will be output in the css. | ||
| * This option allows you to re-write URL's in imported files so that the | ||
| * URL is always relative to the base imported file */ | ||
| rewriteUrls: false, | ||
| /* How to process math | ||
| /* How to process math | ||
| * 0 always - eagerly try to solve all operations | ||
@@ -66,16 +74,18 @@ * 1 parens-division - require parens for division "/" | ||
| math: 1, | ||
| /* Without this option, less attempts to guess at the output unit when it does maths. */ | ||
| strictUnits: false, | ||
| /* Effectively the declaration is put at the top of your base Less file, | ||
| * meaning it can be used but it also can be overridden if this variable | ||
| /* Effectively the declaration is put at the top of your base Less file, | ||
| * meaning it can be used but it also can be overridden if this variable | ||
| * is defined in the file. */ | ||
| globalVars: null, | ||
| /* As opposed to the global variable option, this puts the declaration at the | ||
| * end of your base file, meaning it will override anything defined in your Less file. */ | ||
| modifyVars: null, | ||
| /* This option allows you to specify a argument to go on to every URL. */ | ||
| urlArgs: '' | ||
| }; | ||
| } | ||
| exports.default = default_1; | ||
| //# sourceMappingURL=default-options.js.map | ||
| } | ||
| } |
@@ -1,8 +0,4 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var AbstractFileManager = /** @class */ (function () { | ||
| function AbstractFileManager() { | ||
| } | ||
| AbstractFileManager.prototype.getPath = function (filename) { | ||
| var j = filename.lastIndexOf('?'); | ||
| class AbstractFileManager { | ||
| getPath(filename) { | ||
| let j = filename.lastIndexOf('?'); | ||
| if (j > 0) { | ||
@@ -19,20 +15,26 @@ filename = filename.slice(0, j); | ||
| return filename.slice(0, j + 1); | ||
| }; | ||
| AbstractFileManager.prototype.tryAppendExtension = function (path, ext) { | ||
| } | ||
| tryAppendExtension(path, ext) { | ||
| return /(\.[a-z]*$)|([?;].*)$/.test(path) ? path : path + ext; | ||
| }; | ||
| AbstractFileManager.prototype.tryAppendLessExtension = function (path) { | ||
| } | ||
| tryAppendLessExtension(path) { | ||
| return this.tryAppendExtension(path, '.less'); | ||
| }; | ||
| AbstractFileManager.prototype.supportsSync = function () { | ||
| } | ||
| supportsSync() { | ||
| return false; | ||
| }; | ||
| AbstractFileManager.prototype.alwaysMakePathsAbsolute = function () { | ||
| } | ||
| alwaysMakePathsAbsolute() { | ||
| return false; | ||
| }; | ||
| AbstractFileManager.prototype.isPathAbsolute = function (filename) { | ||
| } | ||
| isPathAbsolute(filename) { | ||
| return (/^(?:[a-z-]+:|\/|\\|#)/i).test(filename); | ||
| }; | ||
| } | ||
| // TODO: pull out / replace? | ||
| AbstractFileManager.prototype.join = function (basePath, laterPath) { | ||
| join(basePath, laterPath) { | ||
| if (!basePath) { | ||
@@ -42,12 +44,15 @@ return laterPath; | ||
| return basePath + laterPath; | ||
| }; | ||
| AbstractFileManager.prototype.pathDiff = function (url, baseUrl) { | ||
| } | ||
| pathDiff(url, baseUrl) { | ||
| // diff between two paths to create a relative path | ||
| var urlParts = this.extractUrlParts(url); | ||
| var baseUrlParts = this.extractUrlParts(baseUrl); | ||
| var i; | ||
| var max; | ||
| var urlDirectories; | ||
| var baseUrlDirectories; | ||
| var diff = ''; | ||
| const urlParts = this.extractUrlParts(url); | ||
| const baseUrlParts = this.extractUrlParts(baseUrl); | ||
| let i; | ||
| let max; | ||
| let urlDirectories; | ||
| let baseUrlDirectories; | ||
| let diff = ''; | ||
| if (urlParts.hostPart !== baseUrlParts.hostPart) { | ||
@@ -58,5 +63,3 @@ return ''; | ||
| for (i = 0; i < max; i++) { | ||
| if (baseUrlParts.directories[i] !== urlParts.directories[i]) { | ||
| break; | ||
| } | ||
| if (baseUrlParts.directories[i] !== urlParts.directories[i]) { break; } | ||
| } | ||
@@ -69,14 +72,15 @@ baseUrlDirectories = baseUrlParts.directories.slice(i); | ||
| for (i = 0; i < urlDirectories.length - 1; i++) { | ||
| diff += "".concat(urlDirectories[i], "/"); | ||
| diff += `${urlDirectories[i]}/`; | ||
| } | ||
| return diff; | ||
| }; | ||
| } | ||
| /** | ||
| * Helper function, not part of API. | ||
| * This should be replaceable by newer Node / Browser APIs | ||
| * | ||
| * @param {string} url | ||
| * | ||
| * @param {string} url | ||
| * @param {string} baseUrl | ||
| */ | ||
| AbstractFileManager.prototype.extractUrlParts = function (url, baseUrl) { | ||
| extractUrlParts(url, baseUrl) { | ||
| // urlParts[1] = protocol://hostname/ OR / | ||
@@ -87,12 +91,16 @@ // urlParts[2] = / if path relative to host base | ||
| // urlParts[5] = parameters | ||
| var urlPartsRegex = /^((?:[a-z-]+:)?\/{2}(?:[^/?#]*\/)|([/\\]))?((?:[^/\\?#]*[/\\])*)([^/\\?#]*)([#?].*)?$/i; | ||
| var urlParts = url.match(urlPartsRegex); | ||
| var returner = {}; | ||
| var rawDirectories = []; | ||
| var directories = []; | ||
| var i; | ||
| var baseUrlParts; | ||
| const urlPartsRegex = /^((?:[a-z-]+:)?\/{2}(?:[^/?#]*\/)|([/\\]))?((?:[^/\\?#]*[/\\])*)([^/\\?#]*)([#?].*)?$/i; | ||
| const urlParts = url.match(urlPartsRegex); | ||
| const returner = {}; | ||
| let rawDirectories = []; | ||
| const directories = []; | ||
| let i; | ||
| let baseUrlParts; | ||
| if (!urlParts) { | ||
| throw new Error("Could not parse sheet href - '".concat(url, "'")); | ||
| throw new Error(`Could not parse sheet href - '${url}'`); | ||
| } | ||
| // Stylesheets in IE don't always return the full path | ||
@@ -102,3 +110,3 @@ if (baseUrl && (!urlParts[1] || urlParts[2])) { | ||
| if (!baseUrlParts) { | ||
| throw new Error("Could not parse page url - '".concat(baseUrl, "'")); | ||
| throw new Error(`Could not parse page url - '${baseUrl}'`); | ||
| } | ||
@@ -110,6 +118,9 @@ urlParts[1] = urlParts[1] || baseUrlParts[1] || ''; | ||
| } | ||
| if (urlParts[3]) { | ||
| rawDirectories = urlParts[3].replace(/\\/g, '/').split('/'); | ||
| // collapse '..' and skip '.' | ||
| for (i = 0; i < rawDirectories.length; i++) { | ||
| if (rawDirectories[i] === '..') { | ||
@@ -121,4 +132,6 @@ directories.pop(); | ||
| } | ||
| } | ||
| } | ||
| returner.hostPart = urlParts[1]; | ||
@@ -132,6 +145,5 @@ returner.directories = directories; | ||
| return returner; | ||
| }; | ||
| return AbstractFileManager; | ||
| }()); | ||
| exports.default = AbstractFileManager; | ||
| //# sourceMappingURL=abstract-file-manager.js.map | ||
| } | ||
| } | ||
| export default AbstractFileManager; |
@@ -1,16 +0,18 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var function_registry_1 = tslib_1.__importDefault(require("../functions/function-registry")); | ||
| var less_error_1 = tslib_1.__importDefault(require("../less-error")); | ||
| var AbstractPluginLoader = /** @class */ (function () { | ||
| function AbstractPluginLoader() { | ||
| import functionRegistry from '../functions/function-registry.js'; | ||
| import LessError from '../less-error.js'; | ||
| class AbstractPluginLoader { | ||
| constructor() { | ||
| // Implemented by Node.js plugin loader | ||
| this.require = function () { | ||
| this.require = function() { | ||
| return null; | ||
| }; | ||
| } | ||
| } | ||
| AbstractPluginLoader.prototype.evalPlugin = function (contents, context, imports, pluginOptions, fileInfo) { | ||
| var loader, registry, pluginObj, localModule, pluginManager, filename, result; | ||
| evalPlugin(contents, context, imports, pluginOptions, fileInfo) { | ||
| let loader, registry, pluginObj, localModule, pluginManager, filename, result; | ||
| pluginManager = context.pluginManager; | ||
| if (fileInfo) { | ||
@@ -24,5 +26,7 @@ if (typeof fileInfo === 'string') { | ||
| } | ||
| var shortname = (new this.less.FileManager()).extractUrlParts(filename).filename; | ||
| const shortname = (new this.less.FileManager()).extractUrlParts(filename).filename; | ||
| if (filename) { | ||
| pluginObj = pluginManager.get(filename); | ||
| if (pluginObj) { | ||
@@ -40,3 +44,3 @@ result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions); | ||
| e.message = e.message || 'Error during @plugin call'; | ||
| return new less_error_1.default(e, imports, filename); | ||
| return new LessError(e, imports, filename); | ||
| } | ||
@@ -48,9 +52,11 @@ return pluginObj; | ||
| exports: {}, | ||
| pluginManager: pluginManager, | ||
| fileInfo: fileInfo | ||
| pluginManager, | ||
| fileInfo | ||
| }; | ||
| registry = function_registry_1.default.create(); | ||
| var registerPlugin = function (obj) { | ||
| registry = functionRegistry.create(); | ||
| const registerPlugin = function(obj) { | ||
| pluginObj = obj; | ||
| }; | ||
| try { | ||
@@ -61,4 +67,5 @@ loader = new Function('module', 'require', 'registerPlugin', 'functions', 'tree', 'less', 'fileInfo', contents); | ||
| catch (e) { | ||
| return new less_error_1.default(e, imports, filename); | ||
| return new LessError(e, imports, filename); | ||
| } | ||
| if (!pluginObj) { | ||
@@ -68,11 +75,15 @@ pluginObj = localModule.exports; | ||
| pluginObj = this.validatePlugin(pluginObj, filename, shortname); | ||
| if (pluginObj instanceof less_error_1.default) { | ||
| if (pluginObj instanceof LessError) { | ||
| return pluginObj; | ||
| } | ||
| if (pluginObj) { | ||
| pluginObj.imports = imports; | ||
| pluginObj.filename = filename; | ||
| // For < 3.x (or unspecified minVersion) - setOptions() before install() | ||
| if (!pluginObj.minVersion || this.compareVersion('3.0.0', pluginObj.minVersion) < 0) { | ||
| result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions); | ||
| if (result) { | ||
@@ -82,5 +93,7 @@ return result; | ||
| } | ||
| // Run on first load | ||
| pluginManager.addPlugin(pluginObj, fileInfo.filename, registry); | ||
| pluginObj.functions = registry.getLocalFunctions(); | ||
| // Need to call setOptions again because the pluginObj might have functions | ||
@@ -91,2 +104,3 @@ result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions); | ||
| } | ||
| // Run every @plugin call | ||
@@ -100,14 +114,18 @@ try { | ||
| e.message = e.message || 'Error during @plugin call'; | ||
| return new less_error_1.default(e, imports, filename); | ||
| return new LessError(e, imports, filename); | ||
| } | ||
| } | ||
| else { | ||
| return new less_error_1.default({ message: 'Not a valid plugin' }, imports, filename); | ||
| return new LessError({ message: 'Not a valid plugin' }, imports, filename); | ||
| } | ||
| return pluginObj; | ||
| }; | ||
| AbstractPluginLoader.prototype.trySetOptions = function (plugin, filename, name, options) { | ||
| } | ||
| trySetOptions(plugin, filename, name, options) { | ||
| if (options && !plugin.setOptions) { | ||
| return new less_error_1.default({ | ||
| message: "Options have been provided but the plugin ".concat(name, " does not support any options.") | ||
| return new LessError({ | ||
| message: `Options have been provided but the plugin ${name} does not support any options.` | ||
| }); | ||
@@ -119,6 +137,7 @@ } | ||
| catch (e) { | ||
| return new less_error_1.default(e); | ||
| return new LessError(e); | ||
| } | ||
| }; | ||
| AbstractPluginLoader.prototype.validatePlugin = function (plugin, filename, name) { | ||
| } | ||
| validatePlugin(plugin, filename, name) { | ||
| if (plugin) { | ||
@@ -130,6 +149,7 @@ // support plugins being a function | ||
| } | ||
| if (plugin.minVersion) { | ||
| if (this.compareVersion(plugin.minVersion, this.less.version) < 0) { | ||
| return new less_error_1.default({ | ||
| message: "Plugin ".concat(name, " requires version ").concat(this.versionToString(plugin.minVersion)) | ||
| return new LessError({ | ||
| message: `Plugin ${name} requires version ${this.versionToString(plugin.minVersion)}` | ||
| }); | ||
@@ -141,4 +161,5 @@ } | ||
| return null; | ||
| }; | ||
| AbstractPluginLoader.prototype.compareVersion = function (aVersion, bVersion) { | ||
| } | ||
| compareVersion(aVersion, bVersion) { | ||
| if (typeof aVersion === 'string') { | ||
@@ -148,3 +169,3 @@ aVersion = aVersion.match(/^(\d+)\.?(\d+)?\.?(\d+)?/); | ||
| } | ||
| for (var i = 0; i < aVersion.length; i++) { | ||
| for (let i = 0; i < aVersion.length; i++) { | ||
| if (aVersion[i] !== bVersion[i]) { | ||
@@ -155,13 +176,15 @@ return parseInt(aVersion[i]) > parseInt(bVersion[i]) ? -1 : 1; | ||
| return 0; | ||
| }; | ||
| AbstractPluginLoader.prototype.versionToString = function (version) { | ||
| var versionString = ''; | ||
| for (var i = 0; i < version.length; i++) { | ||
| } | ||
| versionToString(version) { | ||
| let versionString = ''; | ||
| for (let i = 0; i < version.length; i++) { | ||
| versionString += (versionString ? '.' : '') + version[i]; | ||
| } | ||
| return versionString; | ||
| }; | ||
| AbstractPluginLoader.prototype.printUsage = function (plugins) { | ||
| for (var i = 0; i < plugins.length; i++) { | ||
| var plugin = plugins[i]; | ||
| } | ||
| printUsage(plugins) { | ||
| for (let i = 0; i < plugins.length; i++) { | ||
| const plugin = plugins[i]; | ||
| if (plugin.printUsage) { | ||
@@ -171,6 +194,6 @@ plugin.printUsage(); | ||
| } | ||
| }; | ||
| return AbstractPluginLoader; | ||
| }()); | ||
| exports.default = AbstractPluginLoader; | ||
| //# sourceMappingURL=abstract-plugin-loader.js.map | ||
| } | ||
| } | ||
| export default AbstractPluginLoader; | ||
@@ -1,2 +0,1 @@ | ||
| "use strict"; | ||
| /** | ||
@@ -6,36 +5,40 @@ * @todo Document why this abstraction exists, and the relationship between | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var logger_1 = tslib_1.__importDefault(require("../logger")); | ||
| var Environment = /** @class */ (function () { | ||
| function Environment(externalEnvironment, fileManagers) { | ||
| import logger from '../logger.js'; | ||
| class Environment { | ||
| constructor(externalEnvironment, fileManagers) { | ||
| this.fileManagers = fileManagers || []; | ||
| externalEnvironment = externalEnvironment || {}; | ||
| var optionalFunctions = ['encodeBase64', 'mimeLookup', 'charsetLookup', 'getSourceMapGenerator']; | ||
| var requiredFunctions = []; | ||
| var functions = requiredFunctions.concat(optionalFunctions); | ||
| for (var i = 0; i < functions.length; i++) { | ||
| var propName = functions[i]; | ||
| var environmentFunc = externalEnvironment[propName]; | ||
| const optionalFunctions = ['encodeBase64', 'mimeLookup', 'charsetLookup', 'getSourceMapGenerator']; | ||
| const requiredFunctions = []; | ||
| const functions = requiredFunctions.concat(optionalFunctions); | ||
| for (let i = 0; i < functions.length; i++) { | ||
| const propName = functions[i]; | ||
| const environmentFunc = externalEnvironment[propName]; | ||
| if (environmentFunc) { | ||
| this[propName] = environmentFunc.bind(externalEnvironment); | ||
| } else if (i < requiredFunctions.length) { | ||
| this.warn(`missing required function in environment - ${propName}`); | ||
| } | ||
| else if (i < requiredFunctions.length) { | ||
| this.warn("missing required function in environment - ".concat(propName)); | ||
| } | ||
| } | ||
| } | ||
| Environment.prototype.getFileManager = function (filename, currentDirectory, options, environment, isSync) { | ||
| getFileManager(filename, currentDirectory, options, environment, isSync) { | ||
| if (!filename) { | ||
| logger_1.default.warn('getFileManager called with no filename.. Please report this issue. continuing.'); | ||
| logger.warn('getFileManager called with no filename.. Please report this issue. continuing.'); | ||
| } | ||
| if (currentDirectory === undefined) { | ||
| logger_1.default.warn('getFileManager called with null directory.. Please report this issue. continuing.'); | ||
| logger.warn('getFileManager called with null directory.. Please report this issue. continuing.'); | ||
| } | ||
| var fileManagers = this.fileManagers; | ||
| let fileManagers = this.fileManagers; | ||
| if (options.pluginManager) { | ||
| fileManagers = [].concat(fileManagers).concat(options.pluginManager.getFileManagers()); | ||
| } | ||
| for (var i = fileManagers.length - 1; i >= 0; i--) { | ||
| var fileManager = fileManagers[i]; | ||
| for (let i = fileManagers.length - 1; i >= 0 ; i--) { | ||
| const fileManager = fileManagers[i]; | ||
| if (fileManager[isSync ? 'supportsSync' : 'supports'](filename, currentDirectory, options, environment)) { | ||
@@ -46,12 +49,13 @@ return fileManager; | ||
| return null; | ||
| }; | ||
| Environment.prototype.addFileManager = function (fileManager) { | ||
| } | ||
| addFileManager(fileManager) { | ||
| this.fileManagers.push(fileManager); | ||
| }; | ||
| Environment.prototype.clearFileManagers = function () { | ||
| } | ||
| clearFileManagers() { | ||
| this.fileManagers = []; | ||
| }; | ||
| return Environment; | ||
| }()); | ||
| exports.default = Environment; | ||
| //# sourceMappingURL=environment.js.map | ||
| } | ||
| } | ||
| export default Environment; |
@@ -1,9 +0,8 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var anonymous_1 = tslib_1.__importDefault(require("../tree/anonymous")); | ||
| var keyword_1 = tslib_1.__importDefault(require("../tree/keyword")); | ||
| import Anonymous from '../tree/anonymous.js'; | ||
| import Keyword from '../tree/keyword.js'; | ||
| function boolean(condition) { | ||
| return condition ? keyword_1.default.True : keyword_1.default.False; | ||
| return condition ? Keyword.True : Keyword.False; | ||
| } | ||
| /** | ||
@@ -15,16 +14,17 @@ * Functions with evalArgs set to false are sent context | ||
| return condition.eval(context) ? trueValue.eval(context) | ||
| : (falseValue ? falseValue.eval(context) : new anonymous_1.default); | ||
| : (falseValue ? falseValue.eval(context) : new Anonymous); | ||
| } | ||
| If.evalArgs = false; | ||
| function isdefined(context, variable) { | ||
| try { | ||
| variable.eval(context); | ||
| return keyword_1.default.True; | ||
| return Keyword.True; | ||
| } catch (e) { | ||
| return Keyword.False; | ||
| } | ||
| catch (e) { | ||
| return keyword_1.default.False; | ||
| } | ||
| } | ||
| isdefined.evalArgs = false; | ||
| exports.default = { isdefined: isdefined, boolean: boolean, 'if': If }; | ||
| //# sourceMappingURL=boolean.js.map | ||
| export default { isdefined, boolean, 'if': If }; |
@@ -1,19 +0,23 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var color_1 = tslib_1.__importDefault(require("../tree/color")); | ||
| import Color from '../tree/color.js'; | ||
| // Color Blending | ||
| // ref: http://www.w3.org/TR/compositing-1 | ||
| function colorBlend(mode, color1, color2) { | ||
| var ab = color1.alpha; // result | ||
| var // backdrop | ||
| cb; | ||
| var as = color2.alpha; | ||
| var // source | ||
| cs; | ||
| var ar; | ||
| var cr; | ||
| var r = []; | ||
| const ab = color1.alpha; // result | ||
| let // backdrop | ||
| cb; | ||
| const as = color2.alpha; | ||
| let // source | ||
| cs; | ||
| let ar; | ||
| let cr; | ||
| const r = []; | ||
| ar = as + ab * (1 - as); | ||
| for (var i = 0; i < 3; i++) { | ||
| for (let i = 0; i < 3; i++) { | ||
| cb = color1.rgb[i] / 255; | ||
@@ -24,16 +28,18 @@ cs = color2.rgb[i] / 255; | ||
| cr = (as * cs + ab * (cb - | ||
| as * (cb + cs - cr))) / ar; | ||
| as * (cb + cs - cr))) / ar; | ||
| } | ||
| r[i] = cr * 255; | ||
| } | ||
| return new color_1.default(r, ar); | ||
| return new Color(r, ar); | ||
| } | ||
| var colorBlendModeFunctions = { | ||
| multiply: function (cb, cs) { | ||
| const colorBlendModeFunctions = { | ||
| multiply: function(cb, cs) { | ||
| return cb * cs; | ||
| }, | ||
| screen: function (cb, cs) { | ||
| screen: function(cb, cs) { | ||
| return cb + cs - cb * cs; | ||
| }, | ||
| overlay: function (cb, cs) { | ||
| overlay: function(cb, cs) { | ||
| cb *= 2; | ||
@@ -44,5 +50,5 @@ return (cb <= 1) ? | ||
| }, | ||
| softlight: function (cb, cs) { | ||
| var d = 1; | ||
| var e = cb; | ||
| softlight: function(cb, cs) { | ||
| let d = 1; | ||
| let e = cb; | ||
| if (cs > 0.5) { | ||
@@ -55,20 +61,22 @@ e = 1; | ||
| }, | ||
| hardlight: function (cb, cs) { | ||
| hardlight: function(cb, cs) { | ||
| return colorBlendModeFunctions.overlay(cs, cb); | ||
| }, | ||
| difference: function (cb, cs) { | ||
| difference: function(cb, cs) { | ||
| return Math.abs(cb - cs); | ||
| }, | ||
| exclusion: function (cb, cs) { | ||
| exclusion: function(cb, cs) { | ||
| return cb + cs - 2 * cb * cs; | ||
| }, | ||
| // non-w3c functions: | ||
| average: function (cb, cs) { | ||
| average: function(cb, cs) { | ||
| return (cb + cs) / 2; | ||
| }, | ||
| negation: function (cb, cs) { | ||
| negation: function(cb, cs) { | ||
| return 1 - Math.abs(cb + cs - 1); | ||
| } | ||
| }; | ||
| for (var f in colorBlendModeFunctions) { | ||
| for (const f in colorBlendModeFunctions) { | ||
| // eslint-disable-next-line no-prototype-builtins | ||
@@ -79,3 +87,3 @@ if (colorBlendModeFunctions.hasOwnProperty(f)) { | ||
| } | ||
| exports.default = colorBlend; | ||
| //# sourceMappingURL=color-blending.js.map | ||
| export default colorBlend; |
+152
-136
@@ -1,11 +0,9 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var dimension_1 = tslib_1.__importDefault(require("../tree/dimension")); | ||
| var color_1 = tslib_1.__importDefault(require("../tree/color")); | ||
| var quoted_1 = tslib_1.__importDefault(require("../tree/quoted")); | ||
| var anonymous_1 = tslib_1.__importDefault(require("../tree/anonymous")); | ||
| var expression_1 = tslib_1.__importDefault(require("../tree/expression")); | ||
| var operation_1 = tslib_1.__importDefault(require("../tree/operation")); | ||
| var colorFunctions; | ||
| import Dimension from '../tree/dimension.js'; | ||
| import Color from '../tree/color.js'; | ||
| import Quoted from '../tree/quoted.js'; | ||
| import Anonymous from '../tree/anonymous.js'; | ||
| import Expression from '../tree/expression.js'; | ||
| import Operation from '../tree/operation.js'; | ||
| let colorFunctions; | ||
| function clamp(val) { | ||
@@ -15,9 +13,8 @@ return Math.min(1, Math.max(0, val)); | ||
| function hsla(origColor, hsl) { | ||
| var color = colorFunctions.hsla(hsl.h, hsl.s, hsl.l, hsl.a); | ||
| const color = colorFunctions.hsla(hsl.h, hsl.s, hsl.l, hsl.a); | ||
| if (color) { | ||
| if (origColor.value && | ||
| if (origColor.value && | ||
| /^(rgb|hsl)/.test(origColor.value)) { | ||
| color.value = origColor.value; | ||
| } | ||
| else { | ||
| } else { | ||
| color.value = 'rgb'; | ||
@@ -31,23 +28,21 @@ } | ||
| return color.toHSL(); | ||
| } | ||
| else { | ||
| } else { | ||
| throw new Error('Argument cannot be evaluated to a color'); | ||
| } | ||
| } | ||
| function toHSV(color) { | ||
| if (color.toHSV) { | ||
| return color.toHSV(); | ||
| } | ||
| else { | ||
| } else { | ||
| throw new Error('Argument cannot be evaluated to a color'); | ||
| } | ||
| } | ||
| function number(n) { | ||
| if (n instanceof dimension_1.default) { | ||
| if (n instanceof Dimension) { | ||
| return parseFloat(n.unit.is('%') ? n.value / 100 : n.value); | ||
| } | ||
| else if (typeof n === 'number') { | ||
| } else if (typeof n === 'number') { | ||
| return n; | ||
| } | ||
| else { | ||
| } else { | ||
| throw { | ||
@@ -60,6 +55,5 @@ type: 'Argument', | ||
| function scaled(n, size) { | ||
| if (n instanceof dimension_1.default && n.unit.is('%')) { | ||
| if (n instanceof Dimension && n.unit.is('%')) { | ||
| return parseFloat(n.value * size / 100); | ||
| } | ||
| else { | ||
| } else { | ||
| return number(n); | ||
@@ -70,3 +64,3 @@ } | ||
| rgb: function (r, g, b) { | ||
| var a = 1; | ||
| let a = 1 | ||
| /** | ||
@@ -76,18 +70,18 @@ * Comma-less syntax | ||
| */ | ||
| if (r instanceof expression_1.default) { | ||
| var val = r.value; | ||
| r = val[0]; | ||
| g = val[1]; | ||
| b = val[2]; | ||
| /** | ||
| if (r instanceof Expression) { | ||
| const val = r.value | ||
| r = val[0] | ||
| g = val[1] | ||
| b = val[2] | ||
| /** | ||
| * @todo - should this be normalized in | ||
| * function caller? Or parsed differently? | ||
| */ | ||
| if (b instanceof operation_1.default) { | ||
| var op = b; | ||
| b = op.operands[0]; | ||
| a = op.operands[1]; | ||
| if (b instanceof Operation) { | ||
| const op = b | ||
| b = op.operands[0] | ||
| a = op.operands[1] | ||
| } | ||
| } | ||
| var color = colorFunctions.rgba(r, g, b, a); | ||
| const color = colorFunctions.rgba(r, g, b, a); | ||
| if (color) { | ||
@@ -100,31 +94,31 @@ color.value = 'rgb'; | ||
| try { | ||
| if (r instanceof color_1.default) { | ||
| if (r instanceof Color) { | ||
| if (g) { | ||
| a = number(g); | ||
| } | ||
| else { | ||
| } else { | ||
| a = r.alpha; | ||
| } | ||
| return new color_1.default(r.rgb, a, 'rgba'); | ||
| return new Color(r.rgb, a, 'rgba'); | ||
| } | ||
| var rgb = [r, g, b].map(function (c) { return scaled(c, 255); }); | ||
| const rgb = [r, g, b].map(c => scaled(c, 255)); | ||
| a = number(a); | ||
| return new color_1.default(rgb, a, 'rgba'); | ||
| return new Color(rgb, a, 'rgba'); | ||
| } | ||
| catch (e) { } | ||
| catch (e) {} | ||
| }, | ||
| hsl: function (h, s, l) { | ||
| var a = 1; | ||
| if (h instanceof expression_1.default) { | ||
| var val = h.value; | ||
| h = val[0]; | ||
| s = val[1]; | ||
| l = val[2]; | ||
| if (l instanceof operation_1.default) { | ||
| var op = l; | ||
| l = op.operands[0]; | ||
| a = op.operands[1]; | ||
| let a = 1 | ||
| if (h instanceof Expression) { | ||
| const val = h.value | ||
| h = val[0] | ||
| s = val[1] | ||
| l = val[2] | ||
| if (l instanceof Operation) { | ||
| const op = l | ||
| l = op.operands[0] | ||
| a = op.operands[1] | ||
| } | ||
| } | ||
| var color = colorFunctions.hsla(h, s, l, a); | ||
| const color = colorFunctions.hsla(h, s, l, a); | ||
| if (color) { | ||
@@ -136,4 +130,5 @@ color.value = 'hsl'; | ||
| hsla: function (h, s, l, a) { | ||
| var m1; | ||
| var m2; | ||
| let m1; | ||
| let m2; | ||
| function hue(h) { | ||
@@ -154,45 +149,48 @@ h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h); | ||
| } | ||
| try { | ||
| if (h instanceof color_1.default) { | ||
| if (h instanceof Color) { | ||
| if (s) { | ||
| a = number(s); | ||
| } | ||
| else { | ||
| } else { | ||
| a = h.alpha; | ||
| } | ||
| return new color_1.default(h.rgb, a, 'hsla'); | ||
| return new Color(h.rgb, a, 'hsla'); | ||
| } | ||
| h = (number(h) % 360) / 360; | ||
| s = clamp(number(s)); | ||
| l = clamp(number(l)); | ||
| a = clamp(number(a)); | ||
| s = clamp(number(s));l = clamp(number(l));a = clamp(number(a)); | ||
| m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s; | ||
| m1 = l * 2 - m2; | ||
| var rgb = [ | ||
| const rgb = [ | ||
| hue(h + 1 / 3) * 255, | ||
| hue(h) * 255, | ||
| hue(h) * 255, | ||
| hue(h - 1 / 3) * 255 | ||
| ]; | ||
| a = number(a); | ||
| return new color_1.default(rgb, a, 'hsla'); | ||
| return new Color(rgb, a, 'hsla'); | ||
| } | ||
| catch (e) { } | ||
| catch (e) {} | ||
| }, | ||
| hsv: function (h, s, v) { | ||
| hsv: function(h, s, v) { | ||
| return colorFunctions.hsva(h, s, v, 1.0); | ||
| }, | ||
| hsva: function (h, s, v, a) { | ||
| hsva: function(h, s, v, a) { | ||
| h = ((number(h) % 360) / 360) * 360; | ||
| s = number(s); | ||
| v = number(v); | ||
| a = number(a); | ||
| var i; | ||
| var f; | ||
| s = number(s);v = number(v);a = number(a); | ||
| let i; | ||
| let f; | ||
| i = Math.floor((h / 60) % 6); | ||
| f = (h / 60) - i; | ||
| var vs = [v, | ||
| const vs = [v, | ||
| v * (1 - s), | ||
| v * (1 - f * s), | ||
| v * (1 - (1 - f) * s)]; | ||
| var perm = [[0, 3, 1], | ||
| const perm = [[0, 3, 1], | ||
| [2, 0, 1], | ||
@@ -203,42 +201,49 @@ [1, 0, 3], | ||
| [0, 1, 2]]; | ||
| return colorFunctions.rgba(vs[perm[i][0]] * 255, vs[perm[i][1]] * 255, vs[perm[i][2]] * 255, a); | ||
| return colorFunctions.rgba(vs[perm[i][0]] * 255, | ||
| vs[perm[i][1]] * 255, | ||
| vs[perm[i][2]] * 255, | ||
| a); | ||
| }, | ||
| hue: function (color) { | ||
| return new dimension_1.default(toHSL(color).h); | ||
| return new Dimension(toHSL(color).h); | ||
| }, | ||
| saturation: function (color) { | ||
| return new dimension_1.default(toHSL(color).s * 100, '%'); | ||
| return new Dimension(toHSL(color).s * 100, '%'); | ||
| }, | ||
| lightness: function (color) { | ||
| return new dimension_1.default(toHSL(color).l * 100, '%'); | ||
| return new Dimension(toHSL(color).l * 100, '%'); | ||
| }, | ||
| hsvhue: function (color) { | ||
| return new dimension_1.default(toHSV(color).h); | ||
| hsvhue: function(color) { | ||
| return new Dimension(toHSV(color).h); | ||
| }, | ||
| hsvsaturation: function (color) { | ||
| return new dimension_1.default(toHSV(color).s * 100, '%'); | ||
| return new Dimension(toHSV(color).s * 100, '%'); | ||
| }, | ||
| hsvvalue: function (color) { | ||
| return new dimension_1.default(toHSV(color).v * 100, '%'); | ||
| return new Dimension(toHSV(color).v * 100, '%'); | ||
| }, | ||
| red: function (color) { | ||
| return new dimension_1.default(color.rgb[0]); | ||
| return new Dimension(color.rgb[0]); | ||
| }, | ||
| green: function (color) { | ||
| return new dimension_1.default(color.rgb[1]); | ||
| return new Dimension(color.rgb[1]); | ||
| }, | ||
| blue: function (color) { | ||
| return new dimension_1.default(color.rgb[2]); | ||
| return new Dimension(color.rgb[2]); | ||
| }, | ||
| alpha: function (color) { | ||
| return new dimension_1.default(toHSL(color).a); | ||
| return new Dimension(toHSL(color).a); | ||
| }, | ||
| luma: function (color) { | ||
| return new dimension_1.default(color.luma() * color.alpha * 100, '%'); | ||
| return new Dimension(color.luma() * color.alpha * 100, '%'); | ||
| }, | ||
| luminance: function (color) { | ||
| var luminance = (0.2126 * color.rgb[0] / 255) + | ||
| (0.7152 * color.rgb[1] / 255) + | ||
| (0.0722 * color.rgb[2] / 255); | ||
| return new dimension_1.default(luminance * color.alpha * 100, '%'); | ||
| const luminance = | ||
| (0.2126 * color.rgb[0] / 255) + | ||
| (0.7152 * color.rgb[1] / 255) + | ||
| (0.0722 * color.rgb[2] / 255); | ||
| return new Dimension(luminance * color.alpha * 100, '%'); | ||
| }, | ||
@@ -251,5 +256,6 @@ saturate: function (color, amount, method) { | ||
| } | ||
| var hsl = toHSL(color); | ||
| const hsl = toHSL(color); | ||
| if (typeof method !== 'undefined' && method.value === 'relative') { | ||
| hsl.s += hsl.s * amount.value / 100; | ||
| hsl.s += hsl.s * amount.value / 100; | ||
| } | ||
@@ -263,5 +269,6 @@ else { | ||
| desaturate: function (color, amount, method) { | ||
| var hsl = toHSL(color); | ||
| const hsl = toHSL(color); | ||
| if (typeof method !== 'undefined' && method.value === 'relative') { | ||
| hsl.s -= hsl.s * amount.value / 100; | ||
| hsl.s -= hsl.s * amount.value / 100; | ||
| } | ||
@@ -275,5 +282,6 @@ else { | ||
| lighten: function (color, amount, method) { | ||
| var hsl = toHSL(color); | ||
| const hsl = toHSL(color); | ||
| if (typeof method !== 'undefined' && method.value === 'relative') { | ||
| hsl.l += hsl.l * amount.value / 100; | ||
| hsl.l += hsl.l * amount.value / 100; | ||
| } | ||
@@ -287,5 +295,6 @@ else { | ||
| darken: function (color, amount, method) { | ||
| var hsl = toHSL(color); | ||
| const hsl = toHSL(color); | ||
| if (typeof method !== 'undefined' && method.value === 'relative') { | ||
| hsl.l -= hsl.l * amount.value / 100; | ||
| hsl.l -= hsl.l * amount.value / 100; | ||
| } | ||
@@ -299,5 +308,6 @@ else { | ||
| fadein: function (color, amount, method) { | ||
| var hsl = toHSL(color); | ||
| const hsl = toHSL(color); | ||
| if (typeof method !== 'undefined' && method.value === 'relative') { | ||
| hsl.a += hsl.a * amount.value / 100; | ||
| hsl.a += hsl.a * amount.value / 100; | ||
| } | ||
@@ -311,5 +321,6 @@ else { | ||
| fadeout: function (color, amount, method) { | ||
| var hsl = toHSL(color); | ||
| const hsl = toHSL(color); | ||
| if (typeof method !== 'undefined' && method.value === 'relative') { | ||
| hsl.a -= hsl.a * amount.value / 100; | ||
| hsl.a -= hsl.a * amount.value / 100; | ||
| } | ||
@@ -323,3 +334,4 @@ else { | ||
| fade: function (color, amount) { | ||
| var hsl = toHSL(color); | ||
| const hsl = toHSL(color); | ||
| hsl.a = amount.value / 100; | ||
@@ -330,5 +342,7 @@ hsl.a = clamp(hsl.a); | ||
| spin: function (color, amount) { | ||
| var hsl = toHSL(color); | ||
| var hue = (hsl.h + amount.value) % 360; | ||
| const hsl = toHSL(color); | ||
| const hue = (hsl.h + amount.value) % 360; | ||
| hsl.h = hue < 0 ? 360 + hue : hue; | ||
| return hsla(color, hsl); | ||
@@ -342,17 +356,21 @@ }, | ||
| if (!weight) { | ||
| weight = new dimension_1.default(50); | ||
| weight = new Dimension(50); | ||
| } | ||
| var p = weight.value / 100.0; | ||
| var w = p * 2 - 1; | ||
| var a = toHSL(color1).a - toHSL(color2).a; | ||
| var w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0; | ||
| var w2 = 1 - w1; | ||
| var rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2, | ||
| const p = weight.value / 100.0; | ||
| const w = p * 2 - 1; | ||
| const a = toHSL(color1).a - toHSL(color2).a; | ||
| const w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0; | ||
| const w2 = 1 - w1; | ||
| const rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2, | ||
| color1.rgb[1] * w1 + color2.rgb[1] * w2, | ||
| color1.rgb[2] * w1 + color2.rgb[2] * w2]; | ||
| var alpha = color1.alpha * p + color2.alpha * (1 - p); | ||
| return new color_1.default(rgb, alpha); | ||
| const alpha = color1.alpha * p + color2.alpha * (1 - p); | ||
| return new Color(rgb, alpha); | ||
| }, | ||
| greyscale: function (color) { | ||
| return colorFunctions.desaturate(color, new dimension_1.default(100)); | ||
| return colorFunctions.desaturate(color, new Dimension(100)); | ||
| }, | ||
@@ -373,3 +391,3 @@ contrast: function (color, dark, light, threshold) { | ||
| if (dark.luma() > light.luma()) { | ||
| var t = light; | ||
| const t = light; | ||
| light = dark; | ||
@@ -380,4 +398,3 @@ dark = t; | ||
| threshold = 0.43; | ||
| } | ||
| else { | ||
| } else { | ||
| threshold = number(threshold); | ||
@@ -387,4 +404,3 @@ } | ||
| return light; | ||
| } | ||
| else { | ||
| } else { | ||
| return dark; | ||
@@ -432,11 +448,11 @@ } | ||
| argb: function (color) { | ||
| return new anonymous_1.default(color.toARGB()); | ||
| return new Anonymous(color.toARGB()); | ||
| }, | ||
| color: function (c) { | ||
| if ((c instanceof quoted_1.default) && | ||
| color: function(c) { | ||
| if ((c instanceof Quoted) && | ||
| (/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})$/i.test(c.value))) { | ||
| var val = c.value.slice(1); | ||
| return new color_1.default(val, undefined, "#".concat(val)); | ||
| const val = c.value.slice(1); | ||
| return new Color(val, undefined, `#${val}`); | ||
| } | ||
| if ((c instanceof color_1.default) || (c = color_1.default.fromKeyword(c.value))) { | ||
| if ((c instanceof Color) || (c = Color.fromKeyword(c.value))) { | ||
| c.value = undefined; | ||
@@ -446,14 +462,14 @@ return c; | ||
| throw { | ||
| type: 'Argument', | ||
| type: 'Argument', | ||
| message: 'argument must be a color keyword or 3|4|6|8 digit hex e.g. #FFF' | ||
| }; | ||
| }, | ||
| tint: function (color, amount) { | ||
| tint: function(color, amount) { | ||
| return colorFunctions.mix(colorFunctions.rgb(255, 255, 255), color, amount); | ||
| }, | ||
| shade: function (color, amount) { | ||
| shade: function(color, amount) { | ||
| return colorFunctions.mix(colorFunctions.rgb(0, 0, 0), color, amount); | ||
| } | ||
| }; | ||
| exports.default = colorFunctions; | ||
| //# sourceMappingURL=color.js.map | ||
| export default colorFunctions; |
@@ -1,65 +0,74 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var quoted_1 = tslib_1.__importDefault(require("../tree/quoted")); | ||
| var url_1 = tslib_1.__importDefault(require("../tree/url")); | ||
| var utils = tslib_1.__importStar(require("../utils")); | ||
| var logger_1 = tslib_1.__importDefault(require("../logger")); | ||
| exports.default = (function (environment) { | ||
| var fallback = function (functionThis, node) { return new url_1.default(node, functionThis.index, functionThis.currentFileInfo).eval(functionThis.context); }; | ||
| return { 'data-uri': function (mimetypeNode, filePathNode) { | ||
| if (!filePathNode) { | ||
| filePathNode = mimetypeNode; | ||
| mimetypeNode = null; | ||
| import Quoted from '../tree/quoted.js'; | ||
| import URL from '../tree/url.js'; | ||
| import * as utils from '../utils.js'; | ||
| import logger from '../logger.js'; | ||
| export default environment => { | ||
| const fallback = (functionThis, node) => new URL(node, functionThis.index, functionThis.currentFileInfo).eval(functionThis.context); | ||
| return { 'data-uri': function(mimetypeNode, filePathNode) { | ||
| if (!filePathNode) { | ||
| filePathNode = mimetypeNode; | ||
| mimetypeNode = null; | ||
| } | ||
| let mimetype = mimetypeNode && mimetypeNode.value; | ||
| let filePath = filePathNode.value; | ||
| const currentFileInfo = this.currentFileInfo; | ||
| const currentDirectory = currentFileInfo.rewriteUrls ? | ||
| currentFileInfo.currentDirectory : currentFileInfo.entryPath; | ||
| const fragmentStart = filePath.indexOf('#'); | ||
| let fragment = ''; | ||
| if (fragmentStart !== -1) { | ||
| fragment = filePath.slice(fragmentStart); | ||
| filePath = filePath.slice(0, fragmentStart); | ||
| } | ||
| const context = utils.clone(this.context); | ||
| context.rawBuffer = true; | ||
| const fileManager = environment.getFileManager(filePath, currentDirectory, context, environment, true); | ||
| if (!fileManager) { | ||
| return fallback(this, filePathNode); | ||
| } | ||
| let useBase64 = false; | ||
| // detect the mimetype if not given | ||
| if (!mimetypeNode) { | ||
| mimetype = environment.mimeLookup(filePath); | ||
| if (mimetype === 'image/svg+xml') { | ||
| useBase64 = false; | ||
| } else { | ||
| // use base 64 unless it's an ASCII or UTF-8 format | ||
| const charset = environment.charsetLookup(mimetype); | ||
| useBase64 = ['US-ASCII', 'UTF-8'].indexOf(charset) < 0; | ||
| } | ||
| var mimetype = mimetypeNode && mimetypeNode.value; | ||
| var filePath = filePathNode.value; | ||
| var currentFileInfo = this.currentFileInfo; | ||
| var currentDirectory = currentFileInfo.rewriteUrls ? | ||
| currentFileInfo.currentDirectory : currentFileInfo.entryPath; | ||
| var fragmentStart = filePath.indexOf('#'); | ||
| var fragment = ''; | ||
| if (fragmentStart !== -1) { | ||
| fragment = filePath.slice(fragmentStart); | ||
| filePath = filePath.slice(0, fragmentStart); | ||
| } | ||
| var context = utils.clone(this.context); | ||
| context.rawBuffer = true; | ||
| var fileManager = environment.getFileManager(filePath, currentDirectory, context, environment, true); | ||
| if (!fileManager) { | ||
| return fallback(this, filePathNode); | ||
| } | ||
| var useBase64 = false; | ||
| // detect the mimetype if not given | ||
| if (!mimetypeNode) { | ||
| mimetype = environment.mimeLookup(filePath); | ||
| if (mimetype === 'image/svg+xml') { | ||
| useBase64 = false; | ||
| } | ||
| else { | ||
| // use base 64 unless it's an ASCII or UTF-8 format | ||
| var charset = environment.charsetLookup(mimetype); | ||
| useBase64 = ['US-ASCII', 'UTF-8'].indexOf(charset) < 0; | ||
| } | ||
| if (useBase64) { | ||
| mimetype += ';base64'; | ||
| } | ||
| } | ||
| else { | ||
| useBase64 = /;base64$/.test(mimetype); | ||
| } | ||
| var fileSync = fileManager.loadFileSync(filePath, currentDirectory, context, environment); | ||
| if (!fileSync.contents) { | ||
| logger_1.default.warn("Skipped data-uri embedding of ".concat(filePath, " because file not found")); | ||
| return fallback(this, filePathNode || mimetypeNode); | ||
| } | ||
| var buf = fileSync.contents; | ||
| if (useBase64 && !environment.encodeBase64) { | ||
| return fallback(this, filePathNode); | ||
| } | ||
| buf = useBase64 ? environment.encodeBase64(buf) : encodeURIComponent(buf); | ||
| var uri = "data:".concat(mimetype, ",").concat(buf).concat(fragment); | ||
| return new url_1.default(new quoted_1.default("\"".concat(uri, "\""), uri, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo); | ||
| } }; | ||
| }); | ||
| //# sourceMappingURL=data-uri.js.map | ||
| if (useBase64) { mimetype += ';base64'; } | ||
| } | ||
| else { | ||
| useBase64 = /;base64$/.test(mimetype); | ||
| } | ||
| const fileSync = fileManager.loadFileSync(filePath, currentDirectory, context, environment); | ||
| if (!fileSync.contents) { | ||
| logger.warn(`Skipped data-uri embedding of ${filePath} because file not found`); | ||
| return fallback(this, filePathNode || mimetypeNode); | ||
| } | ||
| let buf = fileSync.contents; | ||
| if (useBase64 && !environment.encodeBase64) { | ||
| return fallback(this, filePathNode); | ||
| } | ||
| buf = useBase64 ? environment.encodeBase64(buf) : encodeURIComponent(buf); | ||
| const uri = `data:${mimetype},${buf}${fragment}`; | ||
| return new URL(new Quoted(`"${uri}"`, uri, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo); | ||
| }}; | ||
| }; |
@@ -1,10 +0,8 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var keyword_1 = tslib_1.__importDefault(require("../tree/keyword")); | ||
| var utils = tslib_1.__importStar(require("../utils")); | ||
| var defaultFunc = { | ||
| import Keyword from '../tree/keyword.js'; | ||
| import * as utils from '../utils.js'; | ||
| const defaultFunc = { | ||
| eval: function () { | ||
| var v = this.value_; | ||
| var e = this.error_; | ||
| const v = this.value_; | ||
| const e = this.error_; | ||
| if (e) { | ||
@@ -14,3 +12,3 @@ throw e; | ||
| if (!utils.isNullOrUndefined(v)) { | ||
| return v ? keyword_1.default.True : keyword_1.default.False; | ||
| return v ? Keyword.True : Keyword.False; | ||
| } | ||
@@ -28,3 +26,3 @@ }, | ||
| }; | ||
| exports.default = defaultFunc; | ||
| //# sourceMappingURL=default.js.map | ||
| export default defaultFunc; |
@@ -1,7 +0,5 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var expression_1 = tslib_1.__importDefault(require("../tree/expression")); | ||
| var functionCaller = /** @class */ (function () { | ||
| function functionCaller(name, context, index, currentFileInfo) { | ||
| import Expression from '../tree/expression.js'; | ||
| class functionCaller { | ||
| constructor(name, context, index, currentFileInfo) { | ||
| this.name = name.toLowerCase(); | ||
@@ -11,17 +9,20 @@ this.index = index; | ||
| this.currentFileInfo = currentFileInfo; | ||
| this.func = context.frames[0].functionRegistry.get(this.name); | ||
| } | ||
| functionCaller.prototype.isValid = function () { | ||
| isValid() { | ||
| return Boolean(this.func); | ||
| }; | ||
| functionCaller.prototype.call = function (args) { | ||
| var _this = this; | ||
| } | ||
| call(args) { | ||
| if (!(Array.isArray(args))) { | ||
| args = [args]; | ||
| } | ||
| var evalArgs = this.func.evalArgs; | ||
| const evalArgs = this.func.evalArgs; | ||
| if (evalArgs !== false) { | ||
| args = args.map(function (a) { return a.eval(_this.context); }); | ||
| args = args.map(a => a.eval(this.context)); | ||
| } | ||
| var commentFilter = function (item) { return !(item.type === 'Comment'); }; | ||
| const commentFilter = item => !(item.type === 'Comment'); | ||
| // This code is terrible and should be replaced as per this issue... | ||
@@ -31,26 +32,26 @@ // https://github.com/less/less.js/issues/2477 | ||
| .filter(commentFilter) | ||
| .map(function (item) { | ||
| if (item.type === 'Expression') { | ||
| var subNodes = item.value.filter(commentFilter); | ||
| if (subNodes.length === 1) { | ||
| // https://github.com/less/less.js/issues/3616 | ||
| if (item.parens && subNodes[0].op === '/') { | ||
| return item; | ||
| .map(item => { | ||
| if (item.type === 'Expression') { | ||
| const subNodes = item.value.filter(commentFilter); | ||
| if (subNodes.length === 1) { | ||
| // https://github.com/less/less.js/issues/3616 | ||
| if (item.parens && subNodes[0].op === '/') { | ||
| return item; | ||
| } | ||
| return subNodes[0]; | ||
| } else { | ||
| return new Expression(subNodes); | ||
| } | ||
| return subNodes[0]; | ||
| } | ||
| else { | ||
| return new expression_1.default(subNodes); | ||
| } | ||
| } | ||
| return item; | ||
| }); | ||
| return item; | ||
| }); | ||
| if (evalArgs === false) { | ||
| return this.func.apply(this, tslib_1.__spreadArray([this.context], args, false)); | ||
| return this.func(this.context, ...args); | ||
| } | ||
| return this.func.apply(this, args); | ||
| }; | ||
| return functionCaller; | ||
| }()); | ||
| exports.default = functionCaller; | ||
| //# sourceMappingURL=function-caller.js.map | ||
| return this.func(...args); | ||
| } | ||
| } | ||
| export default functionCaller; |
@@ -1,10 +0,9 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| function makeRegistry(base) { | ||
| function makeRegistry( base ) { | ||
| return { | ||
| _data: {}, | ||
| add: function (name, func) { | ||
| add: function(name, func) { | ||
| // precautionary case conversion, as later querying of | ||
| // the registry by function-caller uses lower case as well. | ||
| name = name.toLowerCase(); | ||
| // eslint-disable-next-line no-prototype-builtins | ||
@@ -16,18 +15,18 @@ if (this._data.hasOwnProperty(name)) { | ||
| }, | ||
| addMultiple: function (functions) { | ||
| var _this = this; | ||
| Object.keys(functions).forEach(function (name) { | ||
| _this.add(name, functions[name]); | ||
| }); | ||
| addMultiple: function(functions) { | ||
| Object.keys(functions).forEach( | ||
| name => { | ||
| this.add(name, functions[name]); | ||
| }); | ||
| }, | ||
| get: function (name) { | ||
| return this._data[name] || (base && base.get(name)); | ||
| get: function(name) { | ||
| return this._data[name] || ( base && base.get( name )); | ||
| }, | ||
| getLocalFunctions: function () { | ||
| getLocalFunctions: function() { | ||
| return this._data; | ||
| }, | ||
| inherit: function () { | ||
| return makeRegistry(this); | ||
| inherit: function() { | ||
| return makeRegistry( this ); | ||
| }, | ||
| create: function (base) { | ||
| create: function(base) { | ||
| return makeRegistry(base); | ||
@@ -37,3 +36,3 @@ } | ||
| } | ||
| exports.default = makeRegistry(null); | ||
| //# sourceMappingURL=function-registry.js.map | ||
| export default makeRegistry( null ); |
@@ -1,35 +0,35 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var function_registry_1 = tslib_1.__importDefault(require("./function-registry")); | ||
| var function_caller_1 = tslib_1.__importDefault(require("./function-caller")); | ||
| var boolean_1 = tslib_1.__importDefault(require("./boolean")); | ||
| var default_1 = tslib_1.__importDefault(require("./default")); | ||
| var color_1 = tslib_1.__importDefault(require("./color")); | ||
| var color_blending_1 = tslib_1.__importDefault(require("./color-blending")); | ||
| var data_uri_1 = tslib_1.__importDefault(require("./data-uri")); | ||
| var list_1 = tslib_1.__importDefault(require("./list")); | ||
| var math_1 = tslib_1.__importDefault(require("./math")); | ||
| var number_1 = tslib_1.__importDefault(require("./number")); | ||
| var string_1 = tslib_1.__importDefault(require("./string")); | ||
| var svg_1 = tslib_1.__importDefault(require("./svg")); | ||
| var types_1 = tslib_1.__importDefault(require("./types")); | ||
| var style_1 = tslib_1.__importDefault(require("./style")); | ||
| exports.default = (function (environment) { | ||
| var functions = { functionRegistry: function_registry_1.default, functionCaller: function_caller_1.default }; | ||
| import functionRegistry from './function-registry.js'; | ||
| import functionCaller from './function-caller.js'; | ||
| import boolean from './boolean.js'; | ||
| import defaultFunc from './default.js'; | ||
| import color from './color.js'; | ||
| import colorBlending from './color-blending.js'; | ||
| import dataUri from './data-uri.js'; | ||
| import list from './list.js'; | ||
| import math from './math.js'; | ||
| import number from './number.js'; | ||
| import string from './string.js'; | ||
| import svg from './svg.js'; | ||
| import types from './types.js'; | ||
| import style from './style.js'; | ||
| export default environment => { | ||
| const functions = { functionRegistry, functionCaller }; | ||
| // register functions | ||
| function_registry_1.default.addMultiple(boolean_1.default); | ||
| function_registry_1.default.add('default', default_1.default.eval.bind(default_1.default)); | ||
| function_registry_1.default.addMultiple(color_1.default); | ||
| function_registry_1.default.addMultiple(color_blending_1.default); | ||
| function_registry_1.default.addMultiple((0, data_uri_1.default)(environment)); | ||
| function_registry_1.default.addMultiple(list_1.default); | ||
| function_registry_1.default.addMultiple(math_1.default); | ||
| function_registry_1.default.addMultiple(number_1.default); | ||
| function_registry_1.default.addMultiple(string_1.default); | ||
| function_registry_1.default.addMultiple((0, svg_1.default)(environment)); | ||
| function_registry_1.default.addMultiple(types_1.default); | ||
| function_registry_1.default.addMultiple(style_1.default); | ||
| functionRegistry.addMultiple(boolean); | ||
| functionRegistry.add('default', defaultFunc.eval.bind(defaultFunc)); | ||
| functionRegistry.addMultiple(color); | ||
| functionRegistry.addMultiple(colorBlending); | ||
| functionRegistry.addMultiple(dataUri(environment)); | ||
| functionRegistry.addMultiple(list); | ||
| functionRegistry.addMultiple(math); | ||
| functionRegistry.addMultiple(number); | ||
| functionRegistry.addMultiple(string); | ||
| functionRegistry.addMultiple(svg(environment)); | ||
| functionRegistry.addMultiple(types); | ||
| functionRegistry.addMultiple(style); | ||
| return functions; | ||
| }); | ||
| //# sourceMappingURL=index.js.map | ||
| }; |
@@ -1,42 +0,39 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var comment_1 = tslib_1.__importDefault(require("../tree/comment")); | ||
| var node_1 = tslib_1.__importDefault(require("../tree/node")); | ||
| var dimension_1 = tslib_1.__importDefault(require("../tree/dimension")); | ||
| var declaration_1 = tslib_1.__importDefault(require("../tree/declaration")); | ||
| var expression_1 = tslib_1.__importDefault(require("../tree/expression")); | ||
| var ruleset_1 = tslib_1.__importDefault(require("../tree/ruleset")); | ||
| var selector_1 = tslib_1.__importDefault(require("../tree/selector")); | ||
| var element_1 = tslib_1.__importDefault(require("../tree/element")); | ||
| var quoted_1 = tslib_1.__importDefault(require("../tree/quoted")); | ||
| var value_1 = tslib_1.__importDefault(require("../tree/value")); | ||
| var getItemsFromNode = function (node) { | ||
| import Comment from '../tree/comment.js'; | ||
| import Node from '../tree/node.js'; | ||
| import Dimension from '../tree/dimension.js'; | ||
| import Declaration from '../tree/declaration.js'; | ||
| import Expression from '../tree/expression.js'; | ||
| import Ruleset from '../tree/ruleset.js'; | ||
| import Selector from '../tree/selector.js'; | ||
| import Element from '../tree/element.js'; | ||
| import Quote from '../tree/quoted.js'; | ||
| import Value from '../tree/value.js'; | ||
| const getItemsFromNode = node => { | ||
| // handle non-array values as an array of length 1 | ||
| // return 'undefined' if index is invalid | ||
| var items = Array.isArray(node.value) ? | ||
| const items = Array.isArray(node.value) ? | ||
| node.value : Array(node); | ||
| return items; | ||
| }; | ||
| exports.default = { | ||
| _SELF: function (n) { | ||
| export default { | ||
| _SELF: function(n) { | ||
| return n; | ||
| }, | ||
| '~': function () { | ||
| var expr = []; | ||
| for (var _i = 0; _i < arguments.length; _i++) { | ||
| expr[_i] = arguments[_i]; | ||
| } | ||
| '~': function(...expr) { | ||
| if (expr.length === 1) { | ||
| return expr[0]; | ||
| } | ||
| return new value_1.default(expr); | ||
| return new Value(expr); | ||
| }, | ||
| extract: function (values, index) { | ||
| extract: function(values, index) { | ||
| // (1-based index) | ||
| index = index.value - 1; | ||
| return getItemsFromNode(values)[index]; | ||
| }, | ||
| length: function (values) { | ||
| return new dimension_1.default(getItemsFromNode(values).length); | ||
| length: function(values) { | ||
| return new Dimension(getItemsFromNode(values).length); | ||
| }, | ||
@@ -46,12 +43,12 @@ /** | ||
| * Modeled after Lodash's range function, also exists natively in PHP | ||
| * | ||
| * | ||
| * @param {Dimension} [start=1] | ||
| * @param {Dimension} end - e.g. 10 or 10px - unit is added to output | ||
| * @param {Dimension} [step=1] | ||
| * @param {Dimension} [step=1] | ||
| */ | ||
| range: function (start, end, step) { | ||
| var from; | ||
| var to; | ||
| var stepValue = 1; | ||
| var list = []; | ||
| range: function(start, end, step) { | ||
| let from; | ||
| let to; | ||
| let stepValue = 1; | ||
| const list = []; | ||
| if (end) { | ||
@@ -68,41 +65,41 @@ to = end; | ||
| } | ||
| for (var i = from; i <= to.value; i += stepValue) { | ||
| list.push(new dimension_1.default(i, to.unit)); | ||
| for (let i = from; i <= to.value; i += stepValue) { | ||
| list.push(new Dimension(i, to.unit)); | ||
| } | ||
| return new expression_1.default(list); | ||
| return new Expression(list); | ||
| }, | ||
| each: function (list, rs) { | ||
| var _this = this; | ||
| var rules = []; | ||
| var newRules; | ||
| var iterator; | ||
| var tryEval = function (val) { | ||
| if (val instanceof node_1.default) { | ||
| return val.eval(_this.context); | ||
| each: function(list, rs) { | ||
| const rules = []; | ||
| let newRules; | ||
| let iterator; | ||
| const tryEval = val => { | ||
| if (val instanceof Node) { | ||
| return val.eval(this.context); | ||
| } | ||
| return val; | ||
| }; | ||
| if (list.value && !(list instanceof quoted_1.default)) { | ||
| if (list.value && !(list instanceof Quote)) { | ||
| if (Array.isArray(list.value)) { | ||
| iterator = list.value.map(tryEval); | ||
| } | ||
| else { | ||
| } else { | ||
| iterator = [tryEval(list.value)]; | ||
| } | ||
| } | ||
| else if (list.ruleset) { | ||
| } else if (list.ruleset) { | ||
| iterator = tryEval(list.ruleset).rules; | ||
| } | ||
| else if (list.rules) { | ||
| } else if (list.rules) { | ||
| iterator = list.rules.map(tryEval); | ||
| } | ||
| else if (Array.isArray(list)) { | ||
| } else if (Array.isArray(list)) { | ||
| iterator = list.map(tryEval); | ||
| } | ||
| else { | ||
| } else { | ||
| iterator = [tryEval(list)]; | ||
| } | ||
| var valueName = '@value'; | ||
| var keyName = '@key'; | ||
| var indexName = '@index'; | ||
| let valueName = '@value'; | ||
| let keyName = '@key'; | ||
| let indexName = '@index'; | ||
| if (rs.params) { | ||
@@ -113,36 +110,52 @@ valueName = rs.params[0] && rs.params[0].name; | ||
| rs = rs.rules; | ||
| } | ||
| else { | ||
| } else { | ||
| rs = rs.ruleset; | ||
| } | ||
| for (var i = 0; i < iterator.length; i++) { | ||
| var key = void 0; | ||
| var value = void 0; | ||
| var item = iterator[i]; | ||
| if (item instanceof declaration_1.default) { | ||
| for (let i = 0; i < iterator.length; i++) { | ||
| let key; | ||
| let value; | ||
| const item = iterator[i]; | ||
| if (item instanceof Declaration) { | ||
| key = typeof item.name === 'string' ? item.name : item.name[0].value; | ||
| value = item.value; | ||
| } | ||
| else { | ||
| key = new dimension_1.default(i + 1); | ||
| } else { | ||
| key = new Dimension(i + 1); | ||
| value = item; | ||
| } | ||
| if (item instanceof comment_1.default) { | ||
| if (item instanceof Comment) { | ||
| continue; | ||
| } | ||
| newRules = rs.rules.slice(0); | ||
| if (valueName) { | ||
| newRules.push(new declaration_1.default(valueName, value, false, false, this.index, this.currentFileInfo)); | ||
| newRules.push(new Declaration(valueName, | ||
| value, | ||
| false, false, this.index, this.currentFileInfo)); | ||
| } | ||
| if (indexName) { | ||
| newRules.push(new declaration_1.default(indexName, new dimension_1.default(i + 1), false, false, this.index, this.currentFileInfo)); | ||
| newRules.push(new Declaration(indexName, | ||
| new Dimension(i + 1), | ||
| false, false, this.index, this.currentFileInfo)); | ||
| } | ||
| if (keyName) { | ||
| newRules.push(new declaration_1.default(keyName, key, false, false, this.index, this.currentFileInfo)); | ||
| newRules.push(new Declaration(keyName, | ||
| key, | ||
| false, false, this.index, this.currentFileInfo)); | ||
| } | ||
| rules.push(new ruleset_1.default([new (selector_1.default)([new element_1.default('', '&')])], newRules, rs.strictImports, rs.visibilityInfo())); | ||
| rules.push(new Ruleset([ new(Selector)([ new Element('', '&') ]) ], | ||
| newRules, | ||
| rs.strictImports, | ||
| rs.visibilityInfo() | ||
| )); | ||
| } | ||
| return new ruleset_1.default([new (selector_1.default)([new element_1.default('', '&')])], rules, rs.strictImports, rs.visibilityInfo()).eval(this.context); | ||
| return new Ruleset([ new(Selector)([ new Element('', '&') ]) ], | ||
| rules, | ||
| rs.strictImports, | ||
| rs.visibilityInfo() | ||
| ).eval(this.context); | ||
| } | ||
| }; | ||
| //# sourceMappingURL=list.js.map |
@@ -1,7 +0,5 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var dimension_1 = tslib_1.__importDefault(require("../tree/dimension")); | ||
| var MathHelper = function (fn, unit, n) { | ||
| if (!(n instanceof dimension_1.default)) { | ||
| import Dimension from '../tree/dimension.js'; | ||
| const MathHelper = (fn, unit, n) => { | ||
| if (!(n instanceof Dimension)) { | ||
| throw { type: 'Argument', message: 'argument must be a number' }; | ||
@@ -11,9 +9,8 @@ } | ||
| unit = n.unit; | ||
| } | ||
| else { | ||
| } else { | ||
| n = n.unify(); | ||
| } | ||
| return new dimension_1.default(fn(parseFloat(n.value)), unit); | ||
| return new Dimension(fn(parseFloat(n.value)), unit); | ||
| }; | ||
| exports.default = MathHelper; | ||
| //# sourceMappingURL=math-helper.js.map | ||
| export default MathHelper; |
@@ -1,29 +0,29 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var math_helper_js_1 = tslib_1.__importDefault(require("./math-helper.js")); | ||
| var mathFunctions = { | ||
| import mathHelper from './math-helper.js'; | ||
| const mathFunctions = { | ||
| // name, unit | ||
| ceil: null, | ||
| ceil: null, | ||
| floor: null, | ||
| sqrt: null, | ||
| abs: null, | ||
| tan: '', | ||
| sin: '', | ||
| cos: '', | ||
| atan: 'rad', | ||
| asin: 'rad', | ||
| acos: 'rad' | ||
| sqrt: null, | ||
| abs: null, | ||
| tan: '', | ||
| sin: '', | ||
| cos: '', | ||
| atan: 'rad', | ||
| asin: 'rad', | ||
| acos: 'rad' | ||
| }; | ||
| for (var f in mathFunctions) { | ||
| for (const f in mathFunctions) { | ||
| // eslint-disable-next-line no-prototype-builtins | ||
| if (mathFunctions.hasOwnProperty(f)) { | ||
| mathFunctions[f] = math_helper_js_1.default.bind(null, Math[f], mathFunctions[f]); | ||
| mathFunctions[f] = mathHelper.bind(null, Math[f], mathFunctions[f]); | ||
| } | ||
| } | ||
| mathFunctions.round = function (n, f) { | ||
| var fraction = typeof f === 'undefined' ? 0 : f.value; | ||
| return (0, math_helper_js_1.default)(function (num) { return num.toFixed(fraction); }, null, n); | ||
| mathFunctions.round = (n, f) => { | ||
| const fraction = typeof f === 'undefined' ? 0 : f.value; | ||
| return mathHelper(num => num.toFixed(fraction), null, n); | ||
| }; | ||
| exports.default = mathFunctions; | ||
| //# sourceMappingURL=math.js.map | ||
| export default mathFunctions; |
@@ -1,9 +0,6 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var dimension_1 = tslib_1.__importDefault(require("../tree/dimension")); | ||
| var anonymous_1 = tslib_1.__importDefault(require("../tree/anonymous")); | ||
| var math_helper_js_1 = tslib_1.__importDefault(require("./math-helper.js")); | ||
| var minMax = function (isMin, args) { | ||
| var _this = this; | ||
| import Dimension from '../tree/dimension.js'; | ||
| import Anonymous from '../tree/anonymous.js'; | ||
| import mathHelper from './math-helper.js'; | ||
| const minMax = function (isMin, args) { | ||
| args = Array.prototype.slice.call(args); | ||
@@ -13,26 +10,27 @@ switch (args.length) { | ||
| } | ||
| var i; // key is the unit.toString() for unified Dimension values, | ||
| var j; | ||
| var current; | ||
| var currentUnified; | ||
| var referenceUnified; | ||
| var unit; | ||
| var unitStatic; | ||
| var unitClone; | ||
| var // elems only contains original argument values. | ||
| order = []; | ||
| var values = {}; | ||
| let i; // key is the unit.toString() for unified Dimension values, | ||
| let j; | ||
| let current; | ||
| let currentUnified; | ||
| let referenceUnified; | ||
| let unit; | ||
| let unitStatic; | ||
| let unitClone; | ||
| const // elems only contains original argument values. | ||
| order = []; | ||
| const values = {}; | ||
| // value is the index into the order array. | ||
| for (i = 0; i < args.length; i++) { | ||
| current = args[i]; | ||
| if (!(current instanceof dimension_1.default)) { | ||
| if (!(current instanceof Dimension)) { | ||
| if (Array.isArray(args[i].value)) { | ||
| Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value)); | ||
| continue; | ||
| } | ||
| else { | ||
| } else { | ||
| throw { type: 'Argument', message: 'incompatible types' }; | ||
| } | ||
| } | ||
| currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new dimension_1.default(current.value, unitClone).unify() : current.unify(); | ||
| currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new Dimension(current.value, unitClone).unify() : current.unify(); | ||
| unit = currentUnified.unit.toString() === '' && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString(); | ||
@@ -50,4 +48,4 @@ unitStatic = unit !== '' && unitStatic === undefined || unit !== '' && order[0].unify().unit.toString() === '' ? unit : unitStatic; | ||
| } | ||
| referenceUnified = order[j].unit.toString() === '' && unitClone !== undefined ? new dimension_1.default(order[j].value, unitClone).unify() : order[j].unify(); | ||
| if (isMin && currentUnified.value < referenceUnified.value || | ||
| referenceUnified = order[j].unit.toString() === '' && unitClone !== undefined ? new Dimension(order[j].value, unitClone).unify() : order[j].unify(); | ||
| if ( isMin && currentUnified.value < referenceUnified.value || | ||
| !isMin && currentUnified.value > referenceUnified.value) { | ||
@@ -60,25 +58,16 @@ order[j] = current; | ||
| } | ||
| args = order.map(function (a) { return a.toCSS(_this.context); }).join(this.context.compress ? ',' : ', '); | ||
| return new anonymous_1.default("".concat(isMin ? 'min' : 'max', "(").concat(args, ")")); | ||
| args = order.map(a => { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', '); | ||
| return new Anonymous(`${isMin ? 'min' : 'max'}(${args})`); | ||
| }; | ||
| exports.default = { | ||
| min: function () { | ||
| var args = []; | ||
| for (var _i = 0; _i < arguments.length; _i++) { | ||
| args[_i] = arguments[_i]; | ||
| } | ||
| export default { | ||
| min: function(...args) { | ||
| try { | ||
| return minMax.call(this, true, args); | ||
| } | ||
| catch (e) { } | ||
| } catch (e) {} | ||
| }, | ||
| max: function () { | ||
| var args = []; | ||
| for (var _i = 0; _i < arguments.length; _i++) { | ||
| args[_i] = arguments[_i]; | ||
| } | ||
| max: function(...args) { | ||
| try { | ||
| return minMax.call(this, false, args); | ||
| } | ||
| catch (e) { } | ||
| } catch (e) {} | ||
| }, | ||
@@ -89,22 +78,22 @@ convert: function (val, unit) { | ||
| pi: function () { | ||
| return new dimension_1.default(Math.PI); | ||
| return new Dimension(Math.PI); | ||
| }, | ||
| mod: function (a, b) { | ||
| return new dimension_1.default(a.value % b.value, a.unit); | ||
| mod: function(a, b) { | ||
| return new Dimension(a.value % b.value, a.unit); | ||
| }, | ||
| pow: function (x, y) { | ||
| pow: function(x, y) { | ||
| if (typeof x === 'number' && typeof y === 'number') { | ||
| x = new dimension_1.default(x); | ||
| y = new dimension_1.default(y); | ||
| } | ||
| else if (!(x instanceof dimension_1.default) || !(y instanceof dimension_1.default)) { | ||
| x = new Dimension(x); | ||
| y = new Dimension(y); | ||
| } else if (!(x instanceof Dimension) || !(y instanceof Dimension)) { | ||
| throw { type: 'Argument', message: 'arguments must be numbers' }; | ||
| } | ||
| return new dimension_1.default(Math.pow(x.value, y.value), x.unit); | ||
| return new Dimension(Math.pow(x.value, y.value), x.unit); | ||
| }, | ||
| percentage: function (n) { | ||
| var result = (0, math_helper_js_1.default)(function (num) { return num * 100; }, '%', n); | ||
| const result = mathHelper(num => num * 100, '%', n); | ||
| return result; | ||
| } | ||
| }; | ||
| //# sourceMappingURL=number.js.map |
@@ -1,40 +0,36 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var quoted_1 = tslib_1.__importDefault(require("../tree/quoted")); | ||
| var anonymous_1 = tslib_1.__importDefault(require("../tree/anonymous")); | ||
| var javascript_1 = tslib_1.__importDefault(require("../tree/javascript")); | ||
| exports.default = { | ||
| import Quoted from '../tree/quoted.js'; | ||
| import Anonymous from '../tree/anonymous.js'; | ||
| import JavaScript from '../tree/javascript.js'; | ||
| export default { | ||
| e: function (str) { | ||
| return new quoted_1.default('"', str instanceof javascript_1.default ? str.evaluated : str.value, true); | ||
| return new Quoted('"', str instanceof JavaScript ? str.evaluated : str.value, true); | ||
| }, | ||
| escape: function (str) { | ||
| return new anonymous_1.default(encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B') | ||
| .replace(/\(/g, '%28').replace(/\)/g, '%29')); | ||
| return new Anonymous( | ||
| encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B') | ||
| .replace(/\(/g, '%28').replace(/\)/g, '%29')); | ||
| }, | ||
| replace: function (string, pattern, replacement, flags) { | ||
| var result = string.value; | ||
| let result = string.value; | ||
| replacement = (replacement.type === 'Quoted') ? | ||
| replacement.value : replacement.toCSS(); | ||
| result = result.replace(new RegExp(pattern.value, flags ? flags.value : ''), replacement); | ||
| return new quoted_1.default(string.quote || '', result, string.escaped); | ||
| return new Quoted(string.quote || '', result, string.escaped); | ||
| }, | ||
| '%': function (string /* arg, arg, ... */) { | ||
| var args = Array.prototype.slice.call(arguments, 1); | ||
| var result = string.value; | ||
| var _loop_1 = function (i) { | ||
| const args = Array.prototype.slice.call(arguments, 1); | ||
| let result = string.value; | ||
| for (let i = 0; i < args.length; i++) { | ||
| /* jshint loopfunc:true */ | ||
| result = result.replace(/%[sda]/i, function (token) { | ||
| var value = ((args[i].type === 'Quoted') && | ||
| result = result.replace(/%[sda]/i, token => { | ||
| const value = ((args[i].type === 'Quoted') && | ||
| token.match(/s/i)) ? args[i].value : args[i].toCSS(); | ||
| return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value; | ||
| }); | ||
| }; | ||
| for (var i = 0; i < args.length; i++) { | ||
| _loop_1(i); | ||
| } | ||
| result = result.replace(/%%/g, '%'); | ||
| return new quoted_1.default(string.quote || '', result, string.escaped); | ||
| return new Quoted(string.quote || '', result, string.escaped); | ||
| } | ||
| }; | ||
| //# sourceMappingURL=string.js.map |
@@ -1,28 +0,29 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var variable_1 = tslib_1.__importDefault(require("../tree/variable")); | ||
| var variable_2 = tslib_1.__importDefault(require("../tree/variable")); | ||
| var styleExpression = function (args) { | ||
| var _this = this; | ||
| import Variable from '../tree/variable.js'; | ||
| import Anonymous from '../tree/anonymous.js'; | ||
| /** @param {*[]} args */ | ||
| const styleExpression = function (args) { | ||
| args = Array.prototype.slice.call(args); | ||
| switch (args.length) { | ||
| case 0: throw { type: 'Argument', message: 'one or more arguments required' }; | ||
| if (args.length === 0) { | ||
| throw { type: 'Argument', message: 'one or more arguments required' }; | ||
| } | ||
| var entityList = [new variable_1.default(args[0].value, this.index, this.currentFileInfo).eval(this.context)]; | ||
| args = entityList.map(function (a) { return a.toCSS(_this.context); }).join(this.context.compress ? ',' : ', '); | ||
| return new variable_2.default("style(".concat(args, ")")); | ||
| const entityList = [new Variable(args[0].value, this.index, this.currentFileInfo).eval(this.context)]; | ||
| const result = entityList.map(a => { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', '); | ||
| return new Anonymous(`style(${result})`); | ||
| }; | ||
| exports.default = { | ||
| style: function () { | ||
| var args = []; | ||
| for (var _i = 0; _i < arguments.length; _i++) { | ||
| args[_i] = arguments[_i]; | ||
| } | ||
| export default { | ||
| /** @param {...*} args */ | ||
| style: function(...args) { | ||
| try { | ||
| return styleExpression.call(this, args); | ||
| } catch (e) { | ||
| // When style() is used as a CSS function (e.g. @container style(--responsive: true)), | ||
| // arguments won't be valid Less variables. Return undefined to let the | ||
| // parser fall through and treat it as plain CSS. | ||
| } | ||
| catch (e) { } | ||
| }, | ||
| }; | ||
| //# sourceMappingURL=style.js.map |
@@ -1,86 +0,87 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var dimension_1 = tslib_1.__importDefault(require("../tree/dimension")); | ||
| var color_1 = tslib_1.__importDefault(require("../tree/color")); | ||
| var expression_1 = tslib_1.__importDefault(require("../tree/expression")); | ||
| var quoted_1 = tslib_1.__importDefault(require("../tree/quoted")); | ||
| var url_1 = tslib_1.__importDefault(require("../tree/url")); | ||
| exports.default = (function () { | ||
| return { 'svg-gradient': function (direction) { | ||
| var stops; | ||
| var gradientDirectionSvg; | ||
| var gradientType = 'linear'; | ||
| var rectangleDimension = 'x="0" y="0" width="1" height="1"'; | ||
| var renderEnv = { compress: false }; | ||
| var returner; | ||
| var directionValue = direction.toCSS(renderEnv); | ||
| var i; | ||
| var color; | ||
| var position; | ||
| var positionValue; | ||
| var alpha; | ||
| function throwArgumentDescriptor() { | ||
| throw { type: 'Argument', | ||
| message: 'svg-gradient expects direction, start_color [start_position], [color position,]...,' + | ||
| ' end_color [end_position] or direction, color list' }; | ||
| import Dimension from '../tree/dimension.js'; | ||
| import Color from '../tree/color.js'; | ||
| import Expression from '../tree/expression.js'; | ||
| import Quoted from '../tree/quoted.js'; | ||
| import URL from '../tree/url.js'; | ||
| export default () => { | ||
| return { 'svg-gradient': function(direction) { | ||
| let stops; | ||
| let gradientDirectionSvg; | ||
| let gradientType = 'linear'; | ||
| let rectangleDimension = 'x="0" y="0" width="1" height="1"'; | ||
| const renderEnv = {compress: false}; | ||
| let returner; | ||
| const directionValue = direction.toCSS(renderEnv); | ||
| let i; | ||
| let color; | ||
| let position; | ||
| let positionValue; | ||
| let alpha; | ||
| function throwArgumentDescriptor() { | ||
| throw { type: 'Argument', | ||
| message: 'svg-gradient expects direction, start_color [start_position], [color position,]...,' + | ||
| ' end_color [end_position] or direction, color list' }; | ||
| } | ||
| if (arguments.length == 2) { | ||
| if (arguments[1].value.length < 2) { | ||
| throwArgumentDescriptor(); | ||
| } | ||
| if (arguments.length == 2) { | ||
| if (arguments[1].value.length < 2) { | ||
| throwArgumentDescriptor(); | ||
| } | ||
| stops = arguments[1].value; | ||
| stops = arguments[1].value; | ||
| } else if (arguments.length < 3) { | ||
| throwArgumentDescriptor(); | ||
| } else { | ||
| stops = Array.prototype.slice.call(arguments, 1); | ||
| } | ||
| switch (directionValue) { | ||
| case 'to bottom': | ||
| gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"'; | ||
| break; | ||
| case 'to right': | ||
| gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="0%"'; | ||
| break; | ||
| case 'to bottom right': | ||
| gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="100%"'; | ||
| break; | ||
| case 'to top right': | ||
| gradientDirectionSvg = 'x1="0%" y1="100%" x2="100%" y2="0%"'; | ||
| break; | ||
| case 'ellipse': | ||
| case 'ellipse at center': | ||
| gradientType = 'radial'; | ||
| gradientDirectionSvg = 'cx="50%" cy="50%" r="75%"'; | ||
| rectangleDimension = 'x="-50" y="-50" width="101" height="101"'; | ||
| break; | ||
| default: | ||
| throw { type: 'Argument', message: 'svg-gradient direction must be \'to bottom\', \'to right\',' + | ||
| ' \'to bottom right\', \'to top right\' or \'ellipse at center\'' }; | ||
| } | ||
| returner = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"><${gradientType}Gradient id="g" ${gradientDirectionSvg}>`; | ||
| for (i = 0; i < stops.length; i += 1) { | ||
| if (stops[i] instanceof Expression) { | ||
| color = stops[i].value[0]; | ||
| position = stops[i].value[1]; | ||
| } else { | ||
| color = stops[i]; | ||
| position = undefined; | ||
| } | ||
| else if (arguments.length < 3) { | ||
| if (!(color instanceof Color) || (!((i === 0 || i + 1 === stops.length) && position === undefined) && !(position instanceof Dimension))) { | ||
| throwArgumentDescriptor(); | ||
| } | ||
| else { | ||
| stops = Array.prototype.slice.call(arguments, 1); | ||
| } | ||
| switch (directionValue) { | ||
| case 'to bottom': | ||
| gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"'; | ||
| break; | ||
| case 'to right': | ||
| gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="0%"'; | ||
| break; | ||
| case 'to bottom right': | ||
| gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="100%"'; | ||
| break; | ||
| case 'to top right': | ||
| gradientDirectionSvg = 'x1="0%" y1="100%" x2="100%" y2="0%"'; | ||
| break; | ||
| case 'ellipse': | ||
| case 'ellipse at center': | ||
| gradientType = 'radial'; | ||
| gradientDirectionSvg = 'cx="50%" cy="50%" r="75%"'; | ||
| rectangleDimension = 'x="-50" y="-50" width="101" height="101"'; | ||
| break; | ||
| default: | ||
| throw { type: 'Argument', message: 'svg-gradient direction must be \'to bottom\', \'to right\',' + | ||
| ' \'to bottom right\', \'to top right\' or \'ellipse at center\'' }; | ||
| } | ||
| returner = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 1 1\"><".concat(gradientType, "Gradient id=\"g\" ").concat(gradientDirectionSvg, ">"); | ||
| for (i = 0; i < stops.length; i += 1) { | ||
| if (stops[i] instanceof expression_1.default) { | ||
| color = stops[i].value[0]; | ||
| position = stops[i].value[1]; | ||
| } | ||
| else { | ||
| color = stops[i]; | ||
| position = undefined; | ||
| } | ||
| if (!(color instanceof color_1.default) || (!((i === 0 || i + 1 === stops.length) && position === undefined) && !(position instanceof dimension_1.default))) { | ||
| throwArgumentDescriptor(); | ||
| } | ||
| positionValue = position ? position.toCSS(renderEnv) : i === 0 ? '0%' : '100%'; | ||
| alpha = color.alpha; | ||
| returner += "<stop offset=\"".concat(positionValue, "\" stop-color=\"").concat(color.toRGB(), "\"").concat(alpha < 1 ? " stop-opacity=\"".concat(alpha, "\"") : '', "/>"); | ||
| } | ||
| returner += "</".concat(gradientType, "Gradient><rect ").concat(rectangleDimension, " fill=\"url(#g)\" /></svg>"); | ||
| returner = encodeURIComponent(returner); | ||
| returner = "data:image/svg+xml,".concat(returner); | ||
| return new url_1.default(new quoted_1.default("'".concat(returner, "'"), returner, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo); | ||
| } }; | ||
| }); | ||
| //# sourceMappingURL=svg.js.map | ||
| positionValue = position ? position.toCSS(renderEnv) : i === 0 ? '0%' : '100%'; | ||
| alpha = color.alpha; | ||
| returner += `<stop offset="${positionValue}" stop-color="${color.toRGB()}"${alpha < 1 ? ` stop-opacity="${alpha}"` : ''}/>`; | ||
| } | ||
| returner += `</${gradientType}Gradient><rect ${rectangleDimension} fill="url(#g)" /></svg>`; | ||
| returner = encodeURIComponent(returner); | ||
| returner = `data:image/svg+xml,${returner}`; | ||
| return new URL(new Quoted(`'${returner}'`, returner, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo); | ||
| }}; | ||
| }; |
@@ -1,14 +0,12 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var keyword_1 = tslib_1.__importDefault(require("../tree/keyword")); | ||
| var detached_ruleset_1 = tslib_1.__importDefault(require("../tree/detached-ruleset")); | ||
| var dimension_1 = tslib_1.__importDefault(require("../tree/dimension")); | ||
| var color_1 = tslib_1.__importDefault(require("../tree/color")); | ||
| var quoted_1 = tslib_1.__importDefault(require("../tree/quoted")); | ||
| var anonymous_1 = tslib_1.__importDefault(require("../tree/anonymous")); | ||
| var url_1 = tslib_1.__importDefault(require("../tree/url")); | ||
| var operation_1 = tslib_1.__importDefault(require("../tree/operation")); | ||
| var isa = function (n, Type) { return (n instanceof Type) ? keyword_1.default.True : keyword_1.default.False; }; | ||
| var isunit = function (n, unit) { | ||
| import Keyword from '../tree/keyword.js'; | ||
| import DetachedRuleset from '../tree/detached-ruleset.js'; | ||
| import Dimension from '../tree/dimension.js'; | ||
| import Color from '../tree/color.js'; | ||
| import Quoted from '../tree/quoted.js'; | ||
| import Anonymous from '../tree/anonymous.js'; | ||
| import URL from '../tree/url.js'; | ||
| import Operation from '../tree/operation.js'; | ||
| const isa = (n, Type) => (n instanceof Type) ? Keyword.True : Keyword.False; | ||
| const isunit = (n, unit) => { | ||
| if (unit === undefined) { | ||
@@ -21,22 +19,23 @@ throw { type: 'Argument', message: 'missing the required second argument to isunit.' }; | ||
| } | ||
| return (n instanceof dimension_1.default) && n.unit.is(unit) ? keyword_1.default.True : keyword_1.default.False; | ||
| return (n instanceof Dimension) && n.unit.is(unit) ? Keyword.True : Keyword.False; | ||
| }; | ||
| exports.default = { | ||
| export default { | ||
| isruleset: function (n) { | ||
| return isa(n, detached_ruleset_1.default); | ||
| return isa(n, DetachedRuleset); | ||
| }, | ||
| iscolor: function (n) { | ||
| return isa(n, color_1.default); | ||
| return isa(n, Color); | ||
| }, | ||
| isnumber: function (n) { | ||
| return isa(n, dimension_1.default); | ||
| return isa(n, Dimension); | ||
| }, | ||
| isstring: function (n) { | ||
| return isa(n, quoted_1.default); | ||
| return isa(n, Quoted); | ||
| }, | ||
| iskeyword: function (n) { | ||
| return isa(n, keyword_1.default); | ||
| return isa(n, Keyword); | ||
| }, | ||
| isurl: function (n) { | ||
| return isa(n, url_1.default); | ||
| return isa(n, URL); | ||
| }, | ||
@@ -52,25 +51,22 @@ ispixel: function (n) { | ||
| }, | ||
| isunit: isunit, | ||
| isunit, | ||
| unit: function (val, unit) { | ||
| if (!(val instanceof dimension_1.default)) { | ||
| if (!(val instanceof Dimension)) { | ||
| throw { type: 'Argument', | ||
| message: "the first argument to unit must be a number".concat(val instanceof operation_1.default ? '. Have you forgotten parenthesis?' : '') }; | ||
| message: `the first argument to unit must be a number${val instanceof Operation ? '. Have you forgotten parenthesis?' : ''}` }; | ||
| } | ||
| if (unit) { | ||
| if (unit instanceof keyword_1.default) { | ||
| if (unit instanceof Keyword) { | ||
| unit = unit.value; | ||
| } | ||
| else { | ||
| } else { | ||
| unit = unit.toCSS(); | ||
| } | ||
| } | ||
| else { | ||
| } else { | ||
| unit = ''; | ||
| } | ||
| return new dimension_1.default(val.value, unit); | ||
| return new Dimension(val.value, unit); | ||
| }, | ||
| 'get-unit': function (n) { | ||
| return new anonymous_1.default(n.unit); | ||
| return new Anonymous(n.unit); | ||
| } | ||
| }; | ||
| //# sourceMappingURL=types.js.map |
@@ -1,10 +0,8 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var contexts_1 = tslib_1.__importDefault(require("./contexts")); | ||
| var parser_1 = tslib_1.__importDefault(require("./parser/parser")); | ||
| var less_error_1 = tslib_1.__importDefault(require("./less-error")); | ||
| var utils = tslib_1.__importStar(require("./utils")); | ||
| var logger_1 = tslib_1.__importDefault(require("./logger")); | ||
| function default_1(environment) { | ||
| import contexts from './contexts.js'; | ||
| import Parser from './parser/parser.js'; | ||
| import LessError from './less-error.js'; | ||
| import * as utils from './utils.js'; | ||
| import logger from './logger.js'; | ||
| export default function(environment) { | ||
| // FileInfo = { | ||
@@ -18,8 +16,9 @@ // 'rewriteUrls' - option - whether to adjust URL's to be relative | ||
| // 'reference' - whether the file should not be output and only output parts that are referenced | ||
| var ImportManager = /** @class */ (function () { | ||
| function ImportManager(less, context, rootFileInfo) { | ||
| class ImportManager { | ||
| constructor(less, context, rootFileInfo) { | ||
| this.less = less; | ||
| this.rootFilename = rootFileInfo.filename; | ||
| this.paths = context.paths || []; // Search paths, when importing | ||
| this.contents = {}; // map - filename to contents of all the files | ||
| this.paths = context.paths || []; // Search paths, when importing | ||
| this.contents = {}; // map - filename to contents of all the files | ||
| this.contentsIgnoredChars = {}; // map - filename to lines at the beginning of each file to ignore | ||
@@ -30,5 +29,6 @@ this.mime = context.mime; | ||
| // Deprecated? Unused outside of here, could be useful. | ||
| this.queue = []; // Files which haven't been imported yet | ||
| this.files = {}; // Holds the imported parse trees. | ||
| this.queue = []; // Files which haven't been imported yet | ||
| this.files = {}; // Holds the imported parse trees. | ||
| } | ||
| /** | ||
@@ -42,11 +42,14 @@ * Add an import to be imported | ||
| */ | ||
| ImportManager.prototype.push = function (path, tryAppendExtension, currentFileInfo, importOptions, callback) { | ||
| var importManager = this, pluginLoader = this.context.pluginManager.Loader; | ||
| push(path, tryAppendExtension, currentFileInfo, importOptions, callback) { | ||
| const importManager = this, pluginLoader = this.context.pluginManager.Loader; | ||
| this.queue.push(path); | ||
| var fileParsedFunc = function (e, root, fullPath) { | ||
| const fileParsedFunc = function (e, root, fullPath) { | ||
| importManager.queue.splice(importManager.queue.indexOf(path), 1); // Remove the path from the queue | ||
| var importedEqualsRoot = fullPath === importManager.rootFilename; | ||
| const importedEqualsRoot = fullPath === importManager.rootFilename; | ||
| if (importOptions.optional && e) { | ||
| callback(null, { rules: [] }, false, null); | ||
| logger_1.default.info("The file ".concat(fullPath, " was skipped because it was not found and the import was marked optional.")); | ||
| callback(null, {rules:[]}, false, null); | ||
| logger.info(`The file ${fullPath} was skipped because it was not found and the import was marked optional.`); | ||
| } | ||
@@ -58,11 +61,10 @@ else { | ||
| if (!importManager.files[fullPath] && !importOptions.inline) { | ||
| importManager.files[fullPath] = { root: root, options: importOptions }; | ||
| importManager.files[fullPath] = { root, options: importOptions }; | ||
| } | ||
| if (e && !importManager.error) { | ||
| importManager.error = e; | ||
| } | ||
| if (e && !importManager.error) { importManager.error = e; } | ||
| callback(e, root, importedEqualsRoot, fullPath); | ||
| } | ||
| }; | ||
| var newFileInfo = { | ||
| const newFileInfo = { | ||
| rewriteUrls: this.context.rewriteUrls, | ||
@@ -73,11 +75,15 @@ entryPath: currentFileInfo.entryPath, | ||
| }; | ||
| var fileManager = environment.getFileManager(path, currentFileInfo.currentDirectory, this.context, environment); | ||
| const fileManager = environment.getFileManager(path, currentFileInfo.currentDirectory, this.context, environment); | ||
| if (!fileManager) { | ||
| fileParsedFunc({ message: "Could not find a file-manager for ".concat(path) }); | ||
| fileParsedFunc({ message: `Could not find a file-manager for ${path}` }); | ||
| return; | ||
| } | ||
| var loadFileCallback = function (loadedFile) { | ||
| var plugin; | ||
| var resolvedFilename = loadedFile.filename; | ||
| var contents = loadedFile.contents.replace(/^\uFEFF/, ''); | ||
| const loadFileCallback = function(loadedFile) { | ||
| let plugin; | ||
| const resolvedFilename = loadedFile.filename; | ||
| const contents = loadedFile.contents.replace(/^\uFEFF/, ''); | ||
| // Pass on an updated rootpath if path of imported file is relative and file | ||
@@ -93,3 +99,6 @@ // is in a (sub|sup) directory | ||
| if (newFileInfo.rewriteUrls) { | ||
| newFileInfo.rootpath = fileManager.join((importManager.context.rootpath || ''), fileManager.pathDiff(newFileInfo.currentDirectory, newFileInfo.entryPath)); | ||
| newFileInfo.rootpath = fileManager.join( | ||
| (importManager.context.rootpath || ''), | ||
| fileManager.pathDiff(newFileInfo.currentDirectory, newFileInfo.entryPath)); | ||
| if (!fileManager.isPathAbsolute(newFileInfo.rootpath) && fileManager.alwaysMakePathsAbsolute()) { | ||
@@ -100,11 +109,15 @@ newFileInfo.rootpath = fileManager.join(newFileInfo.entryPath, newFileInfo.rootpath); | ||
| newFileInfo.filename = resolvedFilename; | ||
| var newEnv = new contexts_1.default.Parse(importManager.context); | ||
| const newEnv = new contexts.Parse(importManager.context); | ||
| newEnv.processImports = false; | ||
| importManager.contents[resolvedFilename] = contents; | ||
| if (currentFileInfo.reference || importOptions.reference) { | ||
| newFileInfo.reference = true; | ||
| } | ||
| if (importOptions.isPlugin) { | ||
| plugin = pluginLoader.evalPlugin(contents, newEnv, importManager, importOptions.pluginArgs, newFileInfo); | ||
| if (plugin instanceof less_error_1.default) { | ||
| if (plugin instanceof LessError) { | ||
| fileParsedFunc(plugin, null, resolvedFilename); | ||
@@ -115,7 +128,5 @@ } | ||
| } | ||
| } | ||
| else if (importOptions.inline) { | ||
| } else if (importOptions.inline) { | ||
| fileParsedFunc(null, contents, resolvedFilename); | ||
| } | ||
| else { | ||
| } else { | ||
| // import (multiple) parse trees apparently get altered and can't be cached. | ||
@@ -126,6 +137,7 @@ // TODO: investigate why this is | ||
| && !importOptions.multiple) { | ||
| fileParsedFunc(null, importManager.files[resolvedFilename].root, resolvedFilename); | ||
| } | ||
| else { | ||
| new parser_1.default(newEnv, importManager, newFileInfo).parse(contents, function (e, root) { | ||
| new Parser(newEnv, importManager, newFileInfo).parse(contents, function (e, root) { | ||
| fileParsedFunc(e, root, resolvedFilename); | ||
@@ -136,14 +148,16 @@ }); | ||
| }; | ||
| var loadedFile; | ||
| var promise; | ||
| var context = utils.clone(this.context); | ||
| let loadedFile; | ||
| let promise; | ||
| const context = utils.clone(this.context); | ||
| if (tryAppendExtension) { | ||
| context.ext = importOptions.isPlugin ? '.js' : '.less'; | ||
| } | ||
| if (importOptions.isPlugin) { | ||
| context.mime = 'application/javascript'; | ||
| if (context.syncImport) { | ||
| loadedFile = pluginLoader.loadPluginSync(path, currentFileInfo.currentDirectory, context, environment, fileManager); | ||
| } | ||
| else { | ||
| } else { | ||
| promise = pluginLoader.loadPlugin(path, currentFileInfo.currentDirectory, context, environment, fileManager); | ||
@@ -155,13 +169,12 @@ } | ||
| loadedFile = fileManager.loadFileSync(path, currentFileInfo.currentDirectory, context, environment); | ||
| } else { | ||
| promise = fileManager.loadFile(path, currentFileInfo.currentDirectory, context, environment, | ||
| (err, loadedFile) => { | ||
| if (err) { | ||
| fileParsedFunc(err); | ||
| } else { | ||
| loadFileCallback(loadedFile); | ||
| } | ||
| }); | ||
| } | ||
| else { | ||
| promise = fileManager.loadFile(path, currentFileInfo.currentDirectory, context, environment, function (err, loadedFile) { | ||
| if (err) { | ||
| fileParsedFunc(err); | ||
| } | ||
| else { | ||
| loadFileCallback(loadedFile); | ||
| } | ||
| }); | ||
| } | ||
| } | ||
@@ -171,16 +184,12 @@ if (loadedFile) { | ||
| fileParsedFunc(loadedFile); | ||
| } | ||
| else { | ||
| } else { | ||
| loadFileCallback(loadedFile); | ||
| } | ||
| } | ||
| else if (promise) { | ||
| } else if (promise) { | ||
| promise.then(loadFileCallback, fileParsedFunc); | ||
| } | ||
| }; | ||
| return ImportManager; | ||
| }()); | ||
| } | ||
| } | ||
| return ImportManager; | ||
| } | ||
| exports.default = default_1; | ||
| //# sourceMappingURL=import-manager.js.map |
+65
-65
@@ -1,48 +0,48 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var environment_1 = tslib_1.__importDefault(require("./environment/environment")); | ||
| var data_1 = tslib_1.__importDefault(require("./data")); | ||
| var tree_1 = tslib_1.__importDefault(require("./tree")); | ||
| var abstract_file_manager_1 = tslib_1.__importDefault(require("./environment/abstract-file-manager")); | ||
| var abstract_plugin_loader_1 = tslib_1.__importDefault(require("./environment/abstract-plugin-loader")); | ||
| var visitors_1 = tslib_1.__importDefault(require("./visitors")); | ||
| var parser_1 = tslib_1.__importDefault(require("./parser/parser")); | ||
| var functions_1 = tslib_1.__importDefault(require("./functions")); | ||
| var contexts_1 = tslib_1.__importDefault(require("./contexts")); | ||
| var less_error_1 = tslib_1.__importDefault(require("./less-error")); | ||
| var transform_tree_1 = tslib_1.__importDefault(require("./transform-tree")); | ||
| var utils = tslib_1.__importStar(require("./utils")); | ||
| var plugin_manager_1 = tslib_1.__importDefault(require("./plugin-manager")); | ||
| var logger_1 = tslib_1.__importDefault(require("./logger")); | ||
| var source_map_output_1 = tslib_1.__importDefault(require("./source-map-output")); | ||
| var source_map_builder_1 = tslib_1.__importDefault(require("./source-map-builder")); | ||
| var parse_tree_1 = tslib_1.__importDefault(require("./parse-tree")); | ||
| var import_manager_1 = tslib_1.__importDefault(require("./import-manager")); | ||
| var parse_1 = tslib_1.__importDefault(require("./parse")); | ||
| var render_1 = tslib_1.__importDefault(require("./render")); | ||
| var package_json_1 = require("../../package.json"); | ||
| var parse_node_version_1 = tslib_1.__importDefault(require("parse-node-version")); | ||
| function default_1(environment, fileManagers) { | ||
| var sourceMapOutput, sourceMapBuilder, parseTree, importManager; | ||
| environment = new environment_1.default(environment, fileManagers); | ||
| sourceMapOutput = (0, source_map_output_1.default)(environment); | ||
| sourceMapBuilder = (0, source_map_builder_1.default)(sourceMapOutput, environment); | ||
| parseTree = (0, parse_tree_1.default)(sourceMapBuilder); | ||
| importManager = (0, import_manager_1.default)(environment); | ||
| var render = (0, render_1.default)(environment, parseTree, importManager); | ||
| var parse = (0, parse_1.default)(environment, parseTree, importManager); | ||
| var v = (0, parse_node_version_1.default)("v".concat(package_json_1.version)); | ||
| var initial = { | ||
| import Environment from './environment/environment.js'; | ||
| import data from './data/index.js'; | ||
| import tree from './tree/index.js'; | ||
| import AbstractFileManager from './environment/abstract-file-manager.js'; | ||
| import AbstractPluginLoader from './environment/abstract-plugin-loader.js'; | ||
| import visitors from './visitors/index.js'; | ||
| import Parser from './parser/parser.js'; | ||
| import functions from './functions/index.js'; | ||
| import contexts from './contexts.js'; | ||
| import LessError from './less-error.js'; | ||
| import transformTree from './transform-tree.js'; | ||
| import * as utils from './utils.js'; | ||
| import PluginManager from './plugin-manager.js'; | ||
| import logger from './logger.js'; | ||
| import SourceMapOutput from './source-map-output.js'; | ||
| import SourceMapBuilder from './source-map-builder.js'; | ||
| import ParseTree from './parse-tree.js'; | ||
| import ImportManager from './import-manager.js'; | ||
| import Parse from './parse.js'; | ||
| import Render from './render.js'; | ||
| import parseVersion from 'parse-node-version'; | ||
| export default function(environment, fileManagers, version = '0.0.0') { | ||
| let sourceMapOutput, sourceMapBuilder, parseTree, importManager; | ||
| environment = new Environment(environment, fileManagers); | ||
| sourceMapOutput = SourceMapOutput(environment); | ||
| sourceMapBuilder = SourceMapBuilder(sourceMapOutput, environment); | ||
| parseTree = ParseTree(sourceMapBuilder); | ||
| importManager = ImportManager(environment); | ||
| const render = Render(environment, parseTree, importManager); | ||
| const parse = Parse(environment, parseTree, importManager); | ||
| const v = parseVersion(`v${version}`); | ||
| const initial = { | ||
| version: [v.major, v.minor, v.patch], | ||
| data: data_1.default, | ||
| tree: tree_1.default, | ||
| Environment: environment_1.default, | ||
| AbstractFileManager: abstract_file_manager_1.default, | ||
| AbstractPluginLoader: abstract_plugin_loader_1.default, | ||
| environment: environment, | ||
| visitors: visitors_1.default, | ||
| Parser: parser_1.default, | ||
| functions: (0, functions_1.default)(environment), | ||
| contexts: contexts_1.default, | ||
| data, | ||
| tree, | ||
| Environment, | ||
| AbstractFileManager, | ||
| AbstractPluginLoader, | ||
| environment, | ||
| visitors, | ||
| Parser, | ||
| functions: functions(environment), | ||
| contexts, | ||
| SourceMapOutput: sourceMapOutput, | ||
@@ -52,21 +52,21 @@ SourceMapBuilder: sourceMapBuilder, | ||
| ImportManager: importManager, | ||
| render: render, | ||
| parse: parse, | ||
| LessError: less_error_1.default, | ||
| transformTree: transform_tree_1.default, | ||
| utils: utils, | ||
| PluginManager: plugin_manager_1.default, | ||
| logger: logger_1.default | ||
| render, | ||
| parse, | ||
| LessError, | ||
| transformTree, | ||
| utils, | ||
| PluginManager, | ||
| logger | ||
| }; | ||
| // Create a public API | ||
| var ctor = function (t) { | ||
| return function () { | ||
| var obj = Object.create(t.prototype); | ||
| t.apply(obj, Array.prototype.slice.call(arguments, 0)); | ||
| return obj; | ||
| const ctor = function(t) { | ||
| return function(...args) { | ||
| return new t(...args); | ||
| }; | ||
| }; | ||
| var t; | ||
| var api = Object.create(initial); | ||
| for (var n in initial.tree) { | ||
| let t; | ||
| const api = Object.create(initial); | ||
| for (const n in initial.tree) { | ||
| /* eslint guard-for-in: 0 */ | ||
@@ -79,3 +79,3 @@ t = initial.tree[n]; | ||
| api[n] = Object.create(null); | ||
| for (var o in t) { | ||
| for (const o in t) { | ||
| /* eslint guard-for-in: 0 */ | ||
@@ -86,6 +86,7 @@ api[n][o.toLowerCase()] = ctor(t[o]); | ||
| } | ||
| /** | ||
| * Some of the functions assume a `this` context of the API object, | ||
| * which causes it to fail when wrapped for ES6 imports. | ||
| * | ||
| * | ||
| * An assumed `this` should be removed in the future. | ||
@@ -95,5 +96,4 @@ */ | ||
| initial.render = initial.render.bind(api); | ||
| return api; | ||
| } | ||
| exports.default = default_1; | ||
| //# sourceMappingURL=index.js.map |
+63
-45
@@ -1,6 +0,5 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var utils = tslib_1.__importStar(require("./utils")); | ||
| var anonymousFunc = /(<anonymous>|Function):(\d+):(\d+)/; | ||
| import * as utils from './utils.js'; | ||
| const anonymousFunc = /(<anonymous>|Function):(\d+):(\d+)/; | ||
| /** | ||
@@ -28,16 +27,21 @@ * This is a centralized class of any error that could be thrown internally (mostly by the parser). | ||
| */ | ||
| var LessError = function (e, fileContentMap, currentFilename) { | ||
| const LessError = function(e, fileContentMap, currentFilename) { | ||
| Error.call(this); | ||
| var filename = e.filename || currentFilename; | ||
| const filename = e.filename || currentFilename; | ||
| this.message = e.message; | ||
| this.stack = e.stack; | ||
| // Set type early so it's always available, even if fileContentMap is missing | ||
| this.type = e.type || 'Syntax'; | ||
| if (fileContentMap && filename) { | ||
| var input = fileContentMap.contents[filename]; | ||
| var loc = utils.getLocation(e.index, input); | ||
| const input = fileContentMap.contents[filename]; | ||
| const loc = utils.getLocation(e.index, input); | ||
| var line = loc.line; | ||
| var col = loc.column; | ||
| var callLine = e.call && utils.getLocation(e.call, input).line; | ||
| var lines = input ? input.split('\n') : ''; | ||
| const col = loc.column; | ||
| const callLine = e.call && utils.getLocation(e.call, input).line; | ||
| const lines = input ? input.split('\n') : ''; | ||
| this.filename = filename; | ||
@@ -47,4 +51,6 @@ this.index = e.index; | ||
| this.column = col; | ||
| if (!this.line && this.stack) { | ||
| var found = this.stack.match(anonymousFunc); | ||
| const found = this.stack.match(anonymousFunc); | ||
| /** | ||
@@ -57,11 +63,11 @@ * We have to figure out how this environment stringifies anonymous functions | ||
| */ | ||
| var func = new Function('a', 'throw new Error()'); | ||
| var lineAdjust = 0; | ||
| const func = new Function('a', 'throw new Error()'); | ||
| let lineAdjust = 0; | ||
| try { | ||
| func(); | ||
| } | ||
| catch (e) { | ||
| var match = e.stack.match(anonymousFunc); | ||
| } catch (e) { | ||
| const match = e.stack.match(anonymousFunc); | ||
| lineAdjust = 1 - parseInt(match[2]); | ||
| } | ||
| if (found) { | ||
@@ -76,4 +82,6 @@ if (found[2]) { | ||
| } | ||
| this.callLine = callLine + 1; | ||
| this.callExtract = lines[callLine]; | ||
| this.extract = [ | ||
@@ -85,12 +93,15 @@ lines[this.line - 2], | ||
| } | ||
| }; | ||
| if (typeof Object.create === 'undefined') { | ||
| var F = function () { }; | ||
| const F = function () {}; | ||
| F.prototype = Error.prototype; | ||
| LessError.prototype = new F(); | ||
| } | ||
| else { | ||
| } else { | ||
| LessError.prototype = Object.create(Error.prototype); | ||
| } | ||
| LessError.prototype.constructor = LessError; | ||
| /** | ||
@@ -103,28 +114,30 @@ * An overridden version of the default Object.prototype.toString | ||
| */ | ||
| LessError.prototype.toString = function (options) { | ||
| var _a; | ||
| LessError.prototype.toString = function(options) { | ||
| options = options || {}; | ||
| var isWarning = ((_a = this.type) !== null && _a !== void 0 ? _a : '').toLowerCase().includes('warning'); | ||
| var type = isWarning ? this.type : "".concat(this.type, "Error"); | ||
| var color = isWarning ? 'yellow' : 'red'; | ||
| var message = ''; | ||
| var extract = this.extract || []; | ||
| var error = []; | ||
| var stylize = function (str) { return str; }; | ||
| const isWarning = (this.type ?? '').toLowerCase().includes('warning'); | ||
| const type = isWarning ? this.type : `${this.type}Error`; | ||
| const color = isWarning ? 'yellow' : 'red'; | ||
| let message = ''; | ||
| const extract = this.extract || []; | ||
| let error = []; | ||
| let stylize = function (str) { return str; }; | ||
| if (options.stylize) { | ||
| var type_1 = typeof options.stylize; | ||
| if (type_1 !== 'function') { | ||
| throw Error("options.stylize should be a function, got a ".concat(type_1, "!")); | ||
| const type = typeof options.stylize; | ||
| if (type !== 'function') { | ||
| throw Error(`options.stylize should be a function, got a ${type}!`); | ||
| } | ||
| stylize = options.stylize; | ||
| } | ||
| if (this.line !== null) { | ||
| if (!isWarning && typeof extract[0] === 'string') { | ||
| error.push(stylize("".concat(this.line - 1, " ").concat(extract[0]), 'grey')); | ||
| error.push(stylize(`${this.line - 1} ${extract[0]}`, 'grey')); | ||
| } | ||
| if (typeof extract[1] === 'string') { | ||
| var errorTxt = "".concat(this.line, " "); | ||
| let errorTxt = `${this.line} `; | ||
| if (extract[1]) { | ||
| errorTxt += extract[1].slice(0, this.column) + | ||
| stylize(stylize(stylize(extract[1].substr(this.column, 1), 'bold') + | ||
| stylize(stylize(stylize(extract[1].slice(this.column, this.column + 1), 'bold') + | ||
| extract[1].slice(this.column + 1), 'red'), 'inverse'); | ||
@@ -134,8 +147,10 @@ } | ||
| } | ||
| if (!isWarning && typeof extract[2] === 'string') { | ||
| error.push(stylize("".concat(this.line + 1, " ").concat(extract[2]), 'grey')); | ||
| error.push(stylize(`${this.line + 1} ${extract[2]}`, 'grey')); | ||
| } | ||
| error = "".concat(error.join('\n') + stylize('', 'reset'), "\n"); | ||
| error = `${error.join('\n') + stylize('', 'reset')}\n`; | ||
| } | ||
| message += stylize("".concat(type, ": ").concat(this.message), color); | ||
| message += stylize(`${type}: ${this.message}`, color); | ||
| if (this.filename) { | ||
@@ -145,12 +160,15 @@ message += stylize(' in ', color) + this.filename; | ||
| if (this.line) { | ||
| message += stylize(" on line ".concat(this.line, ", column ").concat(this.column + 1, ":"), 'grey'); | ||
| message += stylize(` on line ${this.line}, column ${this.column + 1}:`, 'grey'); | ||
| } | ||
| message += "\n".concat(error); | ||
| message += `\n${error}`; | ||
| if (this.callLine) { | ||
| message += "".concat(stylize('from ', color) + (this.filename || ''), "/n"); | ||
| message += "".concat(stylize(this.callLine, 'grey'), " ").concat(this.callExtract, "/n"); | ||
| message += `${stylize('from ', color) + (this.filename || '')}/n`; | ||
| message += `${stylize(this.callLine, 'grey')} ${this.callExtract}/n`; | ||
| } | ||
| return message; | ||
| }; | ||
| exports.default = LessError; | ||
| //# sourceMappingURL=less-error.js.map | ||
| export default LessError; |
+11
-14
@@ -1,21 +0,19 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.default = { | ||
| error: function (msg) { | ||
| export default { | ||
| error: function(msg) { | ||
| this._fireEvent('error', msg); | ||
| }, | ||
| warn: function (msg) { | ||
| warn: function(msg) { | ||
| this._fireEvent('warn', msg); | ||
| }, | ||
| info: function (msg) { | ||
| info: function(msg) { | ||
| this._fireEvent('info', msg); | ||
| }, | ||
| debug: function (msg) { | ||
| debug: function(msg) { | ||
| this._fireEvent('debug', msg); | ||
| }, | ||
| addListener: function (listener) { | ||
| addListener: function(listener) { | ||
| this._listeners.push(listener); | ||
| }, | ||
| removeListener: function (listener) { | ||
| for (var i = 0; i < this._listeners.length; i++) { | ||
| removeListener: function(listener) { | ||
| for (let i = 0; i < this._listeners.length; i++) { | ||
| if (this._listeners[i] === listener) { | ||
@@ -27,5 +25,5 @@ this._listeners.splice(i, 1); | ||
| }, | ||
| _fireEvent: function (type, msg) { | ||
| for (var i = 0; i < this._listeners.length; i++) { | ||
| var logFunction = this._listeners[i][type]; | ||
| _fireEvent: function(type, msg) { | ||
| for (let i = 0; i < this._listeners.length; i++) { | ||
| const logFunction = this._listeners[i][type]; | ||
| if (logFunction) { | ||
@@ -38,2 +36,1 @@ logFunction(msg); | ||
| }; | ||
| //# sourceMappingURL=logger.js.map |
+52
-53
@@ -1,36 +0,36 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var less_error_1 = tslib_1.__importDefault(require("./less-error")); | ||
| var transform_tree_1 = tslib_1.__importDefault(require("./transform-tree")); | ||
| var logger_1 = tslib_1.__importDefault(require("./logger")); | ||
| function default_1(SourceMapBuilder) { | ||
| var ParseTree = /** @class */ (function () { | ||
| function ParseTree(root, imports) { | ||
| import LessError from './less-error.js'; | ||
| import transformTree from './transform-tree.js'; | ||
| import logger from './logger.js'; | ||
| export default function(SourceMapBuilder) { | ||
| class ParseTree { | ||
| constructor(root, imports) { | ||
| this.root = root; | ||
| this.imports = imports; | ||
| } | ||
| ParseTree.prototype.toCSS = function (options) { | ||
| var evaldRoot; | ||
| var result = {}; | ||
| var sourceMapBuilder; | ||
| toCSS(options) { | ||
| let evaldRoot; | ||
| const result = {}; | ||
| let sourceMapBuilder; | ||
| try { | ||
| evaldRoot = (0, transform_tree_1.default)(this.root, options); | ||
| evaldRoot = transformTree(this.root, options); | ||
| } catch (e) { | ||
| throw new LessError(e, this.imports); | ||
| } | ||
| catch (e) { | ||
| throw new less_error_1.default(e, this.imports); | ||
| } | ||
| try { | ||
| var compress = Boolean(options.compress); | ||
| const compress = Boolean(options.compress); | ||
| if (compress) { | ||
| logger_1.default.warn('The compress option has been deprecated. ' + | ||
| logger.warn('The compress option has been deprecated. ' + | ||
| 'We recommend you use a dedicated css minifier, for instance see less-plugin-clean-css.'); | ||
| } | ||
| var toCSSOptions = { | ||
| compress: compress, | ||
| const toCSSOptions = { | ||
| compress, | ||
| // @deprecated The dumpLineNumbers option is deprecated. Use sourcemaps instead. All modes will be removed in a future version. | ||
| dumpLineNumbers: options.dumpLineNumbers, | ||
| strictUnits: Boolean(options.strictUnits), | ||
| numPrecision: 8 | ||
| }; | ||
| numPrecision: 8}; | ||
| if (options.sourceMap) { | ||
@@ -41,3 +41,4 @@ // Normalize sourceMap option: if it's just true, convert to object | ||
| } | ||
| var sourceMapOpts = options.sourceMap; | ||
| const sourceMapOpts = options.sourceMap; | ||
| // Set sourceMapInputFilename if not set and filename is available | ||
@@ -47,2 +48,3 @@ if (!sourceMapOpts.sourceMapInputFilename && options.filename) { | ||
| } | ||
| // Default sourceMapBasepath to the input file's directory if not set | ||
@@ -52,7 +54,6 @@ // This matches the behavior documented and implemented in bin/lessc | ||
| // Get directory from filename using string manipulation (works cross-platform) | ||
| var lastSlash = Math.max(options.filename.lastIndexOf('/'), options.filename.lastIndexOf('\\')); | ||
| const lastSlash = Math.max(options.filename.lastIndexOf('/'), options.filename.lastIndexOf('\\')); | ||
| if (lastSlash >= 0) { | ||
| sourceMapOpts.sourceMapBasepath = options.filename.substring(0, lastSlash); | ||
| } | ||
| else { | ||
| } else { | ||
| // No directory separator found, use current directory | ||
@@ -62,2 +63,3 @@ sourceMapOpts.sourceMapBasepath = '.'; | ||
| } | ||
| // Handle sourceMapFullFilename (CLI-specific: --source-map=filename) | ||
@@ -70,7 +72,6 @@ // This is converted to sourceMapFilename and sourceMapOutputFilename | ||
| // Extract just the basename for the sourceMappingURL comment | ||
| var mapBase = sourceMapOpts.sourceMapFullFilename.split(/[/\\]/).pop(); | ||
| const mapBase = sourceMapOpts.sourceMapFullFilename.split(/[/\\]/).pop(); | ||
| sourceMapOpts.sourceMapFilename = mapBase; | ||
| } | ||
| } | ||
| else if (!sourceMapOpts.sourceMapFilename && !sourceMapOpts.sourceMapURL) { | ||
| } else if (!sourceMapOpts.sourceMapFilename && !sourceMapOpts.sourceMapURL) { | ||
| // If sourceMapFilename is not set and sourceMapURL is not set, | ||
@@ -81,33 +82,32 @@ // derive it from the output filename (if available) or input filename | ||
| sourceMapOpts.sourceMapFilename = sourceMapOpts.sourceMapOutputFilename + '.map'; | ||
| } else if (options.filename) { | ||
| // Fallback to input filename + .css.map (basename only) | ||
| const inputBasename = options.filename.split(/[/\\]/).pop().replace(/\.[^/.]+$/, ''); | ||
| sourceMapOpts.sourceMapFilename = inputBasename + '.css.map'; | ||
| } | ||
| else if (options.filename) { | ||
| // Fallback to input filename + .css.map | ||
| var inputBase = options.filename.replace(/\.[^/.]+$/, ''); | ||
| sourceMapOpts.sourceMapFilename = inputBase + '.css.map'; | ||
| } | ||
| } | ||
| // Default sourceMapOutputFilename if not set | ||
| if (!sourceMapOpts.sourceMapOutputFilename) { | ||
| if (options.filename) { | ||
| var inputBase = options.filename.replace(/\.[^/.]+$/, ''); | ||
| sourceMapOpts.sourceMapOutputFilename = inputBase + '.css'; | ||
| } | ||
| else { | ||
| const inputBasename = options.filename.split(/[/\\]/).pop().replace(/\.[^/.]+$/, ''); | ||
| sourceMapOpts.sourceMapOutputFilename = inputBasename + '.css'; | ||
| } else { | ||
| sourceMapOpts.sourceMapOutputFilename = 'output.css'; | ||
| } | ||
| } | ||
| sourceMapBuilder = new SourceMapBuilder(sourceMapOpts); | ||
| result.css = sourceMapBuilder.toCSS(evaldRoot, toCSSOptions, this.imports); | ||
| } | ||
| else { | ||
| } else { | ||
| result.css = evaldRoot.toCSS(toCSSOptions); | ||
| } | ||
| } catch (e) { | ||
| throw new LessError(e, this.imports); | ||
| } | ||
| catch (e) { | ||
| throw new less_error_1.default(e, this.imports); | ||
| } | ||
| if (options.pluginManager) { | ||
| var postProcessors = options.pluginManager.getPostProcessors(); | ||
| for (var i = 0; i < postProcessors.length; i++) { | ||
| result.css = postProcessors[i].process(result.css, { sourceMap: sourceMapBuilder, options: options, imports: this.imports }); | ||
| const postProcessors = options.pluginManager.getPostProcessors(); | ||
| for (let i = 0; i < postProcessors.length; i++) { | ||
| result.css = postProcessors[i].process(result.css, { sourceMap: sourceMapBuilder, options, imports: this.imports }); | ||
| } | ||
@@ -118,4 +118,5 @@ } | ||
| } | ||
| result.imports = []; | ||
| for (var file in this.imports.files) { | ||
| for (const file in this.imports.files) { | ||
| if (Object.prototype.hasOwnProperty.call(this.imports.files, file) && file !== this.imports.rootFilename) { | ||
@@ -126,8 +127,6 @@ result.imports.push(file); | ||
| return result; | ||
| }; | ||
| return ParseTree; | ||
| }()); | ||
| } | ||
| } | ||
| return ParseTree; | ||
| } | ||
| exports.default = default_1; | ||
| //# sourceMappingURL=parse-tree.js.map |
+44
-44
@@ -1,11 +0,10 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var contexts_1 = tslib_1.__importDefault(require("./contexts")); | ||
| var parser_1 = tslib_1.__importDefault(require("./parser/parser")); | ||
| var plugin_manager_1 = tslib_1.__importDefault(require("./plugin-manager")); | ||
| var less_error_1 = tslib_1.__importDefault(require("./less-error")); | ||
| var utils = tslib_1.__importStar(require("./utils")); | ||
| function default_1(environment, ParseTree, ImportManager) { | ||
| var parse = function (input, options, callback) { | ||
| import contexts from './contexts.js'; | ||
| import Parser from './parser/parser.js'; | ||
| import PluginManager from './plugin-manager.js'; | ||
| import LessError from './less-error.js'; | ||
| import * as utils from './utils.js'; | ||
| export default function(environment, ParseTree, ImportManager) { | ||
| const parse = function (input, options, callback) { | ||
| if (typeof options === 'function') { | ||
@@ -18,10 +17,10 @@ callback = options; | ||
| } | ||
| if (!callback) { | ||
| var self_1 = this; | ||
| const self = this; | ||
| return new Promise(function (resolve, reject) { | ||
| parse.call(self_1, input, options, function (err, output) { | ||
| parse.call(self, input, options, function(err, output) { | ||
| if (err) { | ||
| reject(err); | ||
| } | ||
| else { | ||
| } else { | ||
| resolve(output); | ||
@@ -31,21 +30,22 @@ } | ||
| }); | ||
| } | ||
| else { | ||
| var context_1; | ||
| var rootFileInfo = void 0; | ||
| var pluginManager_1 = new plugin_manager_1.default(this, !options.reUsePluginManager); | ||
| options.pluginManager = pluginManager_1; | ||
| context_1 = new contexts_1.default.Parse(options); | ||
| } else { | ||
| let context; | ||
| let rootFileInfo; | ||
| const pluginManager = new PluginManager(this, !options.reUsePluginManager); | ||
| options.pluginManager = pluginManager; | ||
| context = new contexts.Parse(options); | ||
| if (options.rootFileInfo) { | ||
| rootFileInfo = options.rootFileInfo; | ||
| } | ||
| else { | ||
| var filename = options.filename || 'input'; | ||
| var entryPath = filename.replace(/[^/\\]*$/, ''); | ||
| } else { | ||
| const filename = options.filename || 'input'; | ||
| const entryPath = filename.replace(/[^/\\]*$/, ''); | ||
| rootFileInfo = { | ||
| filename: filename, | ||
| rewriteUrls: context_1.rewriteUrls, | ||
| rootpath: context_1.rootpath || '', | ||
| filename, | ||
| rewriteUrls: context.rewriteUrls, | ||
| rootpath: context.rootpath || '', | ||
| currentDirectory: entryPath, | ||
| entryPath: entryPath, | ||
| entryPath, | ||
| rootFilename: filename | ||
@@ -58,13 +58,16 @@ }; | ||
| } | ||
| var imports_1 = new ImportManager(this, context_1, rootFileInfo); | ||
| this.importManager = imports_1; | ||
| const imports = new ImportManager(this, context, rootFileInfo); | ||
| this.importManager = imports; | ||
| // TODO: allow the plugins to be just a list of paths or names | ||
| // Do an async plugin queue like lessc | ||
| if (options.plugins) { | ||
| options.plugins.forEach(function (plugin) { | ||
| var evalResult, contents; | ||
| options.plugins.forEach(function(plugin) { | ||
| let evalResult, contents; | ||
| if (plugin.fileContent) { | ||
| contents = plugin.fileContent.replace(/^\uFEFF/, ''); | ||
| evalResult = pluginManager_1.Loader.evalPlugin(contents, context_1, imports_1, plugin.options, plugin.filename); | ||
| if (evalResult instanceof less_error_1.default) { | ||
| evalResult = pluginManager.Loader.evalPlugin(contents, context, imports, plugin.options, plugin.filename); | ||
| if (evalResult instanceof LessError) { | ||
| return callback(evalResult); | ||
@@ -74,13 +77,12 @@ } | ||
| else { | ||
| pluginManager_1.addPlugin(plugin); | ||
| pluginManager.addPlugin(plugin); | ||
| } | ||
| }); | ||
| } | ||
| new parser_1.default(context_1, imports_1, rootFileInfo) | ||
| new Parser(context, imports, rootFileInfo) | ||
| .parse(input, function (e, root) { | ||
| if (e) { | ||
| return callback(e); | ||
| } | ||
| callback(null, root, imports_1, options); | ||
| }, options); | ||
| if (e) { return callback(e); } | ||
| callback(null, root, imports, options); | ||
| }, options); | ||
| } | ||
@@ -90,3 +92,1 @@ }; | ||
| } | ||
| exports.default = default_1; | ||
| //# sourceMappingURL=parse.js.map |
+151
-113
@@ -1,46 +0,55 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.default = (function () { | ||
| var // Less input string | ||
| input; | ||
| var // current chunk | ||
| j; | ||
| var // holds state for backtracking | ||
| saveStack = []; | ||
| var // furthest index the parser has gone to | ||
| furthest; | ||
| var // if this is furthest we got to, this is the probably cause | ||
| furthestPossibleErrorMessage; | ||
| var // chunkified input | ||
| chunks; | ||
| var // current chunk | ||
| current; | ||
| var // index of current chunk, in `input` | ||
| currentPos; | ||
| var parserInput = {}; | ||
| var CHARCODE_SPACE = 32; | ||
| var CHARCODE_TAB = 9; | ||
| var CHARCODE_LF = 10; | ||
| var CHARCODE_CR = 13; | ||
| var CHARCODE_PLUS = 43; | ||
| var CHARCODE_COMMA = 44; | ||
| var CHARCODE_FORWARD_SLASH = 47; | ||
| var CHARCODE_9 = 57; | ||
| export default () => { | ||
| let // Less input string | ||
| input; | ||
| let // current chunk | ||
| j; | ||
| const // holds state for backtracking | ||
| saveStack = []; | ||
| let // furthest index the parser has gone to | ||
| furthest; | ||
| let // if this is furthest we got to, this is the probably cause | ||
| furthestPossibleErrorMessage; | ||
| let // chunkified input | ||
| chunks; | ||
| let // current chunk | ||
| current; | ||
| let // index of current chunk, in `input` | ||
| currentPos; | ||
| const parserInput = {}; | ||
| const CHARCODE_SPACE = 32; | ||
| const CHARCODE_TAB = 9; | ||
| const CHARCODE_LF = 10; | ||
| const CHARCODE_CR = 13; | ||
| const CHARCODE_PLUS = 43; | ||
| const CHARCODE_COMMA = 44; | ||
| const CHARCODE_FORWARD_SLASH = 47; | ||
| const CHARCODE_9 = 57; | ||
| function skipWhitespace(length) { | ||
| var oldi = parserInput.i; | ||
| var oldj = j; | ||
| var curr = parserInput.i - currentPos; | ||
| var endIndex = parserInput.i + current.length - curr; | ||
| var mem = (parserInput.i += length); | ||
| var inp = input; | ||
| var c; | ||
| var nextChar; | ||
| var comment; | ||
| const oldi = parserInput.i; | ||
| const oldj = j; | ||
| const curr = parserInput.i - currentPos; | ||
| const endIndex = parserInput.i + current.length - curr; | ||
| const mem = (parserInput.i += length); | ||
| const inp = input; | ||
| let c; | ||
| let nextChar; | ||
| let comment; | ||
| for (; parserInput.i < endIndex; parserInput.i++) { | ||
| c = inp.charCodeAt(parserInput.i); | ||
| if (parserInput.autoCommentAbsorb && c === CHARCODE_FORWARD_SLASH) { | ||
| nextChar = inp.charAt(parserInput.i + 1); | ||
| if (nextChar === '/') { | ||
| comment = { index: parserInput.i, isLineComment: true }; | ||
| var nextNewLine = inp.indexOf('\n', parserInput.i + 2); | ||
| comment = {index: parserInput.i, isLineComment: true}; | ||
| let nextNewLine = inp.indexOf('\n', parserInput.i + 2); | ||
| if (nextNewLine < 0) { | ||
@@ -50,12 +59,11 @@ nextNewLine = endIndex; | ||
| parserInput.i = nextNewLine; | ||
| comment.text = inp.substr(comment.index, parserInput.i - comment.index); | ||
| comment.text = inp.slice(comment.index, parserInput.i); | ||
| parserInput.commentStore.push(comment); | ||
| continue; | ||
| } | ||
| else if (nextChar === '*') { | ||
| var nextStarSlash = inp.indexOf('*/', parserInput.i + 2); | ||
| } else if (nextChar === '*') { | ||
| const nextStarSlash = inp.indexOf('*/', parserInput.i + 2); | ||
| if (nextStarSlash >= 0) { | ||
| comment = { | ||
| index: parserInput.i, | ||
| text: inp.substr(parserInput.i, nextStarSlash + 2 - parserInput.i), | ||
| text: inp.slice(parserInput.i, nextStarSlash + 2), | ||
| isLineComment: false | ||
@@ -70,2 +78,3 @@ }; | ||
| } | ||
| if ((c !== CHARCODE_SPACE) && (c !== CHARCODE_LF) && (c !== CHARCODE_TAB) && (c !== CHARCODE_CR)) { | ||
@@ -75,4 +84,6 @@ break; | ||
| } | ||
| current = current.slice(length + parserInput.i - mem + curr); | ||
| currentPos = parserInput.i; | ||
| if (!current.length) { | ||
@@ -86,9 +97,12 @@ if (j < chunks.length - 1) { | ||
| } | ||
| return oldi !== parserInput.i || oldj !== j; | ||
| } | ||
| parserInput.save = function () { | ||
| parserInput.save = () => { | ||
| currentPos = parserInput.i; | ||
| saveStack.push({ current: current, i: parserInput.i, j: j }); | ||
| saveStack.push( { current, i: parserInput.i, j }); | ||
| }; | ||
| parserInput.restore = function (possibleErrorMessage) { | ||
| parserInput.restore = possibleErrorMessage => { | ||
| if (parserInput.i > furthest || (parserInput.i === furthest && possibleErrorMessage && !furthestPossibleErrorMessage)) { | ||
@@ -98,3 +112,3 @@ furthest = parserInput.i; | ||
| } | ||
| var state = saveStack.pop(); | ||
| const state = saveStack.pop(); | ||
| current = state.current; | ||
@@ -104,12 +118,13 @@ currentPos = parserInput.i = state.i; | ||
| }; | ||
| parserInput.forget = function () { | ||
| parserInput.forget = () => { | ||
| saveStack.pop(); | ||
| }; | ||
| parserInput.isWhitespace = function (offset) { | ||
| var pos = parserInput.i + (offset || 0); | ||
| var code = input.charCodeAt(pos); | ||
| parserInput.isWhitespace = offset => { | ||
| const pos = parserInput.i + (offset || 0); | ||
| const code = input.charCodeAt(pos); | ||
| return (code === CHARCODE_SPACE || code === CHARCODE_CR || code === CHARCODE_TAB || code === CHARCODE_LF); | ||
| }; | ||
| // Specialization of $(tok) | ||
| parserInput.$re = function (tok) { | ||
| parserInput.$re = tok => { | ||
| if (parserInput.i > currentPos) { | ||
@@ -119,6 +134,8 @@ current = current.slice(parserInput.i - currentPos); | ||
| } | ||
| var m = tok.exec(current); | ||
| const m = tok.exec(current); | ||
| if (!m) { | ||
| return null; | ||
| } | ||
| skipWhitespace(m[0].length); | ||
@@ -128,5 +145,7 @@ if (typeof m === 'string') { | ||
| } | ||
| return m.length === 1 ? m[0] : m; | ||
| }; | ||
| parserInput.$char = function (tok) { | ||
| parserInput.$char = tok => { | ||
| if (input.charAt(parserInput.i) !== tok) { | ||
@@ -138,3 +157,4 @@ return null; | ||
| }; | ||
| parserInput.$peekChar = function (tok) { | ||
| parserInput.$peekChar = tok => { | ||
| if (input.charAt(parserInput.i) !== tok) { | ||
@@ -145,6 +165,8 @@ return null; | ||
| }; | ||
| parserInput.$str = function (tok) { | ||
| var tokLength = tok.length; | ||
| parserInput.$str = tok => { | ||
| const tokLength = tok.length; | ||
| // https://jsperf.com/string-startswith/21 | ||
| for (var i = 0; i < tokLength; i++) { | ||
| for (let i = 0; i < tokLength; i++) { | ||
| if (input.charAt(parserInput.i + i) !== tok.charAt(i)) { | ||
@@ -154,15 +176,19 @@ return null; | ||
| } | ||
| skipWhitespace(tokLength); | ||
| return tok; | ||
| }; | ||
| parserInput.$quoted = function (loc) { | ||
| var pos = loc || parserInput.i; | ||
| var startChar = input.charAt(pos); | ||
| parserInput.$quoted = loc => { | ||
| const pos = loc || parserInput.i; | ||
| const startChar = input.charAt(pos); | ||
| if (startChar !== '\'' && startChar !== '"') { | ||
| return; | ||
| } | ||
| var length = input.length; | ||
| var currentPosition = pos; | ||
| for (var i = 1; i + currentPosition < length; i++) { | ||
| var nextChar = input.charAt(i + currentPosition); | ||
| const length = input.length; | ||
| const currentPosition = pos; | ||
| for (let i = 1; i + currentPosition < length; i++) { | ||
| const nextChar = input.charAt(i + currentPosition); | ||
| switch (nextChar) { | ||
@@ -176,6 +202,6 @@ case '\\': | ||
| case startChar: { | ||
| var str = input.substr(currentPosition, i + 1); | ||
| const str = input.slice(currentPosition, currentPosition + i + 1); | ||
| if (!loc && loc !== 0) { | ||
| skipWhitespace(i + 1); | ||
| return str; | ||
| return str | ||
| } | ||
@@ -189,2 +215,3 @@ return [startChar, str]; | ||
| }; | ||
| /** | ||
@@ -194,25 +221,26 @@ * Permissive parsing. Ignores everything except matching {} [] () and quotes | ||
| */ | ||
| parserInput.$parseUntil = function (tok) { | ||
| var quote = ''; | ||
| var returnVal = null; | ||
| var inComment = false; | ||
| var blockDepth = 0; | ||
| var blockStack = []; | ||
| var parseGroups = []; | ||
| var length = input.length; | ||
| var startPos = parserInput.i; | ||
| var lastPos = parserInput.i; | ||
| var i = parserInput.i; | ||
| var loop = true; | ||
| var testChar; | ||
| parserInput.$parseUntil = tok => { | ||
| let quote = ''; | ||
| let returnVal = null; | ||
| let inComment = false; | ||
| let blockDepth = 0; | ||
| const blockStack = []; | ||
| const parseGroups = []; | ||
| const length = input.length; | ||
| const startPos = parserInput.i; | ||
| let lastPos = parserInput.i; | ||
| let i = parserInput.i; | ||
| let loop = true; | ||
| let testChar; | ||
| if (typeof tok === 'string') { | ||
| testChar = function (char) { return char === tok; }; | ||
| testChar = char => char === tok | ||
| } else { | ||
| testChar = char => tok.test(char) | ||
| } | ||
| else { | ||
| testChar = function (char) { return tok.test(char); }; | ||
| } | ||
| do { | ||
| var nextChar = input.charAt(i); | ||
| let nextChar = input.charAt(i); | ||
| if (blockDepth === 0 && testChar(nextChar)) { | ||
| returnVal = input.substr(lastPos, i - lastPos); | ||
| returnVal = input.slice(lastPos, i); | ||
| if (returnVal) { | ||
@@ -226,5 +254,4 @@ parseGroups.push(returnVal); | ||
| skipWhitespace(i - startPos); | ||
| loop = false; | ||
| } | ||
| else { | ||
| loop = false | ||
| } else { | ||
| if (inComment) { | ||
@@ -244,3 +271,3 @@ if (nextChar === '*' && | ||
| nextChar = input.charAt(i); | ||
| parseGroups.push(input.substr(lastPos, i - lastPos + 1)); | ||
| parseGroups.push(input.slice(lastPos, i + 1)); | ||
| lastPos = i + 1; | ||
@@ -259,3 +286,3 @@ break; | ||
| if (quote) { | ||
| parseGroups.push(input.substr(lastPos, i - lastPos), quote); | ||
| parseGroups.push(input.slice(lastPos, i), quote); | ||
| i += quote[1].length - 1; | ||
@@ -285,7 +312,6 @@ lastPos = i + 1; | ||
| case ']': { | ||
| var expected = blockStack.pop(); | ||
| const expected = blockStack.pop(); | ||
| if (nextChar === expected) { | ||
| blockDepth--; | ||
| } | ||
| else { | ||
| } else { | ||
| // move the parser to the error and return expected | ||
@@ -304,13 +330,16 @@ skipWhitespace(i - startPos); | ||
| } while (loop); | ||
| return returnVal ? returnVal : null; | ||
| }; | ||
| } | ||
| parserInput.autoCommentAbsorb = true; | ||
| parserInput.commentStore = []; | ||
| parserInput.finished = false; | ||
| // Same as $(), but don't change the state of the parser, | ||
| // just return the match. | ||
| parserInput.peek = function (tok) { | ||
| parserInput.peek = tok => { | ||
| if (typeof tok === 'string') { | ||
| // https://jsperf.com/string-startswith/21 | ||
| for (var i = 0; i < tok.length; i++) { | ||
| for (let i = 0; i < tok.length; i++) { | ||
| if (input.charAt(parserInput.i + i) !== tok.charAt(i)) { | ||
@@ -321,28 +350,37 @@ return false; | ||
| return true; | ||
| } | ||
| else { | ||
| } else { | ||
| return tok.test(current); | ||
| } | ||
| }; | ||
| // Specialization of peek() | ||
| // TODO remove or change some currentChar calls to peekChar | ||
| parserInput.peekChar = function (tok) { return input.charAt(parserInput.i) === tok; }; | ||
| parserInput.currentChar = function () { return input.charAt(parserInput.i); }; | ||
| parserInput.prevChar = function () { return input.charAt(parserInput.i - 1); }; | ||
| parserInput.getInput = function () { return input; }; | ||
| parserInput.peekNotNumeric = function () { | ||
| var c = input.charCodeAt(parserInput.i); | ||
| parserInput.peekChar = tok => input.charAt(parserInput.i) === tok; | ||
| parserInput.currentChar = () => input.charAt(parserInput.i); | ||
| parserInput.prevChar = () => input.charAt(parserInput.i - 1); | ||
| parserInput.getInput = () => input; | ||
| parserInput.peekNotNumeric = () => { | ||
| const c = input.charCodeAt(parserInput.i); | ||
| // Is the first char of the dimension 0-9, '.', '+' or '-' | ||
| return (c > CHARCODE_9 || c < CHARCODE_PLUS) || c === CHARCODE_FORWARD_SLASH || c === CHARCODE_COMMA; | ||
| }; | ||
| parserInput.start = function (str) { | ||
| parserInput.start = (str) => { | ||
| input = str; | ||
| parserInput.i = j = currentPos = furthest = 0; | ||
| chunks = [str]; | ||
| current = chunks[0]; | ||
| skipWhitespace(0); | ||
| }; | ||
| parserInput.end = function () { | ||
| var message; | ||
| var isFinished = parserInput.i >= input.length; | ||
| parserInput.end = () => { | ||
| let message; | ||
| const isFinished = parserInput.i >= input.length; | ||
| if (parserInput.i < furthest) { | ||
@@ -353,3 +391,3 @@ message = furthestPossibleErrorMessage; | ||
| return { | ||
| isFinished: isFinished, | ||
| isFinished, | ||
| furthest: parserInput.i, | ||
@@ -361,4 +399,4 @@ furthestPossibleErrorMessage: message, | ||
| }; | ||
| return parserInput; | ||
| }); | ||
| //# sourceMappingURL=parser-input.js.map | ||
| }; |
@@ -1,8 +0,6 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| /** | ||
| * Plugin Manager | ||
| */ | ||
| var PluginManager = /** @class */ (function () { | ||
| function PluginManager(less) { | ||
| class PluginManager { | ||
| constructor(less) { | ||
| this.less = less; | ||
@@ -18,2 +16,3 @@ this.visitors = []; | ||
| } | ||
| /** | ||
@@ -23,9 +22,10 @@ * Adds all the plugins in the array | ||
| */ | ||
| PluginManager.prototype.addPlugins = function (plugins) { | ||
| addPlugins(plugins) { | ||
| if (plugins) { | ||
| for (var i = 0; i < plugins.length; i++) { | ||
| for (let i = 0; i < plugins.length; i++) { | ||
| this.addPlugin(plugins[i]); | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| /** | ||
@@ -36,3 +36,3 @@ * | ||
| */ | ||
| PluginManager.prototype.addPlugin = function (plugin, filename, functionRegistry) { | ||
| addPlugin(plugin, filename, functionRegistry) { | ||
| this.installedPlugins.push(plugin); | ||
@@ -45,3 +45,4 @@ if (filename) { | ||
| } | ||
| }; | ||
| } | ||
| /** | ||
@@ -51,5 +52,6 @@ * | ||
| */ | ||
| PluginManager.prototype.get = function (filename) { | ||
| get(filename) { | ||
| return this.pluginCache[filename]; | ||
| }; | ||
| } | ||
| /** | ||
@@ -60,5 +62,6 @@ * Adds a visitor. The visitor object has options on itself to determine | ||
| */ | ||
| PluginManager.prototype.addVisitor = function (visitor) { | ||
| addVisitor(visitor) { | ||
| this.visitors.push(visitor); | ||
| }; | ||
| } | ||
| /** | ||
@@ -69,4 +72,4 @@ * Adds a pre processor object | ||
| */ | ||
| PluginManager.prototype.addPreProcessor = function (preProcessor, priority) { | ||
| var indexToInsertAt; | ||
| addPreProcessor(preProcessor, priority) { | ||
| let indexToInsertAt; | ||
| for (indexToInsertAt = 0; indexToInsertAt < this.preProcessors.length; indexToInsertAt++) { | ||
@@ -77,4 +80,5 @@ if (this.preProcessors[indexToInsertAt].priority >= priority) { | ||
| } | ||
| this.preProcessors.splice(indexToInsertAt, 0, { preProcessor: preProcessor, priority: priority }); | ||
| }; | ||
| this.preProcessors.splice(indexToInsertAt, 0, {preProcessor, priority}); | ||
| } | ||
| /** | ||
@@ -85,4 +89,4 @@ * Adds a post processor object | ||
| */ | ||
| PluginManager.prototype.addPostProcessor = function (postProcessor, priority) { | ||
| var indexToInsertAt; | ||
| addPostProcessor(postProcessor, priority) { | ||
| let indexToInsertAt; | ||
| for (indexToInsertAt = 0; indexToInsertAt < this.postProcessors.length; indexToInsertAt++) { | ||
@@ -93,4 +97,5 @@ if (this.postProcessors[indexToInsertAt].priority >= priority) { | ||
| } | ||
| this.postProcessors.splice(indexToInsertAt, 0, { postProcessor: postProcessor, priority: priority }); | ||
| }; | ||
| this.postProcessors.splice(indexToInsertAt, 0, {postProcessor, priority}); | ||
| } | ||
| /** | ||
@@ -100,5 +105,6 @@ * | ||
| */ | ||
| PluginManager.prototype.addFileManager = function (manager) { | ||
| addFileManager(manager) { | ||
| this.fileManagers.push(manager); | ||
| }; | ||
| } | ||
| /** | ||
@@ -109,9 +115,10 @@ * | ||
| */ | ||
| PluginManager.prototype.getPreProcessors = function () { | ||
| var preProcessors = []; | ||
| for (var i = 0; i < this.preProcessors.length; i++) { | ||
| getPreProcessors() { | ||
| const preProcessors = []; | ||
| for (let i = 0; i < this.preProcessors.length; i++) { | ||
| preProcessors.push(this.preProcessors[i].preProcessor); | ||
| } | ||
| return preProcessors; | ||
| }; | ||
| } | ||
| /** | ||
@@ -122,9 +129,10 @@ * | ||
| */ | ||
| PluginManager.prototype.getPostProcessors = function () { | ||
| var postProcessors = []; | ||
| for (var i = 0; i < this.postProcessors.length; i++) { | ||
| getPostProcessors() { | ||
| const postProcessors = []; | ||
| for (let i = 0; i < this.postProcessors.length; i++) { | ||
| postProcessors.push(this.postProcessors[i].postProcessor); | ||
| } | ||
| return postProcessors; | ||
| }; | ||
| } | ||
| /** | ||
@@ -135,13 +143,14 @@ * | ||
| */ | ||
| PluginManager.prototype.getVisitors = function () { | ||
| getVisitors() { | ||
| return this.visitors; | ||
| }; | ||
| PluginManager.prototype.visitor = function () { | ||
| var self = this; | ||
| } | ||
| visitor() { | ||
| const self = this; | ||
| return { | ||
| first: function () { | ||
| first: function() { | ||
| self.iterator = -1; | ||
| return self.visitors[self.iterator]; | ||
| }, | ||
| get: function () { | ||
| get: function() { | ||
| self.iterator += 1; | ||
@@ -151,3 +160,4 @@ return self.visitors[self.iterator]; | ||
| }; | ||
| }; | ||
| } | ||
| /** | ||
@@ -158,9 +168,10 @@ * | ||
| */ | ||
| PluginManager.prototype.getFileManagers = function () { | ||
| getFileManagers() { | ||
| return this.fileManagers; | ||
| }; | ||
| return PluginManager; | ||
| }()); | ||
| var pm; | ||
| var PluginManagerFactory = function (less, newFactory) { | ||
| } | ||
| } | ||
| let pm; | ||
| const PluginManagerFactory = function(less, newFactory) { | ||
| if (newFactory || !pm) { | ||
@@ -171,4 +182,4 @@ pm = new PluginManager(less); | ||
| }; | ||
| // | ||
| exports.default = PluginManagerFactory; | ||
| //# sourceMappingURL=plugin-manager.js.map | ||
| export default PluginManagerFactory; |
+17
-23
@@ -1,7 +0,5 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var utils = tslib_1.__importStar(require("./utils")); | ||
| function default_1(environment, ParseTree) { | ||
| var render = function (input, options, callback) { | ||
| import * as utils from './utils.js'; | ||
| export default function(environment, ParseTree) { | ||
| const render = function (input, options, callback) { | ||
| if (typeof options === 'function') { | ||
@@ -14,10 +12,10 @@ callback = options; | ||
| } | ||
| if (!callback) { | ||
| var self_1 = this; | ||
| const self = this; | ||
| return new Promise(function (resolve, reject) { | ||
| render.call(self_1, input, options, function (err, output) { | ||
| render.call(self, input, options, function(err, output) { | ||
| if (err) { | ||
| reject(err); | ||
| } | ||
| else { | ||
| } else { | ||
| resolve(output); | ||
@@ -27,16 +25,13 @@ } | ||
| }); | ||
| } | ||
| else { | ||
| this.parse(input, options, function (err, root, imports, options) { | ||
| if (err) { | ||
| return callback(err); | ||
| } | ||
| var result; | ||
| } else { | ||
| this.parse(input, options, function(err, root, imports, options) { | ||
| if (err) { return callback(err); } | ||
| let result; | ||
| try { | ||
| var parseTree = new ParseTree(root, imports); | ||
| const parseTree = new ParseTree(root, imports); | ||
| result = parseTree.toCSS(options); | ||
| } | ||
| catch (err) { | ||
| return callback(err); | ||
| } | ||
| catch (err) { return callback(err); } | ||
| callback(null, result); | ||
@@ -46,5 +41,4 @@ }); | ||
| }; | ||
| return render; | ||
| } | ||
| exports.default = default_1; | ||
| //# sourceMappingURL=render.js.map |
@@ -1,24 +0,25 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| function default_1(SourceMapOutput, environment) { | ||
| var SourceMapBuilder = /** @class */ (function () { | ||
| function SourceMapBuilder(options) { | ||
| export default function (SourceMapOutput, environment) { | ||
| class SourceMapBuilder { | ||
| constructor(options) { | ||
| this.options = options; | ||
| } | ||
| SourceMapBuilder.prototype.toCSS = function (rootNode, options, imports) { | ||
| var sourceMapOutput = new SourceMapOutput({ | ||
| contentsIgnoredCharsMap: imports.contentsIgnoredChars, | ||
| rootNode: rootNode, | ||
| contentsMap: imports.contents, | ||
| sourceMapFilename: this.options.sourceMapFilename, | ||
| sourceMapURL: this.options.sourceMapURL, | ||
| outputFilename: this.options.sourceMapOutputFilename, | ||
| sourceMapBasepath: this.options.sourceMapBasepath, | ||
| sourceMapRootpath: this.options.sourceMapRootpath, | ||
| outputSourceFiles: this.options.outputSourceFiles, | ||
| sourceMapGenerator: this.options.sourceMapGenerator, | ||
| sourceMapFileInline: this.options.sourceMapFileInline, | ||
| disableSourcemapAnnotation: this.options.disableSourcemapAnnotation | ||
| }); | ||
| var css = sourceMapOutput.toCSS(options); | ||
| toCSS(rootNode, options, imports) { | ||
| const sourceMapOutput = new SourceMapOutput( | ||
| { | ||
| contentsIgnoredCharsMap: imports.contentsIgnoredChars, | ||
| rootNode, | ||
| contentsMap: imports.contents, | ||
| sourceMapFilename: this.options.sourceMapFilename, | ||
| sourceMapURL: this.options.sourceMapURL, | ||
| outputFilename: this.options.sourceMapOutputFilename, | ||
| sourceMapBasepath: this.options.sourceMapBasepath, | ||
| sourceMapRootpath: this.options.sourceMapRootpath, | ||
| outputSourceFiles: this.options.outputSourceFiles, | ||
| sourceMapGenerator: this.options.sourceMapGenerator, | ||
| sourceMapFileInline: this.options.sourceMapFileInline, | ||
| disableSourcemapAnnotation: this.options.disableSourcemapAnnotation | ||
| }); | ||
| const css = sourceMapOutput.toCSS(options); | ||
| this.sourceMap = sourceMapOutput.sourceMap; | ||
@@ -33,5 +34,7 @@ this.sourceMapURL = sourceMapOutput.sourceMapURL; | ||
| return css + this.getCSSAppendage(); | ||
| }; | ||
| SourceMapBuilder.prototype.getCSSAppendage = function () { | ||
| var sourceMapURL = this.sourceMapURL; | ||
| } | ||
| getCSSAppendage() { | ||
| let sourceMapURL = this.sourceMapURL; | ||
| if (this.options.sourceMapFileInline) { | ||
@@ -41,35 +44,41 @@ if (this.sourceMap === undefined) { | ||
| } | ||
| sourceMapURL = "data:application/json;base64,".concat(environment.encodeBase64(this.sourceMap)); | ||
| sourceMapURL = `data:application/json;base64,${environment.encodeBase64(this.sourceMap)}`; | ||
| } | ||
| if (this.options.disableSourcemapAnnotation) { | ||
| return ''; | ||
| } | ||
| if (sourceMapURL) { | ||
| return "/*# sourceMappingURL=".concat(sourceMapURL, " */"); | ||
| return `/*# sourceMappingURL=${sourceMapURL} */`; | ||
| } | ||
| return ''; | ||
| }; | ||
| SourceMapBuilder.prototype.getExternalSourceMap = function () { | ||
| } | ||
| getExternalSourceMap() { | ||
| return this.sourceMap; | ||
| }; | ||
| SourceMapBuilder.prototype.setExternalSourceMap = function (sourceMap) { | ||
| } | ||
| setExternalSourceMap(sourceMap) { | ||
| this.sourceMap = sourceMap; | ||
| }; | ||
| SourceMapBuilder.prototype.isInline = function () { | ||
| } | ||
| isInline() { | ||
| return this.options.sourceMapFileInline; | ||
| }; | ||
| SourceMapBuilder.prototype.getSourceMapURL = function () { | ||
| } | ||
| getSourceMapURL() { | ||
| return this.sourceMapURL; | ||
| }; | ||
| SourceMapBuilder.prototype.getOutputFilename = function () { | ||
| } | ||
| getOutputFilename() { | ||
| return this.options.sourceMapOutputFilename; | ||
| }; | ||
| SourceMapBuilder.prototype.getInputFilename = function () { | ||
| } | ||
| getInputFilename() { | ||
| return this.sourceMapInputFilename; | ||
| }; | ||
| return SourceMapBuilder; | ||
| }()); | ||
| } | ||
| } | ||
| return SourceMapBuilder; | ||
| } | ||
| exports.default = default_1; | ||
| //# sourceMappingURL=source-map-builder.js.map |
@@ -1,6 +0,4 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| function default_1(environment) { | ||
| var SourceMapOutput = /** @class */ (function () { | ||
| function SourceMapOutput(options) { | ||
| export default function (environment) { | ||
| class SourceMapOutput { | ||
| constructor(options) { | ||
| this._css = []; | ||
@@ -23,4 +21,3 @@ this._rootNode = options.rootNode; | ||
| } | ||
| } | ||
| else { | ||
| } else { | ||
| this._sourceMapRootpath = ''; | ||
@@ -30,6 +27,8 @@ } | ||
| this._sourceMapGeneratorConstructor = environment.getSourceMapGenerator(); | ||
| this._lineNumber = 0; | ||
| this._column = 0; | ||
| } | ||
| SourceMapOutput.prototype.removeBasepath = function (path) { | ||
| removeBasepath(path) { | ||
| if (this._sourceMapBasepath && path.indexOf(this._sourceMapBasepath) === 0) { | ||
@@ -41,10 +40,14 @@ path = path.substring(this._sourceMapBasepath.length); | ||
| } | ||
| return path; | ||
| }; | ||
| SourceMapOutput.prototype.normalizeFilename = function (filename) { | ||
| } | ||
| normalizeFilename(filename) { | ||
| filename = filename.replace(/\\/g, '/'); | ||
| filename = this.removeBasepath(filename); | ||
| return (this._sourceMapRootpath || '') + filename; | ||
| }; | ||
| SourceMapOutput.prototype.add = function (chunk, fileInfo, index, mapLines) { | ||
| } | ||
| add(chunk, fileInfo, index, mapLines) { | ||
| // ignore adding empty strings | ||
@@ -54,5 +57,8 @@ if (!chunk) { | ||
| } | ||
| var lines, sourceLines, columns, sourceColumns, i; | ||
| let lines, sourceLines, columns, sourceColumns, i; | ||
| if (fileInfo && fileInfo.filename) { | ||
| var inputSource = this._contentsMap[fileInfo.filename]; | ||
| let inputSource = this._contentsMap[fileInfo.filename]; | ||
| // remove vars/banner added to the top of the file | ||
@@ -62,9 +68,8 @@ if (this._contentsIgnoredCharsMap[fileInfo.filename]) { | ||
| index -= this._contentsIgnoredCharsMap[fileInfo.filename]; | ||
| if (index < 0) { | ||
| index = 0; | ||
| } | ||
| if (index < 0) { index = 0; } | ||
| // adjust the source | ||
| inputSource = inputSource.slice(this._contentsIgnoredCharsMap[fileInfo.filename]); | ||
| } | ||
| /** | ||
| /** | ||
| * ignore empty content, or failsafe | ||
@@ -77,2 +82,3 @@ * if contents map is incorrect | ||
| } | ||
| inputSource = inputSource.substring(0, index); | ||
@@ -82,37 +88,42 @@ sourceLines = inputSource.split('\n'); | ||
| } | ||
| lines = chunk.split('\n'); | ||
| columns = lines[lines.length - 1]; | ||
| if (fileInfo && fileInfo.filename) { | ||
| if (!mapLines) { | ||
| this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + 1, column: this._column }, | ||
| original: { line: sourceLines.length, column: sourceColumns.length }, | ||
| source: this.normalizeFilename(fileInfo.filename) }); | ||
| } | ||
| else { | ||
| this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + 1, column: this._column}, | ||
| original: { line: sourceLines.length, column: sourceColumns.length}, | ||
| source: this.normalizeFilename(fileInfo.filename)}); | ||
| } else { | ||
| for (i = 0; i < lines.length; i++) { | ||
| this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + i + 1, column: i === 0 ? this._column : 0 }, | ||
| original: { line: sourceLines.length + i, column: i === 0 ? sourceColumns.length : 0 }, | ||
| source: this.normalizeFilename(fileInfo.filename) }); | ||
| this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + i + 1, column: i === 0 ? this._column : 0}, | ||
| original: { line: sourceLines.length + i, column: i === 0 ? sourceColumns.length : 0}, | ||
| source: this.normalizeFilename(fileInfo.filename)}); | ||
| } | ||
| } | ||
| } | ||
| if (lines.length === 1) { | ||
| this._column += columns.length; | ||
| } | ||
| else { | ||
| } else { | ||
| this._lineNumber += lines.length - 1; | ||
| this._column = columns.length; | ||
| } | ||
| this._css.push(chunk); | ||
| }; | ||
| SourceMapOutput.prototype.isEmpty = function () { | ||
| } | ||
| isEmpty() { | ||
| return this._css.length === 0; | ||
| }; | ||
| SourceMapOutput.prototype.toCSS = function (context) { | ||
| } | ||
| toCSS(context) { | ||
| this._sourceMapGenerator = new this._sourceMapGeneratorConstructor({ file: this._outputFilename, sourceRoot: null }); | ||
| if (this._outputSourceFiles) { | ||
| for (var filename in this._contentsMap) { | ||
| for (const filename in this._contentsMap) { | ||
| // eslint-disable-next-line no-prototype-builtins | ||
| if (this._contentsMap.hasOwnProperty(filename)) { | ||
| var source = this._contentsMap[filename]; | ||
| let source = this._contentsMap[filename]; | ||
| if (this._contentsIgnoredCharsMap[filename]) { | ||
@@ -125,22 +136,24 @@ source = source.slice(this._contentsIgnoredCharsMap[filename]); | ||
| } | ||
| this._rootNode.genCSS(context, this); | ||
| if (this._css.length > 0) { | ||
| var sourceMapURL = void 0; | ||
| var sourceMapContent = JSON.stringify(this._sourceMapGenerator.toJSON()); | ||
| let sourceMapURL; | ||
| const sourceMapContent = JSON.stringify(this._sourceMapGenerator.toJSON()); | ||
| if (this.sourceMapURL) { | ||
| sourceMapURL = this.sourceMapURL; | ||
| } | ||
| else if (this._sourceMapFilename) { | ||
| } else if (this._sourceMapFilename) { | ||
| sourceMapURL = this._sourceMapFilename; | ||
| } | ||
| this.sourceMapURL = sourceMapURL; | ||
| this.sourceMap = sourceMapContent; | ||
| } | ||
| return this._css.join(''); | ||
| }; | ||
| return SourceMapOutput; | ||
| }()); | ||
| } | ||
| } | ||
| return SourceMapOutput; | ||
| } | ||
| exports.default = default_1; | ||
| //# sourceMappingURL=source-map-output.js.map |
@@ -1,12 +0,16 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var contexts_1 = tslib_1.__importDefault(require("./contexts")); | ||
| var visitors_1 = tslib_1.__importDefault(require("./visitors")); | ||
| var tree_1 = tslib_1.__importDefault(require("./tree")); | ||
| function default_1(root, options) { | ||
| import contexts from './contexts.js'; | ||
| import visitor from './visitors/index.js'; | ||
| import tree from './tree/index.js'; | ||
| /** | ||
| * @param {import('./tree/node.js').default} root | ||
| * @param {{ variables?: Record<string, *>, compress?: boolean, pluginManager?: *, frames?: *[] }} options | ||
| * @returns {import('./tree/node.js').default} | ||
| */ | ||
| export default function(root, options) { | ||
| options = options || {}; | ||
| var evaldRoot; | ||
| var variables = options.variables; | ||
| var evalEnv = new contexts_1.default.Eval(options); | ||
| let evaldRoot; | ||
| let variables = options.variables; | ||
| const evalEnv = new contexts.Eval(options); | ||
| // | ||
@@ -27,25 +31,29 @@ // Allows setting variables with a hash, so: | ||
| variables = Object.keys(variables).map(function (k) { | ||
| var value = variables[k]; | ||
| if (!(value instanceof tree_1.default.Value)) { | ||
| if (!(value instanceof tree_1.default.Expression)) { | ||
| value = new tree_1.default.Expression([value]); | ||
| let value = variables[k]; | ||
| if (!(value instanceof tree.Value)) { | ||
| if (!(value instanceof tree.Expression)) { | ||
| value = new tree.Expression([value]); | ||
| } | ||
| value = new tree_1.default.Value([value]); | ||
| value = new tree.Value([value]); | ||
| } | ||
| return new tree_1.default.Declaration("@".concat(k), value, false, null, 0); | ||
| return new tree.Declaration(`@${k}`, value, false, null, 0); | ||
| }); | ||
| evalEnv.frames = [new tree_1.default.Ruleset(null, variables)]; | ||
| evalEnv.frames = [new tree.Ruleset(null, variables)]; | ||
| } | ||
| var visitors = [ | ||
| new visitors_1.default.JoinSelectorVisitor(), | ||
| new visitors_1.default.MarkVisibleSelectorsVisitor(true), | ||
| new visitors_1.default.ExtendVisitor(), | ||
| new visitors_1.default.ToCSSVisitor({ compress: Boolean(options.compress) }) | ||
| const visitors = [ | ||
| new visitor.JoinSelectorVisitor(), | ||
| new visitor.MarkVisibleSelectorsVisitor(true), | ||
| new visitor.ExtendVisitor(), | ||
| new visitor.ToCSSVisitor({compress: Boolean(options.compress)}) | ||
| ]; | ||
| var preEvalVisitors = []; | ||
| var v; | ||
| var visitorIterator; | ||
| const preEvalVisitors = []; | ||
| let v; | ||
| let visitorIterator; | ||
| /** | ||
| * first() / get() allows visitors to be added while visiting | ||
| * | ||
| * | ||
| * @todo Add scoping for visitors just like functions for @plugin; right now they're global | ||
@@ -55,3 +63,3 @@ */ | ||
| visitorIterator = options.pluginManager.visitor(); | ||
| for (var i = 0; i < 2; i++) { | ||
| for (let i = 0; i < 2; i++) { | ||
| visitorIterator.first(); | ||
@@ -78,6 +86,9 @@ while ((v = visitorIterator.get())) { | ||
| } | ||
| evaldRoot = root.eval(evalEnv); | ||
| for (var i = 0; i < visitors.length; i++) { | ||
| for (let i = 0; i < visitors.length; i++) { | ||
| visitors[i].run(evaldRoot); | ||
| } | ||
| // Run any remaining visitors added after eval pass | ||
@@ -92,5 +103,4 @@ if (options.pluginManager) { | ||
| } | ||
| return evaldRoot; | ||
| } | ||
| exports.default = default_1; | ||
| //# sourceMappingURL=transform-tree.js.map |
@@ -1,33 +0,57 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike, visibilityInfo) { | ||
| this.value = value; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.mapLines = mapLines; | ||
| this.rulesetLike = (typeof rulesetLike === 'undefined') ? false : rulesetLike; | ||
| this.allowRoot = true; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| }; | ||
| Anonymous.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Anonymous', | ||
| eval: function () { | ||
| return new Anonymous(this.value, this._index, this._fileInfo, this.mapLines, this.rulesetLike, this.visibilityInfo()); | ||
| }, | ||
| compare: function (other) { | ||
| return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined; | ||
| }, | ||
| isRulesetLike: function () { | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, FileInfo, VisibilityInfo } from './node.js' */ | ||
| import Node from './node.js'; | ||
| class Anonymous extends Node { | ||
| get type() { return 'Anonymous'; } | ||
| /** | ||
| * @param {string | null} value | ||
| * @param {number} [index] | ||
| * @param {FileInfo} [currentFileInfo] | ||
| * @param {boolean} [mapLines] | ||
| * @param {boolean} [rulesetLike] | ||
| * @param {VisibilityInfo} [visibilityInfo] | ||
| */ | ||
| constructor(value, index, currentFileInfo, mapLines, rulesetLike, visibilityInfo) { | ||
| super(); | ||
| this.value = value; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.mapLines = mapLines; | ||
| this.rulesetLike = (typeof rulesetLike === 'undefined') ? false : rulesetLike; | ||
| this.allowRoot = true; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| } | ||
| /** @returns {Anonymous} */ | ||
| eval() { | ||
| return new Anonymous(/** @type {string | null} */ (this.value), this._index, this._fileInfo, this.mapLines, this.rulesetLike, this.visibilityInfo()); | ||
| } | ||
| /** | ||
| * @param {Node} other | ||
| * @returns {number | undefined} | ||
| */ | ||
| compare(other) { | ||
| return other.toCSS && this.toCSS(/** @type {EvalContext} */ ({})) === other.toCSS(/** @type {EvalContext} */ ({})) ? 0 : undefined; | ||
| } | ||
| /** @returns {boolean} */ | ||
| isRulesetLike() { | ||
| return this.rulesetLike; | ||
| }, | ||
| genCSS: function (context, output) { | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| this.nodeVisible = Boolean(this.value); | ||
| if (this.nodeVisible) { | ||
| output.add(this.value, this._fileInfo, this._index, this.mapLines); | ||
| output.add(/** @type {string} */ (this.value), this._fileInfo, this._index, this.mapLines); | ||
| } | ||
| } | ||
| }); | ||
| exports.default = Anonymous; | ||
| //# sourceMappingURL=anonymous.js.map | ||
| } | ||
| export default Anonymous; |
@@ -1,31 +0,48 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var Assignment = function (key, val) { | ||
| this.key = key; | ||
| this.value = val; | ||
| }; | ||
| Assignment.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Assignment', | ||
| accept: function (visitor) { | ||
| this.value = visitor.visit(this.value); | ||
| }, | ||
| eval: function (context) { | ||
| if (this.value.eval) { | ||
| return new Assignment(this.key, this.value.eval(context)); | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, TreeVisitor } from './node.js' */ | ||
| import Node from './node.js'; | ||
| class Assignment extends Node { | ||
| get type() { return 'Assignment'; } | ||
| /** | ||
| * @param {string} key | ||
| * @param {Node} val | ||
| */ | ||
| constructor(key, val) { | ||
| super(); | ||
| this.key = key; | ||
| this.value = val; | ||
| } | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| this.value = visitor.visit(/** @type {Node} */ (this.value)); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Assignment} | ||
| */ | ||
| eval(context) { | ||
| if (/** @type {Node} */ (this.value).eval) { | ||
| return new Assignment(this.key, /** @type {Node} */ (this.value).eval(context)); | ||
| } | ||
| return this; | ||
| }, | ||
| genCSS: function (context, output) { | ||
| output.add("".concat(this.key, "=")); | ||
| if (this.value.genCSS) { | ||
| this.value.genCSS(context, output); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| output.add(`${this.key}=`); | ||
| if (/** @type {Node} */ (this.value).genCSS) { | ||
| /** @type {Node} */ (this.value).genCSS(context, output); | ||
| } else { | ||
| output.add(/** @type {string} */ (/** @type {unknown} */ (this.value))); | ||
| } | ||
| else { | ||
| output.add(this.value); | ||
| } | ||
| } | ||
| }); | ||
| exports.default = Assignment; | ||
| //# sourceMappingURL=assignment.js.map | ||
| } | ||
| export default Assignment; |
@@ -1,10 +0,8 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.ContainerSyntaxOptions = exports.MediaSyntaxOptions = void 0; | ||
| exports.MediaSyntaxOptions = { | ||
| // @ts-check | ||
| export const MediaSyntaxOptions = { | ||
| queryInParens: true | ||
| }; | ||
| exports.ContainerSyntaxOptions = { | ||
| export const ContainerSyntaxOptions = { | ||
| queryInParens: true | ||
| }; | ||
| //# sourceMappingURL=atrule-syntax.js.map |
+247
-140
@@ -1,109 +0,186 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var selector_1 = tslib_1.__importDefault(require("./selector")); | ||
| var ruleset_1 = tslib_1.__importDefault(require("./ruleset")); | ||
| var anonymous_1 = tslib_1.__importDefault(require("./anonymous")); | ||
| var nested_at_rule_1 = tslib_1.__importDefault(require("./nested-at-rule")); | ||
| var AtRule = function (name, value, rules, index, currentFileInfo, debugInfo, isRooted, visibilityInfo) { | ||
| var _this = this; | ||
| var i; | ||
| var selectors = (new selector_1.default([], null, null, this._index, this._fileInfo)).createEmptySelectors(); | ||
| this.name = name; | ||
| this.value = (value instanceof node_1.default) ? value : (value ? new anonymous_1.default(value) : value); | ||
| if (rules) { | ||
| if (Array.isArray(rules)) { | ||
| var allDeclarations = this.declarationsBlock(rules); | ||
| var allRulesetDeclarations_1 = true; | ||
| rules.forEach(function (rule) { | ||
| if (rule.type === 'Ruleset' && rule.rules) | ||
| allRulesetDeclarations_1 = allRulesetDeclarations_1 && _this.declarationsBlock(rule.rules, true); | ||
| }); | ||
| if (allDeclarations && !isRooted) { | ||
| this.simpleBlock = true; | ||
| this.declarations = rules; | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, TreeVisitor, FileInfo, VisibilityInfo } from './node.js' */ | ||
| /** @import { FunctionRegistry } from './nested-at-rule.js' */ | ||
| import Node from './node.js'; | ||
| import Selector from './selector.js'; | ||
| import Ruleset from './ruleset.js'; | ||
| import Anonymous from './anonymous.js'; | ||
| import NestableAtRulePrototype from './nested-at-rule.js'; | ||
| import mergeRules from './merge-rules.js'; | ||
| /** | ||
| * @typedef {Node & { | ||
| * rules?: Node[], | ||
| * selectors?: Selector[], | ||
| * root?: boolean, | ||
| * allowImports?: boolean, | ||
| * functionRegistry?: FunctionRegistry, | ||
| * merge?: boolean, | ||
| * debugInfo?: { lineNumber: number, fileName: string }, | ||
| * elements?: import('./element.js').default[] | ||
| * }} RulesetLikeNode | ||
| */ | ||
| class AtRule extends Node { | ||
| get type() { return 'AtRule'; } | ||
| /** | ||
| * @param {string} [name] | ||
| * @param {Node | string} [value] | ||
| * @param {Node[] | Ruleset} [rules] | ||
| * @param {number} [index] | ||
| * @param {FileInfo} [currentFileInfo] | ||
| * @param {{ lineNumber: number, fileName: string }} [debugInfo] | ||
| * @param {boolean} [isRooted] | ||
| * @param {VisibilityInfo} [visibilityInfo] | ||
| */ | ||
| constructor( | ||
| name, | ||
| value, | ||
| rules, | ||
| index, | ||
| currentFileInfo, | ||
| debugInfo, | ||
| isRooted, | ||
| visibilityInfo | ||
| ) { | ||
| super(); | ||
| let i; | ||
| var selectors = (new Selector([], null, null, index, currentFileInfo)).createEmptySelectors(); | ||
| /** @type {string | undefined} */ | ||
| this.name = name; | ||
| this.value = (value instanceof Node) ? value : (value ? new Anonymous(value) : value); | ||
| /** @type {boolean | undefined} */ | ||
| this.simpleBlock = undefined; | ||
| /** @type {RulesetLikeNode[] | undefined} */ | ||
| this.declarations = undefined; | ||
| /** @type {RulesetLikeNode[] | undefined} */ | ||
| this.rules = undefined; | ||
| if (rules) { | ||
| if (Array.isArray(rules)) { | ||
| const allDeclarations = this.declarationsBlock(rules); | ||
| let allRulesetDeclarations = true; | ||
| rules.forEach(rule => { | ||
| if (rule.type === 'Ruleset' && /** @type {RulesetLikeNode} */ (rule).rules) allRulesetDeclarations = allRulesetDeclarations && this.declarationsBlock(/** @type {Node[]} */ (/** @type {RulesetLikeNode} */ (rule).rules), true); | ||
| }); | ||
| if (allDeclarations && !isRooted) { | ||
| this.simpleBlock = true; | ||
| this.declarations = rules; | ||
| } else if (allRulesetDeclarations && rules.length === 1 && !isRooted && !value) { | ||
| this.simpleBlock = true; | ||
| this.declarations = /** @type {RulesetLikeNode} */ (rules[0]).rules ? /** @type {RulesetLikeNode} */ (rules[0]).rules : rules; | ||
| } else { | ||
| this.rules = rules; | ||
| } | ||
| } else { | ||
| const allDeclarations = this.declarationsBlock(/** @type {Node[]} */ (rules.rules)); | ||
| if (allDeclarations && !isRooted && !value) { | ||
| this.simpleBlock = true; | ||
| this.declarations = rules.rules; | ||
| } else { | ||
| this.rules = [rules]; | ||
| /** @type {RulesetLikeNode} */ (this.rules[0]).selectors = (new Selector([], null, null, index, currentFileInfo)).createEmptySelectors(); | ||
| } | ||
| } | ||
| else if (allRulesetDeclarations_1 && rules.length === 1 && !isRooted && !value) { | ||
| this.simpleBlock = true; | ||
| this.declarations = rules[0].rules ? rules[0].rules : rules; | ||
| if (!this.simpleBlock) { | ||
| for (i = 0; i < this.rules.length; i++) { | ||
| /** @type {RulesetLikeNode} */ (this.rules[i]).allowImports = true; | ||
| } | ||
| } | ||
| else { | ||
| this.rules = rules; | ||
| if (this.declarations) { | ||
| this.setParent(this.declarations, /** @type {Node} */ (/** @type {unknown} */ (this))); | ||
| } | ||
| } | ||
| else { | ||
| var allDeclarations = this.declarationsBlock(rules.rules); | ||
| if (allDeclarations && !isRooted && !value) { | ||
| this.simpleBlock = true; | ||
| this.declarations = rules.rules; | ||
| if (this.rules) { | ||
| this.setParent(this.rules, /** @type {Node} */ (/** @type {unknown} */ (this))); | ||
| } | ||
| else { | ||
| this.rules = [rules]; | ||
| this.rules[0].selectors = (new selector_1.default([], null, null, index, currentFileInfo)).createEmptySelectors(); | ||
| } | ||
| } | ||
| if (!this.simpleBlock) { | ||
| for (i = 0; i < this.rules.length; i++) { | ||
| this.rules[i].allowImports = true; | ||
| } | ||
| } | ||
| this.setParent(selectors, this); | ||
| this.setParent(this.rules, this); | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| /** @type {{ lineNumber: number, fileName: string } | undefined} */ | ||
| this.debugInfo = debugInfo; | ||
| /** @type {boolean} */ | ||
| this.isRooted = isRooted || false; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| this.allowRoot = true; | ||
| } | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.debugInfo = debugInfo; | ||
| this.isRooted = isRooted || false; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| this.allowRoot = true; | ||
| }; | ||
| AtRule.prototype = Object.assign(new node_1.default(), tslib_1.__assign(tslib_1.__assign({ type: 'AtRule' }, nested_at_rule_1.default), { declarationsBlock: function (rules, mergeable) { | ||
| if (mergeable === void 0) { mergeable = false; } | ||
| /** | ||
| * @param {Node[]} rules | ||
| * @param {boolean} [mergeable] | ||
| * @returns {boolean} | ||
| */ | ||
| declarationsBlock(rules, mergeable = false) { | ||
| if (!mergeable) { | ||
| return rules.filter(function (node) { return (node.type === 'Declaration' || node.type === 'Comment') && !node.merge; }).length === rules.length; | ||
| return rules.filter(function (/** @type {Node & { merge?: boolean }} */ node) { return (node.type === 'Declaration' || node.type === 'Comment') && !node.merge}).length === rules.length; | ||
| } else { | ||
| return rules.filter(function (/** @type {Node} */ node) { return (node.type === 'Declaration' || node.type === 'Comment'); }).length === rules.length; | ||
| } | ||
| else { | ||
| return rules.filter(function (node) { return (node.type === 'Declaration' || node.type === 'Comment'); }).length === rules.length; | ||
| } | ||
| }, keywordList: function (rules) { | ||
| } | ||
| /** | ||
| * @param {Node[]} rules | ||
| * @returns {boolean} | ||
| */ | ||
| keywordList(rules) { | ||
| if (!Array.isArray(rules)) { | ||
| return false; | ||
| } else { | ||
| return rules.filter(function (/** @type {Node} */ node) { return (node.type === 'Keyword' || node.type === 'Comment'); }).length === rules.length; | ||
| } | ||
| else { | ||
| return rules.filter(function (node) { return (node.type === 'Keyword' || node.type === 'Comment'); }).length === rules.length; | ||
| } | ||
| }, accept: function (visitor) { | ||
| var value = this.value, rules = this.rules, declarations = this.declarations; | ||
| } | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| const value = this.value, rules = this.rules, declarations = this.declarations; | ||
| if (rules) { | ||
| this.rules = visitor.visitArray(rules); | ||
| } | ||
| else if (declarations) { | ||
| } else if (declarations) { | ||
| this.declarations = visitor.visitArray(declarations); | ||
| } | ||
| if (value) { | ||
| this.value = visitor.visit(value); | ||
| this.value = visitor.visit(/** @type {Node} */ (value)); | ||
| } | ||
| }, isRulesetLike: function () { | ||
| return this.rules || !this.isCharset(); | ||
| }, isCharset: function () { | ||
| } | ||
| /** @override @returns {boolean} */ | ||
| isRulesetLike() { | ||
| return /** @type {boolean} */ (/** @type {unknown} */ (this.rules || !this.isCharset())); | ||
| } | ||
| isCharset() { | ||
| return '@charset' === this.name; | ||
| }, genCSS: function (context, output) { | ||
| var value = this.value, rules = this.rules || this.declarations; | ||
| output.add(this.name, this.fileInfo(), this.getIndex()); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| const value = this.value, rules = this.rules || this.declarations; | ||
| output.add(/** @type {string} */ (this.name), this.fileInfo(), this.getIndex()); | ||
| if (value) { | ||
| output.add(' '); | ||
| value.genCSS(context, output); | ||
| /** @type {Node} */ (value).genCSS(context, output); | ||
| } | ||
| if (this.simpleBlock) { | ||
| this.outputRuleset(context, output, this.declarations); | ||
| } | ||
| else if (rules) { | ||
| this.outputRuleset(context, output, /** @type {Node[]} */ (this.declarations)); | ||
| } else if (rules) { | ||
| this.outputRuleset(context, output, rules); | ||
| } | ||
| else { | ||
| } else { | ||
| output.add(';'); | ||
| } | ||
| }, eval: function (context) { | ||
| var mediaPathBackup, mediaBlocksBackup, value = this.value, rules = this.rules || this.declarations; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Node} | ||
| */ | ||
| eval(context) { | ||
| let mediaPathBackup, mediaBlocksBackup, value = this.value, rules = this.rules || this.declarations; | ||
| // media stored inside other atrule should not bubble over it | ||
@@ -116,43 +193,53 @@ // backpup media bubbling information | ||
| context.mediaBlocks = []; | ||
| if (value) { | ||
| value = value.eval(context); | ||
| if (value.value && this.keywordList(value.value)) { | ||
| value = new anonymous_1.default(value.value.map(function (keyword) { return keyword.value; }).join(', '), this.getIndex(), this.fileInfo()); | ||
| } | ||
| value = /** @type {Node} */ (value).eval(context); | ||
| } | ||
| if (rules) { | ||
| rules = this.evalRoot(context, rules); | ||
| } | ||
| if (Array.isArray(rules) && rules[0].rules && Array.isArray(rules[0].rules) && rules[0].rules.length) { | ||
| var allMergeableDeclarations = this.declarationsBlock(rules[0].rules, true); | ||
| if (Array.isArray(rules) && /** @type {RulesetLikeNode} */ (rules[0]).rules && Array.isArray(/** @type {RulesetLikeNode} */ (rules[0]).rules) && /** @type {Node[]} */ (/** @type {RulesetLikeNode} */ (rules[0]).rules).length) { | ||
| const allMergeableDeclarations = this.declarationsBlock(/** @type {Node[]} */ (/** @type {RulesetLikeNode} */ (rules[0]).rules), true); | ||
| if (allMergeableDeclarations && !this.isRooted && !value) { | ||
| var mergeRules = context.pluginManager.less.visitors.ToCSSVisitor.prototype._mergeRules; | ||
| mergeRules(rules[0].rules); | ||
| rules = rules[0].rules; | ||
| rules.forEach(function (rule) { return rule.merge = false; }); | ||
| mergeRules(/** @type {Node[]} */ (/** @type {RulesetLikeNode} */ (rules[0]).rules)); | ||
| rules = /** @type {RulesetLikeNode[]} */ (/** @type {RulesetLikeNode} */ (rules[0]).rules); | ||
| rules.forEach(/** @param {RulesetLikeNode} rule */ rule => { rule.merge = false; }); | ||
| } | ||
| } | ||
| if (this.simpleBlock && rules) { | ||
| rules[0].functionRegistry = context.frames[0].functionRegistry.inherit(); | ||
| rules = rules.map(function (rule) { return rule.eval(context); }); | ||
| /** @type {RulesetLikeNode} */ (rules[0]).functionRegistry = /** @type {RulesetLikeNode} */ (context.frames[0]).functionRegistry.inherit(); | ||
| rules = rules.map(function (/** @type {Node} */ rule) { return rule.eval(context); }); | ||
| } | ||
| // restore media bubbling information | ||
| context.mediaPath = mediaPathBackup; | ||
| context.mediaBlocks = mediaBlocksBackup; | ||
| return new AtRule(this.name, value, rules, this.getIndex(), this.fileInfo(), this.debugInfo, this.isRooted, this.visibilityInfo()); | ||
| }, evalRoot: function (context, rules) { | ||
| var ampersandCount = 0; | ||
| var noAmpersandCount = 0; | ||
| var noAmpersands = true; | ||
| var allAmpersands = false; | ||
| return /** @type {Node} */ (/** @type {unknown} */ (new AtRule(this.name, value, rules, this.getIndex(), this.fileInfo(), this.debugInfo, this.isRooted, this.visibilityInfo()))); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {Node[]} rules | ||
| * @returns {Node[]} | ||
| */ | ||
| evalRoot(context, rules) { | ||
| let ampersandCount = 0; | ||
| let noAmpersandCount = 0; | ||
| let noAmpersands = true; | ||
| if (!this.simpleBlock) { | ||
| rules = [rules[0].eval(context)]; | ||
| } | ||
| var precedingSelectors = []; | ||
| /** @type {Selector[]} */ | ||
| let precedingSelectors = []; | ||
| if (context.frames.length > 0) { | ||
| var _loop_1 = function (index) { | ||
| var frame = context.frames[index]; | ||
| if (frame.type === 'Ruleset' && | ||
| for (let index = 0; index < context.frames.length; index++) { | ||
| const frame = /** @type {RulesetLikeNode} */ (context.frames[index]); | ||
| if ( | ||
| frame.type === 'Ruleset' && | ||
| frame.rules && | ||
| frame.rules.length > 0) { | ||
| frame.rules.length > 0 | ||
| ) { | ||
| if (frame && !frame.root && frame.selectors && frame.selectors.length > 0) { | ||
@@ -163,46 +250,60 @@ precedingSelectors = precedingSelectors.concat(frame.selectors); | ||
| if (precedingSelectors.length > 0) { | ||
| var value_1 = ''; | ||
| var output = { add: function (s) { value_1 += s; } }; | ||
| for (var i = 0; i < precedingSelectors.length; i++) { | ||
| precedingSelectors[i].genCSS(context, output); | ||
| } | ||
| if (/^&+$/.test(value_1.replace(/\s+/g, ''))) { | ||
| const allAmpersandElements = precedingSelectors.every( | ||
| sel => sel.elements && sel.elements.length > 0 && sel.elements.every( | ||
| /** @param {import('./element.js').default} el */ | ||
| el => el.value === '&' | ||
| ) | ||
| ); | ||
| if (allAmpersandElements) { | ||
| noAmpersands = false; | ||
| noAmpersandCount++; | ||
| } | ||
| else { | ||
| allAmpersands = false; | ||
| } else { | ||
| ampersandCount++; | ||
| } | ||
| } | ||
| }; | ||
| for (var index = 0; index < context.frames.length; index++) { | ||
| _loop_1(index); | ||
| } | ||
| } | ||
| var mixedAmpersands = ampersandCount > 0 && noAmpersandCount > 0 && !allAmpersands && !noAmpersands; | ||
| if ((this.isRooted && ampersandCount > 0 && noAmpersandCount === 0 && !allAmpersands && noAmpersands) | ||
| || !mixedAmpersands) { | ||
| rules[0].root = true; | ||
| const mixedAmpersands = ampersandCount > 0 && noAmpersandCount > 0 && !noAmpersands; | ||
| if ( | ||
| (this.isRooted && ampersandCount > 0 && noAmpersandCount === 0 && noAmpersands) | ||
| || !mixedAmpersands | ||
| ) { | ||
| /** @type {RulesetLikeNode} */ (rules[0]).root = true; | ||
| } | ||
| return rules; | ||
| }, variable: function (name) { | ||
| } | ||
| /** @param {string} name */ | ||
| variable(name) { | ||
| if (this.rules) { | ||
| // assuming that there is only one rule at this point - that is how parser constructs the rule | ||
| return ruleset_1.default.prototype.variable.call(this.rules[0], name); | ||
| return Ruleset.prototype.variable.call(this.rules[0], name); | ||
| } | ||
| }, find: function () { | ||
| } | ||
| find() { | ||
| if (this.rules) { | ||
| // assuming that there is only one rule at this point - that is how parser constructs the rule | ||
| return ruleset_1.default.prototype.find.apply(this.rules[0], arguments); | ||
| return Ruleset.prototype.find.apply(this.rules[0], arguments); | ||
| } | ||
| }, rulesets: function () { | ||
| } | ||
| rulesets() { | ||
| if (this.rules) { | ||
| // assuming that there is only one rule at this point - that is how parser constructs the rule | ||
| return ruleset_1.default.prototype.rulesets.apply(this.rules[0]); | ||
| return Ruleset.prototype.rulesets.apply(this.rules[0]); | ||
| } | ||
| }, outputRuleset: function (context, output, rules) { | ||
| var ruleCnt = rules.length; | ||
| var i; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| * @param {Node[]} rules | ||
| */ | ||
| outputRuleset(context, output, rules) { | ||
| const ruleCnt = rules.length; | ||
| let i; | ||
| context.tabLevel = (context.tabLevel | 0) + 1; | ||
| // Compressed | ||
@@ -218,9 +319,9 @@ if (context.compress) { | ||
| } | ||
| // Non-compressed | ||
| var tabSetStr = "\n".concat(Array(context.tabLevel).join(' ')), tabRuleStr = "".concat(tabSetStr, " "); | ||
| const tabSetStr = `\n${Array(context.tabLevel).join(' ')}`, tabRuleStr = `${tabSetStr} `; | ||
| if (!ruleCnt) { | ||
| output.add(" {".concat(tabSetStr, "}")); | ||
| } | ||
| else { | ||
| output.add(" {".concat(tabRuleStr)); | ||
| output.add(` {${tabSetStr}}`); | ||
| } else { | ||
| output.add(` {${tabRuleStr}`); | ||
| rules[0].genCSS(context, output); | ||
@@ -231,7 +332,13 @@ for (i = 1; i < ruleCnt; i++) { | ||
| } | ||
| output.add("".concat(tabSetStr, "}")); | ||
| output.add(`${tabSetStr}}`); | ||
| } | ||
| context.tabLevel--; | ||
| } })); | ||
| exports.default = AtRule; | ||
| //# sourceMappingURL=atrule.js.map | ||
| } | ||
| } | ||
| // Apply shared methods from NestableAtRulePrototype that AtRule doesn't override | ||
| const { evalFunction, evalTop, evalNested, permute, bubbleSelectors } = NestableAtRulePrototype; | ||
| Object.assign(AtRule.prototype, { evalFunction, evalTop, evalNested, permute, bubbleSelectors }); | ||
| export default AtRule; |
@@ -1,32 +0,63 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var Attribute = function (key, op, value, cif) { | ||
| this.key = key; | ||
| this.op = op; | ||
| this.value = value; | ||
| this.cif = cif; | ||
| }; | ||
| Attribute.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Attribute', | ||
| eval: function (context) { | ||
| return new Attribute(this.key.eval ? this.key.eval(context) : this.key, this.op, (this.value && this.value.eval) ? this.value.eval(context) : this.value, this.cif); | ||
| }, | ||
| genCSS: function (context, output) { | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput } from './node.js' */ | ||
| import Node from './node.js'; | ||
| class Attribute extends Node { | ||
| get type() { return 'Attribute'; } | ||
| /** | ||
| * @param {string | Node} key | ||
| * @param {string} op | ||
| * @param {string | Node} value | ||
| * @param {string} cif | ||
| */ | ||
| constructor(key, op, value, cif) { | ||
| super(); | ||
| this.key = key; | ||
| this.op = op; | ||
| this.value = value; | ||
| this.cif = cif; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Attribute} | ||
| */ | ||
| eval(context) { | ||
| return new Attribute( | ||
| /** @type {Node} */ (this.key).eval ? /** @type {Node} */ (this.key).eval(context) : /** @type {string} */ (this.key), | ||
| this.op, | ||
| (this.value && /** @type {Node} */ (this.value).eval) ? /** @type {Node} */ (this.value).eval(context) : this.value, | ||
| this.cif | ||
| ); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| output.add(this.toCSS(context)); | ||
| }, | ||
| toCSS: function (context) { | ||
| var value = this.key.toCSS ? this.key.toCSS(context) : this.key; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {string} | ||
| */ | ||
| toCSS(context) { | ||
| let value = /** @type {Node} */ (this.key).toCSS ? /** @type {Node} */ (this.key).toCSS(context) : /** @type {string} */ (this.key); | ||
| if (this.op) { | ||
| value += this.op; | ||
| value += (this.value.toCSS ? this.value.toCSS(context) : this.value); | ||
| value += (/** @type {Node} */ (this.value).toCSS ? /** @type {Node} */ (this.value).toCSS(context) : /** @type {string} */ (this.value)); | ||
| } | ||
| if (this.cif) { | ||
| value = value + ' ' + this.cif; | ||
| } | ||
| return "[".concat(value, "]"); | ||
| return `[${value}]`; | ||
| } | ||
| }); | ||
| exports.default = Attribute; | ||
| //# sourceMappingURL=attribute.js.map | ||
| } | ||
| export default Attribute; |
+70
-42
@@ -1,24 +0,35 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var anonymous_1 = tslib_1.__importDefault(require("./anonymous")); | ||
| var function_caller_1 = tslib_1.__importDefault(require("../functions/function-caller")); | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, TreeVisitor, FileInfo } from './node.js' */ | ||
| import Node from './node.js'; | ||
| import Anonymous from './anonymous.js'; | ||
| import FunctionCaller from '../functions/function-caller.js'; | ||
| // | ||
| // A function call node. | ||
| // | ||
| var Call = function (name, args, index, currentFileInfo) { | ||
| this.name = name; | ||
| this.args = args; | ||
| this.calc = name === 'calc'; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| }; | ||
| Call.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Call', | ||
| accept: function (visitor) { | ||
| class Call extends Node { | ||
| get type() { return 'Call'; } | ||
| /** | ||
| * @param {string} name | ||
| * @param {Node[]} args | ||
| * @param {number} index | ||
| * @param {FileInfo} currentFileInfo | ||
| */ | ||
| constructor(name, args, index, currentFileInfo) { | ||
| super(); | ||
| this.name = name; | ||
| this.args = args; | ||
| this.calc = name === 'calc'; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| } | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| if (this.args) { | ||
| this.args = visitor.visitArray(this.args); | ||
| } | ||
| }, | ||
| } | ||
| // | ||
@@ -35,8 +46,11 @@ // When evaluating a function call, | ||
| // | ||
| eval: function (context) { | ||
| var _this = this; | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Node} | ||
| */ | ||
| eval(context) { | ||
| /** | ||
| * Turn off math for calc(), and switch back on for evaluating nested functions | ||
| */ | ||
| var currentMathContext = context.mathOn; | ||
| const currentMathContext = context.mathOn; | ||
| context.mathOn = !this.calc; | ||
@@ -46,4 +60,5 @@ if (this.calc || context.inCalc) { | ||
| } | ||
| var exitCalc = function () { | ||
| if (_this.calc || context.inCalc) { | ||
| const exitCalc = () => { | ||
| if (this.calc || context.inCalc) { | ||
| context.exitCalc(); | ||
@@ -53,4 +68,7 @@ } | ||
| }; | ||
| var result; | ||
| var funcCaller = new function_caller_1.default(this.name, context, this.getIndex(), this.fileInfo()); | ||
| /** @type {Node | string | boolean | null | undefined} */ | ||
| let result; | ||
| const funcCaller = new FunctionCaller(this.name, context, this.getIndex(), this.fileInfo()); | ||
| if (funcCaller.isValid()) { | ||
@@ -60,28 +78,29 @@ try { | ||
| exitCalc(); | ||
| } | ||
| catch (e) { | ||
| } catch (e) { | ||
| // eslint-disable-next-line no-prototype-builtins | ||
| if (e.hasOwnProperty('line') && e.hasOwnProperty('column')) { | ||
| if (/** @type {Record<string, unknown>} */ (e).hasOwnProperty('line') && /** @type {Record<string, unknown>} */ (e).hasOwnProperty('column')) { | ||
| throw e; | ||
| } | ||
| throw { | ||
| type: e.type || 'Runtime', | ||
| message: "Error evaluating function `".concat(this.name, "`").concat(e.message ? ": ".concat(e.message) : ''), | ||
| type: /** @type {Record<string, string>} */ (e).type || 'Runtime', | ||
| message: `Error evaluating function \`${this.name}\`${/** @type {Error} */ (e).message ? `: ${/** @type {Error} */ (e).message}` : ''}`, | ||
| index: this.getIndex(), | ||
| filename: this.fileInfo().filename, | ||
| line: e.lineNumber, | ||
| column: e.columnNumber | ||
| line: /** @type {Record<string, number>} */ (e).lineNumber, | ||
| column: /** @type {Record<string, number>} */ (e).columnNumber | ||
| }; | ||
| } | ||
| } | ||
| if (result !== null && result !== undefined) { | ||
| // Results that that are not nodes are cast as Anonymous nodes | ||
| // Falsy values or booleans are returned as empty nodes | ||
| if (!(result instanceof node_1.default)) { | ||
| if (!(result instanceof Node)) { | ||
| if (!result || result === true) { | ||
| result = new anonymous_1.default(null); | ||
| result = new Anonymous(null); | ||
| } | ||
| else { | ||
| result = new anonymous_1.default(result.toString()); | ||
| result = new Anonymous(result.toString()); | ||
| } | ||
| } | ||
@@ -92,9 +111,17 @@ result._index = this._index; | ||
| } | ||
| var args = this.args.map(function (a) { return a.eval(context); }); | ||
| const args = this.args.map(a => a.eval(context)); | ||
| exitCalc(); | ||
| return new Call(this.name, args, this.getIndex(), this.fileInfo()); | ||
| }, | ||
| genCSS: function (context, output) { | ||
| output.add("".concat(this.name, "("), this.fileInfo(), this.getIndex()); | ||
| for (var i = 0; i < this.args.length; i++) { | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| output.add(`${this.name}(`, this.fileInfo(), this.getIndex()); | ||
| for (let i = 0; i < this.args.length; i++) { | ||
| this.args[i].genCSS(context, output); | ||
@@ -105,6 +132,7 @@ if (i + 1 < this.args.length) { | ||
| } | ||
| output.add(')'); | ||
| } | ||
| }); | ||
| exports.default = Call; | ||
| //# sourceMappingURL=call.js.map | ||
| } | ||
| export default Call; |
+194
-145
@@ -1,65 +0,92 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var colors_1 = tslib_1.__importDefault(require("../data/colors")); | ||
| // @ts-check | ||
| import Node from './node.js'; | ||
| import colors from '../data/colors.js'; | ||
| /** @import { EvalContext, CSSOutput } from './node.js' */ | ||
| // | ||
| // RGB Colors - #ff0014, #eee | ||
| // | ||
| var Color = function (rgb, a, originalForm) { | ||
| var self = this; | ||
| // | ||
| // The end goal here, is to parse the arguments | ||
| // into an integer triplet, such as `128, 255, 0` | ||
| // | ||
| // This facilitates operations and conversions. | ||
| // | ||
| if (Array.isArray(rgb)) { | ||
| this.rgb = rgb; | ||
| class Color extends Node { | ||
| get type() { return 'Color'; } | ||
| /** | ||
| * @param {number[] | string} rgb | ||
| * @param {number} [a] | ||
| * @param {string} [originalForm] | ||
| */ | ||
| constructor(rgb, a, originalForm) { | ||
| super(); | ||
| const self = this; | ||
| // | ||
| // The end goal here, is to parse the arguments | ||
| // into an integer triplet, such as `128, 255, 0` | ||
| // | ||
| // This facilitates operations and conversions. | ||
| // | ||
| if (Array.isArray(rgb)) { | ||
| /** @type {number[]} */ | ||
| this.rgb = rgb; | ||
| } else if (rgb.length >= 6) { | ||
| /** @type {number[]} */ | ||
| this.rgb = []; | ||
| /** @type {RegExpMatchArray} */ (rgb.match(/.{2}/g)).map(function (c, i) { | ||
| if (i < 3) { | ||
| self.rgb.push(parseInt(c, 16)); | ||
| } else { | ||
| self.alpha = (parseInt(c, 16)) / 255; | ||
| } | ||
| }); | ||
| } else { | ||
| /** @type {number[]} */ | ||
| this.rgb = []; | ||
| rgb.split('').map(function (c, i) { | ||
| if (i < 3) { | ||
| self.rgb.push(parseInt(c + c, 16)); | ||
| } else { | ||
| self.alpha = (parseInt(c + c, 16)) / 255; | ||
| } | ||
| }); | ||
| } | ||
| /** @type {number} */ | ||
| if (typeof this.alpha === 'undefined') { | ||
| this.alpha = (typeof a === 'number') ? a : 1; | ||
| } | ||
| if (typeof originalForm !== 'undefined') { | ||
| this.value = originalForm; | ||
| } | ||
| } | ||
| else if (rgb.length >= 6) { | ||
| this.rgb = []; | ||
| rgb.match(/.{2}/g).map(function (c, i) { | ||
| if (i < 3) { | ||
| self.rgb.push(parseInt(c, 16)); | ||
| } | ||
| else { | ||
| self.alpha = (parseInt(c, 16)) / 255; | ||
| } | ||
| }); | ||
| } | ||
| else { | ||
| this.rgb = []; | ||
| rgb.split('').map(function (c, i) { | ||
| if (i < 3) { | ||
| self.rgb.push(parseInt(c + c, 16)); | ||
| } | ||
| else { | ||
| self.alpha = (parseInt(c + c, 16)) / 255; | ||
| } | ||
| }); | ||
| } | ||
| this.alpha = this.alpha || (typeof a === 'number' ? a : 1); | ||
| if (typeof originalForm !== 'undefined') { | ||
| this.value = originalForm; | ||
| } | ||
| }; | ||
| Color.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Color', | ||
| luma: function () { | ||
| var r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255; | ||
| luma() { | ||
| let r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255; | ||
| r = (r <= 0.03928) ? r / 12.92 : Math.pow(((r + 0.055) / 1.055), 2.4); | ||
| g = (g <= 0.03928) ? g / 12.92 : Math.pow(((g + 0.055) / 1.055), 2.4); | ||
| b = (b <= 0.03928) ? b / 12.92 : Math.pow(((b + 0.055) / 1.055), 2.4); | ||
| return 0.2126 * r + 0.7152 * g + 0.0722 * b; | ||
| }, | ||
| genCSS: function (context, output) { | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| output.add(this.toCSS(context)); | ||
| }, | ||
| toCSS: function (context, doNotCompress) { | ||
| var compress = context && context.compress && !doNotCompress; | ||
| var color; | ||
| var alpha; | ||
| var colorFunction; | ||
| var args = []; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {boolean} [doNotCompress] | ||
| * @returns {string} | ||
| */ | ||
| toCSS(context, doNotCompress) { | ||
| const compress = context && context.compress && !doNotCompress; | ||
| let color; | ||
| let alpha; | ||
| /** @type {string | undefined} */ | ||
| let colorFunction; | ||
| /** @type {(string | number)[]} */ | ||
| let args = []; | ||
| // `value` is set if this color was originally | ||
@@ -69,21 +96,18 @@ // converted from a named color string so we need | ||
| alpha = this.fround(context, this.alpha); | ||
| if (this.value) { | ||
| if (this.value.indexOf('rgb') === 0) { | ||
| if (/** @type {string} */ (this.value).indexOf('rgb') === 0) { | ||
| if (alpha < 1) { | ||
| colorFunction = 'rgba'; | ||
| } | ||
| } | ||
| else if (this.value.indexOf('hsl') === 0) { | ||
| } else if (/** @type {string} */ (this.value).indexOf('hsl') === 0) { | ||
| if (alpha < 1) { | ||
| colorFunction = 'hsla'; | ||
| } | ||
| else { | ||
| } else { | ||
| colorFunction = 'hsl'; | ||
| } | ||
| } else { | ||
| return /** @type {string} */ (this.value); | ||
| } | ||
| else { | ||
| return this.value; | ||
| } | ||
| } | ||
| else { | ||
| } else { | ||
| if (alpha < 1) { | ||
@@ -93,2 +117,3 @@ colorFunction = 'rgba'; | ||
| } | ||
| switch (colorFunction) { | ||
@@ -107,20 +132,26 @@ case 'rgba': | ||
| this.fround(context, color.h), | ||
| "".concat(this.fround(context, color.s * 100), "%"), | ||
| "".concat(this.fround(context, color.l * 100), "%") | ||
| `${this.fround(context, color.s * 100)}%`, | ||
| `${this.fround(context, color.l * 100)}%` | ||
| ].concat(args); | ||
| } | ||
| if (colorFunction) { | ||
| // Values are capped between `0` and `255`, rounded and zero-padded. | ||
| return "".concat(colorFunction, "(").concat(args.join(",".concat(compress ? '' : ' ')), ")"); | ||
| return `${colorFunction}(${args.join(`,${compress ? '' : ' '}`)})`; | ||
| } | ||
| color = this.toRGB(); | ||
| if (compress) { | ||
| var splitcolor = color.split(''); | ||
| const splitcolor = color.split(''); | ||
| // Convert color to short format | ||
| if (splitcolor[1] === splitcolor[2] && splitcolor[3] === splitcolor[4] && splitcolor[5] === splitcolor[6]) { | ||
| color = "#".concat(splitcolor[1]).concat(splitcolor[3]).concat(splitcolor[5]); | ||
| color = `#${splitcolor[1]}${splitcolor[3]}${splitcolor[5]}`; | ||
| } | ||
| } | ||
| return color; | ||
| }, | ||
| } | ||
| // | ||
@@ -132,77 +163,84 @@ // Operations have to be done per-channel, if not, | ||
| // | ||
| operate: function (context, op, other) { | ||
| var rgb = new Array(3); | ||
| var alpha = this.alpha * (1 - other.alpha) + other.alpha; | ||
| for (var c = 0; c < 3; c++) { | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {string} op | ||
| * @param {Color} other | ||
| */ | ||
| operate(context, op, other) { | ||
| const rgb = new Array(3); | ||
| const alpha = this.alpha * (1 - other.alpha) + other.alpha; | ||
| for (let c = 0; c < 3; c++) { | ||
| rgb[c] = this._operate(context, op, this.rgb[c], other.rgb[c]); | ||
| } | ||
| return new Color(rgb, alpha); | ||
| }, | ||
| toRGB: function () { | ||
| } | ||
| toRGB() { | ||
| return toHex(this.rgb); | ||
| }, | ||
| toHSL: function () { | ||
| var r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255, a = this.alpha; | ||
| var max = Math.max(r, g, b), min = Math.min(r, g, b); | ||
| var h; | ||
| var s; | ||
| var l = (max + min) / 2; | ||
| var d = max - min; | ||
| } | ||
| toHSL() { | ||
| const r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255, a = this.alpha; | ||
| const max = Math.max(r, g, b), min = Math.min(r, g, b); | ||
| /** @type {number} */ | ||
| let h; | ||
| let s; | ||
| const l = (max + min) / 2; | ||
| const d = max - min; | ||
| if (max === min) { | ||
| h = s = 0; | ||
| } | ||
| else { | ||
| } else { | ||
| s = l > 0.5 ? d / (2 - max - min) : d / (max + min); | ||
| switch (max) { | ||
| case r: | ||
| h = (g - b) / d + (g < b ? 6 : 0); | ||
| break; | ||
| case g: | ||
| h = (b - r) / d + 2; | ||
| break; | ||
| case b: | ||
| h = (r - g) / d + 4; | ||
| break; | ||
| case r: h = (g - b) / d + (g < b ? 6 : 0); break; | ||
| case g: h = (b - r) / d + 2; break; | ||
| case b: h = (r - g) / d + 4; break; | ||
| } | ||
| h /= 6; | ||
| /** @type {number} */ (h) /= 6; | ||
| } | ||
| return { h: h * 360, s: s, l: l, a: a }; | ||
| }, | ||
| return { h: /** @type {number} */ (h) * 360, s, l, a }; | ||
| } | ||
| // Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript | ||
| toHSV: function () { | ||
| var r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255, a = this.alpha; | ||
| var max = Math.max(r, g, b), min = Math.min(r, g, b); | ||
| var h; | ||
| var s; | ||
| var v = max; | ||
| var d = max - min; | ||
| toHSV() { | ||
| const r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255, a = this.alpha; | ||
| const max = Math.max(r, g, b), min = Math.min(r, g, b); | ||
| /** @type {number} */ | ||
| let h; | ||
| let s; | ||
| const v = max; | ||
| const d = max - min; | ||
| if (max === 0) { | ||
| s = 0; | ||
| } | ||
| else { | ||
| } else { | ||
| s = d / max; | ||
| } | ||
| if (max === min) { | ||
| h = 0; | ||
| } | ||
| else { | ||
| } else { | ||
| switch (max) { | ||
| case r: | ||
| h = (g - b) / d + (g < b ? 6 : 0); | ||
| break; | ||
| case g: | ||
| h = (b - r) / d + 2; | ||
| break; | ||
| case b: | ||
| h = (r - g) / d + 4; | ||
| break; | ||
| case r: h = (g - b) / d + (g < b ? 6 : 0); break; | ||
| case g: h = (b - r) / d + 2; break; | ||
| case b: h = (r - g) / d + 4; break; | ||
| } | ||
| h /= 6; | ||
| /** @type {number} */ (h) /= 6; | ||
| } | ||
| return { h: h * 360, s: s, v: v, a: a }; | ||
| }, | ||
| toARGB: function () { | ||
| return { h: /** @type {number} */ (h) * 360, s, v, a }; | ||
| } | ||
| toARGB() { | ||
| return toHex([this.alpha * 255].concat(this.rgb)); | ||
| }, | ||
| compare: function (x) { | ||
| } | ||
| /** | ||
| * @param {Node & { rgb?: number[], alpha?: number }} x | ||
| * @returns {0 | undefined} | ||
| */ | ||
| compare(x) { | ||
| return (x.rgb && | ||
@@ -212,30 +250,41 @@ x.rgb[0] === this.rgb[0] && | ||
| x.rgb[2] === this.rgb[2] && | ||
| x.alpha === this.alpha) ? 0 : undefined; | ||
| x.alpha === this.alpha) ? 0 : undefined; | ||
| } | ||
| }); | ||
| Color.fromKeyword = function (keyword) { | ||
| var c; | ||
| var key = keyword.toLowerCase(); | ||
| // eslint-disable-next-line no-prototype-builtins | ||
| if (colors_1.default.hasOwnProperty(key)) { | ||
| c = new Color(colors_1.default[key].slice(1)); | ||
| /** @param {string} keyword */ | ||
| static fromKeyword(keyword) { | ||
| /** @type {Color | undefined} */ | ||
| let c; | ||
| const key = keyword.toLowerCase(); | ||
| // eslint-disable-next-line no-prototype-builtins | ||
| if (colors.hasOwnProperty(key)) { | ||
| c = new Color(/** @type {string} */ (colors[/** @type {keyof typeof colors} */ (key)]).slice(1)); | ||
| } | ||
| else if (key === 'transparent') { | ||
| c = new Color([0, 0, 0], 0); | ||
| } | ||
| if (c) { | ||
| c.value = keyword; | ||
| return c; | ||
| } | ||
| } | ||
| else if (key === 'transparent') { | ||
| c = new Color([0, 0, 0], 0); | ||
| } | ||
| if (c) { | ||
| c.value = keyword; | ||
| return c; | ||
| } | ||
| }; | ||
| } | ||
| /** | ||
| * @param {number} v | ||
| * @param {number} max | ||
| */ | ||
| function clamp(v, max) { | ||
| return Math.min(Math.max(v, 0), max); | ||
| } | ||
| /** @param {number[]} v */ | ||
| function toHex(v) { | ||
| return "#".concat(v.map(function (c) { | ||
| return `#${v.map(function (c) { | ||
| c = clamp(Math.round(c), 255); | ||
| return (c < 16 ? '0' : '') + c.toString(16); | ||
| }).join('')); | ||
| }).join('')}`; | ||
| } | ||
| exports.default = Color; | ||
| //# sourceMappingURL=color.js.map | ||
| export default Color; |
@@ -1,6 +0,8 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var _noSpaceCombinators = { | ||
| // @ts-check | ||
| import Node from './node.js'; | ||
| /** @import { EvalContext, CSSOutput } from './node.js' */ | ||
| /** @type {Record<string, boolean>} */ | ||
| const _noSpaceCombinators = { | ||
| '': true, | ||
@@ -10,20 +12,28 @@ ' ': true, | ||
| }; | ||
| var Combinator = function (value) { | ||
| if (value === ' ') { | ||
| this.value = ' '; | ||
| this.emptyOrWhitespace = true; | ||
| class Combinator extends Node { | ||
| get type() { return 'Combinator'; } | ||
| /** @param {string} value */ | ||
| constructor(value) { | ||
| super(); | ||
| if (value === ' ') { | ||
| this.value = ' '; | ||
| this.emptyOrWhitespace = true; | ||
| } else { | ||
| this.value = value ? value.trim() : ''; | ||
| this.emptyOrWhitespace = this.value === ''; | ||
| } | ||
| } | ||
| else { | ||
| this.value = value ? value.trim() : ''; | ||
| this.emptyOrWhitespace = this.value === ''; | ||
| } | ||
| }; | ||
| Combinator.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Combinator', | ||
| genCSS: function (context, output) { | ||
| var spaceOrEmpty = (context.compress || _noSpaceCombinators[this.value]) ? '' : ' '; | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| const spaceOrEmpty = (context.compress || _noSpaceCombinators[/** @type {string} */ (this.value)]) ? '' : ' '; | ||
| output.add(spaceOrEmpty + this.value + spaceOrEmpty); | ||
| } | ||
| }); | ||
| exports.default = Combinator; | ||
| //# sourceMappingURL=combinator.js.map | ||
| } | ||
| export default Combinator; |
+44
-23
@@ -1,27 +0,48 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var debug_info_1 = tslib_1.__importDefault(require("./debug-info")); | ||
| var Comment = function (value, isLineComment, index, currentFileInfo) { | ||
| this.value = value; | ||
| this.isLineComment = isLineComment; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.allowRoot = true; | ||
| }; | ||
| Comment.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Comment', | ||
| genCSS: function (context, output) { | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, FileInfo } from './node.js' */ | ||
| /** @import { DebugInfoContext } from './debug-info.js' */ | ||
| import Node from './node.js'; | ||
| import getDebugInfo from './debug-info.js'; | ||
| class Comment extends Node { | ||
| get type() { return 'Comment'; } | ||
| /** | ||
| * @param {string} value | ||
| * @param {boolean} isLineComment | ||
| * @param {number} index | ||
| * @param {FileInfo} currentFileInfo | ||
| */ | ||
| constructor(value, isLineComment, index, currentFileInfo) { | ||
| super(); | ||
| this.value = value; | ||
| this.isLineComment = isLineComment; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.allowRoot = true; | ||
| /** @type {{ lineNumber: number, fileName: string } | undefined} */ | ||
| this.debugInfo = undefined; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| if (this.debugInfo) { | ||
| output.add((0, debug_info_1.default)(context, this), this.fileInfo(), this.getIndex()); | ||
| output.add(getDebugInfo(context, /** @type {DebugInfoContext} */ (this)), this.fileInfo(), this.getIndex()); | ||
| } | ||
| output.add(this.value); | ||
| }, | ||
| isSilent: function (context) { | ||
| var isCompressed = context.compress && this.value[2] !== '!'; | ||
| output.add(/** @type {string} */ (this.value)); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {boolean} | ||
| */ | ||
| isSilent(context) { | ||
| const isCompressed = context.compress && /** @type {string} */ (this.value)[2] !== '!'; | ||
| return this.isLineComment || isCompressed; | ||
| } | ||
| }); | ||
| exports.default = Comment; | ||
| //# sourceMappingURL=comment.js.map | ||
| } | ||
| export default Comment; |
@@ -1,40 +0,65 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var Condition = function (op, l, r, i, negate) { | ||
| this.op = op.trim(); | ||
| this.lvalue = l; | ||
| this.rvalue = r; | ||
| this._index = i; | ||
| this.negate = negate; | ||
| }; | ||
| Condition.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Condition', | ||
| accept: function (visitor) { | ||
| // @ts-check | ||
| /** @import { EvalContext, TreeVisitor } from './node.js' */ | ||
| import Node from './node.js'; | ||
| class Condition extends Node { | ||
| get type() { return 'Condition'; } | ||
| /** | ||
| * @param {string} op | ||
| * @param {Node} l | ||
| * @param {Node} r | ||
| * @param {number} i | ||
| * @param {boolean} negate | ||
| */ | ||
| constructor(op, l, r, i, negate) { | ||
| super(); | ||
| this.op = op.trim(); | ||
| this.lvalue = l; | ||
| this.rvalue = r; | ||
| this._index = i; | ||
| this.negate = negate; | ||
| } | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| this.lvalue = visitor.visit(this.lvalue); | ||
| this.rvalue = visitor.visit(this.rvalue); | ||
| }, | ||
| eval: function (context) { | ||
| var result = (function (op, a, b) { | ||
| switch (op) { | ||
| case 'and': return a && b; | ||
| case 'or': return a || b; | ||
| default: | ||
| switch (node_1.default.compare(a, b)) { | ||
| case -1: | ||
| return op === '<' || op === '=<' || op === '<='; | ||
| case 0: | ||
| return op === '=' || op === '>=' || op === '=<' || op === '<='; | ||
| case 1: | ||
| return op === '>' || op === '>='; | ||
| default: | ||
| return false; | ||
| } | ||
| } | ||
| })(this.op, this.lvalue.eval(context), this.rvalue.eval(context)); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {boolean} | ||
| * @suppress {checkTypes} | ||
| */ | ||
| // @ts-ignore - Condition.eval returns boolean, not Node (used as guard condition) | ||
| eval(context) { | ||
| const a = this.lvalue.eval(context); | ||
| const b = this.rvalue.eval(context); | ||
| /** @type {boolean} */ | ||
| let result; | ||
| switch (this.op) { | ||
| case 'and': result = Boolean(a && b); break; | ||
| case 'or': result = Boolean(a || b); break; | ||
| default: | ||
| switch (Node.compare(a, b)) { | ||
| case -1: | ||
| result = this.op === '<' || this.op === '=<' || this.op === '<='; | ||
| break; | ||
| case 0: | ||
| result = this.op === '=' || this.op === '>=' || this.op === '=<' || this.op === '<='; | ||
| break; | ||
| case 1: | ||
| result = this.op === '>' || this.op === '>='; | ||
| break; | ||
| default: | ||
| result = false; | ||
| } | ||
| } | ||
| return this.negate ? !result : result; | ||
| } | ||
| }); | ||
| exports.default = Condition; | ||
| //# sourceMappingURL=condition.js.map | ||
| } | ||
| export default Condition; |
@@ -1,27 +0,69 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var ruleset_1 = tslib_1.__importDefault(require("./ruleset")); | ||
| var value_1 = tslib_1.__importDefault(require("./value")); | ||
| var selector_1 = tslib_1.__importDefault(require("./selector")); | ||
| var atrule_1 = tslib_1.__importDefault(require("./atrule")); | ||
| var nested_at_rule_1 = tslib_1.__importDefault(require("./nested-at-rule")); | ||
| var Container = function (value, features, index, currentFileInfo, visibilityInfo) { | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| var selectors = (new selector_1.default([], null, null, this._index, this._fileInfo)).createEmptySelectors(); | ||
| this.features = new value_1.default(features); | ||
| this.rules = [new ruleset_1.default(selectors, value)]; | ||
| this.rules[0].allowImports = true; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| this.allowRoot = true; | ||
| this.setParent(selectors, this); | ||
| this.setParent(this.features, this); | ||
| this.setParent(this.rules, this); | ||
| }; | ||
| Container.prototype = Object.assign(new atrule_1.default(), tslib_1.__assign(tslib_1.__assign({ type: 'Container' }, nested_at_rule_1.default), { genCSS: function (context, output) { | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, FileInfo, VisibilityInfo } from './node.js' */ | ||
| /** @import { FunctionRegistry, NestableAtRuleThis } from './nested-at-rule.js' */ | ||
| import Node from './node.js'; | ||
| import Ruleset from './ruleset.js'; | ||
| import Value from './value.js'; | ||
| import Selector from './selector.js'; | ||
| import AtRule from './atrule.js'; | ||
| import NestableAtRulePrototype from './nested-at-rule.js'; | ||
| /** | ||
| * @typedef {Ruleset & { | ||
| * allowImports?: boolean, | ||
| * debugInfo?: { lineNumber: number, fileName: string }, | ||
| * functionRegistry?: FunctionRegistry | ||
| * }} RulesetWithExtras | ||
| */ | ||
| class Container extends AtRule { | ||
| get type() { return 'Container'; } | ||
| /** | ||
| * @param {Node[] | null} value | ||
| * @param {Node[]} features | ||
| * @param {number} index | ||
| * @param {FileInfo} currentFileInfo | ||
| * @param {VisibilityInfo} visibilityInfo | ||
| */ | ||
| constructor(value, features, index, currentFileInfo, visibilityInfo) { | ||
| super(); | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| const selectors = (new Selector([], null, null, this._index, this._fileInfo)).createEmptySelectors(); | ||
| /** @type {Value} */ | ||
| this.features = new Value(features); | ||
| /** @type {RulesetWithExtras[]} */ | ||
| this.rules = [new Ruleset(selectors, value)]; | ||
| this.rules[0].allowImports = true; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| this.allowRoot = true; | ||
| this.setParent(selectors, /** @type {Node} */ (/** @type {unknown} */ (this))); | ||
| this.setParent(this.features, /** @type {Node} */ (/** @type {unknown} */ (this))); | ||
| this.setParent(this.rules, /** @type {Node} */ (/** @type {unknown} */ (this))); | ||
| /** @type {boolean | undefined} */ | ||
| this._evaluated = undefined; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| output.add('@container ', this._fileInfo, this._index); | ||
| this.features.genCSS(context, output); | ||
| this.outputRuleset(context, output, this.rules); | ||
| }, eval: function (context) { | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Node} | ||
| */ | ||
| eval(context) { | ||
| if (this._evaluated) { | ||
| return /** @type {Node} */ (/** @type {unknown} */ (this)); | ||
| } | ||
| if (!context.mediaBlocks) { | ||
@@ -31,3 +73,5 @@ context.mediaBlocks = []; | ||
| } | ||
| var media = new Container(null, [], this._index, this._fileInfo, this.visibilityInfo()); | ||
| const media = new Container(null, [], this._index, this._fileInfo, this.visibilityInfo()); | ||
| media._evaluated = true; | ||
| if (this.debugInfo) { | ||
@@ -37,14 +81,26 @@ this.rules[0].debugInfo = this.debugInfo; | ||
| } | ||
| media.features = this.features.eval(context); | ||
| context.mediaPath.push(media); | ||
| context.mediaBlocks.push(media); | ||
| this.rules[0].functionRegistry = context.frames[0].functionRegistry.inherit(); | ||
| media.features = /** @type {Value} */ (this.features.eval(context)); | ||
| context.mediaPath.push(/** @type {Node} */ (/** @type {unknown} */ (media))); | ||
| context.mediaBlocks.push(/** @type {Node} */ (/** @type {unknown} */ (media))); | ||
| const fr = /** @type {RulesetWithExtras} */ (context.frames[0]).functionRegistry; | ||
| if (fr) { | ||
| this.rules[0].functionRegistry = fr.inherit(); | ||
| } | ||
| context.frames.unshift(this.rules[0]); | ||
| media.rules = [this.rules[0].eval(context)]; | ||
| media.rules = [/** @type {RulesetWithExtras} */ (this.rules[0].eval(context))]; | ||
| context.frames.shift(); | ||
| context.mediaPath.pop(); | ||
| return context.mediaPath.length === 0 ? media.evalTop(context) : | ||
| media.evalNested(context); | ||
| } })); | ||
| exports.default = Container; | ||
| //# sourceMappingURL=container.js.map | ||
| return context.mediaPath.length === 0 ? /** @type {NestableAtRuleThis} */ (/** @type {unknown} */ (media)).evalTop(context) : | ||
| /** @type {NestableAtRuleThis} */ (/** @type {unknown} */ (media)).evalNested(context); | ||
| } | ||
| } | ||
| // Apply NestableAtRulePrototype methods (accept, isRulesetLike override AtRule's versions) | ||
| Object.assign(Container.prototype, NestableAtRulePrototype); | ||
| export default Container; |
@@ -1,13 +0,25 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| // @ts-check | ||
| /** | ||
| * @typedef {object} DebugInfoData | ||
| * @property {number} lineNumber | ||
| * @property {string} fileName | ||
| */ | ||
| /** | ||
| * @typedef {object} DebugInfoContext | ||
| * @property {DebugInfoData} debugInfo | ||
| */ | ||
| /** | ||
| * @deprecated The dumpLineNumbers option is deprecated. Use sourcemaps instead. | ||
| * This will be removed in a future version. | ||
| * | ||
| * @param {Object} ctx - Context object with debugInfo | ||
| * @param {DebugInfoContext} ctx - Context object with debugInfo | ||
| * @returns {string} Debug info as CSS comment | ||
| */ | ||
| function asComment(ctx) { | ||
| return "/* line ".concat(ctx.debugInfo.lineNumber, ", ").concat(ctx.debugInfo.fileName, " */\n"); | ||
| return `/* line ${ctx.debugInfo.lineNumber}, ${ctx.debugInfo.fileName} */\n`; | ||
| } | ||
| /** | ||
@@ -19,22 +31,23 @@ * @deprecated The dumpLineNumbers option is deprecated. Use sourcemaps instead. | ||
| * | ||
| * @param {Object} ctx - Context object with debugInfo | ||
| * @param {DebugInfoContext} ctx - Context object with debugInfo | ||
| * @returns {string} Sass-compatible debug info as @media query | ||
| */ | ||
| function asMediaQuery(ctx) { | ||
| var filenameWithProtocol = ctx.debugInfo.fileName; | ||
| let filenameWithProtocol = ctx.debugInfo.fileName; | ||
| if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) { | ||
| filenameWithProtocol = "file://".concat(filenameWithProtocol); | ||
| filenameWithProtocol = `file://${filenameWithProtocol}`; | ||
| } | ||
| return "@media -sass-debug-info{filename{font-family:".concat(filenameWithProtocol.replace(/([.:/\\])/g, function (a) { | ||
| return `@media -sass-debug-info{filename{font-family:${filenameWithProtocol.replace(/([.:/\\])/g, function (a) { | ||
| if (a == '\\') { | ||
| a = '/'; | ||
| } | ||
| return "\\".concat(a); | ||
| }), "}line{font-family:\\00003").concat(ctx.debugInfo.lineNumber, "}}\n"); | ||
| return `\\${a}`; | ||
| })}}line{font-family:\\00003${ctx.debugInfo.lineNumber}}}\n`; | ||
| } | ||
| /** | ||
| * Generates debug information (line numbers) for CSS output. | ||
| * | ||
| * @param {Object} context - Context object with dumpLineNumbers option | ||
| * @param {Object} ctx - Context object with debugInfo | ||
| * @param {{ dumpLineNumbers?: string, compress?: boolean }} context - Context object with dumpLineNumbers option | ||
| * @param {DebugInfoContext} ctx - Context object with debugInfo | ||
| * @param {string} [lineSeparator] - Separator between comment and media query (for 'all' mode) | ||
@@ -49,3 +62,3 @@ * @returns {string} Debug info string | ||
| function debugInfo(context, ctx, lineSeparator) { | ||
| var result = ''; | ||
| let result = ''; | ||
| if (context.dumpLineNumbers && !context.compress) { | ||
@@ -66,3 +79,3 @@ switch (context.dumpLineNumbers) { | ||
| } | ||
| exports.default = debugInfo; | ||
| //# sourceMappingURL=debug-info.js.map | ||
| export default debugInfo; |
@@ -1,15 +0,21 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var value_1 = tslib_1.__importDefault(require("./value")); | ||
| var keyword_1 = tslib_1.__importDefault(require("./keyword")); | ||
| var anonymous_1 = tslib_1.__importDefault(require("./anonymous")); | ||
| var Constants = tslib_1.__importStar(require("../constants")); | ||
| var MATH = Constants.Math; | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, FileInfo } from './node.js' */ | ||
| import Node from './node.js'; | ||
| import Value from './value.js'; | ||
| import Keyword from './keyword.js'; | ||
| import Anonymous from './anonymous.js'; | ||
| import * as Constants from '../constants.js'; | ||
| const MATH = Constants.Math; | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {Node[]} name | ||
| * @returns {string} | ||
| */ | ||
| function evalName(context, name) { | ||
| var value = ''; | ||
| var i; | ||
| var n = name.length; | ||
| var output = { add: function (s) { value += s; } }; | ||
| let value = ''; | ||
| let i; | ||
| const n = name.length; | ||
| /** @type {CSSOutput} */ | ||
| const output = {add: function (s) {value += s;}, isEmpty: function() { return value === ''; }}; | ||
| for (i = 0; i < n; i++) { | ||
@@ -20,38 +26,64 @@ name[i].eval(context).genCSS(context, output); | ||
| } | ||
| var Declaration = function (name, value, important, merge, index, currentFileInfo, inline, variable) { | ||
| this.name = name; | ||
| this.value = (value instanceof node_1.default) ? value : new value_1.default([value ? new anonymous_1.default(value) : null]); | ||
| this.important = important ? " ".concat(important.trim()) : ''; | ||
| this.merge = merge; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.inline = inline || false; | ||
| this.variable = (variable !== undefined) ? variable | ||
| : (name.charAt && (name.charAt(0) === '@')); | ||
| this.allowRoot = true; | ||
| this.setParent(this.value, this); | ||
| }; | ||
| Declaration.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Declaration', | ||
| genCSS: function (context, output) { | ||
| output.add(this.name + (context.compress ? ':' : ': '), this.fileInfo(), this.getIndex()); | ||
| class Declaration extends Node { | ||
| get type() { return 'Declaration'; } | ||
| /** | ||
| * @param {string | Node[]} name | ||
| * @param {Node | string | null} value | ||
| * @param {string} [important] | ||
| * @param {string} [merge] | ||
| * @param {number} [index] | ||
| * @param {FileInfo} [currentFileInfo] | ||
| * @param {boolean} [inline] | ||
| * @param {boolean} [variable] | ||
| */ | ||
| constructor(name, value, important, merge, index, currentFileInfo, inline, variable) { | ||
| super(); | ||
| this.name = name; | ||
| this.value = (value instanceof Node) ? value : new Value([value ? new Anonymous(value) : null]); | ||
| this.important = important ? ` ${important.trim()}` : ''; | ||
| /** @type {string | undefined} */ | ||
| this.merge = merge; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| /** @type {boolean} */ | ||
| this.inline = inline || false; | ||
| /** @type {boolean} */ | ||
| this.variable = (variable !== undefined) ? variable | ||
| : (typeof name === 'string' && name.charAt(0) === '@'); | ||
| /** @type {boolean} */ | ||
| this.allowRoot = true; | ||
| this.setParent(this.value, this); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| output.add(/** @type {string} */ (this.name) + (context.compress ? ':' : ': '), this.fileInfo(), this.getIndex()); | ||
| try { | ||
| this.value.genCSS(context, output); | ||
| /** @type {Node} */ (this.value).genCSS(context, output); | ||
| } | ||
| catch (e) { | ||
| e.index = this._index; | ||
| e.filename = this._fileInfo.filename; | ||
| const err = /** @type {{ index?: number, filename?: string }} */ (e); | ||
| err.index = this._index; | ||
| err.filename = this._fileInfo && this._fileInfo.filename; | ||
| throw e; | ||
| } | ||
| output.add(this.important + ((this.inline || (context.lastRule && context.compress)) ? '' : ';'), this._fileInfo, this._index); | ||
| }, | ||
| eval: function (context) { | ||
| var mathBypass = false, prevMath, name = this.name, evaldValue, variable = this.variable; | ||
| } | ||
| /** @param {EvalContext} context */ | ||
| eval(context) { | ||
| let mathBypass = false, prevMath, name = this.name, evaldValue, variable = this.variable; | ||
| if (typeof name !== 'string') { | ||
| // expand 'primitive' name directly to get | ||
| // things faster (~10% for benchmark.less): | ||
| name = (name.length === 1) && (name[0] instanceof keyword_1.default) ? | ||
| name[0].value : evalName(context, name); | ||
| name = (/** @type {Node[]} */ (name).length === 1) && (/** @type {Node[]} */ (name)[0] instanceof Keyword) ? | ||
| /** @type {string} */ (/** @type {Node[]} */ (name)[0].value) : evalName(context, /** @type {Node[]} */ (name)); | ||
| variable = false; // never treat expanded interpolation as new variable name | ||
| } | ||
| // @todo remove when parens-division is default | ||
@@ -65,3 +97,4 @@ if (name === 'font' && context.math === MATH.ALWAYS) { | ||
| context.importantScope.push({}); | ||
| evaldValue = this.value.eval(context); | ||
| evaldValue = /** @type {Node} */ (this.value).eval(context); | ||
| if (!this.variable && evaldValue.type === 'DetachedRuleset') { | ||
@@ -71,13 +104,20 @@ throw { message: 'Rulesets cannot be evaluated on a property.', | ||
| } | ||
| var important = this.important; | ||
| var importantResult = context.importantScope.pop(); | ||
| if (!important && importantResult.important) { | ||
| let important = this.important; | ||
| const importantResult = context.importantScope.pop(); | ||
| if (!important && importantResult && importantResult.important) { | ||
| important = importantResult.important; | ||
| } | ||
| return new Declaration(name, evaldValue, important, this.merge, this.getIndex(), this.fileInfo(), this.inline, variable); | ||
| return new Declaration(/** @type {string} */ (name), | ||
| evaldValue, | ||
| important, | ||
| this.merge, | ||
| this.getIndex(), this.fileInfo(), this.inline, | ||
| variable); | ||
| } | ||
| catch (e) { | ||
| if (typeof e.index !== 'number') { | ||
| e.index = this.getIndex(); | ||
| e.filename = this.fileInfo().filename; | ||
| const err = /** @type {{ index?: number, filename?: string }} */ (e); | ||
| if (typeof err.index !== 'number') { | ||
| err.index = this.getIndex(); | ||
| err.filename = this.fileInfo().filename; | ||
| } | ||
@@ -91,8 +131,13 @@ throw e; | ||
| } | ||
| }, | ||
| makeImportant: function () { | ||
| return new Declaration(this.name, this.value, '!important', this.merge, this.getIndex(), this.fileInfo(), this.inline); | ||
| } | ||
| }); | ||
| exports.default = Declaration; | ||
| //# sourceMappingURL=declaration.js.map | ||
| makeImportant() { | ||
| return new Declaration(this.name, | ||
| /** @type {Node} */ (this.value), | ||
| '!important', | ||
| this.merge, | ||
| this.getIndex(), this.fileInfo(), this.inline); | ||
| } | ||
| } | ||
| export default Declaration; |
@@ -1,27 +0,45 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var contexts_1 = tslib_1.__importDefault(require("../contexts")); | ||
| var utils = tslib_1.__importStar(require("../utils")); | ||
| var DetachedRuleset = function (ruleset, frames) { | ||
| this.ruleset = ruleset; | ||
| this.frames = frames; | ||
| this.setParent(this.ruleset, this); | ||
| }; | ||
| DetachedRuleset.prototype = Object.assign(new node_1.default(), { | ||
| type: 'DetachedRuleset', | ||
| evalFirst: true, | ||
| accept: function (visitor) { | ||
| // @ts-check | ||
| /** @import { EvalContext, TreeVisitor } from './node.js' */ | ||
| import Node from './node.js'; | ||
| import contexts from '../contexts.js'; | ||
| import * as utils from '../utils.js'; | ||
| class DetachedRuleset extends Node { | ||
| get type() { return 'DetachedRuleset'; } | ||
| /** | ||
| * @param {Node} ruleset | ||
| * @param {Node[]} [frames] | ||
| */ | ||
| constructor(ruleset, frames) { | ||
| super(); | ||
| this.ruleset = ruleset; | ||
| this.frames = frames; | ||
| this.evalFirst = true; | ||
| this.setParent(this.ruleset, this); | ||
| } | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| this.ruleset = visitor.visit(this.ruleset); | ||
| }, | ||
| eval: function (context) { | ||
| var frames = this.frames || utils.copyArray(context.frames); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {DetachedRuleset} | ||
| */ | ||
| eval(context) { | ||
| const frames = this.frames || utils.copyArray(context.frames); | ||
| return new DetachedRuleset(this.ruleset, frames); | ||
| }, | ||
| callEval: function (context) { | ||
| return this.ruleset.eval(this.frames ? new contexts_1.default.Eval(context, this.frames.concat(context.frames)) : context); | ||
| } | ||
| }); | ||
| exports.default = DetachedRuleset; | ||
| //# sourceMappingURL=detached-ruleset.js.map | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Node} | ||
| */ | ||
| callEval(context) { | ||
| return this.ruleset.eval(this.frames ? new contexts.Eval(context, this.frames.concat(context.frames)) : context); | ||
| } | ||
| } | ||
| export default DetachedRuleset; |
+127
-71
@@ -1,40 +0,64 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| // @ts-check | ||
| /* eslint-disable no-prototype-builtins */ | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var unit_conversions_1 = tslib_1.__importDefault(require("../data/unit-conversions")); | ||
| var unit_1 = tslib_1.__importDefault(require("./unit")); | ||
| var color_1 = tslib_1.__importDefault(require("./color")); | ||
| import Node from './node.js'; | ||
| import unitConversions from '../data/unit-conversions.js'; | ||
| import Unit from './unit.js'; | ||
| import Color from './color.js'; | ||
| /** @import { EvalContext, CSSOutput } from './node.js' */ | ||
| // | ||
| // A number with a unit | ||
| // | ||
| var Dimension = function (value, unit) { | ||
| this.value = parseFloat(value); | ||
| if (isNaN(this.value)) { | ||
| throw new Error('Dimension is not a number.'); | ||
| class Dimension extends Node { | ||
| get type() { return 'Dimension'; } | ||
| /** | ||
| * @param {number | string} value | ||
| * @param {Unit | string} [unit] | ||
| */ | ||
| constructor(value, unit) { | ||
| super(); | ||
| /** @type {number} */ | ||
| this.value = parseFloat(/** @type {string} */ (value)); | ||
| if (isNaN(this.value)) { | ||
| throw new Error('Dimension is not a number.'); | ||
| } | ||
| /** @type {Unit} */ | ||
| this.unit = (unit && unit instanceof Unit) ? unit : | ||
| new Unit(unit ? [/** @type {string} */ (unit)] : undefined); | ||
| this.setParent(this.unit, this); | ||
| } | ||
| this.unit = (unit && unit instanceof unit_1.default) ? unit : | ||
| new unit_1.default(unit ? [unit] : undefined); | ||
| this.setParent(this.unit, this); | ||
| }; | ||
| Dimension.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Dimension', | ||
| accept: function (visitor) { | ||
| this.unit = visitor.visit(this.unit); | ||
| }, | ||
| /** | ||
| * @param {import('./node.js').TreeVisitor} visitor | ||
| */ | ||
| accept(visitor) { | ||
| this.unit = /** @type {Unit} */ (visitor.visit(this.unit)); | ||
| } | ||
| // remove when Nodes have JSDoc types | ||
| // eslint-disable-next-line no-unused-vars | ||
| eval: function (context) { | ||
| /** @param {EvalContext} context */ | ||
| eval(context) { | ||
| return this; | ||
| }, | ||
| toColor: function () { | ||
| return new color_1.default([this.value, this.value, this.value]); | ||
| }, | ||
| genCSS: function (context, output) { | ||
| } | ||
| toColor() { | ||
| const v = /** @type {number} */ (this.value); | ||
| return new Color([v, v, v]); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| if ((context && context.strictUnits) && !this.unit.isSingular()) { | ||
| throw new Error("Multiple units in dimension. Correct the units or use the unit function. Bad unit: ".concat(this.unit.toString())); | ||
| throw new Error(`Multiple units in dimension. Correct the units or use the unit function. Bad unit: ${this.unit.toString()}`); | ||
| } | ||
| var value = this.fround(context, this.value); | ||
| var strValue = String(value); | ||
| const value = this.fround(context, /** @type {number} */ (this.value)); | ||
| let strValue = String(value); | ||
| if (value !== 0 && value < 0.000001 && value > -0.000001) { | ||
@@ -44,2 +68,3 @@ // would be output 1e-6 etc. | ||
| } | ||
| if (context && context.compress) { | ||
@@ -51,17 +76,26 @@ // Zero values doesn't need a unit | ||
| } | ||
| // Float values doesn't need a leading zero | ||
| if (value > 0 && value < 1) { | ||
| strValue = (strValue).substr(1); | ||
| strValue = (strValue).slice(1); | ||
| } | ||
| } | ||
| output.add(strValue); | ||
| this.unit.genCSS(context, output); | ||
| }, | ||
| } | ||
| // In an operation between two Dimensions, | ||
| // we default to the first Dimension's unit, | ||
| // so `1px + 2` will yield `3px`. | ||
| operate: function (context, op, other) { | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {string} op | ||
| * @param {Dimension} other | ||
| */ | ||
| operate(context, op, other) { | ||
| /* jshint noempty:false */ | ||
| var value = this._operate(context, op, this.value, other.value); | ||
| var unit = this.unit.clone(); | ||
| let value = this._operate(context, op, /** @type {number} */ (this.value), /** @type {number} */ (other.value)); | ||
| let unit = this.unit.clone(); | ||
| if (op === '+' || op === '-') { | ||
@@ -73,21 +107,19 @@ if (unit.numerator.length === 0 && unit.denominator.length === 0) { | ||
| } | ||
| } | ||
| else if (other.unit.numerator.length === 0 && unit.denominator.length === 0) { | ||
| } else if (other.unit.numerator.length === 0 && unit.denominator.length === 0) { | ||
| // do nothing | ||
| } | ||
| else { | ||
| } else { | ||
| other = other.convertTo(this.unit.usedUnits()); | ||
| if (context.strictUnits && other.unit.toString() !== unit.toString()) { | ||
| throw new Error('Incompatible units. Change the units or use the unit function. ' | ||
| + "Bad units: '".concat(unit.toString(), "' and '").concat(other.unit.toString(), "'.")); | ||
| + `Bad units: '${unit.toString()}' and '${other.unit.toString()}'.`); | ||
| } | ||
| value = this._operate(context, op, this.value, other.value); | ||
| value = this._operate(context, op, /** @type {number} */ (this.value), /** @type {number} */ (other.value)); | ||
| } | ||
| } | ||
| else if (op === '*') { | ||
| } else if (op === '*') { | ||
| unit.numerator = unit.numerator.concat(other.unit.numerator).sort(); | ||
| unit.denominator = unit.denominator.concat(other.unit.denominator).sort(); | ||
| unit.cancel(); | ||
| } | ||
| else if (op === '/') { | ||
| } else if (op === '/') { | ||
| unit.numerator = unit.numerator.concat(other.unit.denominator).sort(); | ||
@@ -97,14 +129,20 @@ unit.denominator = unit.denominator.concat(other.unit.numerator).sort(); | ||
| } | ||
| return new Dimension(value, unit); | ||
| }, | ||
| compare: function (other) { | ||
| var a, b; | ||
| return new Dimension(/** @type {number} */ (value), unit); | ||
| } | ||
| /** | ||
| * @param {Node} other | ||
| * @returns {number | undefined} | ||
| */ | ||
| compare(other) { | ||
| let a, b; | ||
| if (!(other instanceof Dimension)) { | ||
| return undefined; | ||
| } | ||
| if (this.unit.isEmpty() || other.unit.isEmpty()) { | ||
| a = this; | ||
| b = other; | ||
| } | ||
| else { | ||
| } else { | ||
| a = this.unify(); | ||
@@ -116,19 +154,32 @@ b = other.unify(); | ||
| } | ||
| return node_1.default.numericCompare(a.value, b.value); | ||
| }, | ||
| unify: function () { | ||
| return Node.numericCompare(/** @type {number} */ (a.value), /** @type {number} */ (b.value)); | ||
| } | ||
| unify() { | ||
| return this.convertTo({ length: 'px', duration: 's', angle: 'rad' }); | ||
| }, | ||
| convertTo: function (conversions) { | ||
| var value = this.value; | ||
| var unit = this.unit.clone(); | ||
| var i; | ||
| var groupName; | ||
| var group; | ||
| var targetUnit; | ||
| var derivedConversions = {}; | ||
| var applyUnit; | ||
| } | ||
| /** | ||
| * @param {string | { [groupName: string]: string }} conversions | ||
| * @returns {Dimension} | ||
| */ | ||
| convertTo(conversions) { | ||
| let value = /** @type {number} */ (this.value); | ||
| const unit = this.unit.clone(); | ||
| let i; | ||
| /** @type {string} */ | ||
| let groupName; | ||
| /** @type {{ [unitName: string]: number }} */ | ||
| let group; | ||
| /** @type {string} */ | ||
| let targetUnit; | ||
| /** @type {{ [groupName: string]: string }} */ | ||
| let derivedConversions = {}; | ||
| /** @type {(atomicUnit: string, denominator: boolean) => string} */ | ||
| let applyUnit; | ||
| if (typeof conversions === 'string') { | ||
| for (i in unit_conversions_1.default) { | ||
| if (unit_conversions_1.default[i].hasOwnProperty(conversions)) { | ||
| for (i in unitConversions) { | ||
| if (unitConversions[/** @type {keyof typeof unitConversions} */ (i)].hasOwnProperty(conversions)) { | ||
| derivedConversions = {}; | ||
@@ -144,22 +195,27 @@ derivedConversions[i] = conversions; | ||
| value = value / (group[atomicUnit] / group[targetUnit]); | ||
| } | ||
| else { | ||
| } else { | ||
| value = value * (group[atomicUnit] / group[targetUnit]); | ||
| } | ||
| return targetUnit; | ||
| } | ||
| return atomicUnit; | ||
| }; | ||
| for (groupName in conversions) { | ||
| if (conversions.hasOwnProperty(groupName)) { | ||
| targetUnit = conversions[groupName]; | ||
| group = unit_conversions_1.default[groupName]; | ||
| group = /** @type {{ [unitName: string]: number }} */ (unitConversions[/** @type {keyof typeof unitConversions} */ (groupName)]); | ||
| unit.map(applyUnit); | ||
| } | ||
| } | ||
| unit.cancel(); | ||
| return new Dimension(value, unit); | ||
| } | ||
| }); | ||
| exports.default = Dimension; | ||
| //# sourceMappingURL=dimension.js.map | ||
| } | ||
| export default Dimension; |
+82
-52
@@ -1,63 +0,93 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var paren_1 = tslib_1.__importDefault(require("./paren")); | ||
| var combinator_1 = tslib_1.__importDefault(require("./combinator")); | ||
| var Element = function (combinator, value, isVariable, index, currentFileInfo, visibilityInfo) { | ||
| this.combinator = combinator instanceof combinator_1.default ? | ||
| combinator : new combinator_1.default(combinator); | ||
| if (typeof value === 'string') { | ||
| this.value = value.trim(); | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, TreeVisitor, FileInfo, VisibilityInfo } from './node.js' */ | ||
| import Node from './node.js'; | ||
| import Paren from './paren.js'; | ||
| import Combinator from './combinator.js'; | ||
| class Element extends Node { | ||
| get type() { return 'Element'; } | ||
| /** | ||
| * @param {Combinator | string} combinator | ||
| * @param {string | Node} value | ||
| * @param {boolean} [isVariable] | ||
| * @param {number} [index] | ||
| * @param {FileInfo} [currentFileInfo] | ||
| * @param {VisibilityInfo} [visibilityInfo] | ||
| */ | ||
| constructor(combinator, value, isVariable, index, currentFileInfo, visibilityInfo) { | ||
| super(); | ||
| this.combinator = combinator instanceof Combinator ? | ||
| combinator : new Combinator(combinator); | ||
| if (typeof value === 'string') { | ||
| this.value = value.trim(); | ||
| } else if (value) { | ||
| this.value = value; | ||
| } else { | ||
| this.value = ''; | ||
| } | ||
| /** @type {boolean | undefined} */ | ||
| this.isVariable = isVariable; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| this.setParent(this.combinator, this); | ||
| } | ||
| else if (value) { | ||
| this.value = value; | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| const value = this.value; | ||
| this.combinator = /** @type {Combinator} */ (visitor.visit(this.combinator)); | ||
| if (typeof value === 'object') { | ||
| this.value = visitor.visit(/** @type {Node} */ (value)); | ||
| } | ||
| } | ||
| else { | ||
| this.value = ''; | ||
| /** @param {EvalContext} context */ | ||
| eval(context) { | ||
| return new Element(this.combinator, | ||
| /** @type {Node} */ (this.value).eval ? /** @type {Node} */ (this.value).eval(context) : /** @type {string} */ (this.value), | ||
| this.isVariable, | ||
| this.getIndex(), | ||
| this.fileInfo(), this.visibilityInfo()); | ||
| } | ||
| this.isVariable = isVariable; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| this.setParent(this.combinator, this); | ||
| }; | ||
| Element.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Element', | ||
| accept: function (visitor) { | ||
| var value = this.value; | ||
| this.combinator = visitor.visit(this.combinator); | ||
| if (typeof value === 'object') { | ||
| this.value = visitor.visit(value); | ||
| } | ||
| }, | ||
| eval: function (context) { | ||
| return new Element(this.combinator, this.value.eval ? this.value.eval(context) : this.value, this.isVariable, this.getIndex(), this.fileInfo(), this.visibilityInfo()); | ||
| }, | ||
| clone: function () { | ||
| return new Element(this.combinator, this.value, this.isVariable, this.getIndex(), this.fileInfo(), this.visibilityInfo()); | ||
| }, | ||
| genCSS: function (context, output) { | ||
| clone() { | ||
| return new Element(this.combinator, | ||
| /** @type {string | Node} */ (this.value), | ||
| this.isVariable, | ||
| this.getIndex(), | ||
| this.fileInfo(), this.visibilityInfo()); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| output.add(this.toCSS(context), this.fileInfo(), this.getIndex()); | ||
| }, | ||
| toCSS: function (context) { | ||
| context = context || {}; | ||
| var value = this.value; | ||
| var firstSelector = context.firstSelector; | ||
| if (value instanceof paren_1.default) { | ||
| } | ||
| /** @param {EvalContext} [context] */ | ||
| toCSS(context) { | ||
| /** @type {EvalContext & { firstSelector?: boolean }} */ | ||
| const ctx = context || {}; | ||
| let value = this.value; | ||
| const firstSelector = ctx.firstSelector; | ||
| if (value instanceof Paren) { | ||
| // selector in parens should not be affected by outer selector | ||
| // flags (breaks only interpolated selectors - see #1973) | ||
| context.firstSelector = true; | ||
| ctx.firstSelector = true; | ||
| } | ||
| value = value.toCSS ? value.toCSS(context) : value; | ||
| context.firstSelector = firstSelector; | ||
| value = /** @type {Node} */ (value).toCSS ? /** @type {Node} */ (value).toCSS(ctx) : /** @type {string} */ (value); | ||
| ctx.firstSelector = firstSelector; | ||
| if (value === '' && this.combinator.value.charAt(0) === '&') { | ||
| return ''; | ||
| } else { | ||
| return this.combinator.toCSS(ctx) + value; | ||
| } | ||
| else { | ||
| return this.combinator.toCSS(context) + value; | ||
| } | ||
| } | ||
| }); | ||
| exports.default = Element; | ||
| //# sourceMappingURL=element.js.map | ||
| } | ||
| export default Element; |
@@ -1,32 +0,50 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var paren_1 = tslib_1.__importDefault(require("./paren")); | ||
| var comment_1 = tslib_1.__importDefault(require("./comment")); | ||
| var dimension_1 = tslib_1.__importDefault(require("./dimension")); | ||
| var anonymous_1 = tslib_1.__importDefault(require("./anonymous")); | ||
| var Expression = function (value, noSpacing) { | ||
| this.value = value; | ||
| this.noSpacing = noSpacing; | ||
| if (!value) { | ||
| throw new Error('Expression requires an array parameter'); | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, TreeVisitor } from './node.js' */ | ||
| import Node from './node.js'; | ||
| import Paren from './paren.js'; | ||
| import Comment from './comment.js'; | ||
| import Dimension from './dimension.js'; | ||
| import Anonymous from './anonymous.js'; | ||
| class Expression extends Node { | ||
| get type() { return 'Expression'; } | ||
| /** | ||
| * @param {Node[]} value | ||
| * @param {boolean} [noSpacing] | ||
| */ | ||
| constructor(value, noSpacing) { | ||
| super(); | ||
| this.value = value; | ||
| /** @type {boolean | undefined} */ | ||
| this.noSpacing = noSpacing; | ||
| /** @type {boolean | undefined} */ | ||
| this.parens = undefined; | ||
| /** @type {boolean | undefined} */ | ||
| this.parensInOp = undefined; | ||
| if (!value) { | ||
| throw new Error('Expression requires an array parameter'); | ||
| } | ||
| } | ||
| }; | ||
| Expression.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Expression', | ||
| accept: function (visitor) { | ||
| this.value = visitor.visitArray(this.value); | ||
| }, | ||
| eval: function (context) { | ||
| var noSpacing = this.noSpacing; | ||
| var returnValue; | ||
| var mathOn = context.isMathOn(); | ||
| var inParenthesis = this.parens; | ||
| var doubleParen = false; | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| this.value = visitor.visitArray(/** @type {Node[]} */ (this.value)); | ||
| } | ||
| /** @param {EvalContext} context */ | ||
| eval(context) { | ||
| const noSpacing = this.noSpacing; | ||
| /** @type {Node | Expression} */ | ||
| let returnValue; | ||
| const mathOn = context.isMathOn(); | ||
| const inParenthesis = this.parens; | ||
| let doubleParen = false; | ||
| if (inParenthesis) { | ||
| context.inParenthesis(); | ||
| } | ||
| if (this.value.length > 1) { | ||
| returnValue = new Expression(this.value.map(function (e) { | ||
| const value = /** @type {Node[]} */ (this.value); | ||
| if (value.length > 1) { | ||
| returnValue = new Expression(value.map(function (e) { | ||
| if (!e.eval) { | ||
@@ -37,10 +55,9 @@ return e; | ||
| }), this.noSpacing); | ||
| } | ||
| else if (this.value.length === 1) { | ||
| if (this.value[0].parens && !this.value[0].parensInOp && !context.inCalc) { | ||
| } else if (value.length === 1) { | ||
| const first = /** @type {Expression} */ (value[0]); | ||
| if (first.parens && !first.parensInOp && !context.inCalc) { | ||
| doubleParen = true; | ||
| } | ||
| returnValue = this.value[0].eval(context); | ||
| } | ||
| else { | ||
| returnValue = value[0].eval(context); | ||
| } else { | ||
| returnValue = this; | ||
@@ -52,14 +69,21 @@ } | ||
| if (this.parens && this.parensInOp && !mathOn && !doubleParen | ||
| && (!(returnValue instanceof dimension_1.default))) { | ||
| returnValue = new paren_1.default(returnValue); | ||
| && (!(returnValue instanceof Dimension))) { | ||
| returnValue = new Paren(returnValue); | ||
| } | ||
| returnValue.noSpacing = returnValue.noSpacing || noSpacing; | ||
| /** @type {Expression} */ (returnValue).noSpacing = | ||
| /** @type {Expression} */ (returnValue).noSpacing || noSpacing; | ||
| return returnValue; | ||
| }, | ||
| genCSS: function (context, output) { | ||
| for (var i = 0; i < this.value.length; i++) { | ||
| this.value[i].genCSS(context, output); | ||
| if (!this.noSpacing && i + 1 < this.value.length) { | ||
| if (i + 1 < this.value.length && !(this.value[i + 1] instanceof anonymous_1.default) || | ||
| this.value[i + 1] instanceof anonymous_1.default && this.value[i + 1].value !== ',') { | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| const value = /** @type {Node[]} */ (this.value); | ||
| for (let i = 0; i < value.length; i++) { | ||
| value[i].genCSS(context, output); | ||
| if (!this.noSpacing && i + 1 < value.length) { | ||
| if (!(value[i + 1] instanceof Anonymous) || | ||
| value[i + 1] instanceof Anonymous && /** @type {string} */ (value[i + 1].value) !== ',') { | ||
| output.add(' '); | ||
@@ -69,10 +93,11 @@ } | ||
| } | ||
| }, | ||
| throwAwayComments: function () { | ||
| this.value = this.value.filter(function (v) { | ||
| return !(v instanceof comment_1.default); | ||
| } | ||
| throwAwayComments() { | ||
| this.value = /** @type {Node[]} */ (this.value).filter(function(v) { | ||
| return !(v instanceof Comment); | ||
| }); | ||
| } | ||
| }); | ||
| exports.default = Expression; | ||
| //# sourceMappingURL=expression.js.map | ||
| } | ||
| export default Expression; |
+71
-42
@@ -1,44 +0,71 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var selector_1 = tslib_1.__importDefault(require("./selector")); | ||
| var Extend = function (selector, option, index, currentFileInfo, visibilityInfo) { | ||
| this.selector = selector; | ||
| this.option = option; | ||
| this.object_id = Extend.next_id++; | ||
| this.parent_ids = [this.object_id]; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| this.allowRoot = true; | ||
| switch (option) { | ||
| case '!all': | ||
| case 'all': | ||
| this.allowBefore = true; | ||
| this.allowAfter = true; | ||
| break; | ||
| default: | ||
| this.allowBefore = false; | ||
| this.allowAfter = false; | ||
| break; | ||
| // @ts-check | ||
| /** @import { EvalContext, TreeVisitor, FileInfo, VisibilityInfo } from './node.js' */ | ||
| import Node from './node.js'; | ||
| import Selector from './selector.js'; | ||
| class Extend extends Node { | ||
| get type() { return 'Extend'; } | ||
| /** | ||
| * @param {Selector} selector | ||
| * @param {string} option | ||
| * @param {number} index | ||
| * @param {FileInfo} currentFileInfo | ||
| * @param {VisibilityInfo} [visibilityInfo] | ||
| */ | ||
| constructor(selector, option, index, currentFileInfo, visibilityInfo) { | ||
| super(); | ||
| this.selector = selector; | ||
| this.option = option; | ||
| this.object_id = Extend.next_id++; | ||
| /** @type {number[]} */ | ||
| this.parent_ids = [this.object_id]; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| /** @type {boolean} */ | ||
| this.allowRoot = true; | ||
| /** @type {boolean} */ | ||
| this.allowBefore = false; | ||
| /** @type {boolean} */ | ||
| this.allowAfter = false; | ||
| switch (option) { | ||
| case '!all': | ||
| case 'all': | ||
| this.allowBefore = true; | ||
| this.allowAfter = true; | ||
| break; | ||
| default: | ||
| this.allowBefore = false; | ||
| this.allowAfter = false; | ||
| break; | ||
| } | ||
| this.setParent(this.selector, this); | ||
| } | ||
| this.setParent(this.selector, this); | ||
| }; | ||
| Extend.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Extend', | ||
| accept: function (visitor) { | ||
| this.selector = visitor.visit(this.selector); | ||
| }, | ||
| eval: function (context) { | ||
| return new Extend(this.selector.eval(context), this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo()); | ||
| }, | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| this.selector = /** @type {Selector} */ (visitor.visit(this.selector)); | ||
| } | ||
| /** @param {EvalContext} context */ | ||
| eval(context) { | ||
| return new Extend(/** @type {Selector} */ (this.selector.eval(context)), this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo()); | ||
| } | ||
| // remove when Nodes have JSDoc types | ||
| // eslint-disable-next-line no-unused-vars | ||
| clone: function (context) { | ||
| /** @param {EvalContext} [context] */ | ||
| clone(context) { | ||
| return new Extend(this.selector, this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo()); | ||
| }, | ||
| } | ||
| // it concatenates (joins) all selectors in selector array | ||
| findSelfSelectors: function (selectors) { | ||
| var selfElements = [], i, selectorElements; | ||
| /** @param {Selector[]} selectors */ | ||
| findSelfSelectors(selectors) { | ||
| /** @type {import('./element.js').default[]} */ | ||
| let selfElements = []; | ||
| let i, selectorElements; | ||
| for (i = 0; i < selectors.length; i++) { | ||
@@ -53,8 +80,10 @@ selectorElements = selectors[i].elements; | ||
| } | ||
| this.selfSelectors = [new selector_1.default(selfElements)]; | ||
| /** @type {Selector[]} */ | ||
| this.selfSelectors = [new Selector(selfElements)]; | ||
| this.selfSelectors[0].copyVisibilityInfo(this.visibilityInfo()); | ||
| } | ||
| }); | ||
| } | ||
| Extend.next_id = 0; | ||
| exports.default = Extend; | ||
| //# sourceMappingURL=extend.js.map | ||
| export default Extend; |
+184
-110
@@ -1,13 +0,21 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var media_1 = tslib_1.__importDefault(require("./media")); | ||
| var url_1 = tslib_1.__importDefault(require("./url")); | ||
| var quoted_1 = tslib_1.__importDefault(require("./quoted")); | ||
| var ruleset_1 = tslib_1.__importDefault(require("./ruleset")); | ||
| var anonymous_1 = tslib_1.__importDefault(require("./anonymous")); | ||
| var utils = tslib_1.__importStar(require("../utils")); | ||
| var less_error_1 = tslib_1.__importDefault(require("../less-error")); | ||
| var expression_1 = tslib_1.__importDefault(require("./expression")); | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, TreeVisitor, FileInfo, VisibilityInfo } from './node.js' */ | ||
| import Node from './node.js'; | ||
| import Media from './media.js'; | ||
| import URL from './url.js'; | ||
| import Quoted from './quoted.js'; | ||
| import Ruleset from './ruleset.js'; | ||
| import Anonymous from './anonymous.js'; | ||
| import Expression from './expression.js'; | ||
| import * as utils from '../utils.js'; | ||
| import LessError from '../less-error.js'; | ||
| /** | ||
| * @typedef {object} ImportOptions | ||
| * @property {boolean} [less] | ||
| * @property {boolean} [inline] | ||
| * @property {boolean} [isPlugin] | ||
| * @property {boolean} [reference] | ||
| */ | ||
| // | ||
@@ -25,25 +33,55 @@ // CSS @import node | ||
| // | ||
| var Import = function (path, features, options, index, currentFileInfo, visibilityInfo) { | ||
| this.options = options; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.path = path; | ||
| this.features = features; | ||
| this.allowRoot = true; | ||
| if (this.options.less !== undefined || this.options.inline) { | ||
| this.css = !this.options.less || this.options.inline; | ||
| } | ||
| else { | ||
| var pathValue = this.getPath(); | ||
| if (pathValue && /[#.&?]css([?;].*)?$/.test(pathValue)) { | ||
| this.css = true; | ||
| class Import extends Node { | ||
| get type() { return 'Import'; } | ||
| /** | ||
| * @param {Node} path | ||
| * @param {Node | null} features | ||
| * @param {ImportOptions} options | ||
| * @param {number} index | ||
| * @param {FileInfo} [currentFileInfo] | ||
| * @param {VisibilityInfo} [visibilityInfo] | ||
| */ | ||
| constructor(path, features, options, index, currentFileInfo, visibilityInfo) { | ||
| super(); | ||
| /** @type {ImportOptions} */ | ||
| this.options = options; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.path = path; | ||
| /** @type {Node | null} */ | ||
| this.features = features; | ||
| /** @type {boolean} */ | ||
| this.allowRoot = true; | ||
| /** @type {boolean | undefined} */ | ||
| this.css = undefined; | ||
| /** @type {boolean | undefined} */ | ||
| this.layerCss = undefined; | ||
| /** @type {(Ruleset & { imports?: object, filename?: string, functions?: object, functionRegistry?: { addMultiple: (fns: object) => void } }) | undefined} */ | ||
| this.root = undefined; | ||
| /** @type {string | undefined} */ | ||
| this.importedFilename = undefined; | ||
| /** @type {boolean | (() => boolean) | undefined} */ | ||
| this.skip = undefined; | ||
| /** @type {{ message: string, index: number, filename: string } | undefined} */ | ||
| this.error = undefined; | ||
| if (this.options.less !== undefined || this.options.inline) { | ||
| this.css = !this.options.less || this.options.inline; | ||
| } else { | ||
| const pathValue = this.getPath(); | ||
| if (pathValue && /[#.&?]css([?;].*)?$/.test(pathValue)) { | ||
| this.css = true; | ||
| } | ||
| } | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| if (this.features) { | ||
| this.setParent(this.features, /** @type {Node} */ (this)); | ||
| } | ||
| this.setParent(this.path, /** @type {Node} */ (this)); | ||
| } | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| this.setParent(this.features, this); | ||
| this.setParent(this.path, this); | ||
| }; | ||
| Import.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Import', | ||
| accept: function (visitor) { | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| if (this.features) { | ||
@@ -54,6 +92,11 @@ this.features = visitor.visit(this.features); | ||
| if (!this.options.isPlugin && !this.options.inline && this.root) { | ||
| this.root = visitor.visit(this.root); | ||
| this.root = /** @type {Ruleset} */ (visitor.visit(this.root)); | ||
| } | ||
| }, | ||
| genCSS: function (context, output) { | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| if (this.css && this.path._fileInfo.reference === undefined) { | ||
@@ -68,30 +111,43 @@ output.add('@import ', this._fileInfo, this._index); | ||
| } | ||
| }, | ||
| getPath: function () { | ||
| return (this.path instanceof url_1.default) ? | ||
| this.path.value.value : this.path.value; | ||
| }, | ||
| isVariableImport: function () { | ||
| var path = this.path; | ||
| if (path instanceof url_1.default) { | ||
| path = path.value; | ||
| } | ||
| /** @returns {string | undefined} */ | ||
| getPath() { | ||
| return (this.path instanceof URL) ? | ||
| /** @type {string} */ (/** @type {Node} */ (this.path.value).value) : | ||
| /** @type {string | undefined} */ (this.path.value); | ||
| } | ||
| /** @returns {boolean | RegExpMatchArray | null} */ | ||
| isVariableImport() { | ||
| let path = this.path; | ||
| if (path instanceof URL) { | ||
| path = /** @type {Node} */ (path.value); | ||
| } | ||
| if (path instanceof quoted_1.default) { | ||
| if (path instanceof Quoted) { | ||
| return path.containsVariables(); | ||
| } | ||
| return true; | ||
| }, | ||
| evalForImport: function (context) { | ||
| var path = this.path; | ||
| if (path instanceof url_1.default) { | ||
| path = path.value; | ||
| } | ||
| /** @param {EvalContext} context */ | ||
| evalForImport(context) { | ||
| let path = this.path; | ||
| if (path instanceof URL) { | ||
| path = /** @type {Node} */ (path.value); | ||
| } | ||
| return new Import(path.eval(context), this.features, this.options, this._index, this._fileInfo, this.visibilityInfo()); | ||
| }, | ||
| evalPath: function (context) { | ||
| var path = this.path.eval(context); | ||
| var fileInfo = this._fileInfo; | ||
| if (!(path instanceof url_1.default)) { | ||
| return new Import(path.eval(context), this.features, this.options, this._index || 0, this._fileInfo, this.visibilityInfo()); | ||
| } | ||
| /** @param {EvalContext} context */ | ||
| evalPath(context) { | ||
| const path = this.path.eval(context); | ||
| const fileInfo = this._fileInfo; | ||
| if (!(path instanceof URL)) { | ||
| // Add the rootpath if the URL requires a rewrite | ||
| var pathValue = path.value; | ||
| const pathValue = /** @type {string} */ (path.value); | ||
| if (fileInfo && | ||
@@ -101,27 +157,32 @@ pathValue && | ||
| path.value = context.rewritePath(pathValue, fileInfo.rootpath); | ||
| } else { | ||
| path.value = context.normalizePath(/** @type {string} */ (path.value)); | ||
| } | ||
| else { | ||
| path.value = context.normalizePath(path.value); | ||
| } | ||
| } | ||
| return path; | ||
| }, | ||
| eval: function (context) { | ||
| var result = this.doEval(context); | ||
| } | ||
| /** @param {EvalContext} context */ | ||
| // @ts-ignore - Import.eval returns Node | Node[] | Import (wider than Node.eval's Node return) | ||
| eval(context) { | ||
| const result = this.doEval(context); | ||
| if (this.options.reference || this.blocksVisibility()) { | ||
| if (result.length || result.length === 0) { | ||
| if (Array.isArray(result)) { | ||
| result.forEach(function (node) { | ||
| node.addVisibilityBlock(); | ||
| }); | ||
| } else { | ||
| /** @type {Node} */ (result).addVisibilityBlock(); | ||
| } | ||
| else { | ||
| result.addVisibilityBlock(); | ||
| } | ||
| } | ||
| return result; | ||
| }, | ||
| doEval: function (context) { | ||
| var ruleset; | ||
| var registry; | ||
| var features = this.features && this.features.eval(context); | ||
| } | ||
| /** @param {EvalContext} context */ | ||
| doEval(context) { | ||
| /** @type {Ruleset | undefined} */ | ||
| let ruleset; | ||
| const features = this.features && this.features.eval(context); | ||
| if (this.options.isPlugin) { | ||
@@ -133,12 +194,20 @@ if (this.root && this.root.eval) { | ||
| catch (e) { | ||
| e.message = 'Plugin error during evaluation'; | ||
| throw new less_error_1.default(e, this.root.imports, this.root.filename); | ||
| const err = /** @type {{ message: string }} */ (e); | ||
| err.message = 'Plugin error during evaluation'; | ||
| throw new LessError( | ||
| /** @type {{ message: string, index?: number, filename?: string }} */ (e), | ||
| /** @type {{ imports: object }} */ (/** @type {unknown} */ (this.root)).imports, | ||
| /** @type {{ filename: string }} */ (/** @type {unknown} */ (this.root)).filename | ||
| ); | ||
| } | ||
| } | ||
| registry = context.frames[0] && context.frames[0].functionRegistry; | ||
| const frame0 = /** @type {Ruleset & { functionRegistry?: { addMultiple: (fns: object) => void } }} */ (context.frames[0]); | ||
| const registry = frame0 && frame0.functionRegistry; | ||
| if (registry && this.root && this.root.functions) { | ||
| registry.addMultiple(this.root.functions); | ||
| } | ||
| return []; | ||
| } | ||
| if (this.skip) { | ||
@@ -153,8 +222,8 @@ if (typeof this.skip === 'function') { | ||
| if (this.features) { | ||
| var featureValue = this.features.value; | ||
| let featureValue = /** @type {Node[]} */ (this.features.value); | ||
| if (Array.isArray(featureValue) && featureValue.length >= 1) { | ||
| var expr = featureValue[0]; | ||
| if (expr.type === 'Expression' && Array.isArray(expr.value) && expr.value.length >= 2) { | ||
| featureValue = expr.value; | ||
| var isLayer = featureValue[0].type === 'Keyword' && featureValue[0].value === 'layer' | ||
| const expr = featureValue[0]; | ||
| if (expr.type === 'Expression' && Array.isArray(expr.value) && /** @type {Node[]} */ (expr.value).length >= 2) { | ||
| featureValue = /** @type {Node[]} */ (expr.value); | ||
| const isLayer = featureValue[0].type === 'Keyword' && featureValue[0].value === 'layer' | ||
| && featureValue[1].type === 'Paren'; | ||
@@ -168,10 +237,16 @@ if (isLayer) { | ||
| if (this.options.inline) { | ||
| var contents = new anonymous_1.default(this.root, 0, { | ||
| filename: this.importedFilename, | ||
| reference: this.path._fileInfo && this.path._fileInfo.reference | ||
| }, true, true); | ||
| return this.features ? new media_1.default([contents], this.features.value) : [contents]; | ||
| } | ||
| else if (this.css || this.layerCss) { | ||
| var newImport = new Import(this.evalPath(context), features, this.options, this._index); | ||
| const contents = new Anonymous( | ||
| /** @type {string} */ (/** @type {unknown} */ (this.root)), | ||
| 0, | ||
| { | ||
| filename: this.importedFilename, | ||
| reference: this.path._fileInfo && this.path._fileInfo.reference | ||
| }, | ||
| true, | ||
| true | ||
| ); | ||
| return this.features ? new Media([contents], /** @type {Node[]} */ (this.features.value)) : [contents]; | ||
| } else if (this.css || this.layerCss) { | ||
| const newImport = new Import(this.evalPath(context), features, this.options, this._index || 0); | ||
| if (this.layerCss) { | ||
@@ -185,17 +260,16 @@ newImport.css = this.layerCss; | ||
| return newImport; | ||
| } | ||
| else if (this.root) { | ||
| } else if (this.root) { | ||
| if (this.features) { | ||
| var featureValue = this.features.value; | ||
| let featureValue = /** @type {Node[]} */ (this.features.value); | ||
| if (Array.isArray(featureValue) && featureValue.length === 1) { | ||
| var expr = featureValue[0]; | ||
| if (expr.type === 'Expression' && Array.isArray(expr.value) && expr.value.length >= 2) { | ||
| featureValue = expr.value; | ||
| var isLayer = featureValue[0].type === 'Keyword' && featureValue[0].value === 'layer' | ||
| const expr = featureValue[0]; | ||
| if (expr.type === 'Expression' && Array.isArray(expr.value) && /** @type {Node[]} */ (expr.value).length >= 2) { | ||
| featureValue = /** @type {Node[]} */ (expr.value); | ||
| const isLayer = featureValue[0].type === 'Keyword' && featureValue[0].value === 'layer' | ||
| && featureValue[1].type === 'Paren'; | ||
| if (isLayer) { | ||
| this.layerCss = true; | ||
| featureValue[0] = new expression_1.default(featureValue.slice(0, 2)); | ||
| featureValue[0] = new Expression(/** @type {Node[]} */ (featureValue.slice(0, 2))); | ||
| featureValue.splice(1, 1); | ||
| featureValue[0].noSpacing = true; | ||
| /** @type {Expression} */ (featureValue[0]).noSpacing = true; | ||
| return this; | ||
@@ -206,19 +280,19 @@ } | ||
| } | ||
| ruleset = new ruleset_1.default(null, utils.copyArray(this.root.rules)); | ||
| ruleset = new Ruleset(null, utils.copyArray(this.root.rules)); | ||
| ruleset.evalImports(context); | ||
| return this.features ? new media_1.default(ruleset.rules, this.features.value) : ruleset.rules; | ||
| } | ||
| else { | ||
| return this.features ? new Media(ruleset.rules, /** @type {Node[]} */ (this.features.value)) : ruleset.rules; | ||
| } else { | ||
| if (this.features) { | ||
| var featureValue = this.features.value; | ||
| let featureValue = /** @type {Node[]} */ (this.features.value); | ||
| if (Array.isArray(featureValue) && featureValue.length >= 1) { | ||
| featureValue = featureValue[0].value; | ||
| featureValue = /** @type {Node[]} */ (featureValue[0].value); | ||
| if (Array.isArray(featureValue) && featureValue.length >= 2) { | ||
| var isLayer = featureValue[0].type === 'Keyword' && featureValue[0].value === 'layer' | ||
| const isLayer = featureValue[0].type === 'Keyword' && featureValue[0].value === 'layer' | ||
| && featureValue[1].type === 'Paren'; | ||
| if (isLayer) { | ||
| this.css = true; | ||
| featureValue[0] = new expression_1.default(featureValue.slice(0, 2)); | ||
| featureValue[0] = new Expression(/** @type {Node[]} */ (featureValue.slice(0, 2))); | ||
| featureValue.splice(1, 1); | ||
| featureValue[0].noSpacing = true; | ||
| /** @type {Expression} */ (featureValue[0]).noSpacing = true; | ||
| return this; | ||
@@ -232,4 +306,4 @@ } | ||
| } | ||
| }); | ||
| exports.default = Import; | ||
| //# sourceMappingURL=import.js.map | ||
| } | ||
| export default Import; |
+52
-81
@@ -1,85 +0,56 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var color_1 = tslib_1.__importDefault(require("./color")); | ||
| var atrule_1 = tslib_1.__importDefault(require("./atrule")); | ||
| var detached_ruleset_1 = tslib_1.__importDefault(require("./detached-ruleset")); | ||
| var operation_1 = tslib_1.__importDefault(require("./operation")); | ||
| var dimension_1 = tslib_1.__importDefault(require("./dimension")); | ||
| var unit_1 = tslib_1.__importDefault(require("./unit")); | ||
| var keyword_1 = tslib_1.__importDefault(require("./keyword")); | ||
| var variable_1 = tslib_1.__importDefault(require("./variable")); | ||
| var property_1 = tslib_1.__importDefault(require("./property")); | ||
| var ruleset_1 = tslib_1.__importDefault(require("./ruleset")); | ||
| var element_1 = tslib_1.__importDefault(require("./element")); | ||
| var attribute_1 = tslib_1.__importDefault(require("./attribute")); | ||
| var combinator_1 = tslib_1.__importDefault(require("./combinator")); | ||
| var selector_1 = tslib_1.__importDefault(require("./selector")); | ||
| var quoted_1 = tslib_1.__importDefault(require("./quoted")); | ||
| var expression_1 = tslib_1.__importDefault(require("./expression")); | ||
| var declaration_1 = tslib_1.__importDefault(require("./declaration")); | ||
| var call_1 = tslib_1.__importDefault(require("./call")); | ||
| var url_1 = tslib_1.__importDefault(require("./url")); | ||
| var import_1 = tslib_1.__importDefault(require("./import")); | ||
| var comment_1 = tslib_1.__importDefault(require("./comment")); | ||
| var anonymous_1 = tslib_1.__importDefault(require("./anonymous")); | ||
| var value_1 = tslib_1.__importDefault(require("./value")); | ||
| var javascript_1 = tslib_1.__importDefault(require("./javascript")); | ||
| var assignment_1 = tslib_1.__importDefault(require("./assignment")); | ||
| var condition_1 = tslib_1.__importDefault(require("./condition")); | ||
| var query_in_parens_1 = tslib_1.__importDefault(require("./query-in-parens")); | ||
| var paren_1 = tslib_1.__importDefault(require("./paren")); | ||
| var media_1 = tslib_1.__importDefault(require("./media")); | ||
| var container_1 = tslib_1.__importDefault(require("./container")); | ||
| var unicode_descriptor_1 = tslib_1.__importDefault(require("./unicode-descriptor")); | ||
| var negative_1 = tslib_1.__importDefault(require("./negative")); | ||
| var extend_1 = tslib_1.__importDefault(require("./extend")); | ||
| var variable_call_1 = tslib_1.__importDefault(require("./variable-call")); | ||
| var namespace_value_1 = tslib_1.__importDefault(require("./namespace-value")); | ||
| // @ts-check | ||
| import Node from './node.js'; | ||
| import Color from './color.js'; | ||
| import AtRule from './atrule.js'; | ||
| import DetachedRuleset from './detached-ruleset.js'; | ||
| import Operation from './operation.js'; | ||
| import Dimension from './dimension.js'; | ||
| import Unit from './unit.js'; | ||
| import Keyword from './keyword.js'; | ||
| import Variable from './variable.js'; | ||
| import Property from './property.js'; | ||
| import Ruleset from './ruleset.js'; | ||
| import Element from './element.js'; | ||
| import Attribute from './attribute.js'; | ||
| import Combinator from './combinator.js'; | ||
| import Selector from './selector.js'; | ||
| import Quoted from './quoted.js'; | ||
| import Expression from './expression.js'; | ||
| import Declaration from './declaration.js'; | ||
| import Call from './call.js'; | ||
| import URL from './url.js'; | ||
| import Import from './import.js'; | ||
| import Comment from './comment.js'; | ||
| import Anonymous from './anonymous.js'; | ||
| import Value from './value.js'; | ||
| import JavaScript from './javascript.js'; | ||
| import Assignment from './assignment.js'; | ||
| import Condition from './condition.js'; | ||
| import QueryInParens from './query-in-parens.js'; | ||
| import Paren from './paren.js'; | ||
| import Media from './media.js'; | ||
| import Container from './container.js'; | ||
| import UnicodeDescriptor from './unicode-descriptor.js'; | ||
| import Negative from './negative.js'; | ||
| import Extend from './extend.js'; | ||
| import VariableCall from './variable-call.js'; | ||
| import NamespaceValue from './namespace-value.js'; | ||
| // mixins | ||
| var mixin_call_1 = tslib_1.__importDefault(require("./mixin-call")); | ||
| var mixin_definition_1 = tslib_1.__importDefault(require("./mixin-definition")); | ||
| exports.default = { | ||
| Node: node_1.default, | ||
| Color: color_1.default, | ||
| AtRule: atrule_1.default, | ||
| DetachedRuleset: detached_ruleset_1.default, | ||
| Operation: operation_1.default, | ||
| Dimension: dimension_1.default, | ||
| Unit: unit_1.default, | ||
| Keyword: keyword_1.default, | ||
| Variable: variable_1.default, | ||
| Property: property_1.default, | ||
| Ruleset: ruleset_1.default, | ||
| Element: element_1.default, | ||
| Attribute: attribute_1.default, | ||
| Combinator: combinator_1.default, | ||
| Selector: selector_1.default, | ||
| Quoted: quoted_1.default, | ||
| Expression: expression_1.default, | ||
| Declaration: declaration_1.default, | ||
| Call: call_1.default, | ||
| URL: url_1.default, | ||
| Import: import_1.default, | ||
| Comment: comment_1.default, | ||
| Anonymous: anonymous_1.default, | ||
| Value: value_1.default, | ||
| JavaScript: javascript_1.default, | ||
| Assignment: assignment_1.default, | ||
| Condition: condition_1.default, | ||
| Paren: paren_1.default, | ||
| Media: media_1.default, | ||
| Container: container_1.default, | ||
| QueryInParens: query_in_parens_1.default, | ||
| UnicodeDescriptor: unicode_descriptor_1.default, | ||
| Negative: negative_1.default, | ||
| Extend: extend_1.default, | ||
| VariableCall: variable_call_1.default, | ||
| NamespaceValue: namespace_value_1.default, | ||
| import MixinCall from './mixin-call.js'; | ||
| import MixinDefinition from './mixin-definition.js'; | ||
| export default { | ||
| Node, Color, AtRule, DetachedRuleset, Operation, | ||
| Dimension, Unit, Keyword, Variable, Property, | ||
| Ruleset, Element, Attribute, Combinator, Selector, | ||
| Quoted, Expression, Declaration, Call, URL, Import, | ||
| Comment, Anonymous, Value, JavaScript, Assignment, | ||
| Condition, Paren, Media, Container, QueryInParens, | ||
| UnicodeDescriptor, Negative, Extend, VariableCall, | ||
| NamespaceValue, | ||
| mixin: { | ||
| Call: mixin_call_1.default, | ||
| Definition: mixin_definition_1.default | ||
| Call: MixinCall, | ||
| Definition: MixinDefinition | ||
| } | ||
| }; | ||
| //# sourceMappingURL=index.js.map |
@@ -1,34 +0,45 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var js_eval_node_1 = tslib_1.__importDefault(require("./js-eval-node")); | ||
| var dimension_1 = tslib_1.__importDefault(require("./dimension")); | ||
| var quoted_1 = tslib_1.__importDefault(require("./quoted")); | ||
| var anonymous_1 = tslib_1.__importDefault(require("./anonymous")); | ||
| var JavaScript = function (string, escaped, index, currentFileInfo) { | ||
| this.escaped = escaped; | ||
| this.expression = string; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| }; | ||
| JavaScript.prototype = Object.assign(new js_eval_node_1.default(), { | ||
| type: 'JavaScript', | ||
| eval: function (context) { | ||
| var result = this.evaluateJavaScript(this.expression, context); | ||
| var type = typeof result; | ||
| if (type === 'number' && !isNaN(result)) { | ||
| return new dimension_1.default(result); | ||
| // @ts-check | ||
| /** @import { EvalContext, FileInfo } from './node.js' */ | ||
| import JsEvalNode from './js-eval-node.js'; | ||
| import Dimension from './dimension.js'; | ||
| import Quoted from './quoted.js'; | ||
| import Anonymous from './anonymous.js'; | ||
| class JavaScript extends JsEvalNode { | ||
| get type() { return 'JavaScript'; } | ||
| /** | ||
| * @param {string} string | ||
| * @param {boolean} escaped | ||
| * @param {number} index | ||
| * @param {FileInfo} currentFileInfo | ||
| */ | ||
| constructor(string, escaped, index, currentFileInfo) { | ||
| super(); | ||
| this.escaped = escaped; | ||
| this.expression = string; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Dimension | Quoted | Anonymous} | ||
| */ | ||
| eval(context) { | ||
| const result = this.evaluateJavaScript(this.expression, context); | ||
| const type = typeof result; | ||
| if (type === 'number' && !isNaN(/** @type {number} */ (result))) { | ||
| return new Dimension(/** @type {number} */ (result)); | ||
| } else if (type === 'string') { | ||
| return new Quoted(`"${result}"`, /** @type {string} */ (result), this.escaped, this._index); | ||
| } else if (Array.isArray(result)) { | ||
| return new Anonymous(/** @type {string[]} */ (result).join(', ')); | ||
| } else { | ||
| return new Anonymous(/** @type {string} */ (result)); | ||
| } | ||
| else if (type === 'string') { | ||
| return new quoted_1.default("\"".concat(result, "\""), result, this.escaped, this._index); | ||
| } | ||
| else if (Array.isArray(result)) { | ||
| return new anonymous_1.default(result.join(', ')); | ||
| } | ||
| else { | ||
| return new anonymous_1.default(result); | ||
| } | ||
| } | ||
| }); | ||
| exports.default = JavaScript; | ||
| //# sourceMappingURL=javascript.js.map | ||
| } | ||
| export default JavaScript; |
@@ -1,12 +0,18 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var variable_1 = tslib_1.__importDefault(require("./variable")); | ||
| var JsEvalNode = function () { }; | ||
| JsEvalNode.prototype = Object.assign(new node_1.default(), { | ||
| evaluateJavaScript: function (expression, context) { | ||
| var result; | ||
| var that = this; | ||
| var evalContext = {}; | ||
| // @ts-check | ||
| /** @import { EvalContext } from './node.js' */ | ||
| import Node from './node.js'; | ||
| import Variable from './variable.js'; | ||
| class JsEvalNode extends Node { | ||
| /** | ||
| * @param {string} expression | ||
| * @param {EvalContext} context | ||
| * @returns {string | number | boolean} | ||
| */ | ||
| evaluateJavaScript(expression, context) { | ||
| let result; | ||
| const that = this; | ||
| /** @type {Record<string, { value: Node, toJS: () => string }>} */ | ||
| const evalContext = {}; | ||
| if (!context.javascriptEnabled) { | ||
@@ -17,15 +23,19 @@ throw { message: 'Inline JavaScript is not enabled. Is it set in your options?', | ||
| } | ||
| expression = expression.replace(/@\{([\w-]+)\}/g, function (_, name) { | ||
| return that.jsify(new variable_1.default("@".concat(name), that.getIndex(), that.fileInfo()).eval(context)); | ||
| return that.jsify(new Variable(`@${name}`, that.getIndex(), that.fileInfo()).eval(context)); | ||
| }); | ||
| /** @type {Function} */ | ||
| let expressionFunc; | ||
| try { | ||
| expression = new Function("return (".concat(expression, ")")); | ||
| } | ||
| catch (e) { | ||
| throw { message: "JavaScript evaluation error: ".concat(e.message, " from `").concat(expression, "`"), | ||
| expressionFunc = new Function(`return (${expression})`); | ||
| } catch (e) { | ||
| throw { message: `JavaScript evaluation error: ${/** @type {Error} */ (e).message} from \`${expression}\`` , | ||
| filename: this.fileInfo().filename, | ||
| index: this.getIndex() }; | ||
| } | ||
| var variables = context.frames[0].variables(); | ||
| for (var k in variables) { | ||
| const variables = /** @type {Node & { variables: () => Record<string, { value: Node }> }} */ (context.frames[0]).variables(); | ||
| for (const k in variables) { | ||
| // eslint-disable-next-line no-prototype-builtins | ||
@@ -36,3 +46,3 @@ if (variables.hasOwnProperty(k)) { | ||
| toJS: function () { | ||
| return this.value.eval(context).toCSS(); | ||
| return this.value.eval(context).toCSS(context); | ||
| } | ||
@@ -42,7 +52,7 @@ }; | ||
| } | ||
| try { | ||
| result = expression.call(evalContext); | ||
| } | ||
| catch (e) { | ||
| throw { message: "JavaScript evaluation error: '".concat(e.name, ": ").concat(e.message.replace(/["]/g, '\''), "'"), | ||
| result = expressionFunc.call(evalContext); | ||
| } catch (e) { | ||
| throw { message: `JavaScript evaluation error: '${/** @type {Error} */ (e).name}: ${/** @type {Error} */ (e).message.replace(/["]/g, '\'')}'` , | ||
| filename: this.fileInfo().filename, | ||
@@ -52,13 +62,17 @@ index: this.getIndex() }; | ||
| return result; | ||
| }, | ||
| jsify: function (obj) { | ||
| } | ||
| /** | ||
| * @param {Node} obj | ||
| * @returns {string} | ||
| */ | ||
| jsify(obj) { | ||
| if (Array.isArray(obj.value) && (obj.value.length > 1)) { | ||
| return "[".concat(obj.value.map(function (v) { return v.toCSS(); }).join(', '), "]"); | ||
| return `[${obj.value.map(function (v) { return v.toCSS(/** @type {EvalContext} */ (undefined)); }).join(', ')}]`; | ||
| } else { | ||
| return obj.toCSS(/** @type {EvalContext} */ (undefined)); | ||
| } | ||
| else { | ||
| return obj.toCSS(); | ||
| } | ||
| } | ||
| }); | ||
| exports.default = JsEvalNode; | ||
| //# sourceMappingURL=js-eval-node.js.map | ||
| } | ||
| export default JsEvalNode; |
+25
-17
@@ -1,20 +0,28 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var Keyword = function (value) { | ||
| this.value = value; | ||
| }; | ||
| Keyword.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Keyword', | ||
| genCSS: function (context, output) { | ||
| if (this.value === '%') { | ||
| throw { type: 'Syntax', message: 'Invalid % without number' }; | ||
| } | ||
| output.add(this.value); | ||
| // @ts-check | ||
| import Node from './node.js'; | ||
| /** @import { EvalContext, CSSOutput } from './node.js' */ | ||
| class Keyword extends Node { | ||
| get type() { return 'Keyword'; } | ||
| /** @param {string} value */ | ||
| constructor(value) { | ||
| super(); | ||
| this.value = value; | ||
| } | ||
| }); | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| if (this.value === '%') { throw { type: 'Syntax', message: 'Invalid % without number' }; } | ||
| output.add(/** @type {string} */ (this.value)); | ||
| } | ||
| } | ||
| Keyword.True = new Keyword('true'); | ||
| Keyword.False = new Keyword('false'); | ||
| exports.default = Keyword; | ||
| //# sourceMappingURL=keyword.js.map | ||
| export default Keyword; |
+77
-35
@@ -1,27 +0,56 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var ruleset_1 = tslib_1.__importDefault(require("./ruleset")); | ||
| var value_1 = tslib_1.__importDefault(require("./value")); | ||
| var selector_1 = tslib_1.__importDefault(require("./selector")); | ||
| var atrule_1 = tslib_1.__importDefault(require("./atrule")); | ||
| var nested_at_rule_1 = tslib_1.__importDefault(require("./nested-at-rule")); | ||
| var Media = function (value, features, index, currentFileInfo, visibilityInfo) { | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| var selectors = (new selector_1.default([], null, null, this._index, this._fileInfo)).createEmptySelectors(); | ||
| this.features = new value_1.default(features); | ||
| this.rules = [new ruleset_1.default(selectors, value)]; | ||
| this.rules[0].allowImports = true; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| this.allowRoot = true; | ||
| this.setParent(selectors, this); | ||
| this.setParent(this.features, this); | ||
| this.setParent(this.rules, this); | ||
| }; | ||
| Media.prototype = Object.assign(new atrule_1.default(), tslib_1.__assign(tslib_1.__assign({ type: 'Media' }, nested_at_rule_1.default), { genCSS: function (context, output) { | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, FileInfo, VisibilityInfo } from './node.js' */ | ||
| /** @import { NestableAtRuleThis } from './nested-at-rule.js' */ | ||
| /** @import { RulesetLikeNode } from './atrule.js' */ | ||
| import Node from './node.js'; | ||
| import Ruleset from './ruleset.js'; | ||
| import Value from './value.js'; | ||
| import Selector from './selector.js'; | ||
| import AtRule from './atrule.js'; | ||
| import NestableAtRulePrototype from './nested-at-rule.js'; | ||
| class Media extends AtRule { | ||
| get type() { return 'Media'; } | ||
| /** | ||
| * @param {Node[] | null} value | ||
| * @param {Node[]} features | ||
| * @param {number} [index] | ||
| * @param {FileInfo} [currentFileInfo] | ||
| * @param {VisibilityInfo} [visibilityInfo] | ||
| */ | ||
| constructor(value, features, index, currentFileInfo, visibilityInfo) { | ||
| super(); | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| const selectors = (new Selector([], null, null, this._index, this._fileInfo)).createEmptySelectors(); | ||
| /** @type {Value} */ | ||
| this.features = new Value(features); | ||
| /** @type {RulesetLikeNode[]} */ | ||
| this.rules = [new Ruleset(selectors, value)]; | ||
| /** @type {RulesetLikeNode} */ (this.rules[0]).allowImports = true; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| this.allowRoot = true; | ||
| this.setParent(selectors, /** @type {Node} */ (/** @type {unknown} */ (this))); | ||
| this.setParent(this.features, /** @type {Node} */ (/** @type {unknown} */ (this))); | ||
| this.setParent(this.rules, /** @type {Node} */ (/** @type {unknown} */ (this))); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| output.add('@media ', this._fileInfo, this._index); | ||
| this.features.genCSS(context, output); | ||
| this.outputRuleset(context, output, this.rules); | ||
| }, eval: function (context) { | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Node} | ||
| */ | ||
| eval(context) { | ||
| if (!context.mediaBlocks) { | ||
@@ -31,19 +60,32 @@ context.mediaBlocks = []; | ||
| } | ||
| var media = new Media(null, [], this._index, this._fileInfo, this.visibilityInfo()); | ||
| const media = new Media(null, [], this._index, this._fileInfo, this.visibilityInfo()); | ||
| if (this.debugInfo) { | ||
| this.rules[0].debugInfo = this.debugInfo; | ||
| /** @type {RulesetLikeNode} */ (this.rules[0]).debugInfo = this.debugInfo; | ||
| media.debugInfo = this.debugInfo; | ||
| } | ||
| media.features = this.features.eval(context); | ||
| context.mediaPath.push(media); | ||
| context.mediaBlocks.push(media); | ||
| this.rules[0].functionRegistry = context.frames[0].functionRegistry.inherit(); | ||
| media.features = /** @type {Value} */ (this.features.eval(context)); | ||
| context.mediaPath.push(/** @type {Node} */ (/** @type {unknown} */ (media))); | ||
| context.mediaBlocks.push(/** @type {Node} */ (/** @type {unknown} */ (media))); | ||
| const fr = /** @type {RulesetLikeNode} */ (context.frames[0]).functionRegistry; | ||
| if (fr) { | ||
| /** @type {RulesetLikeNode} */ (this.rules[0]).functionRegistry = fr.inherit(); | ||
| } | ||
| context.frames.unshift(this.rules[0]); | ||
| media.rules = [this.rules[0].eval(context)]; | ||
| media.rules = [/** @type {RulesetLikeNode} */ (this.rules[0].eval(context))]; | ||
| context.frames.shift(); | ||
| context.mediaPath.pop(); | ||
| return context.mediaPath.length === 0 ? media.evalTop(context) : | ||
| media.evalNested(context); | ||
| } })); | ||
| exports.default = Media; | ||
| //# sourceMappingURL=media.js.map | ||
| return context.mediaPath.length === 0 ? /** @type {NestableAtRuleThis} */ (/** @type {unknown} */ (media)).evalTop(context) : | ||
| /** @type {NestableAtRuleThis} */ (/** @type {unknown} */ (media)).evalNested(context); | ||
| } | ||
| } | ||
| // Apply NestableAtRulePrototype methods (accept, isRulesetLike override AtRule's versions) | ||
| Object.assign(Media.prototype, NestableAtRulePrototype); | ||
| export default Media; |
+181
-98
@@ -1,58 +0,125 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var selector_1 = tslib_1.__importDefault(require("./selector")); | ||
| var mixin_definition_1 = tslib_1.__importDefault(require("./mixin-definition")); | ||
| var default_1 = tslib_1.__importDefault(require("../functions/default")); | ||
| var MixinCall = function (elements, args, index, currentFileInfo, important) { | ||
| this.selector = new selector_1.default(elements); | ||
| this.arguments = args || []; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.important = important; | ||
| this.allowRoot = true; | ||
| this.setParent(this.selector, this); | ||
| }; | ||
| MixinCall.prototype = Object.assign(new node_1.default(), { | ||
| type: 'MixinCall', | ||
| accept: function (visitor) { | ||
| // @ts-check | ||
| /** @import { EvalContext, TreeVisitor, FileInfo } from './node.js' */ | ||
| /** @import { FunctionRegistry } from './nested-at-rule.js' */ | ||
| import Node from './node.js'; | ||
| import Selector from './selector.js'; | ||
| import MixinDefinition from './mixin-definition.js'; | ||
| import defaultFunc from '../functions/default.js'; | ||
| /** | ||
| * @typedef {{ name?: string, value: Node, expand?: boolean }} MixinArg | ||
| */ | ||
| /** | ||
| * @typedef {Node & { | ||
| * rules?: Node[], | ||
| * selectors?: Selector[], | ||
| * originalRuleset?: Node, | ||
| * matchArgs: (args: MixinArg[] | null, context: EvalContext) => boolean, | ||
| * matchCondition?: (args: MixinArg[] | null, context: EvalContext) => boolean, | ||
| * find: (selector: Selector, self?: Node | null, filter?: (rule: Node) => boolean) => Array<{ rule: Node & { rules?: Node[], originalRuleset?: Node, matchArgs: Function, matchCondition?: Function, evalCall?: Function }, path: Node[] }>, | ||
| * functionRegistry?: FunctionRegistry | ||
| * }} MixinSearchFrame | ||
| */ | ||
| class MixinCall extends Node { | ||
| get type() { return 'MixinCall'; } | ||
| /** | ||
| * @param {import('./element.js').default[]} elements | ||
| * @param {MixinArg[]} [args] | ||
| * @param {number} [index] | ||
| * @param {FileInfo} [currentFileInfo] | ||
| * @param {string} [important] | ||
| */ | ||
| constructor(elements, args, index, currentFileInfo, important) { | ||
| super(); | ||
| /** @type {Selector} */ | ||
| this.selector = new Selector(elements); | ||
| /** @type {MixinArg[]} */ | ||
| this.arguments = args || []; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| /** @type {string | undefined} */ | ||
| this.important = important; | ||
| this.allowRoot = true; | ||
| this.setParent(this.selector, /** @type {Node} */ (/** @type {unknown} */ (this))); | ||
| } | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| if (this.selector) { | ||
| this.selector = visitor.visit(this.selector); | ||
| this.selector = /** @type {Selector} */ (visitor.visit(this.selector)); | ||
| } | ||
| if (this.arguments.length) { | ||
| this.arguments = visitor.visitArray(this.arguments); | ||
| this.arguments = /** @type {MixinArg[]} */ (/** @type {unknown} */ (visitor.visitArray(/** @type {Node[]} */ (/** @type {unknown} */ (this.arguments))))); | ||
| } | ||
| }, | ||
| eval: function (context) { | ||
| var mixins; | ||
| var mixin; | ||
| var mixinPath; | ||
| var args = []; | ||
| var arg; | ||
| var argValue; | ||
| var rules = []; | ||
| var match = false; | ||
| var i; | ||
| var m; | ||
| var f; | ||
| var isRecursive; | ||
| var isOneFound; | ||
| var candidates = []; | ||
| var candidate; | ||
| var conditionResult = []; | ||
| var defaultResult; | ||
| var defFalseEitherCase = -1; | ||
| var defNone = 0; | ||
| var defTrue = 1; | ||
| var defFalse = 2; | ||
| var count; | ||
| var originalRuleset; | ||
| var noArgumentsFilter; | ||
| this.selector = this.selector.eval(context); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Node} | ||
| */ | ||
| eval(context) { | ||
| /** @type {{ rule: Node & { rules?: Node[], originalRuleset?: Node, matchArgs: Function, matchCondition?: Function, evalCall?: Function }, path: Node[] }[] | undefined} */ | ||
| let mixins; | ||
| /** @type {Node & { rules?: Node[], originalRuleset?: Node, matchArgs: Function, matchCondition?: Function, evalCall?: Function }} */ | ||
| let mixin; | ||
| /** @type {Node[]} */ | ||
| let mixinPath; | ||
| /** @type {MixinArg[]} */ | ||
| const args = []; | ||
| /** @type {MixinArg} */ | ||
| let arg; | ||
| /** @type {Node} */ | ||
| let argValue; | ||
| /** @type {Node[]} */ | ||
| const rules = []; | ||
| let match = false; | ||
| /** @type {number} */ | ||
| let i; | ||
| /** @type {number} */ | ||
| let m; | ||
| /** @type {number} */ | ||
| let f; | ||
| /** @type {boolean} */ | ||
| let isRecursive; | ||
| /** @type {boolean | undefined} */ | ||
| let isOneFound; | ||
| /** @type {{ mixin: Node & { rules?: Node[], originalRuleset?: Node, matchArgs: Function, matchCondition?: Function, evalCall?: Function }, group: number }[]} */ | ||
| const candidates = []; | ||
| /** @type {{ mixin: Node & { rules?: Node[], originalRuleset?: Node, matchArgs: Function, matchCondition?: Function, evalCall?: Function }, group: number } | number} */ | ||
| let candidate; | ||
| /** @type {boolean[]} */ | ||
| const conditionResult = []; | ||
| /** @type {number | undefined} */ | ||
| let defaultResult; | ||
| const defFalseEitherCase = -1; | ||
| const defNone = 0; | ||
| const defTrue = 1; | ||
| const defFalse = 2; | ||
| /** @type {number[]} */ | ||
| let count; | ||
| /** @type {Node | undefined} */ | ||
| let originalRuleset; | ||
| /** @type {((rule: MixinSearchFrame) => boolean) | undefined} */ | ||
| let noArgumentsFilter; | ||
| this.selector = /** @type {Selector} */ (this.selector.eval(context)); | ||
| /** | ||
| * @param {Node & { matchCondition?: Function }} mixin | ||
| * @param {Node[]} mixinPath | ||
| */ | ||
| function calcDefGroup(mixin, mixinPath) { | ||
| var f, p, namespace; | ||
| /** @type {number} */ | ||
| let f; | ||
| /** @type {number} */ | ||
| let p; | ||
| /** @type {Node & { matchCondition?: Function }} */ | ||
| let namespace; | ||
| for (f = 0; f < 2; f++) { | ||
| conditionResult[f] = true; | ||
| default_1.default.value(f); | ||
| defaultFunc.value(f); | ||
| for (p = 0; p < mixinPath.length && conditionResult[f]; p++) { | ||
@@ -73,2 +140,3 @@ namespace = mixinPath[p]; | ||
| } | ||
| return defNone; | ||
@@ -78,2 +146,3 @@ } | ||
| } | ||
| for (i = 0; i < this.arguments.length; i++) { | ||
@@ -83,15 +152,17 @@ arg = this.arguments[i]; | ||
| if (arg.expand && Array.isArray(argValue.value)) { | ||
| argValue = argValue.value; | ||
| for (m = 0; m < argValue.length; m++) { | ||
| args.push({ value: argValue[m] }); | ||
| const expandedValues = /** @type {Node[]} */ (argValue.value); | ||
| for (m = 0; m < expandedValues.length; m++) { | ||
| args.push({value: expandedValues[m]}); | ||
| } | ||
| } else { | ||
| args.push({name: arg.name, value: argValue}); | ||
| } | ||
| else { | ||
| args.push({ name: arg.name, value: argValue }); | ||
| } | ||
| } | ||
| noArgumentsFilter = function (rule) { return rule.matchArgs(null, context); }; | ||
| noArgumentsFilter = function(/** @type {MixinSearchFrame} */ rule) {return rule.matchArgs(null, context);}; | ||
| for (i = 0; i < context.frames.length; i++) { | ||
| if ((mixins = context.frames[i].find(this.selector, null, noArgumentsFilter)).length > 0) { | ||
| if ((mixins = /** @type {MixinSearchFrame} */ (context.frames[i]).find(this.selector, null, /** @type {(rule: Node) => boolean} */ (/** @type {unknown} */ (noArgumentsFilter)))).length > 0) { | ||
| isOneFound = true; | ||
| // To make `default()` function independent of definition order we have two "subpasses" here. | ||
@@ -101,2 +172,3 @@ // At first we evaluate each guard *twice* (with `default() == true` and `default() == false`), | ||
| // we make a final decision. | ||
| for (m = 0; m < mixins.length; m++) { | ||
@@ -107,3 +179,3 @@ mixin = mixins[m].rule; | ||
| for (f = 0; f < context.frames.length; f++) { | ||
| if ((!(mixin instanceof mixin_definition_1.default)) && mixin === (context.frames[f].originalRuleset || context.frames[f])) { | ||
| if ((!(mixin instanceof MixinDefinition)) && mixin === (/** @type {Node & { originalRuleset?: Node }} */ (context.frames[f]).originalRuleset || context.frames[f])) { | ||
| isRecursive = true; | ||
@@ -116,11 +188,16 @@ break; | ||
| } | ||
| if (mixin.matchArgs(args, context)) { | ||
| candidate = { mixin: mixin, group: calcDefGroup(mixin, mixinPath) }; | ||
| if (candidate.group !== defFalseEitherCase) { | ||
| candidates.push(candidate); | ||
| candidate = {mixin, group: calcDefGroup(mixin, mixinPath)}; | ||
| if (/** @type {{ mixin: Node, group: number }} */ (candidate).group !== defFalseEitherCase) { | ||
| candidates.push(/** @type {{ mixin: Node & { rules?: Node[], originalRuleset?: Node, matchArgs: Function, matchCondition?: Function, evalCall?: Function }, group: number }} */ (candidate)); | ||
| } | ||
| match = true; | ||
| } | ||
| } | ||
| default_1.default.reset(); | ||
| defaultFunc.reset(); | ||
| count = [0, 0, 0]; | ||
@@ -130,13 +207,14 @@ for (m = 0; m < candidates.length; m++) { | ||
| } | ||
| if (count[defNone] > 0) { | ||
| defaultResult = defFalse; | ||
| } | ||
| else { | ||
| } else { | ||
| defaultResult = defTrue; | ||
| if ((count[defTrue] + count[defFalse]) > 1) { | ||
| throw { type: 'Runtime', | ||
| message: "Ambiguous use of `default()` found when matching for `".concat(this.format(args), "`"), | ||
| message: `Ambiguous use of \`default()\` found when matching for \`${this.format(args)}\``, | ||
| index: this.getIndex(), filename: this.fileInfo().filename }; | ||
| } | ||
| } | ||
| for (m = 0; m < candidates.length; m++) { | ||
@@ -147,18 +225,18 @@ candidate = candidates[m].group; | ||
| mixin = candidates[m].mixin; | ||
| if (!(mixin instanceof mixin_definition_1.default)) { | ||
| originalRuleset = mixin.originalRuleset || mixin; | ||
| mixin = new mixin_definition_1.default('', [], mixin.rules, null, false, null, originalRuleset.visibilityInfo()); | ||
| mixin.originalRuleset = originalRuleset; | ||
| if (!(mixin instanceof MixinDefinition)) { | ||
| originalRuleset = /** @type {Node & { originalRuleset?: Node }} */ (mixin).originalRuleset || mixin; | ||
| mixin = new MixinDefinition('', [], mixin.rules, null, false, null, originalRuleset.visibilityInfo()); | ||
| /** @type {Node & { originalRuleset?: Node }} */ (mixin).originalRuleset = originalRuleset; | ||
| } | ||
| var newRules = mixin.evalCall(context, args, this.important).rules; | ||
| const newRules = /** @type {MixinDefinition} */ (mixin).evalCall(context, args, this.important).rules; | ||
| this._setVisibilityToReplacement(newRules); | ||
| Array.prototype.push.apply(rules, newRules); | ||
| } catch (e) { | ||
| throw { .../** @type {object} */ (e), index: this.getIndex(), filename: this.fileInfo().filename }; | ||
| } | ||
| catch (e) { | ||
| throw { message: e.message, index: this.getIndex(), filename: this.fileInfo().filename, stack: e.stack }; | ||
| } | ||
| } | ||
| } | ||
| if (match) { | ||
| return rules; | ||
| return /** @type {Node} */ (/** @type {unknown} */ (rules)); | ||
| } | ||
@@ -168,14 +246,18 @@ } | ||
| if (isOneFound) { | ||
| throw { type: 'Runtime', | ||
| message: "No matching definition was found for `".concat(this.format(args), "`"), | ||
| index: this.getIndex(), filename: this.fileInfo().filename }; | ||
| throw { type: 'Runtime', | ||
| message: `No matching definition was found for \`${this.format(args)}\``, | ||
| index: this.getIndex(), filename: this.fileInfo().filename }; | ||
| } else { | ||
| throw { type: 'Name', | ||
| message: `${this.selector.toCSS(/** @type {EvalContext} */ ({})).trim()} is undefined`, | ||
| index: this.getIndex(), filename: this.fileInfo().filename }; | ||
| } | ||
| else { | ||
| throw { type: 'Name', | ||
| message: "".concat(this.selector.toCSS().trim(), " is undefined"), | ||
| index: this.getIndex(), filename: this.fileInfo().filename }; | ||
| } | ||
| }, | ||
| _setVisibilityToReplacement: function (replacement) { | ||
| var i, rule; | ||
| } | ||
| /** @param {Node[]} replacement */ | ||
| _setVisibilityToReplacement(replacement) { | ||
| /** @type {number} */ | ||
| let i; | ||
| /** @type {Node} */ | ||
| let rule; | ||
| if (this.blocksVisibility()) { | ||
@@ -187,20 +269,21 @@ for (i = 0; i < replacement.length; i++) { | ||
| } | ||
| }, | ||
| format: function (args) { | ||
| return "".concat(this.selector.toCSS().trim(), "(").concat(args ? args.map(function (a) { | ||
| var argValue = ''; | ||
| } | ||
| /** @param {MixinArg[]} args */ | ||
| format(args) { | ||
| return `${this.selector.toCSS(/** @type {EvalContext} */ ({})).trim()}(${args ? args.map(function (/** @type {MixinArg} */ a) { | ||
| let argValue = ''; | ||
| if (a.name) { | ||
| argValue += "".concat(a.name, ":"); | ||
| argValue += `${a.name}:`; | ||
| } | ||
| if (a.value.toCSS) { | ||
| argValue += a.value.toCSS(); | ||
| } | ||
| else { | ||
| argValue += a.value.toCSS(/** @type {EvalContext} */ ({})); | ||
| } else { | ||
| argValue += '???'; | ||
| } | ||
| return argValue; | ||
| }).join(', ') : '', ")"); | ||
| }).join(', ') : ''})`; | ||
| } | ||
| }); | ||
| exports.default = MixinCall; | ||
| //# sourceMappingURL=mixin-call.js.map | ||
| } | ||
| export default MixinCall; |
@@ -1,42 +0,82 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var selector_1 = tslib_1.__importDefault(require("./selector")); | ||
| var element_1 = tslib_1.__importDefault(require("./element")); | ||
| var ruleset_1 = tslib_1.__importDefault(require("./ruleset")); | ||
| var declaration_1 = tslib_1.__importDefault(require("./declaration")); | ||
| var detached_ruleset_1 = tslib_1.__importDefault(require("./detached-ruleset")); | ||
| var expression_1 = tslib_1.__importDefault(require("./expression")); | ||
| var contexts_1 = tslib_1.__importDefault(require("../contexts")); | ||
| var utils = tslib_1.__importStar(require("../utils")); | ||
| var Definition = function (name, params, rules, condition, variadic, frames, visibilityInfo) { | ||
| this.name = name || 'anonymous mixin'; | ||
| this.selectors = [new selector_1.default([new element_1.default(null, name, false, this._index, this._fileInfo)])]; | ||
| this.params = params; | ||
| this.condition = condition; | ||
| this.variadic = variadic; | ||
| this.arity = params.length; | ||
| this.rules = rules; | ||
| this._lookups = {}; | ||
| var optionalParameters = []; | ||
| this.required = params.reduce(function (count, p) { | ||
| if (!p.name || (p.name && !p.value)) { | ||
| return count + 1; | ||
| } | ||
| else { | ||
| optionalParameters.push(p.name); | ||
| return count; | ||
| } | ||
| }, 0); | ||
| this.optionalParameters = optionalParameters; | ||
| this.frames = frames; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| this.allowRoot = true; | ||
| }; | ||
| Definition.prototype = Object.assign(new ruleset_1.default(), { | ||
| type: 'MixinDefinition', | ||
| evalFirst: true, | ||
| accept: function (visitor) { | ||
| // @ts-check | ||
| /** @import { EvalContext, TreeVisitor, VisibilityInfo } from './node.js' */ | ||
| /** @import { FunctionRegistry } from './nested-at-rule.js' */ | ||
| /** @import { MixinArg } from './mixin-call.js' */ | ||
| import Node from './node.js'; | ||
| import Selector from './selector.js'; | ||
| import Element from './element.js'; | ||
| import Ruleset from './ruleset.js'; | ||
| import Declaration from './declaration.js'; | ||
| import DetachedRuleset from './detached-ruleset.js'; | ||
| import Expression from './expression.js'; | ||
| import contexts from '../contexts.js'; | ||
| import * as utils from '../utils.js'; | ||
| /** | ||
| * @typedef {object} MixinParam | ||
| * @property {string} [name] | ||
| * @property {Node} [value] | ||
| * @property {boolean} [variadic] | ||
| */ | ||
| /** | ||
| * @typedef {Ruleset & { | ||
| * functionRegistry?: FunctionRegistry, | ||
| * originalRuleset?: Node | ||
| * }} RulesetWithRegistry | ||
| */ | ||
| class Definition extends Ruleset { | ||
| get type() { return 'MixinDefinition'; } | ||
| /** | ||
| * @param {string | undefined} name | ||
| * @param {MixinParam[]} params | ||
| * @param {Node[]} rules | ||
| * @param {Node | null} [condition] | ||
| * @param {boolean} [variadic] | ||
| * @param {Node[] | null} [frames] | ||
| * @param {VisibilityInfo} [visibilityInfo] | ||
| */ | ||
| constructor(name, params, rules, condition, variadic, frames, visibilityInfo) { | ||
| super(null, null); | ||
| /** @type {string} */ | ||
| this.name = name || 'anonymous mixin'; | ||
| this.selectors = [new Selector([new Element(null, name, false, this._index, this._fileInfo)])]; | ||
| /** @type {MixinParam[]} */ | ||
| this.params = params; | ||
| /** @type {Node | null | undefined} */ | ||
| this.condition = condition; | ||
| /** @type {boolean | undefined} */ | ||
| this.variadic = variadic; | ||
| /** @type {number} */ | ||
| this.arity = params.length; | ||
| this.rules = rules; | ||
| this._lookups = {}; | ||
| /** @type {string[]} */ | ||
| const optionalParameters = []; | ||
| /** @type {number} */ | ||
| this.required = params.reduce(function (/** @type {number} */ count, /** @type {MixinParam} */ p) { | ||
| if (!p.name || (p.name && !p.value)) { | ||
| return count + 1; | ||
| } | ||
| else { | ||
| optionalParameters.push(p.name); | ||
| return count; | ||
| } | ||
| }, 0); | ||
| /** @type {string[]} */ | ||
| this.optionalParameters = optionalParameters; | ||
| /** @type {Node[] | null | undefined} */ | ||
| this.frames = frames; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| this.allowRoot = true; | ||
| /** @type {boolean} */ | ||
| this.evalFirst = true; | ||
| } | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| if (this.params && this.params.length) { | ||
| this.params = visitor.visitArray(this.params); | ||
| this.params = /** @type {MixinParam[]} */ (/** @type {unknown} */ (visitor.visitArray(/** @type {Node[]} */ (/** @type {unknown} */ (this.params))))); | ||
| } | ||
@@ -47,23 +87,43 @@ this.rules = visitor.visitArray(this.rules); | ||
| } | ||
| }, | ||
| evalParams: function (context, mixinEnv, args, evaldArguments) { | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {EvalContext} mixinEnv | ||
| * @param {MixinArg[] | null} args | ||
| * @param {Node[]} evaldArguments | ||
| * @returns {Ruleset} | ||
| */ | ||
| evalParams(context, mixinEnv, args, evaldArguments) { | ||
| /* jshint boss:true */ | ||
| var frame = new ruleset_1.default(null, null); | ||
| var varargs; | ||
| var arg; | ||
| var params = utils.copyArray(this.params); | ||
| var i; | ||
| var j; | ||
| var val; | ||
| var name; | ||
| var isNamedFound; | ||
| var argIndex; | ||
| var argsLength = 0; | ||
| if (mixinEnv.frames && mixinEnv.frames[0] && mixinEnv.frames[0].functionRegistry) { | ||
| frame.functionRegistry = mixinEnv.frames[0].functionRegistry.inherit(); | ||
| const frame = new Ruleset(null, null); | ||
| /** @type {Node[] | undefined} */ | ||
| let varargs; | ||
| /** @type {MixinArg | undefined} */ | ||
| let arg; | ||
| const params = /** @type {MixinParam[]} */ (utils.copyArray(this.params)); | ||
| /** @type {number} */ | ||
| let i; | ||
| /** @type {number} */ | ||
| let j; | ||
| /** @type {Node | undefined} */ | ||
| let val; | ||
| /** @type {string | undefined} */ | ||
| let name; | ||
| /** @type {boolean} */ | ||
| let isNamedFound; | ||
| /** @type {number} */ | ||
| let argIndex; | ||
| let argsLength = 0; | ||
| if (mixinEnv.frames && mixinEnv.frames[0] && /** @type {RulesetWithRegistry} */ (mixinEnv.frames[0]).functionRegistry) { | ||
| /** @type {RulesetWithRegistry} */ (frame).functionRegistry = /** @type {FunctionRegistry} */ (/** @type {RulesetWithRegistry} */ (mixinEnv.frames[0]).functionRegistry).inherit(); | ||
| } | ||
| mixinEnv = new contexts_1.default.Eval(mixinEnv, [frame].concat(mixinEnv.frames)); | ||
| mixinEnv = new contexts.Eval(mixinEnv, /** @type {Node[]} */ ([frame]).concat(/** @type {Node[]} */ (mixinEnv.frames))); | ||
| if (args) { | ||
| args = utils.copyArray(args); | ||
| args = /** @type {MixinArg[]} */ (utils.copyArray(args)); | ||
| argsLength = args.length; | ||
| for (i = 0; i < argsLength; i++) { | ||
@@ -76,3 +136,3 @@ arg = args[i]; | ||
| evaldArguments[j] = arg.value.eval(context); | ||
| frame.prependRule(new declaration_1.default(name, arg.value.eval(context))); | ||
| frame.prependRule(new Declaration(name, arg.value.eval(context))); | ||
| isNamedFound = true; | ||
@@ -86,6 +146,5 @@ break; | ||
| continue; | ||
| } else { | ||
| throw { type: 'Runtime', message: `Named argument for ${this.name} ${args[i].name} not found` }; | ||
| } | ||
| else { | ||
| throw { type: 'Runtime', message: "Named argument for ".concat(this.name, " ").concat(args[i].name, " not found") }; | ||
| } | ||
| } | ||
@@ -96,6 +155,6 @@ } | ||
| for (i = 0; i < params.length; i++) { | ||
| if (evaldArguments[i]) { | ||
| continue; | ||
| } | ||
| if (evaldArguments[i]) { continue; } | ||
| arg = args && args[argIndex]; | ||
| if (name = params[i].name) { | ||
@@ -105,7 +164,6 @@ if (params[i].variadic) { | ||
| for (j = argIndex; j < argsLength; j++) { | ||
| varargs.push(args[j].value.eval(context)); | ||
| varargs.push(/** @type {MixinArg[]} */ (args)[j].value.eval(context)); | ||
| } | ||
| frame.prependRule(new declaration_1.default(name, new expression_1.default(varargs).eval(context))); | ||
| } | ||
| else { | ||
| frame.prependRule(new Declaration(name, new Expression(varargs).eval(context))); | ||
| } else { | ||
| val = arg && arg.value; | ||
@@ -115,3 +173,3 @@ if (val) { | ||
| if (Array.isArray(val)) { | ||
| val = new detached_ruleset_1.default(new ruleset_1.default('', val)); | ||
| val = /** @type {Node} */ (/** @type {unknown} */ (new DetachedRuleset(new Ruleset(null, /** @type {Node[]} */ (val))))); | ||
| } | ||
@@ -121,14 +179,14 @@ else { | ||
| } | ||
| } | ||
| else if (params[i].value) { | ||
| val = params[i].value.eval(mixinEnv); | ||
| } else if (params[i].value) { | ||
| val = /** @type {Node} */ (params[i].value).eval(mixinEnv); | ||
| frame.resetCache(); | ||
| } else { | ||
| throw { type: 'Runtime', message: `wrong number of arguments for ${this.name} (${argsLength} for ${this.arity})` }; | ||
| } | ||
| else { | ||
| throw { type: 'Runtime', message: "wrong number of arguments for ".concat(this.name, " (").concat(argsLength, " for ").concat(this.arity, ")") }; | ||
| } | ||
| frame.prependRule(new declaration_1.default(name, val)); | ||
| frame.prependRule(new Declaration(name, val)); | ||
| evaldArguments[i] = val; | ||
| } | ||
| } | ||
| if (params[i].variadic && args) { | ||
@@ -141,55 +199,90 @@ for (j = argIndex; j < argsLength; j++) { | ||
| } | ||
| return frame; | ||
| }, | ||
| makeImportant: function () { | ||
| var rules = !this.rules ? this.rules : this.rules.map(function (r) { | ||
| } | ||
| /** @returns {Ruleset} */ | ||
| makeImportant() { | ||
| const rules = !this.rules ? this.rules : this.rules.map(function (/** @type {Node & { makeImportant?: (important?: boolean) => Node }} */ r) { | ||
| if (r.makeImportant) { | ||
| return r.makeImportant(true); | ||
| } | ||
| else { | ||
| } else { | ||
| return r; | ||
| } | ||
| }); | ||
| var result = new Definition(this.name, this.params, rules, this.condition, this.variadic, this.frames); | ||
| return result; | ||
| }, | ||
| eval: function (context) { | ||
| const result = new Definition(this.name, this.params, rules, this.condition, this.variadic, this.frames); | ||
| return /** @type {Ruleset} */ (/** @type {unknown} */ (result)); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Definition} | ||
| */ | ||
| eval(context) { | ||
| return new Definition(this.name, this.params, this.rules, this.condition, this.variadic, this.frames || utils.copyArray(context.frames)); | ||
| }, | ||
| evalCall: function (context, args, important) { | ||
| var _arguments = []; | ||
| var mixinFrames = this.frames ? this.frames.concat(context.frames) : context.frames; | ||
| var frame = this.evalParams(context, new contexts_1.default.Eval(context, mixinFrames), args, _arguments); | ||
| var rules; | ||
| var ruleset; | ||
| frame.prependRule(new declaration_1.default('@arguments', new expression_1.default(_arguments).eval(context))); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {MixinArg[]} args | ||
| * @param {string | undefined} important | ||
| * @returns {Ruleset} | ||
| */ | ||
| evalCall(context, args, important) { | ||
| /** @type {Node[]} */ | ||
| const _arguments = []; | ||
| const mixinFrames = this.frames ? /** @type {Node[]} */ (this.frames).concat(/** @type {Node[]} */ (context.frames)) : /** @type {Node[]} */ (context.frames); | ||
| const frame = this.evalParams(context, new contexts.Eval(context, mixinFrames), args, _arguments); | ||
| /** @type {Node[]} */ | ||
| let rules; | ||
| /** @type {Ruleset} */ | ||
| let ruleset; | ||
| frame.prependRule(new Declaration('@arguments', new Expression(_arguments).eval(context))); | ||
| rules = utils.copyArray(this.rules); | ||
| ruleset = new ruleset_1.default(null, rules); | ||
| ruleset.originalRuleset = this; | ||
| ruleset = ruleset.eval(new contexts_1.default.Eval(context, [this, frame].concat(mixinFrames))); | ||
| ruleset = new Ruleset(null, rules); | ||
| /** @type {RulesetWithRegistry} */ (ruleset).originalRuleset = this; | ||
| ruleset = /** @type {Ruleset} */ (ruleset.eval(new contexts.Eval(context, /** @type {Node[]} */ ([this, frame]).concat(mixinFrames)))); | ||
| if (important) { | ||
| ruleset = ruleset.makeImportant(); | ||
| ruleset = /** @type {Ruleset} */ (ruleset.makeImportant()); | ||
| } | ||
| return ruleset; | ||
| }, | ||
| matchCondition: function (args, context) { | ||
| if (this.condition && !this.condition.eval(new contexts_1.default.Eval(context, [this.evalParams(context, /* the parameter variables */ new contexts_1.default.Eval(context, this.frames ? this.frames.concat(context.frames) : context.frames), args, [])] | ||
| .concat(this.frames || []) // the parent namespace/mixin frames | ||
| .concat(context.frames)))) { // the current environment frames | ||
| } | ||
| /** | ||
| * @param {MixinArg[] | null} args | ||
| * @param {EvalContext} context | ||
| * @returns {boolean} | ||
| */ | ||
| matchCondition(args, context) { | ||
| if (this.condition && !this.condition.eval( | ||
| new contexts.Eval(context, | ||
| /** @type {Node[]} */ ([this.evalParams(context, /* the parameter variables */ | ||
| new contexts.Eval(context, this.frames ? /** @type {Node[]} */ (this.frames).concat(/** @type {Node[]} */ (context.frames)) : context.frames), args, [])]) | ||
| .concat(/** @type {Node[]} */ (this.frames || [])) // the parent namespace/mixin frames | ||
| .concat(/** @type {Node[]} */ (context.frames))))) { // the current environment frames | ||
| return false; | ||
| } | ||
| return true; | ||
| }, | ||
| matchArgs: function (args, context) { | ||
| var allArgsCnt = (args && args.length) || 0; | ||
| var len; | ||
| var optionalParameters = this.optionalParameters; | ||
| var requiredArgsCnt = !args ? 0 : args.reduce(function (count, p) { | ||
| } | ||
| /** | ||
| * @param {MixinArg[] | null} args | ||
| * @param {EvalContext} [context] | ||
| * @returns {boolean} | ||
| */ | ||
| matchArgs(args, context) { | ||
| const allArgsCnt = (args && args.length) || 0; | ||
| let len; | ||
| const optionalParameters = this.optionalParameters; | ||
| const requiredArgsCnt = !args ? 0 : args.reduce(function (/** @type {number} */ count, /** @type {MixinArg} */ p) { | ||
| if (optionalParameters.indexOf(p.name) < 0) { | ||
| return count + 1; | ||
| } | ||
| else { | ||
| } else { | ||
| return count; | ||
| } | ||
| }, 0); | ||
| if (!this.variadic) { | ||
@@ -202,4 +295,3 @@ if (requiredArgsCnt < this.required) { | ||
| } | ||
| } | ||
| else { | ||
| } else { | ||
| if (requiredArgsCnt < (this.required - 1)) { | ||
@@ -209,7 +301,9 @@ return false; | ||
| } | ||
| // check patterns | ||
| len = Math.min(requiredArgsCnt, this.arity); | ||
| for (var i = 0; i < len; i++) { | ||
| for (let i = 0; i < len; i++) { | ||
| if (!this.params[i].name && !this.params[i].variadic) { | ||
| if (args[i].value.eval(context).toCSS() != this.params[i].value.eval(context).toCSS()) { | ||
| if (/** @type {MixinArg[]} */ (args)[i].value.eval(context).toCSS(/** @type {EvalContext} */ ({})) != /** @type {Node} */ (this.params[i].value).eval(context).toCSS(/** @type {EvalContext} */ ({}))) { | ||
| return false; | ||
@@ -221,4 +315,4 @@ } | ||
| } | ||
| }); | ||
| exports.default = Definition; | ||
| //# sourceMappingURL=mixin-definition.js.map | ||
| } | ||
| export default Definition; |
@@ -1,41 +0,57 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var variable_1 = tslib_1.__importDefault(require("./variable")); | ||
| var ruleset_1 = tslib_1.__importDefault(require("./ruleset")); | ||
| var selector_1 = tslib_1.__importDefault(require("./selector")); | ||
| var NamespaceValue = function (ruleCall, lookups, index, fileInfo) { | ||
| this.value = ruleCall; | ||
| this.lookups = lookups; | ||
| this._index = index; | ||
| this._fileInfo = fileInfo; | ||
| }; | ||
| NamespaceValue.prototype = Object.assign(new node_1.default(), { | ||
| type: 'NamespaceValue', | ||
| eval: function (context) { | ||
| var i, name, rules = this.value.eval(context); | ||
| // @ts-check | ||
| /** @import { EvalContext, FileInfo } from './node.js' */ | ||
| import Node from './node.js'; | ||
| import Variable from './variable.js'; | ||
| import Ruleset from './ruleset.js'; | ||
| import Selector from './selector.js'; | ||
| class NamespaceValue extends Node { | ||
| get type() { return 'NamespaceValue'; } | ||
| /** | ||
| * @param {Node} ruleCall | ||
| * @param {string[]} lookups | ||
| * @param {number} index | ||
| * @param {FileInfo} fileInfo | ||
| */ | ||
| constructor(ruleCall, lookups, index, fileInfo) { | ||
| super(); | ||
| this.value = ruleCall; | ||
| this.lookups = lookups; | ||
| this._index = index; | ||
| this._fileInfo = fileInfo; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Node} | ||
| */ | ||
| eval(context) { | ||
| let i, name; | ||
| /** @type {Ruleset | Node | Node[]} */ | ||
| let rules = this.value.eval(context); | ||
| for (i = 0; i < this.lookups.length; i++) { | ||
| name = this.lookups[i]; | ||
| /** | ||
| * Eval'd DRs return rulesets. | ||
| * Eval'd mixins return rules, so let's make a ruleset if we need it. | ||
| * We need to do this because of late parsing of values | ||
| */ | ||
| if (Array.isArray(rules)) { | ||
| rules = new ruleset_1.default([new selector_1.default()], rules); | ||
| rules = new Ruleset([new Selector()], rules); | ||
| } | ||
| const rs = /** @type {Ruleset} */ (rules); | ||
| if (name === '') { | ||
| rules = rules.lastDeclaration(); | ||
| rules = rs.lastDeclaration(); | ||
| } | ||
| else if (name.charAt(0) === '@') { | ||
| if (name.charAt(1) === '@') { | ||
| name = "@".concat(new variable_1.default(name.substr(1)).eval(context).value); | ||
| name = `@${new Variable(name.slice(1)).eval(context).value}`; | ||
| } | ||
| if (rules.variables) { | ||
| rules = rules.variable(name); | ||
| if (rs.variables) { | ||
| rules = rs.variable(name); | ||
| } | ||
| if (!rules) { | ||
| throw { type: 'Name', | ||
| message: "variable ".concat(name, " not found"), | ||
| message: `variable ${name} not found`, | ||
| filename: this.fileInfo().filename, | ||
@@ -47,31 +63,34 @@ index: this.getIndex() }; | ||
| if (name.substring(0, 2) === '$@') { | ||
| name = "$".concat(new variable_1.default(name.substr(1)).eval(context).value); | ||
| name = `$${new Variable(name.slice(1)).eval(context).value}`; | ||
| } | ||
| else { | ||
| name = name.charAt(0) === '$' ? name : "$".concat(name); | ||
| name = name.charAt(0) === '$' ? name : `$${name}`; | ||
| } | ||
| if (rules.properties) { | ||
| rules = rules.property(name); | ||
| if (rs.properties) { | ||
| rules = rs.property(name); | ||
| } | ||
| if (!rules) { | ||
| throw { type: 'Name', | ||
| message: "property \"".concat(name.substr(1), "\" not found"), | ||
| message: `property "${name.slice(1)}" not found`, | ||
| filename: this.fileInfo().filename, | ||
| index: this.getIndex() }; | ||
| } | ||
| // Properties are an array of values, since a ruleset can have multiple props. | ||
| // We pick the last one (the "cascaded" value) | ||
| rules = rules[rules.length - 1]; | ||
| const rulesArr = /** @type {Node[]} */ (rules); | ||
| rules = rulesArr[rulesArr.length - 1]; | ||
| } | ||
| if (rules.value) { | ||
| rules = rules.eval(context).value; | ||
| const current = /** @type {Node} */ (rules); | ||
| if (current.value) { | ||
| rules = /** @type {Node} */ (current.eval(context).value); | ||
| } | ||
| if (rules.ruleset) { | ||
| rules = rules.ruleset.eval(context); | ||
| const currentNode = /** @type {Node & { ruleset?: Node }} */ (rules); | ||
| if (currentNode.ruleset) { | ||
| rules = currentNode.ruleset.eval(context); | ||
| } | ||
| } | ||
| return rules; | ||
| return /** @type {Node} */ (rules); | ||
| } | ||
| }); | ||
| exports.default = NamespaceValue; | ||
| //# sourceMappingURL=namespace-value.js.map | ||
| } | ||
| export default NamespaceValue; |
@@ -1,24 +0,37 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var operation_1 = tslib_1.__importDefault(require("./operation")); | ||
| var dimension_1 = tslib_1.__importDefault(require("./dimension")); | ||
| var Negative = function (node) { | ||
| this.value = node; | ||
| }; | ||
| Negative.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Negative', | ||
| genCSS: function (context, output) { | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput } from './node.js' */ | ||
| import Node from './node.js'; | ||
| import Operation from './operation.js'; | ||
| import Dimension from './dimension.js'; | ||
| class Negative extends Node { | ||
| get type() { return 'Negative'; } | ||
| /** @param {Node} node */ | ||
| constructor(node) { | ||
| super(); | ||
| this.value = node; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| output.add('-'); | ||
| this.value.genCSS(context, output); | ||
| }, | ||
| eval: function (context) { | ||
| if (context.isMathOn()) { | ||
| return (new operation_1.default('*', [new dimension_1.default(-1), this.value])).eval(context); | ||
| /** @type {Node} */ (this.value).genCSS(context, output); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Node} | ||
| */ | ||
| eval(context) { | ||
| if (context.isMathOn('*')) { | ||
| return (new Operation('*', [new Dimension(-1), /** @type {Node} */ (this.value)], false)).eval(context); | ||
| } | ||
| return new Negative(this.value.eval(context)); | ||
| return new Negative(/** @type {Node} */ (this.value).eval(context)); | ||
| } | ||
| }); | ||
| exports.default = Negative; | ||
| //# sourceMappingURL=negative.js.map | ||
| } | ||
| export default Negative; |
@@ -1,36 +0,83 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var ruleset_1 = tslib_1.__importDefault(require("./ruleset")); | ||
| var value_1 = tslib_1.__importDefault(require("./value")); | ||
| var selector_1 = tslib_1.__importDefault(require("./selector")); | ||
| var anonymous_1 = tslib_1.__importDefault(require("./anonymous")); | ||
| var expression_1 = tslib_1.__importDefault(require("./expression")); | ||
| var utils = tslib_1.__importStar(require("../utils")); | ||
| var NestableAtRulePrototype = { | ||
| isRulesetLike: function () { | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, TreeVisitor, FileInfo, VisibilityInfo } from './node.js' */ | ||
| import Ruleset from './ruleset.js'; | ||
| import Value from './value.js'; | ||
| import Selector from './selector.js'; | ||
| import Anonymous from './anonymous.js'; | ||
| import Expression from './expression.js'; | ||
| import * as utils from '../utils.js'; | ||
| import Node from './node.js'; | ||
| /** | ||
| * @typedef {object} FunctionRegistry | ||
| * @property {(name: string, func: Function) => void} add | ||
| * @property {(functions: Object) => void} addMultiple | ||
| * @property {(name: string) => Function} get | ||
| * @property {() => Object} getLocalFunctions | ||
| * @property {() => FunctionRegistry} inherit | ||
| * @property {(base: FunctionRegistry) => FunctionRegistry} create | ||
| */ | ||
| /** | ||
| * @typedef {Node & { | ||
| * features: Value, | ||
| * rules: Ruleset[], | ||
| * type: string, | ||
| * functionRegistry?: FunctionRegistry, | ||
| * multiMedia?: boolean, | ||
| * debugInfo?: { lineNumber: number, fileName: string }, | ||
| * allowRoot?: boolean, | ||
| * _evaluated?: boolean, | ||
| * evalFunction: () => void, | ||
| * evalTop: (context: EvalContext) => Node | Ruleset, | ||
| * evalNested: (context: EvalContext) => Node | Ruleset, | ||
| * permute: (arr: Node[][]) => Node[][], | ||
| * bubbleSelectors: (selectors: Selector[] | undefined) => void, | ||
| * outputRuleset: (context: EvalContext, output: CSSOutput, rules: Node[]) => void | ||
| * }} NestableAtRuleThis | ||
| */ | ||
| const NestableAtRulePrototype = { | ||
| isRulesetLike() { | ||
| return true; | ||
| }, | ||
| accept: function (visitor) { | ||
| if (this.features) { | ||
| this.features = visitor.visit(this.features); | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| /** @type {NestableAtRuleThis} */ | ||
| const self = /** @type {NestableAtRuleThis} */ (/** @type {unknown} */ (this)); | ||
| if (self.features) { | ||
| self.features = /** @type {Value} */ (visitor.visit(self.features)); | ||
| } | ||
| if (this.rules) { | ||
| this.rules = visitor.visitArray(this.rules); | ||
| if (self.rules) { | ||
| self.rules = /** @type {Ruleset[]} */ (visitor.visitArray(self.rules)); | ||
| } | ||
| }, | ||
| evalFunction: function () { | ||
| if (!this.features || !Array.isArray(this.features.value) || this.features.value.length < 1) { | ||
| /** @type {NestableAtRuleThis} */ | ||
| const self = /** @type {NestableAtRuleThis} */ (/** @type {unknown} */ (this)); | ||
| if (!self.features || !Array.isArray(self.features.value) || self.features.value.length < 1) { | ||
| return; | ||
| } | ||
| var exprValues = this.features.value; | ||
| var expr, paren; | ||
| for (var index = 0; index < exprValues.length; ++index) { | ||
| const exprValues = /** @type {Node[]} */ (self.features.value); | ||
| /** @type {Node | undefined} */ | ||
| let expr; | ||
| /** @type {Node | undefined} */ | ||
| let paren; | ||
| for (let index = 0; index < exprValues.length; ++index) { | ||
| expr = exprValues[index]; | ||
| if (expr.type === 'Keyword' && index + 1 < exprValues.length && (expr.noSpacing || expr.noSpacing == null)) { | ||
| paren = exprValues[index + 1]; | ||
| if (paren.type === 'Paren' && paren.noSpacing) { | ||
| exprValues[index] = new expression_1.default([expr, paren]); | ||
| if ((expr.type === 'Keyword' || expr.type === 'Variable') | ||
| && index + 1 < exprValues.length | ||
| && (/** @type {Node & { noSpacing?: boolean }} */ (expr).noSpacing || /** @type {Node & { noSpacing?: boolean }} */ (expr).noSpacing == null)) { | ||
| paren = exprValues[index + 1]; | ||
| if (paren.type === 'Paren' && /** @type {Node & { noSpacing?: boolean }} */ (paren).noSpacing) { | ||
| exprValues[index]= new Expression([expr, paren]); | ||
| exprValues.splice(index + 1, 1); | ||
| exprValues[index].noSpacing = true; | ||
| /** @type {Node & { noSpacing?: boolean }} */ (exprValues[index]).noSpacing = true; | ||
| } | ||
@@ -40,32 +87,53 @@ } | ||
| }, | ||
| evalTop: function (context) { | ||
| this.evalFunction(); | ||
| var result = this; | ||
| /** @param {EvalContext} context */ | ||
| evalTop(context) { | ||
| /** @type {NestableAtRuleThis} */ | ||
| const self = /** @type {NestableAtRuleThis} */ (/** @type {unknown} */ (this)); | ||
| self.evalFunction(); | ||
| /** @type {Node | Ruleset} */ | ||
| let result = self; | ||
| // Render all dependent Media blocks. | ||
| if (context.mediaBlocks.length > 1) { | ||
| var selectors = (new selector_1.default([], null, null, this.getIndex(), this.fileInfo())).createEmptySelectors(); | ||
| result = new ruleset_1.default(selectors, context.mediaBlocks); | ||
| result.multiMedia = true; | ||
| result.copyVisibilityInfo(this.visibilityInfo()); | ||
| this.setParent(result, this); | ||
| const selectors = (new Selector([], null, null, self.getIndex(), self.fileInfo())).createEmptySelectors(); | ||
| result = new Ruleset(selectors, context.mediaBlocks); | ||
| /** @type {Ruleset & { multiMedia?: boolean }} */ (result).multiMedia = true; | ||
| result.copyVisibilityInfo(self.visibilityInfo()); | ||
| self.setParent(result, self); | ||
| } | ||
| delete context.mediaBlocks; | ||
| delete context.mediaPath; | ||
| return result; | ||
| }, | ||
| evalNested: function (context) { | ||
| this.evalFunction(); | ||
| var i; | ||
| var value; | ||
| var path = context.mediaPath.concat([this]); | ||
| /** @param {EvalContext} context */ | ||
| evalNested(context) { | ||
| /** @type {NestableAtRuleThis} */ | ||
| const self = /** @type {NestableAtRuleThis} */ (/** @type {unknown} */ (this)); | ||
| self.evalFunction(); | ||
| let i; | ||
| /** @type {Node | Node[]} */ | ||
| let value; | ||
| const path = context.mediaPath.concat([self]); | ||
| // Extract the media-query conditions separated with `,` (OR). | ||
| for (i = 0; i < path.length; i++) { | ||
| if (path[i].type !== this.type) { | ||
| context.mediaBlocks.splice(i, 1); | ||
| return this; | ||
| if (path[i].type !== self.type) { | ||
| const blockIndex = context.mediaBlocks.indexOf(self); | ||
| if (blockIndex > -1) { | ||
| context.mediaBlocks.splice(blockIndex, 1); | ||
| } | ||
| return self; | ||
| } | ||
| value = path[i].features instanceof value_1.default ? | ||
| path[i].features.value : path[i].features; | ||
| path[i] = Array.isArray(value) ? value : [value]; | ||
| value = /** @type {NestableAtRuleThis} */ (path[i]).features instanceof Value ? | ||
| /** @type {Node[]} */ (/** @type {NestableAtRuleThis} */ (path[i]).features.value) : /** @type {NestableAtRuleThis} */ (path[i]).features; | ||
| path[i] = /** @type {Node} */ (/** @type {unknown} */ (Array.isArray(value) ? value : [value])); | ||
| } | ||
| // Trace all permutations to generate the resulting media-query. | ||
@@ -78,25 +146,36 @@ // | ||
| // b and c and e | ||
| this.features = new value_1.default(this.permute(path).map(function (path) { | ||
| path = path.map(function (fragment) { return fragment.toCSS ? fragment : new anonymous_1.default(fragment); }); | ||
| for (i = path.length - 1; i > 0; i--) { | ||
| path.splice(i, 0, new anonymous_1.default('and')); | ||
| self.features = new Value(self.permute(/** @type {Node[][]} */ (/** @type {unknown} */ (path))).map( | ||
| /** @param {Node | Node[]} path */ | ||
| path => { | ||
| path = /** @type {Node[]} */ (path).map( | ||
| /** @param {Node & { toCSS?: Function }} fragment */ | ||
| fragment => fragment.toCSS ? fragment : new Anonymous(/** @type {string} */ (/** @type {unknown} */ (fragment)))); | ||
| for (i = /** @type {Node[]} */ (path).length - 1; i > 0; i--) { | ||
| /** @type {Node[]} */ (path).splice(i, 0, new Anonymous('and')); | ||
| } | ||
| return new expression_1.default(path); | ||
| return new Expression(/** @type {Node[]} */ (path)); | ||
| })); | ||
| this.setParent(this.features, this); | ||
| self.setParent(self.features, self); | ||
| // Fake a tree-node that doesn't output anything. | ||
| return new ruleset_1.default([], []); | ||
| return new Ruleset([], []); | ||
| }, | ||
| permute: function (arr) { | ||
| /** | ||
| * @param {Node[][]} arr | ||
| * @returns {Node[][]} | ||
| */ | ||
| permute(arr) { | ||
| if (arr.length === 0) { | ||
| return []; | ||
| } | ||
| else if (arr.length === 1) { | ||
| return arr[0]; | ||
| } | ||
| else { | ||
| var result = []; | ||
| var rest = this.permute(arr.slice(1)); | ||
| for (var i = 0; i < rest.length; i++) { | ||
| for (var j = 0; j < arr[0].length; j++) { | ||
| } else if (arr.length === 1) { | ||
| return /** @type {Node[][]} */ (/** @type {unknown} */ (arr[0])); | ||
| } else { | ||
| /** @type {Node[][]} */ | ||
| const result = []; | ||
| const rest = this.permute(arr.slice(1)); | ||
| for (let i = 0; i < rest.length; i++) { | ||
| for (let j = 0; j < arr[0].length; j++) { | ||
| result.push([arr[0][j]].concat(rest[i])); | ||
@@ -108,11 +187,15 @@ } | ||
| }, | ||
| bubbleSelectors: function (selectors) { | ||
| /** @param {Selector[] | undefined} selectors */ | ||
| bubbleSelectors(selectors) { | ||
| /** @type {NestableAtRuleThis} */ | ||
| const self = /** @type {NestableAtRuleThis} */ (/** @type {unknown} */ (this)); | ||
| if (!selectors) { | ||
| return; | ||
| } | ||
| this.rules = [new ruleset_1.default(utils.copyArray(selectors), [this.rules[0]])]; | ||
| this.setParent(this.rules, this); | ||
| self.rules = [new Ruleset(utils.copyArray(selectors), [self.rules[0]])]; | ||
| self.setParent(self.rules, self); | ||
| } | ||
| }; | ||
| exports.default = NestableAtRulePrototype; | ||
| //# sourceMappingURL=nested-at-rule.js.map | ||
| export default NestableAtRulePrototype; |
+225
-90
@@ -1,4 +0,64 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| // @ts-check | ||
| /** | ||
| * @typedef {object} FileInfo | ||
| * @property {string} [filename] | ||
| * @property {string} [rootpath] | ||
| * @property {string} [currentDirectory] | ||
| * @property {string} [rootFilename] | ||
| * @property {string} [entryPath] | ||
| * @property {boolean} [reference] | ||
| */ | ||
| /** | ||
| * @typedef {object} VisibilityInfo | ||
| * @property {number} [visibilityBlocks] | ||
| * @property {boolean} [nodeVisible] | ||
| */ | ||
| /** | ||
| * @typedef {object} CSSOutput | ||
| * @property {(chunk: string, fileInfo?: FileInfo, index?: number, mapLines?: boolean) => void} add | ||
| * @property {() => boolean} isEmpty | ||
| */ | ||
| /** | ||
| * @typedef {object} EvalContext | ||
| * @property {number} [numPrecision] | ||
| * @property {(op?: string) => boolean} [isMathOn] | ||
| * @property {number} [math] | ||
| * @property {Node[]} [frames] | ||
| * @property {Array<{important?: string}>} [importantScope] | ||
| * @property {string[]} [paths] | ||
| * @property {boolean} [compress] | ||
| * @property {boolean} [strictUnits] | ||
| * @property {boolean} [sourceMap] | ||
| * @property {boolean} [importMultiple] | ||
| * @property {string} [urlArgs] | ||
| * @property {boolean} [javascriptEnabled] | ||
| * @property {object} [pluginManager] | ||
| * @property {number} [rewriteUrls] | ||
| * @property {boolean} [inCalc] | ||
| * @property {boolean} [mathOn] | ||
| * @property {boolean[]} [calcStack] | ||
| * @property {boolean[]} [parensStack] | ||
| * @property {Node[]} [mediaBlocks] | ||
| * @property {Node[]} [mediaPath] | ||
| * @property {() => void} [inParenthesis] | ||
| * @property {() => void} [outOfParenthesis] | ||
| * @property {() => void} [enterCalc] | ||
| * @property {() => void} [exitCalc] | ||
| * @property {(path: string) => boolean} [pathRequiresRewrite] | ||
| * @property {(path: string, rootpath?: string) => string} [rewritePath] | ||
| * @property {(path: string) => string} [normalizePath] | ||
| * @property {number} [tabLevel] | ||
| * @property {boolean} [lastRule] | ||
| */ | ||
| /** | ||
| * @typedef {object} TreeVisitor | ||
| * @property {(node: Node) => Node} visit | ||
| * @property {(nodes: Node[], nonReplacing?: boolean) => Node[]} visitArray | ||
| */ | ||
| /** | ||
| * The reason why Node is a class and other nodes simply do not extend | ||
@@ -9,25 +69,39 @@ * from Node (since we're transpiling) is due to this issue: | ||
| */ | ||
| var Node = /** @class */ (function () { | ||
| function Node() { | ||
| class Node { | ||
| get type() { return ''; } | ||
| constructor() { | ||
| /** @type {Node | null} */ | ||
| this.parent = null; | ||
| /** @type {number | undefined} */ | ||
| this.visibilityBlocks = undefined; | ||
| /** @type {boolean | undefined} */ | ||
| this.nodeVisible = undefined; | ||
| /** @type {Node | null} */ | ||
| this.rootNode = null; | ||
| /** @type {Node | null} */ | ||
| this.parsed = null; | ||
| /** @type {Node | Node[] | string | number | undefined} */ | ||
| this.value = undefined; | ||
| /** @type {number | undefined} */ | ||
| this._index = undefined; | ||
| /** @type {FileInfo | undefined} */ | ||
| this._fileInfo = undefined; | ||
| } | ||
| Object.defineProperty(Node.prototype, "currentFileInfo", { | ||
| get: function () { | ||
| return this.fileInfo(); | ||
| }, | ||
| enumerable: false, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(Node.prototype, "index", { | ||
| get: function () { | ||
| return this.getIndex(); | ||
| }, | ||
| enumerable: false, | ||
| configurable: true | ||
| }); | ||
| Node.prototype.setParent = function (nodes, parent) { | ||
| get currentFileInfo() { | ||
| return this.fileInfo(); | ||
| } | ||
| get index() { | ||
| return this.getIndex(); | ||
| } | ||
| /** | ||
| * @param {Node | Node[]} nodes | ||
| * @param {Node} parent | ||
| */ | ||
| setParent(nodes, parent) { | ||
| /** @param {Node} node */ | ||
| function set(node) { | ||
@@ -44,16 +118,26 @@ if (node && node instanceof Node) { | ||
| } | ||
| }; | ||
| Node.prototype.getIndex = function () { | ||
| } | ||
| /** @returns {number} */ | ||
| getIndex() { | ||
| return this._index || (this.parent && this.parent.getIndex()) || 0; | ||
| }; | ||
| Node.prototype.fileInfo = function () { | ||
| } | ||
| /** @returns {FileInfo} */ | ||
| fileInfo() { | ||
| return this._fileInfo || (this.parent && this.parent.fileInfo()) || {}; | ||
| }; | ||
| Node.prototype.isRulesetLike = function () { return false; }; | ||
| Node.prototype.toCSS = function (context) { | ||
| var strs = []; | ||
| } | ||
| /** @returns {boolean} */ | ||
| isRulesetLike() { return false; } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {string} | ||
| */ | ||
| toCSS(context) { | ||
| /** @type {string[]} */ | ||
| const strs = []; | ||
| this.genCSS(context, { | ||
| // remove when genCSS has JSDoc types | ||
| // eslint-disable-next-line no-unused-vars | ||
| add: function (chunk, fileInfo, index) { | ||
| add: function(chunk, fileInfo, index) { | ||
| strs.push(chunk); | ||
@@ -66,11 +150,33 @@ }, | ||
| return strs.join(''); | ||
| }; | ||
| Node.prototype.genCSS = function (context, output) { | ||
| output.add(this.value); | ||
| }; | ||
| Node.prototype.accept = function (visitor) { | ||
| this.value = visitor.visit(this.value); | ||
| }; | ||
| Node.prototype.eval = function () { return this; }; | ||
| Node.prototype._operate = function (context, op, a, b) { | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| output.add(/** @type {string} */ (this.value)); | ||
| } | ||
| /** | ||
| * @param {TreeVisitor} visitor | ||
| */ | ||
| accept(visitor) { | ||
| this.value = visitor.visit(/** @type {Node} */ (this.value)); | ||
| } | ||
| /** | ||
| * @param {EvalContext} [context] | ||
| * @returns {Node} | ||
| */ | ||
| eval(context) { return this; } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {string} op | ||
| * @param {number} a | ||
| * @param {number} b | ||
| * @returns {number | undefined} | ||
| */ | ||
| _operate(context, op, a, b) { | ||
| switch (op) { | ||
@@ -82,9 +188,21 @@ case '+': return a + b; | ||
| } | ||
| }; | ||
| Node.prototype.fround = function (context, value) { | ||
| var precision = context && context.numPrecision; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {number} value | ||
| * @returns {number} | ||
| */ | ||
| fround(context, value) { | ||
| const precision = context && context.numPrecision; | ||
| // add "epsilon" to ensure numbers like 1.000000005 (represented as 1.000000004999...) are properly rounded: | ||
| return (precision) ? Number((value + 2e-16).toFixed(precision)) : value; | ||
| }; | ||
| Node.compare = function (a, b) { | ||
| } | ||
| /** | ||
| * @param {Node & { compare?: (other: Node) => number | undefined }} a | ||
| * @param {Node & { compare?: (other: Node) => number | undefined }} b | ||
| * @returns {number | undefined} | ||
| */ | ||
| static compare(a, b) { | ||
| /* returns: | ||
@@ -95,2 +213,3 @@ -1: a < b | ||
| and *any* other value for a != b (e.g. undefined, NaN, -2 etc.) */ | ||
| if ((a.compare) && | ||
@@ -101,19 +220,21 @@ // for "symmetric results" force toCSS-based comparison | ||
| return a.compare(b); | ||
| } | ||
| else if (b.compare) { | ||
| } else if (b.compare) { | ||
| return -b.compare(a); | ||
| } | ||
| else if (a.type !== b.type) { | ||
| } else if (a.type !== b.type) { | ||
| return undefined; | ||
| } | ||
| a = a.value; | ||
| b = b.value; | ||
| if (!Array.isArray(a)) { | ||
| return a === b ? 0 : undefined; | ||
| let aVal = a.value; | ||
| let bVal = b.value; | ||
| if (!Array.isArray(aVal)) { | ||
| return aVal === bVal ? 0 : undefined; | ||
| } | ||
| if (a.length !== b.length) { | ||
| if (!Array.isArray(bVal)) { | ||
| return undefined; | ||
| } | ||
| for (var i = 0; i < a.length; i++) { | ||
| if (Node.compare(a[i], b[i]) !== 0) { | ||
| if (aVal.length !== bVal.length) { | ||
| return undefined; | ||
| } | ||
| for (let i = 0; i < aVal.length; i++) { | ||
| if (Node.compare(aVal[i], bVal[i]) !== 0) { | ||
| return undefined; | ||
@@ -123,10 +244,17 @@ } | ||
| return 0; | ||
| }; | ||
| Node.numericCompare = function (a, b) { | ||
| return a < b ? -1 | ||
| : a === b ? 0 | ||
| : a > b ? 1 : undefined; | ||
| }; | ||
| // Returns true if this node represents root of ast imported by reference | ||
| Node.prototype.blocksVisibility = function () { | ||
| } | ||
| /** | ||
| * @param {number | string} a | ||
| * @param {number | string} b | ||
| * @returns {number | undefined} | ||
| */ | ||
| static numericCompare(a, b) { | ||
| return a < b ? -1 | ||
| : a === b ? 0 | ||
| : a > b ? 1 : undefined; | ||
| } | ||
| /** @returns {boolean} */ | ||
| blocksVisibility() { | ||
| if (this.visibilityBlocks === undefined) { | ||
@@ -136,4 +264,5 @@ this.visibilityBlocks = 0; | ||
| return this.visibilityBlocks !== 0; | ||
| }; | ||
| Node.prototype.addVisibilityBlock = function () { | ||
| } | ||
| addVisibilityBlock() { | ||
| if (this.visibilityBlocks === undefined) { | ||
@@ -143,4 +272,5 @@ this.visibilityBlocks = 0; | ||
| this.visibilityBlocks = this.visibilityBlocks + 1; | ||
| }; | ||
| Node.prototype.removeVisibilityBlock = function () { | ||
| } | ||
| removeVisibilityBlock() { | ||
| if (this.visibilityBlocks === undefined) { | ||
@@ -150,21 +280,19 @@ this.visibilityBlocks = 0; | ||
| this.visibilityBlocks = this.visibilityBlocks - 1; | ||
| }; | ||
| // Turns on node visibility - if called node will be shown in output regardless | ||
| // of whether it comes from import by reference or not | ||
| Node.prototype.ensureVisibility = function () { | ||
| } | ||
| ensureVisibility() { | ||
| this.nodeVisible = true; | ||
| }; | ||
| // Turns off node visibility - if called node will NOT be shown in output regardless | ||
| // of whether it comes from import by reference or not | ||
| Node.prototype.ensureInvisibility = function () { | ||
| } | ||
| ensureInvisibility() { | ||
| this.nodeVisible = false; | ||
| }; | ||
| // return values: | ||
| // false - the node must not be visible | ||
| // true - the node must be visible | ||
| // undefined or null - the node has the same visibility as its parent | ||
| Node.prototype.isVisible = function () { | ||
| } | ||
| /** @returns {boolean | undefined} */ | ||
| isVisible() { | ||
| return this.nodeVisible; | ||
| }; | ||
| Node.prototype.visibilityInfo = function () { | ||
| } | ||
| /** @returns {VisibilityInfo} */ | ||
| visibilityInfo() { | ||
| return { | ||
@@ -174,4 +302,6 @@ visibilityBlocks: this.visibilityBlocks, | ||
| }; | ||
| }; | ||
| Node.prototype.copyVisibilityInfo = function (info) { | ||
| } | ||
| /** @param {VisibilityInfo} info */ | ||
| copyVisibilityInfo(info) { | ||
| if (!info) { | ||
@@ -182,6 +312,11 @@ return; | ||
| this.nodeVisible = info.nodeVisible; | ||
| }; | ||
| return Node; | ||
| }()); | ||
| exports.default = Node; | ||
| //# sourceMappingURL=node.js.map | ||
| } | ||
| } | ||
| /** | ||
| * Set by the parser at runtime on Node.prototype. | ||
| * @type {{ context: EvalContext, importManager: object, imports: object } | undefined} | ||
| */ | ||
| Node.prototype.parse = undefined; | ||
| export default Node; |
@@ -1,32 +0,49 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var color_1 = tslib_1.__importDefault(require("./color")); | ||
| var dimension_1 = tslib_1.__importDefault(require("./dimension")); | ||
| var Constants = tslib_1.__importStar(require("../constants")); | ||
| var MATH = Constants.Math; | ||
| var Operation = function (op, operands, isSpaced) { | ||
| this.op = op.trim(); | ||
| this.operands = operands; | ||
| this.isSpaced = isSpaced; | ||
| }; | ||
| Operation.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Operation', | ||
| accept: function (visitor) { | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, TreeVisitor } from './node.js' */ | ||
| import Node from './node.js'; | ||
| import Color from './color.js'; | ||
| import Dimension from './dimension.js'; | ||
| import * as Constants from '../constants.js'; | ||
| const MATH = Constants.Math; | ||
| class Operation extends Node { | ||
| get type() { return 'Operation'; } | ||
| /** | ||
| * @param {string} op | ||
| * @param {Node[]} operands | ||
| * @param {boolean} isSpaced | ||
| */ | ||
| constructor(op, operands, isSpaced) { | ||
| super(); | ||
| this.op = op.trim(); | ||
| this.operands = operands; | ||
| this.isSpaced = isSpaced; | ||
| } | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| this.operands = visitor.visitArray(this.operands); | ||
| }, | ||
| eval: function (context) { | ||
| var a = this.operands[0].eval(context), b = this.operands[1].eval(context), op; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Node} | ||
| */ | ||
| eval(context) { | ||
| let a = this.operands[0].eval(context), b = this.operands[1].eval(context), op; | ||
| if (context.isMathOn(this.op)) { | ||
| op = this.op === './' ? '/' : this.op; | ||
| if (a instanceof dimension_1.default && b instanceof color_1.default) { | ||
| a = a.toColor(); | ||
| if (a instanceof Dimension && b instanceof Color) { | ||
| a = /** @type {Dimension} */ (a).toColor(); | ||
| } | ||
| if (b instanceof dimension_1.default && a instanceof color_1.default) { | ||
| b = b.toColor(); | ||
| if (b instanceof Dimension && a instanceof Color) { | ||
| b = /** @type {Dimension} */ (b).toColor(); | ||
| } | ||
| if (!a.operate || !b.operate) { | ||
| if ((a instanceof Operation || b instanceof Operation) | ||
| && a.op === '/' && context.math === MATH.PARENS_DIVISION) { | ||
| if (!/** @type {Dimension | Color} */ (a).operate || !/** @type {Dimension | Color} */ (b).operate) { | ||
| if ( | ||
| (a instanceof Operation || b instanceof Operation) | ||
| && /** @type {Operation} */ (a).op === '/' && context.math === MATH.PARENS_DIVISION | ||
| ) { | ||
| return new Operation(this.op, [a, b], this.isSpaced); | ||
@@ -37,9 +54,17 @@ } | ||
| } | ||
| return a.operate(context, op, b); | ||
| } | ||
| else { | ||
| if (a instanceof Dimension) { | ||
| return a.operate(context, op, /** @type {Dimension} */ (b)); | ||
| } | ||
| return /** @type {Color} */ (a).operate(context, op, /** @type {Color} */ (b)); | ||
| } else { | ||
| return new Operation(this.op, [a, b], this.isSpaced); | ||
| } | ||
| }, | ||
| genCSS: function (context, output) { | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| this.operands[0].genCSS(context, output); | ||
@@ -55,4 +80,4 @@ if (this.isSpaced) { | ||
| } | ||
| }); | ||
| exports.default = Operation; | ||
| //# sourceMappingURL=operation.js.map | ||
| } | ||
| export default Operation; |
+34
-17
@@ -1,24 +0,41 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var Paren = function (node) { | ||
| this.value = node; | ||
| }; | ||
| Paren.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Paren', | ||
| genCSS: function (context, output) { | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput } from './node.js' */ | ||
| import Node from './node.js'; | ||
| class Paren extends Node { | ||
| get type() { return 'Paren'; } | ||
| /** @param {Node} node */ | ||
| constructor(node) { | ||
| super(); | ||
| this.value = node; | ||
| /** @type {boolean | undefined} */ | ||
| this.noSpacing = undefined; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| output.add('('); | ||
| this.value.genCSS(context, output); | ||
| /** @type {Node} */ (this.value).genCSS(context, output); | ||
| output.add(')'); | ||
| }, | ||
| eval: function (context) { | ||
| var paren = new Paren(this.value.eval(context)); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Paren} | ||
| */ | ||
| eval(context) { | ||
| const paren = new Paren(/** @type {Node} */ (this.value).eval(context)); | ||
| if (this.noSpacing) { | ||
| paren.noSpacing = true; | ||
| } | ||
| return paren; | ||
| } | ||
| }); | ||
| exports.default = Paren; | ||
| //# sourceMappingURL=paren.js.map | ||
| } | ||
| export default Paren; |
@@ -1,37 +0,65 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var declaration_1 = tslib_1.__importDefault(require("./declaration")); | ||
| var Property = function (name, index, currentFileInfo) { | ||
| this.name = name; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| }; | ||
| Property.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Property', | ||
| eval: function (context) { | ||
| var property; | ||
| var name = this.name; | ||
| // @ts-check | ||
| /** @import { EvalContext, FileInfo } from './node.js' */ | ||
| import Node from './node.js'; | ||
| import Declaration from './declaration.js'; | ||
| import Ruleset from './ruleset.js'; | ||
| class Property extends Node { | ||
| get type() { return 'Property'; } | ||
| /** | ||
| * @param {string} name | ||
| * @param {number} index | ||
| * @param {FileInfo} currentFileInfo | ||
| */ | ||
| constructor(name, index, currentFileInfo) { | ||
| super(); | ||
| this.name = name; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| /** @type {boolean | undefined} */ | ||
| this.evaluating = undefined; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Node} | ||
| */ | ||
| eval(context) { | ||
| let property; | ||
| const name = this.name; | ||
| // TODO: shorten this reference | ||
| var mergeRules = context.pluginManager.less.visitors.ToCSSVisitor.prototype._mergeRules; | ||
| const mergeRules = /** @type {{ less: { visitors: { ToCSSVisitor: { prototype: { _mergeRules: (rules: Declaration[]) => void } } } } }} */ (context.pluginManager).less.visitors.ToCSSVisitor.prototype._mergeRules; | ||
| if (this.evaluating) { | ||
| throw { type: 'Name', | ||
| message: "Recursive property reference for ".concat(name), | ||
| message: `Recursive property reference for ${name}`, | ||
| filename: this.fileInfo().filename, | ||
| index: this.getIndex() }; | ||
| } | ||
| this.evaluating = true; | ||
| property = this.find(context.frames, function (frame) { | ||
| var v; | ||
| var vArr = frame.property(name); | ||
| property = this.find(context.frames, function (/** @type {Node} */ frame) { | ||
| let v; | ||
| const vArr = /** @type {Ruleset} */ (frame).property(name); | ||
| if (vArr) { | ||
| for (var i = 0; i < vArr.length; i++) { | ||
| for (let i = 0; i < vArr.length; i++) { | ||
| v = vArr[i]; | ||
| vArr[i] = new declaration_1.default(v.name, v.value, v.important, v.merge, v.index, v.currentFileInfo, v.inline, v.variable); | ||
| vArr[i] = new Declaration(v.name, | ||
| v.value, | ||
| v.important, | ||
| v.merge, | ||
| v.index, | ||
| v.currentFileInfo, | ||
| v.inline, | ||
| v.variable | ||
| ); | ||
| } | ||
| mergeRules(vArr); | ||
| v = vArr[vArr.length - 1]; | ||
| if (v.important) { | ||
| var importantScope = context.importantScope[context.importantScope.length - 1]; | ||
| const importantScope = context.importantScope[context.importantScope.length - 1]; | ||
| importantScope.important = v.important; | ||
@@ -46,21 +74,24 @@ } | ||
| return property; | ||
| } | ||
| else { | ||
| } else { | ||
| throw { type: 'Name', | ||
| message: "Property '".concat(name, "' is undefined"), | ||
| message: `Property '${name}' is undefined`, | ||
| filename: this.currentFileInfo.filename, | ||
| index: this.index }; | ||
| } | ||
| }, | ||
| find: function (obj, fun) { | ||
| for (var i = 0, r = void 0; i < obj.length; i++) { | ||
| } | ||
| /** | ||
| * @param {Node[]} obj | ||
| * @param {(frame: Node) => Node | undefined} fun | ||
| * @returns {Node | null} | ||
| */ | ||
| find(obj, fun) { | ||
| for (let i = 0, r; i < obj.length; i++) { | ||
| r = fun.call(obj, obj[i]); | ||
| if (r) { | ||
| return r; | ||
| } | ||
| if (r) { return r; } | ||
| } | ||
| return null; | ||
| } | ||
| }); | ||
| exports.default = Property; | ||
| //# sourceMappingURL=property.js.map | ||
| } | ||
| export default Property; |
@@ -1,19 +0,29 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var copy_anything_1 = require("copy-anything"); | ||
| var declaration_1 = tslib_1.__importDefault(require("./declaration")); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var QueryInParens = function (op, l, m, op2, r, i) { | ||
| this.op = op.trim(); | ||
| this.lvalue = l; | ||
| this.mvalue = m; | ||
| this.op2 = op2 ? op2.trim() : null; | ||
| this.rvalue = r; | ||
| this._index = i; | ||
| this.mvalues = []; | ||
| }; | ||
| QueryInParens.prototype = Object.assign(new node_1.default(), { | ||
| type: 'QueryInParens', | ||
| accept: function (visitor) { | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, TreeVisitor } from './node.js' */ | ||
| import Node from './node.js'; | ||
| class QueryInParens extends Node { | ||
| get type() { return 'QueryInParens'; } | ||
| /** | ||
| * @param {string} op | ||
| * @param {Node} l | ||
| * @param {Node} m | ||
| * @param {string | null} op2 | ||
| * @param {Node | null} r | ||
| * @param {number} i | ||
| */ | ||
| constructor(op, l, m, op2, r, i) { | ||
| super(); | ||
| this.op = op.trim(); | ||
| this.lvalue = l; | ||
| this.mvalue = m; | ||
| this.op2 = op2 ? op2.trim() : null; | ||
| /** @type {Node | null} */ | ||
| this.rvalue = r; | ||
| this._index = i; | ||
| } | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| this.lvalue = visitor.visit(this.lvalue); | ||
@@ -24,42 +34,24 @@ this.mvalue = visitor.visit(this.mvalue); | ||
| } | ||
| }, | ||
| eval: function (context) { | ||
| this.lvalue = this.lvalue.eval(context); | ||
| var variableDeclaration; | ||
| var rule; | ||
| for (var i = 0; (rule = context.frames[i]); i++) { | ||
| if (rule.type === 'Ruleset') { | ||
| variableDeclaration = rule.rules.find(function (r) { | ||
| if ((r instanceof declaration_1.default) && r.variable) { | ||
| return true; | ||
| } | ||
| return false; | ||
| }); | ||
| if (variableDeclaration) { | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (!this.mvalueCopy) { | ||
| this.mvalueCopy = (0, copy_anything_1.copy)(this.mvalue); | ||
| } | ||
| if (variableDeclaration) { | ||
| this.mvalue = this.mvalueCopy; | ||
| this.mvalue = this.mvalue.eval(context); | ||
| this.mvalues.push(this.mvalue); | ||
| } | ||
| else { | ||
| this.mvalue = this.mvalue.eval(context); | ||
| } | ||
| if (this.rvalue) { | ||
| this.rvalue = this.rvalue.eval(context); | ||
| } | ||
| return this; | ||
| }, | ||
| genCSS: function (context, output) { | ||
| } | ||
| /** @param {EvalContext} context */ | ||
| eval(context) { | ||
| const node = new QueryInParens( | ||
| this.op, | ||
| this.lvalue.eval(context), | ||
| this.mvalue.eval(context), | ||
| this.op2, | ||
| this.rvalue ? this.rvalue.eval(context) : null, | ||
| this._index || 0 | ||
| ); | ||
| return node; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| this.lvalue.genCSS(context, output); | ||
| output.add(' ' + this.op + ' '); | ||
| if (this.mvalues.length > 0) { | ||
| this.mvalue = this.mvalues.shift(); | ||
| } | ||
| this.mvalue.genCSS(context, output); | ||
@@ -70,5 +62,5 @@ if (this.rvalue) { | ||
| } | ||
| }, | ||
| }); | ||
| exports.default = QueryInParens; | ||
| //# sourceMappingURL=query-in-parens.js.map | ||
| } | ||
| } | ||
| export default QueryInParens; |
+93
-44
@@ -1,44 +0,86 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var variable_1 = tslib_1.__importDefault(require("./variable")); | ||
| var property_1 = tslib_1.__importDefault(require("./property")); | ||
| var Quoted = function (str, content, escaped, index, currentFileInfo) { | ||
| this.escaped = (escaped === undefined) ? true : escaped; | ||
| this.value = content || ''; | ||
| this.quote = str.charAt(0); | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.variableRegex = /@\{([\w-]+)\}/g; | ||
| this.propRegex = /\$\{([\w-]+)\}/g; | ||
| this.allowRoot = escaped; | ||
| }; | ||
| Quoted.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Quoted', | ||
| genCSS: function (context, output) { | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, FileInfo } from './node.js' */ | ||
| import Node from './node.js'; | ||
| import Variable from './variable.js'; | ||
| import Property from './property.js'; | ||
| class Quoted extends Node { | ||
| get type() { return 'Quoted'; } | ||
| /** | ||
| * @param {string} str | ||
| * @param {string} [content] | ||
| * @param {boolean} [escaped] | ||
| * @param {number} [index] | ||
| * @param {FileInfo} [currentFileInfo] | ||
| */ | ||
| constructor(str, content, escaped, index, currentFileInfo) { | ||
| super(); | ||
| /** @type {boolean} */ | ||
| this.escaped = (escaped === undefined) ? true : escaped; | ||
| /** @type {string} */ | ||
| this.value = content || ''; | ||
| /** @type {string} */ | ||
| this.quote = str.charAt(0); | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| /** @type {RegExp} */ | ||
| this.variableRegex = /@\{([\w-]+)\}/g; | ||
| /** @type {RegExp} */ | ||
| this.propRegex = /\$\{([\w-]+)\}/g; | ||
| /** @type {boolean | undefined} */ | ||
| this.allowRoot = escaped; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| if (!this.escaped) { | ||
| output.add(this.quote, this.fileInfo(), this.getIndex()); | ||
| } | ||
| output.add(this.value); | ||
| output.add(/** @type {string} */ (this.value)); | ||
| if (!this.escaped) { | ||
| output.add(this.quote); | ||
| } | ||
| }, | ||
| containsVariables: function () { | ||
| return this.value.match(this.variableRegex); | ||
| }, | ||
| eval: function (context) { | ||
| var that = this; | ||
| var value = this.value; | ||
| var variableReplacement = function (_, name1, name2) { | ||
| var v = new variable_1.default("@".concat(name1 !== null && name1 !== void 0 ? name1 : name2), that.getIndex(), that.fileInfo()).eval(context, true); | ||
| return (v instanceof Quoted) ? v.value : v.toCSS(); | ||
| } | ||
| /** @returns {RegExpMatchArray | null} */ | ||
| containsVariables() { | ||
| return /** @type {string} */ (this.value).match(this.variableRegex); | ||
| } | ||
| /** @param {EvalContext} context */ | ||
| eval(context) { | ||
| const that = this; | ||
| let value = /** @type {string} */ (this.value); | ||
| /** | ||
| * @param {string} _ | ||
| * @param {string} name1 | ||
| * @param {string} name2 | ||
| * @returns {string} | ||
| */ | ||
| const variableReplacement = function (_, name1, name2) { | ||
| const v = new Variable(`@${name1 ?? name2}`, that.getIndex(), that.fileInfo()).eval(context); | ||
| return (v instanceof Quoted) ? /** @type {string} */ (v.value) : v.toCSS(context); | ||
| }; | ||
| var propertyReplacement = function (_, name1, name2) { | ||
| var v = new property_1.default("$".concat(name1 !== null && name1 !== void 0 ? name1 : name2), that.getIndex(), that.fileInfo()).eval(context, true); | ||
| return (v instanceof Quoted) ? v.value : v.toCSS(); | ||
| /** | ||
| * @param {string} _ | ||
| * @param {string} name1 | ||
| * @param {string} name2 | ||
| * @returns {string} | ||
| */ | ||
| const propertyReplacement = function (_, name1, name2) { | ||
| const v = new Property(`$${name1 ?? name2}`, that.getIndex(), that.fileInfo()).eval(context); | ||
| return (v instanceof Quoted) ? /** @type {string} */ (v.value) : v.toCSS(context); | ||
| }; | ||
| /** | ||
| * @param {string} value | ||
| * @param {RegExp} regexp | ||
| * @param {(substring: string, ...args: string[]) => string} replacementFnc | ||
| * @returns {string} | ||
| */ | ||
| function iterativeReplace(value, regexp, replacementFnc) { | ||
| var evaluatedValue = value; | ||
| let evaluatedValue = value; | ||
| do { | ||
@@ -53,14 +95,21 @@ value = evaluatedValue.toString(); | ||
| return new Quoted(this.quote + value + this.quote, value, this.escaped, this.getIndex(), this.fileInfo()); | ||
| }, | ||
| compare: function (other) { | ||
| } | ||
| /** | ||
| * @param {Node} other | ||
| * @returns {number | undefined} | ||
| */ | ||
| compare(other) { | ||
| // when comparing quoted strings allow the quote to differ | ||
| if (other.type === 'Quoted' && !this.escaped && !other.escaped) { | ||
| return node_1.default.numericCompare(this.value, other.value); | ||
| if (other.type === 'Quoted' && !this.escaped && !/** @type {Quoted} */ (other).escaped) { | ||
| return Node.numericCompare( | ||
| /** @type {string} */ (this.value), | ||
| /** @type {string} */ (other.value) | ||
| ); | ||
| } else { | ||
| return other.toCSS && this.toCSS(/** @type {EvalContext} */ ({})) === other.toCSS(/** @type {EvalContext} */ ({})) ? 0 : undefined; | ||
| } | ||
| else { | ||
| return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined; | ||
| } | ||
| } | ||
| }); | ||
| exports.default = Quoted; | ||
| //# sourceMappingURL=quoted.js.map | ||
| } | ||
| export default Quoted; |
+632
-318
@@ -1,61 +0,127 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var declaration_1 = tslib_1.__importDefault(require("./declaration")); | ||
| var keyword_1 = tslib_1.__importDefault(require("./keyword")); | ||
| var comment_1 = tslib_1.__importDefault(require("./comment")); | ||
| var paren_1 = tslib_1.__importDefault(require("./paren")); | ||
| var selector_1 = tslib_1.__importDefault(require("./selector")); | ||
| var element_1 = tslib_1.__importDefault(require("./element")); | ||
| var anonymous_1 = tslib_1.__importDefault(require("./anonymous")); | ||
| var contexts_1 = tslib_1.__importDefault(require("../contexts")); | ||
| var function_registry_1 = tslib_1.__importDefault(require("../functions/function-registry")); | ||
| var default_1 = tslib_1.__importDefault(require("../functions/default")); | ||
| var debug_info_1 = tslib_1.__importDefault(require("./debug-info")); | ||
| var utils = tslib_1.__importStar(require("../utils")); | ||
| var parser_1 = tslib_1.__importDefault(require("../parser/parser")); | ||
| var Ruleset = function (selectors, rules, strictImports, visibilityInfo) { | ||
| this.selectors = selectors; | ||
| this.rules = rules; | ||
| this._lookups = {}; | ||
| this._variables = null; | ||
| this._properties = null; | ||
| this.strictImports = strictImports; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| this.allowRoot = true; | ||
| this.setParent(this.selectors, this); | ||
| this.setParent(this.rules, this); | ||
| }; | ||
| Ruleset.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Ruleset', | ||
| isRuleset: true, | ||
| isRulesetLike: function () { return true; }, | ||
| accept: function (visitor) { | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, TreeVisitor, FileInfo, VisibilityInfo } from './node.js' */ | ||
| /** @import { FunctionRegistry } from './nested-at-rule.js' */ | ||
| import Node from './node.js'; | ||
| import Declaration from './declaration.js'; | ||
| import Keyword from './keyword.js'; | ||
| import Comment from './comment.js'; | ||
| import Paren from './paren.js'; | ||
| import Selector from './selector.js'; | ||
| import Element from './element.js'; | ||
| import Anonymous from './anonymous.js'; | ||
| import contexts from '../contexts.js'; | ||
| import globalFunctionRegistry from '../functions/function-registry.js'; | ||
| import defaultFunc from '../functions/default.js'; | ||
| import getDebugInfo from './debug-info.js'; | ||
| import * as utils from '../utils.js'; | ||
| import Parser from '../parser/parser.js'; | ||
| /** | ||
| * @typedef {Node & { | ||
| * rules?: Node[], | ||
| * selectors?: Selector[], | ||
| * root?: boolean, | ||
| * firstRoot?: boolean, | ||
| * allowImports?: boolean, | ||
| * functionRegistry?: FunctionRegistry, | ||
| * originalRuleset?: Node, | ||
| * debugInfo?: { lineNumber: number, fileName: string }, | ||
| * evalFirst?: boolean, | ||
| * isRuleset?: boolean, | ||
| * isCharset?: () => boolean, | ||
| * merge?: boolean | string, | ||
| * multiMedia?: boolean, | ||
| * parse?: { context: EvalContext, importManager: object }, | ||
| * bubbleSelectors?: (selectors: Selector[]) => void | ||
| * }} RuleNode | ||
| */ | ||
| class Ruleset extends Node { | ||
| get type() { return 'Ruleset'; } | ||
| /** | ||
| * @param {Selector[] | null} selectors | ||
| * @param {Node[] | null} rules | ||
| * @param {boolean} [strictImports] | ||
| * @param {VisibilityInfo} [visibilityInfo] | ||
| */ | ||
| constructor(selectors, rules, strictImports, visibilityInfo) { | ||
| super(); | ||
| /** @type {Selector[] | null} */ | ||
| this.selectors = selectors; | ||
| /** @type {Node[] | null} */ | ||
| this.rules = rules; | ||
| /** @type {Object<string, { rule: Node, path: Node[] }[]>} */ | ||
| this._lookups = {}; | ||
| /** @type {Object<string, Declaration> | null} */ | ||
| this._variables = null; | ||
| /** @type {Object<string, Declaration[]> | null} */ | ||
| this._properties = null; | ||
| /** @type {boolean | undefined} */ | ||
| this.strictImports = strictImports; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| this.allowRoot = true; | ||
| /** @type {boolean} */ | ||
| this.isRuleset = true; | ||
| /** @type {boolean | undefined} */ | ||
| this.root = undefined; | ||
| /** @type {boolean | undefined} */ | ||
| this.firstRoot = undefined; | ||
| /** @type {boolean | undefined} */ | ||
| this.allowImports = undefined; | ||
| /** @type {FunctionRegistry | undefined} */ | ||
| this.functionRegistry = undefined; | ||
| /** @type {Node | undefined} */ | ||
| this.originalRuleset = undefined; | ||
| /** @type {{ lineNumber: number, fileName: string } | undefined} */ | ||
| this.debugInfo = undefined; | ||
| /** @type {Selector[][] | undefined} */ | ||
| this.paths = undefined; | ||
| /** @type {Ruleset[] | null | undefined} */ | ||
| this._rulesets = undefined; | ||
| /** @type {boolean | undefined} */ | ||
| this.evalFirst = undefined; | ||
| this.setParent(this.selectors, this); | ||
| this.setParent(this.rules, this); | ||
| } | ||
| isRulesetLike() { return true; } | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| if (this.paths) { | ||
| this.paths = visitor.visitArray(this.paths, true); | ||
| this.paths = /** @type {Selector[][]} */ (/** @type {unknown} */ (visitor.visitArray(/** @type {Node[]} */ (/** @type {unknown} */ (this.paths)), true))); | ||
| } else if (this.selectors) { | ||
| this.selectors = /** @type {Selector[]} */ (visitor.visitArray(this.selectors)); | ||
| } | ||
| else if (this.selectors) { | ||
| this.selectors = visitor.visitArray(this.selectors); | ||
| } | ||
| if (this.rules && this.rules.length) { | ||
| this.rules = visitor.visitArray(this.rules); | ||
| } | ||
| }, | ||
| eval: function (context) { | ||
| var selectors; | ||
| var selCnt; | ||
| var selector; | ||
| var i; | ||
| var hasVariable; | ||
| var hasOnePassingSelector = false; | ||
| } | ||
| /** @param {EvalContext} context */ | ||
| eval(context) { | ||
| /** @type {Selector[] | undefined} */ | ||
| let selectors; | ||
| /** @type {number} */ | ||
| let selCnt; | ||
| /** @type {Selector} */ | ||
| let selector; | ||
| /** @type {number} */ | ||
| let i; | ||
| /** @type {boolean | undefined} */ | ||
| let hasVariable; | ||
| let hasOnePassingSelector = false; | ||
| if (this.selectors && (selCnt = this.selectors.length)) { | ||
| selectors = new Array(selCnt); | ||
| default_1.default.error({ | ||
| defaultFunc.error({ | ||
| type: 'Syntax', | ||
| message: 'it is currently only allowed in parametric mixin guards,' | ||
| }); | ||
| for (i = 0; i < selCnt; i++) { | ||
| selector = this.selectors[i].eval(context); | ||
| for (var j = 0; j < selector.elements.length; j++) { | ||
| selector = /** @type {Selector} */ (this.selectors[i].eval(context)); | ||
| for (let j = 0; j < selector.elements.length; j++) { | ||
| if (selector.elements[j].isVariable) { | ||
@@ -71,4 +137,5 @@ hasVariable = true; | ||
| } | ||
| if (hasVariable) { | ||
| var toParseSelectors = new Array(selCnt); | ||
| const toParseSelectors = new Array(selCnt); | ||
| for (i = 0; i < selCnt; i++) { | ||
@@ -78,19 +145,26 @@ selector = selectors[i]; | ||
| } | ||
| var startingIndex = selectors[0].getIndex(); | ||
| var selectorFileInfo = selectors[0].fileInfo(); | ||
| new parser_1.default(context, this.parse.importManager, selectorFileInfo, startingIndex).parseNode(toParseSelectors.join(','), ['selectors'], function (err, result) { | ||
| if (result) { | ||
| selectors = utils.flattenArray(result); | ||
| } | ||
| }); | ||
| const startingIndex = selectors[0].getIndex(); | ||
| const selectorFileInfo = selectors[0].fileInfo(); | ||
| new (/** @type {new (...args: [EvalContext, object, FileInfo, number]) => { parseNode: Function }} */ (/** @type {unknown} */ (Parser)))(context, /** @type {{ context: EvalContext, importManager: object }} */ (this.parse).importManager, selectorFileInfo, startingIndex).parseNode( | ||
| toParseSelectors.join(','), | ||
| ['selectors'], | ||
| function(/** @type {Error | null} */ err, /** @type {Node[]} */ result) { | ||
| if (result) { | ||
| selectors = /** @type {Selector[]} */ (utils.flattenArray(result)); | ||
| } | ||
| }); | ||
| } | ||
| default_1.default.reset(); | ||
| } | ||
| else { | ||
| defaultFunc.reset(); | ||
| } else { | ||
| hasOnePassingSelector = true; | ||
| } | ||
| var rules = this.rules ? utils.copyArray(this.rules) : null; | ||
| var ruleset = new Ruleset(selectors, rules, this.strictImports, this.visibilityInfo()); | ||
| var rule; | ||
| var subRule; | ||
| let rules = this.rules ? utils.copyArray(this.rules) : null; | ||
| const ruleset = new Ruleset(selectors, rules, this.strictImports, this.visibilityInfo()); | ||
| /** @type {Node} */ | ||
| let rule; | ||
| /** @type {Node} */ | ||
| let subRule; | ||
| ruleset.originalRuleset = this; | ||
@@ -100,31 +174,33 @@ ruleset.root = this.root; | ||
| ruleset.allowImports = this.allowImports; | ||
| if (this.debugInfo) { | ||
| ruleset.debugInfo = this.debugInfo; | ||
| } | ||
| if (!hasOnePassingSelector) { | ||
| rules.length = 0; | ||
| /** @type {Node[]} */ (rules).length = 0; | ||
| } | ||
| // push the current ruleset to the frames stack | ||
| const ctxFrames = context.frames; | ||
| // inherit a function registry from the frames stack when possible; | ||
| // otherwise from the global registry | ||
| ruleset.functionRegistry = (function (frames) { | ||
| var i = 0; | ||
| var n = frames.length; | ||
| var found; | ||
| for (; i !== n; ++i) { | ||
| found = frames[i].functionRegistry; | ||
| if (found) { | ||
| return found; | ||
| } | ||
| } | ||
| return function_registry_1.default; | ||
| }(context.frames)).inherit(); | ||
| // push the current ruleset to the frames stack | ||
| var ctxFrames = context.frames; | ||
| /** @type {FunctionRegistry | undefined} */ | ||
| let foundRegistry; | ||
| for (let fi = 0, fn = ctxFrames.length; fi !== fn; ++fi) { | ||
| foundRegistry = /** @type {RuleNode} */ (ctxFrames[fi]).functionRegistry; | ||
| if (foundRegistry) { break; } | ||
| } | ||
| ruleset.functionRegistry = (foundRegistry || globalFunctionRegistry).inherit(); | ||
| ctxFrames.unshift(ruleset); | ||
| // currrent selectors | ||
| var ctxSelectors = context.selectors; | ||
| /** @type {Selector[][] | undefined} */ | ||
| let ctxSelectors = /** @type {EvalContext & { selectors?: Selector[][] }} */ (context).selectors; | ||
| if (!ctxSelectors) { | ||
| context.selectors = ctxSelectors = []; | ||
| /** @type {EvalContext & { selectors?: Selector[][] }} */ (context).selectors = ctxSelectors = []; | ||
| } | ||
| ctxSelectors.unshift(this.selectors); | ||
| // Evaluate imports | ||
@@ -134,11 +210,14 @@ if (ruleset.root || ruleset.allowImports || !ruleset.strictImports) { | ||
| } | ||
| // Store the frames around mixin definitions, | ||
| // so they can be evaluated like closures when the time comes. | ||
| var rsRules = ruleset.rules; | ||
| const rsRules = /** @type {Node[]} */ (ruleset.rules); | ||
| for (i = 0; (rule = rsRules[i]); i++) { | ||
| if (rule.evalFirst) { | ||
| if (/** @type {RuleNode} */ (rule).evalFirst) { | ||
| rsRules[i] = rule.eval(context); | ||
| } | ||
| } | ||
| var mediaBlockCount = (context.mediaBlocks && context.mediaBlocks.length) || 0; | ||
| const mediaBlockCount = (context.mediaBlocks && context.mediaBlocks.length) || 0; | ||
| // Evaluate mixin calls. | ||
@@ -148,19 +227,18 @@ for (i = 0; (rule = rsRules[i]); i++) { | ||
| /* jshint loopfunc:true */ | ||
| rules = rule.eval(context).filter(function (r) { | ||
| if ((r instanceof declaration_1.default) && r.variable) { | ||
| rules = /** @type {Node[]} */ (/** @type {unknown} */ (rule.eval(context))).filter(function(/** @type {Node & { variable?: boolean }} */ r) { | ||
| if ((r instanceof Declaration) && r.variable) { | ||
| // do not pollute the scope if the variable is | ||
| // already there. consider returning false here | ||
| // but we need a way to "return" variable from mixins | ||
| return !(ruleset.variable(r.name)); | ||
| return !(ruleset.variable(/** @type {string} */ (r.name))); | ||
| } | ||
| return true; | ||
| }); | ||
| rsRules.splice.apply(rsRules, [i, 1].concat(rules)); | ||
| rsRules.splice.apply(rsRules, /** @type {[number, number, ...Node[]]} */ ([i, 1].concat(rules))); | ||
| i += rules.length - 1; | ||
| ruleset.resetCache(); | ||
| } | ||
| else if (rule.type === 'VariableCall') { | ||
| } else if (rule.type === 'VariableCall') { | ||
| /* jshint loopfunc:true */ | ||
| rules = rule.eval(context).rules.filter(function (r) { | ||
| if ((r instanceof declaration_1.default) && r.variable) { | ||
| rules = /** @type {Node[]} */ (/** @type {RuleNode} */ (rule.eval(context)).rules).filter(function(/** @type {Node & { variable?: boolean }} */ r) { | ||
| if ((r instanceof Declaration) && r.variable) { | ||
| // do not pollute the scope at all | ||
@@ -171,3 +249,3 @@ return false; | ||
| }); | ||
| rsRules.splice.apply(rsRules, [i, 1].concat(rules)); | ||
| rsRules.splice.apply(rsRules, /** @type {[number, number, ...Node[]]} */ ([i, 1].concat(rules))); | ||
| i += rules.length - 1; | ||
@@ -177,8 +255,10 @@ ruleset.resetCache(); | ||
| } | ||
| // Evaluate everything else | ||
| for (i = 0; (rule = rsRules[i]); i++) { | ||
| if (!rule.evalFirst) { | ||
| if (!/** @type {RuleNode} */ (rule).evalFirst) { | ||
| rsRules[i] = rule = rule.eval ? rule.eval(context) : rule; | ||
| } | ||
| } | ||
| // Evaluate everything else | ||
@@ -191,6 +271,7 @@ for (i = 0; (rule = rsRules[i]); i++) { | ||
| rsRules.splice(i--, 1); | ||
| for (var j = 0; (subRule = rule.rules[j]); j++) { | ||
| if (subRule instanceof node_1.default) { | ||
| for (let j = 0; (subRule = rule.rules[j]); j++) { | ||
| if (subRule instanceof Node) { | ||
| subRule.copyVisibilityInfo(rule.visibilityInfo()); | ||
| if (!(subRule instanceof declaration_1.default) || !subRule.variable) { | ||
| if (!(subRule instanceof Declaration) || !subRule.variable) { | ||
| rsRules.splice(++i, 0, subRule); | ||
@@ -203,27 +284,33 @@ } | ||
| } | ||
| // Pop the stack | ||
| ctxFrames.shift(); | ||
| ctxSelectors.shift(); | ||
| if (context.mediaBlocks) { | ||
| for (i = mediaBlockCount; i < context.mediaBlocks.length; i++) { | ||
| context.mediaBlocks[i].bubbleSelectors(selectors); | ||
| /** @type {RuleNode} */ (context.mediaBlocks[i]).bubbleSelectors(selectors); | ||
| } | ||
| } | ||
| return ruleset; | ||
| }, | ||
| evalImports: function (context) { | ||
| var rules = this.rules; | ||
| var i; | ||
| var importRules; | ||
| if (!rules) { | ||
| return; | ||
| } | ||
| } | ||
| /** @param {EvalContext} context */ | ||
| evalImports(context) { | ||
| const rules = this.rules; | ||
| /** @type {number} */ | ||
| let i; | ||
| /** @type {Node | Node[]} */ | ||
| let importRules; | ||
| if (!rules) { return; } | ||
| for (i = 0; i < rules.length; i++) { | ||
| if (rules[i].type === 'Import') { | ||
| importRules = rules[i].eval(context); | ||
| if (importRules && (importRules.length || importRules.length === 0)) { | ||
| rules.splice.apply(rules, [i, 1].concat(importRules)); | ||
| i += importRules.length - 1; | ||
| } | ||
| else { | ||
| if (importRules && (/** @type {Node[]} */ (/** @type {unknown} */ (importRules)).length || /** @type {Node[]} */ (/** @type {unknown} */ (importRules)).length === 0)) { | ||
| const importArr = /** @type {Node[]} */ (/** @type {unknown} */ (importRules)); | ||
| rules.splice(i, 1, ...importArr); | ||
| i += importArr.length - 1; | ||
| } else { | ||
| rules.splice(i, 1, importRules); | ||
@@ -234,20 +321,27 @@ } | ||
| } | ||
| }, | ||
| makeImportant: function () { | ||
| var result = new Ruleset(this.selectors, this.rules.map(function (r) { | ||
| } | ||
| makeImportant() { | ||
| const result = new Ruleset(this.selectors, /** @type {Node[]} */ (this.rules).map(function (/** @type {Node & { makeImportant?: () => Node }} */ r) { | ||
| if (r.makeImportant) { | ||
| return r.makeImportant(); | ||
| } | ||
| else { | ||
| } else { | ||
| return r; | ||
| } | ||
| }), this.strictImports, this.visibilityInfo()); | ||
| return result; | ||
| }, | ||
| matchArgs: function (args) { | ||
| } | ||
| /** @param {Node[] | object[] | null} [args] */ | ||
| matchArgs(args) { | ||
| return !args || args.length === 0; | ||
| }, | ||
| // lets you call a css selector with a guard | ||
| matchCondition: function (args, context) { | ||
| var lastSelector = this.selectors[this.selectors.length - 1]; | ||
| } | ||
| /** | ||
| * @param {Node[] | object[] | null} args | ||
| * @param {EvalContext} context | ||
| */ | ||
| matchCondition(args, context) { | ||
| const lastSelector = /** @type {Selector[]} */ (this.selectors)[/** @type {Selector[]} */ (this.selectors).length - 1]; | ||
| if (!lastSelector.evaldCondition) { | ||
@@ -257,8 +351,11 @@ return false; | ||
| if (lastSelector.condition && | ||
| !lastSelector.condition.eval(new contexts_1.default.Eval(context, context.frames))) { | ||
| !lastSelector.condition.eval( | ||
| new contexts.Eval(context, | ||
| context.frames))) { | ||
| return false; | ||
| } | ||
| return true; | ||
| }, | ||
| resetCache: function () { | ||
| } | ||
| resetCache() { | ||
| this._rulesets = null; | ||
@@ -268,8 +365,9 @@ this._variables = null; | ||
| this._lookups = {}; | ||
| }, | ||
| variables: function () { | ||
| } | ||
| variables() { | ||
| if (!this._variables) { | ||
| this._variables = !this.rules ? {} : this.rules.reduce(function (hash, r) { | ||
| if (r instanceof declaration_1.default && r.variable === true) { | ||
| hash[r.name] = r; | ||
| this._variables = !this.rules ? {} : this.rules.reduce(function (/** @type {Object<string, Declaration>} */ hash, /** @type {Node} */ r) { | ||
| if (r instanceof Declaration && r.variable === true) { | ||
| hash[/** @type {string} */ (r.name)] = r; | ||
| } | ||
@@ -279,8 +377,7 @@ // when evaluating variables in an import statement, imports have not been eval'd | ||
| // guard against root being a string (in the case of inlined less) | ||
| if (r.type === 'Import' && r.root && r.root.variables) { | ||
| var vars = r.root.variables(); | ||
| for (var name_1 in vars) { | ||
| // eslint-disable-next-line no-prototype-builtins | ||
| if (vars.hasOwnProperty(name_1)) { | ||
| hash[name_1] = r.root.variable(name_1); | ||
| if (r.type === 'Import' && /** @type {RuleNode} */ (r).root && /** @type {RuleNode & { root: Ruleset }} */ (r).root.variables) { | ||
| const vars = /** @type {RuleNode & { root: Ruleset }} */ (r).root.variables(); | ||
| for (const name in vars) { | ||
| if (Object.prototype.hasOwnProperty.call(vars, name)) { | ||
| hash[name] = /** @type {Declaration} */ (/** @type {RuleNode & { root: Ruleset }} */ (r).root.variable(name)); | ||
| } | ||
@@ -293,15 +390,16 @@ } | ||
| return this._variables; | ||
| }, | ||
| properties: function () { | ||
| } | ||
| properties() { | ||
| if (!this._properties) { | ||
| this._properties = !this.rules ? {} : this.rules.reduce(function (hash, r) { | ||
| if (r instanceof declaration_1.default && r.variable !== true) { | ||
| var name_2 = (r.name.length === 1) && (r.name[0] instanceof keyword_1.default) ? | ||
| r.name[0].value : r.name; | ||
| this._properties = !this.rules ? {} : this.rules.reduce(function (/** @type {Object<string, Declaration[]>} */ hash, /** @type {Node} */ r) { | ||
| if (r instanceof Declaration && r.variable !== true) { | ||
| const name = (/** @type {Node[]} */ (r.name).length === 1) && (/** @type {Node[]} */ (r.name)[0] instanceof Keyword) ? | ||
| /** @type {string} */ (/** @type {Node[]} */ (r.name)[0].value) : /** @type {string} */ (r.name); | ||
| // Properties don't overwrite as they can merge | ||
| if (!hash["$".concat(name_2)]) { | ||
| hash["$".concat(name_2)] = [r]; | ||
| if (!hash[`$${name}`]) { | ||
| hash[`$${name}`] = [ r ]; | ||
| } | ||
| else { | ||
| hash["$".concat(name_2)].push(r); | ||
| hash[`$${name}`].push(r); | ||
| } | ||
@@ -313,42 +411,53 @@ } | ||
| return this._properties; | ||
| }, | ||
| variable: function (name) { | ||
| var decl = this.variables()[name]; | ||
| } | ||
| /** @param {string} name */ | ||
| variable(name) { | ||
| const decl = this.variables()[name]; | ||
| if (decl) { | ||
| return this.parseValue(decl); | ||
| } | ||
| }, | ||
| property: function (name) { | ||
| var decl = this.properties()[name]; | ||
| } | ||
| /** @param {string} name */ | ||
| property(name) { | ||
| const decl = this.properties()[name]; | ||
| if (decl) { | ||
| return this.parseValue(decl); | ||
| } | ||
| }, | ||
| lastDeclaration: function () { | ||
| for (var i = this.rules.length; i > 0; i--) { | ||
| var decl = this.rules[i - 1]; | ||
| if (decl instanceof declaration_1.default) { | ||
| } | ||
| lastDeclaration() { | ||
| for (let i = /** @type {Node[]} */ (this.rules).length; i > 0; i--) { | ||
| const decl = /** @type {Node[]} */ (this.rules)[i - 1]; | ||
| if (decl instanceof Declaration) { | ||
| return this.parseValue(decl); | ||
| } | ||
| } | ||
| }, | ||
| parseValue: function (toParse) { | ||
| var self = this; | ||
| } | ||
| /** @param {Declaration | Declaration[]} toParse */ | ||
| parseValue(toParse) { | ||
| const self = this; | ||
| /** @param {Declaration} decl */ | ||
| function transformDeclaration(decl) { | ||
| if (decl.value instanceof anonymous_1.default && !decl.parsed) { | ||
| if (decl.value instanceof Anonymous && !/** @type {Declaration & { parsed?: boolean }} */ (decl).parsed) { | ||
| if (typeof decl.value.value === 'string') { | ||
| new parser_1.default(this.parse.context, this.parse.importManager, decl.fileInfo(), decl.value.getIndex()).parseNode(decl.value.value, ['value', 'important'], function (err, result) { | ||
| if (err) { | ||
| decl.parsed = true; | ||
| } | ||
| if (result) { | ||
| decl.value = result[0]; | ||
| decl.important = result[1] || ''; | ||
| decl.parsed = true; | ||
| } | ||
| }); | ||
| new (/** @type {new (...args: [EvalContext, object, FileInfo, number]) => { parseNode: Function }} */ (/** @type {unknown} */ (Parser)))(/** @type {{ context: EvalContext, importManager: object }} */ (/** @type {Ruleset} */ (this).parse).context, /** @type {{ context: EvalContext, importManager: object }} */ (/** @type {Ruleset} */ (this).parse).importManager, decl.fileInfo(), decl.value.getIndex()).parseNode( | ||
| decl.value.value, | ||
| ['value', 'important'], | ||
| function(/** @type {Error | null} */ err, /** @type {Node[]} */ result) { | ||
| if (err) { | ||
| decl.parsed = /** @type {Node} */ (/** @type {unknown} */ (true)); | ||
| } | ||
| if (result) { | ||
| decl.value = result[0]; | ||
| /** @type {Declaration & { important?: string }} */ (decl).important = /** @type {string} */ (/** @type {unknown} */ (result[1])) || ''; | ||
| decl.parsed = /** @type {Node} */ (/** @type {unknown} */ (true)); | ||
| } | ||
| }); | ||
| } else { | ||
| decl.parsed = /** @type {Node} */ (/** @type {unknown} */ (true)); | ||
| } | ||
| else { | ||
| decl.parsed = true; | ||
| } | ||
| return decl; | ||
@@ -364,52 +473,69 @@ } | ||
| else { | ||
| var nodes_1 = []; | ||
| toParse.forEach(function (n) { | ||
| nodes_1.push(transformDeclaration.call(self, n)); | ||
| }); | ||
| return nodes_1; | ||
| /** @type {Declaration[]} */ | ||
| const nodes = []; | ||
| for (let ti = 0; ti < toParse.length; ti++) { | ||
| nodes.push(transformDeclaration.call(self, toParse[ti])); | ||
| } | ||
| return nodes; | ||
| } | ||
| }, | ||
| rulesets: function () { | ||
| if (!this.rules) { | ||
| return []; | ||
| } | ||
| var filtRules = []; | ||
| var rules = this.rules; | ||
| var i; | ||
| var rule; | ||
| } | ||
| rulesets() { | ||
| if (!this.rules) { return []; } | ||
| /** @type {Node[]} */ | ||
| const filtRules = []; | ||
| const rules = this.rules; | ||
| /** @type {number} */ | ||
| let i; | ||
| /** @type {Node} */ | ||
| let rule; | ||
| for (i = 0; (rule = rules[i]); i++) { | ||
| if (rule.isRuleset) { | ||
| if (/** @type {RuleNode} */ (rule).isRuleset) { | ||
| filtRules.push(rule); | ||
| } | ||
| } | ||
| return filtRules; | ||
| }, | ||
| prependRule: function (rule) { | ||
| var rules = this.rules; | ||
| } | ||
| /** @param {Node} rule */ | ||
| prependRule(rule) { | ||
| const rules = this.rules; | ||
| if (rules) { | ||
| rules.unshift(rule); | ||
| } else { | ||
| this.rules = [ rule ]; | ||
| } | ||
| else { | ||
| this.rules = [rule]; | ||
| } | ||
| this.setParent(rule, this); | ||
| }, | ||
| find: function (selector, self, filter) { | ||
| } | ||
| /** | ||
| * @param {Selector} selector | ||
| * @param {Ruleset | null} [self] | ||
| * @param {((rule: Node) => boolean)} [filter] | ||
| * @returns {{ rule: Node, path: Node[] }[]} | ||
| */ | ||
| find(selector, self, filter) { | ||
| self = self || this; | ||
| var rules = []; | ||
| var match; | ||
| var foundMixins; | ||
| var key = selector.toCSS(); | ||
| if (key in this._lookups) { | ||
| return this._lookups[key]; | ||
| } | ||
| /** @type {{ rule: Node, path: Node[] }[]} */ | ||
| const rules = []; | ||
| /** @type {number | undefined} */ | ||
| let match; | ||
| /** @type {{ rule: Node, path: Node[] }[]} */ | ||
| let foundMixins; | ||
| const key = selector.toCSS(/** @type {EvalContext} */ ({})); | ||
| if (key in this._lookups) { return /** @type {{ rule: Node, path: Node[] }[]} */ (this._lookups[key]); } | ||
| this.rulesets().forEach(function (rule) { | ||
| if (rule !== self) { | ||
| for (var j = 0; j < rule.selectors.length; j++) { | ||
| match = selector.match(rule.selectors[j]); | ||
| for (let j = 0; j < /** @type {RuleNode} */ (rule).selectors.length; j++) { | ||
| match = selector.match(/** @type {RuleNode} */ (rule).selectors[j]); | ||
| if (match) { | ||
| if (selector.elements.length > match) { | ||
| if (!filter || filter(rule)) { | ||
| foundMixins = rule.find(new selector_1.default(selector.elements.slice(match)), self, filter); | ||
| for (var i = 0; i < foundMixins.length; ++i) { | ||
| foundMixins = /** @type {Ruleset} */ (/** @type {unknown} */ (rule)).find(new Selector(selector.elements.slice(match)), self, filter); | ||
| for (let i = 0; i < foundMixins.length; ++i) { | ||
| foundMixins[i].path.push(rule); | ||
@@ -419,6 +545,5 @@ } | ||
| } | ||
| } else { | ||
| rules.push({ rule, path: []}); | ||
| } | ||
| else { | ||
| rules.push({ rule: rule, path: [] }); | ||
| } | ||
| break; | ||
@@ -431,23 +556,41 @@ } | ||
| return rules; | ||
| }, | ||
| genCSS: function (context, output) { | ||
| var i; | ||
| var j; | ||
| var charsetRuleNodes = []; | ||
| var ruleNodes = []; | ||
| var // Line number debugging | ||
| debugInfo; | ||
| var rule; | ||
| var path; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| /** @type {number} */ | ||
| let i; | ||
| /** @type {number} */ | ||
| let j; | ||
| /** @type {Node[]} */ | ||
| const charsetRuleNodes = []; | ||
| /** @type {Node[]} */ | ||
| let ruleNodes = []; | ||
| let // Line number debugging | ||
| debugInfo; | ||
| /** @type {Node} */ | ||
| let rule; | ||
| /** @type {Selector[]} */ | ||
| let path; | ||
| context.tabLevel = (context.tabLevel || 0); | ||
| if (!this.root) { | ||
| context.tabLevel++; | ||
| } | ||
| var tabRuleStr = context.compress ? '' : Array(context.tabLevel + 1).join(' '); | ||
| var tabSetStr = context.compress ? '' : Array(context.tabLevel).join(' '); | ||
| var sep; | ||
| var charsetNodeIndex = 0; | ||
| var importNodeIndex = 0; | ||
| for (i = 0; (rule = this.rules[i]); i++) { | ||
| if (rule instanceof comment_1.default) { | ||
| const tabRuleStr = context.compress ? '' : Array(context.tabLevel + 1).join(' '); | ||
| const tabSetStr = context.compress ? '' : Array(context.tabLevel).join(' '); | ||
| /** @type {string} */ | ||
| let sep; | ||
| let charsetNodeIndex = 0; | ||
| let importNodeIndex = 0; | ||
| for (i = 0; (rule = /** @type {Node[]} */ (this.rules)[i]); i++) { | ||
| if (rule instanceof Comment) { | ||
| if (importNodeIndex === i) { | ||
@@ -457,13 +600,10 @@ importNodeIndex++; | ||
| ruleNodes.push(rule); | ||
| } | ||
| else if (rule.isCharset && rule.isCharset()) { | ||
| } else if (/** @type {RuleNode} */ (rule).isCharset && /** @type {RuleNode} */ (rule).isCharset()) { | ||
| ruleNodes.splice(charsetNodeIndex, 0, rule); | ||
| charsetNodeIndex++; | ||
| importNodeIndex++; | ||
| } | ||
| else if (rule.type === 'Import') { | ||
| } else if (rule.type === 'Import') { | ||
| ruleNodes.splice(importNodeIndex, 0, rule); | ||
| importNodeIndex++; | ||
| } | ||
| else { | ||
| } else { | ||
| ruleNodes.push(rule); | ||
@@ -473,6 +613,8 @@ } | ||
| ruleNodes = charsetRuleNodes.concat(ruleNodes); | ||
| // If this is the root node, we don't render | ||
| // a selector, or {}. | ||
| if (!this.root) { | ||
| debugInfo = (0, debug_info_1.default)(context, this, tabSetStr); | ||
| debugInfo = getDebugInfo(context, /** @type {{ debugInfo: { lineNumber: number, fileName: string } }} */ (/** @type {unknown} */ (this)), tabSetStr); | ||
| if (debugInfo) { | ||
@@ -482,17 +624,19 @@ output.add(debugInfo); | ||
| } | ||
| var paths = this.paths; | ||
| var pathCnt = paths.length; | ||
| var pathSubCnt = void 0; | ||
| sep = context.compress ? ',' : (",\n".concat(tabSetStr)); | ||
| const paths = /** @type {Selector[][]} */ (this.paths); | ||
| const pathCnt = paths.length; | ||
| /** @type {number} */ | ||
| let pathSubCnt; | ||
| sep = context.compress ? ',' : (`,\n${tabSetStr}`); | ||
| for (i = 0; i < pathCnt; i++) { | ||
| path = paths[i]; | ||
| if (!(pathSubCnt = path.length)) { | ||
| continue; | ||
| } | ||
| if (i > 0) { | ||
| output.add(sep); | ||
| } | ||
| context.firstSelector = true; | ||
| if (!(pathSubCnt = path.length)) { continue; } | ||
| if (i > 0) { output.add(sep); } | ||
| /** @type {EvalContext & { firstSelector?: boolean }} */ (context).firstSelector = true; | ||
| path[0].genCSS(context, output); | ||
| context.firstSelector = false; | ||
| /** @type {EvalContext & { firstSelector?: boolean }} */ (context).firstSelector = false; | ||
| for (j = 1; j < pathSubCnt; j++) { | ||
@@ -502,68 +646,121 @@ path[j].genCSS(context, output); | ||
| } | ||
| output.add((context.compress ? '{' : ' {\n') + tabRuleStr); | ||
| } | ||
| // Compile rules and rulesets | ||
| for (i = 0; (rule = ruleNodes[i]); i++) { | ||
| if (i + 1 === ruleNodes.length) { | ||
| context.lastRule = true; | ||
| } | ||
| var currentLastRule = context.lastRule; | ||
| if (rule.isRulesetLike(rule)) { | ||
| const currentLastRule = context.lastRule; | ||
| if (rule.isRulesetLike()) { | ||
| context.lastRule = false; | ||
| } | ||
| if (rule.genCSS) { | ||
| rule.genCSS(context, output); | ||
| } else if (rule.value) { | ||
| output.add(/** @type {string} */ (rule.value).toString()); | ||
| } | ||
| else if (rule.value) { | ||
| output.add(rule.value.toString()); | ||
| } | ||
| context.lastRule = currentLastRule; | ||
| if (!context.lastRule && rule.isVisible()) { | ||
| output.add(context.compress ? '' : ("\n".concat(tabRuleStr))); | ||
| } | ||
| else { | ||
| output.add(context.compress ? '' : (`\n${tabRuleStr}`)); | ||
| } else { | ||
| context.lastRule = false; | ||
| } | ||
| } | ||
| if (!this.root) { | ||
| output.add((context.compress ? '}' : "\n".concat(tabSetStr, "}"))); | ||
| output.add((context.compress ? '}' : `\n${tabSetStr}}`)); | ||
| context.tabLevel--; | ||
| } | ||
| if (!output.isEmpty() && !context.compress && this.firstRoot) { | ||
| output.add('\n'); | ||
| } | ||
| }, | ||
| joinSelectors: function (paths, context, selectors) { | ||
| for (var s = 0; s < selectors.length; s++) { | ||
| } | ||
| /** | ||
| * @param {Selector[][]} paths | ||
| * @param {Selector[][]} context | ||
| * @param {Selector[]} selectors | ||
| */ | ||
| joinSelectors(paths, context, selectors) { | ||
| for (let s = 0; s < selectors.length; s++) { | ||
| this.joinSelector(paths, context, selectors[s]); | ||
| } | ||
| }, | ||
| joinSelector: function (paths, context, selector) { | ||
| } | ||
| /** | ||
| * @param {Selector[][]} paths | ||
| * @param {Selector[][]} context | ||
| * @param {Selector} selector | ||
| */ | ||
| joinSelector(paths, context, selector) { | ||
| /** | ||
| * @param {Selector[]} elementsToPak | ||
| * @param {Element} originalElement | ||
| * @returns {Paren} | ||
| */ | ||
| function createParenthesis(elementsToPak, originalElement) { | ||
| var replacementParen, j; | ||
| /** @type {Paren} */ | ||
| let replacementParen; | ||
| /** @type {number} */ | ||
| let j; | ||
| if (elementsToPak.length === 0) { | ||
| replacementParen = new paren_1.default(elementsToPak[0]); | ||
| } | ||
| else { | ||
| var insideParent = new Array(elementsToPak.length); | ||
| replacementParen = new Paren(elementsToPak[0]); | ||
| } else { | ||
| const insideParent = new Array(elementsToPak.length); | ||
| for (j = 0; j < elementsToPak.length; j++) { | ||
| insideParent[j] = new element_1.default(null, elementsToPak[j], originalElement.isVariable, originalElement._index, originalElement._fileInfo); | ||
| insideParent[j] = new Element( | ||
| null, | ||
| elementsToPak[j], | ||
| originalElement.isVariable, | ||
| originalElement._index, | ||
| originalElement._fileInfo | ||
| ); | ||
| } | ||
| replacementParen = new paren_1.default(new selector_1.default(insideParent)); | ||
| replacementParen = new Paren(new Selector(insideParent)); | ||
| } | ||
| return replacementParen; | ||
| } | ||
| /** | ||
| * @param {Paren | Selector} containedElement | ||
| * @param {Element} originalElement | ||
| * @returns {Selector} | ||
| */ | ||
| function createSelector(containedElement, originalElement) { | ||
| var element, selector; | ||
| element = new element_1.default(null, containedElement, originalElement.isVariable, originalElement._index, originalElement._fileInfo); | ||
| selector = new selector_1.default([element]); | ||
| /** @type {Element} */ | ||
| let element; | ||
| /** @type {Selector} */ | ||
| let selector; | ||
| element = new Element(null, containedElement, originalElement.isVariable, originalElement._index, originalElement._fileInfo); | ||
| selector = new Selector([element]); | ||
| return selector; | ||
| } | ||
| // joins selector path from `beginningPath` with selector path in `addPath` | ||
| // `replacedElement` contains element that is being replaced by `addPath` | ||
| // returns concatenated path | ||
| /** | ||
| * @param {Selector[]} beginningPath | ||
| * @param {Selector[]} addPath | ||
| * @param {Element} replacedElement | ||
| * @param {Selector} originalSelector | ||
| * @returns {Selector[]} | ||
| */ | ||
| function addReplacementIntoPath(beginningPath, addPath, replacedElement, originalSelector) { | ||
| var newSelectorPath, lastSelector, newJoinedSelector; | ||
| /** @type {Selector[]} */ | ||
| let newSelectorPath; | ||
| /** @type {Selector} */ | ||
| let lastSelector; | ||
| /** @type {Selector} */ | ||
| let newJoinedSelector; | ||
| // our new selector path | ||
| newSelectorPath = []; | ||
| // construct the joined selector - if & is the first thing this will be empty, | ||
@@ -579,2 +776,3 @@ // if not newJoinedSelector will be the last set of elements in the selector | ||
| } | ||
| if (addPath.length > 0) { | ||
@@ -586,4 +784,5 @@ // /deep/ is a CSS4 selector - (removed, so should deprecate) | ||
| // this also allows + a { & .b { .a & { ... though not sure why you would want to do that | ||
| var combinator = replacedElement.combinator; | ||
| var parentEl = addPath[0].elements[0]; | ||
| let combinator = replacedElement.combinator; | ||
| const parentEl = addPath[0].elements[0]; | ||
| if (combinator.emptyOrWhitespace && !parentEl.combinator.emptyOrWhitespace) { | ||
@@ -593,5 +792,12 @@ combinator = parentEl.combinator; | ||
| // join the elements so far with the first part of the parent | ||
| newJoinedSelector.elements.push(new element_1.default(combinator, parentEl.value, replacedElement.isVariable, replacedElement._index, replacedElement._fileInfo)); | ||
| newJoinedSelector.elements.push(new Element( | ||
| combinator, | ||
| parentEl.value, | ||
| replacedElement.isVariable, | ||
| replacedElement._index, | ||
| replacedElement._fileInfo | ||
| )); | ||
| newJoinedSelector.elements = newJoinedSelector.elements.concat(addPath[0].elements.slice(1)); | ||
| } | ||
| // now add the joined selector - but only if it is not empty | ||
@@ -601,6 +807,7 @@ if (newJoinedSelector.elements.length !== 0) { | ||
| } | ||
| // put together the parent selectors after the join (e.g. the rest of the parent) | ||
| if (addPath.length > 1) { | ||
| var restOfPath = addPath.slice(1); | ||
| restOfPath = restOfPath.map(function (selector) { | ||
| let restOfPath = addPath.slice(1); | ||
| restOfPath = restOfPath.map(function (/** @type {Selector} */ selector) { | ||
| return selector.createDerived(selector.elements, []); | ||
@@ -612,9 +819,16 @@ }); | ||
| } | ||
| // joins selector path from `beginningPath` with every selector path in `addPaths` array | ||
| // `replacedElement` contains element that is being replaced by `addPath` | ||
| // returns array with all concatenated paths | ||
| function addAllReplacementsIntoPath(beginningPath, addPaths, replacedElement, originalSelector, result) { | ||
| var j; | ||
| /** | ||
| * @param {Selector[][]} beginningPath | ||
| * @param {Selector[]} addPaths | ||
| * @param {Element} replacedElement | ||
| * @param {Selector} originalSelector | ||
| * @param {Selector[][]} result | ||
| * @returns {Selector[][]} | ||
| */ | ||
| function addAllReplacementsIntoPath( beginningPath, addPaths, replacedElement, originalSelector, result) { | ||
| /** @type {number} */ | ||
| let j; | ||
| for (j = 0; j < beginningPath.length; j++) { | ||
| var newSelectorPath = addReplacementIntoPath(beginningPath[j], addPaths, replacedElement, originalSelector); | ||
| const newSelectorPath = addReplacementIntoPath(beginningPath[j], addPaths, replacedElement, originalSelector); | ||
| result.push(newSelectorPath); | ||
@@ -624,11 +838,21 @@ } | ||
| } | ||
| /** | ||
| * @param {Element[]} elements | ||
| * @param {Selector[][]} selectors | ||
| */ | ||
| function mergeElementsOnToSelectors(elements, selectors) { | ||
| var i, sel; | ||
| /** @type {number} */ | ||
| let i; | ||
| /** @type {Selector[]} */ | ||
| let sel; | ||
| if (elements.length === 0) { | ||
| return; | ||
| return ; | ||
| } | ||
| if (selectors.length === 0) { | ||
| selectors.push([new selector_1.default(elements)]); | ||
| selectors.push([ new Selector(elements) ]); | ||
| return; | ||
| } | ||
| for (i = 0; (sel = selectors[i]); i++) { | ||
@@ -640,9 +864,13 @@ // if the previous thing in sel is a parent this needs to join on to it | ||
| else { | ||
| sel.push(new selector_1.default(elements)); | ||
| sel.push(new Selector(elements)); | ||
| } | ||
| } | ||
| } | ||
| // replace all parent selectors inside `inSelector` by content of `context` array | ||
| // resulting selectors are returned inside `paths` array | ||
| // returns true if `inSelector` contained at least one parent selector | ||
| /** | ||
| * @param {Selector[][]} paths | ||
| * @param {Selector[][]} context | ||
| * @param {Selector} inSelector | ||
| * @returns {boolean} | ||
| */ | ||
| function replaceParentSelector(paths, context, inSelector) { | ||
@@ -659,14 +887,43 @@ // The paths are [[Selector]] | ||
| // | ||
| var i, j, k, currentElements, newSelectors, selectorsMultiplied, sel, el, hadParentSelector = false, length, lastSelector; | ||
| /** @type {number} */ | ||
| let i; | ||
| /** @type {number} */ | ||
| let j; | ||
| /** @type {number} */ | ||
| let k; | ||
| /** @type {Element[]} */ | ||
| let currentElements; | ||
| /** @type {Selector[][]} */ | ||
| let newSelectors; | ||
| /** @type {Selector[][]} */ | ||
| let selectorsMultiplied; | ||
| /** @type {Selector[]} */ | ||
| let sel; | ||
| /** @type {Element} */ | ||
| let el; | ||
| let hadParentSelector = false; | ||
| /** @type {number} */ | ||
| let length; | ||
| /** @type {Selector} */ | ||
| let lastSelector; | ||
| /** | ||
| * @param {Element} element | ||
| * @returns {Selector | null} | ||
| */ | ||
| function findNestedSelector(element) { | ||
| var maybeSelector; | ||
| if (!(element.value instanceof paren_1.default)) { | ||
| /** @type {Node} */ | ||
| let maybeSelector; | ||
| if (!(element.value instanceof Paren)) { | ||
| return null; | ||
| } | ||
| maybeSelector = element.value.value; | ||
| if (!(maybeSelector instanceof selector_1.default)) { | ||
| maybeSelector = /** @type {Node} */ (element.value.value); | ||
| if (!(maybeSelector instanceof Selector)) { | ||
| return null; | ||
| } | ||
| return maybeSelector; | ||
| } | ||
| // the elements from the current selector so far | ||
@@ -680,6 +937,7 @@ currentElements = []; | ||
| ]; | ||
| for (i = 0; (el = inSelector.elements[i]); i++) { | ||
| // non parent reference elements just get added | ||
| if (el.value !== '&') { | ||
| var nestedSelector = findNestedSelector(el); | ||
| const nestedSelector = findNestedSelector(el); | ||
| if (nestedSelector !== null) { | ||
@@ -689,26 +947,61 @@ // merge the current list of non parent selector elements | ||
| mergeElementsOnToSelectors(currentElements, newSelectors); | ||
| var nestedPaths = []; | ||
| var replaced = void 0; | ||
| var replacedNewSelectors = []; | ||
| replaced = replaceParentSelector(nestedPaths, context, nestedSelector); | ||
| hadParentSelector = hadParentSelector || replaced; | ||
| // the nestedPaths array should have only one member - replaceParentSelector does not multiply selectors | ||
| for (k = 0; k < nestedPaths.length; k++) { | ||
| var replacementSelector = createSelector(createParenthesis(nestedPaths[k], el), el); | ||
| /** @type {Selector[][]} */ | ||
| const nestedPaths = []; | ||
| /** @type {boolean | undefined} */ | ||
| let replaced; | ||
| /** @type {Selector[][]} */ | ||
| const replacedNewSelectors = []; | ||
| // Check if this is a comma-separated selector list inside the paren | ||
| // e.g. :not(&.a, &.b) produces Selector([Selector, Anonymous(','), Selector]) | ||
| const hasSubSelectors = nestedSelector.elements.some(e => e instanceof Selector); | ||
| if (hasSubSelectors) { | ||
| // Process each sub-selector individually | ||
| /** @type {(Element | Selector)[]} */ | ||
| const resolvedElements = []; | ||
| for (const subEl of nestedSelector.elements) { | ||
| if (subEl instanceof Selector) { | ||
| /** @type {Selector[][]} */ | ||
| const subPaths = []; | ||
| const subReplaced = replaceParentSelector(subPaths, context, subEl); | ||
| replaced = replaced || subReplaced; | ||
| if (subPaths.length > 0 && subPaths[0].length > 0) { | ||
| resolvedElements.push(subPaths[0][0]); | ||
| } else { | ||
| resolvedElements.push(subEl); | ||
| } | ||
| } else { | ||
| resolvedElements.push(subEl); | ||
| } | ||
| } | ||
| hadParentSelector = hadParentSelector || /** @type {boolean} */ (replaced); | ||
| const resolvedNestedSelector = new Selector(resolvedElements); | ||
| const replacementSelector = createSelector(createParenthesis([resolvedNestedSelector], el), el); | ||
| addAllReplacementsIntoPath(newSelectors, [replacementSelector], el, inSelector, replacedNewSelectors); | ||
| } else { | ||
| replaced = replaceParentSelector(nestedPaths, context, nestedSelector); | ||
| hadParentSelector = hadParentSelector || replaced; | ||
| // the nestedPaths array should have only one member - replaceParentSelector does not multiply selectors | ||
| for (k = 0; k < nestedPaths.length; k++) { | ||
| const replacementSelector = createSelector(createParenthesis(nestedPaths[k], el), el); | ||
| addAllReplacementsIntoPath(newSelectors, [replacementSelector], el, inSelector, replacedNewSelectors); | ||
| } | ||
| } | ||
| newSelectors = replacedNewSelectors; | ||
| currentElements = []; | ||
| } | ||
| else { | ||
| } else { | ||
| currentElements.push(el); | ||
| } | ||
| } | ||
| else { | ||
| } else { | ||
| hadParentSelector = true; | ||
| // the new list of selectors to add | ||
| selectorsMultiplied = []; | ||
| // merge the current list of non parent selector elements | ||
| // on to the current list of selectors to add | ||
| mergeElementsOnToSelectors(currentElements, newSelectors); | ||
| // loop through our current selectors | ||
@@ -723,3 +1016,3 @@ for (j = 0; j < newSelectors.length; j++) { | ||
| if (sel.length > 0) { | ||
| sel[0].elements.push(new element_1.default(el.combinator, '', el.isVariable, el._index, el._fileInfo)); | ||
| sel[0].elements.push(new Element(el.combinator, '', el.isVariable, el._index, el._fileInfo)); | ||
| } | ||
@@ -733,3 +1026,3 @@ selectorsMultiplied.push(sel); | ||
| // then join the last selector's elements on to the parents selectors | ||
| var newSelectorPath = addReplacementIntoPath(sel, context[k], el, inSelector); | ||
| const newSelectorPath = addReplacementIntoPath(sel, context[k], el, inSelector); | ||
| // add that to our new set of selectors | ||
@@ -740,2 +1033,3 @@ selectorsMultiplied.push(newSelectorPath); | ||
| } | ||
| // our new selectors has been multiplied, so reset the state | ||
@@ -746,5 +1040,7 @@ newSelectors = selectorsMultiplied; | ||
| } | ||
| // if we have any elements left over (e.g. .a& .b == .b) | ||
| // add them on to all the current selectors | ||
| mergeElementsOnToSelectors(currentElements, newSelectors); | ||
| for (i = 0; i < newSelectors.length; i++) { | ||
@@ -758,13 +1054,27 @@ length = newSelectors[i].length; | ||
| } | ||
| return hadParentSelector; | ||
| } | ||
| /** | ||
| * @param {VisibilityInfo} visibilityInfo | ||
| * @param {Selector} deriveFrom | ||
| */ | ||
| function deriveSelector(visibilityInfo, deriveFrom) { | ||
| var newSelector = deriveFrom.createDerived(deriveFrom.elements, deriveFrom.extendList, deriveFrom.evaldCondition); | ||
| const newSelector = deriveFrom.createDerived(deriveFrom.elements, deriveFrom.extendList, deriveFrom.evaldCondition); | ||
| newSelector.copyVisibilityInfo(visibilityInfo); | ||
| return newSelector; | ||
| } | ||
| // joinSelector code follows | ||
| var i, newPaths, hadParentSelector; | ||
| /** @type {number} */ | ||
| let i; | ||
| /** @type {Selector[][]} */ | ||
| let newPaths; | ||
| /** @type {boolean} */ | ||
| let hadParentSelector; | ||
| newPaths = []; | ||
| hadParentSelector = replaceParentSelector(newPaths, context, selector); | ||
| if (!hadParentSelector) { | ||
@@ -774,3 +1084,5 @@ if (context.length > 0) { | ||
| for (i = 0; i < context.length; i++) { | ||
| var concatenated = context[i].map(deriveSelector.bind(this, selector.visibilityInfo())); | ||
| const concatenated = context[i].map(deriveSelector.bind(this, selector.visibilityInfo())); | ||
| concatenated.push(selector); | ||
@@ -784,8 +1096,10 @@ newPaths.push(concatenated); | ||
| } | ||
| for (i = 0; i < newPaths.length; i++) { | ||
| paths.push(newPaths[i]); | ||
| } | ||
| } | ||
| }); | ||
| exports.default = Ruleset; | ||
| //# sourceMappingURL=ruleset.js.map | ||
| } | ||
| export default Ruleset; |
+151
-77
@@ -1,25 +0,45 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var element_1 = tslib_1.__importDefault(require("./element")); | ||
| var less_error_1 = tslib_1.__importDefault(require("../less-error")); | ||
| var utils = tslib_1.__importStar(require("../utils")); | ||
| var parser_1 = tslib_1.__importDefault(require("../parser/parser")); | ||
| var Selector = function (elements, extendList, condition, index, currentFileInfo, visibilityInfo) { | ||
| this.extendList = extendList; | ||
| this.condition = condition; | ||
| this.evaldCondition = !condition; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.elements = this.getElements(elements); | ||
| this.mixinElements_ = undefined; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| this.setParent(this.elements, this); | ||
| }; | ||
| Selector.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Selector', | ||
| accept: function (visitor) { | ||
| // @ts-check | ||
| import Node from './node.js'; | ||
| import Element from './element.js'; | ||
| import LessError from '../less-error.js'; | ||
| import * as utils from '../utils.js'; | ||
| import Parser from '../parser/parser.js'; | ||
| /** @import { EvalContext, CSSOutput, FileInfo, VisibilityInfo, TreeVisitor } from './node.js' */ | ||
| class Selector extends Node { | ||
| get type() { return 'Selector'; } | ||
| /** | ||
| * @param {(Element | Selector)[] | string} [elements] | ||
| * @param {Node[] | null} [extendList] | ||
| * @param {Node | null} [condition] | ||
| * @param {number} [index] | ||
| * @param {FileInfo} [currentFileInfo] | ||
| * @param {VisibilityInfo} [visibilityInfo] | ||
| */ | ||
| constructor(elements, extendList, condition, index, currentFileInfo, visibilityInfo) { | ||
| super(); | ||
| /** @type {Node[] | null | undefined} */ | ||
| this.extendList = extendList; | ||
| /** @type {Node | null | undefined} */ | ||
| this.condition = condition; | ||
| /** @type {boolean | Node} */ | ||
| this.evaldCondition = !condition; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| /** @type {Element[]} */ | ||
| this.elements = this.getElements(elements); | ||
| /** @type {string[] | undefined} */ | ||
| this.mixinElements_ = undefined; | ||
| /** @type {boolean | undefined} */ | ||
| this.mediaEmpty = undefined; | ||
| this.copyVisibilityInfo(visibilityInfo); | ||
| this.setParent(this.elements, this); | ||
| } | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| if (this.elements) { | ||
| this.elements = visitor.visitArray(this.elements); | ||
| this.elements = /** @type {Element[]} */ (visitor.visitArray(this.elements)); | ||
| } | ||
@@ -32,45 +52,69 @@ if (this.extendList) { | ||
| } | ||
| }, | ||
| createDerived: function (elements, extendList, evaldCondition) { | ||
| } | ||
| /** | ||
| * @param {Element[]} elements | ||
| * @param {Node[] | null} [extendList] | ||
| * @param {boolean | Node} [evaldCondition] | ||
| */ | ||
| createDerived(elements, extendList, evaldCondition) { | ||
| elements = this.getElements(elements); | ||
| var newSelector = new Selector(elements, extendList || this.extendList, null, this.getIndex(), this.fileInfo(), this.visibilityInfo()); | ||
| const newSelector = new Selector(elements, extendList || this.extendList, | ||
| null, this.getIndex(), this.fileInfo(), this.visibilityInfo()); | ||
| newSelector.evaldCondition = (!utils.isNullOrUndefined(evaldCondition)) ? evaldCondition : this.evaldCondition; | ||
| newSelector.mediaEmpty = this.mediaEmpty; | ||
| return newSelector; | ||
| }, | ||
| getElements: function (els) { | ||
| } | ||
| /** | ||
| * @param {(Element | Selector)[] | string | null | undefined} els | ||
| * @returns {Element[]} | ||
| */ | ||
| getElements(els) { | ||
| if (!els) { | ||
| return [new element_1.default('', '&', false, this._index, this._fileInfo)]; | ||
| return [new Element('', '&', false, this._index, this._fileInfo)]; | ||
| } | ||
| if (typeof els === 'string') { | ||
| new parser_1.default(this.parse.context, this.parse.importManager, this._fileInfo, this._index).parseNode(els, ['selector'], function (err, result) { | ||
| if (err) { | ||
| throw new less_error_1.default({ | ||
| index: err.index, | ||
| message: err.message | ||
| }, this.parse.imports, this._fileInfo.filename); | ||
| } | ||
| els = result[0].elements; | ||
| }); | ||
| const fileInfo = this._fileInfo; | ||
| const parse = this.parse; | ||
| new (/** @type {new (...args: unknown[]) => { parseNode: Function }} */ (/** @type {unknown} */ (Parser)))(parse.context, parse.importManager, fileInfo, this._index).parseNode( | ||
| els, | ||
| ['selector'], | ||
| function(/** @type {{ index: number, message: string } | null} */ err, /** @type {Selector[]} */ result) { | ||
| if (err) { | ||
| throw new LessError({ | ||
| index: err.index, | ||
| message: err.message | ||
| }, parse.imports, /** @type {string} */ (/** @type {FileInfo} */ (fileInfo).filename)); | ||
| } | ||
| els = result[0].elements; | ||
| }); | ||
| } | ||
| return els; | ||
| }, | ||
| createEmptySelectors: function () { | ||
| var el = new element_1.default('', '&', false, this._index, this._fileInfo), sels = [new Selector([el], null, null, this._index, this._fileInfo)]; | ||
| return /** @type {Element[]} */ (els); | ||
| } | ||
| createEmptySelectors() { | ||
| const el = new Element('', '&', false, this._index, this._fileInfo), sels = [new Selector([el], null, null, this._index, this._fileInfo)]; | ||
| sels[0].mediaEmpty = true; | ||
| return sels; | ||
| }, | ||
| match: function (other) { | ||
| var elements = this.elements; | ||
| var len = elements.length; | ||
| var olen; | ||
| var i; | ||
| other = other.mixinElements(); | ||
| olen = other.length; | ||
| } | ||
| /** | ||
| * @param {Selector} other | ||
| * @returns {number} | ||
| */ | ||
| match(other) { | ||
| const elements = this.elements; | ||
| const len = elements.length; | ||
| let olen; | ||
| let i; | ||
| /** @type {string[]} */ | ||
| const mixinEls = other.mixinElements(); | ||
| olen = mixinEls.length; | ||
| if (olen === 0 || len < olen) { | ||
| return 0; | ||
| } | ||
| else { | ||
| } else { | ||
| for (i = 0; i < olen; i++) { | ||
| if (elements[i].value !== other[i]) { | ||
| if (elements[i].value !== mixinEls[i]) { | ||
| return 0; | ||
@@ -80,11 +124,17 @@ } | ||
| } | ||
| return olen; // return number of matched elements | ||
| }, | ||
| mixinElements: function () { | ||
| } | ||
| /** @returns {string[]} */ | ||
| mixinElements() { | ||
| if (this.mixinElements_) { | ||
| return this.mixinElements_; | ||
| } | ||
| var elements = this.elements.map(function (v) { | ||
| return v.combinator.value + (v.value.value || v.value); | ||
| /** @type {string[] | null} */ | ||
| let elements = this.elements.map( function(v) { | ||
| return /** @type {string} */ (v.combinator.value) + (/** @type {{ value: string }} */ (v.value).value || v.value); | ||
| }).join('').match(/[,&#*.\w-]([\w-]|(\\.))*/g); | ||
| if (elements) { | ||
@@ -94,9 +144,10 @@ if (elements[0] === '&') { | ||
| } | ||
| } | ||
| else { | ||
| } else { | ||
| elements = []; | ||
| } | ||
| return (this.mixinElements_ = elements); | ||
| }, | ||
| isJustParentSelector: function () { | ||
| } | ||
| isJustParentSelector() { | ||
| return !this.mediaEmpty && | ||
@@ -106,14 +157,36 @@ this.elements.length === 1 && | ||
| (this.elements[0].combinator.value === ' ' || this.elements[0].combinator.value === ''); | ||
| }, | ||
| eval: function (context) { | ||
| var evaldCondition = this.condition && this.condition.eval(context); | ||
| var elements = this.elements; | ||
| var extendList = this.extendList; | ||
| elements = elements && elements.map(function (e) { return e.eval(context); }); | ||
| extendList = extendList && extendList.map(function (extend) { return extend.eval(context); }); | ||
| } | ||
| /** @param {EvalContext} context */ | ||
| eval(context) { | ||
| const evaldCondition = this.condition && this.condition.eval(context); | ||
| let elements = this.elements; | ||
| /** @type {Node[] | null | undefined} */ | ||
| let extendList = this.extendList; | ||
| if (elements) { | ||
| const evaldElements = new Array(elements.length); | ||
| for (let i = 0; i < elements.length; i++) { | ||
| evaldElements[i] = elements[i].eval(context); | ||
| } | ||
| elements = evaldElements; | ||
| } | ||
| if (extendList) { | ||
| const evaldExtends = new Array(extendList.length); | ||
| for (let i = 0; i < extendList.length; i++) { | ||
| evaldExtends[i] = extendList[i].eval(context); | ||
| } | ||
| extendList = evaldExtends; | ||
| } | ||
| return this.createDerived(elements, extendList, evaldCondition); | ||
| }, | ||
| genCSS: function (context, output) { | ||
| var i, element; | ||
| if ((!context || !context.firstSelector) && this.elements[0].combinator.value === '') { | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| let i, element; | ||
| if ((!context || !/** @type {EvalContext & { firstSelector?: boolean }} */ (context).firstSelector) && this.elements[0].combinator.value === '') { | ||
| output.add(' ', this.fileInfo(), this.getIndex()); | ||
@@ -125,8 +198,9 @@ } | ||
| } | ||
| }, | ||
| getIsOutput: function () { | ||
| } | ||
| getIsOutput() { | ||
| return this.evaldCondition; | ||
| } | ||
| }); | ||
| exports.default = Selector; | ||
| //# sourceMappingURL=selector.js.map | ||
| } | ||
| export default Selector; |
@@ -1,12 +0,14 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var UnicodeDescriptor = function (value) { | ||
| this.value = value; | ||
| }; | ||
| UnicodeDescriptor.prototype = Object.assign(new node_1.default(), { | ||
| type: 'UnicodeDescriptor' | ||
| }); | ||
| exports.default = UnicodeDescriptor; | ||
| //# sourceMappingURL=unicode-descriptor.js.map | ||
| // @ts-check | ||
| import Node from './node.js'; | ||
| class UnicodeDescriptor extends Node { | ||
| get type() { return 'UnicodeDescriptor'; } | ||
| /** @param {string} value */ | ||
| constructor(value) { | ||
| super(); | ||
| this.value = value; | ||
| } | ||
| } | ||
| export default UnicodeDescriptor; |
+111
-63
@@ -1,71 +0,107 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var unit_conversions_1 = tslib_1.__importDefault(require("../data/unit-conversions")); | ||
| var utils = tslib_1.__importStar(require("../utils")); | ||
| var Unit = function (numerator, denominator, backupUnit) { | ||
| this.numerator = numerator ? utils.copyArray(numerator).sort() : []; | ||
| this.denominator = denominator ? utils.copyArray(denominator).sort() : []; | ||
| if (backupUnit) { | ||
| this.backupUnit = backupUnit; | ||
| // @ts-check | ||
| import Node from './node.js'; | ||
| import unitConversions from '../data/unit-conversions.js'; | ||
| import * as utils from '../utils.js'; | ||
| /** @import { EvalContext, CSSOutput } from './node.js' */ | ||
| class Unit extends Node { | ||
| get type() { return 'Unit'; } | ||
| /** | ||
| * @param {string[]} [numerator] | ||
| * @param {string[]} [denominator] | ||
| * @param {string} [backupUnit] | ||
| */ | ||
| constructor(numerator, denominator, backupUnit) { | ||
| super(); | ||
| /** @type {string[]} */ | ||
| this.numerator = numerator ? utils.copyArray(numerator).sort() : []; | ||
| /** @type {string[]} */ | ||
| this.denominator = denominator ? utils.copyArray(denominator).sort() : []; | ||
| if (backupUnit) { | ||
| /** @type {string | undefined} */ | ||
| this.backupUnit = backupUnit; | ||
| } else if (numerator && numerator.length) { | ||
| this.backupUnit = numerator[0]; | ||
| } | ||
| } | ||
| else if (numerator && numerator.length) { | ||
| this.backupUnit = numerator[0]; | ||
| clone() { | ||
| return new Unit(utils.copyArray(this.numerator), utils.copyArray(this.denominator), this.backupUnit); | ||
| } | ||
| }; | ||
| Unit.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Unit', | ||
| clone: function () { | ||
| return new Unit(utils.copyArray(this.numerator), utils.copyArray(this.denominator), this.backupUnit); | ||
| }, | ||
| genCSS: function (context, output) { | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| // Dimension checks the unit is singular and throws an error if in strict math mode. | ||
| var strictUnits = context && context.strictUnits; | ||
| const strictUnits = context && context.strictUnits; | ||
| if (this.numerator.length === 1) { | ||
| output.add(this.numerator[0]); // the ideal situation | ||
| } | ||
| else if (!strictUnits && this.backupUnit) { | ||
| } else if (!strictUnits && this.backupUnit) { | ||
| output.add(this.backupUnit); | ||
| } | ||
| else if (!strictUnits && this.denominator.length) { | ||
| } else if (!strictUnits && this.denominator.length) { | ||
| output.add(this.denominator[0]); | ||
| } | ||
| }, | ||
| toString: function () { | ||
| var i, returnStr = this.numerator.join('*'); | ||
| } | ||
| toString() { | ||
| let i, returnStr = this.numerator.join('*'); | ||
| for (i = 0; i < this.denominator.length; i++) { | ||
| returnStr += "/".concat(this.denominator[i]); | ||
| returnStr += `/${this.denominator[i]}`; | ||
| } | ||
| return returnStr; | ||
| }, | ||
| compare: function (other) { | ||
| } | ||
| /** | ||
| * @param {Unit} other | ||
| * @returns {0 | undefined} | ||
| */ | ||
| compare(other) { | ||
| return this.is(other.toString()) ? 0 : undefined; | ||
| }, | ||
| is: function (unitString) { | ||
| } | ||
| /** @param {string} unitString */ | ||
| is(unitString) { | ||
| return this.toString().toUpperCase() === unitString.toUpperCase(); | ||
| }, | ||
| isLength: function () { | ||
| return RegExp('^(px|em|ex|ch|rem|in|cm|mm|pc|pt|ex|vw|vh|vmin|vmax)$', 'gi').test(this.toCSS()); | ||
| }, | ||
| isEmpty: function () { | ||
| } | ||
| isLength() { | ||
| return RegExp('^(px|em|ex|ch|rem|in|cm|mm|pc|pt|ex|vw|vh|vmin|vmax)$', 'gi').test(this.toCSS(/** @type {import('./node.js').EvalContext} */ ({}))); | ||
| } | ||
| isEmpty() { | ||
| return this.numerator.length === 0 && this.denominator.length === 0; | ||
| }, | ||
| isSingular: function () { | ||
| } | ||
| isSingular() { | ||
| return this.numerator.length <= 1 && this.denominator.length === 0; | ||
| }, | ||
| map: function (callback) { | ||
| var i; | ||
| } | ||
| /** @param {(atomicUnit: string, denominator: boolean) => string} callback */ | ||
| map(callback) { | ||
| let i; | ||
| for (i = 0; i < this.numerator.length; i++) { | ||
| this.numerator[i] = callback(this.numerator[i], false); | ||
| } | ||
| for (i = 0; i < this.denominator.length; i++) { | ||
| this.denominator[i] = callback(this.denominator[i], true); | ||
| } | ||
| }, | ||
| usedUnits: function () { | ||
| var group; | ||
| var result = {}; | ||
| var mapUnit; | ||
| var groupName; | ||
| } | ||
| /** @returns {{ [groupName: string]: string }} */ | ||
| usedUnits() { | ||
| /** @type {{ [unitName: string]: number }} */ | ||
| let group; | ||
| /** @type {{ [groupName: string]: string }} */ | ||
| const result = {}; | ||
| /** @type {(atomicUnit: string) => string} */ | ||
| let mapUnit; | ||
| /** @type {string} */ | ||
| let groupName; | ||
| mapUnit = function (atomicUnit) { | ||
@@ -76,17 +112,25 @@ // eslint-disable-next-line no-prototype-builtins | ||
| } | ||
| return atomicUnit; | ||
| }; | ||
| for (groupName in unit_conversions_1.default) { | ||
| for (groupName in unitConversions) { | ||
| // eslint-disable-next-line no-prototype-builtins | ||
| if (unit_conversions_1.default.hasOwnProperty(groupName)) { | ||
| group = unit_conversions_1.default[groupName]; | ||
| if (unitConversions.hasOwnProperty(groupName)) { | ||
| group = /** @type {{ [unitName: string]: number }} */ (unitConversions[/** @type {keyof typeof unitConversions} */ (groupName)]); | ||
| this.map(mapUnit); | ||
| } | ||
| } | ||
| return result; | ||
| }, | ||
| cancel: function () { | ||
| var counter = {}; | ||
| var atomicUnit; | ||
| var i; | ||
| } | ||
| cancel() { | ||
| /** @type {{ [unit: string]: number }} */ | ||
| const counter = {}; | ||
| /** @type {string} */ | ||
| let atomicUnit; | ||
| let i; | ||
| for (i = 0; i < this.numerator.length; i++) { | ||
@@ -96,2 +140,3 @@ atomicUnit = this.numerator[i]; | ||
| } | ||
| for (i = 0; i < this.denominator.length; i++) { | ||
@@ -101,8 +146,11 @@ atomicUnit = this.denominator[i]; | ||
| } | ||
| this.numerator = []; | ||
| this.denominator = []; | ||
| for (atomicUnit in counter) { | ||
| // eslint-disable-next-line no-prototype-builtins | ||
| if (counter.hasOwnProperty(atomicUnit)) { | ||
| var count = counter[atomicUnit]; | ||
| const count = counter[atomicUnit]; | ||
| if (count > 0) { | ||
@@ -112,4 +160,3 @@ for (i = 0; i < count; i++) { | ||
| } | ||
| } | ||
| else if (count < 0) { | ||
| } else if (count < 0) { | ||
| for (i = 0; i < -count; i++) { | ||
@@ -121,7 +168,8 @@ this.denominator.push(atomicUnit); | ||
| } | ||
| this.numerator.sort(); | ||
| this.denominator.sort(); | ||
| } | ||
| }); | ||
| exports.default = Unit; | ||
| //# sourceMappingURL=unit.js.map | ||
| } | ||
| export default Unit; |
+62
-38
@@ -1,27 +0,51 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, TreeVisitor, FileInfo } from './node.js' */ | ||
| import Node from './node.js'; | ||
| /** | ||
| * @param {string} path | ||
| * @returns {string} | ||
| */ | ||
| function escapePath(path) { | ||
| return path.replace(/[()'"\s]/g, function (match) { return "\\".concat(match); }); | ||
| return path.replace(/[()'"\s]/g, function(match) { return `\\${match}`; }); | ||
| } | ||
| var URL = function (val, index, currentFileInfo, isEvald) { | ||
| this.value = val; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.isEvald = isEvald; | ||
| }; | ||
| URL.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Url', | ||
| accept: function (visitor) { | ||
| this.value = visitor.visit(this.value); | ||
| }, | ||
| genCSS: function (context, output) { | ||
| class URL extends Node { | ||
| get type() { return 'Url'; } | ||
| /** | ||
| * @param {Node} val | ||
| * @param {number} index | ||
| * @param {FileInfo} currentFileInfo | ||
| * @param {boolean} [isEvald] | ||
| */ | ||
| constructor(val, index, currentFileInfo, isEvald) { | ||
| super(); | ||
| this.value = val; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| /** @type {boolean | undefined} */ | ||
| this.isEvald = isEvald; | ||
| } | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| this.value = visitor.visit(/** @type {Node} */ (this.value)); | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| output.add('url('); | ||
| this.value.genCSS(context, output); | ||
| /** @type {Node} */ (this.value).genCSS(context, output); | ||
| output.add(')'); | ||
| }, | ||
| eval: function (context) { | ||
| var val = this.value.eval(context); | ||
| var rootpath; | ||
| } | ||
| /** @param {EvalContext} context */ | ||
| eval(context) { | ||
| const val = /** @type {Node} */ (this.value).eval(context); | ||
| let rootpath; | ||
| if (!this.isEvald) { | ||
@@ -32,20 +56,19 @@ // Add the rootpath if the URL requires a rewrite | ||
| typeof val.value === 'string' && | ||
| context.pathRequiresRewrite(val.value)) { | ||
| if (!val.quote) { | ||
| context.pathRequiresRewrite(/** @type {string} */ (val.value))) { | ||
| if (!/** @type {import('./quoted.js').default} */ (val).quote) { | ||
| rootpath = escapePath(rootpath); | ||
| } | ||
| val.value = context.rewritePath(val.value, rootpath); | ||
| val.value = context.rewritePath(/** @type {string} */ (val.value), rootpath); | ||
| } else { | ||
| val.value = context.normalizePath(/** @type {string} */ (val.value)); | ||
| } | ||
| else { | ||
| val.value = context.normalizePath(val.value); | ||
| } | ||
| // Add url args if enabled | ||
| if (context.urlArgs) { | ||
| if (!val.value.match(/^\s*data:/)) { | ||
| var delimiter = val.value.indexOf('?') === -1 ? '?' : '&'; | ||
| var urlArgs = delimiter + context.urlArgs; | ||
| if (val.value.indexOf('#') !== -1) { | ||
| val.value = val.value.replace('#', "".concat(urlArgs, "#")); | ||
| } | ||
| else { | ||
| if (!/** @type {string} */ (val.value).match(/^\s*data:/)) { | ||
| const delimiter = /** @type {string} */ (val.value).indexOf('?') === -1 ? '?' : '&'; | ||
| const urlArgs = delimiter + context.urlArgs; | ||
| if (/** @type {string} */ (val.value).indexOf('#') !== -1) { | ||
| val.value = /** @type {string} */ (val.value).replace('#', `${urlArgs}#`); | ||
| } else { | ||
| val.value += urlArgs; | ||
@@ -56,6 +79,7 @@ } | ||
| } | ||
| return new URL(val, this.getIndex(), this.fileInfo(), true); | ||
| } | ||
| }); | ||
| exports.default = URL; | ||
| //# sourceMappingURL=url.js.map | ||
| } | ||
| export default URL; |
+50
-34
@@ -1,38 +0,54 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var Value = function (value) { | ||
| if (!value) { | ||
| throw new Error('Value requires an array argument'); | ||
| // @ts-check | ||
| /** @import { EvalContext, CSSOutput, TreeVisitor } from './node.js' */ | ||
| import Node from './node.js'; | ||
| class Value extends Node { | ||
| get type() { return 'Value'; } | ||
| /** @param {Node[] | Node} value */ | ||
| constructor(value) { | ||
| super(); | ||
| if (!value) { | ||
| throw new Error('Value requires an array argument'); | ||
| } | ||
| if (!Array.isArray(value)) { | ||
| this.value = [ value ]; | ||
| } | ||
| else { | ||
| this.value = value; | ||
| } | ||
| } | ||
| if (!Array.isArray(value)) { | ||
| this.value = [value]; | ||
| } | ||
| else { | ||
| this.value = value; | ||
| } | ||
| }; | ||
| Value.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Value', | ||
| accept: function (visitor) { | ||
| /** @param {TreeVisitor} visitor */ | ||
| accept(visitor) { | ||
| if (this.value) { | ||
| this.value = visitor.visitArray(this.value); | ||
| this.value = visitor.visitArray(/** @type {Node[]} */ (this.value)); | ||
| } | ||
| }, | ||
| eval: function (context) { | ||
| if (this.value.length === 1) { | ||
| return this.value[0].eval(context); | ||
| } | ||
| else { | ||
| return new Value(this.value.map(function (v) { | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Node} | ||
| */ | ||
| eval(context) { | ||
| const value = /** @type {Node[]} */ (this.value); | ||
| if (value.length === 1) { | ||
| return value[0].eval(context); | ||
| } else { | ||
| return new Value(value.map(function (v) { | ||
| return v.eval(context); | ||
| })); | ||
| } | ||
| }, | ||
| genCSS: function (context, output) { | ||
| var i; | ||
| for (i = 0; i < this.value.length; i++) { | ||
| this.value[i].genCSS(context, output); | ||
| if (i + 1 < this.value.length) { | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @param {CSSOutput} output | ||
| */ | ||
| genCSS(context, output) { | ||
| const value = /** @type {Node[]} */ (this.value); | ||
| let i; | ||
| for (i = 0; i < value.length; i++) { | ||
| value[i].genCSS(context, output); | ||
| if (i + 1 < value.length) { | ||
| output.add((context && context.compress) ? ',' : ', '); | ||
@@ -42,4 +58,4 @@ } | ||
| } | ||
| }); | ||
| exports.default = Value; | ||
| //# sourceMappingURL=value.js.map | ||
| } | ||
| export default Value; |
@@ -1,30 +0,45 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var variable_1 = tslib_1.__importDefault(require("./variable")); | ||
| var ruleset_1 = tslib_1.__importDefault(require("./ruleset")); | ||
| var detached_ruleset_1 = tslib_1.__importDefault(require("./detached-ruleset")); | ||
| var less_error_1 = tslib_1.__importDefault(require("../less-error")); | ||
| var VariableCall = function (variable, index, currentFileInfo) { | ||
| this.variable = variable; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.allowRoot = true; | ||
| }; | ||
| VariableCall.prototype = Object.assign(new node_1.default(), { | ||
| type: 'VariableCall', | ||
| eval: function (context) { | ||
| var rules; | ||
| var detachedRuleset = new variable_1.default(this.variable, this.getIndex(), this.fileInfo()).eval(context); | ||
| var error = new less_error_1.default({ message: "Could not evaluate variable call ".concat(this.variable) }); | ||
| if (!detachedRuleset.ruleset) { | ||
| if (detachedRuleset.rules) { | ||
| // @ts-check | ||
| /** @import { EvalContext, FileInfo } from './node.js' */ | ||
| import Node from './node.js'; | ||
| import Variable from './variable.js'; | ||
| import Ruleset from './ruleset.js'; | ||
| import DetachedRuleset from './detached-ruleset.js'; | ||
| import LessError from '../less-error.js'; | ||
| class VariableCall extends Node { | ||
| get type() { return 'VariableCall'; } | ||
| /** | ||
| * @param {string} variable | ||
| * @param {number} index | ||
| * @param {FileInfo} currentFileInfo | ||
| */ | ||
| constructor(variable, index, currentFileInfo) { | ||
| super(); | ||
| this.variable = variable; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| this.allowRoot = true; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Node} | ||
| */ | ||
| eval(context) { | ||
| let rules; | ||
| /** @type {DetachedRuleset | Node} */ | ||
| let detachedRuleset = new Variable(this.variable, this.getIndex(), this.fileInfo()).eval(context); | ||
| const error = new LessError({message: `Could not evaluate variable call ${this.variable}`}); | ||
| if (!(/** @type {DetachedRuleset} */ (detachedRuleset)).ruleset) { | ||
| const dr = /** @type {Node & { rules?: Node[] }} */ (detachedRuleset); | ||
| if (dr.rules) { | ||
| rules = detachedRuleset; | ||
| } | ||
| else if (Array.isArray(detachedRuleset)) { | ||
| rules = new ruleset_1.default('', detachedRuleset); | ||
| rules = new Ruleset(null, detachedRuleset); | ||
| } | ||
| else if (Array.isArray(detachedRuleset.value)) { | ||
| rules = new ruleset_1.default('', detachedRuleset.value); | ||
| rules = new Ruleset(null, detachedRuleset.value); | ||
| } | ||
@@ -34,11 +49,13 @@ else { | ||
| } | ||
| detachedRuleset = new detached_ruleset_1.default(rules); | ||
| detachedRuleset = new DetachedRuleset(rules); | ||
| } | ||
| if (detachedRuleset.ruleset) { | ||
| return detachedRuleset.callEval(context); | ||
| const dr = /** @type {DetachedRuleset} */ (detachedRuleset); | ||
| if (dr.ruleset) { | ||
| return dr.callEval(context); | ||
| } | ||
| throw error; | ||
| } | ||
| }); | ||
| exports.default = VariableCall; | ||
| //# sourceMappingURL=variable-call.js.map | ||
| } | ||
| export default VariableCall; |
@@ -1,30 +0,49 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var node_1 = tslib_1.__importDefault(require("./node")); | ||
| var call_1 = tslib_1.__importDefault(require("./call")); | ||
| var Variable = function (name, index, currentFileInfo) { | ||
| this.name = name; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| }; | ||
| Variable.prototype = Object.assign(new node_1.default(), { | ||
| type: 'Variable', | ||
| eval: function (context) { | ||
| var variable, name = this.name; | ||
| // @ts-check | ||
| /** @import { EvalContext, FileInfo } from './node.js' */ | ||
| import Node from './node.js'; | ||
| import Call from './call.js'; | ||
| import Ruleset from './ruleset.js'; | ||
| class Variable extends Node { | ||
| get type() { return 'Variable'; } | ||
| /** | ||
| * @param {string} name | ||
| * @param {number} [index] | ||
| * @param {FileInfo} [currentFileInfo] | ||
| */ | ||
| constructor(name, index, currentFileInfo) { | ||
| super(); | ||
| this.name = name; | ||
| this._index = index; | ||
| this._fileInfo = currentFileInfo; | ||
| /** @type {boolean | undefined} */ | ||
| this.evaluating = undefined; | ||
| } | ||
| /** | ||
| * @param {EvalContext} context | ||
| * @returns {Node} | ||
| */ | ||
| eval(context) { | ||
| let variable, name = this.name; | ||
| if (name.indexOf('@@') === 0) { | ||
| name = "@".concat(new Variable(name.slice(1), this.getIndex(), this.fileInfo()).eval(context).value); | ||
| name = `@${new Variable(name.slice(1), this.getIndex(), this.fileInfo()).eval(context).value}`; | ||
| } | ||
| if (this.evaluating) { | ||
| throw { type: 'Name', | ||
| message: "Recursive variable definition for ".concat(name), | ||
| message: `Recursive variable definition for ${name}`, | ||
| filename: this.fileInfo().filename, | ||
| index: this.getIndex() }; | ||
| } | ||
| this.evaluating = true; | ||
| variable = this.find(context.frames, function (frame) { | ||
| var v = frame.variable(name); | ||
| const v = /** @type {Ruleset} */ (frame).variable(name); | ||
| if (v) { | ||
| if (v.important) { | ||
| var importantScope = context.importantScope[context.importantScope.length - 1]; | ||
| const importantScope = context.importantScope[context.importantScope.length - 1]; | ||
| importantScope.important = v.important; | ||
@@ -34,3 +53,3 @@ } | ||
| if (context.inCalc) { | ||
| return (new call_1.default('_SELF', [v.value])).eval(context); | ||
| return (new Call('_SELF', [v.value], 0, undefined)).eval(context); | ||
| } | ||
@@ -45,21 +64,24 @@ else { | ||
| return variable; | ||
| } | ||
| else { | ||
| } else { | ||
| throw { type: 'Name', | ||
| message: "variable ".concat(name, " is undefined"), | ||
| message: `variable ${name} is undefined`, | ||
| filename: this.fileInfo().filename, | ||
| index: this.getIndex() }; | ||
| } | ||
| }, | ||
| find: function (obj, fun) { | ||
| for (var i = 0, r = void 0; i < obj.length; i++) { | ||
| } | ||
| /** | ||
| * @param {Node[]} obj | ||
| * @param {(frame: Node) => Node | undefined} fun | ||
| * @returns {Node | null} | ||
| */ | ||
| find(obj, fun) { | ||
| for (let i = 0, r; i < obj.length; i++) { | ||
| r = fun.call(obj, obj[i]); | ||
| if (r) { | ||
| return r; | ||
| } | ||
| if (r) { return r; } | ||
| } | ||
| return null; | ||
| } | ||
| }); | ||
| exports.default = Variable; | ||
| //# sourceMappingURL=variable.js.map | ||
| } | ||
| export default Variable; |
+44
-47
@@ -1,28 +0,29 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.isNullOrUndefined = exports.flattenArray = exports.merge = exports.copyOptions = exports.defaults = exports.clone = exports.copyArray = exports.getLocation = void 0; | ||
| var tslib_1 = require("tslib"); | ||
| /* jshint proto: true */ | ||
| var Constants = tslib_1.__importStar(require("./constants")); | ||
| var copy_anything_1 = require("copy-anything"); | ||
| function getLocation(index, inputStream) { | ||
| var n = index + 1; | ||
| var line = null; | ||
| var column = -1; | ||
| import * as Constants from './constants.js'; | ||
| import { copy } from 'copy-anything'; | ||
| export function getLocation(index, inputStream) { | ||
| let n = index + 1; | ||
| let line = null; | ||
| let column = -1; | ||
| while (--n >= 0 && inputStream.charAt(n) !== '\n') { | ||
| column++; | ||
| } | ||
| if (typeof index === 'number') { | ||
| line = (inputStream.slice(0, index).match(/\n/g) || '').length; | ||
| } | ||
| return { | ||
| line: line, | ||
| column: column | ||
| line, | ||
| column | ||
| }; | ||
| } | ||
| exports.getLocation = getLocation; | ||
| function copyArray(arr) { | ||
| var i; | ||
| var length = arr.length; | ||
| var copy = new Array(length); | ||
| export function copyArray(arr) { | ||
| let i; | ||
| const length = arr.length; | ||
| const copy = new Array(length); | ||
| for (i = 0; i < length; i++) { | ||
@@ -33,6 +34,6 @@ copy[i] = arr[i]; | ||
| } | ||
| exports.copyArray = copyArray; | ||
| function clone(obj) { | ||
| var cloned = {}; | ||
| for (var prop in obj) { | ||
| export function clone(obj) { | ||
| const cloned = {}; | ||
| for (const prop in obj) { | ||
| if (Object.prototype.hasOwnProperty.call(obj, prop)) { | ||
@@ -44,20 +45,20 @@ cloned[prop] = obj[prop]; | ||
| } | ||
| exports.clone = clone; | ||
| function defaults(obj1, obj2) { | ||
| var newObj = obj2 || {}; | ||
| export function defaults(obj1, obj2) { | ||
| let newObj = obj2 || {}; | ||
| if (!obj2._defaults) { | ||
| newObj = {}; | ||
| var defaults_1 = (0, copy_anything_1.copy)(obj1); | ||
| newObj._defaults = defaults_1; | ||
| var cloned = obj2 ? (0, copy_anything_1.copy)(obj2) : {}; | ||
| Object.assign(newObj, defaults_1, cloned); | ||
| const defaults = copy(obj1); | ||
| newObj._defaults = defaults; | ||
| const cloned = obj2 ? copy(obj2) : {}; | ||
| Object.assign(newObj, defaults, cloned); | ||
| } | ||
| return newObj; | ||
| } | ||
| exports.defaults = defaults; | ||
| function copyOptions(obj1, obj2) { | ||
| export function copyOptions(obj1, obj2) { | ||
| if (obj2 && obj2._defaults) { | ||
| return obj2; | ||
| } | ||
| var opts = defaults(obj1, obj2); | ||
| const opts = defaults(obj1, obj2); | ||
| if (opts.strictMath) { | ||
@@ -101,5 +102,5 @@ opts.math = Constants.Math.PARENS; | ||
| } | ||
| exports.copyOptions = copyOptions; | ||
| function merge(obj1, obj2) { | ||
| for (var prop in obj2) { | ||
| export function merge(obj1, obj2) { | ||
| for (const prop in obj2) { | ||
| if (Object.prototype.hasOwnProperty.call(obj2, prop)) { | ||
@@ -111,11 +112,9 @@ obj1[prop] = obj2[prop]; | ||
| } | ||
| exports.merge = merge; | ||
| function flattenArray(arr, result) { | ||
| if (result === void 0) { result = []; } | ||
| for (var i = 0, length_1 = arr.length; i < length_1; i++) { | ||
| var value = arr[i]; | ||
| export function flattenArray(arr, result = []) { | ||
| for (let i = 0, length = arr.length; i < length; i++) { | ||
| const value = arr[i]; | ||
| if (Array.isArray(value)) { | ||
| flattenArray(value, result); | ||
| } | ||
| else { | ||
| } else { | ||
| if (value !== undefined) { | ||
@@ -128,7 +127,5 @@ result.push(value); | ||
| } | ||
| exports.flattenArray = flattenArray; | ||
| function isNullOrUndefined(val) { | ||
| return val === null || val === undefined; | ||
| } | ||
| exports.isNullOrUndefined = isNullOrUndefined; | ||
| //# sourceMappingURL=utils.js.map | ||
| export function isNullOrUndefined(val) { | ||
| return val === null || val === undefined | ||
| } |
@@ -1,4 +0,1 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| /* eslint-disable no-unused-vars */ | ||
@@ -8,37 +5,45 @@ /** | ||
| */ | ||
| var tree_1 = tslib_1.__importDefault(require("../tree")); | ||
| var visitor_1 = tslib_1.__importDefault(require("./visitor")); | ||
| var logger_1 = tslib_1.__importDefault(require("../logger")); | ||
| var utils = tslib_1.__importStar(require("../utils")); | ||
| import tree from '../tree/index.js'; | ||
| import Visitor from './visitor.js'; | ||
| import logger from '../logger.js'; | ||
| import * as utils from '../utils.js'; | ||
| /* jshint loopfunc:true */ | ||
| var ExtendFinderVisitor = /** @class */ (function () { | ||
| function ExtendFinderVisitor() { | ||
| this._visitor = new visitor_1.default(this); | ||
| class ExtendFinderVisitor { | ||
| constructor() { | ||
| this._visitor = new Visitor(this); | ||
| this.contexts = []; | ||
| this.allExtendsStack = [[]]; | ||
| } | ||
| ExtendFinderVisitor.prototype.run = function (root) { | ||
| run(root) { | ||
| root = this._visitor.visit(root); | ||
| root.allExtends = this.allExtendsStack[0]; | ||
| return root; | ||
| }; | ||
| ExtendFinderVisitor.prototype.visitDeclaration = function (declNode, visitArgs) { | ||
| } | ||
| visitDeclaration(declNode, visitArgs) { | ||
| visitArgs.visitDeeper = false; | ||
| }; | ||
| ExtendFinderVisitor.prototype.visitMixinDefinition = function (mixinDefinitionNode, visitArgs) { | ||
| } | ||
| visitMixinDefinition(mixinDefinitionNode, visitArgs) { | ||
| visitArgs.visitDeeper = false; | ||
| }; | ||
| ExtendFinderVisitor.prototype.visitRuleset = function (rulesetNode, visitArgs) { | ||
| } | ||
| visitRuleset(rulesetNode, visitArgs) { | ||
| if (rulesetNode.root) { | ||
| return; | ||
| } | ||
| var i; | ||
| var j; | ||
| var extend; | ||
| var allSelectorsExtendList = []; | ||
| var extendList; | ||
| let i; | ||
| let j; | ||
| let extend; | ||
| const allSelectorsExtendList = []; | ||
| let extendList; | ||
| // get &:extend(.a); rules which apply to all selectors in this ruleset | ||
| var rules = rulesetNode.rules, ruleCnt = rules ? rules.length : 0; | ||
| const rules = rulesetNode.rules, ruleCnt = rules ? rules.length : 0; | ||
| for (i = 0; i < ruleCnt; i++) { | ||
| if (rulesetNode.rules[i] instanceof tree_1.default.Extend) { | ||
| if (rulesetNode.rules[i] instanceof tree.Extend) { | ||
| allSelectorsExtendList.push(rules[i]); | ||
@@ -48,14 +53,18 @@ rulesetNode.extendOnEveryPath = true; | ||
| } | ||
| // now find every selector and apply the extends that apply to all extends | ||
| // and the ones which apply to an individual extend | ||
| var paths = rulesetNode.paths; | ||
| const paths = rulesetNode.paths; | ||
| for (i = 0; i < paths.length; i++) { | ||
| var selectorPath = paths[i], selector = selectorPath[selectorPath.length - 1], selExtendList = selector.extendList; | ||
| const selectorPath = paths[i], selector = selectorPath[selectorPath.length - 1], selExtendList = selector.extendList; | ||
| extendList = selExtendList ? utils.copyArray(selExtendList).concat(allSelectorsExtendList) | ||
| : allSelectorsExtendList; | ||
| if (extendList) { | ||
| extendList = extendList.map(function (allSelectorsExtend) { | ||
| extendList = extendList.map(function(allSelectorsExtend) { | ||
| return allSelectorsExtend.clone(); | ||
| }); | ||
| } | ||
| for (j = 0; j < extendList.length; j++) { | ||
@@ -66,60 +75,65 @@ this.foundExtends = true; | ||
| extend.ruleset = rulesetNode; | ||
| if (j === 0) { | ||
| extend.firstExtendOnThisSelectorPath = true; | ||
| } | ||
| if (j === 0) { extend.firstExtendOnThisSelectorPath = true; } | ||
| this.allExtendsStack[this.allExtendsStack.length - 1].push(extend); | ||
| } | ||
| } | ||
| this.contexts.push(rulesetNode.selectors); | ||
| }; | ||
| ExtendFinderVisitor.prototype.visitRulesetOut = function (rulesetNode) { | ||
| } | ||
| visitRulesetOut(rulesetNode) { | ||
| if (!rulesetNode.root) { | ||
| this.contexts.length = this.contexts.length - 1; | ||
| } | ||
| }; | ||
| ExtendFinderVisitor.prototype.visitMedia = function (mediaNode, visitArgs) { | ||
| } | ||
| visitMedia(mediaNode, visitArgs) { | ||
| mediaNode.allExtends = []; | ||
| this.allExtendsStack.push(mediaNode.allExtends); | ||
| }; | ||
| ExtendFinderVisitor.prototype.visitMediaOut = function (mediaNode) { | ||
| } | ||
| visitMediaOut(mediaNode) { | ||
| this.allExtendsStack.length = this.allExtendsStack.length - 1; | ||
| }; | ||
| ExtendFinderVisitor.prototype.visitAtRule = function (atRuleNode, visitArgs) { | ||
| } | ||
| visitAtRule(atRuleNode, visitArgs) { | ||
| atRuleNode.allExtends = []; | ||
| this.allExtendsStack.push(atRuleNode.allExtends); | ||
| }; | ||
| ExtendFinderVisitor.prototype.visitAtRuleOut = function (atRuleNode) { | ||
| } | ||
| visitAtRuleOut(atRuleNode) { | ||
| this.allExtendsStack.length = this.allExtendsStack.length - 1; | ||
| }; | ||
| return ExtendFinderVisitor; | ||
| }()); | ||
| var ProcessExtendsVisitor = /** @class */ (function () { | ||
| function ProcessExtendsVisitor() { | ||
| this._visitor = new visitor_1.default(this); | ||
| } | ||
| ProcessExtendsVisitor.prototype.run = function (root) { | ||
| var extendFinder = new ExtendFinderVisitor(); | ||
| } | ||
| class ProcessExtendsVisitor { | ||
| constructor() { | ||
| this._visitor = new Visitor(this); | ||
| } | ||
| run(root) { | ||
| const extendFinder = new ExtendFinderVisitor(); | ||
| this.extendIndices = {}; | ||
| extendFinder.run(root); | ||
| if (!extendFinder.foundExtends) { | ||
| return root; | ||
| } | ||
| if (!extendFinder.foundExtends) { return root; } | ||
| root.allExtends = root.allExtends.concat(this.doExtendChaining(root.allExtends, root.allExtends)); | ||
| this.allExtendsStack = [root.allExtends]; | ||
| var newRoot = this._visitor.visit(root); | ||
| const newRoot = this._visitor.visit(root); | ||
| this.checkExtendsForNonMatched(root.allExtends); | ||
| return newRoot; | ||
| }; | ||
| ProcessExtendsVisitor.prototype.checkExtendsForNonMatched = function (extendList) { | ||
| var indices = this.extendIndices; | ||
| extendList.filter(function (extend) { | ||
| } | ||
| checkExtendsForNonMatched(extendList) { | ||
| const indices = this.extendIndices; | ||
| extendList.filter(function(extend) { | ||
| return !extend.hasFoundMatches && extend.parent_ids.length == 1; | ||
| }).forEach(function (extend) { | ||
| var selector = '_unknown_'; | ||
| }).forEach(function(extend) { | ||
| let selector = '_unknown_'; | ||
| try { | ||
| selector = extend.selector.toCSS({}); | ||
| } | ||
| catch (_) { } | ||
| if (!indices["".concat(extend.index, " ").concat(selector)]) { | ||
| indices["".concat(extend.index, " ").concat(selector)] = true; | ||
| catch (_) {} | ||
| if (!indices[`${extend.index} ${selector}`]) { | ||
| indices[`${extend.index} ${selector}`] = true; | ||
| /** | ||
@@ -130,7 +144,8 @@ * @todo Shouldn't this be an error? To alert the developer | ||
| */ | ||
| logger_1.default.warn("WARNING: extend '".concat(selector, "' has no matches")); | ||
| logger.warn(`WARNING: extend '${selector}' has no matches`); | ||
| } | ||
| }); | ||
| }; | ||
| ProcessExtendsVisitor.prototype.doExtendChaining = function (extendsList, extendsListTarget, iterationCount) { | ||
| } | ||
| doExtendChaining(extendsList, extendsListTarget, iterationCount) { | ||
| // | ||
@@ -144,13 +159,17 @@ // chaining is different from normal extension.. if we extend an extend then we are not just copying, altering | ||
| // processed if we look at each selector at a time, as is done in visitRuleset | ||
| var extendIndex; | ||
| var targetExtendIndex; | ||
| var matches; | ||
| var extendsToAdd = []; | ||
| var newSelector; | ||
| var extendVisitor = this; | ||
| var selectorPath; | ||
| var extend; | ||
| var targetExtend; | ||
| var newExtend; | ||
| let extendIndex; | ||
| let targetExtendIndex; | ||
| let matches; | ||
| const extendsToAdd = []; | ||
| let newSelector; | ||
| const extendVisitor = this; | ||
| let selectorPath; | ||
| let extend; | ||
| let targetExtend; | ||
| let newExtend; | ||
| iterationCount = iterationCount || 0; | ||
| // loop through comparing every extend with every target extend. | ||
@@ -164,28 +183,37 @@ // a target extend is the one on the ruleset we are looking at copy/edit/pasting in place | ||
| for (targetExtendIndex = 0; targetExtendIndex < extendsListTarget.length; targetExtendIndex++) { | ||
| extend = extendsList[extendIndex]; | ||
| targetExtend = extendsListTarget[targetExtendIndex]; | ||
| // look for circular references | ||
| if (extend.parent_ids.indexOf(targetExtend.object_id) >= 0) { | ||
| continue; | ||
| } | ||
| if ( extend.parent_ids.indexOf( targetExtend.object_id ) >= 0 ) { continue; } | ||
| // find a match in the target extends self selector (the bit before :extend) | ||
| selectorPath = [targetExtend.selfSelectors[0]]; | ||
| matches = extendVisitor.findMatch(extend, selectorPath); | ||
| if (matches.length) { | ||
| extend.hasFoundMatches = true; | ||
| // we found a match, so for each self selector.. | ||
| extend.selfSelectors.forEach(function (selfSelector) { | ||
| var info = targetExtend.visibilityInfo(); | ||
| extend.selfSelectors.forEach(function(selfSelector) { | ||
| const info = targetExtend.visibilityInfo(); | ||
| // process the extend as usual | ||
| newSelector = extendVisitor.extendSelector(matches, selectorPath, selfSelector, extend.isVisible()); | ||
| // but now we create a new extend from it | ||
| newExtend = new (tree_1.default.Extend)(targetExtend.selector, targetExtend.option, 0, targetExtend.fileInfo(), info); | ||
| newExtend = new(tree.Extend)(targetExtend.selector, targetExtend.option, 0, targetExtend.fileInfo(), info); | ||
| newExtend.selfSelectors = newSelector; | ||
| // add the extend onto the list of extends for that selector | ||
| newSelector[newSelector.length - 1].extendList = [newExtend]; | ||
| // record that we need to add it. | ||
| extendsToAdd.push(newExtend); | ||
| newExtend.ruleset = targetExtend.ruleset; | ||
| // remember its parents for circular references | ||
| newExtend.parent_ids = newExtend.parent_ids.concat(targetExtend.parent_ids, extend.parent_ids); | ||
| // only process the selector once.. if we have :extend(.a,.b) then multiple | ||
@@ -202,2 +230,3 @@ // extends will look at the same selector path, so when extending | ||
| } | ||
| if (extendsToAdd.length) { | ||
@@ -208,4 +237,4 @@ // try to detect circular references to stop a stack overflow. | ||
| if (iterationCount > 100) { | ||
| var selectorOne = '{unable to calculate}'; | ||
| var selectorTwo = '{unable to calculate}'; | ||
| let selectorOne = '{unable to calculate}'; | ||
| let selectorTwo = '{unable to calculate}'; | ||
| try { | ||
@@ -215,59 +244,65 @@ selectorOne = extendsToAdd[0].selfSelectors[0].toCSS(); | ||
| } | ||
| catch (e) { } | ||
| throw { message: "extend circular reference detected. One of the circular extends is currently:".concat(selectorOne, ":extend(").concat(selectorTwo, ")") }; | ||
| catch (e) {} | ||
| throw { message: `extend circular reference detected. One of the circular extends is currently:${selectorOne}:extend(${selectorTwo})`}; | ||
| } | ||
| // now process the new extends on the existing rules so that we can handle a extending b extending c extending | ||
| // d extending e... | ||
| return extendsToAdd.concat(extendVisitor.doExtendChaining(extendsToAdd, extendsListTarget, iterationCount + 1)); | ||
| } | ||
| else { | ||
| } else { | ||
| return extendsToAdd; | ||
| } | ||
| }; | ||
| ProcessExtendsVisitor.prototype.visitDeclaration = function (ruleNode, visitArgs) { | ||
| } | ||
| visitDeclaration(ruleNode, visitArgs) { | ||
| visitArgs.visitDeeper = false; | ||
| }; | ||
| ProcessExtendsVisitor.prototype.visitMixinDefinition = function (mixinDefinitionNode, visitArgs) { | ||
| } | ||
| visitMixinDefinition(mixinDefinitionNode, visitArgs) { | ||
| visitArgs.visitDeeper = false; | ||
| }; | ||
| ProcessExtendsVisitor.prototype.visitSelector = function (selectorNode, visitArgs) { | ||
| } | ||
| visitSelector(selectorNode, visitArgs) { | ||
| visitArgs.visitDeeper = false; | ||
| }; | ||
| ProcessExtendsVisitor.prototype.visitRuleset = function (rulesetNode, visitArgs) { | ||
| } | ||
| visitRuleset(rulesetNode, visitArgs) { | ||
| if (rulesetNode.root) { | ||
| return; | ||
| } | ||
| var matches; | ||
| var pathIndex; | ||
| var extendIndex; | ||
| var allExtends = this.allExtendsStack[this.allExtendsStack.length - 1]; | ||
| var selectorsToAdd = []; | ||
| var extendVisitor = this; | ||
| var selectorPath; | ||
| let matches; | ||
| const allExtends = this.allExtendsStack[this.allExtendsStack.length - 1]; | ||
| const selectorsToAdd = []; | ||
| const paths = rulesetNode.paths; | ||
| const pathCount = paths.length; | ||
| // look at each selector path in the ruleset, find any extend matches and then copy, find and replace | ||
| for (extendIndex = 0; extendIndex < allExtends.length; extendIndex++) { | ||
| for (pathIndex = 0; pathIndex < rulesetNode.paths.length; pathIndex++) { | ||
| selectorPath = rulesetNode.paths[pathIndex]; | ||
| for (let extendIndex = 0; extendIndex < allExtends.length; extendIndex++) { | ||
| const extend = allExtends[extendIndex]; | ||
| for (let pathIndex = 0; pathIndex < pathCount; pathIndex++) { | ||
| const selectorPath = paths[pathIndex]; | ||
| // extending extends happens initially, before the main pass | ||
| if (rulesetNode.extendOnEveryPath) { | ||
| continue; | ||
| } | ||
| var extendList = selectorPath[selectorPath.length - 1].extendList; | ||
| if (extendList && extendList.length) { | ||
| continue; | ||
| } | ||
| matches = this.findMatch(allExtends[extendIndex], selectorPath); | ||
| if (rulesetNode.extendOnEveryPath) { continue; } | ||
| const extendList = selectorPath[selectorPath.length - 1].extendList; | ||
| if (extendList && extendList.length) { continue; } | ||
| matches = this.findMatch(extend, selectorPath); | ||
| if (matches.length) { | ||
| allExtends[extendIndex].hasFoundMatches = true; | ||
| allExtends[extendIndex].selfSelectors.forEach(function (selfSelector) { | ||
| var extendedSelectors; | ||
| extendedSelectors = extendVisitor.extendSelector(matches, selectorPath, selfSelector, allExtends[extendIndex].isVisible()); | ||
| selectorsToAdd.push(extendedSelectors); | ||
| }); | ||
| extend.hasFoundMatches = true; | ||
| const selfSelectors = extend.selfSelectors; | ||
| const isVisible = extend.isVisible(); | ||
| for (let si = 0; si < selfSelectors.length; si++) { | ||
| selectorsToAdd.push(this.extendSelector(matches, selectorPath, selfSelectors[si], isVisible)); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| rulesetNode.paths = rulesetNode.paths.concat(selectorsToAdd); | ||
| }; | ||
| ProcessExtendsVisitor.prototype.findMatch = function (extend, haystackSelectorPath) { | ||
| rulesetNode.paths = paths.concat(selectorsToAdd); | ||
| } | ||
| findMatch(extend, haystackSelectorPath) { | ||
| // | ||
@@ -277,25 +312,31 @@ // look through the haystack selector path to try and find the needle - extend.selector | ||
| // | ||
| var haystackSelectorIndex; | ||
| var hackstackSelector; | ||
| var hackstackElementIndex; | ||
| var haystackElement; | ||
| var targetCombinator; | ||
| var i; | ||
| var extendVisitor = this; | ||
| var needleElements = extend.selector.elements; | ||
| var potentialMatches = []; | ||
| var potentialMatch; | ||
| var matches = []; | ||
| let haystackSelectorIndex; | ||
| let hackstackSelector; | ||
| let hackstackElementIndex; | ||
| let haystackElement; | ||
| let targetCombinator; | ||
| let i; | ||
| const needleElements = extend.selector.elements; | ||
| const potentialMatches = []; | ||
| let potentialMatch; | ||
| const matches = []; | ||
| // loop through the haystack elements | ||
| for (haystackSelectorIndex = 0; haystackSelectorIndex < haystackSelectorPath.length; haystackSelectorIndex++) { | ||
| hackstackSelector = haystackSelectorPath[haystackSelectorIndex]; | ||
| for (hackstackElementIndex = 0; hackstackElementIndex < hackstackSelector.elements.length; hackstackElementIndex++) { | ||
| haystackElement = hackstackSelector.elements[hackstackElementIndex]; | ||
| // if we allow elements before our match we can add a potential match every time. otherwise only at the first element. | ||
| if (extend.allowBefore || (haystackSelectorIndex === 0 && hackstackElementIndex === 0)) { | ||
| potentialMatches.push({ pathIndex: haystackSelectorIndex, index: hackstackElementIndex, matched: 0, | ||
| initialCombinator: haystackElement.combinator }); | ||
| potentialMatches.push({pathIndex: haystackSelectorIndex, index: hackstackElementIndex, matched: 0, | ||
| initialCombinator: haystackElement.combinator}); | ||
| } | ||
| for (i = 0; i < potentialMatches.length; i++) { | ||
| potentialMatch = potentialMatches[i]; | ||
| // selectors add " " onto the first element. When we use & it joins the selectors together, but if we don't | ||
@@ -308,10 +349,11 @@ // then each selector in haystackSelectorPath has a space before it added in the toCSS phase. so we need to | ||
| } | ||
| // if we don't match, null our match to indicate failure | ||
| if (!extendVisitor.isElementValuesEqual(needleElements[potentialMatch.matched].value, haystackElement.value) || | ||
| if (!this.isElementValuesEqual(needleElements[potentialMatch.matched].value, haystackElement.value) || | ||
| (potentialMatch.matched > 0 && needleElements[potentialMatch.matched].combinator.value !== targetCombinator)) { | ||
| potentialMatch = null; | ||
| } | ||
| else { | ||
| } else { | ||
| potentialMatch.matched++; | ||
| } | ||
| // if we are still valid and have finished, test whether we have elements after and whether these are allowed | ||
@@ -335,4 +377,3 @@ if (potentialMatch) { | ||
| } | ||
| } | ||
| else { | ||
| } else { | ||
| potentialMatches.splice(i, 1); | ||
@@ -345,8 +386,9 @@ i--; | ||
| return matches; | ||
| }; | ||
| ProcessExtendsVisitor.prototype.isElementValuesEqual = function (elementValue1, elementValue2) { | ||
| } | ||
| isElementValuesEqual(elementValue1, elementValue2) { | ||
| if (typeof elementValue1 === 'string' || typeof elementValue2 === 'string') { | ||
| return elementValue1 === elementValue2; | ||
| } | ||
| if (elementValue1 instanceof tree_1.default.Attribute) { | ||
| if (elementValue1 instanceof tree.Attribute) { | ||
| if (elementValue1.op !== elementValue2.op || elementValue1.key !== elementValue2.key) { | ||
@@ -367,7 +409,7 @@ return false; | ||
| elementValue2 = elementValue2.value; | ||
| if (elementValue1 instanceof tree_1.default.Selector) { | ||
| if (!(elementValue2 instanceof tree_1.default.Selector) || elementValue1.elements.length !== elementValue2.elements.length) { | ||
| if (elementValue1 instanceof tree.Selector) { | ||
| if (!(elementValue2 instanceof tree.Selector) || elementValue1.elements.length !== elementValue2.elements.length) { | ||
| return false; | ||
| } | ||
| for (var i = 0; i < elementValue1.elements.length; i++) { | ||
| for (let i = 0; i < elementValue1.elements.length; i++) { | ||
| if (elementValue1.elements[i].combinator.value !== elementValue2.elements[i].combinator.value) { | ||
@@ -385,10 +427,21 @@ if (i !== 0 || (elementValue1.elements[i].combinator.value || ' ') !== (elementValue2.elements[i].combinator.value || ' ')) { | ||
| return false; | ||
| }; | ||
| ProcessExtendsVisitor.prototype.extendSelector = function (matches, selectorPath, replacementSelector, isVisible) { | ||
| } | ||
| extendSelector(matches, selectorPath, replacementSelector, isVisible) { | ||
| // for a set of matches, replace each match with the replacement selector | ||
| var currentSelectorPathIndex = 0, currentSelectorPathElementIndex = 0, path = [], matchIndex, selector, firstElement, match, newElements; | ||
| let currentSelectorPathIndex = 0, currentSelectorPathElementIndex = 0, path = [], matchIndex, selector, firstElement, match, newElements; | ||
| for (matchIndex = 0; matchIndex < matches.length; matchIndex++) { | ||
| match = matches[matchIndex]; | ||
| selector = selectorPath[match.pathIndex]; | ||
| firstElement = new tree_1.default.Element(match.initialCombinator, replacementSelector.elements[0].value, replacementSelector.elements[0].isVariable, replacementSelector.elements[0].getIndex(), replacementSelector.elements[0].fileInfo()); | ||
| firstElement = new tree.Element( | ||
| match.initialCombinator, | ||
| replacementSelector.elements[0].value, | ||
| replacementSelector.elements[0].isVariable, | ||
| replacementSelector.elements[0].getIndex(), | ||
| replacementSelector.elements[0].fileInfo() | ||
| ); | ||
| if (match.pathIndex > currentSelectorPathIndex && currentSelectorPathElementIndex > 0) { | ||
@@ -400,2 +453,3 @@ path[path.length - 1].elements = path[path.length - 1] | ||
| } | ||
| newElements = selector.elements | ||
@@ -405,9 +459,12 @@ .slice(currentSelectorPathElementIndex, match.index) | ||
| .concat(replacementSelector.elements.slice(1)); | ||
| if (currentSelectorPathIndex === match.pathIndex && matchIndex > 0) { | ||
| path[path.length - 1].elements = | ||
| path[path.length - 1].elements.concat(newElements); | ||
| } | ||
| else { | ||
| } else { | ||
| path = path.concat(selectorPath.slice(currentSelectorPathIndex, match.pathIndex)); | ||
| path.push(new tree_1.default.Selector(newElements)); | ||
| path.push(new tree.Selector( | ||
| newElements | ||
| )); | ||
| } | ||
@@ -421,2 +478,3 @@ currentSelectorPathIndex = match.endPathIndex; | ||
| } | ||
| if (currentSelectorPathIndex < selectorPath.length && currentSelectorPathElementIndex > 0) { | ||
@@ -427,10 +485,10 @@ path[path.length - 1].elements = path[path.length - 1] | ||
| } | ||
| path = path.concat(selectorPath.slice(currentSelectorPathIndex, selectorPath.length)); | ||
| path = path.map(function (currentValue) { | ||
| // we can re-use elements here, because the visibility property matters only for selectors | ||
| var derived = currentValue.createDerived(currentValue.elements); | ||
| const derived = currentValue.createDerived(currentValue.elements); | ||
| if (isVisible) { | ||
| derived.ensureVisibility(); | ||
| } | ||
| else { | ||
| } else { | ||
| derived.ensureInvisibility(); | ||
@@ -441,24 +499,27 @@ } | ||
| return path; | ||
| }; | ||
| ProcessExtendsVisitor.prototype.visitMedia = function (mediaNode, visitArgs) { | ||
| var newAllExtends = mediaNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]); | ||
| } | ||
| visitMedia(mediaNode, visitArgs) { | ||
| let newAllExtends = mediaNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]); | ||
| newAllExtends = newAllExtends.concat(this.doExtendChaining(newAllExtends, mediaNode.allExtends)); | ||
| this.allExtendsStack.push(newAllExtends); | ||
| }; | ||
| ProcessExtendsVisitor.prototype.visitMediaOut = function (mediaNode) { | ||
| var lastIndex = this.allExtendsStack.length - 1; | ||
| } | ||
| visitMediaOut(mediaNode) { | ||
| const lastIndex = this.allExtendsStack.length - 1; | ||
| this.allExtendsStack.length = lastIndex; | ||
| }; | ||
| ProcessExtendsVisitor.prototype.visitAtRule = function (atRuleNode, visitArgs) { | ||
| var newAllExtends = atRuleNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]); | ||
| } | ||
| visitAtRule(atRuleNode, visitArgs) { | ||
| let newAllExtends = atRuleNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]); | ||
| newAllExtends = newAllExtends.concat(this.doExtendChaining(newAllExtends, atRuleNode.allExtends)); | ||
| this.allExtendsStack.push(newAllExtends); | ||
| }; | ||
| ProcessExtendsVisitor.prototype.visitAtRuleOut = function (atRuleNode) { | ||
| var lastIndex = this.allExtendsStack.length - 1; | ||
| } | ||
| visitAtRuleOut(atRuleNode) { | ||
| const lastIndex = this.allExtendsStack.length - 1; | ||
| this.allExtendsStack.length = lastIndex; | ||
| }; | ||
| return ProcessExtendsVisitor; | ||
| }()); | ||
| exports.default = ProcessExtendsVisitor; | ||
| //# sourceMappingURL=extend-visitor.js.map | ||
| } | ||
| } | ||
| export default ProcessExtendsVisitor; |
@@ -1,5 +0,3 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var ImportSequencer = /** @class */ (function () { | ||
| function ImportSequencer(onSequencerEmpty) { | ||
| class ImportSequencer { | ||
| constructor(onSequencerEmpty) { | ||
| this.imports = []; | ||
@@ -10,10 +8,12 @@ this.variableImports = []; | ||
| } | ||
| ImportSequencer.prototype.addImport = function (callback) { | ||
| var importSequencer = this, importItem = { | ||
| callback: callback, | ||
| args: null, | ||
| isReady: false | ||
| }; | ||
| addImport(callback) { | ||
| const importSequencer = this, | ||
| importItem = { | ||
| callback, | ||
| args: null, | ||
| isReady: false | ||
| }; | ||
| this.imports.push(importItem); | ||
| return function () { | ||
| return function() { | ||
| importItem.args = Array.prototype.slice.call(arguments, 0); | ||
@@ -23,7 +23,9 @@ importItem.isReady = true; | ||
| }; | ||
| }; | ||
| ImportSequencer.prototype.addVariableImport = function (callback) { | ||
| } | ||
| addVariableImport(callback) { | ||
| this.variableImports.push(callback); | ||
| }; | ||
| ImportSequencer.prototype.tryRun = function () { | ||
| } | ||
| tryRun() { | ||
| this._currentDepth++; | ||
@@ -33,3 +35,3 @@ try { | ||
| while (this.imports.length > 0) { | ||
| var importItem = this.imports[0]; | ||
| const importItem = this.imports[0]; | ||
| if (!importItem.isReady) { | ||
@@ -44,8 +46,7 @@ return; | ||
| } | ||
| var variableImport = this.variableImports[0]; | ||
| const variableImport = this.variableImports[0]; | ||
| this.variableImports = this.variableImports.slice(1); | ||
| variableImport(); | ||
| } | ||
| } | ||
| finally { | ||
| } finally { | ||
| this._currentDepth--; | ||
@@ -56,6 +57,5 @@ } | ||
| } | ||
| }; | ||
| return ImportSequencer; | ||
| }()); | ||
| exports.default = ImportSequencer; | ||
| //# sourceMappingURL=import-sequencer.js.map | ||
| } | ||
| } | ||
| export default ImportSequencer; |
@@ -1,4 +0,1 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| /* eslint-disable no-unused-vars */ | ||
@@ -8,16 +5,19 @@ /** | ||
| */ | ||
| var contexts_1 = tslib_1.__importDefault(require("../contexts")); | ||
| var visitor_1 = tslib_1.__importDefault(require("./visitor")); | ||
| var import_sequencer_1 = tslib_1.__importDefault(require("./import-sequencer")); | ||
| var utils = tslib_1.__importStar(require("../utils")); | ||
| var ImportVisitor = function (importer, finish) { | ||
| this._visitor = new visitor_1.default(this); | ||
| import contexts from '../contexts.js'; | ||
| import Visitor from './visitor.js'; | ||
| import ImportSequencer from './import-sequencer.js'; | ||
| import * as utils from '../utils.js'; | ||
| const ImportVisitor = function(importer, finish) { | ||
| this._visitor = new Visitor(this); | ||
| this._importer = importer; | ||
| this._finish = finish; | ||
| this.context = new contexts_1.default.Eval(); | ||
| this.context = new contexts.Eval(); | ||
| this.importCount = 0; | ||
| this.onceFileDetectionMap = {}; | ||
| this.recursionDetector = {}; | ||
| this._sequencer = new import_sequencer_1.default(this._onSequencerEmpty.bind(this)); | ||
| this._sequencer = new ImportSequencer(this._onSequencerEmpty.bind(this)); | ||
| }; | ||
| ImportVisitor.prototype = { | ||
@@ -33,6 +33,7 @@ isReplacing: false, | ||
| } | ||
| this.isFinished = true; | ||
| this._sequencer.tryRun(); | ||
| }, | ||
| _onSequencerEmpty: function () { | ||
| _onSequencerEmpty: function() { | ||
| if (!this.isFinished) { | ||
@@ -44,11 +45,13 @@ return; | ||
| visitImport: function (importNode, visitArgs) { | ||
| var inlineCSS = importNode.options.inline; | ||
| const inlineCSS = importNode.options.inline; | ||
| if (!importNode.css || inlineCSS) { | ||
| var context = new contexts_1.default.Eval(this.context, utils.copyArray(this.context.frames)); | ||
| var importParent = context.frames[0]; | ||
| const context = new contexts.Eval(this.context, utils.copyArray(this.context.frames)); | ||
| const importParent = context.frames[0]; | ||
| this.importCount++; | ||
| if (importNode.isVariableImport()) { | ||
| this._sequencer.addVariableImport(this.processImportNode.bind(this, importNode, context, importParent)); | ||
| } | ||
| else { | ||
| } else { | ||
| this.processImportNode(importNode, context, importParent); | ||
@@ -59,13 +62,10 @@ } | ||
| }, | ||
| processImportNode: function (importNode, context, importParent) { | ||
| var evaldImportNode; | ||
| var inlineCSS = importNode.options.inline; | ||
| processImportNode: function(importNode, context, importParent) { | ||
| let evaldImportNode; | ||
| const inlineCSS = importNode.options.inline; | ||
| try { | ||
| evaldImportNode = importNode.evalForImport(context); | ||
| } | ||
| catch (e) { | ||
| if (!e.filename) { | ||
| e.index = importNode.getIndex(); | ||
| e.filename = importNode.fileInfo().filename; | ||
| } | ||
| } catch (e) { | ||
| if (!e.filename) { e.index = importNode.getIndex(); e.filename = importNode.fileInfo().filename; } | ||
| // attempt to eval properly and treat as css | ||
@@ -76,9 +76,13 @@ importNode.css = true; | ||
| } | ||
| if (evaldImportNode && (!evaldImportNode.css || inlineCSS)) { | ||
| if (evaldImportNode.options.multiple) { | ||
| context.importMultiple = true; | ||
| } | ||
| // try appending if we haven't determined if it is css or not | ||
| var tryAppendLessExtension = evaldImportNode.css === undefined; | ||
| for (var i = 0; i < importParent.rules.length; i++) { | ||
| const tryAppendLessExtension = evaldImportNode.css === undefined; | ||
| for (let i = 0; i < importParent.rules.length; i++) { | ||
| if (importParent.rules[i] === importNode) { | ||
@@ -89,6 +93,8 @@ importParent.rules[i] = evaldImportNode; | ||
| } | ||
| var onImported = this.onImported.bind(this, evaldImportNode, context), sequencedOnImported = this._sequencer.addImport(onImported); | ||
| this._importer.push(evaldImportNode.getPath(), tryAppendLessExtension, evaldImportNode.fileInfo(), evaldImportNode.options, sequencedOnImported); | ||
| } | ||
| else { | ||
| const onImported = this.onImported.bind(this, evaldImportNode, context), sequencedOnImported = this._sequencer.addImport(onImported); | ||
| this._importer.push(evaldImportNode.getPath(), tryAppendLessExtension, evaldImportNode.fileInfo(), | ||
| evaldImportNode.options, sequencedOnImported); | ||
| } else { | ||
| this.importCount--; | ||
@@ -103,14 +109,18 @@ if (this.isFinished) { | ||
| if (!e.filename) { | ||
| e.index = importNode.getIndex(); | ||
| e.filename = importNode.fileInfo().filename; | ||
| e.index = importNode.getIndex(); e.filename = importNode.fileInfo().filename; | ||
| } | ||
| this.error = e; | ||
| } | ||
| var importVisitor = this, inlineCSS = importNode.options.inline, isPlugin = importNode.options.isPlugin, isOptional = importNode.options.optional, duplicateImport = importedAtRoot || fullPath in importVisitor.recursionDetector; | ||
| const importVisitor = this, | ||
| inlineCSS = importNode.options.inline, | ||
| isPlugin = importNode.options.isPlugin, | ||
| isOptional = importNode.options.optional, | ||
| duplicateImport = importedAtRoot || fullPath in importVisitor.recursionDetector; | ||
| if (!context.importMultiple) { | ||
| if (duplicateImport) { | ||
| importNode.skip = true; | ||
| } | ||
| else { | ||
| importNode.skip = function () { | ||
| } else { | ||
| importNode.skip = function() { | ||
| if (fullPath in importVisitor.onceFileDetectionMap) { | ||
@@ -124,16 +134,19 @@ return true; | ||
| } | ||
| if (!fullPath && isOptional) { | ||
| importNode.skip = true; | ||
| } | ||
| if (root) { | ||
| importNode.root = root; | ||
| importNode.importedFilename = fullPath; | ||
| if (!inlineCSS && !isPlugin && (context.importMultiple || !duplicateImport)) { | ||
| importVisitor.recursionDetector[fullPath] = true; | ||
| var oldContext = this.context; | ||
| const oldContext = this.context; | ||
| this.context = context; | ||
| try { | ||
| this._visitor.visit(root); | ||
| } | ||
| catch (e) { | ||
| } catch (e) { | ||
| this.error = e; | ||
@@ -144,3 +157,5 @@ } | ||
| } | ||
| importVisitor.importCount--; | ||
| if (importVisitor.isFinished) { | ||
@@ -153,8 +168,7 @@ importVisitor._sequencer.tryRun(); | ||
| this.context.frames.unshift(declNode); | ||
| } | ||
| else { | ||
| } else { | ||
| visitArgs.visitDeeper = false; | ||
| } | ||
| }, | ||
| visitDeclarationOut: function (declNode) { | ||
| visitDeclarationOut: function(declNode) { | ||
| if (declNode.value.type === 'DetachedRuleset') { | ||
@@ -167,12 +181,9 @@ this.context.frames.shift(); | ||
| this.context.frames.unshift(atRuleNode); | ||
| } | ||
| else if (atRuleNode.declarations && atRuleNode.declarations.length) { | ||
| } else if (atRuleNode.declarations && atRuleNode.declarations.length) { | ||
| if (atRuleNode.isRooted) { | ||
| this.context.frames.unshift(atRuleNode); | ||
| } | ||
| else { | ||
| } else { | ||
| this.context.frames.unshift(atRuleNode.declarations[0]); | ||
| } | ||
| } | ||
| else if (atRuleNode.rules && atRuleNode.rules.length) { | ||
| } else if (atRuleNode.rules && atRuleNode.rules.length) { | ||
| this.context.frames.unshift(atRuleNode); | ||
@@ -203,3 +214,2 @@ } | ||
| }; | ||
| exports.default = ImportVisitor; | ||
| //# sourceMappingURL=import-visitor.js.map | ||
| export default ImportVisitor; |
@@ -1,18 +0,15 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var visitor_1 = tslib_1.__importDefault(require("./visitor")); | ||
| var import_visitor_1 = tslib_1.__importDefault(require("./import-visitor")); | ||
| var set_tree_visibility_visitor_1 = tslib_1.__importDefault(require("./set-tree-visibility-visitor")); | ||
| var extend_visitor_1 = tslib_1.__importDefault(require("./extend-visitor")); | ||
| var join_selector_visitor_1 = tslib_1.__importDefault(require("./join-selector-visitor")); | ||
| var to_css_visitor_1 = tslib_1.__importDefault(require("./to-css-visitor")); | ||
| exports.default = { | ||
| Visitor: visitor_1.default, | ||
| ImportVisitor: import_visitor_1.default, | ||
| MarkVisibleSelectorsVisitor: set_tree_visibility_visitor_1.default, | ||
| ExtendVisitor: extend_visitor_1.default, | ||
| JoinSelectorVisitor: join_selector_visitor_1.default, | ||
| ToCSSVisitor: to_css_visitor_1.default | ||
| import Visitor from './visitor.js'; | ||
| import ImportVisitor from './import-visitor.js'; | ||
| import MarkVisibleSelectorsVisitor from './set-tree-visibility-visitor.js'; | ||
| import ExtendVisitor from './extend-visitor.js'; | ||
| import JoinSelectorVisitor from './join-selector-visitor.js'; | ||
| import ToCSSVisitor from './to-css-visitor.js'; | ||
| export default { | ||
| Visitor, | ||
| ImportVisitor, | ||
| MarkVisibleSelectorsVisitor, | ||
| ExtendVisitor, | ||
| JoinSelectorVisitor, | ||
| ToCSSVisitor | ||
| }; | ||
| //# sourceMappingURL=index.js.map |
@@ -1,4 +0,1 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| /* eslint-disable no-unused-vars */ | ||
@@ -8,46 +5,53 @@ /** | ||
| */ | ||
| var visitor_1 = tslib_1.__importDefault(require("./visitor")); | ||
| var JoinSelectorVisitor = /** @class */ (function () { | ||
| function JoinSelectorVisitor() { | ||
| import Visitor from './visitor.js'; | ||
| class JoinSelectorVisitor { | ||
| constructor() { | ||
| this.contexts = [[]]; | ||
| this._visitor = new visitor_1.default(this); | ||
| this._visitor = new Visitor(this); | ||
| } | ||
| JoinSelectorVisitor.prototype.run = function (root) { | ||
| run(root) { | ||
| return this._visitor.visit(root); | ||
| }; | ||
| JoinSelectorVisitor.prototype.visitDeclaration = function (declNode, visitArgs) { | ||
| } | ||
| visitDeclaration(declNode, visitArgs) { | ||
| visitArgs.visitDeeper = false; | ||
| }; | ||
| JoinSelectorVisitor.prototype.visitMixinDefinition = function (mixinDefinitionNode, visitArgs) { | ||
| } | ||
| visitMixinDefinition(mixinDefinitionNode, visitArgs) { | ||
| visitArgs.visitDeeper = false; | ||
| }; | ||
| JoinSelectorVisitor.prototype.visitRuleset = function (rulesetNode, visitArgs) { | ||
| var context = this.contexts[this.contexts.length - 1]; | ||
| var paths = []; | ||
| var selectors; | ||
| } | ||
| visitRuleset(rulesetNode, visitArgs) { | ||
| const context = this.contexts[this.contexts.length - 1]; | ||
| const paths = []; | ||
| let selectors; | ||
| this.contexts.push(paths); | ||
| if (!rulesetNode.root) { | ||
| selectors = rulesetNode.selectors; | ||
| if (selectors) { | ||
| selectors = selectors.filter(function (selector) { return selector.getIsOutput(); }); | ||
| selectors = selectors.filter(function(selector) { return selector.getIsOutput(); }); | ||
| rulesetNode.selectors = selectors.length ? selectors : (selectors = null); | ||
| if (selectors) { | ||
| rulesetNode.joinSelectors(paths, context, selectors); | ||
| } | ||
| if (selectors) { rulesetNode.joinSelectors(paths, context, selectors); } | ||
| } | ||
| if (!selectors) { | ||
| rulesetNode.rules = null; | ||
| } | ||
| if (!selectors) { rulesetNode.rules = null; } | ||
| rulesetNode.paths = paths; | ||
| } | ||
| }; | ||
| JoinSelectorVisitor.prototype.visitRulesetOut = function (rulesetNode) { | ||
| } | ||
| visitRulesetOut(rulesetNode) { | ||
| this.contexts.length = this.contexts.length - 1; | ||
| }; | ||
| JoinSelectorVisitor.prototype.visitMedia = function (mediaNode, visitArgs) { | ||
| var context = this.contexts[this.contexts.length - 1]; | ||
| } | ||
| visitMedia(mediaNode, visitArgs) { | ||
| const context = this.contexts[this.contexts.length - 1]; | ||
| mediaNode.rules[0].root = (context.length === 0 || context[0].multiMedia); | ||
| }; | ||
| JoinSelectorVisitor.prototype.visitAtRule = function (atRuleNode, visitArgs) { | ||
| var context = this.contexts[this.contexts.length - 1]; | ||
| } | ||
| visitAtRule(atRuleNode, visitArgs) { | ||
| const context = this.contexts[this.contexts.length - 1]; | ||
| if (atRuleNode.declarations && atRuleNode.declarations.length) { | ||
@@ -59,6 +63,5 @@ atRuleNode.declarations[0].root = (context.length === 0 || context[0].multiMedia); | ||
| } | ||
| }; | ||
| return JoinSelectorVisitor; | ||
| }()); | ||
| exports.default = JoinSelectorVisitor; | ||
| //# sourceMappingURL=join-selector-visitor.js.map | ||
| } | ||
| } | ||
| export default JoinSelectorVisitor; |
@@ -1,16 +0,25 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var SetTreeVisibilityVisitor = /** @class */ (function () { | ||
| function SetTreeVisibilityVisitor(visible) { | ||
| import Node from '../tree/node.js'; | ||
| class SetTreeVisibilityVisitor { | ||
| /** @param {boolean} visible */ | ||
| constructor(visible) { | ||
| this.visible = visible; | ||
| } | ||
| SetTreeVisibilityVisitor.prototype.run = function (root) { | ||
| /** @param {Node} root */ | ||
| run(root) { | ||
| this.visit(root); | ||
| }; | ||
| SetTreeVisibilityVisitor.prototype.visitArray = function (nodes) { | ||
| } | ||
| /** | ||
| * @param {Node[]} nodes | ||
| * @returns {Node[]} | ||
| */ | ||
| visitArray(nodes) { | ||
| if (!nodes) { | ||
| return nodes; | ||
| } | ||
| var cnt = nodes.length; | ||
| var i; | ||
| const cnt = nodes.length; | ||
| let i; | ||
| for (i = 0; i < cnt; i++) { | ||
@@ -20,4 +29,9 @@ this.visit(nodes[i]); | ||
| return nodes; | ||
| }; | ||
| SetTreeVisibilityVisitor.prototype.visit = function (node) { | ||
| } | ||
| /** | ||
| * @param {*} node | ||
| * @returns {*} | ||
| */ | ||
| visit(node) { | ||
| if (!node) { | ||
@@ -29,2 +43,3 @@ return node; | ||
| } | ||
| if (!node.blocksVisibility || node.blocksVisibility()) { | ||
@@ -35,12 +50,11 @@ return node; | ||
| node.ensureVisibility(); | ||
| } | ||
| else { | ||
| } else { | ||
| node.ensureInvisibility(); | ||
| } | ||
| node.accept(this); | ||
| return node; | ||
| }; | ||
| return SetTreeVisibilityVisitor; | ||
| }()); | ||
| exports.default = SetTreeVisibilityVisitor; | ||
| //# sourceMappingURL=set-tree-visibility-visitor.js.map | ||
| } | ||
| } | ||
| export default SetTreeVisibilityVisitor; |
@@ -1,4 +0,1 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| /* eslint-disable no-unused-vars */ | ||
@@ -8,15 +5,18 @@ /** | ||
| */ | ||
| var tree_1 = tslib_1.__importDefault(require("../tree")); | ||
| var visitor_1 = tslib_1.__importDefault(require("./visitor")); | ||
| var CSSVisitorUtils = /** @class */ (function () { | ||
| function CSSVisitorUtils(context) { | ||
| this._visitor = new visitor_1.default(this); | ||
| import tree from '../tree/index.js'; | ||
| import Visitor from './visitor.js'; | ||
| import mergeRules from '../tree/merge-rules.js'; | ||
| class CSSVisitorUtils { | ||
| constructor(context) { | ||
| this._visitor = new Visitor(this); | ||
| this._context = context; | ||
| } | ||
| CSSVisitorUtils.prototype.containsSilentNonBlockedChild = function (bodyRules) { | ||
| var rule; | ||
| containsSilentNonBlockedChild(bodyRules) { | ||
| let rule; | ||
| if (!bodyRules) { | ||
| return false; | ||
| } | ||
| for (var r = 0; r < bodyRules.length; r++) { | ||
| for (let r = 0; r < bodyRules.length; r++) { | ||
| rule = bodyRules[r]; | ||
@@ -30,51 +30,65 @@ if (rule.isSilent && rule.isSilent(this._context) && !rule.blocksVisibility()) { | ||
| return false; | ||
| }; | ||
| CSSVisitorUtils.prototype.keepOnlyVisibleChilds = function (owner) { | ||
| } | ||
| keepOnlyVisibleChilds(owner) { | ||
| if (owner && owner.rules) { | ||
| owner.rules = owner.rules.filter(function (thing) { return thing.isVisible(); }); | ||
| owner.rules = owner.rules.filter(thing => thing.isVisible()); | ||
| } | ||
| }; | ||
| CSSVisitorUtils.prototype.isEmpty = function (owner) { | ||
| return (owner && owner.rules) | ||
| } | ||
| isEmpty(owner) { | ||
| return (owner && owner.rules) | ||
| ? (owner.rules.length === 0) : true; | ||
| }; | ||
| CSSVisitorUtils.prototype.hasVisibleSelector = function (rulesetNode) { | ||
| } | ||
| hasVisibleSelector(rulesetNode) { | ||
| return (rulesetNode && rulesetNode.paths) | ||
| ? (rulesetNode.paths.length > 0) : false; | ||
| }; | ||
| CSSVisitorUtils.prototype.resolveVisibility = function (node) { | ||
| } | ||
| resolveVisibility(node) { | ||
| if (!node.blocksVisibility()) { | ||
| if (this.isEmpty(node)) { | ||
| return; | ||
| return ; | ||
| } | ||
| return node; | ||
| } | ||
| var compiledRulesBody = node.rules[0]; | ||
| const compiledRulesBody = node.rules[0]; | ||
| this.keepOnlyVisibleChilds(compiledRulesBody); | ||
| if (this.isEmpty(compiledRulesBody)) { | ||
| return; | ||
| return ; | ||
| } | ||
| node.ensureVisibility(); | ||
| node.removeVisibilityBlock(); | ||
| return node; | ||
| }; | ||
| CSSVisitorUtils.prototype.isVisibleRuleset = function (rulesetNode) { | ||
| } | ||
| isVisibleRuleset(rulesetNode) { | ||
| if (rulesetNode.firstRoot) { | ||
| return true; | ||
| } | ||
| if (this.isEmpty(rulesetNode)) { | ||
| return false; | ||
| } | ||
| if (!rulesetNode.root && !this.hasVisibleSelector(rulesetNode)) { | ||
| return false; | ||
| } | ||
| return true; | ||
| }; | ||
| return CSSVisitorUtils; | ||
| }()); | ||
| var ToCSSVisitor = function (context) { | ||
| this._visitor = new visitor_1.default(this); | ||
| } | ||
| } | ||
| const ToCSSVisitor = function(context) { | ||
| this._visitor = new Visitor(this); | ||
| this._context = context; | ||
| this.utils = new CSSVisitorUtils(context); | ||
| }; | ||
| ToCSSVisitor.prototype = { | ||
@@ -85,2 +99,3 @@ isReplacing: true, | ||
| }, | ||
| visitDeclaration: function (declNode, visitArgs) { | ||
@@ -92,2 +107,3 @@ if (declNode.blocksVisibility() || declNode.variable) { | ||
| }, | ||
| visitMixinDefinition: function (mixinNode, visitArgs) { | ||
@@ -98,4 +114,6 @@ // mixin definitions do not get eval'd - this means they keep state | ||
| }, | ||
| visitExtend: function (extendNode, visitArgs) { | ||
| }, | ||
| visitComment: function (commentNode, visitArgs) { | ||
@@ -107,23 +125,27 @@ if (commentNode.blocksVisibility() || commentNode.isSilent(this._context)) { | ||
| }, | ||
| visitMedia: function (mediaNode, visitArgs) { | ||
| var originalRules = mediaNode.rules[0].rules; | ||
| visitMedia: function(mediaNode, visitArgs) { | ||
| const originalRules = mediaNode.rules[0].rules; | ||
| mediaNode.accept(this._visitor); | ||
| visitArgs.visitDeeper = false; | ||
| return this.utils.resolveVisibility(mediaNode, originalRules); | ||
| }, | ||
| visitImport: function (importNode, visitArgs) { | ||
| if (importNode.blocksVisibility()) { | ||
| return; | ||
| return ; | ||
| } | ||
| return importNode; | ||
| }, | ||
| visitAtRule: function (atRuleNode, visitArgs) { | ||
| visitAtRule: function(atRuleNode, visitArgs) { | ||
| if (atRuleNode.rules && atRuleNode.rules.length) { | ||
| return this.visitAtRuleWithBody(atRuleNode, visitArgs); | ||
| } | ||
| else { | ||
| } else { | ||
| return this.visitAtRuleWithoutBody(atRuleNode, visitArgs); | ||
| } | ||
| }, | ||
| visitAnonymous: function (anonymousNode, visitArgs) { | ||
| visitAnonymous: function(anonymousNode, visitArgs) { | ||
| if (!anonymousNode.blocksVisibility()) { | ||
@@ -134,14 +156,16 @@ anonymousNode.accept(this._visitor); | ||
| }, | ||
| visitAtRuleWithBody: function (atRuleNode, visitArgs) { | ||
| visitAtRuleWithBody: function(atRuleNode, visitArgs) { | ||
| // if there is only one nested ruleset and that one has no path, then it is | ||
| // just fake ruleset | ||
| function hasFakeRuleset(atRuleNode) { | ||
| var bodyRules = atRuleNode.rules; | ||
| const bodyRules = atRuleNode.rules; | ||
| return bodyRules.length === 1 && (!bodyRules[0].paths || bodyRules[0].paths.length === 0); | ||
| } | ||
| function getBodyRules(atRuleNode) { | ||
| var nodeRules = atRuleNode.rules; | ||
| const nodeRules = atRuleNode.rules; | ||
| if (hasFakeRuleset(atRuleNode)) { | ||
| return nodeRules[0].rules; | ||
| } | ||
| return nodeRules; | ||
@@ -152,14 +176,18 @@ } | ||
| // process childs | ||
| var originalRules = getBodyRules(atRuleNode); | ||
| const originalRules = getBodyRules(atRuleNode); | ||
| atRuleNode.accept(this._visitor); | ||
| visitArgs.visitDeeper = false; | ||
| if (!this.utils.isEmpty(atRuleNode)) { | ||
| this._mergeRules(atRuleNode.rules[0].rules); | ||
| } | ||
| return this.utils.resolveVisibility(atRuleNode, originalRules); | ||
| }, | ||
| visitAtRuleWithoutBody: function (atRuleNode, visitArgs) { | ||
| visitAtRuleWithoutBody: function(atRuleNode, visitArgs) { | ||
| if (atRuleNode.blocksVisibility()) { | ||
| return; | ||
| } | ||
| if (atRuleNode.name === '@charset') { | ||
@@ -171,3 +199,3 @@ // Only output the debug info together with subsequent @charset definitions | ||
| if (atRuleNode.debugInfo) { | ||
| var comment = new tree_1.default.Comment("/* ".concat(atRuleNode.toCSS(this._context).replace(/\n/g, ''), " */\n")); | ||
| const comment = new tree.Comment(`/* ${atRuleNode.toCSS(this._context).replace(/\n/g, '')} */\n`); | ||
| comment.debugInfo = atRuleNode.debugInfo; | ||
@@ -180,36 +208,45 @@ return this._visitor.visit(comment); | ||
| } | ||
| return atRuleNode; | ||
| }, | ||
| checkValidNodes: function (rules, isRoot) { | ||
| checkValidNodes: function(rules, isRoot) { | ||
| if (!rules) { | ||
| return; | ||
| } | ||
| for (var i = 0; i < rules.length; i++) { | ||
| var ruleNode = rules[i]; | ||
| if (isRoot && ruleNode instanceof tree_1.default.Declaration && !ruleNode.variable) { | ||
| for (let i = 0; i < rules.length; i++) { | ||
| const ruleNode = rules[i]; | ||
| if (isRoot && ruleNode instanceof tree.Declaration && !ruleNode.variable) { | ||
| throw { message: 'Properties must be inside selector blocks. They cannot be in the root', | ||
| index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename }; | ||
| index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename}; | ||
| } | ||
| if (ruleNode instanceof tree_1.default.Call) { | ||
| throw { message: "Function '".concat(ruleNode.name, "' did not return a root node"), | ||
| index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename }; | ||
| if (ruleNode instanceof tree.Call) { | ||
| throw { message: `Function '${ruleNode.name}' did not return a root node`, | ||
| index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename}; | ||
| } | ||
| if (ruleNode.type && !ruleNode.allowRoot) { | ||
| throw { message: "".concat(ruleNode.type, " node returned by a function is not valid here"), | ||
| index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename }; | ||
| throw { message: `${ruleNode.type} node returned by a function is not valid here`, | ||
| index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename}; | ||
| } | ||
| } | ||
| }, | ||
| visitRuleset: function (rulesetNode, visitArgs) { | ||
| // at this point rulesets are nested into each other | ||
| var rule; | ||
| var rulesets = []; | ||
| let rule; | ||
| const rulesets = []; | ||
| this.checkValidNodes(rulesetNode.rules, rulesetNode.firstRoot); | ||
| if (!rulesetNode.root) { | ||
| // remove invisible paths | ||
| this._compileRulesetPaths(rulesetNode); | ||
| // remove rulesets from this ruleset body and compile them separately | ||
| var nodeRules = rulesetNode.rules; | ||
| var nodeRuleCnt = nodeRules ? nodeRules.length : 0; | ||
| for (var i = 0; i < nodeRuleCnt;) { | ||
| const nodeRules = rulesetNode.rules; | ||
| let nodeRuleCnt = nodeRules ? nodeRules.length : 0; | ||
| for (let i = 0; i < nodeRuleCnt; ) { | ||
| rule = nodeRules[i]; | ||
@@ -230,12 +267,11 @@ if (rule && rule.rules) { | ||
| rulesetNode.accept(this._visitor); | ||
| } | ||
| else { | ||
| } else { | ||
| rulesetNode.rules = null; | ||
| } | ||
| visitArgs.visitDeeper = false; | ||
| } | ||
| else { // if (! rulesetNode.root) { | ||
| } else { // if (! rulesetNode.root) { | ||
| rulesetNode.accept(this._visitor); | ||
| visitArgs.visitDeeper = false; | ||
| } | ||
| if (rulesetNode.rules) { | ||
@@ -245,2 +281,3 @@ this._mergeRules(rulesetNode.rules); | ||
| } | ||
| // now decide whether we keep the ruleset | ||
@@ -251,2 +288,3 @@ if (this.utils.isVisibleRuleset(rulesetNode)) { | ||
| } | ||
| if (rulesets.length === 1) { | ||
@@ -257,44 +295,42 @@ return rulesets[0]; | ||
| }, | ||
| _compileRulesetPaths: function (rulesetNode) { | ||
| _compileRulesetPaths: function(rulesetNode) { | ||
| if (rulesetNode.paths) { | ||
| rulesetNode.paths = rulesetNode.paths | ||
| .filter(function (p) { | ||
| var i; | ||
| if (p[0].elements[0].combinator.value === ' ') { | ||
| p[0].elements[0].combinator = new (tree_1.default.Combinator)(''); | ||
| } | ||
| for (i = 0; i < p.length; i++) { | ||
| if (p[i].isVisible() && p[i].getIsOutput()) { | ||
| return true; | ||
| .filter(p => { | ||
| let i; | ||
| if (p[0].elements[0].combinator.value === ' ') { | ||
| p[0].elements[0].combinator = new(tree.Combinator)(''); | ||
| } | ||
| } | ||
| return false; | ||
| }); | ||
| for (i = 0; i < p.length; i++) { | ||
| if (p[i].isVisible() && p[i].getIsOutput()) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| }); | ||
| } | ||
| }, | ||
| _removeDuplicateRules: function (rules) { | ||
| if (!rules) { | ||
| return; | ||
| } | ||
| _removeDuplicateRules: function(rules) { | ||
| if (!rules) { return; } | ||
| // remove duplicates | ||
| var ruleCache = {}; | ||
| var ruleList; | ||
| var rule; | ||
| var i; | ||
| for (i = rules.length - 1; i >= 0; i--) { | ||
| rule = rules[i]; | ||
| if (rule instanceof tree_1.default.Declaration) { | ||
| if (!ruleCache[rule.name]) { | ||
| const ruleCache = {}; | ||
| for (let i = rules.length - 1; i >= 0 ; i--) { | ||
| let rule = rules[i]; | ||
| if (rule instanceof tree.Declaration) { | ||
| if (!Object.prototype.hasOwnProperty.call(ruleCache, rule.name)) { | ||
| ruleCache[rule.name] = rule; | ||
| } | ||
| else { | ||
| ruleList = ruleCache[rule.name]; | ||
| if (ruleList instanceof tree_1.default.Declaration) { | ||
| ruleList = ruleCache[rule.name] = [ruleCache[rule.name].toCSS(this._context)]; | ||
| } else { | ||
| let ruleList = ruleCache[rule.name]; | ||
| if (!Array.isArray(ruleList)) { | ||
| const prevRuleCSS = ruleList.toCSS(this._context); | ||
| ruleList = ruleCache[rule.name] = [prevRuleCSS]; | ||
| } | ||
| var ruleCSS = rule.toCSS(this._context); | ||
| const ruleCSS = rule.toCSS(this._context); | ||
| if (ruleList.indexOf(ruleCSS) !== -1) { | ||
| rules.splice(i, 1); | ||
| } | ||
| else { | ||
| } else { | ||
| ruleList.push(ruleCSS); | ||
@@ -306,35 +342,6 @@ } | ||
| }, | ||
| _mergeRules: function (rules) { | ||
| if (!rules) { | ||
| return; | ||
| } | ||
| var groups = {}; | ||
| var groupsArr = []; | ||
| for (var i = 0; i < rules.length; i++) { | ||
| var rule = rules[i]; | ||
| if (rule.merge) { | ||
| var key = rule.name; | ||
| groups[key] ? rules.splice(i--, 1) : | ||
| groupsArr.push(groups[key] = []); | ||
| groups[key].push(rule); | ||
| } | ||
| } | ||
| groupsArr.forEach(function (group) { | ||
| if (group.length > 0) { | ||
| var result_1 = group[0]; | ||
| var space_1 = []; | ||
| var comma_1 = [new tree_1.default.Expression(space_1)]; | ||
| group.forEach(function (rule) { | ||
| if ((rule.merge === '+') && (space_1.length > 0)) { | ||
| comma_1.push(new tree_1.default.Expression(space_1 = [])); | ||
| } | ||
| space_1.push(rule.value); | ||
| result_1.important = result_1.important || rule.important; | ||
| }); | ||
| result_1.value = new tree_1.default.Value(comma_1); | ||
| } | ||
| }); | ||
| } | ||
| _mergeRules: mergeRules | ||
| }; | ||
| exports.default = ToCSSVisitor; | ||
| //# sourceMappingURL=to-css-visitor.js.map | ||
| export default ToCSSVisitor; |
@@ -1,14 +0,14 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var tree_1 = tslib_1.__importDefault(require("../tree")); | ||
| var _visitArgs = { visitDeeper: true }; | ||
| var _hasIndexed = false; | ||
| import tree from '../tree/index.js'; | ||
| const _visitArgs = { visitDeeper: true }; | ||
| let _hasIndexed = false; | ||
| function _noop(node) { | ||
| return node; | ||
| } | ||
| function indexNodeTypes(parent, ticker) { | ||
| // add .typeIndex to tree node types for lookup table | ||
| var key, child; | ||
| for (key in parent) { | ||
| let key, child; | ||
| for (key in parent) { | ||
| /* eslint guard-for-in: 0 */ | ||
@@ -27,2 +27,3 @@ child = parent[key]; | ||
| break; | ||
| } | ||
@@ -32,17 +33,21 @@ } | ||
| } | ||
| var Visitor = /** @class */ (function () { | ||
| function Visitor(implementation) { | ||
| class Visitor { | ||
| constructor(implementation) { | ||
| this._implementation = implementation; | ||
| this._visitInCache = {}; | ||
| this._visitOutCache = {}; | ||
| if (!_hasIndexed) { | ||
| indexNodeTypes(tree_1.default, 1); | ||
| indexNodeTypes(tree, 1); | ||
| _hasIndexed = true; | ||
| } | ||
| } | ||
| Visitor.prototype.visit = function (node) { | ||
| visit(node) { | ||
| if (!node) { | ||
| return node; | ||
| } | ||
| var nodeTypeIndex = node.typeIndex; | ||
| const nodeTypeIndex = node.typeIndex; | ||
| if (!nodeTypeIndex) { | ||
@@ -55,17 +60,21 @@ // MixinCall args aren't a node type? | ||
| } | ||
| var impl = this._implementation; | ||
| var func = this._visitInCache[nodeTypeIndex]; | ||
| var funcOut = this._visitOutCache[nodeTypeIndex]; | ||
| var visitArgs = _visitArgs; | ||
| var fnName; | ||
| const impl = this._implementation; | ||
| let func = this._visitInCache[nodeTypeIndex]; | ||
| let funcOut = this._visitOutCache[nodeTypeIndex]; | ||
| const visitArgs = _visitArgs; | ||
| let fnName; | ||
| visitArgs.visitDeeper = true; | ||
| if (!func) { | ||
| fnName = "visit".concat(node.type); | ||
| fnName = `visit${node.type}`; | ||
| func = impl[fnName] || _noop; | ||
| funcOut = impl["".concat(fnName, "Out")] || _noop; | ||
| funcOut = impl[`${fnName}Out`] || _noop; | ||
| this._visitInCache[nodeTypeIndex] = func; | ||
| this._visitOutCache[nodeTypeIndex] = funcOut; | ||
| } | ||
| if (func !== _noop) { | ||
| var newNode = func.call(impl, node, visitArgs); | ||
| const newNode = func.call(impl, node, visitArgs); | ||
| if (node && impl.isReplacing) { | ||
@@ -75,5 +84,6 @@ node = newNode; | ||
| } | ||
| if (visitArgs.visitDeeper && node) { | ||
| if (node.length) { | ||
| for (var i = 0, cnt = node.length; i < cnt; i++) { | ||
| for (let i = 0, cnt = node.length; i < cnt; i++) { | ||
| if (node[i].accept) { | ||
@@ -83,18 +93,22 @@ node[i].accept(this); | ||
| } | ||
| } | ||
| else if (node.accept) { | ||
| } else if (node.accept) { | ||
| node.accept(this); | ||
| } | ||
| } | ||
| if (funcOut != _noop) { | ||
| funcOut.call(impl, node); | ||
| } | ||
| return node; | ||
| }; | ||
| Visitor.prototype.visitArray = function (nodes, nonReplacing) { | ||
| } | ||
| visitArray(nodes, nonReplacing) { | ||
| if (!nodes) { | ||
| return nodes; | ||
| } | ||
| var cnt = nodes.length; | ||
| var i; | ||
| const cnt = nodes.length; | ||
| let i; | ||
| // Non-replacing | ||
@@ -107,13 +121,11 @@ if (nonReplacing || !this._implementation.isReplacing) { | ||
| } | ||
| // Replacing | ||
| var out = []; | ||
| const out = []; | ||
| for (i = 0; i < cnt; i++) { | ||
| var evald = this.visit(nodes[i]); | ||
| if (evald === undefined) { | ||
| continue; | ||
| } | ||
| const evald = this.visit(nodes[i]); | ||
| if (evald === undefined) { continue; } | ||
| if (!evald.splice) { | ||
| out.push(evald); | ||
| } | ||
| else if (evald.length) { | ||
| } else if (evald.length) { | ||
| this.flatten(evald, out); | ||
@@ -123,8 +135,11 @@ } | ||
| return out; | ||
| }; | ||
| Visitor.prototype.flatten = function (arr, out) { | ||
| } | ||
| flatten(arr, out) { | ||
| if (!out) { | ||
| out = []; | ||
| } | ||
| var cnt, i, item, nestedCnt, j, nestedItem; | ||
| let cnt, i, item, nestedCnt, j, nestedItem; | ||
| for (i = 0, cnt = arr.length; i < cnt; i++) { | ||
@@ -139,2 +154,3 @@ item = arr[i]; | ||
| } | ||
| for (j = 0, nestedCnt = item.length; j < nestedCnt; j++) { | ||
@@ -147,4 +163,3 @@ nestedItem = item[j]; | ||
| out.push(nestedItem); | ||
| } | ||
| else if (nestedItem.length) { | ||
| } else if (nestedItem.length) { | ||
| this.flatten(nestedItem, out); | ||
@@ -154,7 +169,7 @@ } | ||
| } | ||
| return out; | ||
| }; | ||
| return Visitor; | ||
| }()); | ||
| exports.default = Visitor; | ||
| //# sourceMappingURL=visitor.js.map | ||
| } | ||
| } | ||
| export default Visitor; |
+25
-18
| { | ||
| "name": "less", | ||
| "version": "4.5.1", | ||
| "version": "4.6.0", | ||
| "description": "Leaner CSS", | ||
@@ -25,13 +25,25 @@ "homepage": "http://lesscss.org", | ||
| "license": "Apache-2.0", | ||
| "type": "module", | ||
| "bin": { | ||
| "lessc": "./bin/lessc" | ||
| }, | ||
| "main": "index", | ||
| "module": "./lib/less-node/index", | ||
| "main": "./lib/less-node/index.js", | ||
| "exports": { | ||
| ".": "./lib/less-node/index.js", | ||
| "./lib/*": "./lib/*" | ||
| }, | ||
| "directories": { | ||
| "test": "./test" | ||
| }, | ||
| "files": [ | ||
| "bin", | ||
| "lib", | ||
| "!lib/**/*.map", | ||
| "dist", | ||
| "index.js", | ||
| "README.md" | ||
| ], | ||
| "browser": "./dist/less.js", | ||
| "engines": { | ||
| "node": ">=14" | ||
| "node": ">=18" | ||
| }, | ||
@@ -45,8 +57,5 @@ "scripts": { | ||
| "lint:fix": "eslint '**/*.{ts,js}' --fix", | ||
| "build": "npm-run-all clean compile", | ||
| "clean": "shx rm -rf ./lib tsconfig.tsbuildinfo", | ||
| "compile": "tsc -p tsconfig.build.json", | ||
| "dev": "tsc -p tsconfig.build.json -w", | ||
| "prepublishOnly": "grunt dist", | ||
| "postinstall": "node scripts/postinstall.js" | ||
| "typecheck": "tsc --noEmit", | ||
| "build": "node build/rollup.js --dist", | ||
| "prepublishOnly": "npm run typecheck && grunt dist" | ||
| }, | ||
@@ -68,2 +77,3 @@ "optionalDependencies": { | ||
| "@rollup/plugin-node-resolve": "^11.0.0", | ||
| "@types/node": "^18", | ||
| "@typescript-eslint/eslint-plugin": "^4.28.0", | ||
@@ -73,4 +83,4 @@ "@typescript-eslint/parser": "^4.28.0", | ||
| "bootstrap-less-port": "0.3.0", | ||
| "c8": "^10.1.3", | ||
| "chai": "^4.2.0", | ||
| "c8": "^10.1.3", | ||
| "chalk": "^4.1.2", | ||
@@ -84,3 +94,3 @@ "cosmiconfig": "~9.0.0", | ||
| "globby": "^10.0.1", | ||
| "grunt": "^1.0.4", | ||
| "grunt": "^1.5.0", | ||
| "grunt-cli": "^1.3.2", | ||
@@ -109,8 +119,6 @@ "grunt-contrib-clean": "^1.0.0", | ||
| "rollup-plugin-terser": "^5.1.1", | ||
| "rollup-plugin-typescript2": "^0.29.0", | ||
| "semver": "^6.3.0", | ||
| "shx": "^0.3.2", | ||
| "time-grunt": "^1.3.0", | ||
| "ts-node": "^10.9.1", | ||
| "typescript": "^4.3.4", | ||
| "typescript": "^5.7.0", | ||
| "uikit": "2.27.4" | ||
@@ -146,7 +154,6 @@ }, | ||
| "dependencies": { | ||
| "copy-anything": "^2.0.1", | ||
| "parse-node-version": "^1.0.1", | ||
| "tslib": "^2.3.0" | ||
| "copy-anything": "^3.0.5", | ||
| "parse-node-version": "^1.0.1" | ||
| }, | ||
| "gitHead": "1df9072ee9ebdadc791bf35dfb1dbc3ef9f1948f" | ||
| } |
Sorry, the diff of this file is not supported yet
-63
| module.exports = { | ||
| 'parser': '@typescript-eslint/parser', | ||
| 'extends': 'eslint:recommended', | ||
| 'parserOptions': { | ||
| 'ecmaVersion': 2018, | ||
| 'sourceType': 'module' | ||
| }, | ||
| 'plugins': ['@typescript-eslint'], | ||
| 'env': { | ||
| 'browser': true, | ||
| 'node': true, | ||
| 'mocha': true | ||
| }, | ||
| 'globals': {}, | ||
| 'rules': { | ||
| indent: ['error', 4, { | ||
| SwitchCase: 1 | ||
| }], | ||
| 'no-empty': ['error', { 'allowEmptyCatch': true }], | ||
| quotes: ['error', 'single', { | ||
| avoidEscape: true | ||
| }], | ||
| /** | ||
| * The codebase uses some while(true) statements. | ||
| * Refactor to remove this rule. | ||
| */ | ||
| 'no-constant-condition': 0, | ||
| /** | ||
| * Less combines assignments with conditionals sometimes | ||
| */ | ||
| 'no-cond-assign': 0, | ||
| /** | ||
| * @todo - remove when some kind of code style (XO?) is added | ||
| */ | ||
| 'no-multiple-empty-lines': 'error' | ||
| }, | ||
| 'overrides': [ | ||
| { | ||
| files: ['*.ts'], | ||
| extends: ['plugin:@typescript-eslint/recommended'], | ||
| rules: { | ||
| /** | ||
| * Suppress until Less has better-defined types | ||
| * @see https://github.com/less/less.js/discussions/3786 | ||
| */ | ||
| '@typescript-eslint/no-explicit-any': 0 | ||
| } | ||
| }, | ||
| { | ||
| files: ['test/**/*.{js,ts}', 'benchmark/index.js'], | ||
| /** | ||
| * @todo - fix later | ||
| */ | ||
| rules: { | ||
| 'no-undef': 0, | ||
| 'no-useless-escape': 0, | ||
| 'no-unused-vars': 0, | ||
| 'no-redeclare': 0, | ||
| '@typescript-eslint/no-unused-vars': 0 | ||
| } | ||
| }, | ||
| ] | ||
| } |
-22
| { | ||
| "name": "less", | ||
| "main": "dist/less.js", | ||
| "ignore": [ | ||
| "**/.*", | ||
| "benchmark", | ||
| "bin", | ||
| "lib", | ||
| "src", | ||
| "build", | ||
| "test", | ||
| "*.md", | ||
| "LICENSE", | ||
| "Gruntfile.js", | ||
| "*.json", | ||
| "*.yml", | ||
| ".gitattributes", | ||
| ".npmignore", | ||
| ".eslintignore", | ||
| "tsconfig.json" | ||
| ] | ||
| } |
-403
| "use strict"; | ||
| var resolve = require('resolve'); | ||
| var path = require('path'); | ||
| var testFolder = path.relative(process.cwd(), path.dirname(resolve.sync('@less/test-data'))); | ||
| var lessFolder = testFolder; | ||
| module.exports = function(grunt) { | ||
| grunt.option("stack", true); | ||
| // Report the elapsed execution time of tasks. | ||
| require("time-grunt")(grunt); | ||
| var git = require("git-rev"); | ||
| // Sauce Labs browser | ||
| var browsers = [ | ||
| // Desktop browsers | ||
| { | ||
| browserName: "chrome", | ||
| version: "latest", | ||
| platform: "Windows 7" | ||
| }, | ||
| { | ||
| browserName: "firefox", | ||
| version: "latest", | ||
| platform: "Linux" | ||
| }, | ||
| { | ||
| browserName: "safari", | ||
| version: "9", | ||
| platform: "OS X 10.11" | ||
| }, | ||
| { | ||
| browserName: "internet explorer", | ||
| version: "8", | ||
| platform: "Windows XP" | ||
| }, | ||
| { | ||
| browserName: "internet explorer", | ||
| version: "11", | ||
| platform: "Windows 8.1" | ||
| }, | ||
| { | ||
| browserName: "edge", | ||
| version: "13", | ||
| platform: "Windows 10" | ||
| }, | ||
| // Mobile browsers | ||
| { | ||
| browserName: "ipad", | ||
| deviceName: "iPad Air Simulator", | ||
| deviceOrientation: "portrait", | ||
| version: "8.4", | ||
| platform: "OS X 10.9" | ||
| }, | ||
| { | ||
| browserName: "iphone", | ||
| deviceName: "iPhone 5 Simulator", | ||
| deviceOrientation: "portrait", | ||
| version: "9.3", | ||
| platform: "OS X 10.11" | ||
| }, | ||
| { | ||
| browserName: "android", | ||
| deviceName: "Google Nexus 7 HD Emulator", | ||
| deviceOrientation: "portrait", | ||
| version: "4.4", | ||
| platform: "Linux" | ||
| } | ||
| ]; | ||
| var sauceJobs = {}; | ||
| var browserTests = [ | ||
| "filemanager-plugin", | ||
| "visitor-plugin", | ||
| "global-vars", | ||
| "modify-vars", | ||
| "production", | ||
| "rootpath-relative", | ||
| "rootpath-rewrite-urls", | ||
| "rootpath", | ||
| "relative-urls", | ||
| "rewrite-urls", | ||
| "browser", | ||
| "no-js-errors" | ||
| ]; | ||
| function makeJob(testName) { | ||
| sauceJobs[testName] = { | ||
| options: { | ||
| urls: | ||
| testName === "all" | ||
| ? browserTests.map(function(name) { | ||
| return ( | ||
| "http://localhost:8081/tmp/browser/test-runner-" + | ||
| name + | ||
| ".html" | ||
| ); | ||
| }) | ||
| : [ | ||
| "http://localhost:8081/tmp/browser/test-runner-" + | ||
| testName + | ||
| ".html" | ||
| ], | ||
| testname: | ||
| testName === "all" ? "Unit Tests for Less.js" : testName, | ||
| browsers: browsers, | ||
| public: "public", | ||
| recordVideo: false, | ||
| videoUploadOnPass: false, | ||
| recordScreenshots: process.env.TRAVIS_BRANCH !== "master", | ||
| build: | ||
| process.env.TRAVIS_BRANCH === "master" | ||
| ? process.env.TRAVIS_JOB_ID | ||
| : undefined, | ||
| tags: [ | ||
| process.env.TRAVIS_BUILD_NUMBER, | ||
| process.env.TRAVIS_PULL_REQUEST, | ||
| process.env.TRAVIS_BRANCH | ||
| ], | ||
| statusCheckAttempts: -1, | ||
| sauceConfig: { | ||
| "idle-timeout": 100 | ||
| }, | ||
| throttled: 5, | ||
| onTestComplete: function(result, callback) { | ||
| // Called after a unit test is done, per page, per browser | ||
| // 'result' param is the object returned by the test framework's reporter | ||
| // 'callback' is a Node.js style callback function. You must invoke it after you | ||
| // finish your work. | ||
| // Pass a non-null value as the callback's first parameter if you want to throw an | ||
| // exception. If your function is synchronous you can also throw exceptions | ||
| // directly. | ||
| // Passing true or false as the callback's second parameter passes or fails the | ||
| // test. Passing undefined does not alter the test result. Please note that this | ||
| // only affects the grunt task's result. You have to explicitly update the Sauce | ||
| // Labs job's status via its REST API, if you want so. | ||
| // This should be the encrypted value in Travis | ||
| var user = process.env.SAUCE_USERNAME; | ||
| var pass = process.env.SAUCE_ACCESS_KEY; | ||
| git.short(function(hash) { | ||
| require("phin")( | ||
| { | ||
| method: "PUT", | ||
| url: [ | ||
| "https://saucelabs.com/rest/v1", | ||
| user, | ||
| "jobs", | ||
| result.job_id | ||
| ].join("/"), | ||
| auth: { user: user, pass: pass }, | ||
| data: { | ||
| passed: result.passed, | ||
| build: "build-" + hash | ||
| } | ||
| }, | ||
| function(error, response) { | ||
| if (error) { | ||
| console.log(error); | ||
| callback(error); | ||
| } else if (response.statusCode !== 200) { | ||
| console.log(response); | ||
| callback( | ||
| new Error("Unexpected response status") | ||
| ); | ||
| } else { | ||
| callback(null, result.passed); | ||
| } | ||
| } | ||
| ); | ||
| }); | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| // Make the SauceLabs jobs | ||
| ["all"].concat(browserTests).map(makeJob); | ||
| // Project configuration. | ||
| grunt.initConfig({ | ||
| shell: { | ||
| options: { | ||
| stdout: true, | ||
| failOnError: true, | ||
| execOptions: { | ||
| maxBuffer: Infinity | ||
| } | ||
| }, | ||
| build: { | ||
| command: [ | ||
| /** Browser runtime */ | ||
| "node build/rollup.js --dist", | ||
| /** Node.js runtime */ | ||
| "npm run build" | ||
| ].join(" && ") | ||
| }, | ||
| testbuild: { | ||
| command: [ | ||
| "npm run build", | ||
| "node build/rollup.js --browser --out=./tmp/browser/less.min.js" | ||
| ].join(" && ") | ||
| }, | ||
| testcjs: { | ||
| command: "npm run build" | ||
| }, | ||
| testbrowser: { | ||
| command: "node build/rollup.js --browser --out=./tmp/browser/less.min.js" | ||
| }, | ||
| test: { | ||
| command: 'npx ts-node test/test-es6.ts && node test/index.js' | ||
| }, | ||
| generatebrowser: { | ||
| command: 'node test/browser/generator/generate.js' | ||
| }, | ||
| runbrowser: { | ||
| command: 'node test/browser/generator/runner.js' | ||
| }, | ||
| benchmark: { | ||
| command: "node benchmark/index.js" | ||
| }, | ||
| opts: { | ||
| // test running with all current options (using `opts` since `options` means something already) | ||
| command: [ | ||
| // @TODO: make this more thorough | ||
| // CURRENT OPTIONS | ||
| `node bin/lessc --ie-compat ${lessFolder}/tests-unit/lazy-eval/lazy-eval.less tmp/lazy-eval.css`, | ||
| // --math | ||
| `node bin/lessc --math=always ${lessFolder}/tests-unit/lazy-eval/lazy-eval.less tmp/lazy-eval.css`, | ||
| `node bin/lessc --math=parens-division ${lessFolder}/tests-unit/lazy-eval/lazy-eval.less tmp/lazy-eval.css`, | ||
| `node bin/lessc --math=parens ${lessFolder}/tests-unit/lazy-eval/lazy-eval.less tmp/lazy-eval.css`, | ||
| `node bin/lessc --math=strict ${lessFolder}/tests-unit/lazy-eval/lazy-eval.less tmp/lazy-eval.css`, | ||
| `node bin/lessc --math=strict-legacy ${lessFolder}/tests-unit/lazy-eval/lazy-eval.less tmp/lazy-eval.css`, | ||
| // DEPRECATED OPTIONS | ||
| // --strict-math | ||
| `node bin/lessc --strict-math=on ${lessFolder}/tests-unit/lazy-eval/lazy-eval.less tmp/lazy-eval.css` | ||
| ].join(" && ") | ||
| }, | ||
| plugin: { | ||
| command: [ | ||
| `node bin/lessc --clean-css="--s1 --advanced" ${lessFolder}/tests-unit/lazy-eval/lazy-eval.less tmp/lazy-eval.css`, | ||
| "cd lib", | ||
| `node ../bin/lessc --clean-css="--s1 --advanced" ../${lessFolder}/tests-unit/lazy-eval/lazy-eval.less ../tmp/lazy-eval.css`, | ||
| `node ../bin/lessc --source-map=lazy-eval.css.map --autoprefix ../${lessFolder}/tests-unit/lazy-eval/lazy-eval.less ../tmp/lazy-eval.css`, | ||
| "cd ..", | ||
| // Test multiple plugins | ||
| `node bin/lessc --plugin=clean-css="--s1 --advanced" --plugin=autoprefix="ie 11,Edge >= 13,Chrome >= 47,Firefox >= 45,iOS >= 9.2,Safari >= 9" ${lessFolder}/tests-unit/lazy-eval/lazy-eval.less tmp/lazy-eval.css` | ||
| ].join(" && ") | ||
| }, | ||
| "sourcemap-test": { | ||
| // quoted value doesn't seem to get picked up by time-grunt, or isn't output, at least; maybe just "sourcemap" is fine? | ||
| command: [ | ||
| `node bin/lessc --source-map=test/sourcemaps/maps/import-map.map ${lessFolder}/tests-unit/import/import.less test/sourcemaps/import.css`, | ||
| `node bin/lessc --source-map ${lessFolder}/tests-config/sourcemaps/basic.less test/sourcemaps/basic.css` | ||
| ].join(" && ") | ||
| } | ||
| }, | ||
| eslint: { | ||
| target: [ | ||
| "test/**/*.js", | ||
| "src/less*/**/*.js", | ||
| "!test/less/errors/plugin/plugin-error.js" | ||
| ], | ||
| options: { | ||
| configFile: ".eslintrc.js", | ||
| fix: true | ||
| } | ||
| }, | ||
| connect: { | ||
| server: { | ||
| options: { | ||
| port: 8081, | ||
| base: '../..' | ||
| } | ||
| } | ||
| }, | ||
| "saucelabs-mocha": sauceJobs, | ||
| // Clean the version of less built for the tests | ||
| clean: { | ||
| test: ["test/browser/less.js", "tmp", "test/less-bom"], | ||
| "sourcemap-test": [ | ||
| "test/sourcemaps/*.css", | ||
| "test/sourcemaps/*.map" | ||
| ], | ||
| sauce_log: ["sc_*.log"] | ||
| } | ||
| }); | ||
| // Load these plugins to provide the necessary tasks | ||
| grunt.loadNpmTasks("grunt-saucelabs"); | ||
| require("jit-grunt")(grunt); | ||
| // by default, run tests | ||
| grunt.registerTask("default", ["test"]); | ||
| // Release | ||
| grunt.registerTask("dist", [ | ||
| "shell:build" | ||
| ]); | ||
| // Create the browser version of less.js | ||
| grunt.registerTask("browsertest-lessjs", [ | ||
| "shell:testbrowser" | ||
| ]); | ||
| // Run all browser tests | ||
| grunt.registerTask("browsertest", [ | ||
| "browsertest-lessjs", | ||
| "connect", | ||
| "shell:runbrowser" | ||
| ]); | ||
| // setup a web server to run the browser tests in a browser rather than phantom | ||
| grunt.registerTask("browsertest-server", [ | ||
| "browsertest-lessjs", | ||
| "shell:generatebrowser", | ||
| "connect::keepalive" | ||
| ]); | ||
| var previous_force_state = grunt.option("force"); | ||
| grunt.registerTask("force", function(set) { | ||
| if (set === "on") { | ||
| grunt.option("force", true); | ||
| } else if (set === "off") { | ||
| grunt.option("force", false); | ||
| } else if (set === "restore") { | ||
| grunt.option("force", previous_force_state); | ||
| } | ||
| }); | ||
| grunt.registerTask("sauce", [ | ||
| "browsertest-lessjs", | ||
| "shell:generatebrowser", | ||
| "connect", | ||
| "sauce-after-setup" | ||
| ]); | ||
| grunt.registerTask("sauce-after-setup", [ | ||
| "saucelabs-mocha:all", | ||
| "clean:sauce_log" | ||
| ]); | ||
| var testTasks = [ | ||
| "clean", | ||
| "eslint", | ||
| "shell:testbuild", | ||
| "shell:test", | ||
| "shell:opts", | ||
| "shell:plugin", | ||
| "connect", | ||
| "shell:runbrowser" | ||
| ]; | ||
| if ( | ||
| isNaN(Number(process.env.TRAVIS_PULL_REQUEST, 10)) && | ||
| (process.env.TRAVIS_BRANCH === "master") | ||
| ) { | ||
| testTasks.push("force:on"); | ||
| testTasks.push("sauce-after-setup"); | ||
| testTasks.push("force:off"); | ||
| } | ||
| // Run all tests | ||
| grunt.registerTask("test", testTasks); | ||
| // Run shell option tests (includes deprecated options) | ||
| grunt.registerTask("shell-options", ["shell:opts"]); | ||
| // Run shell plugin test | ||
| grunt.registerTask("shell-plugin", ["shell:plugin"]); | ||
| // Quickly build and run Node tests | ||
| grunt.registerTask("quicktest", [ | ||
| "shell:testcjs", | ||
| "shell:test" | ||
| ]); | ||
| // generate a good test environment for testing sourcemaps | ||
| grunt.registerTask("sourcemap-test", [ | ||
| "clean:sourcemap-test", | ||
| "shell:build:lessc", | ||
| "shell:sourcemap-test", | ||
| "connect::keepalive" | ||
| ]); | ||
| // Run benchmark | ||
| grunt.registerTask("benchmark", [ | ||
| "shell:testcjs", | ||
| "shell:benchmark" | ||
| ]); | ||
| }; |
| {"version":3,"file":"add-default-options.js","sourceRoot":"","sources":["../../src/less-browser/add-default-options.js"],"names":[],"mappings":";;;AAAA,iCAAoC;AACpC,8DAAgC;AAEhC,mBAAe,UAAC,MAAM,EAAE,OAAO;IAE3B,yDAAyD;IACzD,IAAA,mBAAW,EAAC,OAAO,EAAE,iBAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IAEpD,IAAI,OAAO,CAAC,cAAc,KAAK,SAAS,EAAE;QACtC,OAAO,CAAC,cAAc,GAAG,wDAAwD,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;KACpH;IAED,8CAA8C;IAC9C,EAAE;IACF,sDAAsD;IACtD,2DAA2D;IAC3D,mDAAmD;IACnD,EAAE;IACF,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;IACvC,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;IAE/C,+BAA+B;IAC/B,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAEtE,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,IAAI,WAAW;QACjE,MAAM,CAAC,QAAQ,CAAC,QAAQ,IAAI,SAAS;QACrC,MAAM,CAAC,QAAQ,CAAC,QAAQ,IAAI,WAAW;QACvC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI;YACjB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QACpC,OAAO,CAAC,cAAc,CAAmB,CAAC,CAAC,aAAa;QACxD,CAAC,CAAC,YAAY,CAAC,CAAC;IAEpB,IAAM,eAAe,GAAG,4CAA4C,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAChG,IAAI,eAAe,EAAE;QACjB,OAAO,CAAC,eAAe,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;KAChD;IAED,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;QACpC,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;KAC/B;IAED,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE;QAC/B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;KAC1B;IAED,IAAI,OAAO,CAAC,YAAY,EAAE;QACtB,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC;KAC/B;AACL,CAAC,EAAC","sourcesContent":["import {addDataAttr} from './utils';\nimport browser from './browser';\n\nexport default (window, options) => {\n\n // use options from the current script tag data attribues\n addDataAttr(options, browser.currentScript(window));\n\n if (options.isFileProtocol === undefined) {\n options.isFileProtocol = /^(file|(chrome|safari)(-extension)?|resource|qrc|app):/.test(window.location.protocol);\n }\n\n // Load styles asynchronously (default: false)\n //\n // This is set to `false` by default, so that the body\n // doesn't start loading before the stylesheets are parsed.\n // Setting this to `true` can result in flickering.\n //\n options.async = options.async || false;\n options.fileAsync = options.fileAsync || false;\n\n // Interval between watch polls\n options.poll = options.poll || (options.isFileProtocol ? 1000 : 1500);\n\n options.env = options.env || (window.location.hostname == '127.0.0.1' ||\n window.location.hostname == '0.0.0.0' ||\n window.location.hostname == 'localhost' ||\n (window.location.port &&\n window.location.port.length > 0) ||\n options.isFileProtocol ? 'development'\n : 'production');\n\n const dumpLineNumbers = /!dumpLineNumbers:(comments|mediaquery|all)/.exec(window.location.hash);\n if (dumpLineNumbers) {\n options.dumpLineNumbers = dumpLineNumbers[1];\n }\n\n if (options.useFileCache === undefined) {\n options.useFileCache = true;\n }\n\n if (options.onReady === undefined) {\n options.onReady = true;\n }\n\n if (options.relativeUrls) {\n options.rewriteUrls = 'all';\n }\n};\n"]} |
| {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/less-browser/bootstrap.js"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,oFAAqD;AACrD,sFAAsD;AACtD,0DAA2B;AAE3B,IAAM,OAAO,GAAG,IAAA,yBAAc,GAAE,CAAC;AAEjC,IAAI,MAAM,CAAC,IAAI,EAAE;IACb,KAAK,IAAM,GAAG,IAAI,MAAM,CAAC,IAAI,EAAE;QAC3B,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE;YACxD,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACnC;KACJ;CACJ;AACD,IAAA,6BAAiB,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;AAExC,IAAI,MAAM,CAAC,YAAY,EAAE;IACrB,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;CACjE;AAED,IAAM,IAAI,GAAG,IAAA,eAAI,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACnC,kBAAe,IAAI,CAAC;AAEpB,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;AAEnB,IAAI,GAAG,CAAC;AACR,IAAI,IAAI,CAAC;AACT,IAAI,KAAK,CAAC;AAEV,iCAAiC;AACjC,SAAS,eAAe,CAAC,IAAI;IACzB,IAAI,IAAI,CAAC,QAAQ,EAAE;QACf,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACtB;IACD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;QAChB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;KAC3B;AACL,CAAC;AAED,IAAI,OAAO,CAAC,OAAO,EAAE;IACjB,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;QACrC,IAAI,CAAC,KAAK,EAAE,CAAC;KAChB;IACD,mEAAmE;IACnE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;QAChB,GAAG,GAAG,mCAAmC,CAAC;QAC1C,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACjE,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAExC,KAAK,CAAC,IAAI,GAAG,UAAU,CAAC;QACxB,IAAI,KAAK,CAAC,UAAU,EAAE;YAClB,KAAK,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG,CAAC;SAClC;aAAM;YACH,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;SACnD;QAED,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;KAC3B;IACD,IAAI,CAAC,8BAA8B,EAAE,CAAC;IACtC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;CAC3G","sourcesContent":["/**\n * Kicks off less and compiles any stylesheets\n * used in the browser distributed version of less\n * to kick-start less using the browser api\n */\nimport defaultOptions from '../less/default-options';\nimport addDefaultOptions from './add-default-options';\nimport root from './index';\n\nconst options = defaultOptions();\n\nif (window.less) {\n for (const key in window.less) {\n if (Object.prototype.hasOwnProperty.call(window.less, key)) {\n options[key] = window.less[key];\n }\n }\n}\naddDefaultOptions(window, options);\n\noptions.plugins = options.plugins || [];\n\nif (window.LESS_PLUGINS) {\n options.plugins = options.plugins.concat(window.LESS_PLUGINS);\n}\n\nconst less = root(window, options);\nexport default less;\n\nwindow.less = less;\n\nlet css;\nlet head;\nlet style;\n\n// Always restore page visibility\nfunction resolveOrReject(data) {\n if (data.filename) {\n console.warn(data);\n }\n if (!options.async) {\n head.removeChild(style);\n }\n}\n\nif (options.onReady) {\n if (/!watch/.test(window.location.hash)) {\n less.watch();\n }\n // Simulate synchronous stylesheet loading by hiding page rendering\n if (!options.async) {\n css = 'body { display: none !important }';\n head = document.head || document.getElementsByTagName('head')[0];\n style = document.createElement('style');\n\n style.type = 'text/css';\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n\n head.appendChild(style);\n }\n less.registerStylesheetsImmediately();\n less.pageLoadFinished = less.refresh(less.env === 'development').then(resolveOrReject, resolveOrReject);\n}\n"]} |
| {"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/less-browser/browser.js"],"names":[],"mappings":";;;AAAA,qDAAiC;AAEjC,kBAAe;IACX,SAAS,EAAE,UAAU,QAAQ,EAAE,MAAM,EAAE,KAAK;QACxC,yBAAyB;QACzB,IAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;QAE9B,kEAAkE;QAClE,IAAM,EAAE,GAAG,eAAQ,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAE,CAAC;QAE1D,4EAA4E;QAC5E,IAAM,YAAY,GAAG,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QACjD,IAAI,gBAAgB,GAAG,KAAK,CAAC;QAE7B,2EAA2E;QAC3E,IAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAClD,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAC3C,IAAI,KAAK,CAAC,KAAK,EAAE;YACb,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,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IACD,aAAa,EAAE,UAAS,MAAM;QAC1B,IAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QACjC,OAAO,QAAQ,CAAC,aAAa,IAAI,CAAC;YAC9B,IAAM,OAAO,GAAG,QAAQ,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;YACxD,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC,EAAE,CAAC;IACT,CAAC;CACJ,CAAC","sourcesContent":["import * as utils from './utils';\n\nexport default {\n createCSS: function (document, styles, sheet) {\n // Strip the query-string\n const href = sheet.href || '';\n\n // If there is no title set, use the filename, minus the extension\n const id = `less:${sheet.title || utils.extractId(href)}`;\n\n // If this has already been inserted into the DOM, we may need to replace it\n const oldStyleNode = document.getElementById(id);\n let keepOldStyleNode = false;\n\n // Create a new stylesheet node for insertion or (if necessary) replacement\n const styleNode = document.createElement('style');\n styleNode.setAttribute('type', 'text/css');\n if (sheet.media) {\n styleNode.setAttribute('media', sheet.media);\n }\n styleNode.id = id;\n\n if (!styleNode.styleSheet) {\n styleNode.appendChild(document.createTextNode(styles));\n\n // If new contents match contents of oldStyleNode, don't replace oldStyleNode\n keepOldStyleNode = (oldStyleNode !== null && oldStyleNode.childNodes.length > 0 && styleNode.childNodes.length > 0 &&\n oldStyleNode.firstChild.nodeValue === styleNode.firstChild.nodeValue);\n }\n\n const head = document.getElementsByTagName('head')[0];\n\n // If there is no oldStyleNode, just append; otherwise, only append if we need\n // to replace oldStyleNode with an updated stylesheet\n if (oldStyleNode === null || keepOldStyleNode === false) {\n const nextEl = sheet && sheet.nextSibling || null;\n if (nextEl) {\n nextEl.parentNode.insertBefore(styleNode, nextEl);\n } else {\n head.appendChild(styleNode);\n }\n }\n if (oldStyleNode && keepOldStyleNode === false) {\n oldStyleNode.parentNode.removeChild(oldStyleNode);\n }\n\n // For IE.\n // This needs to happen *after* the style element is added to the DOM, otherwise IE 7 and 8 may crash.\n // See http://social.msdn.microsoft.com/Forums/en-US/7e081b65-878a-4c22-8e68-c10d39c2ed32/internet-explorer-crashes-appending-style-element-to-head\n if (styleNode.styleSheet) {\n try {\n styleNode.styleSheet.cssText = styles;\n } catch (e) {\n throw new Error('Couldn\\'t reassign styleSheet.cssText.');\n }\n }\n },\n currentScript: function(window) {\n const document = window.document;\n return document.currentScript || (() => {\n const scripts = document.getElementsByTagName('script');\n return scripts[scripts.length - 1];\n })();\n }\n};\n"]} |
| {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/less-browser/cache.js"],"names":[],"mappings":";AAAA,wDAAwD;;AAExD,mBAAe,UAAC,MAAM,EAAE,OAAO,EAAE,MAAM;IACnC,IAAI,KAAK,GAAG,IAAI,CAAC;IACjB,IAAI,OAAO,CAAC,GAAG,KAAK,aAAa,EAAE;QAC/B,IAAI;YACA,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;SACrF;QAAC,OAAO,CAAC,EAAE,GAAE;KACjB;IACD,OAAO;QACH,MAAM,EAAE,UAAS,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM;YACnD,IAAI,KAAK,EAAE;gBACP,MAAM,CAAC,IAAI,CAAC,iBAAU,IAAI,eAAY,CAAC,CAAC;gBACxC,IAAI;oBACA,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;oBAC5B,KAAK,CAAC,OAAO,CAAC,UAAG,IAAI,eAAY,EAAE,YAAY,CAAC,CAAC;oBACjD,IAAI,UAAU,EAAE;wBACZ,KAAK,CAAC,OAAO,CAAC,UAAG,IAAI,UAAO,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;qBAC7D;iBACJ;gBAAC,OAAO,CAAC,EAAE;oBACR,yDAAyD;oBACzD,MAAM,CAAC,KAAK,CAAC,2BAAmB,IAAI,qCAAiC,CAAC,CAAC;iBAC1E;aACJ;QACL,CAAC;QACD,MAAM,EAAE,UAAS,IAAI,EAAE,OAAO,EAAE,UAAU;YACtC,IAAM,GAAG,GAAS,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC/C,IAAM,SAAS,GAAG,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,UAAG,IAAI,eAAY,CAAC,CAAC;YAC9D,IAAI,IAAI,GAAQ,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,UAAG,IAAI,UAAO,CAAC,CAAC;YAEvD,UAAU,GAAG,UAAU,IAAI,EAAE,CAAC;YAC9B,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,CAAC,kEAAkE;YAEvF,IAAI,SAAS,IAAI,OAAO,CAAC,YAAY;gBACjC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;oBACrC,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC;gBAClC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE;gBACrC,iBAAiB;gBACjB,OAAO,GAAG,CAAC;aACd;QACL,CAAC;KACJ,CAAC;AACN,CAAC,EAAC","sourcesContent":["// Cache system is a bit outdated and could do with work\n\nexport default (window, options, logger) => {\n let cache = null;\n if (options.env !== 'development') {\n try {\n cache = (typeof window.localStorage === 'undefined') ? null : window.localStorage;\n } catch (_) {}\n }\n return {\n setCSS: function(path, lastModified, modifyVars, styles) {\n if (cache) {\n logger.info(`saving ${path} to cache.`);\n try {\n cache.setItem(path, styles);\n cache.setItem(`${path}:timestamp`, lastModified);\n if (modifyVars) {\n cache.setItem(`${path}:vars`, JSON.stringify(modifyVars));\n }\n } catch (e) {\n // TODO - could do with adding more robust error handling\n logger.error(`failed to save \"${path}\" to local storage for caching.`);\n }\n }\n },\n getCSS: function(path, webInfo, modifyVars) {\n const css = cache && cache.getItem(path);\n const timestamp = cache && cache.getItem(`${path}:timestamp`);\n let vars = cache && cache.getItem(`${path}:vars`);\n\n modifyVars = modifyVars || {};\n vars = vars || '{}'; // if not set, treat as the JSON representation of an empty object\n\n if (timestamp && webInfo.lastModified &&\n (new Date(webInfo.lastModified).valueOf() ===\n new Date(timestamp).valueOf()) &&\n JSON.stringify(modifyVars) === vars) {\n // Use local copy\n return css;\n }\n }\n };\n};\n"]} |
| {"version":3,"file":"error-reporting.js","sourceRoot":"","sources":["../../src/less-browser/error-reporting.js"],"names":[],"mappings":";;;AAAA,qDAAiC;AACjC,8DAAgC;AAEhC,mBAAe,UAAC,MAAM,EAAE,IAAI,EAAE,OAAO;IAEjC,SAAS,SAAS,CAAC,CAAC,EAAE,QAAQ;QAC1B,IAAM,EAAE,GAAG,6BAAsB,KAAK,CAAC,SAAS,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAE,CAAC;QACnE,IAAM,QAAQ,GAAG,oEAAoE,CAAC;QACtF,IAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAClD,IAAI,KAAK,CAAC;QACV,IAAI,OAAO,CAAC;QACZ,IAAM,MAAM,GAAG,EAAE,CAAC;QAClB,IAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC;QACxC,IAAM,cAAc,GAAG,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;QAE5D,IAAI,CAAC,EAAE,GAAU,EAAE,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,oBAAoB,CAAC;QAEtC,OAAO,GAAG,cAAO,CAAC,CAAC,IAAI,IAAI,QAAQ,oBAAU,CAAC,CAAC,OAAO,IAAI,sCAAsC,CAAE;YAC9F,+BAAuB,QAAQ,gBAAK,cAAc,UAAO,CAAC;QAE9D,IAAM,SAAS,GAAG,UAAC,CAAC,EAAE,CAAC,EAAE,SAAS;YAC9B,IAAI,CA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ACL,CAAC;IAED,OAAO;QACH,GAAG,EAAE,KAAK;QACV,MAAM,EAAE,WAAW;KACtB,CAAC;AACN,CAAC,EAAC","sourcesContent":["import * as utils from './utils';\nimport browser from './browser';\n\nexport default (window, less, options) => {\n\n function errorHTML(e, rootHref) {\n const id = `less-error-message:${utils.extractId(rootHref || '')}`;\n const template = '<li><label>{line}</label><pre class=\"{class}\">{content}</pre></li>';\n const elem = window.document.createElement('div');\n let timer;\n let content;\n const errors = [];\n const filename = e.filename || rootHref;\n const filenameNoPath = filename.match(/([^/]+(\\?.*)?)$/)[1];\n\n elem.id = id;\n elem.className = 'less-error-message';\n\n content = `<h3>${e.type || 'Syntax'}Error: ${e.message || 'There is an error in your .less file'}` + \n `</h3><p>in <a href=\"${filename}\">${filenameNoPath}</a> `;\n\n const errorline = (e, i, classname) => {\n if (e.extract[i] !== undefined) {\n errors.push(template.replace(/\\{line\\}/, (parseInt(e.line, 10) || 0) + (i - 1))\n .replace(/\\{class\\}/, classname)\n .replace(/\\{content\\}/, e.extract[i]));\n }\n };\n\n if (e.line) {\n errorline(e, 0, '');\n errorline(e, 1, 'line');\n errorline(e, 2, '');\n content += `on line ${e.line}, column ${e.column + 1}:</p><ul>${errors.join('')}</ul>`;\n }\n if (e.stack && (e.extract || options.logLevel >= 4)) {\n content += `<br/>Stack Trace</br />${e.stack.split('\\n').slice(1).join('<br/>')}`;\n }\n elem.innerHTML = content;\n\n // CSS for error messages\n browser.createCSS(window.document, [\n '.less-error-message ul, .less-error-message li {',\n 'list-style-type: none;',\n 'margin-right: 15px;',\n 'padding: 4px 0;',\n 'margin: 0;',\n '}',\n '.less-error-message label {',\n 'font-size: 12px;',\n 'margin-right: 15px;',\n 'padding: 4px 0;',\n 'color: #cc7777;',\n '}',\n '.less-error-message pre {',\n 'color: #dd6666;',\n 'padding: 4px 0;',\n 'margin: 0;',\n 'display: inline-block;',\n '}',\n '.less-error-message pre.line {',\n 'color: #ff0000;',\n '}',\n '.less-error-message h3 {',\n 'font-size: 20px;',\n 'font-weight: bold;',\n 'padding: 15px 0 5px 0;',\n 'margin: 0;',\n '}',\n '.less-error-message a {',\n 'color: #10a',\n '}',\n '.less-error-message .error {',\n 'color: red;',\n 'font-weight: bold;',\n 'padding-bottom: 2px;',\n 'border-bottom: 1px dashed red;',\n '}'\n ].join('\\n'), { title: 'error-message' });\n\n elem.style.cssText = [\n 'font-family: Arial, sans-serif',\n 'border: 1px solid #e00',\n 'background-color: #eee',\n 'border-radius: 5px',\n '-webkit-border-radius: 5px',\n '-moz-border-radius: 5px',\n 'color: #e00',\n 'padding: 15px',\n 'margin-bottom: 15px'\n ].join(';');\n\n if (options.env === 'development') {\n timer = setInterval(() => {\n const document = window.document;\n const body = document.body;\n if (body) {\n if (document.getElementById(id)) {\n body.replaceChild(elem, document.getElementById(id));\n } else {\n body.insertBefore(elem, body.firstChild);\n }\n clearInterval(timer);\n }\n }, 10);\n }\n }\n\n function removeErrorHTML(path) {\n const node = window.document.getElementById(`less-error-message:${utils.extractId(path)}`);\n if (node) {\n node.parentNode.removeChild(node);\n }\n }\n\n function removeErrorConsole() {\n // no action\n }\n\n function removeError(path) {\n if (!options.errorReporting || options.errorReporting === 'html') {\n removeErrorHTML(path);\n } else if (options.errorReporting === 'console') {\n removeErrorConsole(path);\n } else if (typeof options.errorReporting === 'function') {\n options.errorReporting('remove', path);\n }\n }\n\n function errorConsole(e, rootHref) {\n const template = '{line} {content}';\n const filename = e.filename || rootHref;\n const errors = [];\n let content = `${e.type || 'Syntax'}Error: ${e.message || 'There is an error in your .less file'} in ${filename}`;\n\n const errorline = (e, i, classname) => {\n if (e.extract[i] !== undefined) {\n errors.push(template.replace(/\\{line\\}/, (parseInt(e.line, 10) || 0) + (i - 1))\n .replace(/\\{class\\}/, classname)\n .replace(/\\{content\\}/, e.extract[i]));\n }\n };\n\n if (e.line) {\n errorline(e, 0, '');\n errorline(e, 1, 'line');\n errorline(e, 2, '');\n content += ` on line ${e.line}, column ${e.column + 1}:\\n${errors.join('\\n')}`;\n }\n if (e.stack && (e.extract || options.logLevel >= 4)) {\n content += `\\nStack Trace\\n${e.stack}`;\n }\n less.logger.error(content);\n }\n\n function error(e, rootHref) {\n if (!options.errorReporting || options.errorReporting === 'html') {\n errorHTML(e, rootHref);\n } else if (options.errorReporting === 'console') {\n errorConsole(e, rootHref);\n } else if (typeof options.errorReporting === 'function') {\n options.errorReporting('add', e, rootHref);\n }\n }\n\n return {\n add: error,\n remove: removeError\n };\n};\n"]} |
| {"version":3,"file":"file-manager.js","sourceRoot":"","sources":["../../src/less-browser/file-manager.js"],"names":[],"mappings":";;;AAAA,kHAA+E;AAE/E,IAAI,OAAO,CAAC;AACZ,IAAI,MAAM,CAAC;AACX,IAAI,SAAS,GAAG,EAAE,CAAC;AAEnB,wIAAwI;AACxI,IAAM,WAAW,GAAG,cAAY,CAAC,CAAA;AACjC,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,kCAAmB,EAAE,EAAE;IAC7D,uBAAuB;QACnB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,IAAI,YAAC,QAAQ,EAAE,SAAS;QACpB,IAAI,CAAC,QAAQ,EAAE;YACX,OAAO,SAAS,CAAC;SACpB;QACD,OAAO,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC;IAC1D,CAAC;IAED,KAAK,YAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO;QAC9B,IAAM,GAAG,GAAG,IAAI,cAAc,EAAE,CAAC;QACjC,IAAM,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;QAEhE,IAAI,OAAO,GAAG,CAAC,gBAAgB,KAAK,UAAU,EAAE;YAC5C,GAAG,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;SACpC;QACD,MAAM,CAAC,KAAK,CAAC,wBAAiB,GAAG,M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AC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,aAAa,CAAC,IAAI,EAAE,YAAY;gBACpE,iBAAiB;gBACjB,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;gBAEvB,6BAA6B;gBAC7B,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,YAAY,cAAA,EAAE,EAAC,CAAC,CAAC;YAC1E,CAAC,EAAE,SAAS,UAAU,CAAC,MAAM,EAAE,GAAG;gBAC9B,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAI,GAAG,6BAAmB,MAAM,MAAG,EAAE,IAAI,MAAA,EAAE,CAAC,CAAC;YACjF,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAC,CAAC;AAEH,mBAAe,UAAC,IAAI,EAAE,GAAG;IACrB,OAAO,GAAG,IAAI,CAAC;IACf,MAAM,GAAG,GAAG,CAAC;IACb,OAAO,WAAW,CAAC;AACvB,CAAC,EAAA","sourcesContent":["import AbstractFileManager from '../less/environment/abstract-file-manager.js';\n\nlet options;\nlet logger;\nlet fileCache = {};\n\n// TODOS - move log somewhere. pathDiff and doing something similar in node. use pathDiff in the other browser file for the initial load\nconst FileManager = function() {}\nFileManager.prototype = Object.assign(new AbstractFileManager(), {\n alwaysMakePathsAbsolute() {\n return true;\n },\n\n join(basePath, laterPath) {\n if (!basePath) {\n return laterPath;\n }\n return this.extractUrlParts(laterPath, basePath).path;\n },\n\n doXHR(url, type, callback, errback) {\n const xhr = new XMLHttpRequest();\n const async = options.isFileProtocol ? options.fileAsync : true;\n\n if (typeof xhr.overrideMimeType === 'function') {\n xhr.overrideMimeType('text/css');\n }\n logger.debug(`XHR: Getting '${url}'`);\n xhr.open('GET', url, async);\n xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5');\n xhr.send(null);\n\n function handleResponse(xhr, callback, errback) {\n if (xhr.status >= 200 && xhr.status < 300) {\n callback(xhr.responseText,\n xhr.getResponseHeader('Last-Modified'));\n } else if (typeof errback === 'function') {\n errback(xhr.status, url);\n }\n }\n\n if (options.isFileProtocol && !options.fileAsync) {\n if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 300)) {\n callback(xhr.responseText);\n } else {\n errback(xhr.status, url);\n }\n } else if (async) {\n xhr.onreadystatechange = () => {\n if (xhr.readyState == 4) {\n handleResponse(xhr, callback, errback);\n }\n };\n } else {\n handleResponse(xhr, callback, errback);\n }\n },\n\n supports() {\n return true;\n },\n\n clearFileCache() {\n fileCache = {};\n },\n\n loadFile(filename, currentDirectory, options) {\n // TODO: Add prefix support like less-node?\n // What about multiple paths?\n\n if (currentDirectory && !this.isPathAbsolute(filename)) {\n filename = currentDirectory + filename;\n }\n\n filename = options.ext ? this.tryAppendExtension(filename, options.ext) : filename;\n\n options = options || {};\n\n // sheet may be set to the stylesheet for the initial load or a collection of properties including\n // some context variables for imports\n const hrefParts = this.extractUrlParts(filename, window.location.href);\n const href = hrefParts.url;\n const self = this;\n \n return new Promise((resolve, reject) => {\n if (options.useFileCache && fileCache[href]) {\n try {\n const lessText = fileCache[href];\n return resolve({ contents: lessText, filename: href, webInfo: { lastModified: new Date() }});\n } catch (e) {\n return reject({ filename: href, message: `Error loading file ${href} error was ${e.message}` });\n }\n }\n\n self.doXHR(href, options.mime, function doXHRCallback(data, lastModified) {\n // per file cache\n fileCache[href] = data;\n\n // Use remote copy (re-parse)\n resolve({ contents: data, filename: href, webInfo: { lastModified }});\n }, function doXHRError(status, url) {\n reject({ type: 'File', message: `'${url}' wasn't found (${status})`, href });\n });\n });\n }\n});\n\nexport default (opts, log) => {\n options = opts;\n logger = log;\n return FileManager;\n}\n"]} |
| {"version":3,"file":"image-size.js","sourceRoot":"","sources":["../../src/less-browser/image-size.js"],"names":[],"mappings":";;;AACA,oGAAqE;AAErE,mBAAe;IACX,SAAS,SAAS;QACd,MAAM;YACF,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,mEAAmE;SAC/E,CAAC;IACN,CAAC;IAED,IAAM,cAAc,GAAG;QACnB,YAAY,EAAE,UAAS,YAAY;YAC/B,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;YAC9B,OAAO,CAAC,CAAC,CAAC;QACd,CAAC;QACD,aAAa,EAAE,UAAS,YAAY;YAChC,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;YAC9B,OAAO,CAAC,CAAC,CAAC;QACd,CAAC;QACD,cAAc,EAAE,UAAS,YAAY;YACjC,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;YAC9B,OAAO,CAAC,CAAC,CAAC;QACd,CAAC;KACJ,CAAC;IAEF,2BAAgB,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;AACjD,CAAC,EAAC","sourcesContent":["\nimport functionRegistry from './../less/functions/function-registry';\n\nexport default () => {\n function imageSize() {\n throw {\n type: 'Runtime',\n message: 'Image size functions are not supported in browser version of less'\n };\n }\n\n const imageFunctions = {\n 'image-size': function(filePathNode) {\n imageSize(this, filePathNode);\n return -1;\n },\n 'image-width': function(filePathNode) {\n imageSize(this, filePathNode);\n return -1;\n },\n 'image-height': function(filePathNode) {\n imageSize(this, filePathNode);\n return -1;\n }\n };\n\n functionRegistry.addMultiple(imageFunctions);\n};\n"]} |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/less-browser/index.js"],"names":[],"mappings":";;;AAAA,EAAE;AACF,WAAW;AACX,uEAAuE;AACvE,EAAE;AACF,iCAAoC;AACpC,yDAA+B;AAC/B,8DAAgC;AAChC,wEAAgC;AAChC,0EAA2C;AAC3C,wEAAyC;AACzC,8EAA+C;AAC/C,0DAA4B;AAC5B,oEAAqC;AAErC,mBAAe,UAAC,MAAM,EAAE,OAAO;IAC3B,IAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACjC,IAAM,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IAAI,CAAC,mBAAY,KAAK,CAAC,IAAI,mBAAgB,CAAC,CAAC;qBAC5D;oBACD,iBAAO,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;oBAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAW,KAAK,CAAC,IAAI,2BAAiB,IAAI,IAAI,EAAE,GAAG,OAAO,OAAI,CAAC,CAAC;oBAEjF,wBAAwB;oBACxB,eAAe,EAAE,CAAC;oBAElB,4EAA4E;oBAC5E,IAAI,eAAe,KAAK,CAAC,EAAE;wBACvB,iBAAiB,GAAG,IAAI,IAAI,EAAE,GAAG,SAAS,CAAC;wBAC3C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,8CAAuC,iBAAiB,OAAI,CAAC,CAAC;wBAC/E,OAAO,CAAC;4BACJ,SAAS,WAAA;4BACT,OAAO,SAAA;4BACP,iBAAiB,mBAAA;4BACjB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;yBAC7B,CAAC,CAAC;qBACN;oBACD,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC;gBACzB,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;aAC1B;YAED,UAAU,CAAC,UAAU,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;IAEF,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC;IAChC,OAAO,IAAI,CAAC;AAChB,CAAC,EAAC","sourcesContent":["//\n// index.js\n// Should expose the additional browser functions on to the less object\n//\nimport {addDataAttr} from './utils';\nimport lessRoot from '../less';\nimport browser from './browser';\nimport FM from './file-manager';\nimport PluginLoader from './plugin-loader';\nimport LogListener from './log-listener';\nimport ErrorReporting from './error-reporting';\nimport Cache from './cache';\nimport ImageSize from './image-size';\n\nexport default (window, options) => {\n const document = window.document;\n const less = lessRoot();\n\n less.options = options;\n const environment = less.environment;\n const FileManager = FM(options, less.logger);\n const fileManager = new FileManager();\n environment.addFileManager(fileManager);\n less.FileManager = FileManager;\n less.PluginLoader = PluginLoader;\n\n LogListener(less, options);\n const errors = ErrorReporting(window, less, options);\n const cache = less.cache = options.cache || Cache(window, options, less.logger);\n ImageSize(less.environment);\n\n // Setup user functions - Deprecate?\n if (options.functions) {\n less.functions.functionRegistry.addMultiple(options.functions);\n }\n\n const typePattern = /^text\\/(x-)?less$/;\n\n function clone(obj) {\n const cloned = {};\n for (const prop in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, prop)) {\n cloned[prop] = obj[prop];\n }\n }\n return cloned;\n }\n\n // only really needed for phantom\n function bind(func, thisArg) {\n const curryArgs = Array.prototype.slice.call(arguments, 2);\n return function() {\n const args = curryArgs.concat(Array.prototype.slice.call(arguments, 0));\n return func.apply(thisArg, args);\n };\n }\n\n function loadStyles(modifyVars) {\n const styles = document.getElementsByTagName('style');\n let style;\n\n for (let i = 0; i < styles.length; i++) {\n style = styles[i];\n if (style.type.match(typePattern)) {\n const instanceOptions = clone(options);\n instanceOptions.modifyVars = modifyVars;\n const lessText = style.innerHTML || '';\n instanceOptions.filename = document.location.href.replace(/#.*$/, '');\n\n /* jshint loopfunc:true */\n // use closure to store current style\n less.render(lessText, instanceOptions,\n bind((style, e, result) => {\n if (e) {\n errors.add(e, 'inline');\n } else {\n style.type = 'text/css';\n if (style.styleSheet) {\n style.styleSheet.cssText = result.css;\n } else {\n style.innerHTML = result.css;\n }\n }\n }, null, style));\n }\n }\n }\n\n function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) {\n\n const instanceOptions = clone(options);\n addDataAttr(instanceOptions, sheet);\n instanceOptions.mime = sheet.type;\n\n if (modifyVars) {\n instanceOptions.modifyVars = modifyVars;\n }\n\n function loadInitialFileCallback(loadedFile) {\n const data = loadedFile.contents;\n const path = loadedFile.filename;\n const webInfo = loadedFile.webInfo;\n\n const newFileInfo = {\n currentDirectory: fileManager.getPath(path),\n filename: path,\n rootFilename: path,\n rewriteUrls: instanceOptions.rewriteUrls\n };\n\n newFileInfo.entryPath = newFileInfo.currentDirectory;\n newFileInfo.rootpath = instanceOptions.rootpath || newFileInfo.currentDirectory;\n\n if (webInfo) {\n webInfo.remaining = remaining;\n\n const css = cache.getCSS(path, webInfo, instanceOptions.modifyVars);\n if (!reload && css) {\n webInfo.local = true;\n callback(null, css, data, sheet, webInfo, path);\n return;\n }\n\n }\n\n // TODO add tests around how this behaves when reloading\n errors.remove(path);\n\n instanceOptions.rootFileInfo = newFileInfo;\n less.render(data, instanceOptions, (e, result) => {\n if (e) {\n e.href = path;\n callback(e);\n } else {\n cache.setCSS(sheet.href, webInfo.lastModified, instanceOptions.modifyVars, result.css);\n callback(null, result.css, data, sheet, webInfo, path);\n }\n });\n }\n\n fileManager.loadFile(sheet.href, null, instanceOptions, environment)\n .then(loadedFile => {\n loadInitialFileCallback(loadedFile);\n }).catch(err => {\n console.log(err);\n callback(err);\n });\n\n }\n\n function loadStyleSheets(callback, reload, modifyVars) {\n for (let i = 0; i < less.sheets.length; i++) {\n loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1), modifyVars);\n }\n }\n\n function initRunningMode() {\n if (less.env === 'development') {\n less.watchTimer = setInterval(() => {\n if (less.watchMode) {\n fileManager.clearFileCache();\n /**\n * @todo remove when this is typed with JSDoc\n */\n // eslint-disable-next-line no-unused-vars\n loadStyleSheets((e, css, _, sheet, webInfo) => {\n if (e) {\n errors.add(e, e.href || sheet.href);\n } else if (css) {\n browser.createCSS(window.document, css, sheet);\n }\n });\n }\n }, options.poll);\n }\n }\n\n //\n // Watch mode\n //\n less.watch = function () {\n if (!less.watchMode ) {\n less.env = 'development';\n initRunningMode();\n }\n this.watchMode = true;\n return true;\n };\n\n less.unwatch = function () {clearInterval(less.watchTimer); this.watchMode = false; return false; };\n\n //\n // Synchronously get all <link> tags with the 'rel' attribute set to\n // \"stylesheet/less\".\n //\n less.registerStylesheetsImmediately = () => {\n const links = document.getElementsByTagName('link');\n less.sheets = [];\n\n for (let i = 0; i < links.length; i++) {\n if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&\n (links[i].type.match(typePattern)))) {\n less.sheets.push(links[i]);\n }\n }\n };\n\n //\n // Asynchronously get all <link> tags with the 'rel' attribute set to\n // \"stylesheet/less\", returning a Promise.\n //\n less.registerStylesheets = () => new Promise((resolve) => {\n less.registerStylesheetsImmediately();\n resolve();\n });\n\n //\n // With this function, it's possible to alter variables and re-render\n // CSS without reloading less-files\n //\n less.modifyVars = record => less.refresh(true, record, false);\n\n less.refresh = (reload, modifyVars, clearFileCache) => {\n if ((reload || clearFileCache) && clearFileCache !== false) {\n fileManager.clearFileCache();\n }\n return new Promise((resolve, reject) => {\n let startTime;\n let endTime;\n let totalMilliseconds;\n let remainingSheets;\n startTime = endTime = new Date();\n\n // Set counter for remaining unprocessed sheets\n remainingSheets = less.sheets.length;\n\n if (remainingSheets === 0) {\n\n endTime = new Date();\n totalMilliseconds = endTime - startTime;\n less.logger.info('Less has finished and no sheets were loaded.');\n resolve({\n startTime,\n endTime,\n totalMilliseconds,\n sheets: less.sheets.length\n });\n\n } else {\n // Relies on less.sheets array, callback seems to be guaranteed to be called for every element of the array\n loadStyleSheets((e, css, _, sheet, webInfo) => {\n if (e) {\n errors.add(e, e.href || sheet.href);\n reject(e);\n return;\n }\n if (webInfo.local) {\n less.logger.info(`Loading ${sheet.href} from cache.`);\n } else {\n less.logger.info(`Rendered ${sheet.href} successfully.`);\n }\n browser.createCSS(window.document, css, sheet);\n less.logger.info(`CSS for ${sheet.href} generated in ${new Date() - endTime}ms`);\n\n // Count completed sheet\n remainingSheets--;\n\n // Check if the last remaining sheet was processed and then call the promise\n if (remainingSheets === 0) {\n totalMilliseconds = new Date() - startTime;\n less.logger.info(`Less has finished. CSS generated in ${totalMilliseconds}ms`);\n resolve({\n startTime,\n endTime,\n totalMilliseconds,\n sheets: less.sheets.length\n });\n }\n endTime = new Date();\n }, reload, modifyVars);\n }\n\n loadStyles(modifyVars);\n });\n };\n\n less.refreshStyles = loadStyles;\n return less;\n};\n"]} |
| {"version":3,"file":"log-listener.js","sourceRoot":"","sources":["../../src/less-browser/log-listener.js"],"names":[],"mappings":";;AAAA,mBAAe,UAAC,IAAI,EAAE,OAAO;IACzB,IAAM,cAAc,GAAG,CAAC,CAAC;IACzB,IAAM,aAAa,GAAG,CAAC,CAAC;IACxB,IAAM,aAAa,GAAG,CAAC,CAAC;IACxB,IAAM,cAAc,GAAG,CAAC,CAAC;IAEzB,mDAAmD;IACnD,oCAAoC;IACpC,6BAA6B;IAC7B,aAAa;IACb,WAAW;IACX,gBAAgB;IAChB,OAAO,CAAC,QAAQ,GAAG,OAAO,OAAO,CAAC,QAAQ,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,KAAK,aAAa,CAAC,CAAC,CAAE,aAAa,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;IAElJ,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;QAClB,OAAO,CAAC,OAAO,GAAG,CAAC;gBACf,KAAK,EAAE,UAAS,GAAG;oBACf,IAAI,OAAO,CAAC,QAAQ,IAAI,cAAc,EAAE;wBACpC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;qBACpB;gBACL,CAAC;gBACD,IAAI,EAAE,UAAS,GAAG;oBACd,IAAI,OAAO,CAAC,QAAQ,IAAI,aAAa,EAAE;wBACnC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;qBACpB;gBACL,CAAC;gBACD,IAAI,EAAE,UAAS,GAAG;oBACd,IAAI,OAAO,CAAC,QAAQ,IAAI,aAAa,EAAE;wBACnC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;qBACrB;gBACL,CAAC;gBACD,KAAK,EAAE,UAAS,GAAG;oBACf,IAAI,OAAO,CAAC,QAAQ,IAAI,cAAc,EAAE;wBACpC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;qBACtB;gBACL,CAAC;aACJ,CAAC,CAAC;KACN;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC7C,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;KAC/C;AACL,CAAC,EAAC","sourcesContent":["export default (less, options) => {\n const logLevel_debug = 4;\n const logLevel_info = 3;\n const logLevel_warn = 2;\n const logLevel_error = 1;\n\n // The amount of logging in the javascript console.\n // 3 - Debug, information and errors\n // 2 - Information and errors\n // 1 - Errors\n // 0 - None\n // Defaults to 2\n options.logLevel = typeof options.logLevel !== 'undefined' ? options.logLevel : (options.env === 'development' ? logLevel_info : logLevel_error);\n\n if (!options.loggers) {\n options.loggers = [{\n debug: function(msg) {\n if (options.logLevel >= logLevel_debug) {\n console.log(msg);\n }\n },\n info: function(msg) {\n if (options.logLevel >= logLevel_info) {\n console.log(msg);\n }\n },\n warn: function(msg) {\n if (options.logLevel >= logLevel_warn) {\n console.warn(msg);\n }\n },\n error: function(msg) {\n if (options.logLevel >= logLevel_error) {\n console.error(msg);\n }\n }\n }];\n }\n for (let i = 0; i < options.loggers.length; i++) {\n less.logger.addListener(options.loggers[i]);\n }\n};\n"]} |
| {"version":3,"file":"plugin-loader.js","sourceRoot":"","sources":["../../src/less-browser/plugin-loader.js"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,oHAAiF;AAEjF;;GAEG;AACH,IAAM,YAAY,GAAG,UAAS,IAAI;IAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,yDAAyD;AAC7D,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,mCAAoB,EAAE,EAAE;IAC/D,UAAU,YAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW;QAC5D,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YAC/B,WAAW,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC;iBACzD,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,YAAY,CAAC","sourcesContent":["/**\n * @todo Add tests for browser `@plugin`\n */\nimport AbstractPluginLoader from '../less/environment/abstract-plugin-loader.js';\n\n/**\n * Browser Plugin Loader\n */\nconst PluginLoader = function(less) {\n this.less = less;\n // Should we shim this.require for browser? Probably not?\n};\n\nPluginLoader.prototype = Object.assign(new AbstractPluginLoader(), {\n loadPlugin(filename, basePath, context, environment, fileManager) {\n return new Promise((fulfill, reject) => {\n fileManager.loadFile(filename, basePath, context, environment)\n .then(fulfill).catch(reject);\n });\n }\n});\n\nexport default PluginLoader;\n\n"]} |
| {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/less-browser/utils.js"],"names":[],"mappings":";;;AACA,SAAgB,SAAS,CAAC,IAAI;IAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAE,2BAA2B;SACrE,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAQ,gCAAgC;SACzE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAyB,gBAAgB;SAC3D,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAgB,0BAA0B;SACrE,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,CAAiB,6BAA6B;SACvE,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAuB,yCAAyC;AAC7F,CAAC;AAPD,8BAOC;AAED,SAAgB,WAAW,CAAC,OAAO,EAAE,GAAG;IACpC,IAAI,CAAC,GAAG,EAAE;QAAC,OAAO;KAAC,CAAC,sCAAsC;IAC1D,KAAK,IAAM,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE;QAC3B,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE;YACxD,IAAI,GAAG,KAAK,KAAK,IAAI,GAAG,KAAK,iBAAiB,IAAI,GAAG,KAAK,UAAU,IAAI,GAAG,KAAK,gBAAgB,EAAE;gBAC9F,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;aACnC;iBAAM;gBACH,IAAI;oBACA,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;iBAC/C;gBACD,OAAO,CAAC,EAAE,GAAE;aACf;SACJ;KACJ;AACL,CAAC;AAdD,kCAcC","sourcesContent":["\nexport function extractId(href) {\n return href.replace(/^[a-z-]+:\\/+?[^/]+/, '') // Remove protocol & domain\n .replace(/[?&]livereload=\\w+/, '') // Remove LiveReload cachebuster\n .replace(/^\\//, '') // Remove root /\n .replace(/\\.[a-zA-Z]+$/, '') // Remove simple extension\n .replace(/[^.\\w-]+/g, '-') // Replace illegal characters\n .replace(/\\./g, ':'); // Replace dots with colons(for valid id)\n}\n\nexport function addDataAttr(options, tag) {\n if (!tag) {return;} // in case of tag is null or undefined\n for (const opt in tag.dataset) {\n if (Object.prototype.hasOwnProperty.call(tag.dataset, opt)) {\n if (opt === 'env' || opt === 'dumpLineNumbers' || opt === 'rootpath' || opt === 'errorReporting') {\n options[opt] = tag.dataset[opt];\n } else {\n try {\n options[opt] = JSON.parse(tag.dataset[opt]);\n }\n catch (_) {}\n }\n }\n }\n}\n"]} |
| {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/less-node/environment.js"],"names":[],"mappings":";;AAAA,kBAAe;IACX,YAAY,EAAE,SAAS,YAAY,CAAC,GAAG;QACnC,yDAAyD;QACzD,IAAM,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACpE,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IACD,UAAU,EAAE,UAAU,QAAQ;QAC1B,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IACD,aAAa,EAAE,UAAU,IAAI;QACzB,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IACD,qBAAqB,EAAE,SAAS,qBAAqB;QACjD,OAAO,OAAO,CAAC,YAAY,CAAC,CAAC,kBAAkB,CAAC;IACpD,CAAC;CACJ,CAAC","sourcesContent":["export default {\n encodeBase64: function encodeBase64(str) {\n // Avoid Buffer constructor on newer versions of Node.js.\n const buffer = (Buffer.from ? Buffer.from(str) : (new Buffer(str)));\n return buffer.toString('base64');\n },\n mimeLookup: function (filename) {\n return require('mime').lookup(filename);\n },\n charsetLookup: function (mime) {\n return require('mime').charsets.lookup(mime);\n },\n getSourceMapGenerator: function getSourceMapGenerator() {\n return require('source-map').SourceMapGenerator;\n }\n};\n"]} |
| {"version":3,"file":"file-manager.js","sourceRoot":"","sources":["../../src/less-node/file-manager.js"],"names":[],"mappings":";;;AAAA,sDAAwB;AACxB,oDAAsB;AACtB,kHAA+E;AAE/E,IAAM,WAAW,GAAG,cAAY,CAAC,CAAA;AACjC,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,kCAAmB,EAAE,EAAE;IAC7D,QAAQ;QACJ,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,YAAY;QACR,OAAO,IAA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I,CAAC,EAAE;wCACH,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;wCAC5E,OAAO,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;qCAC3B;oCACD,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAC,CAAC,CAAC;gCACvD,CAAC,CAAC,CAAC;gCACH,YAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;6BACzC;yBAEJ;6BACI;4BACD,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;yBACvB;oBACL,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBACT;qBAAM;oBACH,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAI,QAAQ,qCAA2B,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAE,EAAE,CAAC,CAAC;iBACxG;YACL,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACV,CAAC;IACL,CAAC;IAED,YAAY,YAAC,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW;QACzD,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IAC3E,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,WAAW,CAAC","sourcesContent":["import path from 'path';\nimport fs from './fs';\nimport AbstractFileManager from '../less/environment/abstract-file-manager.js';\n\nconst FileManager = function() {}\nFileManager.prototype = Object.assign(new AbstractFileManager(), {\n supports() {\n return true;\n },\n\n supportsSync() {\n return true;\n },\n\n loadFile(filename, currentDirectory, options, environment, callback) {\n let fullFilename;\n const isAbsoluteFilename = this.isPathAbsolute(filename);\n const filenamesTried = [];\n const self = this;\n const prefix = filename.slice(0, 1);\n const explicit = prefix === '.' || prefix === '/';\n let result = null;\n let isNodeModule = false;\n const npmPrefix = 'npm://';\n\n options = options || {};\n\n const paths = isAbsoluteFilename ? [''] : [currentDirectory];\n\n if (options.paths) { paths.push.apply(paths, options.paths); }\n\n if (!isAbsoluteFilename && paths.indexOf('.') === -1) { paths.push('.'); }\n\n const prefixes = options.prefixes || [''];\n const fileParts = this.extractUrlParts(filename);\n\n if (options.syncImport) {\n getFileData(returnData, returnData);\n if (callback) {\n callback(result.error, result);\n }\n else {\n return result;\n }\n }\n else {\n // promise is guaranteed to be asyncronous\n // which helps as it allows the file handle\n // to be closed before it continues with the next file\n return new Promise(getFileData);\n }\n\n function returnData(data) {\n if (!data.filename) {\n result = { error: data };\n }\n else {\n result = data;\n }\n }\n\n function getFileData(fulfill, reject) {\n (function tryPathIndex(i) {\n function tryWithExtension() {\n const extFilename = options.ext ? self.tryAppendExtension(fullFilename, options.ext) : fullFilename;\n\n if (extFilename !== fullFilename && !explicit && paths[i] === '.') {\n try {\n fullFilename = require.resolve(extFilename);\n isNodeModule = true;\n }\n catch (e) {\n filenamesTried.push(npmPrefix + extFilename);\n fullFilename = extFilename;\n }\n }\n else {\n fullFilename = extFilename;\n }\n }\n if (i < paths.length) {\n (function tryPrefix(j) {\n if (j < prefixes.length) {\n isNodeModule = false;\n fullFilename = fileParts.rawPath + prefixes[j] + fileParts.filename;\n\n if (paths[i]) {\n fullFilename = path.join(paths[i], fullFilename);\n }\n\n if (!explicit && paths[i] === '.') {\n try {\n fullFilename = require.resolve(fullFilename);\n isNodeModule = true;\n }\n catch (e) {\n filenamesTried.push(npmPrefix + fullFilename);\n tryWithExtension();\n }\n }\n else {\n tryWithExtension();\n } \n\n const readFileArgs = [fullFilename];\n if (!options.rawBuffer) {\n readFileArgs.push('utf-8');\n }\n if (options.syncImport) {\n try {\n const data = fs.readFileSync.apply(this, readFileArgs);\n fulfill({ contents: data, filename: fullFilename});\n }\n catch (e) {\n filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);\n return tryPrefix(j + 1);\n }\n }\n else {\n readFileArgs.push(function(e, data) {\n if (e) {\n filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);\n return tryPrefix(j + 1);\n } \n fulfill({ contents: data, filename: fullFilename});\n });\n fs.readFile.apply(this, readFileArgs);\n }\n\n }\n else {\n tryPathIndex(i + 1);\n }\n })(0);\n } else {\n reject({ type: 'File', message: `'${filename}' wasn't found. Tried - ${filenamesTried.join(',')}` });\n }\n }(0));\n }\n },\n\n loadFileSync(filename, currentDirectory, options, environment) {\n options.syncImport = true;\n return this.loadFile(filename, currentDirectory, options, environment);\n }\n});\n\nexport default FileManager;\n"]} |
| {"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/less-node/fs.js"],"names":[],"mappings":";;AAAA,IAAI,EAAE,CAAC;AACP,IACA;IACI,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAC/B;AACD,OAAO,CAAC,EACR;IACI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtB;AACD,kBAAe,EAAE,CAAC","sourcesContent":["let fs;\ntry\n{\n fs = require('graceful-fs');\n}\ncatch (e)\n{\n fs = require('fs');\n}\nexport default fs;\n"]} |
| {"version":3,"file":"image-size.js","sourceRoot":"","sources":["../../src/less-node/image-size.js"],"names":[],"mappings":";;;AAAA,6EAA+C;AAC/C,+EAAiD;AACjD,oGAAqE;AAErE,mBAAe,UAAA,WAAW;IAEtB,SAAS,SAAS,CAAC,eAAe,EAAE,YAAY;QAC5C,IAAI,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC;QAClC,IAAM,eAAe,GAAG,eAAe,CAAC,eAAe,CAAC;QACxD,IAAM,gBAAgB,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;YAClD,eAAe,CAAC,gBAAgB,CAAC,CAAC,CAAC,eAAe,CAAC,SAAS,CAAC;QAEjE,IAAM,aAAa,GAA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AC;QACD,cAAc,EAAE,UAAS,YAAY;YACjC,IAAM,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;YAC3C,OAAO,IAAI,mBAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC5C,CAAC;KACJ,CAAC;IAEF,2BAAgB,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;AACjD,CAAC,EAAC","sourcesContent":["import Dimension from '../less/tree/dimension';\nimport Expression from '../less/tree/expression';\nimport functionRegistry from './../less/functions/function-registry';\n\nexport default environment => {\n\n function imageSize(functionContext, filePathNode) {\n let filePath = filePathNode.value;\n const currentFileInfo = functionContext.currentFileInfo;\n const currentDirectory = currentFileInfo.rewriteUrls ?\n currentFileInfo.currentDirectory : currentFileInfo.entryPath;\n\n const fragmentStart = filePath.indexOf('#');\n if (fragmentStart !== -1) {\n filePath = filePath.slice(0, fragmentStart);\n }\n\n const fileManager = environment.getFileManager(filePath, currentDirectory, functionContext.context, environment, true);\n\n if (!fileManager) {\n throw {\n type: 'File',\n message: `Can not set up FileManager for ${filePathNode}`\n };\n }\n\n const fileSync = fileManager.loadFileSync(filePath, currentDirectory, functionContext.context, environment);\n\n if (fileSync.error) {\n throw fileSync.error;\n }\n\n const sizeOf = require('image-size');\n return sizeOf(fileSync.filename);\n }\n\n const imageFunctions = {\n 'image-size': function(filePathNode) {\n const size = imageSize(this, filePathNode);\n return new Expression([\n new Dimension(size.width, 'px'),\n new Dimension(size.height, 'px')\n ]);\n },\n 'image-width': function(filePathNode) {\n const size = imageSize(this, filePathNode);\n return new Dimension(size.width, 'px');\n },\n 'image-height': function(filePathNode) {\n const size = imageSize(this, filePathNode);\n return new Dimension(size.height, 'px');\n }\n };\n\n functionRegistry.addMultiple(imageFunctions);\n};\n"]} |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/less-node/index.js"],"names":[],"mappings":";;;AAAA,sEAAwC;AACxC,wEAAyC;AACzC,gFAAgD;AAChD,yDAA4C;AAC5C,IAAM,IAAI,GAAG,IAAA,cAAqB,EAAC,qBAAW,EAAE,CAAC,IAAI,sBAAW,EAAE,EAAE,IAAI,0BAAc,EAAE,CAAC,CAAC,CAAC;AAC3F,wEAAyC;AAEzC,yDAAyD;AACzD,IAAI,CAAC,qBAAqB,GAAG,cAAqB,CAAC;AACnD,IAAI,CAAC,WAAW,GAAG,sBAAW,CAAC;AAC/B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC;AACvD,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;AAClC,IAAI,CAAC,WAAW,GAAG,sBAAW,CAAC;AAC/B,IAAI,CAAC,cAAc,GAAG,0BAAc,CAAC;AAErC,iBAAiB;AACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC,OAAO,EAAE,CAAC;AAE5D,mCAAmC;AACnC,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAElD,kBAAe,IAAI,CAAC","sourcesContent":["import environment from './environment';\nimport FileManager from './file-manager';\nimport UrlFileManager from './url-file-manager';\nimport createFromEnvironment from '../less';\nconst less = createFromEnvironment(environment, [new FileManager(), new UrlFileManager()]);\nimport lesscHelper from './lessc-helper';\n\n// allow people to create less with their own environment\nless.createFromEnvironment = createFromEnvironment;\nless.lesscHelper = lesscHelper;\nless.PluginLoader = require('./plugin-loader').default;\nless.fs = require('./fs').default;\nless.FileManager = FileManager;\nless.UrlFileManager = UrlFileManager;\n\n// Set up options\nless.options = require('../less/default-options').default();\n\n// provide image-size functionality\nrequire('./image-size').default(less.environment);\n\nexport default less;\n"]} |
| {"version":3,"file":"lessc-helper.js","sourceRoot":"","sources":["../../src/less-node/lessc-helper.js"],"names":[],"mappings":"AAAA,kBAAkB;AAClB,EAAE;AACF,kCAAkC;AAClC,IAAM,YAAY,G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,CAAC,CAAC;QAClH,OAAO,CAAC,GAAG,CAAC,sFAAsF,CAAC,CAAC;QACpG,OAAO,CAAC,GAAG,CAAC,4EAA4E,CAAC,CAAC;QAC1F,OAAO,CAAC,GAAG,CAAC,gGAAgG,CAAC,CAAC;QAC9G,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,uDAAuD,CAAC,CAAC;QACrE,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;IACpD,CAAC;CACJ,CAAC;AAEF,2BAA2B;AAC3B,iDAAiD;AACjD,KAAK,IAAM,CAAC,IAAI,YAAY,EAAE;IAAE,IAAI,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE;QAAE,OAAO,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;KAAE;CAAC","sourcesContent":["// lessc_helper.js\n//\n// helper functions for lessc\nconst lessc_helper = {\n\n // Stylize a string\n stylize : function(str, style) {\n const styles = {\n 'reset' : [0, 0],\n 'bold' : [1, 22],\n 'inverse' : [7, 27],\n 'underline' : [4, 24],\n 'yellow' : [33, 39],\n 'green' : [32, 39],\n 'red' : [31, 39],\n 'grey' : [90, 39]\n };\n return `\\x1b[${styles[style][0]}m${str}\\x1b[${styles[style][1]}m`;\n },\n\n // Print command line options\n printUsage: function() {\n console.log('usage: lessc [option option=parameter ...] <source> [destination]');\n console.log('');\n console.log('If source is set to `-\\' (dash or hyphen-minus), input is read from stdin.');\n console.log('');\n console.log('options:');\n console.log(' -h, --help Prints help (this message) and exit.');\n console.log(' --include-path=PATHS Sets include paths. Separated by `:\\'. `;\\' also supported on windows.');\n console.log(' -M, --depends Outputs a makefile import dependency list to stdout.');\n console.log(' --no-color Disables colorized output.');\n console.log(' --ie-compat Enables IE8 compatibility checks.');\n console.log(' --js Enables inline JavaScript in less files');\n console.log(' -l, --lint Syntax check only (lint).');\n console.log(' -s, --silent Suppresses output of error messages.');\n console.log(' --quiet Suppresses output of warnings.');\n console.log(' --strict-imports (DEPRECATED) Ignores .less imports inside selector blocks. Has confusing behavior.');\n console.log(' --insecure Allows imports from insecure https hosts.');\n console.log(' -v, --version Prints version number and exit.');\n console.log(' --verbose Be verbose.');\n console.log(' --source-map[=FILENAME] Outputs a v3 sourcemap to the filename (or output filename.map).');\n console.log(' --source-map-rootpath=X Adds this path onto the sourcemap filename and less file paths.');\n console.log(' --source-map-basepath=X Sets sourcemap base path, defaults to current working directory.');\n console.log(' --source-map-include-source Puts the less files into the map instead of referencing them.');\n console.log(' --source-map-inline Puts the map (and any less files) as a base64 data uri into the output css file.');\n console.log(' --source-map-url=URL Sets a custom URL to map file, for sourceMappingURL comment');\n console.log(' in generated CSS file.');\n console.log(' --source-map-no-annotation Excludes the sourceMappingURL comment from the output css file.');\n console.log(' -rp, --rootpath=URL Sets rootpath for url rewriting in relative imports and urls');\n console.log(' Works with or without the relative-urls option.');\n console.log(' -ru=, --rewrite-urls= Rewrites URLs to make them relative to the base less file.');\n console.log(' all|local|off \\'all\\' rewrites all URLs, \\'local\\' just those starting with a \\'.\\'');\n console.log('');\n console.log(' -m=, --math=');\n console.log(' always Less will eagerly perform math operations always.');\n console.log(' parens-division Math performed except for division (/) operator');\n console.log(' parens | strict Math only performed inside parentheses');\n console.log(' strict-legacy Parens required in very strict terms (legacy --strict-math)');\n console.log('');\n console.log(' -su=on|off Allows mixed units, e.g. 1px+1em or 1px*1px which have units');\n console.log(' --strict-units=on|off that cannot be represented.');\n console.log(' --global-var=\\'VAR=VALUE\\' Defines a variable that can be referenced by the file.');\n console.log(' --modify-var=\\'VAR=VALUE\\' Modifies a variable already declared in the file.');\n console.log(' --url-args=\\'QUERYSTRING\\' Adds params into url tokens (e.g. 42, cb=42 or \\'a=1&b=2\\')');\n console.log(' --plugin=PLUGIN=OPTIONS Loads a plugin. You can also omit the --plugin= if the plugin begins');\n console.log(' less-plugin. E.g. the clean css plugin is called less-plugin-clean-css');\n console.log(' once installed (npm install less-plugin-clean-css), use either with');\n console.log(' --plugin=less-plugin-clean-css or just --clean-css');\n console.log(' specify options afterwards e.g. --plugin=less-plugin-clean-css=\"advanced\"');\n console.log(' or --clean-css=\"advanced\"');\n console.log(' --disable-plugin-rule Disallow @plugin statements');\n console.log('');\n console.log('-------------------------- Deprecated ----------------');\n console.log(' -sm=on|off Legacy parens-only math. Use --math');\n console.log(' --strict-math=on|off ');\n console.log('');\n console.log(' --line-numbers=TYPE (DEPRECATED) Outputs filename and line numbers.');\n console.log(' TYPE can be either \\'comments\\', \\'mediaquery\\', or \\'all\\'.');\n console.log(' The entire dumpLineNumbers option is deprecated.');\n console.log(' Use sourcemaps (--source-map) instead.');\n console.log(' All modes will be removed in a future version.');\n console.log(' Note: \\'mediaquery\\' and \\'all\\' modes generate @media -sass-debug-info');\n console.log(' which had short-lived usage and is no longer recommended.');\n console.log(' -x, --compress Compresses output by removing some whitespaces.');\n console.log(' We recommend you use a dedicated minifer like less-plugin-clean-css');\n console.log('');\n console.log('Report bugs to: http://github.com/less/less.js/issues');\n console.log('Home page: <http://lesscss.org/>');\n }\n};\n\n// Exports helper functions\n// eslint-disable-next-line no-prototype-builtins\nfor (const h in lessc_helper) { if (lessc_helper.hasOwnProperty(h)) { exports[h] = lessc_helper[h]; }}\n"]} |
| {"version":3,"file":"plugin-loader.js","sourceRoot":"","sources":["../../src/less-node/plugin-loader.js"],"names":[],"mappings":";;;AAAA,sDAAwB;AACxB,oHAAiF;AAEjF;;GAEG;AACH,IAAM,YAAY,GAAG,UAAS,IAAI;IAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,IAAI,CAAC,OAAO,GAAG,UAAA,MAAM;QACjB,MAAM,GAAG,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9B,OAAO,UAAA,EAAE;YACL,IAAM,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAC5B,IAAI,GAAG,KAAK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AC,UAAA,GAAG;gBACP,MAAM,CAAC,GAAG,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAED,cAAc,YAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW;QAChE,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IAClF,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,YAAY,CAAC","sourcesContent":["import path from 'path';\nimport AbstractPluginLoader from '../less/environment/abstract-plugin-loader.js';\n\n/**\n * Node Plugin Loader\n */\nconst PluginLoader = function(less) {\n this.less = less;\n this.require = prefix => {\n prefix = path.dirname(prefix);\n return id => {\n const str = id.substr(0, 2);\n if (str === '..' || str === './') {\n return require(path.join(prefix, id));\n }\n else {\n return require(id);\n }\n };\n };\n};\n\nPluginLoader.prototype = Object.assign(new AbstractPluginLoader(), {\n loadPlugin(filename, basePath, context, environment, fileManager) {\n const prefix = filename.slice(0, 1);\n const explicit = prefix === '.' || prefix === '/' || filename.slice(-3).toLowerCase() === '.js';\n if (!explicit) {\n context.prefixes = ['less-plugin-', ''];\n }\n\n if (context.syncImport) {\n return fileManager.loadFileSync(filename, basePath, context, environment);\n }\n\n return new Promise((fulfill, reject) => {\n fileManager.loadFile(filename, basePath, context, environment).then(\n data => {\n try {\n fulfill(data);\n }\n catch (e) {\n console.log(e);\n reject(e);\n }\n }\n ).catch(err => {\n reject(err);\n });\n });\n },\n\n loadPluginSync(filename, basePath, context, environment, fileManager) {\n context.syncImport = true;\n return this.loadPlugin(filename, basePath, context, environment, fileManager);\n }\n});\n\nexport default PluginLoader;\n\n"]} |
| {"version":3,"file":"url-file-manager.js","sourceRoot":"","sources":["../../src/less-node/url-file-manager.js"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC;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EAAE,EAAE,UAAC,GAAG,EAAE,IAAI,EAAE,IAAI;gBACvD,IAAI,GAAG,IAAI,IAAI,IAAI,IAAI,CAAC,UAAU,IAAI,GAAG,EAAE;oBACvC,IAAM,OAAO,GAAG,IAAI,IAAI,IAAI,CAAC,UAAU,KAAK,GAAG;wBAC3C,CAAC,CAAC,oBAAa,MAAM,sBAAmB;wBACxC,CAAC,CAAC,oBAAa,MAAM,mCAAyB,GAAG,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,UAAU,OAAI,CAAC;oBACnG,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC;oBAClC,OAAO;iBACV;gBACD,IAAI,IAAI,CAAC,UAAU,IAAI,GAAG,EAAE;oBACxB,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAa,MAAM,gCAA6B,EAAE,CAAC,CAAC;oBACpF,OAAO;iBACV;gBACD,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;gBAC7B,IAAI,CAAC,IAAI,EAAE;oBACP,gBAAM,CAAC,IAAI,CAAC,oCAA6B,IAAI,CAAC,UAAU,6BAAkB,MAAM,OAAG,CAAC,CAAC;iBACxF;gBACD,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,cAAc,CAAC","sourcesContent":["/* eslint-disable no-unused-vars */\n/**\n * @todo - remove top eslint rule when FileManagers have JSDoc type\n * and are TS-type-checked\n */\nconst isUrlRe = /^(?:https?:)?\\/\\//i;\nimport url from 'url';\nlet request;\nimport AbstractFileManager from '../less/environment/abstract-file-manager.js';\nimport logger from '../less/logger';\n\nconst UrlFileManager = function() {}\nUrlFileManager.prototype = Object.assign(new AbstractFileManager(), {\n supports(filename, currentDirectory, options, environment) {\n return isUrlRe.test( filename ) || isUrlRe.test(currentDirectory);\n },\n\n loadFile(filename, currentDirectory, options, environment) {\n return new Promise((fulfill, reject) => {\n if (request === undefined) {\n try { request = require('needle'); }\n catch (e) { request = null; }\n }\n if (!request) {\n reject({ type: 'File', message: 'optional dependency \\'needle\\' required to import over http(s)\\n' });\n return;\n }\n\n let urlStr = isUrlRe.test( filename ) ? filename : url.resolve(currentDirectory, filename);\n\n /** native-request currently has a bug */\n const hackUrlStr = urlStr.indexOf('?') === -1 ? urlStr + '?' : urlStr\n\n request.get(hackUrlStr, { follow_max: 5 }, (err, resp, body) => {\n if (err || resp && resp.statusCode >= 400) {\n const message = resp && resp.statusCode === 404\n ? `resource '${urlStr}' was not found\\n`\n : `resource '${urlStr}' gave this Error:\\n ${err || resp.statusMessage || resp.statusCode}\\n`;\n reject({ type: 'File', message });\n return;\n }\n if (resp.statusCode >= 300) {\n reject({ type: 'File', message: `resource '${urlStr}' caused too many redirects` });\n return;\n }\n body = body.toString('utf8');\n if (!body) {\n logger.warn(`Warning: Empty body (HTTP ${resp.statusCode}) returned by \"${urlStr}\"`);\n }\n fulfill({ contents: body || '', filename: urlStr });\n });\n });\n }\n});\n\nexport default UrlFileManager;\n"]} |
| {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/less/constants.js"],"names":[],"mappings":";;;AACa,QAAA,IAAI,GAAG;IAChB,MAAM,EAAE,CAAC;IACT,eAAe,EAAE,CAAC;IAClB,MAAM,EAAE,CAAC;IACT,6BAA6B;CAChC,CAAC;AAEW,QAAA,WAAW,GAAG;IACvB,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,CAAC;IACR,GAAG,EAAE,CAAC;CACT,CAAC","sourcesContent":["\nexport const Math = {\n ALWAYS: 0,\n PARENS_DIVISION: 1,\n PARENS: 2\n // removed - STRICT_LEGACY: 3\n};\n\nexport const RewriteUrls = {\n OFF: 0,\n LOCAL: 1,\n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AM,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 - @deprecated The dumpLineNumbers option is deprecated. Use sourcemaps instead. All modes ('comments', 'mediaquery', 'all') will be removed in a future version.\n 'compress', // option - whether to compress\n 'syncImport', // option - whether to import synchronously\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"]} |
| {"version":3,"file":"colors.js","sourceRoot":"","sources":["../../../src/less/data/colors.js"],"names":[],"mappings":";;AAAA,kBAAe;IACX,WAAW,EAAC,SAAS;IACrB,cAAc,EAAC,SAAS;IACxB,MAAM,EAAC,SAAS;IAChB,YAAY,EAAC,SAAS;IACtB,OAAO,EAAC,SAAS;IACjB,OAAO,EAAC,SAAS;IACjB,QAAQ,EAAC,SAAS;IAClB,OAAO,EAAC,SAAS;IACjB,gBAAgB,EAAC,SAAS;IAC1B,MAAM,EAAC,SAAS;IAChB,YAAY,EAAC,SAAS;IACtB,OAAO,EAAC,SAAS;IACjB,WAAW,EAAC,SAAS;IACrB,WAAW,EAAC,SAAS;IACrB,YAAY,EAAC,SAAS;IACtB,WAAW,EAAC,SAAS;IACrB,OAAO,EAAC,SAAS;IACjB,gBAAgB,EAAC,SAAS;IAC1B,UAAU,EAAC,SAAS;IACpB,SAAS,EAAC,SAAS;IACnB,MAAM,EAAC,SAAS;IAChB,UAAU,EAAC,SAAS;IACpB,UAAU,EAAC,SAAS;IACpB,eAAe,EAAC,SAAS;IACzB,UAAU,EAAC,SAAS;IACpB,UAAU,EAAC,SAAS;IACpB,WAAW,EAAC,SAAS;IACrB,WAAW,EAAC,SAAS;IACrB,aAAa,EAAC,SAAS;IACvB,gBAAgB,EAAC,SAAS;IAC1B,YAAY,EAAC,SAAS;IACtB,YAAY,EAAC,SAAS;IACtB,SAAS,EAAC,SAAS;IACnB,YAAY,EAAC,SAAS;IACtB,cAAc,EAAC,SAAS;IACxB,eAAe,EAAC,SAAS;IACzB,eAAe,EAAC,SAAS;IACzB,eAAe,EAAC,SAAS;IACzB,eAAe,EAAC,SAAS;I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,SAAS;IACnB,QAAQ,EAAC,SAAS;IAClB,WAAW,EAAC,SAAS;IACrB,QAAQ,EAAC,SAAS;IAClB,OAAO,EAAC,SAAS;IACjB,OAAO,EAAC,SAAS;IACjB,YAAY,EAAC,SAAS;IACtB,QAAQ,EAAC,SAAS;IAClB,aAAa,EAAC,SAAS;CAC1B,CAAC","sourcesContent":["export default {\n 'aliceblue':'#f0f8ff',\n 'antiquewhite':'#faebd7',\n 'aqua':'#00ffff',\n 'aquamarine':'#7fffd4',\n 'azure':'#f0ffff',\n 'beige':'#f5f5dc',\n 'bisque':'#ffe4c4',\n 'black':'#000000',\n 'blanchedalmond':'#ffebcd',\n 'blue':'#0000ff',\n 'blueviolet':'#8a2be2',\n 'brown':'#a52a2a',\n 'burlywood':'#deb887',\n 'cadetblue':'#5f9ea0',\n 'chartreuse':'#7fff00',\n 'chocolate':'#d2691e',\n 'coral':'#ff7f50',\n 'cornflowerblue':'#6495ed',\n 'cornsilk':'#fff8dc',\n 'crimson':'#dc143c',\n 'cyan':'#00ffff',\n 'darkblue':'#00008b',\n 'darkcyan':'#008b8b',\n 'darkgoldenrod':'#b8860b',\n 'darkgray':'#a9a9a9',\n 'darkgrey':'#a9a9a9',\n 'darkgreen':'#006400',\n 'darkkhaki':'#bdb76b',\n 'darkmagenta':'#8b008b',\n 'darkolivegreen':'#556b2f',\n 'darkorange':'#ff8c00',\n 'darkorchid':'#9932cc',\n 'darkred':'#8b0000',\n 'darksalmon':'#e9967a',\n 'darkseagreen':'#8fbc8f',\n 'darkslateblue':'#483d8b',\n 'darkslategray':'#2f4f4f',\n 'darkslategrey':'#2f4f4f',\n 'darkturquoise':'#00ced1',\n 'darkviolet':'#9400d3',\n 'deeppink':'#ff1493',\n 'deepskyblue':'#00bfff',\n 'dimgray':'#696969',\n 'dimgrey':'#696969',\n 'dodgerblue':'#1e90ff',\n 'firebrick':'#b22222',\n 'floralwhite':'#fffaf0',\n 'forestgreen':'#228b22',\n 'fuchsia':'#ff00ff',\n 'gainsboro':'#dcdcdc',\n 'ghostwhite':'#f8f8ff',\n 'gold':'#ffd700',\n 'goldenrod':'#daa520',\n 'gray':'#808080',\n 'grey':'#808080',\n 'green':'#008000',\n 'greenyellow':'#adff2f',\n 'honeydew':'#f0fff0',\n 'hotpink':'#ff69b4',\n 'indianred':'#cd5c5c',\n 'indigo':'#4b0082',\n 'ivory':'#fffff0',\n 'khaki':'#f0e68c',\n 'lavender':'#e6e6fa',\n 'lavenderblush':'#fff0f5',\n 'lawngreen':'#7cfc00',\n 'lemonchiffon':'#fffacd',\n 'lightblue':'#add8e6',\n 'lightcoral':'#f08080',\n 'lightcyan':'#e0ffff',\n 'lightgoldenrodyellow':'#fafad2',\n 'lightgray':'#d3d3d3',\n 'lightgrey':'#d3d3d3',\n 'lightgreen':'#90ee90',\n 'lightpink':'#ffb6c1',\n 'lightsalmon':'#ffa07a',\n 'lightseagreen':'#20b2aa',\n 'lightskyblue':'#87cefa',\n 'lightslategray':'#778899',\n 'lightslategrey':'#778899',\n 'lightsteelblue':'#b0c4de',\n 'lightyellow':'#ffffe0',\n 'lime':'#00ff00',\n 'limegreen':'#32cd32',\n 'linen':'#faf0e6',\n 'magenta':'#ff00ff',\n 'maroon':'#800000',\n 'mediumaquamarine':'#66cdaa',\n 'mediumblue':'#0000cd',\n 'mediumorchid':'#ba55d3',\n 'mediumpurple':'#9370d8',\n 'mediumseagreen':'#3cb371',\n 'mediumslateblue':'#7b68ee',\n 'mediumspringgreen':'#00fa9a',\n 'mediumturquoise':'#48d1cc',\n 'mediumvioletred':'#c71585',\n 'midnightblue':'#191970',\n 'mintcream':'#f5fffa',\n 'mistyrose':'#ffe4e1',\n 'moccasin':'#ffe4b5',\n 'navajowhite':'#ffdead',\n 'navy':'#000080',\n 'oldlace':'#fdf5e6',\n 'olive':'#808000',\n 'olivedrab':'#6b8e23',\n 'orange':'#ffa500',\n 'orangered':'#ff4500',\n 'orchid':'#da70d6',\n 'palegoldenrod':'#eee8aa',\n 'palegreen':'#98fb98',\n 'paleturquoise':'#afeeee',\n 'palevioletred':'#d87093',\n 'papayawhip':'#ffefd5',\n 'peachpuff':'#ffdab9',\n 'peru':'#cd853f',\n 'pink':'#ffc0cb',\n 'plum':'#dda0dd',\n 'powderblue':'#b0e0e6',\n 'purple':'#800080',\n 'rebeccapurple':'#663399',\n 'red':'#ff0000',\n 'rosybrown':'#bc8f8f',\n 'royalblue':'#4169e1',\n 'saddlebrown':'#8b4513',\n 'salmon':'#fa8072',\n 'sandybrown':'#f4a460',\n 'seagreen':'#2e8b57',\n 'seashell':'#fff5ee',\n 'sienna':'#a0522d',\n 'silver':'#c0c0c0',\n 'skyblue':'#87ceeb',\n 'slateblue':'#6a5acd',\n 'slategray':'#708090',\n 'slategrey':'#708090',\n 'snow':'#fffafa',\n 'springgreen':'#00ff7f',\n 'steelblue':'#4682b4',\n 'tan':'#d2b48c',\n 'teal':'#008080',\n 'thistle':'#d8bfd8',\n 'tomato':'#ff6347',\n 'turquoise':'#40e0d0',\n 'violet':'#ee82ee',\n 'wheat':'#f5deb3',\n 'white':'#ffffff',\n 'whitesmoke':'#f5f5f5',\n 'yellow':'#ffff00',\n 'yellowgreen':'#9acd32'\n};"]} |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/less/data/index.js"],"names":[],"mappings":";;;AAAA,4DAA8B;AAC9B,gFAAiD;AAEjD,kBAAe,EAAE,MAAM,kBAAA,EAAE,eAAe,4BAAA,EAAE,CAAC","sourcesContent":["import colors from './colors';\nimport unitConversions from './unit-conversions';\n\nexport default { colors, unitConversions };\n"]} |
| {"version":3,"file":"unit-conversions.js","sourceRoot":"","sources":["../../../src/less/data/unit-conversions.js"],"names":[],"mappings":";;AAAA,kBAAe;IACX,MAAM,EAAE;QACJ,GAAG,EAAE,CAAC;QACN,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM,GAAG,EAAE;QACjB,IAAI,EAAE,MAAM,GAAG,EAAE;QACjB,IAAI,EAAE,MAAM,GAAG,EAAE,GAAG,EAAE;KACzB;IACD,QAAQ,EAAE;QACN,GAAG,EAAE,CAAC;QACN,IAAI,EAAE,KAAK;KACd;IACD,KAAK,EAAE;QACH,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;QACxB,KAAK,EAAE,CAAC,GAAG,GAAG;QACd,MAAM,EAAE,CAAC,GAAG,GAAG;QACf,MAAM,EAAE,CAAC;KACZ;CACJ,CAAC","sourcesContent":["export default {\n length: {\n 'm': 1,\n 'cm': 0.01,\n 'mm': 0.001,\n 'in': 0.0254,\n 'px': 0.0254 / 96,\n 'pt': 0.0254 / 72,\n 'pc': 0.0254 / 72 * 12\n },\n duration: {\n 's': 1,\n 'ms': 0.001\n },\n angle: {\n 'rad': 1 / (2 * Math.PI),\n 'deg': 1 / 360,\n 'grad': 1 / 400,\n 'turn': 1\n }\n};"]} |
| {"version":3,"file":"default-options.js","sourceRoot":"","sources":["../../src/less/default-options.js"],"names":[],"mappings":";;AAAA,iCAAiC;AACjC;IACI,OAAO;QACH,+CAA+C;QAC/C,iBAAiB,EAAE,KAAK;QAExB,0DAA0D;QAC1D,OAAO,EAAE,KAAK;QAEd;;wCAEgC;QAChC,QAAQ,EAAE,KAAK;QAEf,sEAAsE;QACtE,IAAI,EAAE,KAAK;QAEX;;;;gFAIwE;QACxE,KAAK,EAAE,EAAE;QAET,kCAAkC;QAClC,KAAK,EAAE,IAAI;QAEX;;;;;;;;;;;;;;;;;;;;;WAqBG;QACH,aAAa,EAAE,KAAK;QAEpB,6CAA6C;QAC7C,QAAQ,EAAE,KAAK;QAEf;;8CAEsC;QACtC,QAAQ,EAAE,EAAE;QAEZ;;;8DAGsD;QACtD,WAAW,EAAE,KAAK;QAElB;;;;;WAKG;QACH,IAAI,EAAE,CAAC;QAEP,wFAAwF;QACxF,WAAW,EAAE,KAAK;QAElB;;qCAE6B;QAC7B,UAAU,EAAE,IAAI;QAEhB;iGACyF;QACzF,UAAU,EAAE,IAAI;QAEhB,0EAA0E;QAC1E,OAAO,EAAE,EAAE;KACd,CAAA;AACL,CAAC;AAvFD,4BAuFC","sourcesContent":["// Export a new default each time\nexport default function() {\n return {\n /* Inline Javascript - @plugin still allowed */\n javascriptEnabled: false,\n\n /* Outputs a makefile import dependency list to stdout. */\n depends: false,\n\n /* (DEPRECATED) Compress using less built-in compression. \n * This does an okay job but does not utilise all the tricks of \n * dedicated css compression. */\n compress: false,\n\n /* Runs the less parser and just reports errors without any output. */\n lint: false,\n\n /* Sets available include paths.\n * If the file in an @import rule does not exist at that exact location, \n * less will look for it at the location(s) passed to this option. \n * You might use this for instance to specify a path to a library which \n * you want to be referenced simply and relatively in the less files. */\n paths: [],\n\n /* color output in the terminal */\n color: true,\n\n /**\n * @deprecated This option has confusing behavior and may be removed in a future version.\n * \n * When true, prevents @import statements for .less files from being evaluated inside\n * selector blocks (rulesets). The imports are silently ignored and not output.\n * \n * Behavior:\n * - @import at root level: Always processed\n * - @import inside @-rules (@media, @supports, etc.): Processed (these are not selector blocks)\n * - @import inside selector blocks (.class, #id, etc.): NOT processed (silently ignored)\n * \n * When false (default): All @import statements are processed regardless of context.\n * \n * Note: Despite the name \"strict\", this option does NOT throw an error when imports\n * are used in selector blocks - it silently ignores them. This is confusing\n * behavior that may catch users off guard.\n * \n * Note: Only affects .less file imports. CSS imports (url(...) or .css files) are\n * always output as CSS @import statements regardless of this setting.\n * \n * @see https://github.com/less/less.js/issues/656\n */\n strictImports: false,\n\n /* Allow Imports from Insecure HTTPS Hosts */\n insecure: false,\n\n /* Allows you to add a path to every generated import and url in your css. \n * This does not affect less import statements that are processed, just ones \n * that are left in the output css. */\n rootpath: '',\n\n /* By default URLs are kept as-is, so if you import a file in a sub-directory \n * that references an image, exactly the same URL will be output in the css. \n * This option allows you to re-write URL's in imported files so that the \n * URL is always relative to the base imported file */\n rewriteUrls: false,\n\n /* How to process math \n * 0 always - eagerly try to solve all operations\n * 1 parens-division - require parens for division \"/\"\n * 2 parens | strict - require parens for all operations\n * 3 strict-legacy - legacy strict behavior (super-strict)\n */\n math: 1,\n\n /* Without this option, less attempts to guess at the output unit when it does maths. */\n strictUnits: false,\n\n /* Effectively the declaration is put at the top of your base Less file, \n * meaning it can be used but it also can be overridden if this variable \n * is defined in the file. */\n globalVars: null,\n\n /* As opposed to the global variable option, this puts the declaration at the\n * end of your base file, meaning it will override anything defined in your Less file. */\n modifyVars: null,\n\n /* This option allows you to specify a argument to go on to every URL. */\n urlArgs: ''\n }\n}"]} |
| {"version":3,"file":"abstract-file-manager.js","sourceRoot":"","sources":["../../../src/less/environment/abstract-file-manager.js"],"names":[],"mappings":";;AAAA;IAAA;IAyIA,CAAC;IAxIG,qCAAO,GAAP,UAAQ,QAAQ;QACZ,IAAI,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,GAAG,CAAC,EAAE;YACP,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACnC;QACD,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,CAAC,GAAG,CAAC,EAAE;YACP,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SAClC;QACD,IAAI,CAAC,GAAG,CAAC,EAAE;YACP,OAAO,EAAE,CAAC;SACb;QACD,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,gDAAkB,GAAlB,UAAmB,IAAI,EAAE,GAAG;QACxB,OAAO,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC;IAClE,CAAC;IAED,oDAAsB,GAAtB,UAAuB,IAAI;QACvB,OAAO,IAA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,CAAC,OAAO,GAAG,QAAQ,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACvD,QAAQ,CAAC,GAAG,GAAG,QAAQ,CAAC,OAAO,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACtD,OAAO,QAAQ,CAAC;IACpB,CAAC;IACL,0BAAC;AAAD,CAAC,AAzID,IAyIC;AAED,kBAAe,mBAAmB,CAAC","sourcesContent":["class AbstractFileManager {\n getPath(filename) {\n let j = filename.lastIndexOf('?');\n if (j > 0) {\n filename = filename.slice(0, j);\n }\n j = filename.lastIndexOf('/');\n if (j < 0) {\n j = filename.lastIndexOf('\\\\');\n }\n if (j < 0) {\n return '';\n }\n return filename.slice(0, j + 1);\n }\n\n tryAppendExtension(path, ext) {\n return /(\\.[a-z]*$)|([?;].*)$/.test(path) ? path : path + ext;\n }\n\n tryAppendLessExtension(path) {\n return this.tryAppendExtension(path, '.less');\n }\n\n supportsSync() {\n return false;\n }\n\n alwaysMakePathsAbsolute() {\n return false;\n }\n\n isPathAbsolute(filename) {\n return (/^(?:[a-z-]+:|\\/|\\\\|#)/i).test(filename);\n }\n\n // TODO: pull out / replace?\n join(basePath, laterPath) {\n if (!basePath) {\n return laterPath;\n }\n return basePath + laterPath;\n }\n\n pathDiff(url, baseUrl) {\n // diff between two paths to create a relative path\n\n const urlParts = this.extractUrlParts(url);\n\n const baseUrlParts = this.extractUrlParts(baseUrl);\n let i;\n let max;\n let urlDirectories;\n let baseUrlDirectories;\n let diff = '';\n if (urlParts.hostPart !== baseUrlParts.hostPart) {\n return '';\n }\n max = Math.max(baseUrlParts.directories.length, urlParts.directories.length);\n for (i = 0; i < max; i++) {\n if (baseUrlParts.directories[i] !== urlParts.directories[i]) { break; }\n }\n baseUrlDirectories = baseUrlParts.directories.slice(i);\n urlDirectories = urlParts.directories.slice(i);\n for (i = 0; i < baseUrlDirectories.length - 1; i++) {\n diff += '../';\n }\n for (i = 0; i < urlDirectories.length - 1; i++) {\n diff += `${urlDirectories[i]}/`;\n }\n return diff;\n }\n\n /**\n * Helper function, not part of API.\n * This should be replaceable by newer Node / Browser APIs\n * \n * @param {string} url \n * @param {string} baseUrl\n */\n extractUrlParts(url, baseUrl) {\n // urlParts[1] = protocol://hostname/ OR /\n // urlParts[2] = / if path relative to host base\n // urlParts[3] = directories\n // urlParts[4] = filename\n // urlParts[5] = parameters\n\n const urlPartsRegex = /^((?:[a-z-]+:)?\\/{2}(?:[^/?#]*\\/)|([/\\\\]))?((?:[^/\\\\?#]*[/\\\\])*)([^/\\\\?#]*)([#?].*)?$/i;\n\n const urlParts = url.match(urlPartsRegex);\n const returner = {};\n let rawDirectories = [];\n const directories = [];\n let i;\n let baseUrlParts;\n\n if (!urlParts) {\n throw new Error(`Could not parse sheet href - '${url}'`);\n }\n\n // Stylesheets in IE don't always return the full path\n if (baseUrl && (!urlParts[1] || urlParts[2])) {\n baseUrlParts = baseUrl.match(urlPartsRegex);\n if (!baseUrlParts) {\n throw new Error(`Could not parse page url - '${baseUrl}'`);\n }\n urlParts[1] = urlParts[1] || baseUrlParts[1] || '';\n if (!urlParts[2]) {\n urlParts[3] = baseUrlParts[3] + urlParts[3];\n }\n }\n\n if (urlParts[3]) {\n rawDirectories = urlParts[3].replace(/\\\\/g, '/').split('/');\n\n // collapse '..' and skip '.'\n for (i = 0; i < rawDirectories.length; i++) {\n\n if (rawDirectories[i] === '..') {\n directories.pop();\n }\n else if (rawDirectories[i] !== '.') {\n directories.push(rawDirectories[i]);\n }\n \n }\n }\n\n returner.hostPart = urlParts[1];\n returner.directories = directories;\n returner.rawPath = (urlParts[1] || '') + rawDirectories.join('/');\n returner.path = (urlParts[1] || '') + directories.join('/');\n returner.filename = urlParts[4];\n returner.fileUrl = returner.path + (urlParts[4] || '');\n returner.url = returner.fileUrl + (urlParts[5] || '');\n return returner;\n }\n}\n\nexport default AbstractFileManager;\n"]} |
| {"version":3,"file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AAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aACjE;SACJ;QACD,OAAO,CAAC,CAAC;IACb,CAAC;IAED,8CAAe,GAAf,UAAgB,OAAO;QACnB,IAAI,aAAa,GAAG,EAAE,CAAC;QACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACrC,aAAa,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;SAC5D;QACD,OAAO,aAAa,CAAC;IACzB,CAAC;IAED,yCAAU,GAAV,UAAW,OAAO;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACrC,IAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YAC1B,IAAI,MAAM,CAAC,UAAU,EAAE;gBACnB,MAAM,CAAC,UAAU,EAAE,CAAC;aACvB;SACJ;IACL,CAAC;IACL,2BAAC;AAAD,CAAC,AAlLD,IAkLC;AAED,kBAAe,oBAAoB,CAAC","sourcesContent":["import functionRegistry from '../functions/function-registry';\nimport LessError from '../less-error';\n\nclass AbstractPluginLoader {\n constructor() {\n // Implemented by Node.js plugin loader\n this.require = function() {\n return null;\n }\n }\n\n evalPlugin(contents, context, imports, pluginOptions, fileInfo) {\n\n let loader, registry, pluginObj, localModule, pluginManager, filename, result;\n\n pluginManager = context.pluginManager;\n\n if (fileInfo) {\n if (typeof fileInfo === 'string') {\n filename = fileInfo;\n }\n else {\n filename = fileInfo.filename;\n }\n }\n const shortname = (new this.less.FileManager()).extractUrlParts(filename).filename;\n\n if (filename) {\n pluginObj = pluginManager.get(filename);\n\n if (pluginObj) {\n result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions);\n if (result) {\n return result;\n }\n try {\n if (pluginObj.use) {\n pluginObj.use.call(this.context, pluginObj);\n }\n }\n catch (e) {\n e.message = e.message || 'Error during @plugin call';\n return new LessError(e, imports, filename);\n }\n return pluginObj;\n }\n }\n localModule = {\n exports: {},\n pluginManager,\n fileInfo\n };\n registry = functionRegistry.create();\n\n const registerPlugin = function(obj) {\n pluginObj = obj;\n };\n\n try {\n loader = new Function('module', 'require', 'registerPlugin', 'functions', 'tree', 'less', 'fileInfo', contents);\n loader(localModule, this.require(filename), registerPlugin, registry, this.less.tree, this.less, fileInfo);\n }\n catch (e) {\n return new LessError(e, imports, filename);\n }\n\n if (!pluginObj) {\n pluginObj = localModule.exports;\n }\n pluginObj = this.validatePlugin(pluginObj, filename, shortname);\n\n if (pluginObj instanceof LessError) {\n return pluginObj;\n }\n\n if (pluginObj) {\n pluginObj.imports = imports;\n pluginObj.filename = filename;\n\n // For < 3.x (or unspecified minVersion) - setOptions() before install()\n if (!pluginObj.minVersion || this.compareVersion('3.0.0', pluginObj.minVersion) < 0) {\n result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions);\n\n if (result) {\n return result;\n }\n }\n\n // Run on first load\n pluginManager.addPlugin(pluginObj, fileInfo.filename, registry);\n pluginObj.functions = registry.getLocalFunctions();\n\n // Need to call setOptions again because the pluginObj might have functions\n result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions);\n if (result) {\n return result;\n }\n\n // Run every @plugin call\n try {\n if (pluginObj.use) {\n pluginObj.use.call(this.context, pluginObj);\n }\n }\n catch (e) {\n e.message = e.message || 'Error during @plugin call';\n return new LessError(e, imports, filename);\n }\n\n }\n else {\n return new LessError({ message: 'Not a valid plugin' }, imports, filename);\n }\n\n return pluginObj;\n\n }\n\n trySetOptions(plugin, filename, name, options) {\n if (options && !plugin.setOptions) {\n return new LessError({\n message: `Options have been provided but the plugin ${name} does not support any options.`\n });\n }\n try {\n plugin.setOptions && plugin.setOptions(options);\n }\n catch (e) {\n return new LessError(e);\n }\n }\n\n validatePlugin(plugin, filename, name) {\n if (plugin) {\n // support plugins being a function\n // so that the plugin can be more usable programmatically\n if (typeof plugin === 'function') {\n plugin = new plugin();\n }\n\n if (plugin.minVersion) {\n if (this.compareVersion(plugin.minVersion, this.less.version) < 0) {\n return new LessError({\n message: `Plugin ${name} requires version ${this.versionToString(plugin.minVersion)}`\n });\n }\n }\n return plugin;\n }\n return null;\n }\n\n compareVersion(aVersion, bVersion) {\n if (typeof aVersion === 'string') {\n aVersion = aVersion.match(/^(\\d+)\\.?(\\d+)?\\.?(\\d+)?/);\n aVersion.shift();\n }\n for (let i = 0; i < aVersion.length; i++) {\n if (aVersion[i] !== bVersion[i]) {\n return parseInt(aVersion[i]) > parseInt(bVersion[i]) ? -1 : 1;\n }\n }\n return 0;\n }\n\n versionToString(version) {\n let versionString = '';\n for (let i = 0; i < version.length; i++) {\n versionString += (versionString ? '.' : '') + version[i];\n }\n return versionString;\n }\n\n printUsage(plugins) {\n for (let i = 0; i < plugins.length; i++) {\n const plugin = plugins[i];\n if (plugin.printUsage) {\n plugin.printUsage();\n }\n }\n }\n}\n\nexport default AbstractPluginLoader;\n\n"]} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| //# sourceMappingURL=environment-api.js.map |
| {"version":3,"file":"environment-api.js","sourceRoot":"","sources":["../../../src/less/environment/environment-api.ts"],"names":[],"mappings":"","sourcesContent":["export interface Environment {\n /**\n * Converts a string to a base 64 string\n */\n encodeBase64(str: string): string\n /**\n * Lookup the mime-type of a filename\n */\n mimeLookup(filename: string): string\n /**\n * Look up the charset of a mime type\n * @param mime\n */\n charsetLookup(mime: string): string\n /**\n * Gets a source map generator\n *\n * @todo - Figure out precise type\n */\n getSourceMapGenerator(): any\n}\n"]} |
| {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/less/environment/environment.js"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6DAA+B;AAE/B;IACI,qBAAY,mBAAmB,EAAE,YAAY;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AAC;SAC1F;QACD,KAAK,IAAI,CAAC,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAG,CAAC,EAAE,EAAE;YAChD,IAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;YACpC,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE;gBACrG,OAAO,WAAW,CAAC;aACtB;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,oCAAc,GAAd,UAAe,WAAW;QACtB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACxC,CAAC;IAED,uCAAiB,GAAjB;QACI,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;IAC3B,CAAC;IACL,kBAAC;AAAD,CAAC,AAjDD,IAiDC;AAED,kBAAe,WAAW,CAAC","sourcesContent":["/**\n * @todo Document why this abstraction exists, and the relationship between\n * environment, file managers, and plugin manager\n */\n\nimport logger from '../logger';\n\nclass Environment {\n constructor(externalEnvironment, fileManagers) {\n this.fileManagers = fileManagers || [];\n externalEnvironment = externalEnvironment || {};\n\n const optionalFunctions = ['encodeBase64', 'mimeLookup', 'charsetLookup', 'getSourceMapGenerator'];\n const requiredFunctions = [];\n const functions = requiredFunctions.concat(optionalFunctions);\n\n for (let i = 0; i < functions.length; i++) {\n const propName = functions[i];\n const environmentFunc = externalEnvironment[propName];\n if (environmentFunc) {\n this[propName] = environmentFunc.bind(externalEnvironment);\n } else if (i < requiredFunctions.length) {\n this.warn(`missing required function in environment - ${propName}`);\n }\n }\n }\n\n getFileManager(filename, currentDirectory, options, environment, isSync) {\n\n if (!filename) {\n logger.warn('getFileManager called with no filename.. Please report this issue. continuing.');\n }\n if (currentDirectory === undefined) {\n logger.warn('getFileManager called with null directory.. Please report this issue. continuing.');\n }\n\n let fileManagers = this.fileManagers;\n if (options.pluginManager) {\n fileManagers = [].concat(fileManagers).concat(options.pluginManager.getFileManagers());\n }\n for (let i = fileManagers.length - 1; i >= 0 ; i--) {\n const fileManager = fileManagers[i];\n if (fileManager[isSync ? 'supportsSync' : 'supports'](filename, currentDirectory, options, environment)) {\n return fileManager;\n }\n }\n return null;\n }\n\n addFileManager(fileManager) {\n this.fileManagers.push(fileManager);\n }\n\n clearFileManagers() {\n this.fileManagers = [];\n }\n}\n\nexport default Environment;\n"]} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| //# sourceMappingURL=file-manager-api.js.map |
| {"version":3,"file":"file-manager-api.js","sourceRoot":"","sources":["../../../src/less/environment/file-manager-api.ts"],"names":[],"mappings":"","sourcesContent":["import type { Environment } from './environment-api'\n\nexport interface FileManager {\n /**\n * Given the full path to a file, return the path component\n * Provided by AbstractFileManager\n */\n getPath(filename: string): string\n /**\n * Append a .less extension if appropriate. Only called if less thinks one could be added.\n * Provided by AbstractFileManager\n */\n tryAppendLessExtension(filename: string): string\n /**\n * Whether the rootpath should be converted to be absolute.\n * The browser ovverides this to return true because urls must be absolute.\n * Provided by AbstractFileManager (returns false)\n */\n alwaysMakePathsAbsolute(): boolean\n /**\n * Returns whether a path is absolute\n * Provided by AbstractFileManager\n */\n isPathAbsolute(path: string): boolean\n /**\n * joins together 2 paths\n * Provided by AbstractFileManager\n */\n join(basePath: string, laterPath: string): string\n /**\n * Returns the difference between 2 paths\n * E.g. url = a/ baseUrl = a/b/ returns ../\n * url = a/b/ baseUrl = a/ returns b/\n * Provided by AbstractFileManager\n */\n pathDiff(url: string, baseUrl: string): string\n /**\n * Returns whether this file manager supports this file for syncronous file retrieval\n * If true is returned, loadFileSync will then be called with the file.\n * Provided by AbstractFileManager (returns false)\n * \n * @todo - Narrow Options type\n */\n supportsSync(\n filename: string,\n currentDirectory: string,\n options: Record<string, any>,\n environment: Environment\n ): boolean\n /**\n * If file manager supports async file retrieval for this file type\n */\n supports(\n filename: string,\n currentDirectory: string,\n options: Record<string, any>,\n environment: Environment\n ): boolean\n /**\n * Loads a file asynchronously.\n */\n loadFile(\n filename: string,\n currentDirectory: string,\n options: Record<string, any>,\n environment: Environment\n ): Promise<{ filename: string, contents: string }>\n /**\n * Loads a file synchronously. Expects an immediate return with an object\n */\n loadFileSync(\n filename: string,\n currentDirectory: string,\n options: Record<string, any>,\n environment: Environment\n ): { error?: unknown, filename: string, contents: string }\n}\n"]} |
| {"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../../src/less/functions/boolean.js"],"names":[],"mappings":";;;AAAA,wEAA0C;AAC1C,oEAAsC;AAEtC,SAAS,OAAO,CAAC,SAAS;IACtB,OAAO,SAAS,CAAC,CAAC,CAAC,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAO,CAAC,KAAK,CAAC;AACpD,CAAC;AAED;;;GAGG;AACH,SAAS,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU;IACjD,OAAO,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC;QACpD,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,mBAAS,CAAC,CAAC;AAClE,CAAC;AACD,EAAE,CAAC,QAAQ,GAAG,KAAK,CAAC;AAEpB,SAAS,SAAS,CAAC,OAAO,EAAE,QAAQ;IAChC,IAAI;QACA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,OAAO,iBAAO,CAAC,IAAI,CAAC;KACvB;IAAC,OAAO,CAAC,EAAE;QACR,OAAO,iBAAO,CAAC,KAAK,CAAC;KACxB;AACL,CAAC;AAED,SAAS,CAAC,QAAQ,GAAG,KAAK,CAAC;AAE3B,kBAAe,EAAE,SAAS,WAAA,EAAE,OAAO,SAAA,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC","sourcesContent":["import Anonymous from '../tree/anonymous';\nimport Keyword from '../tree/keyword';\n\nfunction boolean(condition) {\n return condition ? Keyword.True : Keyword.False;\n}\n\n/**\n * Functions with evalArgs set to false are sent context\n * as the first argument.\n */\nfunction If(context, condition, trueValue, falseValue) {\n return condition.eval(context) ? trueValue.eval(context)\n : (falseValue ? falseValue.eval(context) : new Anonymous);\n}\nIf.evalArgs = false;\n\nfunction isdefined(context, variable) {\n try {\n variable.eval(context);\n return Keyword.True;\n } catch (e) {\n return Keyword.False;\n }\n}\n\nisdefined.evalArgs = false;\n\nexport default { isdefined, boolean, 'if': If };\n"]} |
| {"version":3,"file":"color-blending.js","sourceRoot":"","sources":["../../../src/less/functions/color-blending.js"],"names":[],"mappings":";;;AAAA,gEAAkC;AAElC,iBAAiB;AACjB,0CAA0C;AAE1C,SAAS,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM;IACpC,IAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAQ,SAAS;IAEzC,IAAI,WAAW;IACX,EAAE,CAAC;IAEP,IAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC;IAExB,IAAI,SAAS;IACT,EAAE,CAAC;IAEP,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,IAAM,CAAC,GAAG,EAAE,CAAC;IAEb,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QACxB,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QACzB,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QACzB,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAClB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SACxC;QACD,OAAO,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IAC5C,CAAC;IACD,SAAS,EAAE,UAAS,EAAE,EAAE,EAAE;QACtB,OAAO,uBAAuB,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACnD,CAAC;IACD,UAAU,EAAE,UAAS,EAAE,EAAE,EAAE;QACvB,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7B,CAAC;IACD,SAAS,EAAE,UAAS,EAAE,EAAE,EAAE;QACtB,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC;IACjC,CAAC;IAED,qBAAqB;IACrB,OAAO,EAAE,UAAS,EAAE,EAAE,EAAE;QACpB,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IACD,QAAQ,EAAE,UAAS,EAAE,EAAE,EAAE;QACrB,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACrC,CAAC;CACJ,CAAC;AAEF,KAAK,IAAM,CAAC,IAAI,uBAAuB,EAAE;IACrC,iDAAiD;IACjD,IAAI,uBAAuB,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE;QAC3C,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;KACrE;CACJ;AAED,kBAAe,UAAU,CAAC","sourcesContent":["import Color from '../tree/color';\n\n// Color Blending\n// ref: http://www.w3.org/TR/compositing-1\n\nfunction colorBlend(mode, color1, color2) {\n const ab = color1.alpha; // result\n\n let // backdrop\n cb;\n\n const as = color2.alpha;\n\n let // source\n cs;\n\n let ar;\n let cr;\n const r = [];\n\n ar = as + ab * (1 - as);\n for (let i = 0; i < 3; i++) {\n cb = color1.rgb[i] / 255;\n cs = color2.rgb[i] / 255;\n cr = mode(cb, cs);\n if (ar) {\n cr = (as * cs + ab * (cb -\n as * (cb + cs - cr))) / ar;\n }\n r[i] = cr * 255;\n }\n\n return new Color(r, ar);\n}\n\nconst colorBlendModeFunctions = {\n multiply: function(cb, cs) {\n return cb * cs;\n },\n screen: function(cb, cs) {\n return cb + cs - cb * cs;\n },\n overlay: function(cb, cs) {\n cb *= 2;\n return (cb <= 1) ?\n colorBlendModeFunctions.multiply(cb, cs) :\n colorBlendModeFunctions.screen(cb - 1, cs);\n },\n softlight: function(cb, cs) {\n let d = 1;\n let e = cb;\n if (cs > 0.5) {\n e = 1;\n d = (cb > 0.25) ? Math.sqrt(cb)\n : ((16 * cb - 12) * cb + 4) * cb;\n }\n return cb - (1 - 2 * cs) * e * (d - cb);\n },\n hardlight: function(cb, cs) {\n return colorBlendModeFunctions.overlay(cs, cb);\n },\n difference: function(cb, cs) {\n return Math.abs(cb - cs);\n },\n exclusion: function(cb, cs) {\n return cb + cs - 2 * cb * cs;\n },\n\n // non-w3c functions:\n average: function(cb, cs) {\n return (cb + cs) / 2;\n },\n negation: function(cb, cs) {\n return 1 - Math.abs(cb + cs - 1);\n }\n};\n\nfor (const f in colorBlendModeFunctions) {\n // eslint-disable-next-line no-prototype-builtins\n if (colorBlendModeFunctions.hasOwnProperty(f)) {\n colorBlend[f] = colorBlend.bind(null, colorBlendModeFunctions[f]);\n }\n}\n\nexport default colorBlend;\n"]} |
| {"version":3,"file":"color.js","sourceRoot":"","sources":["../../../src/less/functions/color.js"],"names":[],"mappings":";;;AAAA,wEAA0C;AAC1C,gEAAkC;AAClC,kEAAoC;AACpC,wEAA0C;AAC1C,0EAA4C;AAC5C,wEAA0C;AAC1C,IAAI,cAAc,CAAC;AAEnB,SAAS,KAAK,CAAC,GAAG;IACd,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EA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AK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC7B,OAAO,IAAI,eAAK,CAAC,GAAG,EAAE,SAAS,EAAE,WAAI,GAAG,CAAE,CAAC,CAAC;SAC/C;QACD,IAAI,CAAC,CAAC,YAAY,eAAK,CAAC,IAAI,CAAC,CAAC,GAAG,eAAK,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE;YAC1D,CAAC,CAAC,KAAK,GAAG,SAAS,CAAC;YACpB,OAAO,CAAC,CAAC;SACZ;QACD,MAAM;YACF,IAAI,EAAK,UAAU;YACnB,OAAO,EAAE,iEAAiE;SAC7E,CAAC;IACN,CAAC;IACD,IAAI,EAAE,UAAS,KAAK,EAAE,MAAM;QACxB,OAAO,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAChF,CAAC;IACD,KAAK,EAAE,UAAS,KAAK,EAAE,MAAM;QACzB,OAAO,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAC1E,CAAC;CACJ,CAAC;AAEF,kBAAe,cAAc,CAAC","sourcesContent":["import Dimension from '../tree/dimension';\nimport Color from '../tree/color';\nimport Quoted from '../tree/quoted';\nimport Anonymous from '../tree/anonymous';\nimport Expression from '../tree/expression';\nimport Operation from '../tree/operation';\nlet colorFunctions;\n\nfunction clamp(val) {\n return Math.min(1, Math.max(0, val));\n}\nfunction hsla(origColor, hsl) {\n const color = colorFunctions.hsla(hsl.h, hsl.s, hsl.l, hsl.a);\n if (color) {\n if (origColor.value && \n /^(rgb|hsl)/.test(origColor.value)) {\n color.value = origColor.value;\n } else {\n color.value = 'rgb';\n }\n return color;\n }\n}\nfunction toHSL(color) {\n if (color.toHSL) {\n return color.toHSL();\n } else {\n throw new Error('Argument cannot be evaluated to a color');\n }\n}\n\nfunction toHSV(color) {\n if (color.toHSV) {\n return color.toHSV();\n } else {\n throw new Error('Argument cannot be evaluated to a color');\n }\n}\n\nfunction number(n) {\n if (n instanceof Dimension) {\n return parseFloat(n.unit.is('%') ? n.value / 100 : n.value);\n } else if (typeof n === 'number') {\n return n;\n } else {\n throw {\n type: 'Argument',\n message: 'color functions take numbers as parameters'\n };\n }\n}\nfunction scaled(n, size) {\n if (n instanceof Dimension && n.unit.is('%')) {\n return parseFloat(n.value * size / 100);\n } else {\n return number(n);\n }\n}\ncolorFunctions = {\n rgb: function (r, g, b) {\n let a = 1\n /**\n * Comma-less syntax\n * e.g. rgb(0 128 255 / 50%)\n */\n if (r instanceof Expression) {\n const val = r.value\n r = val[0]\n g = val[1]\n b = val[2]\n /** \n * @todo - should this be normalized in\n * function caller? Or parsed differently?\n */\n if (b instanceof Operation) {\n const op = b\n b = op.operands[0]\n a = op.operands[1]\n }\n }\n const color = colorFunctions.rgba(r, g, b, a);\n if (color) {\n color.value = 'rgb';\n return color;\n }\n },\n rgba: function (r, g, b, a) {\n try {\n if (r instanceof Color) {\n if (g) {\n a = number(g);\n } else {\n a = r.alpha;\n }\n return new Color(r.rgb, a, 'rgba');\n }\n const rgb = [r, g, b].map(c => scaled(c, 255));\n a = number(a);\n return new Color(rgb, a, 'rgba');\n }\n catch (e) {}\n },\n hsl: function (h, s, l) {\n let a = 1\n if (h instanceof Expression) {\n const val = h.value\n h = val[0]\n s = val[1]\n l = val[2]\n\n if (l instanceof Operation) {\n const op = l\n l = op.operands[0]\n a = op.operands[1]\n }\n }\n const color = colorFunctions.hsla(h, s, l, a);\n if (color) {\n color.value = 'hsl';\n return color;\n }\n },\n hsla: function (h, s, l, a) {\n let m1;\n let m2;\n\n function hue(h) {\n h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);\n if (h * 6 < 1) {\n return m1 + (m2 - m1) * h * 6;\n }\n else if (h * 2 < 1) {\n return m2;\n }\n else if (h * 3 < 2) {\n return m1 + (m2 - m1) * (2 / 3 - h) * 6;\n }\n else {\n return m1;\n }\n }\n\n try {\n if (h instanceof Color) {\n if (s) {\n a = number(s);\n } else {\n a = h.alpha;\n }\n return new Color(h.rgb, a, 'hsla');\n }\n\n h = (number(h) % 360) / 360;\n s = clamp(number(s));l = clamp(number(l));a = clamp(number(a));\n\n m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;\n m1 = l * 2 - m2;\n\n const rgb = [\n hue(h + 1 / 3) * 255,\n hue(h) * 255,\n hue(h - 1 / 3) * 255\n ];\n a = number(a);\n return new Color(rgb, a, 'hsla');\n }\n catch (e) {}\n },\n\n hsv: function(h, s, v) {\n return colorFunctions.hsva(h, s, v, 1.0);\n },\n\n hsva: function(h, s, v, a) {\n h = ((number(h) % 360) / 360) * 360;\n s = number(s);v = number(v);a = number(a);\n\n let i;\n let f;\n i = Math.floor((h / 60) % 6);\n f = (h / 60) - i;\n\n const vs = [v,\n v * (1 - s),\n v * (1 - f * s),\n v * (1 - (1 - f) * s)];\n const perm = [[0, 3, 1],\n [2, 0, 1],\n [1, 0, 3],\n [1, 2, 0],\n [3, 1, 0],\n [0, 1, 2]];\n\n return colorFunctions.rgba(vs[perm[i][0]] * 255,\n vs[perm[i][1]] * 255,\n vs[perm[i][2]] * 255,\n a);\n },\n\n hue: function (color) {\n return new Dimension(toHSL(color).h);\n },\n saturation: function (color) {\n return new Dimension(toHSL(color).s * 100, '%');\n },\n lightness: function (color) {\n return new Dimension(toHSL(color).l * 100, '%');\n },\n hsvhue: function(color) {\n return new Dimension(toHSV(color).h);\n },\n hsvsaturation: function (color) {\n return new Dimension(toHSV(color).s * 100, '%');\n },\n hsvvalue: function (color) {\n return new Dimension(toHSV(color).v * 100, '%');\n },\n red: function (color) {\n return new Dimension(color.rgb[0]);\n },\n green: function (color) {\n return new Dimension(color.rgb[1]);\n },\n blue: function (color) {\n return new Dimension(color.rgb[2]);\n },\n alpha: function (color) {\n return new Dimension(toHSL(color).a);\n },\n luma: function (color) {\n return new Dimension(color.luma() * color.alpha * 100, '%');\n },\n luminance: function (color) {\n const luminance =\n (0.2126 * color.rgb[0] / 255) +\n (0.7152 * color.rgb[1] / 255) +\n (0.0722 * color.rgb[2] / 255);\n\n return new Dimension(luminance * color.alpha * 100, '%');\n },\n saturate: function (color, amount, method) {\n // filter: saturate(3.2);\n // should be kept as is, so check for color\n if (!color.rgb) {\n return null;\n }\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.s += hsl.s * amount.value / 100;\n }\n else {\n hsl.s += amount.value / 100;\n }\n hsl.s = clamp(hsl.s);\n return hsla(color, hsl);\n },\n desaturate: function (color, amount, method) {\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.s -= hsl.s * amount.value / 100;\n }\n else {\n hsl.s -= amount.value / 100;\n }\n hsl.s = clamp(hsl.s);\n return hsla(color, hsl);\n },\n lighten: function (color, amount, method) {\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.l += hsl.l * amount.value / 100;\n }\n else {\n hsl.l += amount.value / 100;\n }\n hsl.l = clamp(hsl.l);\n return hsla(color, hsl);\n },\n darken: function (color, amount, method) {\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.l -= hsl.l * amount.value / 100;\n }\n else {\n hsl.l -= amount.value / 100;\n }\n hsl.l = clamp(hsl.l);\n return hsla(color, hsl);\n },\n fadein: function (color, amount, method) {\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.a += hsl.a * amount.value / 100;\n }\n else {\n hsl.a += amount.value / 100;\n }\n hsl.a = clamp(hsl.a);\n return hsla(color, hsl);\n },\n fadeout: function (color, amount, method) {\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.a -= hsl.a * amount.value / 100;\n }\n else {\n hsl.a -= amount.value / 100;\n }\n hsl.a = clamp(hsl.a);\n return hsla(color, hsl);\n },\n fade: function (color, amount) {\n const hsl = toHSL(color);\n\n hsl.a = amount.value / 100;\n hsl.a = clamp(hsl.a);\n return hsla(color, hsl);\n },\n spin: function (color, amount) {\n const hsl = toHSL(color);\n const hue = (hsl.h + amount.value) % 360;\n\n hsl.h = hue < 0 ? 360 + hue : hue;\n\n return hsla(color, hsl);\n },\n //\n // Copyright (c) 2006-2009 Hampton Catlin, Natalie Weizenbaum, and Chris Eppstein\n // http://sass-lang.com\n //\n mix: function (color1, color2, weight) {\n if (!weight) {\n weight = new Dimension(50);\n }\n const p = weight.value / 100.0;\n const w = p * 2 - 1;\n const a = toHSL(color1).a - toHSL(color2).a;\n\n const w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;\n const w2 = 1 - w1;\n\n const rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2,\n color1.rgb[1] * w1 + color2.rgb[1] * w2,\n color1.rgb[2] * w1 + color2.rgb[2] * w2];\n\n const alpha = color1.alpha * p + color2.alpha * (1 - p);\n\n return new Color(rgb, alpha);\n },\n greyscale: function (color) {\n return colorFunctions.desaturate(color, new Dimension(100));\n },\n contrast: function (color, dark, light, threshold) {\n // filter: contrast(3.2);\n // should be kept as is, so check for color\n if (!color.rgb) {\n return null;\n }\n if (typeof light === 'undefined') {\n light = colorFunctions.rgba(255, 255, 255, 1.0);\n }\n if (typeof dark === 'undefined') {\n dark = colorFunctions.rgba(0, 0, 0, 1.0);\n }\n // Figure out which is actually light and dark:\n if (dark.luma() > light.luma()) {\n const t = light;\n light = dark;\n dark = t;\n }\n if (typeof threshold === 'undefined') {\n threshold = 0.43;\n } else {\n threshold = number(threshold);\n }\n if (color.luma() < threshold) {\n return light;\n } else {\n return dark;\n }\n },\n // Changes made in 2.7.0 - Reverted in 3.0.0\n // contrast: function (color, color1, color2, threshold) {\n // // Return which of `color1` and `color2` has the greatest contrast with `color`\n // // according to the standard WCAG contrast ratio calculation.\n // // http://www.w3.org/TR/WCAG20/#contrast-ratiodef\n // // The threshold param is no longer used, in line with SASS.\n // // filter: contrast(3.2);\n // // should be kept as is, so check for color\n // if (!color.rgb) {\n // return null;\n // }\n // if (typeof color1 === 'undefined') {\n // color1 = colorFunctions.rgba(0, 0, 0, 1.0);\n // }\n // if (typeof color2 === 'undefined') {\n // color2 = colorFunctions.rgba(255, 255, 255, 1.0);\n // }\n // var contrast1, contrast2;\n // var luma = color.luma();\n // var luma1 = color1.luma();\n // var luma2 = color2.luma();\n // // Calculate contrast ratios for each color\n // if (luma > luma1) {\n // contrast1 = (luma + 0.05) / (luma1 + 0.05);\n // } else {\n // contrast1 = (luma1 + 0.05) / (luma + 0.05);\n // }\n // if (luma > luma2) {\n // contrast2 = (luma + 0.05) / (luma2 + 0.05);\n // } else {\n // contrast2 = (luma2 + 0.05) / (luma + 0.05);\n // }\n // if (contrast1 > contrast2) {\n // return color1;\n // } else {\n // return color2;\n // }\n // },\n argb: function (color) {\n return new Anonymous(color.toARGB());\n },\n color: function(c) {\n if ((c instanceof Quoted) &&\n (/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})$/i.test(c.value))) {\n const val = c.value.slice(1);\n return new Color(val, undefined, `#${val}`);\n }\n if ((c instanceof Color) || (c = Color.fromKeyword(c.value))) {\n c.value = undefined;\n return c;\n }\n throw {\n type: 'Argument',\n message: 'argument must be a color keyword or 3|4|6|8 digit hex e.g. #FFF'\n };\n },\n tint: function(color, amount) {\n return colorFunctions.mix(colorFunctions.rgb(255, 255, 255), color, amount);\n },\n shade: function(color, amount) {\n return colorFunctions.mix(colorFunctions.rgb(0, 0, 0), color, amount);\n }\n};\n\nexport default colorFunctions;\n"]} |
| {"version":3,"file":"data-uri.js","sourceRoot":"","sources":["../../../src/less/functions/data-uri.js"],"names":[],"mappings":";;;AAAA,kEAAoC;AACpC,4DAA8B;AAC9B,sDAAkC;AAClC,6DAA+B;AAE/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G,GAAG,eAAQ,QAAQ,cAAI,GAAG,SAAG,QAAQ,CAAE,CAAC;YAEjD,OAAO,IAAI,aAAG,CAAC,IAAI,gBAAM,CAAC,YAAI,GAAG,OAAG,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAC3H,CAAC,EAAC,CAAC;AACP,CAAC,EAAC","sourcesContent":["import Quoted from '../tree/quoted';\nimport URL from '../tree/url';\nimport * as utils from '../utils';\nimport logger from '../logger';\n\nexport default environment => {\n \n const fallback = (functionThis, node) => new URL(node, functionThis.index, functionThis.currentFileInfo).eval(functionThis.context); \n\n return { 'data-uri': function(mimetypeNode, filePathNode) {\n\n if (!filePathNode) {\n filePathNode = mimetypeNode;\n mimetypeNode = null;\n }\n\n let mimetype = mimetypeNode && mimetypeNode.value;\n let filePath = filePathNode.value;\n const currentFileInfo = this.currentFileInfo;\n const currentDirectory = currentFileInfo.rewriteUrls ?\n currentFileInfo.currentDirectory : currentFileInfo.entryPath;\n\n const fragmentStart = filePath.indexOf('#');\n let fragment = '';\n if (fragmentStart !== -1) {\n fragment = filePath.slice(fragmentStart);\n filePath = filePath.slice(0, fragmentStart);\n }\n const context = utils.clone(this.context);\n context.rawBuffer = true;\n\n const fileManager = environment.getFileManager(filePath, currentDirectory, context, environment, true);\n\n if (!fileManager) {\n return fallback(this, filePathNode);\n }\n\n let useBase64 = false;\n\n // detect the mimetype if not given\n if (!mimetypeNode) {\n\n mimetype = environment.mimeLookup(filePath);\n\n if (mimetype === 'image/svg+xml') {\n useBase64 = false;\n } else {\n // use base 64 unless it's an ASCII or UTF-8 format\n const charset = environment.charsetLookup(mimetype);\n useBase64 = ['US-ASCII', 'UTF-8'].indexOf(charset) < 0;\n }\n if (useBase64) { mimetype += ';base64'; }\n }\n else {\n useBase64 = /;base64$/.test(mimetype);\n }\n\n const fileSync = fileManager.loadFileSync(filePath, currentDirectory, context, environment);\n if (!fileSync.contents) {\n logger.warn(`Skipped data-uri embedding of ${filePath} because file not found`);\n return fallback(this, filePathNode || mimetypeNode);\n }\n let buf = fileSync.contents;\n if (useBase64 && !environment.encodeBase64) {\n return fallback(this, filePathNode);\n }\n\n buf = useBase64 ? environment.encodeBase64(buf) : encodeURIComponent(buf);\n\n const uri = `data:${mimetype},${buf}${fragment}`;\n\n return new URL(new Quoted(`\"${uri}\"`, uri, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo);\n }};\n};\n"]} |
| {"version":3,"file":"default.js","sourceRoot":"","sources":["../../../src/less/functions/default.js"],"names":[],"mappings":";;;AAAA,oEAAsC;AACtC,sDAAkC;AAElC,IAAM,WAAW,GAAG;IAChB,IAAI,EAAE;QACF,IAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QACtB,IAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QACtB,IAAI,CAAC,EAAE;YACH,MAAM,CAAC,CAAC;SACX;QACD,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE;YAC7B,OAAO,CAAC,CAAC,CAAC,CAAC,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAO,CAAC,KAAK,CAAC;SAC3C;IACL,CAAC;IACD,KAAK,EAAE,UAAU,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,CAAC;IACD,KAAK,EAAE,UAAU,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,CAAC;IACD,KAAK,EAAE;QACH,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrC,CAAC;CACJ,CAAC;AAEF,kBAAe,WAAW,CAAC","sourcesContent":["import Keyword from '../tree/keyword';\nimport * as utils from '../utils';\n\nconst defaultFunc = {\n eval: function () {\n const v = this.value_;\n const e = this.error_;\n if (e) {\n throw e;\n }\n if (!utils.isNullOrUndefined(v)) {\n return v ? Keyword.True : Keyword.False;\n }\n },\n value: function (v) {\n this.value_ = v;\n },\n error: function (e) {\n this.error_ = e;\n },\n reset: function () {\n this.value_ = this.error_ = null;\n }\n};\n\nexport default defaultFunc;\n"]} |
| {"version":3,"file":"function-caller.js","sourceRoot":"","sources":["../../../src/less/functions/function-caller.js"],"names":[],"mappings":";;;AAAA,0EAA4C;AAE5C;IACI,wBAAY,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe;QAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QAEvC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClE,CAAC;IAED,gCAAO,GAAP;QACI,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,6BAAI,GAAJ,UAAK,IAAI;QAAT,iBAmCC;QAlCG,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE;YACxB,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;SACjB;QACD,IAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;QACpC,IAAI,QAAQ,KAAK,KAAK,EAAE;YACpB,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,CAAC,KAAI,CAAC,OAAO,CAAC,EAApB,CAAoB,CAAC,CAAC;SAC9C;QACD,IAAM,aAAa,GAAG,UAAA,IAAI,IAAI,OAAA,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,EAA1B,CAA0B,CAAC;QAEzD,oEAAoE;QACpE,8CAA8C;QAC9C,IAAI,GAAG,IAAI;aACN,MAAM,CAAC,aAAa,CAAC;aACrB,GAAG,CAAC,UAAA,IAAI;YACL,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,EAAE;gBAC5B,IAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;gBAClD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;oBACvB,8CAA8C;oBAC9C,IAAI,IAAI,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,EAAE;wBACvC,OAAO,IAAI,CAAC;qBACf;oBACD,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;iBACtB;qBAAM;oBACH,OAAO,IAAI,oBAAU,CAAC,QAAQ,CAAC,CAAC;iBACnC;aACJ;YACD,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;QAEP,IAAI,QAAQ,KAAK,KAAK,EAAE;YACpB,OAAO,IAAI,CAAC,IAAI,OAAT,IAAI,yBAAM,IAAI,CAAC,OAAO,GAAK,IAAI,UAAE;SAC3C;QAED,OAAO,IAAI,CAAC,IAAI,OAAT,IAAI,EAAS,IAAI,EAAE;IAC9B,CAAC;IACL,qBAAC;AAAD,CAAC,AAlDD,IAkDC;AAED,kBAAe,cAAc,CAAC","sourcesContent":["import Expression from '../tree/expression';\n\nclass functionCaller {\n constructor(name, context, index, currentFileInfo) {\n this.name = name.toLowerCase();\n this.index = index;\n this.context = context;\n this.currentFileInfo = currentFileInfo;\n\n this.func = context.frames[0].functionRegistry.get(this.name);\n }\n\n isValid() {\n return Boolean(this.func);\n }\n\n call(args) {\n if (!(Array.isArray(args))) {\n args = [args];\n }\n const evalArgs = this.func.evalArgs;\n if (evalArgs !== false) {\n args = args.map(a => a.eval(this.context));\n }\n const commentFilter = item => !(item.type === 'Comment');\n\n // This code is terrible and should be replaced as per this issue...\n // https://github.com/less/less.js/issues/2477\n args = args\n .filter(commentFilter)\n .map(item => {\n if (item.type === 'Expression') {\n const subNodes = item.value.filter(commentFilter);\n if (subNodes.length === 1) {\n // https://github.com/less/less.js/issues/3616\n if (item.parens && subNodes[0].op === '/') {\n return item;\n }\n return subNodes[0];\n } else {\n return new Expression(subNodes);\n }\n }\n return item;\n });\n\n if (evalArgs === false) {\n return this.func(this.context, ...args);\n }\n\n return this.func(...args);\n }\n}\n\nexport default functionCaller;\n"]} |
| {"version":3,"file":"function-registry.js","sourceRoot":"","sources":["../../../src/less/functions/function-registry.js"],"names":[],"mappings":";;AAAA,SAAS,YAAY,CAAE,IAAI;IACvB,OAAO;QACH,KAAK,EAAE,EAAE;QACT,GAAG,EAAE,UAAS,IAAI,EAAE,IAAI;YACpB,sDAAsD;YACtD,2DAA2D;YAC3D,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YAE1B,iDAAiD;YACjD,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE;gBACjC,YAAY;aACf;YACD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QAC5B,CAAC;QACD,WAAW,EAAE,UAAS,SAAS;YAAlB,iBAKZ;YAJG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAC1B,UAAA,IAAI;gBACA,KAAI,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YACpC,CAAC,CAAC,CAAC;QACX,CAAC;QACD,GAAG,EAAE,UAAS,IAAI;YACd,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAE,IAAI,IAAI,IAAI,CAAC,GAAG,CAAE,IAAI,CAAE,CAAC,CAAC;QAC3D,CAAC;QACD,iBAAiB,EAAE;YACf,OAAO,IAAI,CAAC,KAAK,CAAC;QACtB,CAAC;QACD,OAAO,EAAE;YACL,OAAO,YAAY,CAAE,IAAI,CAAE,CAAC;QAChC,CAAC;QACD,MAAM,EAAE,UAAS,IAAI;YACjB,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;KACJ,CAAC;AACN,CAAC;AAED,kBAAe,YAAY,CAAE,IAAI,CAAE,CAAC","sourcesContent":["function makeRegistry( base ) {\n return {\n _data: {},\n add: function(name, func) {\n // precautionary case conversion, as later querying of\n // the registry by function-caller uses lower case as well.\n name = name.toLowerCase();\n\n // eslint-disable-next-line no-prototype-builtins\n if (this._data.hasOwnProperty(name)) {\n // TODO warn\n }\n this._data[name] = func;\n },\n addMultiple: function(functions) {\n Object.keys(functions).forEach(\n name => {\n this.add(name, functions[name]);\n });\n },\n get: function(name) {\n return this._data[name] || ( base && base.get( name ));\n },\n getLocalFunctions: function() {\n return this._data;\n },\n inherit: function() {\n return makeRegistry( this );\n },\n create: function(base) {\n return makeRegistry(base);\n }\n };\n}\n\nexport default makeRegistry( null );"]} |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/less/functions/index.js"],"names":[],"mappings":";;;AAAA,kFAAmD;AACnD,8EAA+C;AAE/C,8DAAgC;AAChC,8DAAoC;AACpC,0DAA4B;AAC5B,4EAA6C;AAC7C,gEAAiC;AACjC,wDAA0B;AAC1B,wDAA0B;AAC1B,4DAA8B;AAC9B,4DAA8B;AAC9B,sDAAwB;AACxB,0DAA4B;AAC5B,0DAA4B;AAE5B,mBAAe,UAAA,WAAW;IACtB,IAAM,SAAS,GAAG,EAAE,gBAAgB,6BAAA,EAAE,cAAc,2BAAA,EAAE,CAAC;IAEvD,qBAAqB;IACrB,2BAAgB,CAAC,WAAW,CAAC,iBAAO,CAAC,CAAC;IACtC,2BAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,iBAAW,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAW,CAAC,CAAC,CAAC;IACpE,2BAAgB,CAAC,WAAW,CAAC,eAAK,CAAC,CAAC;IACpC,2BAAgB,CAAC,WAAW,CAAC,wBAAa,CAAC,CAAC;IAC5C,2BAAgB,CAAC,WAAW,CAAC,IAAA,kBAAO,EAAC,WAAW,CAAC,CAAC,CAAC;IACnD,2BAAgB,CAAC,WAAW,CAAC,cAAI,CAAC,CAAC;IACnC,2BAAgB,CAAC,WAAW,CAAC,cAAI,CAAC,CAAC;IACnC,2BAAgB,CAAC,WAAW,CAAC,gBAAM,CAAC,CAAC;IACrC,2BAAgB,CAAC,WAAW,CAAC,gBAAM,CAAC,CAAC;IACrC,2BAAgB,CAAC,WAAW,CAAC,IAAA,aAAG,EAAC,WAAW,CAAC,CAAC,CAAC;IAC/C,2BAAgB,CAAC,WAAW,CAAC,eAAK,CAAC,CAAC;IACpC,2BAAgB,CAAC,WAAW,CAAC,eAAK,CAAC,CAAC;IAEpC,OAAO,SAAS,CAAC;AACrB,CAAC,EAAC","sourcesContent":["import functionRegistry from './function-registry';\nimport functionCaller from './function-caller';\n\nimport boolean from './boolean';\nimport defaultFunc from './default';\nimport color from './color';\nimport colorBlending from './color-blending';\nimport dataUri from './data-uri';\nimport list from './list';\nimport math from './math';\nimport number from './number';\nimport string from './string';\nimport svg from './svg';\nimport types from './types';\nimport style from './style';\n\nexport default environment => {\n const functions = { functionRegistry, functionCaller };\n\n // register functions\n functionRegistry.addMultiple(boolean);\n functionRegistry.add('default', defaultFunc.eval.bind(defaultFunc));\n functionRegistry.addMultiple(color);\n functionRegistry.addMultiple(colorBlending);\n functionRegistry.addMultiple(dataUri(environment));\n functionRegistry.addMultiple(list);\n functionRegistry.addMultiple(math);\n functionRegistry.addMultiple(number);\n functionRegistry.addMultiple(string);\n functionRegistry.addMultiple(svg(environment));\n functionRegistry.addMultiple(types);\n functionRegistry.addMultiple(style);\n\n return functions;\n};\n"]} |
| {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/less/functions/list.js"],"names":[],"mappings":";;;AAAA,oEAAsC;AACtC,8DAAgC;AAChC,wEAA0C;AAC1C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C,CAAE,IAAG,CAAC,kBAAQ,CAAC,CAAC,CAAE,IAAI,iBAAO,CAAC,EAAE,EAAE,GAAG,CAAC,CAAE,CAAC,CAAE,EAC1D,KAAK,EACL,EAAE,CAAC,aAAa,EAChB,EAAE,CAAC,cAAc,EAAE,CACtB,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;CACJ,CAAC","sourcesContent":["import Comment from '../tree/comment';\nimport Node from '../tree/node';\nimport Dimension from '../tree/dimension';\nimport Declaration from '../tree/declaration';\nimport Expression from '../tree/expression';\nimport Ruleset from '../tree/ruleset';\nimport Selector from '../tree/selector';\nimport Element from '../tree/element';\nimport Quote from '../tree/quoted';\nimport Value from '../tree/value';\n\nconst getItemsFromNode = node => {\n // handle non-array values as an array of length 1\n // return 'undefined' if index is invalid\n const items = Array.isArray(node.value) ?\n node.value : Array(node);\n\n return items;\n};\n\nexport default {\n _SELF: function(n) {\n return n;\n },\n '~': function(...expr) {\n if (expr.length === 1) {\n return expr[0];\n }\n return new Value(expr);\n },\n extract: function(values, index) {\n // (1-based index)\n index = index.value - 1;\n\n return getItemsFromNode(values)[index];\n },\n length: function(values) {\n return new Dimension(getItemsFromNode(values).length);\n },\n /**\n * Creates a Less list of incremental values.\n * Modeled after Lodash's range function, also exists natively in PHP\n * \n * @param {Dimension} [start=1]\n * @param {Dimension} end - e.g. 10 or 10px - unit is added to output\n * @param {Dimension} [step=1] \n */\n range: function(start, end, step) {\n let from;\n let to;\n let stepValue = 1;\n const list = [];\n if (end) {\n to = end;\n from = start.value;\n if (step) {\n stepValue = step.value;\n }\n }\n else {\n from = 1;\n to = start;\n }\n\n for (let i = from; i <= to.value; i += stepValue) {\n list.push(new Dimension(i, to.unit));\n }\n\n return new Expression(list);\n },\n each: function(list, rs) {\n const rules = [];\n let newRules;\n let iterator;\n\n const tryEval = val => {\n if (val instanceof Node) {\n return val.eval(this.context);\n }\n return val;\n };\n\n if (list.value && !(list instanceof Quote)) {\n if (Array.isArray(list.value)) {\n iterator = list.value.map(tryEval);\n } else {\n iterator = [tryEval(list.value)];\n }\n } else if (list.ruleset) {\n iterator = tryEval(list.ruleset).rules;\n } else if (list.rules) {\n iterator = list.rules.map(tryEval);\n } else if (Array.isArray(list)) {\n iterator = list.map(tryEval);\n } else {\n iterator = [tryEval(list)];\n }\n\n let valueName = '@value';\n let keyName = '@key';\n let indexName = '@index';\n\n if (rs.params) {\n valueName = rs.params[0] && rs.params[0].name;\n keyName = rs.params[1] && rs.params[1].name;\n indexName = rs.params[2] && rs.params[2].name;\n rs = rs.rules;\n } else {\n rs = rs.ruleset;\n }\n\n for (let i = 0; i < iterator.length; i++) {\n let key;\n let value;\n const item = iterator[i];\n if (item instanceof Declaration) {\n key = typeof item.name === 'string' ? item.name : item.name[0].value;\n value = item.value;\n } else {\n key = new Dimension(i + 1);\n value = item;\n }\n\n if (item instanceof Comment) {\n continue;\n }\n\n newRules = rs.rules.slice(0);\n if (valueName) {\n newRules.push(new Declaration(valueName,\n value,\n false, false, this.index, this.currentFileInfo));\n }\n if (indexName) {\n newRules.push(new Declaration(indexName,\n new Dimension(i + 1),\n false, false, this.index, this.currentFileInfo));\n }\n if (keyName) {\n newRules.push(new Declaration(keyName,\n key,\n false, false, this.index, this.currentFileInfo));\n }\n\n rules.push(new Ruleset([ new(Selector)([ new Element('', '&') ]) ],\n newRules,\n rs.strictImports,\n rs.visibilityInfo()\n ));\n }\n\n return new Ruleset([ new(Selector)([ new Element('', '&') ]) ],\n rules,\n rs.strictImports,\n rs.visibilityInfo()\n ).eval(this.context);\n }\n};\n"]} |
| {"version":3,"file":"math-helper.js","sourceRoot":"","sources":["../../../src/less/functions/math-helper.js"],"names":[],"mappings":";;;AAAA,wEAA0C;AAE1C,IAAM,UAAU,GAAG,UAAC,EAAE,EAAE,IAAI,EAAE,CAAC;IAC3B,IAAI,CAAC,CAAC,CAAC,YAAY,mBAAS,CAAC,EAAE;QAC3B,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAC;KACpE;IACD,IAAI,IAAI,KAAK,IAAI,EAAE;QACf,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;KACjB;SAAM;QACH,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;KACjB;IACD,OAAO,IAAI,mBAAS,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AACxD,CAAC,CAAC;AAEF,kBAAe,UAAU,CAAC","sourcesContent":["import Dimension from '../tree/dimension';\n\nconst MathHelper = (fn, unit, n) => {\n if (!(n instanceof Dimension)) {\n throw { type: 'Argument', message: 'argument must be a number' };\n }\n if (unit === null) {\n unit = n.unit;\n } else {\n n = n.unify();\n }\n return new Dimension(fn(parseFloat(n.value)), unit);\n};\n\nexport default MathHelper;"]} |
| {"version":3,"file":"math.js","sourceRoot":"","sources":["../../../src/less/functions/math.js"],"names":[],"mappings":";;;AAAA,4EAA0C;AAE1C,IAAM,aAAa,GAAG;IAClB,cAAc;IACd,IAAI,EAAG,IAAI;IACX,KAAK,EAAE,IAAI;IACX,IAAI,EAAG,IAAI;IACX,GAAG,EAAI,IAAI;IACX,GAAG,EAAI,EAAE;IACT,GAAG,EAAI,EAAE;IACT,GAAG,EAAI,EAAE;IACT,IAAI,EAAG,KAAK;IACZ,IAAI,EAAG,KAAK;IACZ,IAAI,EAAG,KAAK;CACf,CAAC;AAEF,KAAK,IAAM,CAAC,IAAI,aAAa,EAAE;IAC3B,iDAAiD;IACjD,IAAI,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE;QACjC,aAAa,CAAC,CAAC,CAAC,GAAG,wBAAU,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;KACvE;CACJ;AAED,aAAa,CAAC,KAAK,GAAG,UAAC,CAAC,EAAE,CAAC;IACvB,IAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACxD,OAAO,IAAA,wBAAU,EAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,EAArB,CAAqB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC7D,CAAC,CAAC;AAEF,kBAAe,aAAa,CAAC","sourcesContent":["import mathHelper from './math-helper.js';\n\nconst mathFunctions = {\n // name, unit\n ceil: null,\n floor: null,\n sqrt: null,\n abs: null,\n tan: '',\n sin: '',\n cos: '',\n atan: 'rad',\n asin: 'rad',\n acos: 'rad'\n};\n\nfor (const f in mathFunctions) {\n // eslint-disable-next-line no-prototype-builtins\n if (mathFunctions.hasOwnProperty(f)) {\n mathFunctions[f] = mathHelper.bind(null, Math[f], mathFunctions[f]);\n }\n}\n\nmathFunctions.round = (n, f) => {\n const fraction = typeof f === 'undefined' ? 0 : f.value;\n return mathHelper(num => num.toFixed(fraction), null, n);\n};\n\nexport default mathFunctions;\n"]} |
| {"version":3,"file":"number.js","sourceRoot":"","sources":["../../../src/less/functions/number.js"],"names":[],"mappings":";;;AAAA,wEAA0C;AAC1C,wEAA0C;AAC1C,4EAA0C;AAE1C,IAAM,MAAM,GAAG,UAAU,KAAK,EAAE,IAAI;IAArB,iBAqDd;IApDG,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,QAAQ,IAAI,CAAC,MAAM,EAAE;QACjB,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,gCAAgC,EAAE,CAAC;KACjF;IACD,IAAI,CAAC,CAAC,CAAC,2DAA2D;IAClE,IAAI,CAAC,CAAC;IACN,IAAI,OAAO,CAAC;IACZ,IAAI,cAAc,CAAC;IACnB,IAAI,gBAAg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AAC;QACd,OAAO,IAAI,mBAAS,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IACD,GAAG,EAAE,UAAS,CAAC,EAAE,CAAC;QACd,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;YAChD,CAAC,GAAG,IAAI,mBAAS,CAAC,CAAC,CAAC,CAAC;YACrB,CAAC,GAAG,IAAI,mBAAS,CAAC,CAAC,CAAC,CAAC;SACxB;aAAM,IAAI,CAAC,CAAC,CAAC,YAAY,mBAAS,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,mBAAS,CAAC,EAAE;YAC/D,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAC;SACpE;QAED,OAAO,IAAI,mBAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAC7D,CAAC;IACD,UAAU,EAAE,UAAU,CAAC;QACnB,IAAM,MAAM,GAAG,IAAA,wBAAU,EAAC,UAAA,GAAG,IAAI,OAAA,GAAG,GAAG,GAAG,EAAT,CAAS,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QAEpD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAC","sourcesContent":["import Dimension from '../tree/dimension';\nimport Anonymous from '../tree/anonymous';\nimport mathHelper from './math-helper.js';\n\nconst minMax = function (isMin, args) {\n args = Array.prototype.slice.call(args);\n switch (args.length) {\n case 0: throw { type: 'Argument', message: 'one or more arguments required' };\n }\n let i; // key is the unit.toString() for unified Dimension values,\n let j;\n let current;\n let currentUnified;\n let referenceUnified;\n let unit;\n let unitStatic;\n let unitClone;\n\n const // elems only contains original argument values.\n order = [];\n\n const values = {};\n // value is the index into the order array.\n for (i = 0; i < args.length; i++) {\n current = args[i];\n if (!(current instanceof Dimension)) {\n if (Array.isArray(args[i].value)) {\n Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value));\n continue;\n } else {\n throw { type: 'Argument', message: 'incompatible types' };\n }\n }\n currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new Dimension(current.value, unitClone).unify() : current.unify();\n unit = currentUnified.unit.toString() === '' && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString();\n unitStatic = unit !== '' && unitStatic === undefined || unit !== '' && order[0].unify().unit.toString() === '' ? unit : unitStatic;\n unitClone = unit !== '' && unitClone === undefined ? current.unit.toString() : unitClone;\n j = values[''] !== undefined && unit !== '' && unit === unitStatic ? values[''] : values[unit];\n if (j === undefined) {\n if (unitStatic !== undefined && unit !== unitStatic) {\n throw { type: 'Argument', message: 'incompatible types' };\n }\n values[unit] = order.length;\n order.push(current);\n continue;\n }\n referenceUnified = order[j].unit.toString() === '' && unitClone !== undefined ? new Dimension(order[j].value, unitClone).unify() : order[j].unify();\n if ( isMin && currentUnified.value < referenceUnified.value ||\n !isMin && currentUnified.value > referenceUnified.value) {\n order[j] = current;\n }\n }\n if (order.length == 1) {\n return order[0];\n }\n args = order.map(a => { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');\n return new Anonymous(`${isMin ? 'min' : 'max'}(${args})`);\n};\n\nexport default {\n min: function(...args) {\n try {\n return minMax.call(this, true, args);\n } catch (e) {}\n },\n max: function(...args) {\n try {\n return minMax.call(this, false, args);\n } catch (e) {}\n },\n convert: function (val, unit) {\n return val.convertTo(unit.value);\n },\n pi: function () {\n return new Dimension(Math.PI);\n },\n mod: function(a, b) {\n return new Dimension(a.value % b.value, a.unit);\n },\n pow: function(x, y) {\n if (typeof x === 'number' && typeof y === 'number') {\n x = new Dimension(x);\n y = new Dimension(y);\n } else if (!(x instanceof Dimension) || !(y instanceof Dimension)) {\n throw { type: 'Argument', message: 'arguments must be numbers' };\n }\n\n return new Dimension(Math.pow(x.value, y.value), x.unit);\n },\n percentage: function (n) {\n const result = mathHelper(num => num * 100, '%', n);\n\n return result;\n }\n};\n"]} |
| {"version":3,"file":"string.js","sourceRoot":"","sources":["../../../src/less/functions/string.js"],"names":[],"mappings":";;;AAAA,kEAAoC;AACpC,wEAA0C;AAC1C,0EAA4C;AAE5C,kBAAe;IACX,CAAC,EAAE,UAAU,GAAG;QACZ,OAAO,IAAI,gBAAM,CAAC,GAAG,EAAE,GAAG,YAAY,oBAAU,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACxF,CAAC;IACD,MAAM,EAAE,UAAU,GAAG;QACjB,OAAO,IAAI,mBAAS,CAChB,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;aACnG,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,EAAE,UAAU,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK;QAClD,IAAI,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,WAAW,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC;YAC3C,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAC5C,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;QAC1F,OAAO,IAAI,gBAAM,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAClE,CAAC;IACD,GAAG,EAAE,UAAU,MAAM,CAAC,mBAAmB;QACrC,IAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACtD,IAAI,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;gCAEjB,CAAC;YACN,0BAA0B;YAC1B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,UAAA,KAAK;gBACpC,IAAM,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC;oBACtC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;gBACzD,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YACrE,CAAC,CAAC,CAAC;;QANP,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE;oBAA3B,CAAC;SAOT;QACD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACpC,OAAO,IAAI,gBAAM,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAClE,CAAC;CACJ,CAAC","sourcesContent":["import Quoted from '../tree/quoted';\nimport Anonymous from '../tree/anonymous';\nimport JavaScript from '../tree/javascript';\n\nexport default {\n e: function (str) {\n return new Quoted('\"', str instanceof JavaScript ? str.evaluated : str.value, true);\n },\n escape: function (str) {\n return new Anonymous(\n encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B')\n .replace(/\\(/g, '%28').replace(/\\)/g, '%29'));\n },\n replace: function (string, pattern, replacement, flags) {\n let result = string.value;\n replacement = (replacement.type === 'Quoted') ?\n replacement.value : replacement.toCSS();\n result = result.replace(new RegExp(pattern.value, flags ? flags.value : ''), replacement);\n return new Quoted(string.quote || '', result, string.escaped);\n },\n '%': function (string /* arg, arg, ... */) {\n const args = Array.prototype.slice.call(arguments, 1);\n let result = string.value;\n\n for (let i = 0; i < args.length; i++) {\n /* jshint loopfunc:true */\n result = result.replace(/%[sda]/i, token => {\n const value = ((args[i].type === 'Quoted') &&\n token.match(/s/i)) ? args[i].value : args[i].toCSS();\n return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value;\n });\n }\n result = result.replace(/%%/g, '%');\n return new Quoted(string.quote || '', result, string.escaped);\n }\n};\n"]} |
| {"version":3,"file":"style.js","sourceRoot":"","sources":["../../../src/less/functions/style.js"],"names":[],"mappings":";;;AAAA,sEAAwC;AACxC,sEAAyC;AAEzC,IAAM,eAAe,GAAG,UAAU,IAAI;IAAd,iBAWvB;IAVG,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,QAAQ,IAAI,CAAC,MAAM,EAAE;QACjB,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,gCAAgC,EAAE,CAAC;KACjF;IAED,IAAM,UAAU,GAAG,CAAC,IAAI,kBAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAEtG,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,UAAA,CAAC,IAAM,OAAO,CAAC,CAAC,KAAK,CAAC,KAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAEvG,OAAO,IAAI,kBAAS,CAAC,gBAAS,IAAI,MAAG,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF,kBAAe;IACX,KAAK,EAAE;QAAS,cAAO;aAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;YAAP,yBAAO;;QACnB,IAAI;YACA,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SAC3C;QAAC,OAAO,CAAC,EAAE,GAAE;IAClB,CAAC;CACJ,CAAC","sourcesContent":["import Variable from '../tree/variable';\nimport Anonymous from '../tree/variable';\n\nconst styleExpression = function (args) {\n args = Array.prototype.slice.call(args);\n switch (args.length) {\n case 0: throw { type: 'Argument', message: 'one or more arguments required' };\n }\n \n const entityList = [new Variable(args[0].value, this.index, this.currentFileInfo).eval(this.context)];\n \n args = entityList.map(a => { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');\n \n return new Anonymous(`style(${args})`);\n};\n\nexport default {\n style: function(...args) {\n try {\n return styleExpression.call(this, args);\n } catch (e) {}\n },\n};\n"]} |
| {"version":3,"file":"svg.js","sourceRoot":"","sources":["../../../src/less/functions/svg.js"],"names":[],"mappings":";;;AAAA,wEAA0C;AAC1C,gEAAkC;AAClC,0EAA4C;AAC5C,kEAAoC;AACpC,4DAA8B;AAE9B,mBAAe;IACX,OAAO,EAAE,cAAc,EAAE,UAAS,SAAS;YACvC,IAAI,KAAK,CAAC;YACV,IAAI,oBAAoB,CAAC;YACzB,IAAI,YAAY,GAAG,QAAQ,CAAC;YAC5B,IAAI,kBAAkB,GAAG,kCAAkC,CAAC;YAC5D,IAA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B,KAAK,OAAG,CAAC,CAAC,CAAC,EAAE,OAAI,CAAC;aAC/H;YACD,QAAQ,IAAI,YAAK,YAAY,4BAAkB,kBAAkB,+BAA0B,CAAC;YAE5F,QAAQ,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;YAExC,QAAQ,GAAG,6BAAsB,QAAQ,CAAE,CAAC;YAC5C,OAAO,IAAI,aAAG,CAAC,IAAI,gBAAM,CAAC,WAAI,QAAQ,MAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QACrI,CAAC,EAAC,CAAC;AACP,CAAC,EAAC","sourcesContent":["import Dimension from '../tree/dimension';\nimport Color from '../tree/color';\nimport Expression from '../tree/expression';\nimport Quoted from '../tree/quoted';\nimport URL from '../tree/url';\n\nexport default () => {\n return { 'svg-gradient': function(direction) {\n let stops;\n let gradientDirectionSvg;\n let gradientType = 'linear';\n let rectangleDimension = 'x=\"0\" y=\"0\" width=\"1\" height=\"1\"';\n const renderEnv = {compress: false};\n let returner;\n const directionValue = direction.toCSS(renderEnv);\n let i;\n let color;\n let position;\n let positionValue;\n let alpha;\n\n function throwArgumentDescriptor() {\n throw { type: 'Argument',\n message: 'svg-gradient expects direction, start_color [start_position], [color position,]...,' +\n ' end_color [end_position] or direction, color list' };\n }\n\n if (arguments.length == 2) {\n if (arguments[1].value.length < 2) {\n throwArgumentDescriptor();\n }\n stops = arguments[1].value;\n } else if (arguments.length < 3) {\n throwArgumentDescriptor();\n } else {\n stops = Array.prototype.slice.call(arguments, 1);\n }\n\n switch (directionValue) {\n case 'to bottom':\n gradientDirectionSvg = 'x1=\"0%\" y1=\"0%\" x2=\"0%\" y2=\"100%\"';\n break;\n case 'to right':\n gradientDirectionSvg = 'x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"0%\"';\n break;\n case 'to bottom right':\n gradientDirectionSvg = 'x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"100%\"';\n break;\n case 'to top right':\n gradientDirectionSvg = 'x1=\"0%\" y1=\"100%\" x2=\"100%\" y2=\"0%\"';\n break;\n case 'ellipse':\n case 'ellipse at center':\n gradientType = 'radial';\n gradientDirectionSvg = 'cx=\"50%\" cy=\"50%\" r=\"75%\"';\n rectangleDimension = 'x=\"-50\" y=\"-50\" width=\"101\" height=\"101\"';\n break;\n default:\n throw { type: 'Argument', message: 'svg-gradient direction must be \\'to bottom\\', \\'to right\\',' +\n ' \\'to bottom right\\', \\'to top right\\' or \\'ellipse at center\\'' };\n }\n returner = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 1 1\"><${gradientType}Gradient id=\"g\" ${gradientDirectionSvg}>`;\n\n for (i = 0; i < stops.length; i += 1) {\n if (stops[i] instanceof Expression) {\n color = stops[i].value[0];\n position = stops[i].value[1];\n } else {\n color = stops[i];\n position = undefined;\n }\n\n if (!(color instanceof Color) || (!((i === 0 || i + 1 === stops.length) && position === undefined) && !(position instanceof Dimension))) {\n throwArgumentDescriptor();\n }\n positionValue = position ? position.toCSS(renderEnv) : i === 0 ? '0%' : '100%';\n alpha = color.alpha;\n returner += `<stop offset=\"${positionValue}\" stop-color=\"${color.toRGB()}\"${alpha < 1 ? ` stop-opacity=\"${alpha}\"` : ''}/>`;\n }\n returner += `</${gradientType}Gradient><rect ${rectangleDimension} fill=\"url(#g)\" /></svg>`;\n\n returner = encodeURIComponent(returner);\n\n returner = `data:image/svg+xml,${returner}`;\n return new URL(new Quoted(`'${returner}'`, returner, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo);\n }};\n};\n"]} |
| {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/less/functions/types.js"],"names":[],"mappings":";;;AAAA,oEAAsC;AACtC,sFAAuD;AACvD,wEAA0C;AAC1C,gEAAkC;AAClC,kEAAoC;AACpC,wEAA0C;AAC1C,4DAA8B;AAC9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AAC;QAClB,OAAO,GAAG,CAAC,CAAC,EAAE,iBAAO,CAAC,CAAC;IAC3B,CAAC;IACD,KAAK,EAAE,UAAU,CAAC;QACd,OAAO,GAAG,CAAC,CAAC,EAAE,aAAG,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,EAAE,UAAU,CAAC;QAChB,OAAO,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAC3B,CAAC;IACD,YAAY,EAAE,UAAU,CAAC;QACrB,OAAO,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC1B,CAAC;IACD,IAAI,EAAE,UAAU,CAAC;QACb,OAAO,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAC3B,CAAC;IACD,MAAM,QAAA;IACN,IAAI,EAAE,UAAU,GAAG,EAAE,IAAI;QACrB,IAAI,CAAC,CAAC,GAAG,YAAY,mBAAS,CAAC,EAAE;YAC7B,MAAM,EAAE,IAAI,EAAE,UAAU;gBACpB,OAAO,EAAE,qDAA8C,GAAG,YAAY,mBAAS,CAAC,CAAC,CAAC,mCAAmC,CAAC,CAAC,CAAC,EAAE,CAAE,EAAE,CAAC;SACtI;QACD,IAAI,IAAI,EAAE;YACN,IAAI,IAAI,YAAY,iBAAO,EAAE;gBACzB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;aACrB;iBAAM;gBACH,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;aACvB;SACJ;aAAM;YACH,IAAI,GAAG,EAAE,CAAC;SACb;QACD,OAAO,IAAI,mBAAS,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IACD,UAAU,EAAE,UAAU,CAAC;QACnB,OAAO,IAAI,mBAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;CACJ,CAAC","sourcesContent":["import Keyword from '../tree/keyword';\nimport DetachedRuleset from '../tree/detached-ruleset';\nimport Dimension from '../tree/dimension';\nimport Color from '../tree/color';\nimport Quoted from '../tree/quoted';\nimport Anonymous from '../tree/anonymous';\nimport URL from '../tree/url';\nimport Operation from '../tree/operation';\n\nconst isa = (n, Type) => (n instanceof Type) ? Keyword.True : Keyword.False;\nconst isunit = (n, unit) => {\n if (unit === undefined) {\n throw { type: 'Argument', message: 'missing the required second argument to isunit.' };\n }\n unit = typeof unit.value === 'string' ? unit.value : unit;\n if (typeof unit !== 'string') {\n throw { type: 'Argument', message: 'Second argument to isunit should be a unit or a string.' };\n }\n return (n instanceof Dimension) && n.unit.is(unit) ? Keyword.True : Keyword.False;\n};\n\nexport default {\n isruleset: function (n) {\n return isa(n, DetachedRuleset);\n },\n iscolor: function (n) {\n return isa(n, Color);\n },\n isnumber: function (n) {\n return isa(n, Dimension);\n },\n isstring: function (n) {\n return isa(n, Quoted);\n },\n iskeyword: function (n) {\n return isa(n, Keyword);\n },\n isurl: function (n) {\n return isa(n, URL);\n },\n ispixel: function (n) {\n return isunit(n, 'px');\n },\n ispercentage: function (n) {\n return isunit(n, '%');\n },\n isem: function (n) {\n return isunit(n, 'em');\n },\n isunit,\n unit: function (val, unit) {\n if (!(val instanceof Dimension)) {\n throw { type: 'Argument',\n message: `the first argument to unit must be a number${val instanceof Operation ? '. Have you forgotten parenthesis?' : ''}` };\n }\n if (unit) {\n if (unit instanceof Keyword) {\n unit = unit.value;\n } else {\n unit = unit.toCSS();\n }\n } else {\n unit = '';\n }\n return new Dimension(val.value, unit);\n },\n 'get-unit': function (n) {\n return new Anonymous(n.unit);\n }\n};\n"]} |
| {"version":3,"file":"import-manager.js","sourceRoot":"","sources":["../../src/less/import-manager.js"],"names":[],"mappings":";;;AAAA,gEAAkC;AAClC,mEAAqC;AACrC,oEAAqC;AACrC,qDAAiC;AACjC,4DAA8B;AAE9B,mBAAwB,WAAW;IAC/B,eAAe;IACf,mEAAmE;IACnE,uDAAuD;IACvD,4DAA4D;IAC5D,2DAA2D;IAC3D,8CAA8C;IAC9C,iDAAiD;IACjD,iGAAi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AAI,OAAO,CAAC,UAAU,EAAE;oBACpB,UAAU,GAAG,YAAY,CAAC,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,gBAAgB,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;iBACvH;qBAAM;oBACH,OAAO,GAAG,YAAY,CAAC,UAAU,CAAC,IAAI,EAAE,eAAe,CAAC,gBAAgB,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;iBAChH;aACJ;iBACI;gBACD,IAAI,OAAO,CAAC,UAAU,EAAE;oBACpB,UAAU,GAAG,WAAW,CAAC,YAAY,CAAC,IAAI,EAAE,eAAe,CAAC,gBAAgB,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;iBACvG;qBAAM;oBACH,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC,gBAAgB,EAAE,OAAO,EAAE,WAAW,EACvF,UAAC,GAAG,EAAE,UAAU;wBACZ,IAAI,GAAG,EAAE;4BACL,cAAc,CAAC,GAAG,CAAC,CAAC;yBACvB;6BAAM;4BACH,gBAAgB,CAAC,UAAU,CAAC,CAAC;yBAChC;oBACL,CAAC,CAAC,CAAC;iBACV;aACJ;YACD,IAAI,UAAU,EAAE;gBACZ,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE;oBACtB,cAAc,CAAC,UAAU,CAAC,CAAC;iBAC9B;qBAAM;oBACH,gBAAgB,CAAC,UAAU,CAAC,CAAC;iBAChC;aACJ;iBAAM,IAAI,OAAO,EAAE;gBAChB,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;aAClD;QACL,CAAC;QACL,oBAAC;IAAD,CAAC,AAnKD,IAmKC;IAED,OAAO,aAAa,CAAC;AACzB,CAAC;AAhLD,4BAgLC","sourcesContent":["import contexts from './contexts';\nimport Parser from './parser/parser';\nimport LessError from './less-error';\nimport * as utils from './utils';\nimport logger from './logger';\n\nexport default function(environment) {\n // FileInfo = {\n // 'rewriteUrls' - option - whether to adjust URL's to be relative\n // 'filename' - full resolved filename of current file\n // 'rootpath' - path to append to normal URLs for this node\n // 'currentDirectory' - path to the current file, absolute\n // 'rootFilename' - filename of the base file\n // 'entryPath' - absolute path to the entry file\n // 'reference' - whether the file should not be output and only output parts that are referenced\n\n class ImportManager {\n constructor(less, context, rootFileInfo) {\n this.less = less;\n this.rootFilename = rootFileInfo.filename;\n this.paths = context.paths || []; // Search paths, when importing\n this.contents = {}; // map - filename to contents of all the files\n this.contentsIgnoredChars = {}; // map - filename to lines at the beginning of each file to ignore\n this.mime = context.mime;\n this.error = null;\n this.context = context;\n // Deprecated? Unused outside of here, could be useful.\n this.queue = []; // Files which haven't been imported yet\n this.files = {}; // Holds the imported parse trees.\n }\n\n /**\n * Add an import to be imported\n * @param path - the raw path\n * @param tryAppendExtension - whether to try appending a file extension (.less or .js if the path has no extension)\n * @param currentFileInfo - the current file info (used for instance to work out relative paths)\n * @param importOptions - import options\n * @param callback - callback for when it is imported\n */\n push(path, tryAppendExtension, currentFileInfo, importOptions, callback) {\n const importManager = this, pluginLoader = this.context.pluginManager.Loader;\n\n this.queue.push(path);\n\n const fileParsedFunc = function (e, root, fullPath) {\n importManager.queue.splice(importManager.queue.indexOf(path), 1); // Remove the path from the queue\n\n const importedEqualsRoot = fullPath === importManager.rootFilename;\n if (importOptions.optional && e) {\n callback(null, {rules:[]}, false, null);\n logger.info(`The file ${fullPath} was skipped because it was not found and the import was marked optional.`);\n }\n else {\n // Inline imports aren't cached here.\n // If we start to cache them, please make sure they won't conflict with non-inline imports of the\n // same name as they used to do before this comment and the condition below have been added.\n if (!importManager.files[fullPath] && !importOptions.inline) {\n importManager.files[fullPath] = { root, options: importOptions };\n }\n if (e && !importManager.error) { importManager.error = e; }\n callback(e, root, importedEqualsRoot, fullPath);\n }\n };\n\n const newFileInfo = {\n rewriteUrls: this.context.rewriteUrls,\n entryPath: currentFileInfo.entryPath,\n rootpath: currentFileInfo.rootpath,\n rootFilename: currentFileInfo.rootFilename\n };\n\n const fileManager = environment.getFileManager(path, currentFileInfo.currentDirectory, this.context, environment);\n\n if (!fileManager) {\n fileParsedFunc({ message: `Could not find a file-manager for ${path}` });\n return;\n }\n\n const loadFileCallback = function(loadedFile) {\n let plugin;\n const resolvedFilename = loadedFile.filename;\n const contents = loadedFile.contents.replace(/^\\uFEFF/, '');\n\n // Pass on an updated rootpath if path of imported file is relative and file\n // is in a (sub|sup) directory\n //\n // Examples:\n // - If path of imported file is 'module/nav/nav.less' and rootpath is 'less/',\n // then rootpath should become 'less/module/nav/'\n // - If path of imported file is '../mixins.less' and rootpath is 'less/',\n // then rootpath should become 'less/../'\n newFileInfo.currentDirectory = fileManager.getPath(resolvedFilename);\n if (newFileInfo.rewriteUrls) {\n newFileInfo.rootpath = fileManager.join(\n (importManager.context.rootpath || ''),\n fileManager.pathDiff(newFileInfo.currentDirectory, newFileInfo.entryPath));\n\n if (!fileManager.isPathAbsolute(newFileInfo.rootpath) && fileManager.alwaysMakePathsAbsolute()) {\n newFileInfo.rootpath = fileManager.join(newFileInfo.entryPath, newFileInfo.rootpath);\n }\n }\n newFileInfo.filename = resolvedFilename;\n\n const newEnv = new contexts.Parse(importManager.context);\n\n newEnv.processImports = false;\n importManager.contents[resolvedFilename] = contents;\n\n if (currentFileInfo.reference || importOptions.reference) {\n newFileInfo.reference = true;\n }\n\n if (importOptions.isPlugin) {\n plugin = pluginLoader.evalPlugin(contents, newEnv, importManager, importOptions.pluginArgs, newFileInfo);\n if (plugin instanceof LessError) {\n fileParsedFunc(plugin, null, resolvedFilename);\n }\n else {\n fileParsedFunc(null, plugin, resolvedFilename);\n }\n } else if (importOptions.inline) {\n fileParsedFunc(null, contents, resolvedFilename);\n } else {\n // import (multiple) parse trees apparently get altered and can't be cached.\n // TODO: investigate why this is\n if (importManager.files[resolvedFilename]\n && !importManager.files[resolvedFilename].options.multiple\n && !importOptions.multiple) {\n\n fileParsedFunc(null, importManager.files[resolvedFilename].root, resolvedFilename);\n }\n else {\n new Parser(newEnv, importManager, newFileInfo).parse(contents, function (e, root) {\n fileParsedFunc(e, root, resolvedFilename);\n });\n }\n }\n };\n let loadedFile;\n let promise;\n const context = utils.clone(this.context);\n\n if (tryAppendExtension) {\n context.ext = importOptions.isPlugin ? '.js' : '.less';\n }\n\n if (importOptions.isPlugin) {\n context.mime = 'application/javascript';\n\n if (context.syncImport) {\n loadedFile = pluginLoader.loadPluginSync(path, currentFileInfo.currentDirectory, context, environment, fileManager);\n } else {\n promise = pluginLoader.loadPlugin(path, currentFileInfo.currentDirectory, context, environment, fileManager);\n }\n }\n else {\n if (context.syncImport) {\n loadedFile = fileManager.loadFileSync(path, currentFileInfo.currentDirectory, context, environment);\n } else {\n promise = fileManager.loadFile(path, currentFileInfo.currentDirectory, context, environment,\n (err, loadedFile) => {\n if (err) {\n fileParsedFunc(err);\n } else {\n loadFileCallback(loadedFile);\n }\n });\n }\n }\n if (loadedFile) {\n if (!loadedFile.filename) {\n fileParsedFunc(loadedFile);\n } else {\n loadFileCallback(loadedFile);\n }\n } else if (promise) {\n promise.then(loadFileCallback, fileParsedFunc);\n }\n }\n }\n\n return ImportManager;\n}\n"]} |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/less/index.js"],"names":[],"mappings":";;;AAAA,kFAAoD;AACpD,wDAA0B;AAC1B,wDAA0B;AAC1B,sGAAsE;AACtE,wGAAwE;AACxE,gEAAkC;AAClC,mEAAqC;AACrC,kEAAoC;AACpC,gEAAkC;AAClC,oEAAqC;AACrC,4EAA6C;AAC7C,qDAAiC;AACjC,4EAA6C;AAC7C,4DAA8B;AAC9B,kFAAkD;AAClD,oFAAoD;AACpD,oEAAqC;AACrC,4EAA6C;AAC7C,0DAA4B;AAC5B,4DAA8B;AAC9B,mDAA6C;AAC7C,kFAA8C;AAE9C,mBAAwB,WAAW,EAAE,YAAY;IAC7C,IAAI,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,aAAa,CAAC;IAE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MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACvC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;YACvD,OAAO,GAAG,CAAC;QACf,CAAC,CAAC;IACN,CAAC,CAAC;IACF,IAAI,CAAC,CAAC;IACN,IAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACnC,KAAK,IAAM,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE;QAC1B,4BAA4B;QAC5B,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,OAAO,CAAC,KAAK,UAAU,EAAE;YACzB,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;SAClC;aACI;YACD,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC7B,KAAK,IAAM,CAAC,IAAI,CAAC,EAAE;gBACf,4BAA4B;gBAC5B,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aACxC;SACJ;KACJ;IAED;;;;;OAKG;IACH,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxC,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE1C,OAAO,GAAG,CAAC;AACf,CAAC;AA1ED,4BA0EC","sourcesContent":["import Environment from './environment/environment';\nimport data from './data';\nimport tree from './tree';\nimport AbstractFileManager from './environment/abstract-file-manager';\nimport AbstractPluginLoader from './environment/abstract-plugin-loader';\nimport visitors from './visitors';\nimport Parser from './parser/parser';\nimport functions from './functions';\nimport contexts from './contexts';\nimport LessError from './less-error';\nimport transformTree from './transform-tree';\nimport * as utils from './utils';\nimport PluginManager from './plugin-manager';\nimport logger from './logger';\nimport SourceMapOutput from './source-map-output';\nimport SourceMapBuilder from './source-map-builder';\nimport ParseTree from './parse-tree';\nimport ImportManager from './import-manager';\nimport Parse from './parse';\nimport Render from './render';\nimport { version } from '../../package.json';\nimport parseVersion from 'parse-node-version';\n\nexport default function(environment, fileManagers) {\n let sourceMapOutput, sourceMapBuilder, parseTree, importManager;\n\n environment = new Environment(environment, fileManagers);\n sourceMapOutput = SourceMapOutput(environment);\n sourceMapBuilder = SourceMapBuilder(sourceMapOutput, environment);\n parseTree = ParseTree(sourceMapBuilder);\n importManager = ImportManager(environment);\n\n const render = Render(environment, parseTree, importManager);\n const parse = Parse(environment, parseTree, importManager);\n\n const v = parseVersion(`v${version}`);\n const initial = {\n version: [v.major, v.minor, v.patch],\n data,\n tree,\n Environment,\n AbstractFileManager,\n AbstractPluginLoader,\n environment,\n visitors,\n Parser,\n functions: functions(environment),\n contexts,\n SourceMapOutput: sourceMapOutput,\n SourceMapBuilder: sourceMapBuilder,\n ParseTree: parseTree,\n ImportManager: importManager,\n render,\n parse,\n LessError,\n transformTree,\n utils,\n PluginManager,\n logger\n };\n\n // Create a public API\n\n const ctor = function(t) {\n return function() {\n const obj = Object.create(t.prototype);\n t.apply(obj, Array.prototype.slice.call(arguments, 0));\n return obj;\n };\n };\n let t;\n const api = Object.create(initial);\n for (const n in initial.tree) {\n /* eslint guard-for-in: 0 */\n t = initial.tree[n];\n if (typeof t === 'function') {\n api[n.toLowerCase()] = ctor(t);\n }\n else {\n api[n] = Object.create(null);\n for (const o in t) {\n /* eslint guard-for-in: 0 */\n api[n][o.toLowerCase()] = ctor(t[o]);\n }\n }\n }\n\n /**\n * Some of the functions assume a `this` context of the API object,\n * which causes it to fail when wrapped for ES6 imports.\n * \n * An assumed `this` should be removed in the future.\n */\n initial.parse = initial.parse.bind(api);\n initial.render = initial.render.bind(api);\n\n return api;\n}\n"]} |
| {"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,6EAA6E;IAC7E,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,QAAQ,CAAC;IAE/B,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,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAE7C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;QACrB,IAAI,CAAC,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C,IAAI,CAAC,GAAG,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,OAAI,CAAC;KAC1D;IAED,OAAO,IAAI,OAAO,CAAC,UAAG,IAAI,eAAK,IAAI,CAAC,OAAO,CAAE,EAAE,KAAK,CAAC,CAAC;IACtD,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 // Set type early so it's always available, even if fileContentMap is missing\n this.type = e.type || 'Syntax';\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.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;"]} |
| {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/less/logger.js"],"names":[],"mappings":";;AAAA,kBAAe;IACX,KAAK,EAAE,UAAS,GAAG;QACf,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;IACD,IAAI,EAAE,UAAS,GAAG;QACd,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,EAAE,UAAS,GAAG;QACd,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,CAAC;IACD,KAAK,EAAE,UAAS,GAAG;QACf,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;IACD,WAAW,EAAE,UAAS,QAAQ;QAC1B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IACD,cAAc,EAAE,UAAS,QAAQ;QAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC7C,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;gBACjC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC7B,OAAO;aACV;SACJ;IACL,CAAC;IACD,UAAU,EAAE,UAAS,IAAI,EAAE,GAAG;QAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC7C,IAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAC7C,IAAI,WAAW,EAAE;gBACb,WAAW,CAAC,GAAG,CAAC,CAAC;aACpB;SACJ;IACL,CAAC;IACD,UAAU,EAAE,EAAE;CACjB,CAAC","sourcesContent":["export default {\n error: function(msg) {\n this._fireEvent('error', msg);\n },\n warn: function(msg) {\n this._fireEvent('warn', msg);\n },\n info: function(msg) {\n this._fireEvent('info', msg);\n },\n debug: function(msg) {\n this._fireEvent('debug', msg);\n },\n addListener: function(listener) {\n this._listeners.push(listener);\n },\n removeListener: function(listener) {\n for (let i = 0; i < this._listeners.length; i++) {\n if (this._listeners[i] === listener) {\n this._listeners.splice(i, 1);\n return;\n }\n }\n },\n _fireEvent: function(type, msg) {\n for (let i = 0; i < this._listeners.length; i++) {\n const logFunction = this._listeners[i][type];\n if (logFunction) {\n logFunction(msg);\n }\n }\n },\n _listeners: []\n};\n"]} |
| {"version":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,SAAS,EAAE,gBAAgB,EAAE,OAAO,SAAA,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;iBACvH;aACJ;YACD,IAAI,OAAO,CAAC,SAAS,EAAE;gBACnB,MAAM,CAAC,GAAG,GAAG,gBAAgB,CAAC,oBAAoB,EAAE,CAAC;aACxD;YAED,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;YACpB,KAAK,IAAM,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;gBACnC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,IAAI,KAAK,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE;oBACtG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC7B;aACJ;YACD,OAAO,MAAM,CAAC;QAClB,CAAC;QACL,gBAAC;IAAD,CAAC,AAnHD,IAmHC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAvHD,4BAuHC","sourcesContent":["import LessError from './less-error';\nimport transformTree from './transform-tree';\nimport logger from './logger';\n\nexport default function(SourceMapBuilder) {\n class ParseTree {\n constructor(root, imports) {\n this.root = root;\n this.imports = imports;\n }\n\n toCSS(options) {\n let evaldRoot;\n const result = {};\n let sourceMapBuilder;\n try {\n evaldRoot = transformTree(this.root, options);\n } catch (e) {\n throw new LessError(e, this.imports);\n }\n\n try {\n const compress = Boolean(options.compress);\n if (compress) {\n logger.warn('The compress option has been deprecated. ' + \n 'We recommend you use a dedicated css minifier, for instance see less-plugin-clean-css.');\n }\n\n const toCSSOptions = {\n compress,\n // @deprecated The dumpLineNumbers option is deprecated. Use sourcemaps instead. All modes will be removed in a future version.\n dumpLineNumbers: options.dumpLineNumbers,\n strictUnits: Boolean(options.strictUnits),\n numPrecision: 8};\n\n if (options.sourceMap) {\n // Normalize sourceMap option: if it's just true, convert to object\n if (options.sourceMap === true) {\n options.sourceMap = {};\n }\n const sourceMapOpts = options.sourceMap;\n \n // Set sourceMapInputFilename if not set and filename is available\n if (!sourceMapOpts.sourceMapInputFilename && options.filename) {\n sourceMapOpts.sourceMapInputFilename = options.filename;\n }\n \n // Default sourceMapBasepath to the input file's directory if not set\n // This matches the behavior documented and implemented in bin/lessc\n if (sourceMapOpts.sourceMapBasepath === undefined && options.filename) {\n // Get directory from filename using string manipulation (works cross-platform)\n const lastSlash = Math.max(options.filename.lastIndexOf('/'), options.filename.lastIndexOf('\\\\'));\n if (lastSlash >= 0) {\n sourceMapOpts.sourceMapBasepath = options.filename.substring(0, lastSlash);\n } else {\n // No directory separator found, use current directory\n sourceMapOpts.sourceMapBasepath = '.';\n }\n }\n \n // Handle sourceMapFullFilename (CLI-specific: --source-map=filename)\n // This is converted to sourceMapFilename and sourceMapOutputFilename\n if (sourceMapOpts.sourceMapFullFilename && !sourceMapOpts.sourceMapFileInline) {\n // This case is handled by lessc before calling render\n // We just need to ensure sourceMapFilename is set if sourceMapFullFilename is provided\n if (!sourceMapOpts.sourceMapFilename && !sourceMapOpts.sourceMapURL) {\n // Extract just the basename for the sourceMappingURL comment\n const mapBase = sourceMapOpts.sourceMapFullFilename.split(/[/\\\\]/).pop();\n sourceMapOpts.sourceMapFilename = mapBase;\n }\n } else if (!sourceMapOpts.sourceMapFilename && !sourceMapOpts.sourceMapURL) {\n // If sourceMapFilename is not set and sourceMapURL is not set,\n // derive it from the output filename (if available) or input filename\n if (sourceMapOpts.sourceMapOutputFilename) {\n // Use output filename + .map\n sourceMapOpts.sourceMapFilename = sourceMapOpts.sourceMapOutputFilename + '.map';\n } else if (options.filename) {\n // Fallback to input filename + .css.map\n const inputBase = options.filename.replace(/\\.[^/.]+$/, '');\n sourceMapOpts.sourceMapFilename = inputBase + '.css.map';\n }\n }\n \n // Default sourceMapOutputFilename if not set\n if (!sourceMapOpts.sourceMapOutputFilename) {\n if (options.filename) {\n const inputBase = options.filename.replace(/\\.[^/.]+$/, '');\n sourceMapOpts.sourceMapOutputFilename = inputBase + '.css';\n } else {\n sourceMapOpts.sourceMapOutputFilename = 'output.css';\n }\n }\n \n sourceMapBuilder = new SourceMapBuilder(sourceMapOpts);\n result.css = sourceMapBuilder.toCSS(evaldRoot, toCSSOptions, this.imports);\n } else {\n result.css = evaldRoot.toCSS(toCSSOptions);\n }\n } catch (e) {\n throw new LessError(e, this.imports);\n }\n\n if (options.pluginManager) {\n const postProcessors = options.pluginManager.getPostProcessors();\n for (let i = 0; i < postProcessors.length; i++) {\n result.css = postProcessors[i].process(result.css, { sourceMap: sourceMapBuilder, options, imports: this.imports });\n }\n }\n if (options.sourceMap) {\n result.map = sourceMapBuilder.getExternalSourceMap();\n }\n\n result.imports = [];\n for (const file in this.imports.files) {\n if (Object.prototype.hasOwnProperty.call(this.imports.files, file) && file !== this.imports.rootFilename) {\n result.imports.push(file);\n }\n }\n return result;\n }\n }\n\n return ParseTree;\n}\n"]} |
| {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/less/parse.js"],"names":[],"mappings":";;;AAAA,gEAAkC;AAClC,mEAAqC;AACrC,4EAA6C;AAC7C,oEAAqC;AACrC,qDAAiC;AAEjC,mBAAwB,WAAW,EAAE,SAAS,EAAE,aAAa;IACzD,IAAM,KAAK,GAAG,UAAU,KAAK,EAAE,OAAO,EAAE,QAAQ;QAE5C,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;YAC/B,QAAQ,GAAG,OAAO,CAAC;YACnB,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;SACjD;aACI;YACD,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;SAC5D;QAED,IAAI,CAAC,QAAQ,EAAE;YACX,IAAM,MAAI,GAAG,IAAI,CAAC;YAClB,OAAO,IAAI,OAAO,CAAC,UAAU,OAA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AO,EAAE,YAAY,CAAC,CAAC;YAC/D,IAAI,CAAC,aAAa,GAAG,SAAO,CAAC;YAE7B,8DAA8D;YAC9D,sCAAsC;YAEtC,IAAI,OAAO,CAAC,OAAO,EAAE;gBACjB,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,UAAS,MAAM;oBACnC,IAAI,UAAU,EAAE,QAAQ,CAAC;oBACzB,IAAI,MAAM,CAAC,WAAW,EAAE;wBACpB,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;wBACrD,UAAU,GAAG,eAAa,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,SAAO,EAAE,SAAO,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;wBAC1G,IAAI,UAAU,YAAY,oBAAS,EAAE;4BACjC,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC;yBAC/B;qBACJ;yBACI;wBACD,eAAa,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;qBACnC;gBACL,CAAC,CAAC,CAAC;aACN;YAED,IAAI,gBAAM,CAAC,SAAO,EAAE,SAAO,EAAE,YAAY,CAAC;iBACrC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,IAAI;gBAC3B,IAAI,CAAC,EAAE;oBAAE,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;iBAAE;gBAC9B,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,SAAO,EAAE,OAAO,CAAC,CAAC;YAC3C,CAAC,EAAE,OAAO,CAAC,CAAC;SACnB;IACL,CAAC,CAAC;IACF,OAAO,KAAK,CAAC;AACjB,CAAC;AAhFD,4BAgFC","sourcesContent":["import contexts from './contexts';\nimport Parser from './parser/parser';\nimport PluginManager from './plugin-manager';\nimport LessError from './less-error';\nimport * as utils from './utils';\n\nexport default function(environment, ParseTree, ImportManager) {\n const parse = function (input, options, callback) {\n\n if (typeof options === 'function') {\n callback = options;\n options = utils.copyOptions(this.options, {});\n }\n else {\n options = utils.copyOptions(this.options, options || {});\n }\n\n if (!callback) {\n const self = this;\n return new Promise(function (resolve, reject) {\n parse.call(self, input, options, function(err, output) {\n if (err) {\n reject(err);\n } else {\n resolve(output);\n }\n });\n });\n } else {\n let context;\n let rootFileInfo;\n const pluginManager = new PluginManager(this, !options.reUsePluginManager);\n\n options.pluginManager = pluginManager;\n\n context = new contexts.Parse(options);\n\n if (options.rootFileInfo) {\n rootFileInfo = options.rootFileInfo;\n } else {\n const filename = options.filename || 'input';\n const entryPath = filename.replace(/[^/\\\\]*$/, '');\n rootFileInfo = {\n filename,\n rewriteUrls: context.rewriteUrls,\n rootpath: context.rootpath || '',\n currentDirectory: entryPath,\n entryPath,\n rootFilename: filename\n };\n // add in a missing trailing slash\n if (rootFileInfo.rootpath && rootFileInfo.rootpath.slice(-1) !== '/') {\n rootFileInfo.rootpath += '/';\n }\n }\n\n const imports = new ImportManager(this, context, rootFileInfo);\n this.importManager = imports;\n\n // TODO: allow the plugins to be just a list of paths or names\n // Do an async plugin queue like lessc\n\n if (options.plugins) {\n options.plugins.forEach(function(plugin) {\n let evalResult, contents;\n if (plugin.fileContent) {\n contents = plugin.fileContent.replace(/^\\uFEFF/, '');\n evalResult = pluginManager.Loader.evalPlugin(contents, context, imports, plugin.options, plugin.filename);\n if (evalResult instanceof LessError) {\n return callback(evalResult);\n }\n }\n else {\n pluginManager.addPlugin(plugin);\n }\n });\n }\n\n new Parser(context, imports, rootFileInfo)\n .parse(input, function (e, root) {\n if (e) { return callback(e); }\n callback(null, root, imports, options);\n }, options);\n }\n };\n return parse;\n}\n"]} |
| {"version":3,"file":"parser-input.js","sourceRoot":"","sources":["../../../src/less/parser/parser-input.js"],"names":[],"mappings":";;AAAA,mBAAe;IACX,IAAI,oBAAoB;IACpB,KAAK,CAAC;IAEV,IAAI,gBAAgB;IAChB,CAAC,CAAC;IAEN,IAAM,+BAA+B;IACjC,SAAS,GAA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AAK,CAAC,WAAW,CAAC,CAAC,CAAC;SACrC,CAAC;IACN,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC;AACvB,CAAC,EAAC","sourcesContent":["export default () => {\n let // Less input string\n input;\n\n let // current chunk\n j;\n\n const // holds state for backtracking\n saveStack = [];\n\n let // furthest index the parser has gone to\n furthest;\n\n let // if this is furthest we got to, this is the probably cause\n furthestPossibleErrorMessage;\n\n let // chunkified input\n chunks;\n\n let // current chunk\n current;\n\n let // index of current chunk, in `input`\n currentPos;\n\n const parserInput = {};\n const CHARCODE_SPACE = 32;\n const CHARCODE_TAB = 9;\n const CHARCODE_LF = 10;\n const CHARCODE_CR = 13;\n const CHARCODE_PLUS = 43;\n const CHARCODE_COMMA = 44;\n const CHARCODE_FORWARD_SLASH = 47;\n const CHARCODE_9 = 57;\n\n function skipWhitespace(length) {\n const oldi = parserInput.i;\n const oldj = j;\n const curr = parserInput.i - currentPos;\n const endIndex = parserInput.i + current.length - curr;\n const mem = (parserInput.i += length);\n const inp = input;\n let c;\n let nextChar;\n let comment;\n\n for (; parserInput.i < endIndex; parserInput.i++) {\n c = inp.charCodeAt(parserInput.i);\n\n if (parserInput.autoCommentAbsorb && c === CHARCODE_FORWARD_SLASH) {\n nextChar = inp.charAt(parserInput.i + 1);\n if (nextChar === '/') {\n comment = {index: parserInput.i, isLineComment: true};\n let nextNewLine = inp.indexOf('\\n', parserInput.i + 2);\n if (nextNewLine < 0) {\n nextNewLine = endIndex;\n }\n parserInput.i = nextNewLine;\n comment.text = inp.substr(comment.index, parserInput.i - comment.index);\n parserInput.commentStore.push(comment);\n continue;\n } else if (nextChar === '*') {\n const nextStarSlash = inp.indexOf('*/', parserInput.i + 2);\n if (nextStarSlash >= 0) {\n comment = {\n index: parserInput.i,\n text: inp.substr(parserInput.i, nextStarSlash + 2 - parserInput.i),\n isLineComment: false\n };\n parserInput.i += comment.text.length - 1;\n parserInput.commentStore.push(comment);\n continue;\n }\n }\n break;\n }\n\n if ((c !== CHARCODE_SPACE) && (c !== CHARCODE_LF) && (c !== CHARCODE_TAB) && (c !== CHARCODE_CR)) {\n break;\n }\n }\n\n current = current.slice(length + parserInput.i - mem + curr);\n currentPos = parserInput.i;\n\n if (!current.length) {\n if (j < chunks.length - 1) {\n current = chunks[++j];\n skipWhitespace(0); // skip space at the beginning of a chunk\n return true; // things changed\n }\n parserInput.finished = true;\n }\n\n return oldi !== parserInput.i || oldj !== j;\n }\n\n parserInput.save = () => {\n currentPos = parserInput.i;\n saveStack.push( { current, i: parserInput.i, j });\n };\n parserInput.restore = possibleErrorMessage => {\n\n if (parserInput.i > furthest || (parserInput.i === furthest && possibleErrorMessage && !furthestPossibleErrorMessage)) {\n furthest = parserInput.i;\n furthestPossibleErrorMessage = possibleErrorMessage;\n }\n const state = saveStack.pop();\n current = state.current;\n currentPos = parserInput.i = state.i;\n j = state.j;\n };\n parserInput.forget = () => {\n saveStack.pop();\n };\n parserInput.isWhitespace = offset => {\n const pos = parserInput.i + (offset || 0);\n const code = input.charCodeAt(pos);\n return (code === CHARCODE_SPACE || code === CHARCODE_CR || code === CHARCODE_TAB || code === CHARCODE_LF);\n };\n\n // Specialization of $(tok)\n parserInput.$re = tok => {\n if (parserInput.i > currentPos) {\n current = current.slice(parserInput.i - currentPos);\n currentPos = parserInput.i;\n }\n\n const m = tok.exec(current);\n if (!m) {\n return null;\n }\n\n skipWhitespace(m[0].length);\n if (typeof m === 'string') {\n return m;\n }\n\n return m.length === 1 ? m[0] : m;\n };\n\n parserInput.$char = tok => {\n if (input.charAt(parserInput.i) !== tok) {\n return null;\n }\n skipWhitespace(1);\n return tok;\n };\n\n parserInput.$peekChar = tok => {\n if (input.charAt(parserInput.i) !== tok) {\n return null;\n }\n return tok;\n };\n\n parserInput.$str = tok => {\n const tokLength = tok.length;\n\n // https://jsperf.com/string-startswith/21\n for (let i = 0; i < tokLength; i++) {\n if (input.charAt(parserInput.i + i) !== tok.charAt(i)) {\n return null;\n }\n }\n\n skipWhitespace(tokLength);\n return tok;\n };\n\n parserInput.$quoted = loc => {\n const pos = loc || parserInput.i;\n const startChar = input.charAt(pos);\n\n if (startChar !== '\\'' && startChar !== '\"') {\n return;\n }\n const length = input.length;\n const currentPosition = pos;\n\n for (let i = 1; i + currentPosition < length; i++) {\n const nextChar = input.charAt(i + currentPosition);\n switch (nextChar) {\n case '\\\\':\n i++;\n continue;\n case '\\r':\n case '\\n':\n break;\n case startChar: {\n const str = input.substr(currentPosition, i + 1);\n if (!loc && loc !== 0) {\n skipWhitespace(i + 1);\n return str\n }\n return [startChar, str];\n }\n default:\n }\n }\n return null;\n };\n\n /**\n * Permissive parsing. Ignores everything except matching {} [] () and quotes\n * until matching token (outside of blocks)\n */\n parserInput.$parseUntil = tok => {\n let quote = '';\n let returnVal = null;\n let inComment = false;\n let blockDepth = 0;\n const blockStack = [];\n const parseGroups = [];\n const length = input.length;\n const startPos = parserInput.i;\n let lastPos = parserInput.i;\n let i = parserInput.i;\n let loop = true;\n let testChar;\n\n if (typeof tok === 'string') {\n testChar = char => char === tok\n } else {\n testChar = char => tok.test(char)\n }\n\n do {\n let nextChar = input.charAt(i);\n if (blockDepth === 0 && testChar(nextChar)) {\n returnVal = input.substr(lastPos, i - lastPos);\n if (returnVal) {\n parseGroups.push(returnVal);\n }\n else {\n parseGroups.push(' ');\n }\n returnVal = parseGroups;\n skipWhitespace(i - startPos);\n loop = false\n } else {\n if (inComment) {\n if (nextChar === '*' && \n input.charAt(i + 1) === '/') {\n i++;\n blockDepth--;\n inComment = false;\n }\n i++;\n continue;\n }\n switch (nextChar) {\n case '\\\\':\n i++;\n nextChar = input.charAt(i);\n parseGroups.push(input.substr(lastPos, i - lastPos + 1));\n lastPos = i + 1;\n break;\n case '/':\n if (input.charAt(i + 1) === '*') {\n i++;\n inComment = true;\n blockDepth++;\n }\n break;\n case '\\'':\n case '\"':\n quote = parserInput.$quoted(i);\n if (quote) {\n parseGroups.push(input.substr(lastPos, i - lastPos), quote);\n i += quote[1].length - 1;\n lastPos = i + 1;\n }\n else {\n skipWhitespace(i - startPos);\n returnVal = nextChar;\n loop = false;\n }\n break;\n case '{':\n blockStack.push('}');\n blockDepth++;\n break;\n case '(':\n blockStack.push(')');\n blockDepth++;\n break;\n case '[':\n blockStack.push(']');\n blockDepth++;\n break;\n case '}':\n case ')':\n case ']': {\n const expected = blockStack.pop();\n if (nextChar === expected) {\n blockDepth--;\n } else {\n // move the parser to the error and return expected\n skipWhitespace(i - startPos);\n returnVal = expected;\n loop = false;\n }\n }\n }\n i++;\n if (i > length) {\n loop = false;\n }\n }\n } while (loop);\n\n return returnVal ? returnVal : null;\n }\n\n parserInput.autoCommentAbsorb = true;\n parserInput.commentStore = [];\n parserInput.finished = false;\n\n // Same as $(), but don't change the state of the parser,\n // just return the match.\n parserInput.peek = tok => {\n if (typeof tok === 'string') {\n // https://jsperf.com/string-startswith/21\n for (let i = 0; i < tok.length; i++) {\n if (input.charAt(parserInput.i + i) !== tok.charAt(i)) {\n return false;\n }\n }\n return true;\n } else {\n return tok.test(current);\n }\n };\n\n // Specialization of peek()\n // TODO remove or change some currentChar calls to peekChar\n parserInput.peekChar = tok => input.charAt(parserInput.i) === tok;\n\n parserInput.currentChar = () => input.charAt(parserInput.i);\n\n parserInput.prevChar = () => input.charAt(parserInput.i - 1);\n\n parserInput.getInput = () => input;\n\n parserInput.peekNotNumeric = () => {\n const c = input.charCodeAt(parserInput.i);\n // Is the first char of the dimension 0-9, '.', '+' or '-'\n return (c > CHARCODE_9 || c < CHARCODE_PLUS) || c === CHARCODE_FORWARD_SLASH || c === CHARCODE_COMMA;\n };\n\n parserInput.start = (str) => {\n input = str;\n parserInput.i = j = currentPos = furthest = 0;\n\n chunks = [str];\n current = chunks[0];\n\n skipWhitespace(0);\n };\n\n parserInput.end = () => {\n let message;\n const isFinished = parserInput.i >= input.length;\n\n if (parserInput.i < furthest) {\n message = furthestPossibleErrorMessage;\n parserInput.i = furthest;\n }\n return {\n isFinished,\n furthest: parserInput.i,\n furthestPossibleErrorMessage: message,\n furthestReachedEnd: parserInput.i >= input.length - 1,\n furthestChar: input[parserInput.i]\n };\n };\n\n return parserInput;\n};\n"]} |
Sorry, the diff of this file is too big to display
| {"version":3,"file":"plugin-manager.js","sourceRoot":"","sources":["../../src/less/plugin-manager.js"],"names":[],"mappings":";;AAAA;;GAEG;AACH;IACI,uBAAY,IAAI;QACZ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QACxB,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;QACnB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACH,kCAAU,GAAV,UAAW,OAAO;QACd,IAAI,OAAO,EAAE;YACT,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACrC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;aAC9B;SACJ;IACL,CAAC;IAED;;;;OAIG;IACH,iCAAS,GAAT,UAAU,MAAM,EAAE,QAAQ,EAAE,gBAAgB;QACxC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,QAAQ,EAAE;YACV,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;SACvC;QACD,IAAI,MAAM,CAAC,OAAO,EAAE;YAChB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EA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L,oBAAC;AAAD,CAAC,AAxJD,IAwJC;AAED,IAAI,EAAE,CAAC;AAEP,IAAM,oBAAoB,GAAG,UAAS,IAAI,EAAE,UAAU;IAClD,IAAI,UAAU,IAAI,CAAC,EAAE,EAAE;QACnB,EAAE,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;KAChC;IACD,OAAO,EAAE,CAAC;AACd,CAAC,CAAC;AAEF,EAAE;AACF,kBAAe,oBAAoB,CAAC","sourcesContent":["/**\n * Plugin Manager\n */\nclass PluginManager {\n constructor(less) {\n this.less = less;\n this.visitors = [];\n this.preProcessors = [];\n this.postProcessors = [];\n this.installedPlugins = [];\n this.fileManagers = [];\n this.iterator = -1;\n this.pluginCache = {};\n this.Loader = new less.PluginLoader(less);\n }\n\n /**\n * Adds all the plugins in the array\n * @param {Array} plugins\n */\n addPlugins(plugins) {\n if (plugins) {\n for (let i = 0; i < plugins.length; i++) {\n this.addPlugin(plugins[i]);\n }\n }\n }\n\n /**\n *\n * @param plugin\n * @param {String} filename\n */\n addPlugin(plugin, filename, functionRegistry) {\n this.installedPlugins.push(plugin);\n if (filename) {\n this.pluginCache[filename] = plugin;\n }\n if (plugin.install) {\n plugin.install(this.less, this, functionRegistry || this.less.functions.functionRegistry);\n }\n }\n\n /**\n *\n * @param filename\n */\n get(filename) {\n return this.pluginCache[filename];\n }\n\n /**\n * Adds a visitor. The visitor object has options on itself to determine\n * when it should run.\n * @param visitor\n */\n addVisitor(visitor) {\n this.visitors.push(visitor);\n }\n\n /**\n * Adds a pre processor object\n * @param {object} preProcessor\n * @param {number} priority - guidelines 1 = before import, 1000 = import, 2000 = after import\n */\n addPreProcessor(preProcessor, priority) {\n let indexToInsertAt;\n for (indexToInsertAt = 0; indexToInsertAt < this.preProcessors.length; indexToInsertAt++) {\n if (this.preProcessors[indexToInsertAt].priority >= priority) {\n break;\n }\n }\n this.preProcessors.splice(indexToInsertAt, 0, {preProcessor, priority});\n }\n\n /**\n * Adds a post processor object\n * @param {object} postProcessor\n * @param {number} priority - guidelines 1 = before compression, 1000 = compression, 2000 = after compression\n */\n addPostProcessor(postProcessor, priority) {\n let indexToInsertAt;\n for (indexToInsertAt = 0; indexToInsertAt < this.postProcessors.length; indexToInsertAt++) {\n if (this.postProcessors[indexToInsertAt].priority >= priority) {\n break;\n }\n }\n this.postProcessors.splice(indexToInsertAt, 0, {postProcessor, priority});\n }\n\n /**\n *\n * @param manager\n */\n addFileManager(manager) {\n this.fileManagers.push(manager);\n }\n\n /**\n *\n * @returns {Array}\n * @private\n */\n getPreProcessors() {\n const preProcessors = [];\n for (let i = 0; i < this.preProcessors.length; i++) {\n preProcessors.push(this.preProcessors[i].preProcessor);\n }\n return preProcessors;\n }\n\n /**\n *\n * @returns {Array}\n * @private\n */\n getPostProcessors() {\n const postProcessors = [];\n for (let i = 0; i < this.postProcessors.length; i++) {\n postProcessors.push(this.postProcessors[i].postProcessor);\n }\n return postProcessors;\n }\n\n /**\n *\n * @returns {Array}\n * @private\n */\n getVisitors() {\n return this.visitors;\n }\n\n visitor() {\n const self = this;\n return {\n first: function() {\n self.iterator = -1;\n return self.visitors[self.iterator];\n },\n get: function() {\n self.iterator += 1;\n return self.visitors[self.iterator];\n }\n };\n }\n\n /**\n *\n * @returns {Array}\n * @private\n */\n getFileManagers() {\n return this.fileManagers;\n }\n}\n\nlet pm;\n\nconst PluginManagerFactory = function(less, newFactory) {\n if (newFactory || !pm) {\n pm = new PluginManager(less);\n }\n return pm;\n};\n\n//\nexport default PluginManagerFactory;\n"]} |
| {"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/less/render.js"],"names":[],"mappings":";;;AAAA,qDAAiC;AAEjC,mBAAwB,WAAW,EAAE,SAAS;IAC1C,IAAM,MAAM,GAAG,UAAU,KAAK,EAAE,OAAO,EAAE,QAAQ;QAC7C,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;YAC/B,QAAQ,GAAG,OAAO,CAAC;YACnB,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;SACjD;aACI;YACD,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;SAC5D;QAED,IAAI,CAAC,QAAQ,EAAE;YACX,IAAM,MAAI,GAAG,IAAI,CAAC;YAClB,OAAO,IAAI,OAAO,CAAC,UAAU,OAAO,EAAE,MAAM;gBACxC,MAAM,CAAC,IAAI,CAAC,MAAI,EAAE,KAAK,EAAE,OAAO,EAAE,UAAS,GAAG,EAAE,MAAM;oBAClD,IAAI,GAAG,EAAE;wBACL,MAAM,CAAC,GAAG,CAAC,CAAC;qBACf;yBAAM;wBACH,OAAO,CAAC,MAAM,CAAC,CAAC;qBACnB;gBACL,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;SACN;aAAM;YACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,UAAS,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO;gBAC3D,IAAI,GAAG,EAAE;oBAAE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;iBAAE;gBAElC,IAAI,MAAM,CAAC;gBACX,IAAI;oBACA,IAAM,SAAS,GAAG,IAAI,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;oBAC/C,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;iBACrC;gBACD,OAAO,GAAG,EAAE;oBAAE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;iBAAE;gBAErC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;SACN;IACL,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC;AAClB,CAAC;AAtCD,4BAsCC","sourcesContent":["import * as utils from './utils';\n\nexport default function(environment, ParseTree) {\n const render = function (input, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = utils.copyOptions(this.options, {});\n }\n else {\n options = utils.copyOptions(this.options, options || {});\n }\n\n if (!callback) {\n const self = this;\n return new Promise(function (resolve, reject) {\n render.call(self, input, options, function(err, output) {\n if (err) {\n reject(err);\n } else {\n resolve(output);\n }\n });\n });\n } else {\n this.parse(input, options, function(err, root, imports, options) {\n if (err) { return callback(err); }\n\n let result;\n try {\n const parseTree = new ParseTree(root, imports);\n result = parseTree.toCSS(options);\n }\n catch (err) { return callback(err); }\n\n callback(null, result);\n });\n }\n };\n\n return render;\n}\n"]} |
| {"version":3,"file":"source-map-builder.js","sourceRoot":"","sources":["../../src/less/source-map-builder.js"],"names":[],"mappings":";;AAAA,mBAAyB,eAAe,EAAE,WAAW;IACjD;QACI,0BAAY,OAAO;YACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAC3B,CAAC;QAED,gCAAK,GAAL,UAAM,QAAQ,EAAE,OAAO,EAAE,OAAO;YAC5B,IAAM,eAAe,GAAG,IAAI,eAAe,CACvC;gBACI,uBAAuB,EAAE,OAAO,CAAC,oBAAoB;gBACrD,QAAQ,UAAA;gBACR,WAAW,EAAE,OAAO,CAAC,QAAQ;gBAC7B,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB;gBACjD,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;gBACvC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,uBAAuB;gBACpD,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB;gBACjD,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB;gBACjD,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB;gBACjD,kBAAkB,EAAE,IAAI,CAAC,OAAO,CAAC,kBAAkB;gBACnD,mBAAmB,EAAE,IAAI,CAAC,OAAO,CAAC,mBAAmB;gBACrD,0BAA0B,EAAE,IAAI,CAAC,OAAO,CAAC,0BAA0B;aACtE,CAAC,CAAC;YAEP,IAAM,GAAG,GAAG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I,CAAC,OAAO,CAAC,mBAAmB,CAAC;QAC5C,CAAC;QAED,0CAAe,GAAf;YACI,OAAO,IAAI,CAAC,YAAY,CAAC;QAC7B,CAAC;QAED,4CAAiB,GAAjB;YACI,OAAO,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC;QAChD,CAAC;QAED,2CAAgB,GAAhB;YACI,OAAO,IAAI,CAAC,sBAAsB,CAAC;QACvC,CAAC;QACL,uBAAC;IAAD,CAAC,AA7ED,IA6EC;IAED,OAAO,gBAAgB,CAAC;AAC5B,CAAC;AAjFD,4BAiFC","sourcesContent":["export default function (SourceMapOutput, environment) {\n class SourceMapBuilder {\n constructor(options) {\n this.options = options;\n }\n\n toCSS(rootNode, options, imports) {\n const sourceMapOutput = new SourceMapOutput(\n {\n contentsIgnoredCharsMap: imports.contentsIgnoredChars,\n rootNode,\n contentsMap: imports.contents,\n sourceMapFilename: this.options.sourceMapFilename,\n sourceMapURL: this.options.sourceMapURL,\n outputFilename: this.options.sourceMapOutputFilename,\n sourceMapBasepath: this.options.sourceMapBasepath,\n sourceMapRootpath: this.options.sourceMapRootpath,\n outputSourceFiles: this.options.outputSourceFiles,\n sourceMapGenerator: this.options.sourceMapGenerator,\n sourceMapFileInline: this.options.sourceMapFileInline, \n disableSourcemapAnnotation: this.options.disableSourcemapAnnotation\n });\n\n const css = sourceMapOutput.toCSS(options);\n this.sourceMap = sourceMapOutput.sourceMap;\n this.sourceMapURL = sourceMapOutput.sourceMapURL;\n if (this.options.sourceMapInputFilename) {\n this.sourceMapInputFilename = sourceMapOutput.normalizeFilename(this.options.sourceMapInputFilename);\n }\n if (this.options.sourceMapBasepath !== undefined && this.sourceMapURL !== undefined) {\n this.sourceMapURL = sourceMapOutput.removeBasepath(this.sourceMapURL);\n }\n return css + this.getCSSAppendage();\n }\n\n getCSSAppendage() {\n\n let sourceMapURL = this.sourceMapURL;\n if (this.options.sourceMapFileInline) {\n if (this.sourceMap === undefined) {\n return '';\n }\n sourceMapURL = `data:application/json;base64,${environment.encodeBase64(this.sourceMap)}`;\n }\n\n if (this.options.disableSourcemapAnnotation) {\n return '';\n }\n\n if (sourceMapURL) {\n return `/*# sourceMappingURL=${sourceMapURL} */`;\n }\n return '';\n }\n\n getExternalSourceMap() {\n return this.sourceMap;\n }\n\n setExternalSourceMap(sourceMap) {\n this.sourceMap = sourceMap;\n }\n\n isInline() {\n return this.options.sourceMapFileInline;\n }\n\n getSourceMapURL() {\n return this.sourceMapURL;\n }\n\n getOutputFilename() {\n return this.options.sourceMapOutputFilename;\n }\n\n getInputFilename() {\n return this.sourceMapInputFilename;\n }\n }\n\n return SourceMapBuilder;\n}\n"]} |
| {"version":3,"file":"source-map-output.js","sourceRoot":"","sources":["../../src/less/source-map-output.js"],"names":[],"mappings":";;AAAA,mBAAyB,WAAW;IAChC;QACI,yBAAY,OAAO;YACf,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;YACf,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;YAClC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;YACxC,IAAI,CAAC,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC;YAChE,IAAI,OAAO,CAAC,iBAAiB,EAAE;gBAC3B,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;aAC3E;YACD,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;YACpH,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;YACzC,IAAI,OAAO,CAAC,iBAAiB,EAAE;gBAC3B,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG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AAC,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC;gBAE3E,IAAI,IAAI,CAAC,YAAY,EAAE;oBACnB,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;iBACpC;qBAAM,IAAI,IAAI,CAAC,kBAAkB,EAAE;oBAChC,YAAY,GAAG,IAAI,CAAC,kBAAkB,CAAC;iBAC1C;gBACD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;gBAEjC,IAAI,CAAC,SAAS,GAAG,gBAAgB,CAAC;aACrC;YAED,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9B,CAAC;QACL,sBAAC;IAAD,CAAC,AAlJD,IAkJC;IAED,OAAO,eAAe,CAAC;AAC3B,CAAC;AAtJD,4BAsJC","sourcesContent":["export default function (environment) {\n class SourceMapOutput {\n constructor(options) {\n this._css = [];\n this._rootNode = options.rootNode;\n this._contentsMap = options.contentsMap;\n this._contentsIgnoredCharsMap = options.contentsIgnoredCharsMap;\n if (options.sourceMapFilename) {\n this._sourceMapFilename = options.sourceMapFilename.replace(/\\\\/g, '/');\n }\n this._outputFilename = options.outputFilename ? options.outputFilename.replace(/\\\\/g, '/') : options.outputFilename;\n this.sourceMapURL = options.sourceMapURL;\n if (options.sourceMapBasepath) {\n this._sourceMapBasepath = options.sourceMapBasepath.replace(/\\\\/g, '/');\n }\n if (options.sourceMapRootpath) {\n this._sourceMapRootpath = options.sourceMapRootpath.replace(/\\\\/g, '/');\n if (this._sourceMapRootpath.charAt(this._sourceMapRootpath.length - 1) !== '/') {\n this._sourceMapRootpath += '/';\n }\n } else {\n this._sourceMapRootpath = '';\n }\n this._outputSourceFiles = options.outputSourceFiles;\n this._sourceMapGeneratorConstructor = environment.getSourceMapGenerator();\n\n this._lineNumber = 0;\n this._column = 0;\n }\n\n removeBasepath(path) {\n if (this._sourceMapBasepath && path.indexOf(this._sourceMapBasepath) === 0) {\n path = path.substring(this._sourceMapBasepath.length);\n if (path.charAt(0) === '\\\\' || path.charAt(0) === '/') {\n path = path.substring(1);\n }\n }\n\n return path;\n }\n\n normalizeFilename(filename) {\n filename = filename.replace(/\\\\/g, '/');\n filename = this.removeBasepath(filename);\n return (this._sourceMapRootpath || '') + filename;\n }\n\n add(chunk, fileInfo, index, mapLines) {\n\n // ignore adding empty strings\n if (!chunk) {\n return;\n }\n\n let lines, sourceLines, columns, sourceColumns, i;\n\n if (fileInfo && fileInfo.filename) {\n let inputSource = this._contentsMap[fileInfo.filename];\n\n // remove vars/banner added to the top of the file\n if (this._contentsIgnoredCharsMap[fileInfo.filename]) {\n // adjust the index\n index -= this._contentsIgnoredCharsMap[fileInfo.filename];\n if (index < 0) { index = 0; }\n // adjust the source\n inputSource = inputSource.slice(this._contentsIgnoredCharsMap[fileInfo.filename]);\n }\n\n /** \n * ignore empty content, or failsafe\n * if contents map is incorrect\n */\n if (inputSource === undefined) {\n this._css.push(chunk);\n return;\n }\n\n inputSource = inputSource.substring(0, index);\n sourceLines = inputSource.split('\\n');\n sourceColumns = sourceLines[sourceLines.length - 1];\n }\n\n lines = chunk.split('\\n');\n columns = lines[lines.length - 1];\n\n if (fileInfo && fileInfo.filename) {\n if (!mapLines) {\n this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + 1, column: this._column},\n original: { line: sourceLines.length, column: sourceColumns.length},\n source: this.normalizeFilename(fileInfo.filename)});\n } else {\n for (i = 0; i < lines.length; i++) {\n this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + i + 1, column: i === 0 ? this._column : 0},\n original: { line: sourceLines.length + i, column: i === 0 ? sourceColumns.length : 0},\n source: this.normalizeFilename(fileInfo.filename)});\n }\n }\n }\n\n if (lines.length === 1) {\n this._column += columns.length;\n } else {\n this._lineNumber += lines.length - 1;\n this._column = columns.length;\n }\n\n this._css.push(chunk);\n }\n\n isEmpty() {\n return this._css.length === 0;\n }\n\n toCSS(context) {\n this._sourceMapGenerator = new this._sourceMapGeneratorConstructor({ file: this._outputFilename, sourceRoot: null });\n\n if (this._outputSourceFiles) {\n for (const filename in this._contentsMap) {\n // eslint-disable-next-line no-prototype-builtins\n if (this._contentsMap.hasOwnProperty(filename)) {\n let source = this._contentsMap[filename];\n if (this._contentsIgnoredCharsMap[filename]) {\n source = source.slice(this._contentsIgnoredCharsMap[filename]);\n }\n this._sourceMapGenerator.setSourceContent(this.normalizeFilename(filename), source);\n }\n }\n }\n\n this._rootNode.genCSS(context, this);\n\n if (this._css.length > 0) {\n let sourceMapURL;\n const sourceMapContent = JSON.stringify(this._sourceMapGenerator.toJSON());\n\n if (this.sourceMapURL) {\n sourceMapURL = this.sourceMapURL;\n } else if (this._sourceMapFilename) {\n sourceMapURL = this._sourceMapFilename;\n }\n this.sourceMapURL = sourceMapURL;\n\n this.sourceMap = sourceMapContent;\n }\n\n return this._css.join('');\n }\n }\n\n return SourceMapOutput;\n}\n"]} |
| {"version":3,"file":"transform-tree.js","sourceRoot":"","sources":["../../src/less/transform-tree.js"],"names":[],"mappings":";;;AAAA,gEAAkC;AAClC,gEAAiC;AACjC,wDAA0B;AAE1B,mBAAwB,IAAI,EAAE,OAAO;IACjC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;IACxB,IAAI,SAAS,CAAC;IACd,IAAI,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAClC,IAAM,OAAO,GAAG,IAAI,kBAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAE3C,EAAE;IACF,4CAA4C;IAC5C,EAAE;IACF,qDAAqD;IACrD,EAAE;IACF,mCAAmC;IACnC,uBAAuB;IACvB,8BAA8B;IAC9B,iCAAiC;IACjC,WAAW;IACX,SAAS;IACT,MAAM;IACN,EAAE;IACF,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAC5D,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC;YAC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nimport visitor from './visitors';\nimport tree from './tree';\n\nexport default function(root, options) {\n options = options || {};\n let evaldRoot;\n let variables = options.variables;\n const evalEnv = new contexts.Eval(options);\n\n //\n // Allows setting variables with a hash, so:\n //\n // `{ color: new tree.Color('#f01') }` will become:\n //\n // new tree.Declaration('@color',\n // new tree.Value([\n // new tree.Expression([\n // new tree.Color('#f01')\n // ])\n // ])\n // )\n //\n if (typeof variables === 'object' && !Array.isArray(variables)) {\n variables = Object.keys(variables).map(function (k) {\n let value = variables[k];\n\n if (!(value instanceof tree.Value)) {\n if (!(value instanceof tree.Expression)) {\n value = new tree.Expression([value]);\n }\n value = new tree.Value([value]);\n }\n return new tree.Declaration(`@${k}`, value, false, null, 0);\n });\n evalEnv.frames = [new tree.Ruleset(null, variables)];\n }\n\n const visitors = [\n new visitor.JoinSelectorVisitor(),\n new visitor.MarkVisibleSelectorsVisitor(true),\n new visitor.ExtendVisitor(),\n new visitor.ToCSSVisitor({compress: Boolean(options.compress)})\n ];\n\n const preEvalVisitors = [];\n let v;\n let visitorIterator;\n\n /**\n * first() / get() allows visitors to be added while visiting\n * \n * @todo Add scoping for visitors just like functions for @plugin; right now they're global\n */\n if (options.pluginManager) {\n visitorIterator = options.pluginManager.visitor();\n for (let i = 0; i < 2; i++) {\n visitorIterator.first();\n while ((v = visitorIterator.get())) {\n if (v.isPreEvalVisitor) {\n if (i === 0 || preEvalVisitors.indexOf(v) === -1) {\n preEvalVisitors.push(v);\n v.run(root);\n }\n }\n else {\n if (i === 0 || visitors.indexOf(v) === -1) {\n if (v.isPreVisitor) {\n visitors.unshift(v);\n }\n else {\n visitors.push(v);\n }\n }\n }\n }\n }\n }\n\n evaldRoot = root.eval(evalEnv);\n\n for (let i = 0; i < visitors.length; i++) {\n visitors[i].run(evaldRoot);\n }\n\n // Run any remaining visitors added after eval pass\n if (options.pluginManager) {\n visitorIterator.first();\n while ((v = visitorIterator.get())) {\n if (visitors.indexOf(v) === -1 && preEvalVisitors.indexOf(v) === -1) {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QAClB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,IAAI,CAAC,WAAW,EAAE;YAClB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;SACtE;IACL,CAAC;CACJ,CAAC,CAAA;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["import Node from './node';\n\nconst Anonymous = function(value, index, currentFileInfo, mapLines, rulesetLike, visibilityInfo) {\n this.value = value;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.mapLines = mapLines;\n this.rulesetLike = (typeof rulesetLike === 'undefined') ? false : rulesetLike;\n this.allowRoot = true;\n this.copyVisibilityInfo(visibilityInfo);\n}\n\nAnonymous.prototype = Object.assign(new Node(), {\n type: 'Anonymous',\n eval() {\n return new Anonymous(this.value, this._index, this._fileInfo, this.mapLines, this.rulesetLike, this.visibilityInfo());\n },\n compare(other) {\n return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined;\n },\n isRulesetLike() {\n return this.rulesetLike;\n },\n genCSS(context, output) {\n this.nodeVisible = Boolean(this.value);\n if (this.nodeVisible) {\n output.add(this.value, this._fileInfo, this._index, this.mapLines);\n }\n }\n})\n\nexport default Anonymous;\n"]} |
| {"version":3,"file":"assignment.js","sourceRoot":"","sources":["../../../src/less/tree/assignment.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAE1B,IAAM,UAAU,GAAG,UAAS,GAAG,EAAE,GAAG;IAChC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACf,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;AACrB,CAAC,CAAA;AAED,UAAU,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAC7C,IAAI,EAAE,YAAY;IAElB,MAAM,YAAC,OAAO;QACV,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,YAAC,OAAO;QACR,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YACjB,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;SAC7D;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,YAAC,OAAO,EAAE,MAAM;QAClB,MAAM,CAAC,GAAG,CAAC,UAAG,IAAI,CAAC,GAAG,MAAG,CAAC,CAAC;QAC3B,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACnB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;SACtC;aAAM;YACH,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1B;IACL,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,UAAU,CAAC","sourcesContent":["import Node from './node';\n\nconst Assignment = function(key, val) {\n this.key = key;\n this.value = val;\n}\n\nAssignment.prototype = Object.assign(new Node(), {\n type: 'Assignment',\n\n accept(visitor) {\n this.value = visitor.visit(this.value);\n },\n\n eval(context) {\n if (this.value.eval) {\n return new Assignment(this.key, this.value.eval(context));\n }\n return this;\n },\n\n genCSS(context, output) {\n output.add(`${this.key}=`);\n if (this.value.genCSS) {\n this.value.genCSS(context, output);\n } else {\n output.add(this.value);\n }\n }\n});\n\nexport default Assignment;\n"]} |
| {"version":3,"file":"atrule-syntax.js","sourceRoot":"","sources":["../../../src/less/tree/atrule-syntax.js"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG;IAC9B,aAAa,EAAE,IAAI;CACtB,CAAC;AAEW,QAAA,sBAAsB,GAAG;IAClC,aAAa,EAAE,IAAI;CACtB,CAAC","sourcesContent":["export const MediaSyntaxOptions = {\n queryInParens: true\n};\n\nexport const ContainerSyntaxOptions = {\n queryInParens: true\n};\n"]} |
| {"version":3,"file":"atrule.js","sourceRoot":"","sources":["../../../src/less/tree/atrule.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,gEAAkC;AAClC,8DAAgC;AAChC,kEAAoC;AACpC,4EAAuD;AAEvD,IAAM,MAAM,GAAG,UACX,IAAI,EACJ,KAAK,EACL,KAAK,EACL,KAAK,EACL,eAAe,EACf,SAAS,EACT,QAAQ,EACR,cAAc;IARH,iBA0Dd;IAhDG,IAAI,CAAC,CAAC;IACN,IAAI,SAAS,GAAG,CAAC,IAAI,kBAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,oBAAoB,EAAE,CAAC;IAEnG,IAAI,CAAC,IAAI,GAAI,IAAI,CAAC;IAClB,IAAI,CAAC,KAAK,GAAG,CAAC,KAAK,YAAY,cAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,mBAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACtF,IAAI,KAAK,EAAE;QACP,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACtB,IAAM,eAAe,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAEtD,IAAI,wBAAsB,GAAG,IAAI,CAAC;YAClC,KAAK,CAAC,OAAO,CAAC,UAAA,IAAI;gBACd,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK;oBAAE,wBAAsB,GAAG,wBAAsB,IAAI,KAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YAC3I,CAAC,CAAC,CAAC;YAEH,IAAI,eAAe,IAAI,CAAC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jC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,EAAE,EAAE;gBAC1B,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;gBACvB,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;aACpC;YACD,MAAM,CAAC,GAAG,CAAC,UAAG,SAAS,MAAG,CAAC,CAAC;SAC/B;QAED,OAAO,CAAC,QAAQ,EAAE,CAAC;IACvB,CAAC,IACH,CAAC;AAEH,kBAAe,MAAM,CAAC","sourcesContent":["import Node from './node';\nimport Selector from './selector';\nimport Ruleset from './ruleset';\nimport Anonymous from './anonymous';\nimport NestableAtRulePrototype from './nested-at-rule';\n\nconst AtRule = function(\n name,\n value,\n rules,\n index,\n currentFileInfo,\n debugInfo,\n isRooted,\n visibilityInfo\n) {\n let i;\n var selectors = (new Selector([], null, null, this._index, this._fileInfo)).createEmptySelectors();\n\n this.name = name;\n this.value = (value instanceof Node) ? value : (value ? new Anonymous(value) : value);\n if (rules) {\n if (Array.isArray(rules)) {\n const allDeclarations = this.declarationsBlock(rules);\n \n let allRulesetDeclarations = true;\n rules.forEach(rule => {\n if (rule.type === 'Ruleset' && rule.rules) allRulesetDeclarations = allRulesetDeclarations && this.declarationsBlock(rule.rules, true);\n });\n\n if (allDeclarations && !isRooted) {\n this.simpleBlock = true;\n this.declarations = rules;\n } else if (allRulesetDeclarations && rules.length === 1 && !isRooted && !value) {\n this.simpleBlock = true;\n this.declarations = rules[0].rules ? rules[0].rules : rules;\n } else {\n this.rules = rules;\n }\n } else {\n const allDeclarations = this.declarationsBlock(rules.rules);\n \n if (allDeclarations && !isRooted && !value) {\n this.simpleBlock = true;\n this.declarations = rules.rules;\n } else {\n this.rules = [rules];\n this.rules[0].selectors = (new Selector([], null, null, index, currentFileInfo)).createEmptySelectors();\n }\n }\n if (!this.simpleBlock) {\n for (i = 0; i < this.rules.length; i++) {\n this.rules[i].allowImports = true;\n }\n }\n this.setParent(selectors, this);\n this.setParent(this.rules, this);\n }\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.debugInfo = debugInfo;\n this.isRooted = isRooted || false;\n this.copyVisibilityInfo(visibilityInfo);\n this.allowRoot = true;\n}\n\nAtRule.prototype = Object.assign(new Node(), {\n type: 'AtRule',\n\n ...NestableAtRulePrototype,\n\n declarationsBlock(rules, mergeable = false) {\n if (!mergeable) {\n return rules.filter(function (node) { return (node.type === 'Declaration' || node.type === 'Comment') && !node.merge}).length === rules.length;\n } else {\n return rules.filter(function (node) { return (node.type === 'Declaration' || node.type === 'Comment'); }).length === rules.length;\n }\n },\n\n keywordList(rules) {\n if (!Array.isArray(rules)) {\n return false;\n } else { \n return rules.filter(function (node) { return (node.type === 'Keyword' || node.type === 'Comment'); }).length === rules.length;\n }\n },\n\n accept(visitor) {\n const value = this.value, rules = this.rules, declarations = this.declarations;\n\n if (rules) {\n this.rules = visitor.visitArray(rules);\n } else if (declarations) {\n this.declarations = visitor.visitArray(declarations); \n }\n if (value) {\n this.value = visitor.visit(value);\n }\n },\n\n isRulesetLike() {\n return this.rules || !this.isCharset();\n },\n\n isCharset() {\n return '@charset' === this.name;\n },\n\n genCSS(context, output) {\n const value = this.value, rules = this.rules || this.declarations;\n output.add(this.name, this.fileInfo(), this.getIndex());\n if (value) {\n output.add(' ');\n value.genCSS(context, output);\n }\n if (this.simpleBlock) {\n this.outputRuleset(context, output, this.declarations);\n } else if (rules) {\n this.outputRuleset(context, output, rules);\n } else {\n output.add(';');\n }\n },\n\n eval(context) {\n let mediaPathBackup, mediaBlocksBackup, value = this.value, rules = this.rules || this.declarations;\n \n // media stored inside other atrule should not bubble over it\n // backpup media bubbling information\n mediaPathBackup = context.mediaPath;\n mediaBlocksBackup = context.mediaBlocks;\n // deleted media bubbling information\n context.mediaPath = [];\n context.mediaBlocks = [];\n\n if (value) {\n value = value.eval(context);\n if (value.value && this.keywordList(value.value)) {\n value = new Anonymous(value.value.map(keyword => keyword.value).join(', '), this.getIndex(), this.fileInfo());\n }\n }\n\n if (rules) {\n rules = this.evalRoot(context, rules);\n }\n if (Array.isArray(rules) && rules[0].rules && Array.isArray(rules[0].rules) && rules[0].rules.length) {\n const allMergeableDeclarations = this.declarationsBlock(rules[0].rules, true);\n if (allMergeableDeclarations && !this.isRooted && !value) {\n var mergeRules = context.pluginManager.less.visitors.ToCSSVisitor.prototype._mergeRules;\n mergeRules(rules[0].rules);\n rules = rules[0].rules;\n rules.forEach(rule => rule.merge = false);\n }\n }\n if (this.simpleBlock && rules) {\n rules[0].functionRegistry = context.frames[0].functionRegistry.inherit();\n rules = rules.map(function (rule) { return rule.eval(context); });\n }\n\n // restore media bubbling information\n context.mediaPath = mediaPathBackup;\n context.mediaBlocks = mediaBlocksBackup;\n return new AtRule(this.name, value, rules, this.getIndex(), this.fileInfo(), this.debugInfo, this.isRooted, this.visibilityInfo());\n },\n\n evalRoot(context, rules) {\n let ampersandCount = 0;\n let noAmpersandCount = 0;\n let noAmpersands = true;\n let allAmpersands = false;\n\n if (!this.simpleBlock) {\n rules = [rules[0].eval(context)];\n }\n\n let precedingSelectors = [];\n if (context.frames.length > 0) {\n for (let index = 0; index < context.frames.length; index++) {\n const frame = context.frames[index];\n if (\n frame.type === 'Ruleset' &&\n frame.rules &&\n frame.rules.length > 0\n ) {\n if (frame && !frame.root && frame.selectors && frame.selectors.length > 0) {\n precedingSelectors = precedingSelectors.concat(frame.selectors);\n }\n }\n if (precedingSelectors.length > 0) {\n let value = '';\n const output = { add: function (s) { value += s; } };\n for (let i = 0; i < precedingSelectors.length; i++) {\n precedingSelectors[i].genCSS(context, output);\n }\n if (/^&+$/.test(value.replace(/\\s+/g, ''))) {\n noAmpersands = false;\n noAmpersandCount++;\n } else {\n allAmpersands = false;\n ampersandCount++;\n }\n }\n }\n }\n\n const mixedAmpersands = ampersandCount > 0 && noAmpersandCount > 0 && !allAmpersands && !noAmpersands;\n if (\n (this.isRooted && ampersandCount > 0 && noAmpersandCount === 0 && !allAmpersands && noAmpersands)\n || !mixedAmpersands\n ) {\n rules[0].root = true;\n }\n return rules;\n },\n\n variable(name) {\n if (this.rules) {\n // assuming that there is only one rule at this point - that is how parser constructs the rule\n return Ruleset.prototype.variable.call(this.rules[0], name);\n }\n },\n\n find() {\n if (this.rules) {\n // assuming that there is only one rule at this point - that is how parser constructs the rule\n return Ruleset.prototype.find.apply(this.rules[0], arguments);\n }\n },\n\n rulesets() {\n if (this.rules) {\n // assuming that there is only one rule at this point - that is how parser constructs the rule\n return Ruleset.prototype.rulesets.apply(this.rules[0]);\n }\n },\n\n outputRuleset(context, output, rules) {\n const ruleCnt = rules.length;\n let i;\n context.tabLevel = (context.tabLevel | 0) + 1;\n\n // Compressed\n if (context.compress) {\n output.add('{');\n for (i = 0; i < ruleCnt; i++) {\n rules[i].genCSS(context, output);\n }\n output.add('}');\n context.tabLevel--;\n return;\n }\n\n // Non-compressed\n const tabSetStr = `\\n${Array(context.tabLevel).join(' ')}`, tabRuleStr = `${tabSetStr} `;\n if (!ruleCnt) {\n output.add(` {${tabSetStr}}`);\n } else {\n output.add(` {${tabRuleStr}`);\n rules[0].genCSS(context, output);\n for (i = 1; i < ruleCnt; i++) {\n output.add(tabRuleStr);\n rules[i].genCSS(context, output);\n }\n output.add(`${tabSetStr}}`);\n }\n\n context.tabLevel--;\n }\n});\n\nexport default AtRule;\n"]} |
| {"version":3,"file":"attribute.js","sourceRoot":"","sources":["../../../src/less/tree/attribute.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAE1B,IAAM,SAAS,GAAG,UAAS,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG;IAC1C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;AACnB,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,G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C,CAAC;AAEH,kBAAe,SAAS,CAAC","sourcesContent":["import Node from './node';\n\nconst Attribute = function(key, op, value, cif) {\n this.key = key;\n this.op = op;\n this.value = value;\n this.cif = cif;\n}\n\nAttribute.prototype = Object.assign(new Node(), {\n type: 'Attribute',\n\n eval(context) {\n return new Attribute(\n this.key.eval ? this.key.eval(context) : this.key,\n this.op,\n (this.value && this.value.eval) ? this.value.eval(context) : this.value,\n this.cif\n );\n },\n\n genCSS(context, output) {\n output.add(this.toCSS(context));\n },\n\n toCSS(context) {\n let value = this.key.toCSS ? this.key.toCSS(context) : this.key;\n\n if (this.op) {\n value += this.op;\n value += (this.value.toCSS ? this.value.toCSS(context) : this.value);\n }\n\n if (this.cif) {\n value = value + ' ' + this.cif;\n }\n\n return `[${value}]`;\n }\n});\n\nexport default Attribute;\n"]} |
| {"version":3,"file":"call.js","sourceRoot":"","sources":["../../../src/less/tree/call.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,kEAAoC;AACpC,yFAA0D;AAE1D,EAAE;AACF,wBAAwB;AACxB,EAAE;AACF,IAAM,IAAI,GAAG,UAAS,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,eAAe;IACpD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,IAAI,CAAC,IAAI,GAAG,IAAI,KAAK,MAAM,CAAC;IAC5B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACpB,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC;AACrC,CAAC,CAAA;AAED,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IACvC,IAAI,EAAE,MAAM;IAEZ,MAAM,YAAC,OAAO;QACV,IAAI,IAAI,CAAC,IAAI,EAAE;YACX,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC7C;IACL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E,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAE9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACvC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACrC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBAC1B,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;aACpB;SACJ;QAED,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,IAAI,CAAC","sourcesContent":["import Node from './node';\nimport Anonymous from './anonymous';\nimport FunctionCaller from '../functions/function-caller';\n\n//\n// A function call node.\n//\nconst Call = function(name, args, index, currentFileInfo) {\n this.name = name;\n this.args = args;\n this.calc = name === 'calc';\n this._index = index;\n this._fileInfo = currentFileInfo;\n}\n\nCall.prototype = Object.assign(new Node(), {\n type: 'Call',\n\n accept(visitor) {\n if (this.args) {\n this.args = visitor.visitArray(this.args);\n }\n },\n\n //\n // When evaluating a function call,\n // we either find the function in the functionRegistry,\n // in which case we call it, passing the evaluated arguments,\n // if this returns null or we cannot find the function, we\n // simply print it out as it appeared originally [2].\n //\n // The reason why we evaluate the arguments, is in the case where\n // we try to pass a variable to a function, like: `saturate(@color)`.\n // The function should receive the value, not the variable.\n //\n eval(context) {\n /**\n * Turn off math for calc(), and switch back on for evaluating nested functions\n */\n const currentMathContext = context.mathOn;\n context.mathOn = !this.calc;\n if (this.calc || context.inCalc) {\n context.enterCalc();\n }\n\n const exitCalc = () => {\n if (this.calc || context.inCalc) {\n context.exitCalc();\n }\n context.mathOn = currentMathContext;\n };\n\n let result;\n const funcCaller = new FunctionCaller(this.name, context, this.getIndex(), this.fileInfo());\n\n if (funcCaller.isValid()) {\n try {\n result = funcCaller.call(this.args);\n exitCalc();\n } catch (e) {\n // eslint-disable-next-line no-prototype-builtins\n if (e.hasOwnProperty('line') && e.hasOwnProperty('column')) {\n throw e;\n }\n throw { \n type: e.type || 'Runtime',\n message: `Error evaluating function \\`${this.name}\\`${e.message ? `: ${e.message}` : ''}`,\n index: this.getIndex(), \n filename: this.fileInfo().filename,\n line: e.lineNumber,\n column: e.columnNumber\n };\n }\n }\n\n if (result !== null && result !== undefined) {\n // Results that that are not nodes are cast as Anonymous nodes\n // Falsy values or booleans are returned as empty nodes\n if (!(result instanceof Node)) {\n if (!result || result === true) {\n result = new Anonymous(null); \n }\n else {\n result = new Anonymous(result.toString()); \n }\n \n }\n result._index = this._index;\n result._fileInfo = this._fileInfo;\n return result;\n }\n\n const args = this.args.map(a => a.eval(context));\n exitCalc();\n\n return new Call(this.name, args, this.getIndex(), this.fileInfo());\n },\n\n genCSS(context, output) {\n output.add(`${this.name}(`, this.fileInfo(), this.getIndex());\n\n for (let i = 0; i < this.args.length; i++) {\n this.args[i].genCSS(context, output);\n if (i + 1 < this.args.length) {\n output.add(', ');\n }\n }\n\n output.add(')');\n }\n});\n\nexport default Call;\n"]} |
| {"version":3,"file":"color.js","sourceRoot":"","sources":["../../../src/less/tree/color.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,kEAAoC;AAEpC,EAAE;AACF,6BAA6B;AAC7B,EAAE;AACF,IAAM,KAAK,GAAG,UAAS,GAAG,EAAE,CAAC,EAAE,YAAY;IACvC,IAAM,IAAI,GAAG,IAAI,CAAC;IAClB,EAAE;IACF,+CAA+C;IAC/C,iDAAiD;IACjD,EAAE;IACF,+CAA+C;IAC/C,EAAE;IACF,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACpB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;KAClB;SAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,EAAE;QACxB,IAAI,CAAC,GAAG,GAAG,EA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node from './node';\nimport colors from '../data/colors';\n\n//\n// RGB Colors - #ff0014, #eee\n//\nconst Color = function(rgb, a, originalForm) {\n const self = this;\n //\n // The end goal here, is to parse the arguments\n // into an integer triplet, such as `128, 255, 0`\n //\n // This facilitates operations and conversions.\n //\n if (Array.isArray(rgb)) {\n this.rgb = rgb;\n } else if (rgb.length >= 6) {\n this.rgb = [];\n rgb.match(/.{2}/g).map(function (c, i) {\n if (i < 3) {\n self.rgb.push(parseInt(c, 16));\n } else {\n self.alpha = (parseInt(c, 16)) / 255;\n }\n });\n } else {\n this.rgb = [];\n rgb.split('').map(function (c, i) {\n if (i < 3) {\n self.rgb.push(parseInt(c + c, 16));\n } else {\n self.alpha = (parseInt(c + c, 16)) / 255;\n }\n });\n }\n this.alpha = this.alpha || (typeof a === 'number' ? a : 1);\n if (typeof originalForm !== 'undefined') {\n this.value = originalForm;\n }\n}\n\nColor.prototype = Object.assign(new Node(), {\n type: 'Color',\n\n luma() {\n let r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255;\n\n r = (r <= 0.03928) ? r / 12.92 : Math.pow(((r + 0.055) / 1.055), 2.4);\n g = (g <= 0.03928) ? g / 12.92 : Math.pow(((g + 0.055) / 1.055), 2.4);\n b = (b <= 0.03928) ? b / 12.92 : Math.pow(((b + 0.055) / 1.055), 2.4);\n\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n },\n\n genCSS(context, output) {\n output.add(this.toCSS(context));\n },\n\n toCSS(context, doNotCompress) {\n const compress = context && context.compress && !doNotCompress;\n let color;\n let alpha;\n let colorFunction;\n let args = [];\n\n // `value` is set if this color was originally\n // converted from a named color string so we need\n // to respect this and try to output named color too.\n alpha = this.fround(context, this.alpha);\n\n if (this.value) {\n if (this.value.indexOf('rgb') === 0) {\n if (alpha < 1) {\n colorFunction = 'rgba';\n }\n } else if (this.value.indexOf('hsl') === 0) {\n if (alpha < 1) {\n colorFunction = 'hsla';\n } else {\n colorFunction = 'hsl';\n }\n } else {\n return this.value;\n }\n } else {\n if (alpha < 1) {\n colorFunction = 'rgba';\n }\n }\n\n switch (colorFunction) {\n case 'rgba':\n args = this.rgb.map(function (c) {\n return clamp(Math.round(c), 255);\n }).concat(clamp(alpha, 1));\n break;\n case 'hsla':\n args.push(clamp(alpha, 1));\n // eslint-disable-next-line no-fallthrough\n case 'hsl':\n color = this.toHSL();\n args = [\n this.fround(context, color.h),\n `${this.fround(context, color.s * 100)}%`,\n `${this.fround(context, color.l * 100)}%`\n ].concat(args);\n }\n\n if (colorFunction) {\n // Values are capped between `0` and `255`, rounded and zero-padded.\n return `${colorFunction}(${args.join(`,${compress ? '' : ' '}`)})`;\n }\n\n color = this.toRGB();\n\n if (compress) {\n const splitcolor = color.split('');\n\n // Convert color to short format\n if (splitcolor[1] === splitcolor[2] && splitcolor[3] === splitcolor[4] && splitcolor[5] === splitcolor[6]) {\n color = `#${splitcolor[1]}${splitcolor[3]}${splitcolor[5]}`;\n }\n }\n\n return color;\n },\n\n //\n // Operations have to be done per-channel, if not,\n // channels will spill onto each other. Once we have\n // our result, in the form of an integer triplet,\n // we create a new Color node to hold the result.\n //\n operate(context, op, other) {\n const rgb = new Array(3);\n const alpha = this.alpha * (1 - other.alpha) + other.alpha;\n for (let c = 0; c < 3; c++) {\n rgb[c] = this._operate(context, op, this.rgb[c], other.rgb[c]);\n }\n return new Color(rgb, alpha);\n },\n\n toRGB() {\n return toHex(this.rgb);\n },\n\n toHSL() {\n const r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255, a = this.alpha;\n\n const max = Math.max(r, g, b), min = Math.min(r, g, b);\n let h;\n let s;\n const l = (max + min) / 2;\n const d = max - min;\n\n if (max === min) {\n h = s = 0;\n } else {\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n\n switch (max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4; break;\n }\n h /= 6;\n }\n return { h: h * 360, s, l, a };\n },\n\n // Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript\n toHSV() {\n const r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255, a = this.alpha;\n\n const max = Math.max(r, g, b), min = Math.min(r, g, b);\n let h;\n let s;\n const v = max;\n\n const d = max - min;\n if (max === 0) {\n s = 0;\n } else {\n s = d / max;\n }\n\n if (max === min) {\n h = 0;\n } else {\n switch (max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4; break;\n }\n h /= 6;\n }\n return { h: h * 360, s, v, a };\n },\n\n toARGB() {\n return toHex([this.alpha * 255].concat(this.rgb));\n },\n\n compare(x) {\n return (x.rgb &&\n x.rgb[0] === this.rgb[0] &&\n x.rgb[1] === this.rgb[1] &&\n x.rgb[2] === this.rgb[2] &&\n x.alpha === this.alpha) ? 0 : undefined;\n }\n});\n\nColor.fromKeyword = function(keyword) {\n let c;\n const key = keyword.toLowerCase();\n // eslint-disable-next-line no-prototype-builtins\n if (colors.hasOwnProperty(key)) {\n c = new Color(colors[key].slice(1));\n }\n else if (key === 'transparent') {\n c = new Color([0, 0, 0], 0);\n }\n\n if (c) {\n c.value = keyword;\n return c;\n }\n};\n\nfunction clamp(v, max) {\n return Math.min(Math.max(v, 0), max);\n}\n\nfunction toHex(v) {\n return `#${v.map(function (c) {\n c = clamp(Math.round(c), 255);\n return (c < 16 ? '0' : '') + c.toString(16);\n }).join('')}`;\n}\n\nexport default Color;\n"]} |
| {"version":3,"file":"combinator.js","sourceRoot":"","sources":["../../../src/less/tree/combinator.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,IAAM,mBAAmB,GAAG;IACxB,EAAE,EAAE,IAAI;IACR,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;CACZ,CAAC;AAEF,IAAM,UAAU,GAAG,UAAS,KAAK;IAC7B,IAAI,KAAK,KAAK,GAAG,EAAE;QACf,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;QACjB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;KACjC;SAAM;QACH,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC;KAC9C;AACL,CAAC,CAAA;AAED,UAAU,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAC7C,IAAI,EAAE,YAAY;IAElB,MAAM,YAAC,OAAO,EAAE,MAAM;QAClB,IAAM,YAAY,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QACtF,MAAM,CAAC,GAAG,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,CAAC;IACzD,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,UAAU,CAAC","sourcesContent":["import Node from './node';\nconst _noSpaceCombinators = {\n '': true,\n ' ': true,\n '|': true\n};\n\nconst Combinator = function(value) {\n if (value === ' ') {\n this.value = ' ';\n this.emptyOrWhitespace = true;\n } else {\n this.value = value ? value.trim() : '';\n this.emptyOrWhitespace = this.value === '';\n }\n}\n\nCombinator.prototype = Object.assign(new Node(), {\n type: 'Combinator',\n\n genCSS(context, output) {\n const spaceOrEmpty = (context.compress || _noSpaceCombinators[this.value]) ? '' : ' ';\n output.add(spaceOrEmpty + this.value + spaceOrEmpty);\n }\n});\n\nexport default Combinator;\n"]} |
| {"version":3,"file":"comment.js","sourceRoot":"","sources":["../../../src/less/tree/comment.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,oEAAwC;AAExC,IAAM,OAAO,GAAG,UAAS,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,eAAe;IACjE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACnB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACnC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACpB,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC;IACjC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;AAC1B,CAAC,CAAA;AAED,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAC1C,IAAI,EAAE,SAAS;IAEf,MAAM,YAAC,OAAO,EAAE,MAAM;QAClB,IAAI,IAAI,CAAC,SAAS,EAAE;YAChB,MAAM,CAAC,GAAG,CAAC,IAAA,oBAAY,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;SAC7E;QACD,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,QAAQ,YAAC,OAAO;QACZ,IAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;QAC/D,OAAO,IAAI,CAAC,aAAa,IAAI,YAAY,CAAC;IAC9C,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,OAAO,CAAC","sourcesContent":["import Node from './node';\nimport getDebugInfo from './debug-info';\n\nconst Comment = function(value, isLineComment, index, currentFileInfo) {\n this.value = value;\n this.isLineComment = isLineComment;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.allowRoot = true;\n}\n\nComment.prototype = Object.assign(new Node(), {\n type: 'Comment',\n\n genCSS(context, output) {\n if (this.debugInfo) {\n output.add(getDebugInfo(context, this), this.fileInfo(), this.getIndex());\n }\n output.add(this.value);\n },\n\n isSilent(context) {\n const isCompressed = context.compress && this.value[2] !== '!';\n return this.isLineComment || isCompressed;\n }\n});\n\nexport default Comment;\n"]} |
| {"version":3,"file":"condition.js","sourceRoot":"","sources":["../../../src/less/tree/condition.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAE1B,IAAM,SAAS,GAAG,UAAS,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM;IAC1C,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IACpB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAChB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAChB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAChB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACzB,CAAC,CAAC;AAEF,SAAS,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAC5C,IAAI,EAAE,WAAW;IAEjB,MAAM,YAAC,OAAO;QACV,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,YAAC,OAAO;QACR,IAAM,MAAM,GAAG,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC;YAC9B,QAAQ,EAAE,EAAE;gBACR,KAAK,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC1B,KAAK,IAAI,CAAC,CAAE,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC1B;oBACI,QAAQ,cAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;wBACxB,KAAK,CAAC,CAAC;4BACH,OAAO,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,CAAC;wBACpD,KAAK,CAAC;4BACF,OAAO,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,CAAC;wBACnE,KAAK,CAAC;4BACF,OAAO,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,CAAC;wBACrC;4BACI,OAAO,KAAK,CAAC;qBACpB;aACR;QACL,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAElE,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IAC1C,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,SAAS,CAAC","sourcesContent":["import Node from './node';\n\nconst Condition = function(op, l, r, i, negate) {\n this.op = op.trim();\n this.lvalue = l;\n this.rvalue = r;\n this._index = i;\n this.negate = negate;\n};\n\nCondition.prototype = Object.assign(new Node(), {\n type: 'Condition',\n\n accept(visitor) {\n this.lvalue = visitor.visit(this.lvalue);\n this.rvalue = visitor.visit(this.rvalue);\n },\n\n eval(context) {\n const result = (function (op, a, b) {\n switch (op) {\n case 'and': return a && b;\n case 'or': return a || b;\n default:\n switch (Node.compare(a, b)) {\n case -1:\n return op === '<' || op === '=<' || op === '<=';\n case 0:\n return op === '=' || op === '>=' || op === '=<' || op === '<=';\n case 1:\n return op === '>' || op === '>=';\n default:\n return false;\n }\n }\n })(this.op, this.lvalue.eval(context), this.rvalue.eval(context));\n\n return this.negate ? !result : result;\n }\n});\n\nexport default Condition;\n"]} |
| {"version":3,"file":"container.js","sourceRoot":"","sources":["../../../src/less/tree/container.js"],"names":[],"mappings":";;;AAAA,8DAAgC;AAChC,0DAA4B;AAC5B,gEAAkC;AAClC,4DAA8B;AAC9B,4EAAuD;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AAC,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;YAC5D,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC,IACH,CAAC;AAEH,kBAAe,SAAS,CAAC","sourcesContent":["import Ruleset from './ruleset';\nimport Value from './value';\nimport Selector from './selector';\nimport AtRule from './atrule';\nimport NestableAtRulePrototype from './nested-at-rule';\n\nconst Container = function(value, features, index, currentFileInfo, visibilityInfo) {\n this._index = index;\n this._fileInfo = currentFileInfo;\n\n const selectors = (new Selector([], null, null, this._index, this._fileInfo)).createEmptySelectors();\n\n this.features = new Value(features);\n this.rules = [new Ruleset(selectors, value)];\n this.rules[0].allowImports = true;\n this.copyVisibilityInfo(visibilityInfo);\n this.allowRoot = true;\n this.setParent(selectors, this);\n this.setParent(this.features, this);\n this.setParent(this.rules, this);\n};\n\nContainer.prototype = Object.assign(new AtRule(), {\n type: 'Container',\n\n ...NestableAtRulePrototype,\n\n genCSS(context, output) {\n output.add('@container ', this._fileInfo, this._index);\n this.features.genCSS(context, output);\n this.outputRuleset(context, output, this.rules);\n },\n\n eval(context) {\n if (!context.mediaBlocks) {\n context.mediaBlocks = [];\n context.mediaPath = [];\n }\n\n const media = new Container(null, [], this._index, this._fileInfo, this.visibilityInfo());\n if (this.debugInfo) {\n this.rules[0].debugInfo = this.debugInfo;\n media.debugInfo = this.debugInfo;\n }\n \n media.features = this.features.eval(context);\n\n context.mediaPath.push(media);\n context.mediaBlocks.push(media);\n\n this.rules[0].functionRegistry = context.frames[0].functionRegistry.inherit();\n context.frames.unshift(this.rules[0]);\n media.rules = [this.rules[0].eval(context)];\n context.frames.shift();\n\n context.mediaPath.pop();\n\n return context.mediaPath.length === 0 ? media.evalTop(context) :\n media.evalNested(context);\n }\n});\n\nexport default Container;\n"]} |
| {"version":3,"file":"debug-info.js","sourceRoot":"","sources":["../../../src/less/tree/debug-info.js"],"names":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AAe,SAAS,CAAC","sourcesContent":["/**\n * @deprecated The dumpLineNumbers option is deprecated. Use sourcemaps instead.\n * This will be removed in a future version.\n * \n * @param {Object} ctx - Context object with debugInfo\n * @returns {string} Debug info as CSS comment\n */\nfunction asComment(ctx) {\n return `/* line ${ctx.debugInfo.lineNumber}, ${ctx.debugInfo.fileName} */\\n`;\n}\n\n/**\n * @deprecated The dumpLineNumbers option is deprecated. Use sourcemaps instead.\n * This function generates Sass-compatible debug info using @media -sass-debug-info syntax.\n * This format had short-lived usage and is no longer recommended.\n * This will be removed in a future version.\n * \n * @param {Object} ctx - Context object with debugInfo\n * @returns {string} Sass-compatible debug info as @media query\n */\nfunction asMediaQuery(ctx) {\n let filenameWithProtocol = ctx.debugInfo.fileName;\n if (!/^[a-z]+:\\/\\//i.test(filenameWithProtocol)) {\n filenameWithProtocol = `file://${filenameWithProtocol}`;\n }\n return `@media -sass-debug-info{filename{font-family:${filenameWithProtocol.replace(/([.:/\\\\])/g, function (a) {\n if (a == '\\\\') {\n a = '/';\n }\n return `\\\\${a}`;\n })}}line{font-family:\\\\00003${ctx.debugInfo.lineNumber}}}\\n`;\n}\n\n/**\n * Generates debug information (line numbers) for CSS output.\n * \n * @param {Object} context - Context object with dumpLineNumbers option\n * @param {Object} ctx - Context object with debugInfo\n * @param {string} [lineSeparator] - Separator between comment and media query (for 'all' mode)\n * @returns {string} Debug info string\n * \n * @deprecated The dumpLineNumbers option is deprecated. Use sourcemaps instead.\n * All modes ('comments', 'mediaquery', 'all') are deprecated and will be removed in a future version.\n * The 'mediaquery' and 'all' modes generate Sass-compatible @media -sass-debug-info output\n * which had short-lived usage and is no longer recommended.\n */\nfunction debugInfo(context, ctx, lineSeparator) {\n let result = '';\n if (context.dumpLineNumbers && !context.compress) {\n switch (context.dumpLineNumbers) {\n case 'comments':\n result = asComment(ctx);\n break;\n case 'mediaquery':\n result = asMediaQuery(ctx);\n break;\n case 'all':\n result = asComment(ctx) + (lineSeparator || '') + asMediaQuery(ctx);\n break;\n }\n }\n return result;\n}\n\nexport default debugInfo;\n\n"]} |
| {"version":3,"file":"declaration.js","sourceRoot":"","sources":["../../../src/less/tree/declaration.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,0DAA4B;AAC5B,8DAAgC;AAChC,kEAAoC;AACpC,8DAA0C;AAC1C,IAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC;AAE5B,SAAS,QAAQ,CAAC,OAAO,EAAE,IAAI;IAC3B,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,CAAC,CAAC;IACN,IAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IACtB,IAAM,MAAM,GAAG,EAAC,GAAG,EAAE,UAAU,CAAC,IAAG,KAAK,IAAI,CAAC,CAAC,CAAA,CAAC,EAAC,CAAC;IACjD,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QACpB,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;KACjD;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,IAAM,WAAW,GAAG,UAAS,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ;IAChG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,IAAI,CAAC,KAAK,GAAG,CAAC,KAAK,YAAY,cAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,eAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,mBAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAChG,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,WAAI,SAAS,CAAC,IAAI,EAAE,CAAE,CAAC,CAAC,CAAC,EAA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,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;aACpE;YACD,IAAI,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;YAC/B,IAAM,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC;YACrD,IAAI,CAAC,SAAS,IAAI,eAAe,CAAC,SAAS,EAAE;gBACzC,SAAS,GAAG,eAAe,CAAC,SAAS,CAAC;aACzC;YAED,OAAO,IAAI,WAAW,CAAC,IAAI,EACvB,UAAU,EACV,SAAS,EACT,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,MAAM,EAC7C,QAAQ,CAAC,CAAC;SACjB;QACD,OAAO,CAAC,EAAE;YACN,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ,EAAE;gBAC7B,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAC1B,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC;aACzC;YACD,MAAM,CAAC,CAAC;SACX;gBACO;YACJ,IAAI,UAAU,EAAE;gBACZ,OAAO,CAAC,IAAI,GAAG,QAAQ,CAAC;aAC3B;SACJ;IACL,CAAC;IAED,aAAa;QACT,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,EAC5B,IAAI,CAAC,KAAK,EACV,YAAY,EACZ,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,WAAW,CAAC","sourcesContent":["import Node from './node';\nimport Value from './value';\nimport Keyword from './keyword';\nimport Anonymous from './anonymous';\nimport * as Constants from '../constants';\nconst MATH = Constants.Math;\n\nfunction evalName(context, name) {\n let value = '';\n let i;\n const n = name.length;\n const output = {add: function (s) {value += s;}};\n for (i = 0; i < n; i++) {\n name[i].eval(context).genCSS(context, output);\n }\n return value;\n}\n\nconst Declaration = function(name, value, important, merge, index, currentFileInfo, inline, variable) {\n this.name = name;\n this.value = (value instanceof Node) ? value : new Value([value ? new Anonymous(value) : null]);\n this.important = important ? ` ${important.trim()}` : '';\n this.merge = merge;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.inline = inline || false;\n this.variable = (variable !== undefined) ? variable\n : (name.charAt && (name.charAt(0) === '@'));\n this.allowRoot = true;\n this.setParent(this.value, this);\n};\n\nDeclaration.prototype = Object.assign(new Node(), {\n type: 'Declaration',\n\n genCSS(context, output) {\n output.add(this.name + (context.compress ? ':' : ': '), this.fileInfo(), this.getIndex());\n try {\n this.value.genCSS(context, output);\n }\n catch (e) {\n e.index = this._index;\n e.filename = this._fileInfo.filename;\n throw e;\n }\n output.add(this.important + ((this.inline || (context.lastRule && context.compress)) ? '' : ';'), this._fileInfo, this._index);\n },\n\n eval(context) {\n let mathBypass = false, prevMath, name = this.name, evaldValue, variable = this.variable;\n if (typeof name !== 'string') {\n // expand 'primitive' name directly to get\n // things faster (~10% for benchmark.less):\n name = (name.length === 1) && (name[0] instanceof Keyword) ?\n name[0].value : evalName(context, name);\n variable = false; // never treat expanded interpolation as new variable name\n }\n\n // @todo remove when parens-division is default\n if (name === 'font' && context.math === MATH.ALWAYS) {\n mathBypass = true;\n prevMath = context.math;\n context.math = MATH.PARENS_DIVISION;\n }\n try {\n context.importantScope.push({});\n evaldValue = this.value.eval(context);\n\n if (!this.variable && evaldValue.type === 'DetachedRuleset') {\n throw { message: 'Rulesets cannot be evaluated on a property.',\n index: this.getIndex(), filename: this.fileInfo().filename };\n }\n let important = this.important;\n const importantResult = context.importantScope.pop();\n if (!important && importantResult.important) {\n important = importantResult.important;\n }\n\n return new Declaration(name,\n evaldValue,\n important,\n this.merge,\n this.getIndex(), this.fileInfo(), this.inline,\n variable);\n }\n catch (e) {\n if (typeof e.index !== 'number') {\n e.index = this.getIndex();\n e.filename = this.fileInfo().filename;\n }\n throw e;\n }\n finally {\n if (mathBypass) {\n context.math = prevMath;\n }\n }\n },\n\n makeImportant() {\n return new Declaration(this.name,\n this.value,\n '!important',\n this.merge,\n this.getIndex(), this.fileInfo(), this.inline);\n }\n});\n\nexport default Declaration;"]} |
| {"version":3,"file":"detached-ruleset.js","sourceRoot":"","sources":["../../../src/less/tree/detached-ruleset.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,iEAAmC;AACnC,sDAAkC;AAElC,IAAM,eAAe,GAAG,UAAS,OAAO,EAAE,MAAM;IAC5C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF,eAAe,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAClD,IAAI,EAAE,iBAAiB;IACvB,SAAS,EAAE,IAAI;IAEf,MAAM,YAAC,OAAO;QACV,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,YAAC,OAAO;QACR,IAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9D,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;IAED,QAAQ,YAAC,OAAO;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,kBAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACrH,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,eAAe,CAAC","sourcesContent":["import Node from './node';\nimport contexts from '../contexts';\nimport * as utils from '../utils';\n\nconst DetachedRuleset = function(ruleset, frames) {\n this.ruleset = ruleset;\n this.frames = frames;\n this.setParent(this.ruleset, this);\n};\n\nDetachedRuleset.prototype = Object.assign(new Node(), {\n type: 'DetachedRuleset',\n evalFirst: true,\n\n accept(visitor) {\n this.ruleset = visitor.visit(this.ruleset);\n },\n\n eval(context) {\n const frames = this.frames || utils.copyArray(context.frames);\n return new DetachedRuleset(this.ruleset, frames);\n },\n\n callEval(context) {\n return this.ruleset.eval(this.frames ? new contexts.Eval(context, this.frames.concat(context.frames)) : context);\n }\n});\n\nexport default DetachedRuleset;\n"]} |
| {"version":3,"file":"dimension.js","sourceRoot":"","sources":["../../../src/less/tree/dimension.js"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,wDAA0B;AAC1B,sFAAuD;AACvD,wDAA0B;AAC1B,0DAA4B;AAE5B,EAAE;AACF,uBAAuB;AACvB,EAAE;AACF,IAAM,SAAS,GAAG,UAAS,KAAK,EAAE,IAAI;IAClC,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAC/B,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;KACjD;IACD,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,IAAI,IAAI,YAAY,cAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,cAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACxC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,I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,kBAAkB,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;iBACvC;aACJ;YACD,WAAW,GAAG,kBAAkB,CAAC;SACpC;QACD,SAAS,GAAG,UAAU,UAAU,EAAE,WAAW;YACzC,IAAI,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE;gBAClC,IAAI,WAAW,EAAE;oBACb,KAAK,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;iBAC3D;qBAAM;oBACH,KAAK,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;iBAC3D;gBAED,OAAO,UAAU,CAAC;aACrB;YAED,OAAO,UAAU,CAAC;QACtB,CAAC,CAAC;QAEF,KAAK,SAAS,IAAI,WAAW,EAAE;YAC3B,IAAI,WAAW,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;gBACvC,UAAU,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;gBACpC,KAAK,GAAG,0BAAe,CAAC,SAAS,CAAC,CAAC;gBAEnC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;aACvB;SACJ;QAED,IAAI,CAAC,MAAM,EAAE,CAAC;QAEd,OAAO,IAAI,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,SAAS,CAAC","sourcesContent":["/* eslint-disable no-prototype-builtins */\nimport Node from './node';\nimport unitConversions from '../data/unit-conversions';\nimport Unit from './unit';\nimport Color from './color';\n\n//\n// A number with a unit\n//\nconst Dimension = function(value, unit) {\n this.value = parseFloat(value);\n if (isNaN(this.value)) {\n throw new Error('Dimension is not a number.');\n }\n this.unit = (unit && unit instanceof Unit) ? unit :\n new Unit(unit ? [unit] : undefined);\n this.setParent(this.unit, this);\n};\n\nDimension.prototype = Object.assign(new Node(), {\n type: 'Dimension',\n\n accept(visitor) {\n this.unit = visitor.visit(this.unit);\n },\n\n // remove when Nodes have JSDoc types\n // eslint-disable-next-line no-unused-vars\n eval(context) {\n return this;\n },\n\n toColor() {\n return new Color([this.value, this.value, this.value]);\n },\n\n genCSS(context, output) {\n if ((context && context.strictUnits) && !this.unit.isSingular()) {\n throw new Error(`Multiple units in dimension. Correct the units or use the unit function. Bad unit: ${this.unit.toString()}`);\n }\n\n const value = this.fround(context, this.value);\n let strValue = String(value);\n\n if (value !== 0 && value < 0.000001 && value > -0.000001) {\n // would be output 1e-6 etc.\n strValue = value.toFixed(20).replace(/0+$/, '');\n }\n\n if (context && context.compress) {\n // Zero values doesn't need a unit\n if (value === 0 && this.unit.isLength()) {\n output.add(strValue);\n return;\n }\n\n // Float values doesn't need a leading zero\n if (value > 0 && value < 1) {\n strValue = (strValue).substr(1);\n }\n }\n\n output.add(strValue);\n this.unit.genCSS(context, output);\n },\n\n // In an operation between two Dimensions,\n // we default to the first Dimension's unit,\n // so `1px + 2` will yield `3px`.\n operate(context, op, other) {\n /* jshint noempty:false */\n let value = this._operate(context, op, this.value, other.value);\n let unit = this.unit.clone();\n\n if (op === '+' || op === '-') {\n if (unit.numerator.length === 0 && unit.denominator.length === 0) {\n unit = other.unit.clone();\n if (this.unit.backupUnit) {\n unit.backupUnit = this.unit.backupUnit;\n }\n } else if (other.unit.numerator.length === 0 && unit.denominator.length === 0) {\n // do nothing\n } else {\n other = other.convertTo(this.unit.usedUnits());\n\n if (context.strictUnits && other.unit.toString() !== unit.toString()) {\n throw new Error('Incompatible units. Change the units or use the unit function. '\n + `Bad units: '${unit.toString()}' and '${other.unit.toString()}'.`);\n }\n\n value = this._operate(context, op, this.value, other.value);\n }\n } else if (op === '*') {\n unit.numerator = unit.numerator.concat(other.unit.numerator).sort();\n unit.denominator = unit.denominator.concat(other.unit.denominator).sort();\n unit.cancel();\n } else if (op === '/') {\n unit.numerator = unit.numerator.concat(other.unit.denominator).sort();\n unit.denominator = unit.denominator.concat(other.unit.numerator).sort();\n unit.cancel();\n }\n return new Dimension(value, unit);\n },\n\n compare(other) {\n let a, b;\n\n if (!(other instanceof Dimension)) {\n return undefined;\n }\n\n if (this.unit.isEmpty() || other.unit.isEmpty()) {\n a = this;\n b = other;\n } else {\n a = this.unify();\n b = other.unify();\n if (a.unit.compare(b.unit) !== 0) {\n return undefined;\n }\n }\n\n return Node.numericCompare(a.value, b.value);\n },\n\n unify() {\n return this.convertTo({ length: 'px', duration: 's', angle: 'rad' });\n },\n\n convertTo(conversions) {\n let value = this.value;\n const unit = this.unit.clone();\n let i;\n let groupName;\n let group;\n let targetUnit;\n let derivedConversions = {};\n let applyUnit;\n\n if (typeof conversions === 'string') {\n for (i in unitConversions) {\n if (unitConversions[i].hasOwnProperty(conversions)) {\n derivedConversions = {};\n derivedConversions[i] = conversions;\n }\n }\n conversions = derivedConversions;\n }\n applyUnit = function (atomicUnit, denominator) {\n if (group.hasOwnProperty(atomicUnit)) {\n if (denominator) {\n value = value / (group[atomicUnit] / group[targetUnit]);\n } else {\n value = value * (group[atomicUnit] / group[targetUnit]);\n }\n\n return targetUnit;\n }\n\n return atomicUnit;\n };\n\n for (groupName in conversions) {\n if (conversions.hasOwnProperty(groupName)) {\n targetUnit = conversions[groupName];\n group = unitConversions[groupName];\n\n unit.map(applyUnit);\n }\n }\n\n unit.cancel();\n\n return new Dimension(value, unit);\n }\n});\n\nexport default Dimension;\n"]} |
| {"version":3,"file":"element.js","sourceRoot":"","sources":["../../../src/less/tree/element.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,0DAA4B;AAC5B,oEAAsC;AAEtC,IAAM,OAAO,GAAG,UAAS,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,cAAc;IAC1F,IAAI,CAAC,UAAU,GAAG,UAAU,YAAY,oBAAU,CAAC,CAAC;QAChD,UAAU,CAAC,CAAC,CAAC,IAAI,oBAAU,CAAC,UAAU,CAAC,CAAC;IA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ChD,CAAC;IAED,KAAK;QACD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,UAAU,EAC9B,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,QAAQ,EAAE,EACf,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,YAAC,OAAO,EAAE,MAAM;QAClB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,KAAK,YAAC,OAAO;QACT,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QACxB,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACvB,IAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC5C,IAAI,KAAK,YAAY,eAAK,EAAE;YACxB,8DAA8D;YAC9D,yDAAyD;YACzD,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;SAChC;QACD,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACnD,OAAO,CAAC,aAAa,GAAG,aAAa,CAAC;QACtC,IAAI,KAAK,KAAK,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;YACzD,OAAO,EAAE,CAAC;SACb;aAAM;YACH,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;SACjD;IACL,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,OAAO,CAAC","sourcesContent":["import Node from './node';\nimport Paren from './paren';\nimport Combinator from './combinator';\n\nconst Element = function(combinator, value, isVariable, index, currentFileInfo, visibilityInfo) {\n this.combinator = combinator instanceof Combinator ?\n combinator : new Combinator(combinator);\n\n if (typeof value === 'string') {\n this.value = value.trim();\n } else if (value) {\n this.value = value;\n } else {\n this.value = '';\n }\n this.isVariable = isVariable;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.copyVisibilityInfo(visibilityInfo);\n this.setParent(this.combinator, this);\n}\n\nElement.prototype = Object.assign(new Node(), {\n type: 'Element',\n\n accept(visitor) {\n const value = this.value;\n this.combinator = visitor.visit(this.combinator);\n if (typeof value === 'object') {\n this.value = visitor.visit(value);\n }\n },\n\n eval(context) {\n return new Element(this.combinator,\n this.value.eval ? this.value.eval(context) : this.value,\n this.isVariable,\n this.getIndex(),\n this.fileInfo(), this.visibilityInfo());\n },\n\n clone() {\n return new Element(this.combinator,\n this.value,\n this.isVariable,\n this.getIndex(),\n this.fileInfo(), this.visibilityInfo());\n },\n\n genCSS(context, output) {\n output.add(this.toCSS(context), this.fileInfo(), this.getIndex());\n },\n\n toCSS(context) {\n context = context || {};\n let value = this.value;\n const firstSelector = context.firstSelector;\n if (value instanceof Paren) {\n // selector in parens should not be affected by outer selector\n // flags (breaks only interpolated selectors - see #1973)\n context.firstSelector = true;\n }\n value = value.toCSS ? value.toCSS(context) : value;\n context.firstSelector = firstSelector;\n if (value === '' && this.combinator.value.charAt(0) === '&') {\n return '';\n } else {\n return this.combinator.toCSS(context) + value;\n }\n }\n});\n\nexport default Element;\n"]} |
| {"version":3,"file":"expression.js","sourceRoot":"","sources":["../../../src/less/tree/expression.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,0DAA4B;AAC5B,8DAAgC;AAChC,kEAAoC;AACpC,kEAAoC;AAEpC,IAAM,UAAU,GAAG,UAAS,KAAK,EAAE,SAAS;IACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC3B,IAAI,CAAC,KAAK,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,wC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,CAAC,UAAS,CAAC;YACrC,OAAO,CAAC,CAAC,CAAC,YAAY,iBAAO,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,UAAU,CAAC","sourcesContent":["import Node from './node';\nimport Paren from './paren';\nimport Comment from './comment';\nimport Dimension from './dimension';\nimport Anonymous from './anonymous';\n\nconst Expression = function(value, noSpacing) {\n this.value = value;\n this.noSpacing = noSpacing;\n if (!value) {\n throw new Error('Expression requires an array parameter');\n }\n};\n\nExpression.prototype = Object.assign(new Node(), {\n type: 'Expression',\n\n accept(visitor) {\n this.value = visitor.visitArray(this.value);\n },\n\n eval(context) {\n const noSpacing = this.noSpacing;\n let returnValue;\n const mathOn = context.isMathOn();\n const inParenthesis = this.parens;\n\n let doubleParen = false;\n if (inParenthesis) {\n context.inParenthesis();\n }\n if (this.value.length > 1) {\n returnValue = new Expression(this.value.map(function (e) {\n if (!e.eval) {\n return e;\n }\n return e.eval(context);\n }), this.noSpacing);\n } else if (this.value.length === 1) {\n if (this.value[0].parens && !this.value[0].parensInOp && !context.inCalc) {\n doubleParen = true;\n }\n returnValue = this.value[0].eval(context);\n } else {\n returnValue = this;\n }\n if (inParenthesis) {\n context.outOfParenthesis();\n }\n if (this.parens && this.parensInOp && !mathOn && !doubleParen\n && (!(returnValue instanceof Dimension))) {\n returnValue = new Paren(returnValue);\n }\n returnValue.noSpacing = returnValue.noSpacing || noSpacing;\n return returnValue;\n },\n\n genCSS(context, output) {\n for (let i = 0; i < this.value.length; i++) {\n this.value[i].genCSS(context, output);\n if (!this.noSpacing && i + 1 < this.value.length) {\n if (i + 1 < this.value.length && !(this.value[i + 1] instanceof Anonymous) ||\n this.value[i + 1] instanceof Anonymous && this.value[i + 1].value !== ',') {\n output.add(' ');\n }\n }\n }\n },\n\n throwAwayComments() {\n this.value = this.value.filter(function(v) {\n return !(v instanceof Comment);\n });\n }\n});\n\nexport default Expression;\n"]} |
| {"version":3,"file":"extend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G,CAAC,CAAC;AACnB,kBAAe,MAAM,CAAC","sourcesContent":["import Node from './node';\nimport Selector from './selector';\n\nconst Extend = function(selector, option, index, currentFileInfo, visibilityInfo) {\n this.selector = selector;\n this.option = option;\n this.object_id = Extend.next_id++;\n this.parent_ids = [this.object_id];\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.copyVisibilityInfo(visibilityInfo);\n this.allowRoot = true;\n\n switch (option) {\n case '!all':\n case 'all':\n this.allowBefore = true;\n this.allowAfter = true;\n break;\n default:\n this.allowBefore = false;\n this.allowAfter = false;\n break;\n }\n this.setParent(this.selector, this);\n};\n\nExtend.prototype = Object.assign(new Node(), {\n type: 'Extend',\n\n accept(visitor) {\n this.selector = visitor.visit(this.selector);\n },\n\n eval(context) {\n return new Extend(this.selector.eval(context), this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo());\n },\n\n // remove when Nodes have JSDoc types\n // eslint-disable-next-line no-unused-vars\n clone(context) {\n return new Extend(this.selector, this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo());\n },\n\n // it concatenates (joins) all selectors in selector array\n findSelfSelectors(selectors) {\n let selfElements = [], i, selectorElements;\n\n for (i = 0; i < selectors.length; i++) {\n selectorElements = selectors[i].elements;\n // duplicate the logic in genCSS function inside the selector node.\n // future TODO - move both logics into the selector joiner visitor\n if (i > 0 && selectorElements.length && selectorElements[0].combinator.value === '') {\n selectorElements[0].combinator.value = ' ';\n }\n selfElements = selfElements.concat(selectors[i].elements);\n }\n\n this.selfSelectors = [new Selector(selfElements)];\n this.selfSelectors[0].copyVisibilityInfo(this.visibilityInfo());\n }\n});\n\nExtend.next_id = 0;\nexport default Extend;\n"]} |
| {"version":3,"file":"import.js","sourceRoot":"","sources":["../../../src/less/tree/import.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,0DAA4B;AAC5B,sDAAwB;AACxB,4DAA8B;AAC9B,8DAAgC;AAChC,kEAAoC;AACpC,sDAAkC;AAClC,qEAAsC;AACtC,oEAA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AAY,CAAC,IAAI,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE;wBACzD,IAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,OAAO;+BAChF,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC;wBACxC,IAAI,OAAO,EAAE;4BACT,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;4BAChB,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,oBAAU,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;4BAC3D,YAAY,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;4BAC1B,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC;4BACjC,OAAO,IAAI,CAAC;yBACf;qBACJ;iBACJ;aACJ;YACD,OAAO,EAAE,CAAC;SACb;IACL,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,MAAM,CAAC","sourcesContent":["import Node from './node';\nimport Media from './media';\nimport URL from './url';\nimport Quoted from './quoted';\nimport Ruleset from './ruleset';\nimport Anonymous from './anonymous';\nimport * as utils from '../utils';\nimport LessError from '../less-error';\nimport Expression from './expression';\n\n//\n// CSS @import node\n//\n// The general strategy here is that we don't want to wait\n// for the parsing to be completed, before we start importing\n// the file. That's because in the context of a browser,\n// most of the time will be spent waiting for the server to respond.\n//\n// On creation, we push the import path to our import queue, though\n// `import,push`, we also pass it a callback, which it'll call once\n// the file has been fetched, and parsed.\n//\nconst Import = function(path, features, options, index, currentFileInfo, visibilityInfo) {\n this.options = options;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.path = path;\n this.features = features;\n this.allowRoot = true;\n\n if (this.options.less !== undefined || this.options.inline) {\n this.css = !this.options.less || this.options.inline;\n } else {\n const pathValue = this.getPath();\n if (pathValue && /[#.&?]css([?;].*)?$/.test(pathValue)) {\n this.css = true;\n }\n }\n this.copyVisibilityInfo(visibilityInfo);\n this.setParent(this.features, this);\n this.setParent(this.path, this);\n};\n\nImport.prototype = Object.assign(new Node(), {\n type: 'Import',\n\n accept(visitor) {\n if (this.features) {\n this.features = visitor.visit(this.features);\n }\n this.path = visitor.visit(this.path);\n if (!this.options.isPlugin && !this.options.inline && this.root) {\n this.root = visitor.visit(this.root);\n }\n },\n\n genCSS(context, output) {\n if (this.css && this.path._fileInfo.reference === undefined) {\n output.add('@import ', this._fileInfo, this._index);\n this.path.genCSS(context, output);\n if (this.features) {\n output.add(' ');\n this.features.genCSS(context, output);\n }\n output.add(';');\n }\n },\n\n getPath() {\n return (this.path instanceof URL) ?\n this.path.value.value : this.path.value;\n },\n\n isVariableImport() {\n let path = this.path;\n if (path instanceof URL) {\n path = path.value;\n }\n if (path instanceof Quoted) {\n return path.containsVariables();\n }\n\n return true;\n },\n\n evalForImport(context) {\n let path = this.path;\n\n if (path instanceof URL) {\n path = path.value;\n }\n\n return new Import(path.eval(context), this.features, this.options, this._index, this._fileInfo, this.visibilityInfo());\n },\n\n evalPath(context) {\n const path = this.path.eval(context);\n const fileInfo = this._fileInfo;\n\n if (!(path instanceof URL)) {\n // Add the rootpath if the URL requires a rewrite\n const pathValue = path.value;\n if (fileInfo &&\n pathValue &&\n context.pathRequiresRewrite(pathValue)) {\n path.value = context.rewritePath(pathValue, fileInfo.rootpath);\n } else {\n path.value = context.normalizePath(path.value);\n }\n }\n\n return path;\n },\n\n eval(context) {\n const result = this.doEval(context);\n if (this.options.reference || this.blocksVisibility()) {\n if (result.length || result.length === 0) {\n result.forEach(function (node) {\n node.addVisibilityBlock();\n }\n );\n } else {\n result.addVisibilityBlock();\n }\n }\n return result;\n },\n\n doEval(context) {\n let ruleset;\n let registry;\n const features = this.features && this.features.eval(context);\n\n if (this.options.isPlugin) {\n if (this.root && this.root.eval) {\n try {\n this.root.eval(context);\n }\n catch (e) {\n e.message = 'Plugin error during evaluation';\n throw new LessError(e, this.root.imports, this.root.filename);\n }\n }\n registry = context.frames[0] && context.frames[0].functionRegistry;\n if ( registry && this.root && this.root.functions ) {\n registry.addMultiple( this.root.functions );\n }\n\n return [];\n }\n\n if (this.skip) {\n if (typeof this.skip === 'function') {\n this.skip = this.skip();\n }\n if (this.skip) {\n return [];\n }\n }\n if (this.features) {\n let featureValue = this.features.value;\n if (Array.isArray(featureValue) && featureValue.length >= 1) {\n const expr = featureValue[0];\n if (expr.type === 'Expression' && Array.isArray(expr.value) && expr.value.length >= 2) {\n featureValue = expr.value;\n const isLayer = featureValue[0].type === 'Keyword' && featureValue[0].value === 'layer'\n && featureValue[1].type === 'Paren';\n if (isLayer) {\n this.css = false;\n }\n }\n }\n }\n if (this.options.inline) {\n const contents = new Anonymous(this.root, 0,\n {\n filename: this.importedFilename,\n reference: this.path._fileInfo && this.path._fileInfo.reference\n }, true, true);\n\n return this.features ? new Media([contents], this.features.value) : [contents];\n } else if (this.css || this.layerCss) {\n const newImport = new Import(this.evalPath(context), features, this.options, this._index);\n if (this.layerCss) {\n newImport.css = this.layerCss;\n newImport.path._fileInfo = this._fileInfo;\n }\n if (!newImport.css && this.error) {\n throw this.error;\n }\n return newImport;\n } else if (this.root) {\n if (this.features) {\n let featureValue = this.features.value;\n if (Array.isArray(featureValue) && featureValue.length === 1) {\n const expr = featureValue[0];\n if (expr.type === 'Expression' && Array.isArray(expr.value) && expr.value.length >= 2) {\n featureValue = expr.value;\n const isLayer = featureValue[0].type === 'Keyword' && featureValue[0].value === 'layer'\n && featureValue[1].type === 'Paren';\n if (isLayer) {\n this.layerCss = true;\n featureValue[0] = new Expression(featureValue.slice(0, 2));\n featureValue.splice(1, 1);\n featureValue[0].noSpacing = true;\n return this;\n }\n }\n }\n }\n ruleset = new Ruleset(null, utils.copyArray(this.root.rules));\n ruleset.evalImports(context);\n\n return this.features ? new Media(ruleset.rules, this.features.value) : ruleset.rules;\n } else {\n if (this.features) {\n let featureValue = this.features.value;\n if (Array.isArray(featureValue) && featureValue.length >= 1) {\n featureValue = featureValue[0].value;\n if (Array.isArray(featureValue) && featureValue.length >= 2) {\n const isLayer = featureValue[0].type === 'Keyword' && featureValue[0].value === 'layer'\n && featureValue[1].type === 'Paren';\n if (isLayer) {\n this.css = true;\n featureValue[0] = new Expression(featureValue.slice(0, 2));\n featureValue.splice(1, 1);\n featureValue[0].noSpacing = true;\n return this;\n }\n }\n }\n }\n return [];\n }\n }\n});\n\nexport default Import;\n"]} |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/less/tree/index.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,0DAA4B;AAC5B,4DAA8B;AAC9B,gFAAiD;AACjD,kEAAoC;AACpC,kEAAoC;AACpC,wDAA0B;AAC1B,8DAAgC;AAChC,gEAAkC;AAClC,gEAAkC;AAClC,8DAAgC;AAChC,8DAAgC;AAChC,kEAAoC;AACpC,oEAAsC;AACtC,gEAAkC;AAClC,4DAA8B;AAC9B,oEAAsC;AACtC,sEAAwC;AACxC,wDAA0B;AAC1B,sDAAwB;AACxB,4DAA8B;AAC9B,8DAAgC;AAChC,kEAAoC;AACpC,0DAA4B;AAC5B,oEAAsC;AACtC,oEAAsC;AACtC,kEAAoC;AACpC,8EAA8C;AAC9C,0DAA4B;AAC5B,0DAA4B;AAC5B,kEAAoC;AACpC,oFAAqD;AACrD,gEAAkC;AAClC,4DAA8B;AAC9B,0EAA2C;AAC3C,8EAA+C;AAE/C,SAAS;AACT,oEAAqC;AACrC,gFAAiD;AAEjD,kBAAe;IACX,IAAI,gBAAA;IAAE,KAAK,iBAAA;IAAE,MAAM,kBAAA;IAAE,eAAe,4BAAA;IAAE,SAAS,qBAAA;IAC/C,SAAS,qBAAA;IAAE,IAAI,gBAAA;IAAE,OAAO,mBAAA;IAAE,QAAQ,oBAAA;IAAE,QAAQ,oBAAA;IAC5C,OAAO,mBAAA;IAAE,OAAO,mBAAA;IAAE,SAAS,qBAAA;IAAE,UAAU,sBAAA;IAAE,QAAQ,oBAAA;IACjD,MAAM,kBAAA;IAAE,UAAU,sBAAA;IAAE,WAAW,uBAAA;IAAE,IAAI,gBAAA;IAAE,GAAG,eAAA;IAAE,MAAM,kBAAA;IAClD,OAAO,mBAAA;IAAE,SAAS,qBAAA;IAAE,KAAK,iBAAA;IAAE,UAAU,sBAAA;IAAE,UAAU,sBAAA;IACjD,SAAS,qBAAA;IAAE,KAAK,iBAAA;IAAE,KAAK,iBAAA;IAAE,SAAS,qBAAA;IAAE,aAAa,2BAAA;IACjD,iBAAiB,8BAAA;IAAE,QAAQ,oBAAA;IAAE,MAAM,kBAAA;IAAE,YAAY,yBAAA;IACjD,cAAc,2BAAA;IACd,KAAK,EAAE;QACH,IAAI,EAAE,oBAAS;QACf,UAAU,EAAE,0BAAe;KAC9B;CACJ,CAAC","sourcesContent":["import Node from './node';\nimport Color from './color';\nimport AtRule from './atrule';\nimport DetachedRuleset from './detached-ruleset';\nimport Operation from './operation';\nimport Dimension from './dimension';\nimport Unit from './unit';\nimport Keyword from './keyword';\nimport Variable from './variable';\nimport Property from './property';\nimport Ruleset from './ruleset';\nimport Element from './element';\nimport Attribute from './attribute';\nimport Combinator from './combinator';\nimport Selector from './selector';\nimport Quoted from './quoted';\nimport Expression from './expression';\nimport Declaration from './declaration';\nimport Call from './call';\nimport URL from './url';\nimport Import from './import';\nimport Comment from './comment';\nimport Anonymous from './anonymous';\nimport Value from './value';\nimport JavaScript from './javascript';\nimport Assignment from './assignment';\nimport Condition from './condition';\nimport QueryInParens from './query-in-parens';\nimport Paren from './paren';\nimport Media from './media';\nimport Container from './container';\nimport UnicodeDescriptor from './unicode-descriptor';\nimport Negative from './negative';\nimport Extend from './extend';\nimport VariableCall from './variable-call';\nimport NamespaceValue from './namespace-value';\n\n// mixins\nimport MixinCall from './mixin-call';\nimport MixinDefinition from './mixin-definition';\n\nexport default {\n Node, Color, AtRule, DetachedRuleset, Operation,\n Dimension, Unit, Keyword, Variable, Property,\n Ruleset, Element, Attribute, Combinator, Selector,\n Quoted, Expression, Declaration, Call, URL, Import,\n Comment, Anonymous, Value, JavaScript, Assignment,\n Condition, Paren, Media, Container, QueryInParens, \n UnicodeDescriptor, Negative, Extend, VariableCall, \n NamespaceValue,\n mixin: {\n Call: MixinCall,\n Definition: MixinDefinition\n }\n};"]} |
| {"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../../src/less/tree/javascript.js"],"names":[],"mappings":";;;AAAA,wEAAwC;AACxC,kEAAoC;AACpC,4DAA8B;AAC9B,kEAAoC;AAEpC,IAAM,UAAU,GAAG,UAAS,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe;IAC/D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACvB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;IACzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACpB,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC;AACrC,CAAC,CAAA;AAED,UAAU,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,sBAAU,EAAE,EAAE;IACnD,IAAI,EAAE,YAAY;IAElB,IAAI,YAAC,OAAO;QACR,IAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACjE,IAAM,IAAI,GAAG,OAAO,MAAM,CAAC;QAE3B,IAAI,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;YACrC,OAAO,IAAI,mBAAS,CAAC,MAAM,CAAC,CAAC;SAChC;aAAM,IAAI,IAAI,KAAK,QAAQ,EAAE;YAC1B,OAAO,IAAI,gBAAM,CAAC,YAAI,MAAM,OAAG,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;SACvE;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YAC9B,OAAO,IAAI,mBAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3C;aAAM;YACH,OAAO,IAAI,mBAAS,CAAC,MAAM,CAAC,CAAC;SAChC;IACL,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,UAAU,CAAC","sourcesContent":["import JsEvalNode from './js-eval-node';\nimport Dimension from './dimension';\nimport Quoted from './quoted';\nimport Anonymous from './anonymous';\n\nconst JavaScript = function(string, escaped, index, currentFileInfo) {\n this.escaped = escaped;\n this.expression = string;\n this._index = index;\n this._fileInfo = currentFileInfo;\n}\n\nJavaScript.prototype = Object.assign(new JsEvalNode(), {\n type: 'JavaScript',\n\n eval(context) {\n const result = this.evaluateJavaScript(this.expression, context);\n const type = typeof result;\n\n if (type === 'number' && !isNaN(result)) {\n return new Dimension(result);\n } else if (type === 'string') {\n return new Quoted(`\"${result}\"`, result, this.escaped, this._index);\n } else if (Array.isArray(result)) {\n return new Anonymous(result.join(', '));\n } else {\n return new Anonymous(result);\n }\n }\n});\n\nexport default JavaScript;\n"]} |
| {"version":3,"file":"js-eval-node.js","sourceRoot":"","sources":["../../../src/less/tree/js-eval-node.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,gEAAkC;AAElC,IAAM,UAAU,GAAG,cAAY,CAAC,CAAC;AAEjC,UAAU,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAC7C,kBAAkB,YAAC,UAAU,EAAE,OAAO;QAClC,IAAI,MAAM,CAAC;QACX,IAAM,IAAI,GAAG,IAAI,CAAC;QAClB,IAAM,WAAW,GAAG,EAAE,CAAC;QAEvB,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE;YAC5B,MAAM,EAAE,OAAO,EAAE,8DAA8D;gBAC3E,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ;gBAClC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;SAChC;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AO,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAG;gBAC3F,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ;gBAClC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;SAChC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,KAAK,YAAC,GAAG;QACL,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;YACpD,OAAO,WAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAG,CAAC;SAC9E;aAAM;YACH,OAAO,GAAG,CAAC,KAAK,EAAE,CAAC;SACtB;IACL,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,UAAU,CAAC","sourcesContent":["import Node from './node';\nimport Variable from './variable';\n\nconst JsEvalNode = function() {};\n\nJsEvalNode.prototype = Object.assign(new Node(), {\n evaluateJavaScript(expression, context) {\n let result;\n const that = this;\n const evalContext = {};\n\n if (!context.javascriptEnabled) {\n throw { message: 'Inline JavaScript is not enabled. Is it set in your options?',\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n\n expression = expression.replace(/@\\{([\\w-]+)\\}/g, function (_, name) {\n return that.jsify(new Variable(`@${name}`, that.getIndex(), that.fileInfo()).eval(context));\n });\n\n try {\n expression = new Function(`return (${expression})`);\n } catch (e) {\n throw { message: `JavaScript evaluation error: ${e.message} from \\`${expression}\\`` ,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n\n const variables = context.frames[0].variables();\n for (const k in variables) {\n // eslint-disable-next-line no-prototype-builtins\n if (variables.hasOwnProperty(k)) {\n evalContext[k.slice(1)] = {\n value: variables[k].value,\n toJS: function () {\n return this.value.eval(context).toCSS();\n }\n };\n }\n }\n\n try {\n result = expression.call(evalContext);\n } catch (e) {\n throw { message: `JavaScript evaluation error: '${e.name}: ${e.message.replace(/[\"]/g, '\\'')}'` ,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n return result;\n },\n\n jsify(obj) {\n if (Array.isArray(obj.value) && (obj.value.length > 1)) {\n return `[${obj.value.map(function (v) { return v.toCSS(); }).join(', ')}]`;\n } else {\n return obj.toCSS();\n }\n }\n});\n\nexport default JsEvalNode;\n"]} |
| {"version":3,"file":"keyword.js","sourceRoot":"","sources":["../../../src/less/tree/keyword.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAE1B,IAAM,OAAO,GAAG,UAAS,KAAK;IAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AACvB,CAAC,CAAC;AAEF,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAC1C,IAAI,EAAE,SAAS;IAEf,MAAM,YAAC,OAAO,EAAE,MAAM;QAClB,IAAI,IAAI,CAAC,KAAK,KAAK,GAAG,EAAE;YAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,0BAA0B,EAAE,CAAC;SAAE;QAC1F,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;CACJ,CAAC,CAAC;AAEH,OAAO,CAAC,IAAI,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;AACnC,OAAO,CAAC,KAAK,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;AAErC,kBAAe,OAAO,CAAC","sourcesContent":["import Node from './node';\n\nconst Keyword = function(value) {\n this.value = value;\n};\n\nKeyword.prototype = Object.assign(new Node(), {\n type: 'Keyword',\n\n genCSS(context, output) {\n if (this.value === '%') { throw { type: 'Syntax', message: 'Invalid % without number' }; }\n output.add(this.value);\n }\n});\n\nKeyword.True = new Keyword('true');\nKeyword.False = new Keyword('false');\n\nexport default Keyword;\n"]} |
| {"version":3,"file":"media.js","sourceRoot":"","sources":["../../../src/less/tree/media.js"],"names":[],"mappings":";;;AAAA,8DAAgC;AAChC,0DAA4B;AAC5B,gEAAkC;AAClC,4DAA8B;AAC9B,4EAAuD;AAEvD,IAAM,KAAK,GAAG,UAAS,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,eAAe,EAAE,cAAc;IAC1E,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACpB,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC;IAEjC,IAAM,SAAS,GAAG,CAAC,IAAI,kBAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,oBAAoB,EAAE,CAAC;IAErG,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAK,CAAC,QAAQ,CAAC,CAAC;IACpC,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,iBAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAC7C,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC;IAClC,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;IACxC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAChC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACpC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,gBAAM,EAAE,sCACxC,IAAI,EAAE,OAAO,IAEV,wBAAuB,KAE1B,MAAM,YAAC,OAAO,EAAE,MAAM;Q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AC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAC5C,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAEvB,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;QAExB,OAAO,OAAO,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;YAC5D,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC,IACH,CAAC;AAEH,kBAAe,KAAK,CAAC","sourcesContent":["import Ruleset from './ruleset';\nimport Value from './value';\nimport Selector from './selector';\nimport AtRule from './atrule';\nimport NestableAtRulePrototype from './nested-at-rule';\n\nconst Media = function(value, features, index, currentFileInfo, visibilityInfo) {\n this._index = index;\n this._fileInfo = currentFileInfo;\n\n const selectors = (new Selector([], null, null, this._index, this._fileInfo)).createEmptySelectors();\n\n this.features = new Value(features);\n this.rules = [new Ruleset(selectors, value)];\n this.rules[0].allowImports = true;\n this.copyVisibilityInfo(visibilityInfo);\n this.allowRoot = true;\n this.setParent(selectors, this);\n this.setParent(this.features, this);\n this.setParent(this.rules, this);\n};\n\nMedia.prototype = Object.assign(new AtRule(), {\n type: 'Media',\n\n ...NestableAtRulePrototype,\n\n genCSS(context, output) {\n output.add('@media ', this._fileInfo, this._index);\n this.features.genCSS(context, output);\n this.outputRuleset(context, output, this.rules);\n },\n\n eval(context) {\n if (!context.mediaBlocks) {\n context.mediaBlocks = [];\n context.mediaPath = [];\n }\n\n const media = new Media(null, [], this._index, this._fileInfo, this.visibilityInfo());\n if (this.debugInfo) {\n this.rules[0].debugInfo = this.debugInfo;\n media.debugInfo = this.debugInfo;\n }\n \n media.features = this.features.eval(context);\n\n context.mediaPath.push(media);\n context.mediaBlocks.push(media);\n\n this.rules[0].functionRegistry = context.frames[0].functionRegistry.inherit();\n context.frames.unshift(this.rules[0]);\n media.rules = [this.rules[0].eval(context)];\n context.frames.shift();\n\n context.mediaPath.pop();\n\n return context.mediaPath.length === 0 ? media.evalTop(context) :\n media.evalNested(context);\n }\n});\n\nexport default Media;\n"]} |
| {"version":3,"file":"mixin-call.js","sourceRoot":"","sources":["../../../src/less/tree/mixin-call.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,gEAAkC;AAClC,gFAAiD;AACjD,yEAA+C;AAE/C,IAAM,SAAS,GAAG,UAAS,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,eAAe,EAAE,SAAS;IACxE,IAAI,CAAC,QAAQ,GAAG,IAAI,kBAAQ,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC5B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACpB,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC;IACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,SAAS,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAC5C,IAAI,EAAE,WAAW;IAEjB,MAAM,YAAC,OAAO;QACV,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAChD;QACD,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE;YACvB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACvD;IACL,CAAC;IAED,IAAI,YAAC,OAAO;QACR,IAAI,MAAM,CAAC;QACX,IAAI,KAAK,CAAC;QACV,IAAI,SAAS,CAAC;Q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selector from './selector';\nimport MixinDefinition from './mixin-definition';\nimport defaultFunc from '../functions/default';\n\nconst MixinCall = function(elements, args, index, currentFileInfo, important) {\n this.selector = new Selector(elements);\n this.arguments = args || [];\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.important = important;\n this.allowRoot = true;\n this.setParent(this.selector, this);\n};\n\nMixinCall.prototype = Object.assign(new Node(), {\n type: 'MixinCall',\n\n accept(visitor) {\n if (this.selector) {\n this.selector = visitor.visit(this.selector);\n }\n if (this.arguments.length) {\n this.arguments = visitor.visitArray(this.arguments);\n }\n },\n\n eval(context) {\n let mixins;\n let mixin;\n let mixinPath;\n const args = [];\n let arg;\n let argValue;\n const rules = [];\n let match = false;\n let i;\n let m;\n let f;\n let isRecursive;\n let isOneFound;\n const candidates = [];\n let candidate;\n const conditionResult = [];\n let defaultResult;\n const defFalseEitherCase = -1;\n const defNone = 0;\n const defTrue = 1;\n const defFalse = 2;\n let count;\n let originalRuleset;\n let noArgumentsFilter;\n\n this.selector = this.selector.eval(context);\n\n function calcDefGroup(mixin, mixinPath) {\n let f, p, namespace;\n\n for (f = 0; f < 2; f++) {\n conditionResult[f] = true;\n defaultFunc.value(f);\n for (p = 0; p < mixinPath.length && conditionResult[f]; p++) {\n namespace = mixinPath[p];\n if (namespace.matchCondition) {\n conditionResult[f] = conditionResult[f] && namespace.matchCondition(null, context);\n }\n }\n if (mixin.matchCondition) {\n conditionResult[f] = conditionResult[f] && mixin.matchCondition(args, context);\n }\n }\n if (conditionResult[0] || conditionResult[1]) {\n if (conditionResult[0] != conditionResult[1]) {\n return conditionResult[1] ?\n defTrue : defFalse;\n }\n\n return defNone;\n }\n return defFalseEitherCase;\n }\n\n for (i = 0; i < this.arguments.length; i++) {\n arg = this.arguments[i];\n argValue = arg.value.eval(context);\n if (arg.expand && Array.isArray(argValue.value)) {\n argValue = argValue.value;\n for (m = 0; m < argValue.length; m++) {\n args.push({value: argValue[m]});\n }\n } else {\n args.push({name: arg.name, value: argValue});\n }\n }\n\n noArgumentsFilter = function(rule) {return rule.matchArgs(null, context);};\n\n for (i = 0; i < context.frames.length; i++) {\n if ((mixins = context.frames[i].find(this.selector, null, noArgumentsFilter)).length > 0) {\n isOneFound = true;\n\n // To make `default()` function independent of definition order we have two \"subpasses\" here.\n // At first we evaluate each guard *twice* (with `default() == true` and `default() == false`),\n // and build candidate list with corresponding flags. Then, when we know all possible matches,\n // we make a final decision.\n\n for (m = 0; m < mixins.length; m++) {\n mixin = mixins[m].rule;\n mixinPath = mixins[m].path;\n isRecursive = false;\n for (f = 0; f < context.frames.length; f++) {\n if ((!(mixin instanceof MixinDefinition)) && mixin === (context.frames[f].originalRuleset || context.frames[f])) {\n isRecursive = true;\n break;\n }\n }\n if (isRecursive) {\n continue;\n }\n\n if (mixin.matchArgs(args, context)) {\n candidate = {mixin, group: calcDefGroup(mixin, mixinPath)};\n\n if (candidate.group !== defFalseEitherCase) {\n candidates.push(candidate);\n }\n\n match = true;\n }\n }\n\n defaultFunc.reset();\n\n count = [0, 0, 0];\n for (m = 0; m < candidates.length; m++) {\n count[candidates[m].group]++;\n }\n\n if (count[defNone] > 0) {\n defaultResult = defFalse;\n } else {\n defaultResult = defTrue;\n if ((count[defTrue] + count[defFalse]) > 1) {\n throw { type: 'Runtime',\n message: `Ambiguous use of \\`default()\\` found when matching for \\`${this.format(args)}\\``,\n index: this.getIndex(), filename: this.fileInfo().filename };\n }\n }\n\n for (m = 0; m < candidates.length; m++) {\n candidate = candidates[m].group;\n if ((candidate === defNone) || (candidate === defaultResult)) {\n try {\n mixin = candidates[m].mixin;\n if (!(mixin instanceof MixinDefinition)) {\n originalRuleset = mixin.originalRuleset || mixin;\n mixin = new MixinDefinition('', [], mixin.rules, null, false, null, originalRuleset.visibilityInfo());\n mixin.originalRuleset = originalRuleset;\n }\n const newRules = mixin.evalCall(context, args, this.important).rules;\n this._setVisibilityToReplacement(newRules);\n Array.prototype.push.apply(rules, newRules);\n } catch (e) {\n throw { message: e.message, index: this.getIndex(), filename: this.fileInfo().filename, stack: e.stack };\n }\n }\n }\n\n if (match) {\n return rules;\n }\n }\n }\n if (isOneFound) {\n throw { type: 'Runtime',\n message: `No matching definition was found for \\`${this.format(args)}\\``,\n index: this.getIndex(), filename: this.fileInfo().filename };\n } else {\n throw { type: 'Name',\n message: `${this.selector.toCSS().trim()} is undefined`,\n index: this.getIndex(), filename: this.fileInfo().filename };\n }\n },\n\n _setVisibilityToReplacement(replacement) {\n let i, rule;\n if (this.blocksVisibility()) {\n for (i = 0; i < replacement.length; i++) {\n rule = replacement[i];\n rule.addVisibilityBlock();\n }\n }\n },\n\n format(args) {\n return `${this.selector.toCSS().trim()}(${args ? args.map(function (a) {\n let argValue = '';\n if (a.name) {\n argValue += `${a.name}:`;\n }\n if (a.value.toCSS) {\n argValue += a.value.toCSS();\n } else {\n argValue += '???';\n }\n return argValue;\n }).join(', ') : ''})`;\n }\n});\n\nexport default MixinCall;\n"]} |
| {"version":3,"file":"mixin-definition.js","sourceRoot":"","sources":["../../../src/less/tree/mixin-definition.js"],"names":[],"mappings":";;;AAAA,gEAAkC;AAClC,8DAAgC;AAChC,8DAAgC;AAChC,sEAAwC;AACxC,gFAAiD;AACjD,oEAAsC;AACtC,iEAAmC;AACnC,sDAAkC;AAElC,IAAM,UAAU,GAAG,UAAS,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc;IACxF,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,iBAAiB,CAAC;IACtC,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,kBAAQ,CAAC,CAAC,IAAI,iBAAO,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/F,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC3B,IAAI,CA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EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAE5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YAC1B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;gBAClD,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;oBACnF,OAAO,KAAK,CAAC;iBAChB;aACJ;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,UAAU,CAAC","sourcesContent":["import Selector from './selector';\nimport Element from './element';\nimport Ruleset from './ruleset';\nimport Declaration from './declaration';\nimport DetachedRuleset from './detached-ruleset';\nimport Expression from './expression';\nimport contexts from '../contexts';\nimport * as utils from '../utils';\n\nconst Definition = function(name, params, rules, condition, variadic, frames, visibilityInfo) {\n this.name = name || 'anonymous mixin';\n this.selectors = [new Selector([new Element(null, name, false, this._index, this._fileInfo)])];\n this.params = params;\n this.condition = condition;\n this.variadic = variadic;\n this.arity = params.length;\n this.rules = rules;\n this._lookups = {};\n const optionalParameters = [];\n this.required = params.reduce(function (count, p) {\n if (!p.name || (p.name && !p.value)) {\n return count + 1;\n }\n else {\n optionalParameters.push(p.name);\n return count;\n }\n }, 0);\n this.optionalParameters = optionalParameters;\n this.frames = frames;\n this.copyVisibilityInfo(visibilityInfo);\n this.allowRoot = true;\n}\n\nDefinition.prototype = Object.assign(new Ruleset(), {\n type: 'MixinDefinition',\n evalFirst: true,\n\n accept(visitor) {\n if (this.params && this.params.length) {\n this.params = visitor.visitArray(this.params);\n }\n this.rules = visitor.visitArray(this.rules);\n if (this.condition) {\n this.condition = visitor.visit(this.condition);\n }\n },\n\n evalParams(context, mixinEnv, args, evaldArguments) {\n /* jshint boss:true */\n const frame = new Ruleset(null, null);\n\n let varargs;\n let arg;\n const params = utils.copyArray(this.params);\n let i;\n let j;\n let val;\n let name;\n let isNamedFound;\n let argIndex;\n let argsLength = 0;\n\n if (mixinEnv.frames && mixinEnv.frames[0] && mixinEnv.frames[0].functionRegistry) {\n frame.functionRegistry = mixinEnv.frames[0].functionRegistry.inherit();\n }\n mixinEnv = new contexts.Eval(mixinEnv, [frame].concat(mixinEnv.frames));\n\n if (args) {\n args = utils.copyArray(args);\n argsLength = args.length;\n\n for (i = 0; i < argsLength; i++) {\n arg = args[i];\n if (name = (arg && arg.name)) {\n isNamedFound = false;\n for (j = 0; j < params.length; j++) {\n if (!evaldArguments[j] && name === params[j].name) {\n evaldArguments[j] = arg.value.eval(context);\n frame.prependRule(new Declaration(name, arg.value.eval(context)));\n isNamedFound = true;\n break;\n }\n }\n if (isNamedFound) {\n args.splice(i, 1);\n i--;\n continue;\n } else {\n throw { type: 'Runtime', message: `Named argument for ${this.name} ${args[i].name} not found` };\n }\n }\n }\n }\n argIndex = 0;\n for (i = 0; i < params.length; i++) {\n if (evaldArguments[i]) { continue; }\n\n arg = args && args[argIndex];\n\n if (name = params[i].name) {\n if (params[i].variadic) {\n varargs = [];\n for (j = argIndex; j < argsLength; j++) {\n varargs.push(args[j].value.eval(context));\n }\n frame.prependRule(new Declaration(name, new Expression(varargs).eval(context)));\n } else {\n val = arg && arg.value;\n if (val) {\n // This was a mixin call, pass in a detached ruleset of it's eval'd rules\n if (Array.isArray(val)) {\n val = new DetachedRuleset(new Ruleset('', val));\n }\n else {\n val = val.eval(context);\n }\n } else if (params[i].value) {\n val = params[i].value.eval(mixinEnv);\n frame.resetCache();\n } else {\n throw { type: 'Runtime', message: `wrong number of arguments for ${this.name} (${argsLength} for ${this.arity})` };\n }\n\n frame.prependRule(new Declaration(name, val));\n evaldArguments[i] = val;\n }\n }\n\n if (params[i].variadic && args) {\n for (j = argIndex; j < argsLength; j++) {\n evaldArguments[j] = args[j].value.eval(context);\n }\n }\n argIndex++;\n }\n\n return frame;\n },\n\n makeImportant() {\n const rules = !this.rules ? this.rules : this.rules.map(function (r) {\n if (r.makeImportant) {\n return r.makeImportant(true);\n } else {\n return r;\n }\n });\n const result = new Definition(this.name, this.params, rules, this.condition, this.variadic, this.frames);\n return result;\n },\n\n eval(context) {\n return new Definition(this.name, this.params, this.rules, this.condition, this.variadic, this.frames || utils.copyArray(context.frames));\n },\n\n evalCall(context, args, important) {\n const _arguments = [];\n const mixinFrames = this.frames ? this.frames.concat(context.frames) : context.frames;\n const frame = this.evalParams(context, new contexts.Eval(context, mixinFrames), args, _arguments);\n let rules;\n let ruleset;\n\n frame.prependRule(new Declaration('@arguments', new Expression(_arguments).eval(context)));\n\n rules = utils.copyArray(this.rules);\n\n ruleset = new Ruleset(null, rules);\n ruleset.originalRuleset = this;\n ruleset = ruleset.eval(new contexts.Eval(context, [this, frame].concat(mixinFrames)));\n if (important) {\n ruleset = ruleset.makeImportant();\n }\n return ruleset;\n },\n\n matchCondition(args, context) {\n if (this.condition && !this.condition.eval(\n new contexts.Eval(context,\n [this.evalParams(context, /* the parameter variables */\n new contexts.Eval(context, this.frames ? this.frames.concat(context.frames) : context.frames), args, [])]\n .concat(this.frames || []) // the parent namespace/mixin frames\n .concat(context.frames)))) { // the current environment frames\n return false;\n }\n return true;\n },\n\n matchArgs(args, context) {\n const allArgsCnt = (args && args.length) || 0;\n let len;\n const optionalParameters = this.optionalParameters;\n const requiredArgsCnt = !args ? 0 : args.reduce(function (count, p) {\n if (optionalParameters.indexOf(p.name) < 0) {\n return count + 1;\n } else {\n return count;\n }\n }, 0);\n\n if (!this.variadic) {\n if (requiredArgsCnt < this.required) {\n return false;\n }\n if (allArgsCnt > this.params.length) {\n return false;\n }\n } else {\n if (requiredArgsCnt < (this.required - 1)) {\n return false;\n }\n }\n\n // check patterns\n len = Math.min(requiredArgsCnt, this.arity);\n\n for (let i = 0; i < len; i++) {\n if (!this.params[i].name && !this.params[i].variadic) {\n if (args[i].value.eval(context).toCSS() != this.params[i].value.eval(context).toCSS()) {\n return false;\n }\n }\n }\n return true;\n }\n});\n\nexport default Definition;\n"]} |
| {"version":3,"file":"namespace-value.js","sourceRoot":"","sources":["../../../src/less/tree/namespace-value.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,gEAAkC;AAClC,8DAAgC;AAChC,gEAAkC;AAElC,IAAM,cAAc,GAAG,UAAS,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ;IAC9D,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;IACtB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACpB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;AAC9B,CAAC,CAAC;AAEF,cAAc,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IACjD,IAAI,EAAE,gBAAgB;IAEtB,IAAI,YAAC,OAAO;QACR,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE9C,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAEvB;;;;eAIG;YACH,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBACtB,KAAK,GAAG,IAAI,iBAAO,CAAC,CAAC,IAAI,kBAAQ,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;aAChD;YAED,IAAI,IAAI,KAAK,EAAE,EAAE;gBACb,KAAK,GAAG,KAAK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,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAa;wBACjD,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ;wBAClC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;iBAChC;gBACD,8EAA8E;gBAC9E,8CAA8C;gBAC9C,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;aACnC;YAED,IAAI,KAAK,CAAC,KAAK,EAAE;gBACb,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC;aACrC;YACD,IAAI,KAAK,CAAC,OAAO,EAAE;gBACf,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACvC;SACJ;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,cAAc,CAAC","sourcesContent":["import Node from './node';\nimport Variable from './variable';\nimport Ruleset from './ruleset';\nimport Selector from './selector';\n\nconst NamespaceValue = function(ruleCall, lookups, index, fileInfo) {\n this.value = ruleCall;\n this.lookups = lookups;\n this._index = index;\n this._fileInfo = fileInfo;\n};\n\nNamespaceValue.prototype = Object.assign(new Node(), {\n type: 'NamespaceValue',\n\n eval(context) {\n let i, name, rules = this.value.eval(context);\n \n for (i = 0; i < this.lookups.length; i++) {\n name = this.lookups[i];\n\n /**\n * Eval'd DRs return rulesets.\n * Eval'd mixins return rules, so let's make a ruleset if we need it.\n * We need to do this because of late parsing of values\n */\n if (Array.isArray(rules)) {\n rules = new Ruleset([new Selector()], rules);\n }\n\n if (name === '') {\n rules = rules.lastDeclaration();\n }\n else if (name.charAt(0) === '@') {\n if (name.charAt(1) === '@') {\n name = `@${new Variable(name.substr(1)).eval(context).value}`;\n }\n if (rules.variables) {\n rules = rules.variable(name);\n }\n \n if (!rules) {\n throw { type: 'Name',\n message: `variable ${name} not found`,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n }\n else {\n if (name.substring(0, 2) === '$@') {\n name = `$${new Variable(name.substr(1)).eval(context).value}`;\n }\n else {\n name = name.charAt(0) === '$' ? name : `$${name}`;\n }\n if (rules.properties) {\n rules = rules.property(name);\n }\n \n if (!rules) {\n throw { type: 'Name',\n message: `property \"${name.substr(1)}\" not found`,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n // Properties are an array of values, since a ruleset can have multiple props.\n // We pick the last one (the \"cascaded\" value)\n rules = rules[rules.length - 1];\n }\n\n if (rules.value) {\n rules = rules.eval(context).value;\n }\n if (rules.ruleset) {\n rules = rules.ruleset.eval(context);\n }\n }\n return rules;\n }\n});\n\nexport default NamespaceValue;\n"]} |
| {"version":3,"file":"negative.js","sourceRoot":"","sources":["../../../src/less/tree/negative.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,kEAAoC;AACpC,kEAAoC;AAEpC,IAAM,QAAQ,GAAG,UAAS,IAAI;IAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;AACtB,CAAC,CAAC;AAEF,QAAQ,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAC3C,IAAI,EAAE,UAAU;IAEhB,MAAM,YAAC,OAAO,EAAE,MAAM;QAClB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,YAAC,OAAO;QACR,IAAI,OAAO,CAAC,QAAQ,EAAE,EAAE;YACpB,OAAO,CAAC,IAAI,mBAAS,CAAC,GAAG,EAAE,CAAC,IAAI,mBAAS,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SAC9E;QACD,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAClD,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,QAAQ,CAAC","sourcesContent":["import Node from './node';\nimport Operation from './operation';\nimport Dimension from './dimension';\n\nconst Negative = function(node) {\n this.value = node;\n};\n\nNegative.prototype = Object.assign(new Node(), {\n type: 'Negative',\n\n genCSS(context, output) {\n output.add('-');\n this.value.genCSS(context, output);\n },\n\n eval(context) {\n if (context.isMathOn()) {\n return (new Operation('*', [new Dimension(-1), this.value])).eval(context);\n }\n return new Negative(this.value.eval(context));\n }\n});\n\nexport default Negative;\n"]} |
| {"version":3,"file":"nested-at-rule.js","sourceRoot":"","sources":["../../../src/less/tree/nested-at-rule.js"],"names":[],"mappings":";;;AAAA,8DAAgC;AAChC,0DAA4B;AAC5B,gEAAkC;AAClC,kEAAoC;AACpC,oEAAsC;AACtC,sDAAkC;AAElC,IAAM,uBAAuB,GAAG;IAE5B,aAAa;QACT,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,YAAC,OAAO;QACV,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAChD;QACD,IAAI,IAAI,CAAC,KAAK,EAAE;YACZ,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC/C;IACL,CAAC;IAED,YAAY,EAAE;QACV,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YACzF,OAAO;SACV;QAED,IAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QACvC,IAAI,IAAI,EAAE,KAAK,CAAC;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AAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBAC5C;aACJ;YACD,OAAO,MAAM,CAAC;SACjB;IACL,CAAC;IAED,eAAe,YAAC,SAAS;QACrB,IAAI,CAAC,SAAS,EAAE;YACZ,OAAO;SACV;QACD,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,iBAAO,CAAC,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACrC,CAAC;CACJ,CAAC;AAEF,kBAAe,uBAAuB,CAAC","sourcesContent":["import Ruleset from './ruleset';\nimport Value from './value';\nimport Selector from './selector';\nimport Anonymous from './anonymous';\nimport Expression from './expression';\nimport * as utils from '../utils';\n\nconst NestableAtRulePrototype = {\n\n isRulesetLike() {\n return true;\n },\n\n accept(visitor) {\n if (this.features) {\n this.features = visitor.visit(this.features);\n }\n if (this.rules) {\n this.rules = visitor.visitArray(this.rules);\n }\n },\n\n evalFunction: function () {\n if (!this.features || !Array.isArray(this.features.value) || this.features.value.length < 1) {\n return;\n }\n\n const exprValues = this.features.value;\n let expr, paren;\n\n for (let index = 0; index < exprValues.length; ++index) {\n expr = exprValues[index];\n\n if (expr.type === 'Keyword' && index + 1 < exprValues.length && (expr.noSpacing || expr.noSpacing == null)) {\n paren = exprValues[index + 1];\n \n if (paren.type === 'Paren' && paren.noSpacing) {\n exprValues[index]= new Expression([expr, paren]);\n exprValues.splice(index + 1, 1);\n exprValues[index].noSpacing = true;\n }\n }\n }\n },\n\n evalTop(context) {\n this.evalFunction();\n\n let result = this;\n\n // Render all dependent Media blocks.\n if (context.mediaBlocks.length > 1) {\n const selectors = (new Selector([], null, null, this.getIndex(), this.fileInfo())).createEmptySelectors();\n result = new Ruleset(selectors, context.mediaBlocks);\n result.multiMedia = true;\n result.copyVisibilityInfo(this.visibilityInfo());\n this.setParent(result, this);\n }\n\n delete context.mediaBlocks;\n delete context.mediaPath;\n\n return result;\n },\n\n evalNested(context) {\n this.evalFunction();\n\n let i;\n let value;\n const path = context.mediaPath.concat([this]);\n\n // Extract the media-query conditions separated with `,` (OR).\n for (i = 0; i < path.length; i++) {\n if (path[i].type !== this.type) { \n context.mediaBlocks.splice(i, 1); \n \n return this; \n }\n \n value = path[i].features instanceof Value ?\n path[i].features.value : path[i].features;\n path[i] = Array.isArray(value) ? value : [value];\n }\n\n // Trace all permutations to generate the resulting media-query.\n //\n // (a, b and c) with nested (d, e) ->\n // a and d\n // a and e\n // b and c and d\n // b and c and e\n this.features = new Value(this.permute(path).map(path => {\n path = path.map(fragment => fragment.toCSS ? fragment : new Anonymous(fragment));\n\n for (i = path.length - 1; i > 0; i--) {\n path.splice(i, 0, new Anonymous('and'));\n }\n\n return new Expression(path);\n }));\n this.setParent(this.features, this);\n\n // Fake a tree-node that doesn't output anything.\n return new Ruleset([], []);\n },\n\n permute(arr) {\n if (arr.length === 0) {\n return [];\n } else if (arr.length === 1) {\n return arr[0];\n } else {\n const result = [];\n const rest = this.permute(arr.slice(1));\n for (let i = 0; i < rest.length; i++) {\n for (let j = 0; j < arr[0].length; j++) {\n result.push([arr[0][j]].concat(rest[i]));\n }\n }\n return result;\n }\n },\n\n bubbleSelectors(selectors) {\n if (!selectors) {\n return;\n }\n this.rules = [new Ruleset(utils.copyArray(selectors), [this.rules[0]])];\n this.setParent(this.rules, this);\n }\n};\n\nexport default NestableAtRulePrototype;\n"]} |
| {"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/less/tree/node.js"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH;IACI;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;QAClC,IAAI,CAAC,WAAW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,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;IACxC,CAAC;IACL,WAAC;AAAD,CAAC,AAjLD,IAiLC;AAED,kBAAe,IAAI,CAAC","sourcesContent":["/**\n * The reason why Node is a class and other nodes simply do not extend\n * from Node (since we're transpiling) is due to this issue:\n * \n * @see https://github.com/less/less.js/issues/3434\n */\nclass Node {\n constructor() {\n this.parent = null;\n this.visibilityBlocks = undefined;\n this.nodeVisible = undefined;\n this.rootNode = null;\n this.parsed = null;\n }\n\n get currentFileInfo() {\n return this.fileInfo();\n }\n\n get index() {\n return this.getIndex();\n }\n\n setParent(nodes, parent) {\n function set(node) {\n if (node && node instanceof Node) {\n node.parent = parent;\n }\n }\n if (Array.isArray(nodes)) {\n nodes.forEach(set);\n }\n else {\n set(nodes);\n }\n }\n\n getIndex() {\n return this._index || (this.parent && this.parent.getIndex()) || 0;\n }\n\n fileInfo() {\n return this._fileInfo || (this.parent && this.parent.fileInfo()) || {};\n }\n\n isRulesetLike() { return false; }\n\n toCSS(context) {\n const strs = [];\n this.genCSS(context, {\n // remove when genCSS has JSDoc types\n // eslint-disable-next-line no-unused-vars\n add: function(chunk, fileInfo, index) {\n strs.push(chunk);\n },\n isEmpty: function () {\n return strs.length === 0;\n }\n });\n return strs.join('');\n }\n\n genCSS(context, output) {\n output.add(this.value);\n }\n\n accept(visitor) {\n this.value = visitor.visit(this.value);\n }\n\n eval() { return this; }\n\n _operate(context, op, a, b) {\n switch (op) {\n case '+': return a + b;\n case '-': return a - b;\n case '*': return a * b;\n case '/': return a / b;\n }\n }\n\n fround(context, value) {\n const precision = context && context.numPrecision;\n // add \"epsilon\" to ensure numbers like 1.000000005 (represented as 1.000000004999...) are properly rounded:\n return (precision) ? Number((value + 2e-16).toFixed(precision)) : value;\n }\n\n static compare(a, b) {\n /* returns:\n -1: a < b\n 0: a = b\n 1: a > b\n and *any* other value for a != b (e.g. undefined, NaN, -2 etc.) */\n\n if ((a.compare) &&\n // for \"symmetric results\" force toCSS-based comparison\n // of Quoted or Anonymous if either value is one of those\n !(b.type === 'Quoted' || b.type === 'Anonymous')) {\n return a.compare(b);\n } else if (b.compare) {\n return -b.compare(a);\n } else if (a.type !== b.type) {\n return undefined;\n }\n\n a = a.value;\n b = b.value;\n if (!Array.isArray(a)) {\n return a === b ? 0 : undefined;\n }\n if (a.length !== b.length) {\n return undefined;\n }\n for (let i = 0; i < a.length; i++) {\n if (Node.compare(a[i], b[i]) !== 0) {\n return undefined;\n }\n }\n return 0;\n }\n\n static numericCompare(a, b) {\n return a < b ? -1\n : a === b ? 0\n : a > b ? 1 : undefined;\n }\n\n // Returns true if this node represents root of ast imported by reference\n blocksVisibility() {\n if (this.visibilityBlocks === undefined) {\n this.visibilityBlocks = 0;\n }\n return this.visibilityBlocks !== 0;\n }\n\n addVisibilityBlock() {\n if (this.visibilityBlocks === undefined) {\n this.visibilityBlocks = 0;\n }\n this.visibilityBlocks = this.visibilityBlocks + 1;\n }\n\n removeVisibilityBlock() {\n if (this.visibilityBlocks === undefined) {\n this.visibilityBlocks = 0;\n }\n this.visibilityBlocks = this.visibilityBlocks - 1;\n }\n\n // Turns on node visibility - if called node will be shown in output regardless\n // of whether it comes from import by reference or not\n ensureVisibility() {\n this.nodeVisible = true;\n }\n\n // Turns off node visibility - if called node will NOT be shown in output regardless\n // of whether it comes from import by reference or not\n ensureInvisibility() {\n this.nodeVisible = false;\n }\n\n // return values:\n // false - the node must not be visible\n // true - the node must be visible\n // undefined or null - the node has the same visibility as its parent\n isVisible() {\n return this.nodeVisible;\n }\n\n visibilityInfo() {\n return {\n visibilityBlocks: this.visibilityBlocks,\n nodeVisible: this.nodeVisible\n };\n }\n\n copyVisibilityInfo(info) {\n if (!info) {\n return;\n }\n this.visibilityBlocks = info.visibilityBlocks;\n this.nodeVisible = info.nodeVisible;\n }\n}\n\nexport default Node;\n"]} |
| {"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../src/less/tree/operation.js"],"names":[],"mappings":";;;AAAA,wDAA0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,CAAC,CAAC,CAAC,OAAO,EAAE;gBAC1B,IACI,CAAC,CAAC,YAAY,SAAS,IAAI,CAAC,YAAY,SAAS,CAAC;uBAC/C,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,eAAe,EAC1D;oBACE,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;iBACxD;gBACD,MAAM,EAAE,IAAI,EAAE,WAAW;oBACrB,OAAO,EAAE,8BAA8B,EAAE,CAAC;aACjD;YAED,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;SACpC;aAAM;YACH,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;SACxD;IACL,CAAC;IAED,MAAM,YAAC,OAAO,EAAE,MAAM;QAClB,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACzC,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SACnB;QACD,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpB,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SACnB;QACD,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,SAAS,CAAC","sourcesContent":["import Node from './node';\nimport Color from './color';\nimport Dimension from './dimension';\nimport * as Constants from '../constants';\nconst MATH = Constants.Math;\n\n\nconst Operation = function(op, operands, isSpaced) {\n this.op = op.trim();\n this.operands = operands;\n this.isSpaced = isSpaced;\n};\n\nOperation.prototype = Object.assign(new Node(), {\n type: 'Operation',\n\n accept(visitor) {\n this.operands = visitor.visitArray(this.operands);\n },\n\n eval(context) {\n let a = this.operands[0].eval(context), b = this.operands[1].eval(context), op;\n\n if (context.isMathOn(this.op)) {\n op = this.op === './' ? '/' : this.op;\n if (a instanceof Dimension && b instanceof Color) {\n a = a.toColor();\n }\n if (b instanceof Dimension && a instanceof Color) {\n b = b.toColor();\n }\n if (!a.operate || !b.operate) {\n if (\n (a instanceof Operation || b instanceof Operation)\n && a.op === '/' && context.math === MATH.PARENS_DIVISION\n ) {\n return new Operation(this.op, [a, b], this.isSpaced);\n }\n throw { type: 'Operation',\n message: 'Operation on an invalid type' };\n }\n\n return a.operate(context, op, b);\n } else {\n return new Operation(this.op, [a, b], this.isSpaced);\n }\n },\n\n genCSS(context, output) {\n this.operands[0].genCSS(context, output);\n if (this.isSpaced) {\n output.add(' ');\n }\n output.add(this.op);\n if (this.isSpaced) {\n output.add(' ');\n }\n this.operands[1].genCSS(context, output);\n }\n});\n\nexport default Operation;\n"]} |
| {"version":3,"file":"paren.js","sourceRoot":"","sources":["../../../src/less/tree/paren.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAE1B,IAAM,KAAK,GAAG,UAAS,IAAI;IACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;AACtB,CAAC,CAAC;AAEF,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IACxC,IAAI,EAAE,OAAO;IAEb,MAAM,YAAC,OAAO,EAAE,MAAM;QAClB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACnC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IAED,IAAI,YAAC,OAAO;QACR,IAAM,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAElD,IAAI,IAAI,CAAC,SAAS,EAAE;YAChB,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;SAC1B;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,KAAK,CAAC","sourcesContent":["import Node from './node';\n\nconst Paren = function(node) {\n this.value = node;\n};\n\nParen.prototype = Object.assign(new Node(), {\n type: 'Paren',\n\n genCSS(context, output) {\n output.add('(');\n this.value.genCSS(context, output);\n output.add(')');\n },\n\n eval(context) {\n const paren = new Paren(this.value.eval(context));\n \n if (this.noSpacing) {\n paren.noSpacing = true;\n }\n\n return paren;\n }\n});\n\nexport default Paren;\n"]} |
| {"version":3,"file":"property.js","sourceRoot":"","sources":["../../../src/less/tree/property.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,sEAAwC;AAExC,IAAM,QAAQ,GAAG,UAAS,IAAI,EAAE,KAAK,EAAE,eAAe;IAClD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACpB,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC;AACrC,CAAC,CAAC;AAEF,QAAQ,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAC3C,IAAI,EAAE,UAAU;IAEhB,IAAI,YAAC,OAAO;QACR,IAAI,QAAQ,CAAC;QACb,IAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,+BAA+B;QAC/B,IAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC,WAAW,CAAC;QAE1F,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,MAAM,EAAE,I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ACZ;QACL,CAAC,CAAC,CAAC;QACH,IAAI,QAAQ,EAAE;YACV,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;YACxB,OAAO,QAAQ,CAAC;SACnB;aAAM;YACH,MAAM,EAAE,IAAI,EAAE,MAAM;gBAChB,OAAO,EAAE,oBAAa,IAAI,mBAAgB;gBAC1C,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,QAAQ;gBACvC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;SAC3B;IACL,CAAC;IAED,IAAI,YAAC,GAAG,EAAE,GAAG;QACT,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,SAAA,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACpC,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1B,IAAI,CAAC,EAAE;gBAAE,OAAO,CAAC,CAAC;aAAE;SACvB;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,QAAQ,CAAC","sourcesContent":["import Node from './node';\nimport Declaration from './declaration';\n\nconst Property = function(name, index, currentFileInfo) {\n this.name = name;\n this._index = index;\n this._fileInfo = currentFileInfo;\n};\n\nProperty.prototype = Object.assign(new Node(), {\n type: 'Property',\n\n eval(context) {\n let property;\n const name = this.name;\n // TODO: shorten this reference\n const mergeRules = context.pluginManager.less.visitors.ToCSSVisitor.prototype._mergeRules;\n\n if (this.evaluating) {\n throw { type: 'Name',\n message: `Recursive property reference for ${name}`,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n\n this.evaluating = true;\n\n property = this.find(context.frames, function (frame) {\n let v;\n const vArr = frame.property(name);\n if (vArr) {\n for (let i = 0; i < vArr.length; i++) {\n v = vArr[i];\n\n vArr[i] = new Declaration(v.name,\n v.value,\n v.important,\n v.merge,\n v.index,\n v.currentFileInfo,\n v.inline,\n v.variable\n );\n }\n mergeRules(vArr);\n\n v = vArr[vArr.length - 1];\n if (v.important) {\n const importantScope = context.importantScope[context.importantScope.length - 1];\n importantScope.important = v.important;\n }\n v = v.value.eval(context);\n return v;\n }\n });\n if (property) {\n this.evaluating = false;\n return property;\n } else {\n throw { type: 'Name',\n message: `Property '${name}' is undefined`,\n filename: this.currentFileInfo.filename,\n index: this.index };\n }\n },\n\n find(obj, fun) {\n for (let i = 0, r; i < obj.length; i++) {\n r = fun.call(obj, obj[i]);\n if (r) { return r; }\n }\n return null;\n }\n});\n\nexport default Property;\n"]} |
| {"version":3,"file":"query-in-parens.js","sourceRoot":"","sources":["../../../src/less/tree/query-in-parens.js"],"names":[],"mappings":";;;AAAA,+CAAqC;AACrC,sEAAwC;AACxC,wDAA0B;AAE1B,IAAM,aAAa,GAAG,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;IAC/C,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IACpB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAChB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACnC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAChB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAChB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AACtB,CAAC,CAAC;AAEF,aAAa,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAChD,IAAI,EAAE,eAAe;IAErB,MAAM,YAAC,OAAO;QACV,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,OAAO,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IAAI,CAAC,OAAO,CAAC,CAAC;SAC3C;QAED,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SAC3C;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,YAAC,OAAO,EAAE,MAAM;QAClB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACpC,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;QAChC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACzB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;SACtC;QACD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACpC,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;SACvC;IACL,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,aAAa,CAAC","sourcesContent":["import { copy } from 'copy-anything';\nimport Declaration from './declaration';\nimport Node from './node';\n\nconst QueryInParens = function (op, l, m, op2, r, i) {\n this.op = op.trim();\n this.lvalue = l;\n this.mvalue = m;\n this.op2 = op2 ? op2.trim() : null;\n this.rvalue = r;\n this._index = i;\n this.mvalues = [];\n};\n\nQueryInParens.prototype = Object.assign(new Node(), {\n type: 'QueryInParens',\n\n accept(visitor) {\n this.lvalue = visitor.visit(this.lvalue);\n this.mvalue = visitor.visit(this.mvalue);\n if (this.rvalue) {\n this.rvalue = visitor.visit(this.rvalue);\n }\n },\n\n eval(context) {\n this.lvalue = this.lvalue.eval(context);\n \n let variableDeclaration;\n let rule;\n\n for (let i = 0; (rule = context.frames[i]); i++) {\n if (rule.type === 'Ruleset') {\n variableDeclaration = rule.rules.find(function (r) {\n if ((r instanceof Declaration) && r.variable) {\n return true;\n }\n\n return false;\n });\n \n if (variableDeclaration) {\n break;\n }\n }\n }\n\n if (!this.mvalueCopy) {\n this.mvalueCopy = copy(this.mvalue);\n }\n \n if (variableDeclaration) {\n this.mvalue = this.mvalueCopy;\n this.mvalue = this.mvalue.eval(context);\n this.mvalues.push(this.mvalue);\n } else {\n this.mvalue = this.mvalue.eval(context);\n }\n\n if (this.rvalue) {\n this.rvalue = this.rvalue.eval(context);\n }\n return this;\n },\n\n genCSS(context, output) {\n this.lvalue.genCSS(context, output);\n output.add(' ' + this.op + ' ');\n if (this.mvalues.length > 0) {\n this.mvalue = this.mvalues.shift();\n }\n this.mvalue.genCSS(context, output);\n if (this.rvalue) {\n output.add(' ' + this.op2 + ' ');\n this.rvalue.genCSS(context, output);\n }\n },\n});\n\nexport default QueryInParens;\n"]} |
| {"version":3,"file":"quoted.js","sourceRoot":"","sources":["../../../src/less/tree/quoted.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,gEAAkC;AAClC,gEAAkC;AAElC,IAAM,MAAM,GAAG,UAAS,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe;IACjE,IAAI,CAAC,OAAO,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;IACxD,IAAI,CAAC,KAAK,GAAG,OAAO,IAAI,EAAE,CAAC;IAC3B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC3B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACpB,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC;IACjC,IAAI,CAAC,aAAa,GAAG,gBAAgB,CAAC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CAAC,OAAO,EAAE;YAC5D,OAAO,cAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;SACvD;aAAM;YACH,OAAO,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;SACxE;IACL,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,MAAM,CAAC","sourcesContent":["import Node from './node';\nimport Variable from './variable';\nimport Property from './property';\n\nconst Quoted = function(str, content, escaped, index, currentFileInfo) {\n this.escaped = (escaped === undefined) ? true : escaped;\n this.value = content || '';\n this.quote = str.charAt(0);\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.variableRegex = /@\\{([\\w-]+)\\}/g;\n this.propRegex = /\\$\\{([\\w-]+)\\}/g;\n this.allowRoot = escaped;\n};\n\nQuoted.prototype = Object.assign(new Node(), {\n type: 'Quoted',\n\n genCSS(context, output) {\n if (!this.escaped) {\n output.add(this.quote, this.fileInfo(), this.getIndex());\n }\n output.add(this.value);\n if (!this.escaped) {\n output.add(this.quote);\n }\n },\n\n containsVariables() {\n return this.value.match(this.variableRegex);\n },\n\n eval(context) {\n const that = this;\n let value = this.value;\n const variableReplacement = function (_, name1, name2) {\n const v = new Variable(`@${name1 ?? name2}`, that.getIndex(), that.fileInfo()).eval(context, true);\n return (v instanceof Quoted) ? v.value : v.toCSS();\n };\n const propertyReplacement = function (_, name1, name2) {\n const v = new Property(`$${name1 ?? name2}`, that.getIndex(), that.fileInfo()).eval(context, true);\n return (v instanceof Quoted) ? v.value : v.toCSS();\n };\n function iterativeReplace(value, regexp, replacementFnc) {\n let evaluatedValue = value;\n do {\n value = evaluatedValue.toString();\n evaluatedValue = value.replace(regexp, replacementFnc);\n } while (value !== evaluatedValue);\n return evaluatedValue;\n }\n value = iterativeReplace(value, this.variableRegex, variableReplacement);\n value = iterativeReplace(value, this.propRegex, propertyReplacement);\n return new Quoted(this.quote + value + this.quote, value, this.escaped, this.getIndex(), this.fileInfo());\n },\n\n compare(other) {\n // when comparing quoted strings allow the quote to differ\n if (other.type === 'Quoted' && !this.escaped && !other.escaped) {\n return Node.numericCompare(this.value, other.value);\n } else {\n return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined;\n }\n }\n});\n\nexport default Quoted;\n"]} |
| {"version":3,"file":"ruleset.js","sourceRoot":"","sources":["../../../src/less/tree/ruleset.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,sEAAwC;AACxC,8DAAgC;AAChC,8DAAgC;AAChC,0DAA4B;AAC5B,gEAAkC;AAClC,8DAAgC;AAChC,kEAAoC;AACpC,iEAAmC;AACnC,6FAAoE;AACpE,yEAA+C;AAC/C,oEAAwC;AACxC,sDAAkC;AAClC,oEAAsC;AAEtC,IAAM,OAAO,GAAG,UAAS,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,cAAc;IACpE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACnB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACnB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACvB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IACxB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACnC,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;IACxC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAEtB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACrC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC,CAAA;AAED,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAC1C,IAAI,EAAE,SAAS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AAO,EAAE,QAAQ,CAAC,CAAC;QAEvE,IAAI,CAAC,iBAAiB,EAAE;YACpB,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;gBACpB,QAAQ,GAAG,EAAE,CAAC;gBACd,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBAEjC,IAAM,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;oBAE1F,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;oBAC5B,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;iBAC/B;aACJ;iBACI;gBACD,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;aAC3B;SACJ;QAED,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAClC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3B;IAEL,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,OAAO,CAAC","sourcesContent":["import Node from './node';\nimport Declaration from './declaration';\nimport Keyword from './keyword';\nimport Comment from './comment';\nimport Paren from './paren';\nimport Selector from './selector';\nimport Element from './element';\nimport Anonymous from './anonymous';\nimport contexts from '../contexts';\nimport globalFunctionRegistry from '../functions/function-registry';\nimport defaultFunc from '../functions/default';\nimport getDebugInfo from './debug-info';\nimport * as utils from '../utils';\nimport Parser from '../parser/parser';\n\nconst Ruleset = function(selectors, rules, strictImports, visibilityInfo) {\n this.selectors = selectors;\n this.rules = rules;\n this._lookups = {};\n this._variables = null;\n this._properties = null;\n this.strictImports = strictImports;\n this.copyVisibilityInfo(visibilityInfo);\n this.allowRoot = true;\n\n this.setParent(this.selectors, this);\n this.setParent(this.rules, this);\n}\n\nRuleset.prototype = Object.assign(new Node(), {\n type: 'Ruleset',\n isRuleset: true,\n\n isRulesetLike() { return true; },\n\n accept(visitor) {\n if (this.paths) {\n this.paths = visitor.visitArray(this.paths, true);\n } else if (this.selectors) {\n this.selectors = visitor.visitArray(this.selectors);\n }\n if (this.rules && this.rules.length) {\n this.rules = visitor.visitArray(this.rules);\n }\n },\n\n eval(context) {\n let selectors;\n let selCnt;\n let selector;\n let i;\n let hasVariable;\n let hasOnePassingSelector = false;\n\n if (this.selectors && (selCnt = this.selectors.length)) {\n selectors = new Array(selCnt);\n defaultFunc.error({\n type: 'Syntax',\n message: 'it is currently only allowed in parametric mixin guards,'\n });\n\n for (i = 0; i < selCnt; i++) {\n selector = this.selectors[i].eval(context);\n for (let j = 0; j < selector.elements.length; j++) {\n if (selector.elements[j].isVariable) {\n hasVariable = true;\n break;\n }\n }\n selectors[i] = selector;\n if (selector.evaldCondition) {\n hasOnePassingSelector = true;\n }\n }\n\n if (hasVariable) {\n const toParseSelectors = new Array(selCnt);\n for (i = 0; i < selCnt; i++) {\n selector = selectors[i];\n toParseSelectors[i] = selector.toCSS(context);\n }\n const startingIndex = selectors[0].getIndex();\n const selectorFileInfo = selectors[0].fileInfo();\n new Parser(context, this.parse.importManager, selectorFileInfo, startingIndex).parseNode(\n toParseSelectors.join(','),\n ['selectors'],\n function(err, result) {\n if (result) {\n selectors = utils.flattenArray(result);\n }\n });\n }\n\n defaultFunc.reset();\n } else {\n hasOnePassingSelector = true;\n }\n\n let rules = this.rules ? utils.copyArray(this.rules) : null;\n const ruleset = new Ruleset(selectors, rules, this.strictImports, this.visibilityInfo());\n let rule;\n let subRule;\n\n ruleset.originalRuleset = this;\n ruleset.root = this.root;\n ruleset.firstRoot = this.firstRoot;\n ruleset.allowImports = this.allowImports;\n\n if (this.debugInfo) {\n ruleset.debugInfo = this.debugInfo;\n }\n\n if (!hasOnePassingSelector) {\n rules.length = 0;\n }\n\n // inherit a function registry from the frames stack when possible;\n // otherwise from the global registry\n ruleset.functionRegistry = (function (frames) {\n let i = 0;\n const n = frames.length;\n let found;\n for ( ; i !== n ; ++i ) {\n found = frames[ i ].functionRegistry;\n if ( found ) { return found; }\n }\n return globalFunctionRegistry;\n }(context.frames)).inherit();\n\n // push the current ruleset to the frames stack\n const ctxFrames = context.frames;\n ctxFrames.unshift(ruleset);\n\n // currrent selectors\n let ctxSelectors = context.selectors;\n if (!ctxSelectors) {\n context.selectors = ctxSelectors = [];\n }\n ctxSelectors.unshift(this.selectors);\n\n // Evaluate imports\n if (ruleset.root || ruleset.allowImports || !ruleset.strictImports) {\n ruleset.evalImports(context);\n }\n\n // Store the frames around mixin definitions,\n // so they can be evaluated like closures when the time comes.\n const rsRules = ruleset.rules;\n for (i = 0; (rule = rsRules[i]); i++) {\n if (rule.evalFirst) {\n rsRules[i] = rule.eval(context);\n }\n }\n\n const mediaBlockCount = (context.mediaBlocks && context.mediaBlocks.length) || 0;\n\n // Evaluate mixin calls.\n for (i = 0; (rule = rsRules[i]); i++) {\n if (rule.type === 'MixinCall') {\n /* jshint loopfunc:true */\n rules = rule.eval(context).filter(function(r) {\n if ((r instanceof Declaration) && r.variable) {\n // do not pollute the scope if the variable is\n // already there. consider returning false here\n // but we need a way to \"return\" variable from mixins\n return !(ruleset.variable(r.name));\n }\n return true;\n });\n rsRules.splice.apply(rsRules, [i, 1].concat(rules));\n i += rules.length - 1;\n ruleset.resetCache();\n } else if (rule.type === 'VariableCall') {\n /* jshint loopfunc:true */\n rules = rule.eval(context).rules.filter(function(r) {\n if ((r instanceof Declaration) && r.variable) {\n // do not pollute the scope at all\n return false;\n }\n return true;\n });\n rsRules.splice.apply(rsRules, [i, 1].concat(rules));\n i += rules.length - 1;\n ruleset.resetCache();\n }\n }\n\n // Evaluate everything else\n for (i = 0; (rule = rsRules[i]); i++) {\n if (!rule.evalFirst) {\n rsRules[i] = rule = rule.eval ? rule.eval(context) : rule;\n }\n }\n\n // Evaluate everything else\n for (i = 0; (rule = rsRules[i]); i++) {\n // for rulesets, check if it is a css guard and can be removed\n if (rule instanceof Ruleset && rule.selectors && rule.selectors.length === 1) {\n // check if it can be folded in (e.g. & where)\n if (rule.selectors[0] && rule.selectors[0].isJustParentSelector()) {\n rsRules.splice(i--, 1);\n\n for (let j = 0; (subRule = rule.rules[j]); j++) {\n if (subRule instanceof Node) {\n subRule.copyVisibilityInfo(rule.visibilityInfo());\n if (!(subRule instanceof Declaration) || !subRule.variable) {\n rsRules.splice(++i, 0, subRule);\n }\n }\n }\n }\n }\n }\n\n // Pop the stack\n ctxFrames.shift();\n ctxSelectors.shift();\n\n if (context.mediaBlocks) {\n for (i = mediaBlockCount; i < context.mediaBlocks.length; i++) {\n context.mediaBlocks[i].bubbleSelectors(selectors);\n }\n }\n\n return ruleset;\n },\n\n evalImports(context) {\n const rules = this.rules;\n let i;\n let importRules;\n if (!rules) { return; }\n\n for (i = 0; i < rules.length; i++) {\n if (rules[i].type === 'Import') {\n importRules = rules[i].eval(context);\n if (importRules && (importRules.length || importRules.length === 0)) {\n rules.splice.apply(rules, [i, 1].concat(importRules));\n i += importRules.length - 1;\n } else {\n rules.splice(i, 1, importRules);\n }\n this.resetCache();\n }\n }\n },\n\n makeImportant() {\n const result = new Ruleset(this.selectors, this.rules.map(function (r) {\n if (r.makeImportant) {\n return r.makeImportant();\n } else {\n return r;\n }\n }), this.strictImports, this.visibilityInfo());\n\n return result;\n },\n\n matchArgs(args) {\n return !args || args.length === 0;\n },\n\n // lets you call a css selector with a guard\n matchCondition(args, context) {\n const lastSelector = this.selectors[this.selectors.length - 1];\n if (!lastSelector.evaldCondition) {\n return false;\n }\n if (lastSelector.condition &&\n !lastSelector.condition.eval(\n new contexts.Eval(context,\n context.frames))) {\n return false;\n }\n return true;\n },\n\n resetCache() {\n this._rulesets = null;\n this._variables = null;\n this._properties = null;\n this._lookups = {};\n },\n\n variables() {\n if (!this._variables) {\n this._variables = !this.rules ? {} : this.rules.reduce(function (hash, r) {\n if (r instanceof Declaration && r.variable === true) {\n hash[r.name] = r;\n }\n // when evaluating variables in an import statement, imports have not been eval'd\n // so we need to go inside import statements.\n // guard against root being a string (in the case of inlined less)\n if (r.type === 'Import' && r.root && r.root.variables) {\n const vars = r.root.variables();\n for (const name in vars) {\n // eslint-disable-next-line no-prototype-builtins\n if (vars.hasOwnProperty(name)) {\n hash[name] = r.root.variable(name);\n }\n }\n }\n return hash;\n }, {});\n }\n return this._variables;\n },\n\n properties() {\n if (!this._properties) {\n this._properties = !this.rules ? {} : this.rules.reduce(function (hash, r) {\n if (r instanceof Declaration && r.variable !== true) {\n const name = (r.name.length === 1) && (r.name[0] instanceof Keyword) ?\n r.name[0].value : r.name;\n // Properties don't overwrite as they can merge\n if (!hash[`$${name}`]) {\n hash[`$${name}`] = [ r ];\n }\n else {\n hash[`$${name}`].push(r);\n }\n }\n return hash;\n }, {});\n }\n return this._properties;\n },\n\n variable(name) {\n const decl = this.variables()[name];\n if (decl) {\n return this.parseValue(decl);\n }\n },\n\n property(name) {\n const decl = this.properties()[name];\n if (decl) {\n return this.parseValue(decl);\n }\n },\n\n lastDeclaration() {\n for (let i = this.rules.length; i > 0; i--) {\n const decl = this.rules[i - 1];\n if (decl instanceof Declaration) {\n return this.parseValue(decl);\n }\n }\n },\n\n parseValue(toParse) {\n const self = this;\n function transformDeclaration(decl) {\n if (decl.value instanceof Anonymous && !decl.parsed) {\n if (typeof decl.value.value === 'string') {\n new Parser(this.parse.context, this.parse.importManager, decl.fileInfo(), decl.value.getIndex()).parseNode(\n decl.value.value,\n ['value', 'important'],\n function(err, result) {\n if (err) {\n decl.parsed = true;\n }\n if (result) {\n decl.value = result[0];\n decl.important = result[1] || '';\n decl.parsed = true;\n }\n });\n } else {\n decl.parsed = true;\n }\n\n return decl;\n }\n else {\n return decl;\n }\n }\n if (!Array.isArray(toParse)) {\n return transformDeclaration.call(self, toParse);\n }\n else {\n const nodes = [];\n toParse.forEach(function(n) {\n nodes.push(transformDeclaration.call(self, n));\n });\n return nodes;\n }\n },\n\n rulesets() {\n if (!this.rules) { return []; }\n\n const filtRules = [];\n const rules = this.rules;\n let i;\n let rule;\n\n for (i = 0; (rule = rules[i]); i++) {\n if (rule.isRuleset) {\n filtRules.push(rule);\n }\n }\n\n return filtRules;\n },\n\n prependRule(rule) {\n const rules = this.rules;\n if (rules) {\n rules.unshift(rule);\n } else {\n this.rules = [ rule ];\n }\n this.setParent(rule, this);\n },\n\n find(selector, self, filter) {\n self = self || this;\n const rules = [];\n let match;\n let foundMixins;\n const key = selector.toCSS();\n\n if (key in this._lookups) { return this._lookups[key]; }\n\n this.rulesets().forEach(function (rule) {\n if (rule !== self) {\n for (let j = 0; j < rule.selectors.length; j++) {\n match = selector.match(rule.selectors[j]);\n if (match) {\n if (selector.elements.length > match) {\n if (!filter || filter(rule)) {\n foundMixins = rule.find(new Selector(selector.elements.slice(match)), self, filter);\n for (let i = 0; i < foundMixins.length; ++i) {\n foundMixins[i].path.push(rule);\n }\n Array.prototype.push.apply(rules, foundMixins);\n }\n } else {\n rules.push({ rule, path: []});\n }\n break;\n }\n }\n }\n });\n this._lookups[key] = rules;\n return rules;\n },\n\n genCSS(context, output) {\n let i;\n let j;\n const charsetRuleNodes = [];\n let ruleNodes = [];\n\n let // Line number debugging\n debugInfo;\n\n let rule;\n let path;\n\n context.tabLevel = (context.tabLevel || 0);\n\n if (!this.root) {\n context.tabLevel++;\n }\n\n const tabRuleStr = context.compress ? '' : Array(context.tabLevel + 1).join(' ');\n const tabSetStr = context.compress ? '' : Array(context.tabLevel).join(' ');\n let sep;\n\n let charsetNodeIndex = 0;\n let importNodeIndex = 0;\n for (i = 0; (rule = this.rules[i]); i++) {\n if (rule instanceof Comment) {\n if (importNodeIndex === i) {\n importNodeIndex++;\n }\n ruleNodes.push(rule);\n } else if (rule.isCharset && rule.isCharset()) {\n ruleNodes.splice(charsetNodeIndex, 0, rule);\n charsetNodeIndex++;\n importNodeIndex++;\n } else if (rule.type === 'Import') {\n ruleNodes.splice(importNodeIndex, 0, rule);\n importNodeIndex++;\n } else {\n ruleNodes.push(rule);\n }\n }\n ruleNodes = charsetRuleNodes.concat(ruleNodes);\n\n // If this is the root node, we don't render\n // a selector, or {}.\n if (!this.root) {\n debugInfo = getDebugInfo(context, this, tabSetStr);\n\n if (debugInfo) {\n output.add(debugInfo);\n output.add(tabSetStr);\n }\n\n const paths = this.paths;\n const pathCnt = paths.length;\n let pathSubCnt;\n\n sep = context.compress ? ',' : (`,\\n${tabSetStr}`);\n\n for (i = 0; i < pathCnt; i++) {\n path = paths[i];\n if (!(pathSubCnt = path.length)) { continue; }\n if (i > 0) { output.add(sep); }\n\n context.firstSelector = true;\n path[0].genCSS(context, output);\n\n context.firstSelector = false;\n for (j = 1; j < pathSubCnt; j++) {\n path[j].genCSS(context, output);\n }\n }\n\n output.add((context.compress ? '{' : ' {\\n') + tabRuleStr);\n }\n\n // Compile rules and rulesets\n for (i = 0; (rule = ruleNodes[i]); i++) {\n\n if (i + 1 === ruleNodes.length) {\n context.lastRule = true;\n }\n\n const currentLastRule = context.lastRule;\n if (rule.isRulesetLike(rule)) {\n context.lastRule = false;\n }\n\n if (rule.genCSS) {\n rule.genCSS(context, output);\n } else if (rule.value) {\n output.add(rule.value.toString());\n }\n\n context.lastRule = currentLastRule;\n\n if (!context.lastRule && rule.isVisible()) {\n output.add(context.compress ? '' : (`\\n${tabRuleStr}`));\n } else {\n context.lastRule = false;\n }\n }\n\n if (!this.root) {\n output.add((context.compress ? '}' : `\\n${tabSetStr}}`));\n context.tabLevel--;\n }\n\n if (!output.isEmpty() && !context.compress && this.firstRoot) {\n output.add('\\n');\n }\n },\n\n joinSelectors(paths, context, selectors) {\n for (let s = 0; s < selectors.length; s++) {\n this.joinSelector(paths, context, selectors[s]);\n }\n },\n\n joinSelector(paths, context, selector) {\n\n function createParenthesis(elementsToPak, originalElement) {\n let replacementParen, j;\n if (elementsToPak.length === 0) {\n replacementParen = new Paren(elementsToPak[0]);\n } else {\n const insideParent = new Array(elementsToPak.length);\n for (j = 0; j < elementsToPak.length; j++) {\n insideParent[j] = new Element(\n null,\n elementsToPak[j],\n originalElement.isVariable,\n originalElement._index,\n originalElement._fileInfo\n );\n }\n replacementParen = new Paren(new Selector(insideParent));\n }\n return replacementParen;\n }\n\n function createSelector(containedElement, originalElement) {\n let element, selector;\n element = new Element(null, containedElement, originalElement.isVariable, originalElement._index, originalElement._fileInfo);\n selector = new Selector([element]);\n return selector;\n }\n\n // joins selector path from `beginningPath` with selector path in `addPath`\n // `replacedElement` contains element that is being replaced by `addPath`\n // returns concatenated path\n function addReplacementIntoPath(beginningPath, addPath, replacedElement, originalSelector) {\n let newSelectorPath, lastSelector, newJoinedSelector;\n // our new selector path\n newSelectorPath = [];\n\n // construct the joined selector - if & is the first thing this will be empty,\n // if not newJoinedSelector will be the last set of elements in the selector\n if (beginningPath.length > 0) {\n newSelectorPath = utils.copyArray(beginningPath);\n lastSelector = newSelectorPath.pop();\n newJoinedSelector = originalSelector.createDerived(utils.copyArray(lastSelector.elements));\n }\n else {\n newJoinedSelector = originalSelector.createDerived([]);\n }\n\n if (addPath.length > 0) {\n // /deep/ is a CSS4 selector - (removed, so should deprecate)\n // that is valid without anything in front of it\n // so if the & does not have a combinator that is \"\" or \" \" then\n // and there is a combinator on the parent, then grab that.\n // this also allows + a { & .b { .a & { ... though not sure why you would want to do that\n let combinator = replacedElement.combinator;\n\n const parentEl = addPath[0].elements[0];\n if (combinator.emptyOrWhitespace && !parentEl.combinator.emptyOrWhitespace) {\n combinator = parentEl.combinator;\n }\n // join the elements so far with the first part of the parent\n newJoinedSelector.elements.push(new Element(\n combinator,\n parentEl.value,\n replacedElement.isVariable,\n replacedElement._index,\n replacedElement._fileInfo\n ));\n newJoinedSelector.elements = newJoinedSelector.elements.concat(addPath[0].elements.slice(1));\n }\n\n // now add the joined selector - but only if it is not empty\n if (newJoinedSelector.elements.length !== 0) {\n newSelectorPath.push(newJoinedSelector);\n }\n\n // put together the parent selectors after the join (e.g. the rest of the parent)\n if (addPath.length > 1) {\n let restOfPath = addPath.slice(1);\n restOfPath = restOfPath.map(function (selector) {\n return selector.createDerived(selector.elements, []);\n });\n newSelectorPath = newSelectorPath.concat(restOfPath);\n }\n return newSelectorPath;\n }\n\n // joins selector path from `beginningPath` with every selector path in `addPaths` array\n // `replacedElement` contains element that is being replaced by `addPath`\n // returns array with all concatenated paths\n function addAllReplacementsIntoPath( beginningPath, addPaths, replacedElement, originalSelector, result) {\n let j;\n for (j = 0; j < beginningPath.length; j++) {\n const newSelectorPath = addReplacementIntoPath(beginningPath[j], addPaths, replacedElement, originalSelector);\n result.push(newSelectorPath);\n }\n return result;\n }\n\n function mergeElementsOnToSelectors(elements, selectors) {\n let i, sel;\n\n if (elements.length === 0) {\n return ;\n }\n if (selectors.length === 0) {\n selectors.push([ new Selector(elements) ]);\n return;\n }\n\n for (i = 0; (sel = selectors[i]); i++) {\n // if the previous thing in sel is a parent this needs to join on to it\n if (sel.length > 0) {\n sel[sel.length - 1] = sel[sel.length - 1].createDerived(sel[sel.length - 1].elements.concat(elements));\n }\n else {\n sel.push(new Selector(elements));\n }\n }\n }\n\n // replace all parent selectors inside `inSelector` by content of `context` array\n // resulting selectors are returned inside `paths` array\n // returns true if `inSelector` contained at least one parent selector\n function replaceParentSelector(paths, context, inSelector) {\n // The paths are [[Selector]]\n // The first list is a list of comma separated selectors\n // The inner list is a list of inheritance separated selectors\n // e.g.\n // .a, .b {\n // .c {\n // }\n // }\n // == [[.a] [.c]] [[.b] [.c]]\n //\n let i, j, k, currentElements, newSelectors, selectorsMultiplied, sel, el, hadParentSelector = false, length, lastSelector;\n function findNestedSelector(element) {\n let maybeSelector;\n if (!(element.value instanceof Paren)) {\n return null;\n }\n\n maybeSelector = element.value.value;\n if (!(maybeSelector instanceof Selector)) {\n return null;\n }\n\n return maybeSelector;\n }\n\n // the elements from the current selector so far\n currentElements = [];\n // the current list of new selectors to add to the path.\n // We will build it up. We initiate it with one empty selector as we \"multiply\" the new selectors\n // by the parents\n newSelectors = [\n []\n ];\n\n for (i = 0; (el = inSelector.elements[i]); i++) {\n // non parent reference elements just get added\n if (el.value !== '&') {\n const nestedSelector = findNestedSelector(el);\n if (nestedSelector !== null) {\n // merge the current list of non parent selector elements\n // on to the current list of selectors to add\n mergeElementsOnToSelectors(currentElements, newSelectors);\n\n const nestedPaths = [];\n let replaced;\n const replacedNewSelectors = [];\n replaced = replaceParentSelector(nestedPaths, context, nestedSelector);\n hadParentSelector = hadParentSelector || replaced;\n // the nestedPaths array should have only one member - replaceParentSelector does not multiply selectors\n for (k = 0; k < nestedPaths.length; k++) {\n const replacementSelector = createSelector(createParenthesis(nestedPaths[k], el), el);\n addAllReplacementsIntoPath(newSelectors, [replacementSelector], el, inSelector, replacedNewSelectors);\n }\n newSelectors = replacedNewSelectors;\n currentElements = [];\n } else {\n currentElements.push(el);\n }\n\n } else {\n hadParentSelector = true;\n // the new list of selectors to add\n selectorsMultiplied = [];\n\n // merge the current list of non parent selector elements\n // on to the current list of selectors to add\n mergeElementsOnToSelectors(currentElements, newSelectors);\n\n // loop through our current selectors\n for (j = 0; j < newSelectors.length; j++) {\n sel = newSelectors[j];\n // if we don't have any parent paths, the & might be in a mixin so that it can be used\n // whether there are parents or not\n if (context.length === 0) {\n // the combinator used on el should now be applied to the next element instead so that\n // it is not lost\n if (sel.length > 0) {\n sel[0].elements.push(new Element(el.combinator, '', el.isVariable, el._index, el._fileInfo));\n }\n selectorsMultiplied.push(sel);\n }\n else {\n // and the parent selectors\n for (k = 0; k < context.length; k++) {\n // We need to put the current selectors\n // then join the last selector's elements on to the parents selectors\n const newSelectorPath = addReplacementIntoPath(sel, context[k], el, inSelector);\n // add that to our new set of selectors\n selectorsMultiplied.push(newSelectorPath);\n }\n }\n }\n\n // our new selectors has been multiplied, so reset the state\n newSelectors = selectorsMultiplied;\n currentElements = [];\n }\n }\n\n // if we have any elements left over (e.g. .a& .b == .b)\n // add them on to all the current selectors\n mergeElementsOnToSelectors(currentElements, newSelectors);\n\n for (i = 0; i < newSelectors.length; i++) {\n length = newSelectors[i].length;\n if (length > 0) {\n paths.push(newSelectors[i]);\n lastSelector = newSelectors[i][length - 1];\n newSelectors[i][length - 1] = lastSelector.createDerived(lastSelector.elements, inSelector.extendList);\n }\n }\n\n return hadParentSelector;\n }\n\n function deriveSelector(visibilityInfo, deriveFrom) {\n const newSelector = deriveFrom.createDerived(deriveFrom.elements, deriveFrom.extendList, deriveFrom.evaldCondition);\n newSelector.copyVisibilityInfo(visibilityInfo);\n return newSelector;\n }\n\n // joinSelector code follows\n let i, newPaths, hadParentSelector;\n\n newPaths = [];\n hadParentSelector = replaceParentSelector(newPaths, context, selector);\n\n if (!hadParentSelector) {\n if (context.length > 0) {\n newPaths = [];\n for (i = 0; i < context.length; i++) {\n\n const concatenated = context[i].map(deriveSelector.bind(this, selector.visibilityInfo()));\n\n concatenated.push(selector);\n newPaths.push(concatenated);\n }\n }\n else {\n newPaths = [[selector]];\n }\n }\n\n for (i = 0; i < newPaths.length; i++) {\n paths.push(newPaths[i]);\n }\n\n }\n});\n\nexport default Ruleset;\n"]} |
| {"version":3,"file":"selector.js","sourceRoot":"","sources":["../../../src/less/tree/selector.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,8DAAgC;AAChC,qEAAsC;AACtC,sDAAkC;AAClC,oEAAsC;AAEtC,IAAM,QAAQ,GAAG,UAAS,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,cAAc;IAC7F,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC3B,IAAI,CAAC,cAAc,GAAG,CAAC,SAAS,CAAC;IACjC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACpB,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC;IACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CA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G,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;SACrD;QACD,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACvC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC3B,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;SACnC;IACL,CAAC;IAED,WAAW;QACP,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,QAAQ,CAAC","sourcesContent":["import Node from './node';\nimport Element from './element';\nimport LessError from '../less-error';\nimport * as utils from '../utils';\nimport Parser from '../parser/parser';\n\nconst Selector = function(elements, extendList, condition, index, currentFileInfo, visibilityInfo) {\n this.extendList = extendList;\n this.condition = condition;\n this.evaldCondition = !condition;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.elements = this.getElements(elements);\n this.mixinElements_ = undefined;\n this.copyVisibilityInfo(visibilityInfo);\n this.setParent(this.elements, this);\n};\n\nSelector.prototype = Object.assign(new Node(), {\n type: 'Selector',\n\n accept(visitor) {\n if (this.elements) {\n this.elements = visitor.visitArray(this.elements);\n }\n if (this.extendList) {\n this.extendList = visitor.visitArray(this.extendList);\n }\n if (this.condition) {\n this.condition = visitor.visit(this.condition);\n }\n },\n\n createDerived(elements, extendList, evaldCondition) {\n elements = this.getElements(elements);\n const newSelector = new Selector(elements, extendList || this.extendList,\n null, this.getIndex(), this.fileInfo(), this.visibilityInfo());\n newSelector.evaldCondition = (!utils.isNullOrUndefined(evaldCondition)) ? evaldCondition : this.evaldCondition;\n newSelector.mediaEmpty = this.mediaEmpty;\n return newSelector;\n },\n\n getElements(els) {\n if (!els) {\n return [new Element('', '&', false, this._index, this._fileInfo)];\n }\n if (typeof els === 'string') {\n new Parser(this.parse.context, this.parse.importManager, this._fileInfo, this._index).parseNode(\n els,\n ['selector'],\n function(err, result) {\n if (err) {\n throw new LessError({\n index: err.index,\n message: err.message\n }, this.parse.imports, this._fileInfo.filename);\n }\n els = result[0].elements;\n });\n }\n return els;\n },\n\n createEmptySelectors() {\n const el = new Element('', '&', false, this._index, this._fileInfo), sels = [new Selector([el], null, null, this._index, this._fileInfo)];\n sels[0].mediaEmpty = true;\n return sels;\n },\n\n match(other) {\n const elements = this.elements;\n const len = elements.length;\n let olen;\n let i;\n\n other = other.mixinElements();\n olen = other.length;\n if (olen === 0 || len < olen) {\n return 0;\n } else {\n for (i = 0; i < olen; i++) {\n if (elements[i].value !== other[i]) {\n return 0;\n }\n }\n }\n\n return olen; // return number of matched elements\n },\n\n mixinElements() {\n if (this.mixinElements_) {\n return this.mixinElements_;\n }\n\n let elements = this.elements.map( function(v) {\n return v.combinator.value + (v.value.value || v.value);\n }).join('').match(/[,&#*.\\w-]([\\w-]|(\\\\.))*/g);\n\n if (elements) {\n if (elements[0] === '&') {\n elements.shift();\n }\n } else {\n elements = [];\n }\n\n return (this.mixinElements_ = elements);\n },\n\n isJustParentSelector() {\n return !this.mediaEmpty &&\n this.elements.length === 1 &&\n this.elements[0].value === '&' &&\n (this.elements[0].combinator.value === ' ' || this.elements[0].combinator.value === '');\n },\n\n eval(context) {\n const evaldCondition = this.condition && this.condition.eval(context);\n let elements = this.elements;\n let extendList = this.extendList;\n\n elements = elements && elements.map(function (e) { return e.eval(context); });\n extendList = extendList && extendList.map(function(extend) { return extend.eval(context); });\n\n return this.createDerived(elements, extendList, evaldCondition);\n },\n\n genCSS(context, output) {\n let i, element;\n if ((!context || !context.firstSelector) && this.elements[0].combinator.value === '') {\n output.add(' ', this.fileInfo(), this.getIndex());\n }\n for (i = 0; i < this.elements.length; i++) {\n element = this.elements[i];\n element.genCSS(context, output);\n }\n },\n\n getIsOutput() {\n return this.evaldCondition;\n }\n});\n\nexport default Selector;\n"]} |
| {"version":3,"file":"unicode-descriptor.js","sourceRoot":"","sources":["../../../src/less/tree/unicode-descriptor.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAE1B,IAAM,iBAAiB,GAAG,UAAS,KAAK;IACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AACvB,CAAC,CAAA;AAED,iBAAiB,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IACpD,IAAI,EAAE,mBAAmB;CAC5B,CAAC,CAAA;AAEF,kBAAe,iBAAiB,CAAC","sourcesContent":["import Node from './node';\n\nconst UnicodeDescriptor = function(value) {\n this.value = value;\n}\n\nUnicodeDescriptor.prototype = Object.assign(new Node(), {\n type: 'UnicodeDescriptor'\n})\n\nexport default UnicodeDescriptor;\n"]} |
| {"version":3,"file":"unit.js","sourceRoot":"","sources":["../../../src/less/tree/unit.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,sFAAuD;AACvD,sDAAkC;AAElC,IAAM,IAAI,GAAG,UAAS,SAAS,EAAE,WAAW,EAAE,UAAU;IACpD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACpE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,IAAI,UAAU,EAAE;QACZ,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;KAChC;SAAM,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,EAAE;QACtC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;KAClC;AACL,CAAC,CAAC;AAEF,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IACvC,IAAI,EAAE,MAAM;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M,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;gBAElC,IAAI,KAAK,GAAG,CAAC,EAAE;oBACX,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;wBACxB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;qBACnC;iBACJ;qBAAM,IAAI,KAAK,GAAG,CAAC,EAAE;oBAClB,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;wBACzB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;qBACrC;iBACJ;aACJ;SACJ;QAED,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,IAAI,CAAC","sourcesContent":["import Node from './node';\nimport unitConversions from '../data/unit-conversions';\nimport * as utils from '../utils';\n\nconst Unit = function(numerator, denominator, backupUnit) {\n this.numerator = numerator ? utils.copyArray(numerator).sort() : [];\n this.denominator = denominator ? utils.copyArray(denominator).sort() : [];\n if (backupUnit) {\n this.backupUnit = backupUnit;\n } else if (numerator && numerator.length) {\n this.backupUnit = numerator[0];\n }\n};\n\nUnit.prototype = Object.assign(new Node(), {\n type: 'Unit',\n\n clone() {\n return new Unit(utils.copyArray(this.numerator), utils.copyArray(this.denominator), this.backupUnit);\n },\n\n genCSS(context, output) {\n // Dimension checks the unit is singular and throws an error if in strict math mode.\n const strictUnits = context && context.strictUnits;\n if (this.numerator.length === 1) {\n output.add(this.numerator[0]); // the ideal situation\n } else if (!strictUnits && this.backupUnit) {\n output.add(this.backupUnit);\n } else if (!strictUnits && this.denominator.length) {\n output.add(this.denominator[0]);\n }\n },\n\n toString() {\n let i, returnStr = this.numerator.join('*');\n for (i = 0; i < this.denominator.length; i++) {\n returnStr += `/${this.denominator[i]}`;\n }\n return returnStr;\n },\n\n compare(other) {\n return this.is(other.toString()) ? 0 : undefined;\n },\n\n is(unitString) {\n return this.toString().toUpperCase() === unitString.toUpperCase();\n },\n\n isLength() {\n return RegExp('^(px|em|ex|ch|rem|in|cm|mm|pc|pt|ex|vw|vh|vmin|vmax)$', 'gi').test(this.toCSS());\n },\n\n isEmpty() {\n return this.numerator.length === 0 && this.denominator.length === 0;\n },\n\n isSingular() {\n return this.numerator.length <= 1 && this.denominator.length === 0;\n },\n\n map(callback) {\n let i;\n\n for (i = 0; i < this.numerator.length; i++) {\n this.numerator[i] = callback(this.numerator[i], false);\n }\n\n for (i = 0; i < this.denominator.length; i++) {\n this.denominator[i] = callback(this.denominator[i], true);\n }\n },\n\n usedUnits() {\n let group;\n const result = {};\n let mapUnit;\n let groupName;\n\n mapUnit = function (atomicUnit) {\n // eslint-disable-next-line no-prototype-builtins\n if (group.hasOwnProperty(atomicUnit) && !result[groupName]) {\n result[groupName] = atomicUnit;\n }\n\n return atomicUnit;\n };\n\n for (groupName in unitConversions) {\n // eslint-disable-next-line no-prototype-builtins\n if (unitConversions.hasOwnProperty(groupName)) {\n group = unitConversions[groupName];\n\n this.map(mapUnit);\n }\n }\n\n return result;\n },\n\n cancel() {\n const counter = {};\n let atomicUnit;\n let i;\n\n for (i = 0; i < this.numerator.length; i++) {\n atomicUnit = this.numerator[i];\n counter[atomicUnit] = (counter[atomicUnit] || 0) + 1;\n }\n\n for (i = 0; i < this.denominator.length; i++) {\n atomicUnit = this.denominator[i];\n counter[atomicUnit] = (counter[atomicUnit] || 0) - 1;\n }\n\n this.numerator = [];\n this.denominator = [];\n\n for (atomicUnit in counter) {\n // eslint-disable-next-line no-prototype-builtins\n if (counter.hasOwnProperty(atomicUnit)) {\n const count = counter[atomicUnit];\n\n if (count > 0) {\n for (i = 0; i < count; i++) {\n this.numerator.push(atomicUnit);\n }\n } else if (count < 0) {\n for (i = 0; i < -count; i++) {\n this.denominator.push(atomicUnit);\n }\n }\n }\n }\n\n this.numerator.sort();\n this.denominator.sort();\n }\n});\n\nexport default Unit;\n"]} |
| {"version":3,"file":"url.js","sourceRoot":"","sources":["../../../src/less/tree/url.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAE1B,SAAS,UAAU,CAAC,IAAI;IACpB,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,UAAS,KAAK,IAAI,OAAO,YAAK,KAAK,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,IAAM,GAAG,GAAG,UAAS,GAAG,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO;IACrD,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;IACjB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACpB,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC;IACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AAC3B,CAAC,CAAC;AAEF,GAAG,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IACtC,IAAI,EAAE,KAAK;IAEX,MAAM,YAAC,OAAO;QACV,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,YAAC,OAAO,EAAE,MAAM;QAClB,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACnB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACnC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IAED,IAAI,YAAC,OAAO;QACR,IAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,QAAQ,CAAC;QAEb,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACf,iDAAiD;YACjD,QAAQ,GAAG,IAAI,CAA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AE,IAAI,CAAC,CAAC;IAChE,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,GAAG,CAAC","sourcesContent":["import Node from './node';\n\nfunction escapePath(path) {\n return path.replace(/[()'\"\\s]/g, function(match) { return `\\\\${match}`; });\n}\n\nconst URL = function(val, index, currentFileInfo, isEvald) {\n this.value = val;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.isEvald = isEvald;\n};\n\nURL.prototype = Object.assign(new Node(), {\n type: 'Url',\n\n accept(visitor) {\n this.value = visitor.visit(this.value);\n },\n\n genCSS(context, output) {\n output.add('url(');\n this.value.genCSS(context, output);\n output.add(')');\n },\n\n eval(context) {\n const val = this.value.eval(context);\n let rootpath;\n\n if (!this.isEvald) {\n // Add the rootpath if the URL requires a rewrite\n rootpath = this.fileInfo() && this.fileInfo().rootpath;\n if (typeof rootpath === 'string' &&\n typeof val.value === 'string' &&\n context.pathRequiresRewrite(val.value)) {\n if (!val.quote) {\n rootpath = escapePath(rootpath);\n }\n val.value = context.rewritePath(val.value, rootpath);\n } else {\n val.value = context.normalizePath(val.value);\n }\n\n // Add url args if enabled\n if (context.urlArgs) {\n if (!val.value.match(/^\\s*data:/)) {\n const delimiter = val.value.indexOf('?') === -1 ? '?' : '&';\n const urlArgs = delimiter + context.urlArgs;\n if (val.value.indexOf('#') !== -1) {\n val.value = val.value.replace('#', `${urlArgs}#`);\n } else {\n val.value += urlArgs;\n }\n }\n }\n }\n\n return new URL(val, this.getIndex(), this.fileInfo(), true);\n }\n});\n\nexport default URL;\n"]} |
| {"version":3,"file":"value.js","sourceRoot":"","sources":["../../../src/less/tree/value.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAE1B,IAAM,KAAK,GAAG,UAAS,KAAK;IACxB,IAAI,CAAC,KAAK,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;KACvD;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACvB,IAAI,CAAC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C;AAEH,kBAAe,KAAK,CAAC","sourcesContent":["import Node from './node';\n\nconst Value = function(value) {\n if (!value) {\n throw new Error('Value requires an array argument');\n }\n if (!Array.isArray(value)) {\n this.value = [ value ];\n }\n else {\n this.value = value;\n }\n};\n\nValue.prototype = Object.assign(new Node(), {\n type: 'Value',\n\n accept(visitor) {\n if (this.value) {\n this.value = visitor.visitArray(this.value);\n }\n },\n\n eval(context) {\n if (this.value.length === 1) {\n return this.value[0].eval(context);\n } else {\n return new Value(this.value.map(function (v) {\n return v.eval(context);\n }));\n }\n },\n\n genCSS(context, output) {\n let i;\n for (i = 0; i < this.value.length; i++) {\n this.value[i].genCSS(context, output);\n if (i + 1 < this.value.length) {\n output.add((context && context.compress) ? ',' : ', ');\n }\n }\n }\n});\n\nexport default Value;\n"]} |
| {"version":3,"file":"variable-call.js","sourceRoot":"","sources":["../../../src/less/tree/variable-call.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,gEAAkC;AAClC,8DAAgC;AAChC,gFAAiD;AACjD,qEAAsC;AAEtC,IAAM,YAAY,GAAG,UAAS,QAAQ,EAAE,KAAK,EAAE,eAAe;IAC1D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACpB,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC;IACjC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;AAC1B,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAC/C,IAAI,EAAE,cAAc;IAEpB,IAAI,YAAC,OAAO;QACR,IAAI,KAAK,CAAC;QACV,IAAI,eAAe,GAAG,IAAI,kBAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClG,IAAM,KAAK,GAAG,IAAI,oBAAS,CAAC,EAAC,OAAO,EAAE,2CAAoC,IAAI,CAAC,QAAQ,CAAE,EAAC,CAAC,CAAC;QAE5F,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE;YAC1B,IAAI,eAAe,CAAC,KAAK,EAAE;gBACvB,KAAK,GAAG,eAAe,CAAC;aAC3B;iBACI,IAAI,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;gBACrC,KAAK,GAAG,IAAI,iBAAO,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;aAC5C;iBACI,IAAI,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE;gBAC3C,KAAK,GAAG,IAAI,iBAAO,CAAC,EAAE,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;aAClD;iBACI;gBACD,MAAM,KAAK,CAAC;aACf;YACD,eAAe,GAAG,IAAI,0BAAe,CAAC,KAAK,CAAC,CAAC;SAChD;QAED,IAAI,eAAe,CAAC,OAAO,EAAE;YACzB,OAAO,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;SAC5C;QACD,MAAM,KAAK,CAAC;IAChB,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,YAAY,CAAC","sourcesContent":["import Node from './node';\nimport Variable from './variable';\nimport Ruleset from './ruleset';\nimport DetachedRuleset from './detached-ruleset';\nimport LessError from '../less-error';\n\nconst VariableCall = function(variable, index, currentFileInfo) {\n this.variable = variable;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.allowRoot = true;\n};\n\nVariableCall.prototype = Object.assign(new Node(), {\n type: 'VariableCall',\n\n eval(context) {\n let rules;\n let detachedRuleset = new Variable(this.variable, this.getIndex(), this.fileInfo()).eval(context);\n const error = new LessError({message: `Could not evaluate variable call ${this.variable}`});\n\n if (!detachedRuleset.ruleset) {\n if (detachedRuleset.rules) {\n rules = detachedRuleset;\n }\n else if (Array.isArray(detachedRuleset)) {\n rules = new Ruleset('', detachedRuleset);\n }\n else if (Array.isArray(detachedRuleset.value)) {\n rules = new Ruleset('', detachedRuleset.value);\n }\n else {\n throw error;\n }\n detachedRuleset = new DetachedRuleset(rules);\n }\n\n if (detachedRuleset.ruleset) {\n return detachedRuleset.callEval(context);\n }\n throw error;\n }\n});\n\nexport default VariableCall;\n"]} |
| {"version":3,"file":"variable.js","sourceRoot":"","sources":["../../../src/less/tree/variable.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,wDAA0B;AAE1B,IAAM,QAAQ,GAAG,UAAS,IAAI,EAAE,KAAK,EAAE,eAAe;IAClD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACpB,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC;AACrC,CAAC,CAAC;AAEF,QAAQ,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAC3C,IAAI,EAAE,UAAU;IAEhB,IAAI,YAAC,OAAO;QACR,IAAI,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAE/B,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YAC1B,IAAI,GAAG,WAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAE,CAAC;SAClG;QAED,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,MAAM,EAAE,IAAI,EAAE,MAAM;gBAChB,OAAO,EAAE,4CAAqC,IAAI,CAAE;gBACpD,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ;gBAClC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;SAChC;QAED,IAAI,CAAC,UAAU,GAAG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YAC1B,IAAI,CAAC,EAAE;gBAAE,OAAO,CAAC,CAAC;aAAE;SACvB;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,QAAQ,CAAC","sourcesContent":["import Node from './node';\nimport Call from './call';\n\nconst Variable = function(name, index, currentFileInfo) {\n this.name = name;\n this._index = index;\n this._fileInfo = currentFileInfo;\n};\n\nVariable.prototype = Object.assign(new Node(), {\n type: 'Variable',\n\n eval(context) {\n let variable, name = this.name;\n\n if (name.indexOf('@@') === 0) {\n name = `@${new Variable(name.slice(1), this.getIndex(), this.fileInfo()).eval(context).value}`;\n }\n\n if (this.evaluating) {\n throw { type: 'Name',\n message: `Recursive variable definition for ${name}`,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n\n this.evaluating = true;\n\n variable = this.find(context.frames, function (frame) {\n const v = frame.variable(name);\n if (v) {\n if (v.important) {\n const importantScope = context.importantScope[context.importantScope.length - 1];\n importantScope.important = v.important;\n }\n // If in calc, wrap vars in a function call to cascade evaluate args first\n if (context.inCalc) {\n return (new Call('_SELF', [v.value])).eval(context);\n }\n else {\n return v.value.eval(context);\n }\n }\n });\n if (variable) {\n this.evaluating = false;\n return variable;\n } else {\n throw { type: 'Name',\n message: `variable ${name} is undefined`,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n },\n\n find(obj, fun) {\n for (let i = 0, r; i < obj.length; i++) {\n r = fun.call(obj, obj[i]);\n if (r) { return r; }\n }\n return null;\n }\n});\n\nexport default Variable;\n"]} |
| {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/less/utils.js"],"names":[],"mappings":";;;;AAAA,wBAAwB;AACxB,6DAAyC;AACzC,+CAAqC;AAErC,SAAgB,WAAW,CAAC,KAAK,EAAE,WAAW;IAC1C,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;IAClB,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,IAAI,MAAM,GAAG,CAAC,CAAC,C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rB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACtB;SACJ;KACJ;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAZD,oCAYC;AAED,SAAgB,iBAAiB,CAAC,GAAG;IACjC,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,CAAA;AAC5C,CAAC;AAFD,8CAEC","sourcesContent":["/* jshint proto: true */\nimport * as Constants from './constants';\nimport { copy } from 'copy-anything';\n\nexport function getLocation(index, inputStream) {\n let n = index + 1;\n let line = null;\n let column = -1;\n\n while (--n >= 0 && inputStream.charAt(n) !== '\\n') {\n column++;\n }\n\n if (typeof index === 'number') {\n line = (inputStream.slice(0, index).match(/\\n/g) || '').length;\n }\n\n return {\n line,\n column\n };\n}\n\nexport function copyArray(arr) {\n let i;\n const length = arr.length;\n const copy = new Array(length);\n\n for (i = 0; i < length; i++) {\n copy[i] = arr[i];\n }\n return copy;\n}\n\nexport function clone(obj) {\n const cloned = {};\n for (const prop in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, prop)) {\n cloned[prop] = obj[prop];\n }\n }\n return cloned;\n}\n\nexport function defaults(obj1, obj2) {\n let newObj = obj2 || {};\n if (!obj2._defaults) {\n newObj = {};\n const defaults = copy(obj1);\n newObj._defaults = defaults;\n const cloned = obj2 ? copy(obj2) : {};\n Object.assign(newObj, defaults, cloned);\n }\n return newObj;\n}\n\nexport function copyOptions(obj1, obj2) {\n if (obj2 && obj2._defaults) {\n return obj2;\n }\n const opts = defaults(obj1, obj2);\n if (opts.strictMath) {\n opts.math = Constants.Math.PARENS;\n }\n // Back compat with changed relativeUrls option\n if (opts.relativeUrls) {\n opts.rewriteUrls = Constants.RewriteUrls.ALL;\n }\n if (typeof opts.math === 'string') {\n switch (opts.math.toLowerCase()) {\n case 'always':\n opts.math = Constants.Math.ALWAYS;\n break;\n case 'parens-division':\n opts.math = Constants.Math.PARENS_DIVISION;\n break;\n case 'strict':\n case 'parens':\n opts.math = Constants.Math.PARENS;\n break;\n default:\n opts.math = Constants.Math.PARENS;\n }\n }\n if (typeof opts.rewriteUrls === 'string') {\n switch (opts.rewriteUrls.toLowerCase()) {\n case 'off':\n opts.rewriteUrls = Constants.RewriteUrls.OFF;\n break;\n case 'local':\n opts.rewriteUrls = Constants.RewriteUrls.LOCAL;\n break;\n case 'all':\n opts.rewriteUrls = Constants.RewriteUrls.ALL;\n break;\n }\n }\n return opts;\n}\n\nexport function merge(obj1, obj2) {\n for (const prop in obj2) {\n if (Object.prototype.hasOwnProperty.call(obj2, prop)) {\n obj1[prop] = obj2[prop];\n }\n }\n return obj1;\n}\n\nexport function flattenArray(arr, result = []) {\n for (let i = 0, length = arr.length; i < length; i++) {\n const value = arr[i];\n if (Array.isArray(value)) {\n flattenArray(value, result);\n } else {\n if (value !== undefined) {\n result.push(value);\n }\n }\n }\n return result;\n}\n\nexport function isNullOrUndefined(val) {\n return val === null || val === undefined\n}"]} |
| {"version":3,"file":"extend-visitor.js","sourceRoot":"","sources":["../../../src/less/visitors/extend-visitor.js"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC;;GAEG;AACH,yDAA2B;AAC3B,8DAAgC;AAChC,6DAA+B;AAC/B,sDAAkC;AAElC,0BAA0B;AAE1B;IACI;QACI,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAO,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,eAAe,GAAG,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC;IAED,iCAAG,GAAH,UAAI,IAAI;QACJ,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,8CAAgB,GAAhB,UAAiB,QAAQ,EAAE,SAAS;QAChC,SAAS,CAAC,W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C,CAAC;IAED,2CAAW,GAAX,UAAY,UAAU,EAAE,SAAS;QAC7B,IAAI,aAAa,GAAG,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QACxG,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;QAClG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC;IAED,8CAAc,GAAd,UAAe,UAAU;QACrB,IAAM,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;QAClD,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,SAAS,CAAC;IAC5C,CAAC;IACL,4BAAC;AAAD,CAAC,AA/YD,IA+YC;AAED,kBAAe,qBAAqB,CAAC","sourcesContent":["/* eslint-disable no-unused-vars */\n/**\n * @todo - Remove unused when JSDoc types are added for visitor methods\n */\nimport tree from '../tree';\nimport Visitor from './visitor';\nimport logger from '../logger';\nimport * as utils from '../utils';\n\n/* jshint loopfunc:true */\n\nclass ExtendFinderVisitor {\n constructor() {\n this._visitor = new Visitor(this);\n this.contexts = [];\n this.allExtendsStack = [[]];\n }\n\n run(root) {\n root = this._visitor.visit(root);\n root.allExtends = this.allExtendsStack[0];\n return root;\n }\n\n visitDeclaration(declNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitMixinDefinition(mixinDefinitionNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitRuleset(rulesetNode, visitArgs) {\n if (rulesetNode.root) {\n return;\n }\n\n let i;\n let j;\n let extend;\n const allSelectorsExtendList = [];\n let extendList;\n\n // get &:extend(.a); rules which apply to all selectors in this ruleset\n const rules = rulesetNode.rules, ruleCnt = rules ? rules.length : 0;\n for (i = 0; i < ruleCnt; i++) {\n if (rulesetNode.rules[i] instanceof tree.Extend) {\n allSelectorsExtendList.push(rules[i]);\n rulesetNode.extendOnEveryPath = true;\n }\n }\n\n // now find every selector and apply the extends that apply to all extends\n // and the ones which apply to an individual extend\n const paths = rulesetNode.paths;\n for (i = 0; i < paths.length; i++) {\n const selectorPath = paths[i], selector = selectorPath[selectorPath.length - 1], selExtendList = selector.extendList;\n\n extendList = selExtendList ? utils.copyArray(selExtendList).concat(allSelectorsExtendList)\n : allSelectorsExtendList;\n\n if (extendList) {\n extendList = extendList.map(function(allSelectorsExtend) {\n return allSelectorsExtend.clone();\n });\n }\n\n for (j = 0; j < extendList.length; j++) {\n this.foundExtends = true;\n extend = extendList[j];\n extend.findSelfSelectors(selectorPath);\n extend.ruleset = rulesetNode;\n if (j === 0) { extend.firstExtendOnThisSelectorPath = true; }\n this.allExtendsStack[this.allExtendsStack.length - 1].push(extend);\n }\n }\n\n this.contexts.push(rulesetNode.selectors);\n }\n\n visitRulesetOut(rulesetNode) {\n if (!rulesetNode.root) {\n this.contexts.length = this.contexts.length - 1;\n }\n }\n\n visitMedia(mediaNode, visitArgs) {\n mediaNode.allExtends = [];\n this.allExtendsStack.push(mediaNode.allExtends);\n }\n\n visitMediaOut(mediaNode) {\n this.allExtendsStack.length = this.allExtendsStack.length - 1;\n }\n\n visitAtRule(atRuleNode, visitArgs) {\n atRuleNode.allExtends = [];\n this.allExtendsStack.push(atRuleNode.allExtends);\n }\n\n visitAtRuleOut(atRuleNode) {\n this.allExtendsStack.length = this.allExtendsStack.length - 1;\n }\n}\n\nclass ProcessExtendsVisitor {\n constructor() {\n this._visitor = new Visitor(this);\n }\n\n run(root) {\n const extendFinder = new ExtendFinderVisitor();\n this.extendIndices = {};\n extendFinder.run(root);\n if (!extendFinder.foundExtends) { return root; }\n root.allExtends = root.allExtends.concat(this.doExtendChaining(root.allExtends, root.allExtends));\n this.allExtendsStack = [root.allExtends];\n const newRoot = this._visitor.visit(root);\n this.checkExtendsForNonMatched(root.allExtends);\n return newRoot;\n }\n\n checkExtendsForNonMatched(extendList) {\n const indices = this.extendIndices;\n extendList.filter(function(extend) {\n return !extend.hasFoundMatches && extend.parent_ids.length == 1;\n }).forEach(function(extend) {\n let selector = '_unknown_';\n try {\n selector = extend.selector.toCSS({});\n }\n catch (_) {}\n\n if (!indices[`${extend.index} ${selector}`]) {\n indices[`${extend.index} ${selector}`] = true;\n /**\n * @todo Shouldn't this be an error? To alert the developer\n * that they may have made an error in the selector they are\n * targeting?\n */\n logger.warn(`WARNING: extend '${selector}' has no matches`);\n }\n });\n }\n\n doExtendChaining(extendsList, extendsListTarget, iterationCount) {\n //\n // chaining is different from normal extension.. if we extend an extend then we are not just copying, altering\n // and pasting the selector we would do normally, but we are also adding an extend with the same target selector\n // this means this new extend can then go and alter other extends\n //\n // this method deals with all the chaining work - without it, extend is flat and doesn't work on other extend selectors\n // this is also the most expensive.. and a match on one selector can cause an extension of a selector we had already\n // processed if we look at each selector at a time, as is done in visitRuleset\n\n let extendIndex;\n\n let targetExtendIndex;\n let matches;\n const extendsToAdd = [];\n let newSelector;\n const extendVisitor = this;\n let selectorPath;\n let extend;\n let targetExtend;\n let newExtend;\n\n iterationCount = iterationCount || 0;\n\n // loop through comparing every extend with every target extend.\n // a target extend is the one on the ruleset we are looking at copy/edit/pasting in place\n // e.g. .a:extend(.b) {} and .b:extend(.c) {} then the first extend extends the second one\n // and the second is the target.\n // the separation into two lists allows us to process a subset of chains with a bigger set, as is the\n // case when processing media queries\n for (extendIndex = 0; extendIndex < extendsList.length; extendIndex++) {\n for (targetExtendIndex = 0; targetExtendIndex < extendsListTarget.length; targetExtendIndex++) {\n\n extend = extendsList[extendIndex];\n targetExtend = extendsListTarget[targetExtendIndex];\n\n // look for circular references\n if ( extend.parent_ids.indexOf( targetExtend.object_id ) >= 0 ) { continue; }\n\n // find a match in the target extends self selector (the bit before :extend)\n selectorPath = [targetExtend.selfSelectors[0]];\n matches = extendVisitor.findMatch(extend, selectorPath);\n\n if (matches.length) {\n extend.hasFoundMatches = true;\n\n // we found a match, so for each self selector..\n extend.selfSelectors.forEach(function(selfSelector) {\n const info = targetExtend.visibilityInfo();\n\n // process the extend as usual\n newSelector = extendVisitor.extendSelector(matches, selectorPath, selfSelector, extend.isVisible());\n\n // but now we create a new extend from it\n newExtend = new(tree.Extend)(targetExtend.selector, targetExtend.option, 0, targetExtend.fileInfo(), info);\n newExtend.selfSelectors = newSelector;\n\n // add the extend onto the list of extends for that selector\n newSelector[newSelector.length - 1].extendList = [newExtend];\n\n // record that we need to add it.\n extendsToAdd.push(newExtend);\n newExtend.ruleset = targetExtend.ruleset;\n\n // remember its parents for circular references\n newExtend.parent_ids = newExtend.parent_ids.concat(targetExtend.parent_ids, extend.parent_ids);\n\n // only process the selector once.. if we have :extend(.a,.b) then multiple\n // extends will look at the same selector path, so when extending\n // we know that any others will be duplicates in terms of what is added to the css\n if (targetExtend.firstExtendOnThisSelectorPath) {\n newExtend.firstExtendOnThisSelectorPath = true;\n targetExtend.ruleset.paths.push(newSelector);\n }\n });\n }\n }\n }\n\n if (extendsToAdd.length) {\n // try to detect circular references to stop a stack overflow.\n // may no longer be needed.\n this.extendChainCount++;\n if (iterationCount > 100) {\n let selectorOne = '{unable to calculate}';\n let selectorTwo = '{unable to calculate}';\n try {\n selectorOne = extendsToAdd[0].selfSelectors[0].toCSS();\n selectorTwo = extendsToAdd[0].selector.toCSS();\n }\n catch (e) {}\n throw { message: `extend circular reference detected. One of the circular extends is currently:${selectorOne}:extend(${selectorTwo})`};\n }\n\n // now process the new extends on the existing rules so that we can handle a extending b extending c extending\n // d extending e...\n return extendsToAdd.concat(extendVisitor.doExtendChaining(extendsToAdd, extendsListTarget, iterationCount + 1));\n } else {\n return extendsToAdd;\n }\n }\n\n visitDeclaration(ruleNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitMixinDefinition(mixinDefinitionNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitSelector(selectorNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitRuleset(rulesetNode, visitArgs) {\n if (rulesetNode.root) {\n return;\n }\n let matches;\n let pathIndex;\n let extendIndex;\n const allExtends = this.allExtendsStack[this.allExtendsStack.length - 1];\n const selectorsToAdd = [];\n const extendVisitor = this;\n let selectorPath;\n\n // look at each selector path in the ruleset, find any extend matches and then copy, find and replace\n\n for (extendIndex = 0; extendIndex < allExtends.length; extendIndex++) {\n for (pathIndex = 0; pathIndex < rulesetNode.paths.length; pathIndex++) {\n selectorPath = rulesetNode.paths[pathIndex];\n\n // extending extends happens initially, before the main pass\n if (rulesetNode.extendOnEveryPath) { continue; }\n const extendList = selectorPath[selectorPath.length - 1].extendList;\n if (extendList && extendList.length) { continue; }\n\n matches = this.findMatch(allExtends[extendIndex], selectorPath);\n\n if (matches.length) {\n allExtends[extendIndex].hasFoundMatches = true;\n\n allExtends[extendIndex].selfSelectors.forEach(function(selfSelector) {\n let extendedSelectors;\n extendedSelectors = extendVisitor.extendSelector(matches, selectorPath, selfSelector, allExtends[extendIndex].isVisible());\n selectorsToAdd.push(extendedSelectors);\n });\n }\n }\n }\n rulesetNode.paths = rulesetNode.paths.concat(selectorsToAdd);\n }\n\n findMatch(extend, haystackSelectorPath) {\n //\n // look through the haystack selector path to try and find the needle - extend.selector\n // returns an array of selector matches that can then be replaced\n //\n let haystackSelectorIndex;\n\n let hackstackSelector;\n let hackstackElementIndex;\n let haystackElement;\n let targetCombinator;\n let i;\n const extendVisitor = this;\n const needleElements = extend.selector.elements;\n const potentialMatches = [];\n let potentialMatch;\n const matches = [];\n\n // loop through the haystack elements\n for (haystackSelectorIndex = 0; haystackSelectorIndex < haystackSelectorPath.length; haystackSelectorIndex++) {\n hackstackSelector = haystackSelectorPath[haystackSelectorIndex];\n\n for (hackstackElementIndex = 0; hackstackElementIndex < hackstackSelector.elements.length; hackstackElementIndex++) {\n\n haystackElement = hackstackSelector.elements[hackstackElementIndex];\n\n // if we allow elements before our match we can add a potential match every time. otherwise only at the first element.\n if (extend.allowBefore || (haystackSelectorIndex === 0 && hackstackElementIndex === 0)) {\n potentialMatches.push({pathIndex: haystackSelectorIndex, index: hackstackElementIndex, matched: 0,\n initialCombinator: haystackElement.combinator});\n }\n\n for (i = 0; i < potentialMatches.length; i++) {\n potentialMatch = potentialMatches[i];\n\n // selectors add \" \" onto the first element. When we use & it joins the selectors together, but if we don't\n // then each selector in haystackSelectorPath has a space before it added in the toCSS phase. so we need to\n // work out what the resulting combinator will be\n targetCombinator = haystackElement.combinator.value;\n if (targetCombinator === '' && hackstackElementIndex === 0) {\n targetCombinator = ' ';\n }\n\n // if we don't match, null our match to indicate failure\n if (!extendVisitor.isElementValuesEqual(needleElements[potentialMatch.matched].value, haystackElement.value) ||\n (potentialMatch.matched > 0 && needleElements[potentialMatch.matched].combinator.value !== targetCombinator)) {\n potentialMatch = null;\n } else {\n potentialMatch.matched++;\n }\n\n // if we are still valid and have finished, test whether we have elements after and whether these are allowed\n if (potentialMatch) {\n potentialMatch.finished = potentialMatch.matched === needleElements.length;\n if (potentialMatch.finished &&\n (!extend.allowAfter &&\n (hackstackElementIndex + 1 < hackstackSelector.elements.length || haystackSelectorIndex + 1 < haystackSelectorPath.length))) {\n potentialMatch = null;\n }\n }\n // if null we remove, if not, we are still valid, so either push as a valid match or continue\n if (potentialMatch) {\n if (potentialMatch.finished) {\n potentialMatch.length = needleElements.length;\n potentialMatch.endPathIndex = haystackSelectorIndex;\n potentialMatch.endPathElementIndex = hackstackElementIndex + 1; // index after end of match\n potentialMatches.length = 0; // we don't allow matches to overlap, so start matching again\n matches.push(potentialMatch);\n }\n } else {\n potentialMatches.splice(i, 1);\n i--;\n }\n }\n }\n }\n return matches;\n }\n\n isElementValuesEqual(elementValue1, elementValue2) {\n if (typeof elementValue1 === 'string' || typeof elementValue2 === 'string') {\n return elementValue1 === elementValue2;\n }\n if (elementValue1 instanceof tree.Attribute) {\n if (elementValue1.op !== elementValue2.op || elementValue1.key !== elementValue2.key) {\n return false;\n }\n if (!elementValue1.value || !elementValue2.value) {\n if (elementValue1.value || elementValue2.value) {\n return false;\n }\n return true;\n }\n elementValue1 = elementValue1.value.value || elementValue1.value;\n elementValue2 = elementValue2.value.value || elementValue2.value;\n return elementValue1 === elementValue2;\n }\n elementValue1 = elementValue1.value;\n elementValue2 = elementValue2.value;\n if (elementValue1 instanceof tree.Selector) {\n if (!(elementValue2 instanceof tree.Selector) || elementValue1.elements.length !== elementValue2.elements.length) {\n return false;\n }\n for (let i = 0; i < elementValue1.elements.length; i++) {\n if (elementValue1.elements[i].combinator.value !== elementValue2.elements[i].combinator.value) {\n if (i !== 0 || (elementValue1.elements[i].combinator.value || ' ') !== (elementValue2.elements[i].combinator.value || ' ')) {\n return false;\n }\n }\n if (!this.isElementValuesEqual(elementValue1.elements[i].value, elementValue2.elements[i].value)) {\n return false;\n }\n }\n return true;\n }\n return false;\n }\n\n extendSelector(matches, selectorPath, replacementSelector, isVisible) {\n\n // for a set of matches, replace each match with the replacement selector\n\n let currentSelectorPathIndex = 0, currentSelectorPathElementIndex = 0, path = [], matchIndex, selector, firstElement, match, newElements;\n\n for (matchIndex = 0; matchIndex < matches.length; matchIndex++) {\n match = matches[matchIndex];\n selector = selectorPath[match.pathIndex];\n firstElement = new tree.Element(\n match.initialCombinator,\n replacementSelector.elements[0].value,\n replacementSelector.elements[0].isVariable,\n replacementSelector.elements[0].getIndex(),\n replacementSelector.elements[0].fileInfo()\n );\n\n if (match.pathIndex > currentSelectorPathIndex && currentSelectorPathElementIndex > 0) {\n path[path.length - 1].elements = path[path.length - 1]\n .elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex));\n currentSelectorPathElementIndex = 0;\n currentSelectorPathIndex++;\n }\n\n newElements = selector.elements\n .slice(currentSelectorPathElementIndex, match.index)\n .concat([firstElement])\n .concat(replacementSelector.elements.slice(1));\n\n if (currentSelectorPathIndex === match.pathIndex && matchIndex > 0) {\n path[path.length - 1].elements =\n path[path.length - 1].elements.concat(newElements);\n } else {\n path = path.concat(selectorPath.slice(currentSelectorPathIndex, match.pathIndex));\n\n path.push(new tree.Selector(\n newElements\n ));\n }\n currentSelectorPathIndex = match.endPathIndex;\n currentSelectorPathElementIndex = match.endPathElementIndex;\n if (currentSelectorPathElementIndex >= selectorPath[currentSelectorPathIndex].elements.length) {\n currentSelectorPathElementIndex = 0;\n currentSelectorPathIndex++;\n }\n }\n\n if (currentSelectorPathIndex < selectorPath.length && currentSelectorPathElementIndex > 0) {\n path[path.length - 1].elements = path[path.length - 1]\n .elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex));\n currentSelectorPathIndex++;\n }\n\n path = path.concat(selectorPath.slice(currentSelectorPathIndex, selectorPath.length));\n path = path.map(function (currentValue) {\n // we can re-use elements here, because the visibility property matters only for selectors\n const derived = currentValue.createDerived(currentValue.elements);\n if (isVisible) {\n derived.ensureVisibility();\n } else {\n derived.ensureInvisibility();\n }\n return derived;\n });\n return path;\n }\n\n visitMedia(mediaNode, visitArgs) {\n let newAllExtends = mediaNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]);\n newAllExtends = newAllExtends.concat(this.doExtendChaining(newAllExtends, mediaNode.allExtends));\n this.allExtendsStack.push(newAllExtends);\n }\n\n visitMediaOut(mediaNode) {\n const lastIndex = this.allExtendsStack.length - 1;\n this.allExtendsStack.length = lastIndex;\n }\n\n visitAtRule(atRuleNode, visitArgs) {\n let newAllExtends = atRuleNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]);\n newAllExtends = newAllExtends.concat(this.doExtendChaining(newAllExtends, atRuleNode.allExtends));\n this.allExtendsStack.push(newAllExtends);\n }\n\n visitAtRuleOut(atRuleNode) {\n const lastIndex = this.allExtendsStack.length - 1;\n this.allExtendsStack.length = lastIndex;\n }\n}\n\nexport default ProcessExtendsVisitor;\n"]} |
| {"version":3,"file":"import-sequencer.js","sourceRoot":"","sources":["../../../src/less/visitors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,CAAC,CAAC;iBACpD;gBACD,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;oBACnC,MAAM;iBACT;gBACD,IAAM,cAAc,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;gBAC/C,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACrD,cAAc,EAAE,CAAC;aACpB;SACJ;gBAAS;YACN,IAAI,CAAC,aAAa,EAAE,CAAC;SACxB;QACD,IAAI,IAAI,CAAC,aAAa,KAAK,CAAC,IAAI,IAAI,CAAC,iBAAiB,EAAE;YACpD,IAAI,CAAC,iBAAiB,EAAE,CAAC;SAC5B;IACL,CAAC;IACL,sBAAC;AAAD,CAAC,AArDD,IAqDC;AAED,kBAAe,eAAe,CAAC","sourcesContent":["class ImportSequencer {\n constructor(onSequencerEmpty) {\n this.imports = [];\n this.variableImports = [];\n this._onSequencerEmpty = onSequencerEmpty;\n this._currentDepth = 0;\n }\n\n addImport(callback) {\n const importSequencer = this,\n importItem = {\n callback,\n args: null,\n isReady: false\n };\n this.imports.push(importItem);\n return function() {\n importItem.args = Array.prototype.slice.call(arguments, 0);\n importItem.isReady = true;\n importSequencer.tryRun();\n };\n }\n\n addVariableImport(callback) {\n this.variableImports.push(callback);\n }\n\n tryRun() {\n this._currentDepth++;\n try {\n while (true) {\n while (this.imports.length > 0) {\n const importItem = this.imports[0];\n if (!importItem.isReady) {\n return;\n }\n this.imports = this.imports.slice(1);\n importItem.callback.apply(null, importItem.args);\n }\n if (this.variableImports.length === 0) {\n break;\n }\n const variableImport = this.variableImports[0];\n this.variableImports = this.variableImports.slice(1);\n variableImport();\n }\n } finally {\n this._currentDepth--;\n }\n if (this._currentDepth === 0 && this._onSequencerEmpty) {\n this._onSequencerEmpty();\n }\n }\n}\n\nexport default ImportSequencer;\n"]} |
| {"version":3,"file":"import-visitor.js","sourceRoot":"","sources":["../../../src/less/visitors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,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE;YACpD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;SAC3C;IACL,CAAC;IACD,cAAc,EAAE,UAAU,UAAU;QAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;IACD,oBAAoB,EAAE,UAAU,mBAAmB,EAAE,SAAS;QAC1D,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACrD,CAAC;IACD,uBAAuB,EAAE,UAAU,mBAAmB;QAClD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;IACD,YAAY,EAAE,UAAU,WAAW,EAAE,SAAS;QAC1C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;IACD,eAAe,EAAE,UAAU,WAAW;QAClC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;IACD,UAAU,EAAE,UAAU,SAAS,EAAE,SAAS;QACtC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;IACD,aAAa,EAAE,UAAU,SAAS;QAC9B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;CACJ,CAAC;AACF,kBAAe,aAAa,CAAC","sourcesContent":["/* eslint-disable no-unused-vars */\n/**\n * @todo - Remove unused when JSDoc types are added for visitor methods\n */\nimport contexts from '../contexts';\nimport Visitor from './visitor';\nimport ImportSequencer from './import-sequencer';\nimport * as utils from '../utils';\n\nconst ImportVisitor = function(importer, finish) {\n\n this._visitor = new Visitor(this);\n this._importer = importer;\n this._finish = finish;\n this.context = new contexts.Eval();\n this.importCount = 0;\n this.onceFileDetectionMap = {};\n this.recursionDetector = {};\n this._sequencer = new ImportSequencer(this._onSequencerEmpty.bind(this));\n};\n\nImportVisitor.prototype = {\n isReplacing: false,\n run: function (root) {\n try {\n // process the contents\n this._visitor.visit(root);\n }\n catch (e) {\n this.error = e;\n }\n\n this.isFinished = true;\n this._sequencer.tryRun();\n },\n _onSequencerEmpty: function() {\n if (!this.isFinished) {\n return;\n }\n this._finish(this.error);\n },\n visitImport: function (importNode, visitArgs) {\n const inlineCSS = importNode.options.inline;\n\n if (!importNode.css || inlineCSS) {\n\n const context = new contexts.Eval(this.context, utils.copyArray(this.context.frames));\n const importParent = context.frames[0];\n\n this.importCount++;\n if (importNode.isVariableImport()) {\n this._sequencer.addVariableImport(this.processImportNode.bind(this, importNode, context, importParent));\n } else {\n this.processImportNode(importNode, context, importParent);\n }\n }\n visitArgs.visitDeeper = false;\n },\n processImportNode: function(importNode, context, importParent) {\n let evaldImportNode;\n const inlineCSS = importNode.options.inline;\n\n try {\n evaldImportNode = importNode.evalForImport(context);\n } catch (e) {\n if (!e.filename) { e.index = importNode.getIndex(); e.filename = importNode.fileInfo().filename; }\n // attempt to eval properly and treat as css\n importNode.css = true;\n // if that fails, this error will be thrown\n importNode.error = e;\n }\n\n if (evaldImportNode && (!evaldImportNode.css || inlineCSS)) {\n\n if (evaldImportNode.options.multiple) {\n context.importMultiple = true;\n }\n\n // try appending if we haven't determined if it is css or not\n const tryAppendLessExtension = evaldImportNode.css === undefined;\n\n for (let i = 0; i < importParent.rules.length; i++) {\n if (importParent.rules[i] === importNode) {\n importParent.rules[i] = evaldImportNode;\n break;\n }\n }\n\n const onImported = this.onImported.bind(this, evaldImportNode, context), sequencedOnImported = this._sequencer.addImport(onImported);\n\n this._importer.push(evaldImportNode.getPath(), tryAppendLessExtension, evaldImportNode.fileInfo(),\n evaldImportNode.options, sequencedOnImported);\n } else {\n this.importCount--;\n if (this.isFinished) {\n this._sequencer.tryRun();\n }\n }\n },\n onImported: function (importNode, context, e, root, importedAtRoot, fullPath) {\n if (e) {\n if (!e.filename) {\n e.index = importNode.getIndex(); e.filename = importNode.fileInfo().filename;\n }\n this.error = e;\n }\n\n const importVisitor = this,\n inlineCSS = importNode.options.inline,\n isPlugin = importNode.options.isPlugin,\n isOptional = importNode.options.optional,\n duplicateImport = importedAtRoot || fullPath in importVisitor.recursionDetector;\n\n if (!context.importMultiple) {\n if (duplicateImport) {\n importNode.skip = true;\n } else {\n importNode.skip = function() {\n if (fullPath in importVisitor.onceFileDetectionMap) {\n return true;\n }\n importVisitor.onceFileDetectionMap[fullPath] = true;\n return false;\n };\n }\n }\n\n if (!fullPath && isOptional) {\n importNode.skip = true;\n }\n\n if (root) {\n importNode.root = root;\n importNode.importedFilename = fullPath;\n\n if (!inlineCSS && !isPlugin && (context.importMultiple || !duplicateImport)) {\n importVisitor.recursionDetector[fullPath] = true;\n\n const oldContext = this.context;\n this.context = context;\n try {\n this._visitor.visit(root);\n } catch (e) {\n this.error = e;\n }\n this.context = oldContext;\n }\n }\n\n importVisitor.importCount--;\n\n if (importVisitor.isFinished) {\n importVisitor._sequencer.tryRun();\n }\n },\n visitDeclaration: function (declNode, visitArgs) {\n if (declNode.value.type === 'DetachedRuleset') {\n this.context.frames.unshift(declNode);\n } else {\n visitArgs.visitDeeper = false;\n }\n },\n visitDeclarationOut: function(declNode) {\n if (declNode.value.type === 'DetachedRuleset') {\n this.context.frames.shift();\n }\n },\n visitAtRule: function (atRuleNode, visitArgs) {\n if (atRuleNode.value) {\n this.context.frames.unshift(atRuleNode);\n } else if (atRuleNode.declarations && atRuleNode.declarations.length) {\n if (atRuleNode.isRooted) {\n this.context.frames.unshift(atRuleNode);\n } else {\n this.context.frames.unshift(atRuleNode.declarations[0]);\n }\n } else if (atRuleNode.rules && atRuleNode.rules.length) {\n this.context.frames.unshift(atRuleNode);\n }\n },\n visitAtRuleOut: function (atRuleNode) {\n this.context.frames.shift();\n },\n visitMixinDefinition: function (mixinDefinitionNode, visitArgs) {\n this.context.frames.unshift(mixinDefinitionNode);\n },\n visitMixinDefinitionOut: function (mixinDefinitionNode) {\n this.context.frames.shift();\n },\n visitRuleset: function (rulesetNode, visitArgs) {\n this.context.frames.unshift(rulesetNode);\n },\n visitRulesetOut: function (rulesetNode) {\n this.context.frames.shift();\n },\n visitMedia: function (mediaNode, visitArgs) {\n this.context.frames.unshift(mediaNode.rules[0]);\n },\n visitMediaOut: function (mediaNode) {\n this.context.frames.shift();\n }\n};\nexport default ImportVisitor;\n"]} |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/less/visitors/index.js"],"names":[],"mappings":";;;AAAA,8DAAgC;AAChC,4EAA6C;AAC7C,sGAAwE;AACxE,4EAA6C;AAC7C,0FAA0D;AAC1D,4EAA4C;AAE5C,kBAAe;IACX,OAAO,mBAAA;IACP,aAAa,0BAAA;IACb,2BAA2B,uCAAA;IAC3B,aAAa,0BAAA;IACb,mBAAmB,iCAAA;IACnB,YAAY,0BAAA;CACf,CAAC","sourcesContent":["import Visitor from './visitor';\nimport ImportVisitor from './import-visitor';\nimport MarkVisibleSelectorsVisitor from './set-tree-visibility-visitor';\nimport ExtendVisitor from './extend-visitor';\nimport JoinSelectorVisitor from './join-selector-visitor';\nimport ToCSSVisitor from './to-css-visitor';\n\nexport default {\n Visitor,\n ImportVisitor,\n MarkVisibleSelectorsVisitor,\n ExtendVisitor,\n JoinSelectorVisitor,\n ToCSSVisitor\n};\n"]} |
| {"version":3,"file":"join-selector-visitor.js","sourceRoot":"","sources":["../../../src/less/visitors/join-selector-visitor.js"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC;;GAEG;AACH,8DAAgC;AAEhC;IACI;QACI,IAAI,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAO,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,iCAAG,GAAH,UAAI,IAAI;QACJ,OAAO,IAAI,C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C,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IACpD,CAAC;IAED,wCAAU,GAAV,UAAW,SAAS,EAAE,SAAS;QAC3B,IAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACxD,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IAC9E,CAAC;IAED,yCAAW,GAAX,UAAY,UAAU,EAAE,SAAS;QAC7B,IAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAExD,IAAI,UAAU,CAAC,YAAY,IAAI,UAAU,CAAC,YAAY,CAAC,MAAM,EAAE;YAC3D,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;SACrF;aACI,IAAI,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE;YAClD,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC;SACpF;IACL,CAAC;IACL,0BAAC;AAAD,CAAC,AAxDD,IAwDC;AAED,kBAAe,mBAAmB,CAAC","sourcesContent":["/* eslint-disable no-unused-vars */\n/**\n * @todo - Remove unused when JSDoc types are added for visitor methods\n */\nimport Visitor from './visitor';\n\nclass JoinSelectorVisitor {\n constructor() {\n this.contexts = [[]];\n this._visitor = new Visitor(this);\n }\n\n run(root) {\n return this._visitor.visit(root);\n }\n\n visitDeclaration(declNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitMixinDefinition(mixinDefinitionNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitRuleset(rulesetNode, visitArgs) {\n const context = this.contexts[this.contexts.length - 1];\n const paths = [];\n let selectors;\n\n this.contexts.push(paths);\n\n if (!rulesetNode.root) {\n selectors = rulesetNode.selectors;\n if (selectors) {\n selectors = selectors.filter(function(selector) { return selector.getIsOutput(); });\n rulesetNode.selectors = selectors.length ? selectors : (selectors = null);\n if (selectors) { rulesetNode.joinSelectors(paths, context, selectors); }\n }\n if (!selectors) { rulesetNode.rules = null; }\n rulesetNode.paths = paths;\n }\n }\n\n visitRulesetOut(rulesetNode) {\n this.contexts.length = this.contexts.length - 1;\n }\n\n visitMedia(mediaNode, visitArgs) {\n const context = this.contexts[this.contexts.length - 1];\n mediaNode.rules[0].root = (context.length === 0 || context[0].multiMedia);\n }\n\n visitAtRule(atRuleNode, visitArgs) {\n const context = this.contexts[this.contexts.length - 1];\n\n if (atRuleNode.declarations && atRuleNode.declarations.length) {\n atRuleNode.declarations[0].root = (context.length === 0 || context[0].multiMedia);\n }\n else if (atRuleNode.rules && atRuleNode.rules.length) {\n atRuleNode.rules[0].root = (atRuleNode.isRooted || context.length === 0 || null);\n }\n }\n}\n\nexport default JoinSelectorVisitor;\n"]} |
| {"version":3,"file":"set-tree-visibility-visitor.js","sourceRoot":"","sources":["../../../src/less/visitors/set-tree-visibility-visitor.js"],"names":[],"mappings":";;AAAA;IACI,kCAAY,OAAO;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED,sCAAG,GAAH,UAAI,IAAI;QACJ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAED,6CAAU,GAAV,UAAW,KAAK;QACZ,IAAI,CAAC,KAAK,EAAE;YACR,OAAO,KAAK,CAAC;SAChB;QAED,IAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC;QACzB,IAAI,CAAC,CAAC;QACN,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YACtB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SACxB;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,wCAAK,GAAL,UAAM,IAAI;QACN,IAAI,CAAC,IAAI,EAAE;YACP,OAAO,IAAI,CAAC;SACf;QACD,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE;YAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;SAChC;QAED,IAAI,CAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,gBAAgB,EAAE,EAAE;YACnD,OAAO,IAAI,CAAC;SACf;QACD,IAAI,IAAI,CAAC,OAAO,EAAE;YACd,IAAI,CAAC,gBAAgB,EAAE,CAAC;SAC3B;aAAM;YACH,IAAI,CAAC,kBAAkB,EAAE,CAAC;SAC7B;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAClB,OAAO,IAAI,CAAC;IAChB,CAAC;IACL,+BAAC;AAAD,CAAC,AA1CD,IA0CC;AAED,kBAAe,wBAAwB,CAAC","sourcesContent":["class SetTreeVisibilityVisitor {\n constructor(visible) {\n this.visible = visible;\n }\n\n run(root) {\n this.visit(root);\n }\n\n visitArray(nodes) {\n if (!nodes) {\n return nodes;\n }\n\n const cnt = nodes.length;\n let i;\n for (i = 0; i < cnt; i++) {\n this.visit(nodes[i]);\n }\n return nodes;\n }\n\n visit(node) {\n if (!node) {\n return node;\n }\n if (node.constructor === Array) {\n return this.visitArray(node);\n }\n\n if (!node.blocksVisibility || node.blocksVisibility()) {\n return node;\n }\n if (this.visible) {\n node.ensureVisibility();\n } else {\n node.ensureInvisibility();\n }\n\n node.accept(this);\n return node;\n }\n}\n\nexport default SetTreeVisibilityVisitor;"]} |
| {"version":3,"file":"to-css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oBAChC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;gBACrC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC1B;SACJ;QAED,SAAS,CAAC,OAAO,CAAC,UAAA,KAAK;YACnB,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;gBAClB,IAAM,QAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBACxB,IAAI,OAAK,GAAI,EAAE,CAAC;gBAChB,IAAM,OAAK,GAAI,CAAC,IAAI,cAAI,CAAC,UAAU,CAAC,OAAK,CAAC,CAAC,CAAC;gBAC5C,KAAK,CAAC,OAAO,CAAC,UAAA,IAAI;oBACd,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,GAAG,CAAC,IAAI,CAAC,OAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;wBAC5C,OAAK,CAAC,IAAI,CAAC,IAAI,cAAI,CAAC,UAAU,CAAC,OAAK,GAAG,EAAE,CAAC,CAAC,CAAC;qBAC/C;oBACD,OAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBACvB,QAAM,CAAC,SAAS,GAAG,QAAM,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;gBAC1D,CAAC,CAAC,CAAC;gBACH,QAAM,CAAC,KAAK,GAAG,IAAI,cAAI,CAAC,KAAK,CAAC,OAAK,CAAC,CAAC;aACxC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAC;AAEF,kBAAe,YAAY,CAAC","sourcesContent":["/* eslint-disable no-unused-vars */\n/**\n * @todo - Remove unused when JSDoc types are added for visitor methods\n */\nimport tree from '../tree';\nimport Visitor from './visitor';\n\nclass CSSVisitorUtils {\n constructor(context) {\n this._visitor = new Visitor(this);\n this._context = context;\n }\n\n containsSilentNonBlockedChild(bodyRules) {\n let rule;\n if (!bodyRules) {\n return false;\n }\n for (let r = 0; r < bodyRules.length; r++) {\n rule = bodyRules[r];\n if (rule.isSilent && rule.isSilent(this._context) && !rule.blocksVisibility()) {\n // the atrule contains something that was referenced (likely by extend)\n // therefore it needs to be shown in output too\n return true;\n }\n }\n return false;\n }\n\n keepOnlyVisibleChilds(owner) {\n if (owner && owner.rules) {\n owner.rules = owner.rules.filter(thing => thing.isVisible());\n }\n }\n\n isEmpty(owner) {\n return (owner && owner.rules) \n ? (owner.rules.length === 0) : true;\n }\n\n hasVisibleSelector(rulesetNode) {\n return (rulesetNode && rulesetNode.paths)\n ? (rulesetNode.paths.length > 0) : false;\n }\n\n resolveVisibility(node) {\n if (!node.blocksVisibility()) {\n if (this.isEmpty(node)) {\n return ;\n }\n\n return node;\n }\n\n const compiledRulesBody = node.rules[0];\n this.keepOnlyVisibleChilds(compiledRulesBody);\n\n if (this.isEmpty(compiledRulesBody)) {\n return ;\n }\n\n node.ensureVisibility();\n node.removeVisibilityBlock();\n\n return node;\n }\n\n isVisibleRuleset(rulesetNode) {\n if (rulesetNode.firstRoot) {\n return true;\n }\n\n if (this.isEmpty(rulesetNode)) {\n return false;\n }\n\n if (!rulesetNode.root && !this.hasVisibleSelector(rulesetNode)) {\n return false;\n }\n\n return true;\n }\n}\n\nconst ToCSSVisitor = function(context) {\n this._visitor = new Visitor(this);\n this._context = context;\n this.utils = new CSSVisitorUtils(context);\n};\n\nToCSSVisitor.prototype = {\n isReplacing: true,\n run: function (root) {\n return this._visitor.visit(root);\n },\n\n visitDeclaration: function (declNode, visitArgs) {\n if (declNode.blocksVisibility() || declNode.variable) {\n return;\n }\n return declNode;\n },\n\n visitMixinDefinition: function (mixinNode, visitArgs) {\n // mixin definitions do not get eval'd - this means they keep state\n // so we have to clear that state here so it isn't used if toCSS is called twice\n mixinNode.frames = [];\n },\n\n visitExtend: function (extendNode, visitArgs) {\n },\n\n visitComment: function (commentNode, visitArgs) {\n if (commentNode.blocksVisibility() || commentNode.isSilent(this._context)) {\n return;\n }\n return commentNode;\n },\n\n visitMedia: function(mediaNode, visitArgs) {\n const originalRules = mediaNode.rules[0].rules;\n mediaNode.accept(this._visitor);\n visitArgs.visitDeeper = false;\n\n return this.utils.resolveVisibility(mediaNode, originalRules);\n },\n\n visitImport: function (importNode, visitArgs) {\n if (importNode.blocksVisibility()) {\n return ;\n }\n return importNode;\n },\n\n visitAtRule: function(atRuleNode, visitArgs) {\n if (atRuleNode.rules && atRuleNode.rules.length) {\n return this.visitAtRuleWithBody(atRuleNode, visitArgs);\n } else {\n return this.visitAtRuleWithoutBody(atRuleNode, visitArgs);\n }\n },\n\n visitAnonymous: function(anonymousNode, visitArgs) {\n if (!anonymousNode.blocksVisibility()) {\n anonymousNode.accept(this._visitor);\n return anonymousNode;\n }\n },\n\n visitAtRuleWithBody: function(atRuleNode, visitArgs) {\n // if there is only one nested ruleset and that one has no path, then it is\n // just fake ruleset\n function hasFakeRuleset(atRuleNode) {\n const bodyRules = atRuleNode.rules;\n return bodyRules.length === 1 && (!bodyRules[0].paths || bodyRules[0].paths.length === 0);\n }\n function getBodyRules(atRuleNode) {\n const nodeRules = atRuleNode.rules;\n if (hasFakeRuleset(atRuleNode)) {\n return nodeRules[0].rules;\n }\n\n return nodeRules;\n }\n // it is still true that it is only one ruleset in array\n // this is last such moment\n // process childs\n const originalRules = getBodyRules(atRuleNode);\n atRuleNode.accept(this._visitor);\n visitArgs.visitDeeper = false;\n\n if (!this.utils.isEmpty(atRuleNode)) {\n this._mergeRules(atRuleNode.rules[0].rules);\n }\n\n return this.utils.resolveVisibility(atRuleNode, originalRules);\n },\n\n visitAtRuleWithoutBody: function(atRuleNode, visitArgs) {\n if (atRuleNode.blocksVisibility()) {\n return;\n }\n\n if (atRuleNode.name === '@charset') {\n // Only output the debug info together with subsequent @charset definitions\n // a comment (or @media statement) before the actual @charset atrule would\n // be considered illegal css as it has to be on the first line\n if (this.charset) {\n if (atRuleNode.debugInfo) {\n const comment = new tree.Comment(`/* ${atRuleNode.toCSS(this._context).replace(/\\n/g, '')} */\\n`);\n comment.debugInfo = atRuleNode.debugInfo;\n return this._visitor.visit(comment);\n }\n return;\n }\n this.charset = true;\n }\n\n return atRuleNode;\n },\n\n checkValidNodes: function(rules, isRoot) {\n if (!rules) {\n return;\n }\n\n for (let i = 0; i < rules.length; i++) {\n const ruleNode = rules[i];\n if (isRoot && ruleNode instanceof tree.Declaration && !ruleNode.variable) {\n throw { message: 'Properties must be inside selector blocks. They cannot be in the root',\n index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename};\n }\n if (ruleNode instanceof tree.Call) {\n throw { message: `Function '${ruleNode.name}' did not return a root node`,\n index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename};\n }\n if (ruleNode.type && !ruleNode.allowRoot) {\n throw { message: `${ruleNode.type} node returned by a function is not valid here`,\n index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename};\n }\n }\n },\n\n visitRuleset: function (rulesetNode, visitArgs) {\n // at this point rulesets are nested into each other\n let rule;\n\n const rulesets = [];\n\n this.checkValidNodes(rulesetNode.rules, rulesetNode.firstRoot);\n\n if (!rulesetNode.root) {\n // remove invisible paths\n this._compileRulesetPaths(rulesetNode);\n\n // remove rulesets from this ruleset body and compile them separately\n const nodeRules = rulesetNode.rules;\n\n let nodeRuleCnt = nodeRules ? nodeRules.length : 0;\n for (let i = 0; i < nodeRuleCnt; ) {\n rule = nodeRules[i];\n if (rule && rule.rules) {\n // visit because we are moving them out from being a child\n rulesets.push(this._visitor.visit(rule));\n nodeRules.splice(i, 1);\n nodeRuleCnt--;\n continue;\n }\n i++;\n }\n // accept the visitor to remove rules and refactor itself\n // then we can decide nogw whether we want it or not\n // compile body\n if (nodeRuleCnt > 0) {\n rulesetNode.accept(this._visitor);\n } else {\n rulesetNode.rules = null;\n }\n visitArgs.visitDeeper = false;\n } else { // if (! rulesetNode.root) {\n rulesetNode.accept(this._visitor);\n visitArgs.visitDeeper = false;\n }\n\n if (rulesetNode.rules) {\n this._mergeRules(rulesetNode.rules);\n this._removeDuplicateRules(rulesetNode.rules);\n }\n\n // now decide whether we keep the ruleset\n if (this.utils.isVisibleRuleset(rulesetNode)) {\n rulesetNode.ensureVisibility();\n rulesets.splice(0, 0, rulesetNode);\n }\n\n if (rulesets.length === 1) {\n return rulesets[0];\n }\n return rulesets;\n },\n\n _compileRulesetPaths: function(rulesetNode) {\n if (rulesetNode.paths) {\n rulesetNode.paths = rulesetNode.paths\n .filter(p => {\n let i;\n if (p[0].elements[0].combinator.value === ' ') {\n p[0].elements[0].combinator = new(tree.Combinator)('');\n }\n for (i = 0; i < p.length; i++) {\n if (p[i].isVisible() && p[i].getIsOutput()) {\n return true;\n }\n }\n return false;\n });\n }\n },\n\n _removeDuplicateRules: function(rules) {\n if (!rules) { return; }\n\n // remove duplicates\n const ruleCache = {};\n\n let ruleList;\n let rule;\n let i;\n\n for (i = rules.length - 1; i >= 0 ; i--) {\n rule = rules[i];\n if (rule instanceof tree.Declaration) {\n if (!ruleCache[rule.name]) {\n ruleCache[rule.name] = rule;\n } else {\n ruleList = ruleCache[rule.name];\n if (ruleList instanceof tree.Declaration) {\n ruleList = ruleCache[rule.name] = [ruleCache[rule.name].toCSS(this._context)];\n }\n const ruleCSS = rule.toCSS(this._context);\n if (ruleList.indexOf(ruleCSS) !== -1) {\n rules.splice(i, 1);\n } else {\n ruleList.push(ruleCSS);\n }\n }\n }\n }\n },\n\n _mergeRules: function(rules) {\n if (!rules) {\n return; \n }\n\n const groups = {};\n const groupsArr = [];\n\n for (let i = 0; i < rules.length; i++) {\n const rule = rules[i];\n if (rule.merge) {\n const key = rule.name;\n groups[key] ? rules.splice(i--, 1) : \n groupsArr.push(groups[key] = []);\n groups[key].push(rule);\n }\n }\n\n groupsArr.forEach(group => {\n if (group.length > 0) {\n const result = group[0];\n let space = [];\n const comma = [new tree.Expression(space)];\n group.forEach(rule => {\n if ((rule.merge === '+') && (space.length > 0)) {\n comma.push(new tree.Expression(space = []));\n }\n space.push(rule.value);\n result.important = result.important || rule.important;\n });\n result.value = new tree.Value(comma);\n }\n });\n }\n};\n\nexport default ToCSSVisitor;\n"]} |
| {"version":3,"file":"visitor.js","sourceRoot":"","sources":["../../../src/less/visitors/visitor.js"],"names":[],"mappings":";;;AAAA,yDAA2B;AAE3B,IAAM,UAAU,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AACzC,IAAI,WAAW,GAAG,KAAK,CAAC;AAExB,SAAS,KAAK,CAAC,IAAI;IACf,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAS,cAAc,CAAC,MAAM,EAAE,MAAM;IAClC,qDAAqD;IACrD,IAAI,GAAG,EAAE,KAAK,CAAC;IACf,KAAK,GAAG,IAAI,MAAM,EAAE;QAChB,4BAA4B;QAC5B,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QACpB,QAAQ,OAAO,KAAK,EAAE;YAClB,KAAK,UAAU;gBACX,wEAAwE;gBACxE,kBAAkB;gBAClB,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE;oBACzC,KAAK,CAAC,SAAS,CAAC,SAAS,GAAG,MAAM,EAAE,CAAC;iBACxC;gBACD,MAAM;YACV,KAAK,QAAQ;gBACT,MAAM,GAAG,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gBACvC,MAAM;SAEb;KACJ;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;IACI,iBAAY,cAAc;QACtB,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QACtC,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QACxB,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QAEzB,IAAI,CAAC,WAAW,EAAE;YACd,cAAc,CAAC,cAAI,EAAE,CAAC,CAAC,CAAC;YACxB,WAAW,GAAG,IAAI,CAAC;SACtB;IACL,CAAC;IAED,uBAAK,GAAL,UAAM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AAAD,CAAC,AAlID,IAkIC;AAED,kBAAe,OAAO,CAAC","sourcesContent":["import tree from '../tree';\n\nconst _visitArgs = { visitDeeper: true };\nlet _hasIndexed = false;\n\nfunction _noop(node) {\n return node;\n}\n\nfunction indexNodeTypes(parent, ticker) {\n // add .typeIndex to tree node types for lookup table\n let key, child;\n for (key in parent) { \n /* eslint guard-for-in: 0 */\n child = parent[key];\n switch (typeof child) {\n case 'function':\n // ignore bound functions directly on tree which do not have a prototype\n // or aren't nodes\n if (child.prototype && child.prototype.type) {\n child.prototype.typeIndex = ticker++;\n }\n break;\n case 'object':\n ticker = indexNodeTypes(child, ticker);\n break;\n \n }\n }\n return ticker;\n}\n\nclass Visitor {\n constructor(implementation) {\n this._implementation = implementation;\n this._visitInCache = {};\n this._visitOutCache = {};\n\n if (!_hasIndexed) {\n indexNodeTypes(tree, 1);\n _hasIndexed = true;\n }\n }\n\n visit(node) {\n if (!node) {\n return node;\n }\n\n const nodeTypeIndex = node.typeIndex;\n if (!nodeTypeIndex) {\n // MixinCall args aren't a node type?\n if (node.value && node.value.typeIndex) {\n this.visit(node.value);\n }\n return node;\n }\n\n const impl = this._implementation;\n let func = this._visitInCache[nodeTypeIndex];\n let funcOut = this._visitOutCache[nodeTypeIndex];\n const visitArgs = _visitArgs;\n let fnName;\n\n visitArgs.visitDeeper = true;\n\n if (!func) {\n fnName = `visit${node.type}`;\n func = impl[fnName] || _noop;\n funcOut = impl[`${fnName}Out`] || _noop;\n this._visitInCache[nodeTypeIndex] = func;\n this._visitOutCache[nodeTypeIndex] = funcOut;\n }\n\n if (func !== _noop) {\n const newNode = func.call(impl, node, visitArgs);\n if (node && impl.isReplacing) {\n node = newNode;\n }\n }\n\n if (visitArgs.visitDeeper && node) {\n if (node.length) {\n for (let i = 0, cnt = node.length; i < cnt; i++) {\n if (node[i].accept) {\n node[i].accept(this);\n }\n }\n } else if (node.accept) {\n node.accept(this);\n }\n }\n\n if (funcOut != _noop) {\n funcOut.call(impl, node);\n }\n\n return node;\n }\n\n visitArray(nodes, nonReplacing) {\n if (!nodes) {\n return nodes;\n }\n\n const cnt = nodes.length;\n let i;\n\n // Non-replacing\n if (nonReplacing || !this._implementation.isReplacing) {\n for (i = 0; i < cnt; i++) {\n this.visit(nodes[i]);\n }\n return nodes;\n }\n\n // Replacing\n const out = [];\n for (i = 0; i < cnt; i++) {\n const evald = this.visit(nodes[i]);\n if (evald === undefined) { continue; }\n if (!evald.splice) {\n out.push(evald);\n } else if (evald.length) {\n this.flatten(evald, out);\n }\n }\n return out;\n }\n\n flatten(arr, out) {\n if (!out) {\n out = [];\n }\n\n let cnt, i, item, nestedCnt, j, nestedItem;\n\n for (i = 0, cnt = arr.length; i < cnt; i++) {\n item = arr[i];\n if (item === undefined) {\n continue;\n }\n if (!item.splice) {\n out.push(item);\n continue;\n }\n\n for (j = 0, nestedCnt = item.length; j < nestedCnt; j++) {\n nestedItem = item[j];\n if (nestedItem === undefined) {\n continue;\n }\n if (!nestedItem.splice) {\n out.push(nestedItem);\n } else if (nestedItem.length) {\n this.flatten(nestedItem, out);\n }\n }\n }\n\n return out;\n }\n}\n\nexport default Visitor;\n"]} |
| #!/usr/bin/env node | ||
| /** | ||
| * Generates a line-by-line coverage report showing uncovered lines | ||
| * Reads from LCOV format and displays in terminal | ||
| * Also outputs JSON file with uncovered lines for programmatic access | ||
| */ | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const lcovPath = path.join(__dirname, '..', 'coverage', 'lcov.info'); | ||
| const jsonOutputPath = path.join(__dirname, '..', 'coverage', 'uncovered-lines.json'); | ||
| if (!fs.existsSync(lcovPath)) { | ||
| console.error('LCOV coverage file not found. Run pnpm test:coverage first.'); | ||
| process.exit(1); | ||
| } | ||
| const lcovContent = fs.readFileSync(lcovPath, 'utf8'); | ||
| // Parse LCOV format | ||
| const files = []; | ||
| let currentFile = null; | ||
| const lines = lcovContent.split('\n'); | ||
| for (let i = 0; i < lines.length; i++) { | ||
| const line = lines[i]; | ||
| // SF: source file | ||
| if (line.startsWith('SF:')) { | ||
| if (currentFile) { | ||
| files.push(currentFile); | ||
| } | ||
| const filePath = line.substring(3); | ||
| // Only include src/ files (not less-browser) and bin/ | ||
| // Exclude abstract base classes (they're meant to be overridden) | ||
| const normalized = filePath.replace(/\\/g, '/'); | ||
| const abstractClasses = ['abstract-file-manager', 'abstract-plugin-loader']; | ||
| const isAbstract = abstractClasses.some(abstract => normalized.includes(abstract)); | ||
| if (!isAbstract && | ||
| ((normalized.includes('src/less/') && !normalized.includes('src/less-browser/')) || | ||
| normalized.includes('src/less-node/') || | ||
| normalized.includes('bin/'))) { | ||
| // Extract relative path - match src/less/... or src/less-node/... or bin/... | ||
| // Path format: src/less/tree/debug-info.js or src/less-node/file-manager.js | ||
| // Match from src/ or bin/ to end of path | ||
| const match = normalized.match(/(src\/[^/]+\/.+|bin\/.+)$/); | ||
| const relativePath = match ? match[1] : (normalized.includes('/src/') || normalized.includes('/bin/') ? normalized.split('/').slice(-3).join('/') : path.basename(filePath)); | ||
| currentFile = { | ||
| path: relativePath, | ||
| fullPath: filePath, | ||
| uncoveredLines: [], | ||
| uncoveredLineCode: {}, // line number -> source code | ||
| totalLines: 0, | ||
| coveredLines: 0 | ||
| }; | ||
| } else { | ||
| currentFile = null; | ||
| } | ||
| } | ||
| // DA: line data (line number, execution count) | ||
| if (currentFile && line.startsWith('DA:')) { | ||
| const match = line.match(/^DA:(\d+),(\d+)$/); | ||
| if (match) { | ||
| const lineNum = parseInt(match[1], 10); | ||
| const count = parseInt(match[2], 10); | ||
| currentFile.totalLines++; | ||
| if (count > 0) { | ||
| currentFile.coveredLines++; | ||
| } else { | ||
| currentFile.uncoveredLines.push(lineNum); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| if (currentFile) { | ||
| files.push(currentFile); | ||
| } | ||
| // Read source code for uncovered lines | ||
| files.forEach(file => { | ||
| if (file.uncoveredLines.length > 0 && fs.existsSync(file.fullPath)) { | ||
| try { | ||
| const sourceCode = fs.readFileSync(file.fullPath, 'utf8'); | ||
| const sourceLines = sourceCode.split('\n'); | ||
| file.uncoveredLines.forEach(lineNum => { | ||
| // LCOV uses 1-based line numbers | ||
| if (lineNum > 0 && lineNum <= sourceLines.length) { | ||
| file.uncoveredLineCode[lineNum] = sourceLines[lineNum - 1].trim(); | ||
| } | ||
| }); | ||
| } catch (err) { | ||
| // If we can't read the source (e.g., it's in lib/ but we want src/), that's ok | ||
| // We'll just skip the source code | ||
| } | ||
| } | ||
| }); | ||
| // Filter to only files with uncovered lines and sort by coverage | ||
| const filesWithGaps = files | ||
| .filter(f => f.uncoveredLines.length > 0) | ||
| .sort((a, b) => { | ||
| const aPct = a.totalLines > 0 ? a.coveredLines / a.totalLines : 1; | ||
| const bPct = b.totalLines > 0 ? b.coveredLines / b.totalLines : 1; | ||
| return aPct - bPct; | ||
| }); | ||
| if (filesWithGaps.length === 0) { | ||
| if (files.length === 0) { | ||
| console.log('\n⚠️ No source files found in coverage data. This may indicate an issue with the coverage report.\n'); | ||
| } else { | ||
| console.log('\n✅ All analyzed files have 100% line coverage!\n'); | ||
| console.log(`(Analyzed ${files.length} files from src/less/, src/less-node/, and bin/)\n`); | ||
| } | ||
| process.exit(0); | ||
| } | ||
| console.log('\n' + '='.repeat(100)); | ||
| console.log('Uncovered Lines Report'); | ||
| console.log('='.repeat(100) + '\n'); | ||
| filesWithGaps.forEach(file => { | ||
| const coveragePct = file.totalLines > 0 | ||
| ? ((file.coveredLines / file.totalLines) * 100).toFixed(1) | ||
| : '0.0'; | ||
| console.log(`\n${file.path} (${coveragePct}% coverage)`); | ||
| console.log('-'.repeat(100)); | ||
| // Group consecutive lines into ranges | ||
| const ranges = []; | ||
| let start = file.uncoveredLines[0]; | ||
| let end = file.uncoveredLines[0]; | ||
| for (let i = 1; i < file.uncoveredLines.length; i++) { | ||
| if (file.uncoveredLines[i] === end + 1) { | ||
| end = file.uncoveredLines[i]; | ||
| } else { | ||
| ranges.push(start === end ? `${start}` : `${start}..${end}`); | ||
| start = file.uncoveredLines[i]; | ||
| end = file.uncoveredLines[i]; | ||
| } | ||
| } | ||
| ranges.push(start === end ? `${start}` : `${start}..${end}`); | ||
| // Display ranges (max 5 per line for readability) | ||
| const linesPerRow = 5; | ||
| for (let i = 0; i < ranges.length; i += linesPerRow) { | ||
| const row = ranges.slice(i, i + linesPerRow); | ||
| console.log(` Lines: ${row.join(', ')}`); | ||
| } | ||
| console.log(` Total uncovered: ${file.uncoveredLines.length} of ${file.totalLines} lines`); | ||
| }); | ||
| console.log('\n' + '='.repeat(100) + '\n'); | ||
| // Write JSON output for programmatic access | ||
| const jsonOutput = { | ||
| generated: new Date().toISOString(), | ||
| files: filesWithGaps.map(file => ({ | ||
| path: file.path, | ||
| fullPath: file.fullPath, | ||
| sourcePath: (() => { | ||
| // Try to map lib/ path to src/ path | ||
| const normalized = file.fullPath.replace(/\\/g, '/'); | ||
| if (normalized.includes('/lib/')) { | ||
| return normalized.replace('/lib/', '/src/').replace(/\.js$/, '.ts'); | ||
| } | ||
| return file.fullPath; | ||
| })(), | ||
| coveragePercent: file.totalLines > 0 | ||
| ? parseFloat(((file.coveredLines / file.totalLines) * 100).toFixed(1)) | ||
| : 0, | ||
| totalLines: file.totalLines, | ||
| coveredLines: file.coveredLines, | ||
| uncoveredLines: file.uncoveredLines, | ||
| uncoveredLineCode: file.uncoveredLineCode || {}, | ||
| uncoveredRanges: (() => { | ||
| const ranges = []; | ||
| if (file.uncoveredLines.length === 0) return ranges; | ||
| let start = file.uncoveredLines[0]; | ||
| let end = file.uncoveredLines[0]; | ||
| for (let i = 1; i < file.uncoveredLines.length; i++) { | ||
| if (file.uncoveredLines[i] === end + 1) { | ||
| end = file.uncoveredLines[i]; | ||
| } else { | ||
| ranges.push({ start, end }); | ||
| start = file.uncoveredLines[i]; | ||
| end = file.uncoveredLines[i]; | ||
| } | ||
| } | ||
| ranges.push({ start, end }); | ||
| return ranges; | ||
| })() | ||
| })) | ||
| }; | ||
| fs.writeFileSync(jsonOutputPath, JSON.stringify(jsonOutput, null, 2), 'utf8'); | ||
| console.log('\n📄 Uncovered lines data written to: coverage/uncovered-lines.json\n'); | ||
| #!/usr/bin/env node | ||
| /** | ||
| * Generates a per-file coverage report table for src/ directories | ||
| */ | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const coverageSummaryPath = path.join(__dirname, '..', 'coverage', 'coverage-summary.json'); | ||
| if (!fs.existsSync(coverageSummaryPath)) { | ||
| console.error('Coverage summary not found. Run pnpm test:coverage first.'); | ||
| process.exit(1); | ||
| } | ||
| const coverage = JSON.parse(fs.readFileSync(coverageSummaryPath, 'utf8')); | ||
| // Filter to only src/ files (less, less-node) and bin/ files | ||
| // Note: src/less-browser/ is excluded because browser tests aren't included in coverage | ||
| // Abstract base classes are excluded as they're meant to be overridden by implementations | ||
| const abstractClasses = [ | ||
| 'abstract-file-manager', | ||
| 'abstract-plugin-loader' | ||
| ]; | ||
| const srcFiles = Object.entries(coverage) | ||
| .filter(([filePath]) => { | ||
| const normalized = filePath.replace(/\\/g, '/'); | ||
| // Exclude abstract classes | ||
| if (abstractClasses.some(abstract => normalized.includes(abstract))) { | ||
| return false; | ||
| } | ||
| return (normalized.includes('/src/less/') && !normalized.includes('/src/less-browser/')) || | ||
| normalized.includes('/src/less-node/') || | ||
| normalized.includes('/bin/'); | ||
| }) | ||
| .map(([filePath, data]) => { | ||
| // Extract relative path from absolute path | ||
| const normalized = filePath.replace(/\\/g, '/'); | ||
| // Match src/ paths or bin/ paths | ||
| const match = normalized.match(/((?:src\/[^/]+\/[^/]+\/|bin\/).+)$/); | ||
| const relativePath = match ? match[1] : path.basename(filePath); | ||
| return { | ||
| path: relativePath, | ||
| statements: data.statements, | ||
| branches: data.branches, | ||
| functions: data.functions, | ||
| lines: data.lines | ||
| }; | ||
| }) | ||
| .sort((a, b) => { | ||
| // Sort by directory first, then by coverage percentage | ||
| const pathCompare = a.path.localeCompare(b.path); | ||
| if (pathCompare !== 0) return pathCompare; | ||
| return a.statements.pct - b.statements.pct; | ||
| }); | ||
| if (srcFiles.length === 0) { | ||
| console.log('No src/ files found in coverage report.'); | ||
| process.exit(0); | ||
| } | ||
| // Group by directory | ||
| const grouped = { | ||
| 'src/less/': [], | ||
| 'src/less-node/': [], | ||
| 'bin/': [] | ||
| }; | ||
| srcFiles.forEach(file => { | ||
| if (file.path.startsWith('src/less/')) { | ||
| grouped['src/less/'].push(file); | ||
| } else if (file.path.startsWith('src/less-node/')) { | ||
| grouped['src/less-node/'].push(file); | ||
| } else if (file.path.startsWith('bin/')) { | ||
| grouped['bin/'].push(file); | ||
| } | ||
| }); | ||
| // Print table | ||
| console.log('\n' + '='.repeat(100)); | ||
| console.log('Per-File Coverage Report (src/less/, src/less-node/, and bin/)'); | ||
| console.log('='.repeat(100)); | ||
| console.log('For line-by-line coverage details, open coverage/index.html in your browser.'); | ||
| console.log('='.repeat(100) + '\n'); | ||
| Object.entries(grouped).forEach(([dir, files]) => { | ||
| if (files.length === 0) return; | ||
| console.log(`\n${dir.toUpperCase()}`); | ||
| console.log('-'.repeat(100)); | ||
| console.log( | ||
| 'File'.padEnd(50) + | ||
| 'Statements'.padStart(12) + | ||
| 'Branches'.padStart(12) + | ||
| 'Functions'.padStart(12) + | ||
| 'Lines'.padStart(12) | ||
| ); | ||
| console.log('-'.repeat(100)); | ||
| files.forEach(file => { | ||
| const filename = file.path.replace(dir, ''); | ||
| const truncated = filename.length > 48 ? '...' + filename.slice(-45) : filename; | ||
| console.log( | ||
| truncated.padEnd(50) + | ||
| `${file.statements.pct.toFixed(1)}%`.padStart(12) + | ||
| `${file.branches.pct.toFixed(1)}%`.padStart(12) + | ||
| `${file.functions.pct.toFixed(1)}%`.padStart(12) + | ||
| `${file.lines.pct.toFixed(1)}%`.padStart(12) | ||
| ); | ||
| }); | ||
| // Summary for this directory | ||
| const totals = files.reduce((acc, file) => { | ||
| acc.statements.total += file.statements.total; | ||
| acc.statements.covered += file.statements.covered; | ||
| acc.branches.total += file.branches.total; | ||
| acc.branches.covered += file.branches.covered; | ||
| acc.functions.total += file.functions.total; | ||
| acc.functions.covered += file.functions.covered; | ||
| acc.lines.total += file.lines.total; | ||
| acc.lines.covered += file.lines.covered; | ||
| return acc; | ||
| }, { | ||
| statements: { total: 0, covered: 0 }, | ||
| branches: { total: 0, covered: 0 }, | ||
| functions: { total: 0, covered: 0 }, | ||
| lines: { total: 0, covered: 0 } | ||
| }); | ||
| const stmtPct = totals.statements.total > 0 | ||
| ? (totals.statements.covered / totals.statements.total * 100).toFixed(1) | ||
| : '0.0'; | ||
| const branchPct = totals.branches.total > 0 | ||
| ? (totals.branches.covered / totals.branches.total * 100).toFixed(1) | ||
| : '0.0'; | ||
| const funcPct = totals.functions.total > 0 | ||
| ? (totals.functions.covered / totals.functions.total * 100).toFixed(1) | ||
| : '0.0'; | ||
| const linePct = totals.lines.total > 0 | ||
| ? (totals.lines.covered / totals.lines.total * 100).toFixed(1) | ||
| : '0.0'; | ||
| console.log('-'.repeat(100)); | ||
| console.log( | ||
| 'TOTAL'.padEnd(50) + | ||
| `${stmtPct}%`.padStart(12) + | ||
| `${branchPct}%`.padStart(12) + | ||
| `${funcPct}%`.padStart(12) + | ||
| `${linePct}%`.padStart(12) | ||
| ); | ||
| }); | ||
| console.log('\n' + '='.repeat(100) + '\n'); | ||
| #!/usr/bin/env node | ||
| /** | ||
| * Post-install script for Less.js package | ||
| * | ||
| * This script installs Playwright browsers only when: | ||
| * 1. This is a development environment (not when installed as a dependency) | ||
| * 2. We're in a monorepo context (parent package.json exists) | ||
| * 3. Not running in CI or other automated environments | ||
| */ | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const { execSync } = require('child_process'); | ||
| // Check if we're in a development environment | ||
| function isDevelopmentEnvironment() { | ||
| // Skip if this is a global install or user config | ||
| if (process.env.npm_config_user_config || process.env.npm_config_global) { | ||
| return false; | ||
| } | ||
| // Skip in CI environments | ||
| if (process.env.CI || process.env.GITHUB_ACTIONS || process.env.TRAVIS) { | ||
| return false; | ||
| } | ||
| // Check if we're in a monorepo (parent package.json exists) | ||
| const parentPackageJson = path.join(__dirname, '../../../package.json'); | ||
| if (!fs.existsSync(parentPackageJson)) { | ||
| return false; | ||
| } | ||
| // Check if this is the root of the monorepo | ||
| const currentPackageJson = path.join(__dirname, '../package.json'); | ||
| if (!fs.existsSync(currentPackageJson)) { | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
| // Install Playwright browsers | ||
| function installPlaywrightBrowsers() { | ||
| try { | ||
| console.log('🎭 Installing Playwright browsers for development...'); | ||
| execSync('pnpm exec playwright install', { | ||
| stdio: 'inherit', | ||
| cwd: path.join(__dirname, '..') | ||
| }); | ||
| console.log('✅ Playwright browsers installed successfully'); | ||
| } catch (error) { | ||
| console.warn('⚠️ Failed to install Playwright browsers:', error.message); | ||
| console.warn(' You can install them manually with: pnpm exec playwright install'); | ||
| } | ||
| } | ||
| // Main execution | ||
| if (isDevelopmentEnvironment()) { | ||
| installPlaywrightBrowsers(); | ||
| } |
| .test { color: red; } |
| { | ||
| "env": { | ||
| "node": true, | ||
| "browser": true | ||
| }, | ||
| "parserOptions": { | ||
| "ecmaVersion": 6 | ||
| } | ||
| } |
| var logMessages = []; | ||
| window.less = window.less || {}; | ||
| var logLevel_debug = 4, | ||
| logLevel_info = 3, | ||
| logLevel_warn = 2, | ||
| logLevel_error = 1; | ||
| // The amount of logging in the javascript console. | ||
| // 3 - Debug, information and errors | ||
| // 2 - Information and errors | ||
| // 1 - Errors | ||
| // 0 - None | ||
| // Defaults to 2 | ||
| less.loggers = [ | ||
| { | ||
| debug: function(msg) { | ||
| if (less.options.logLevel >= logLevel_debug) { | ||
| logMessages.push(msg); | ||
| } | ||
| }, | ||
| info: function(msg) { | ||
| if (less.options.logLevel >= logLevel_info) { | ||
| logMessages.push(msg); | ||
| } | ||
| }, | ||
| warn: function(msg) { | ||
| if (less.options.logLevel >= logLevel_warn) { | ||
| logMessages.push(msg); | ||
| } | ||
| }, | ||
| error: function(msg) { | ||
| if (less.options.logLevel >= logLevel_error) { | ||
| logMessages.push(msg); | ||
| } | ||
| } | ||
| } | ||
| ]; | ||
| testLessEqualsInDocument = function () { | ||
| testLessInDocument(testSheet); | ||
| }; | ||
| testLessErrorsInDocument = function (isConsole) { | ||
| testLessInDocument(isConsole ? testErrorSheetConsole : testErrorSheet); | ||
| }; | ||
| testLessInDocument = function (testFunc) { | ||
| var links = document.getElementsByTagName('link'), | ||
| typePattern = /^text\/(x-)?less$/; | ||
| for (var i = 0; i < links.length; i++) { | ||
| if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) && | ||
| (links[i].type.match(typePattern)))) { | ||
| testFunc(links[i]); | ||
| } | ||
| } | ||
| }; | ||
| ieFormat = function(text) { | ||
| var styleNode = document.createElement('style'); | ||
| styleNode.setAttribute('type', 'text/css'); | ||
| var headNode = document.getElementsByTagName('head')[0]; | ||
| headNode.appendChild(styleNode); | ||
| try { | ||
| if (styleNode.styleSheet) { | ||
| styleNode.styleSheet.cssText = text; | ||
| } else { | ||
| styleNode.innerText = text; | ||
| } | ||
| } catch (e) { | ||
| throw new Error('Couldn\'t reassign styleSheet.cssText.'); | ||
| } | ||
| var transformedText = styleNode.styleSheet ? styleNode.styleSheet.cssText : styleNode.innerText; | ||
| headNode.removeChild(styleNode); | ||
| return transformedText; | ||
| }; | ||
| testSheet = function (sheet) { | ||
| it(sheet.id + ' should match the expected output', function (done) { | ||
| var lessOutputId = sheet.id.replace('original-', ''), | ||
| expectedOutputId = 'expected-' + lessOutputId, | ||
| lessOutputObj, | ||
| lessOutput, | ||
| expectedOutputHref = document.getElementById(expectedOutputId).href, | ||
| expectedOutput = loadFile(expectedOutputHref); | ||
| // Browser spec generates less on the fly, so we need to loose control | ||
| less.pageLoadFinished | ||
| .then(function () { | ||
| lessOutputObj = document.getElementById(lessOutputId); | ||
| lessOutput = lessOutputObj.styleSheet ? lessOutputObj.styleSheet.cssText : | ||
| (lessOutputObj.innerText || lessOutputObj.innerHTML); | ||
| expectedOutput | ||
| .then(function (text) { | ||
| if (window.navigator.userAgent.indexOf('MSIE') >= 0 || | ||
| window.navigator.userAgent.indexOf('Trident/') >= 0) { | ||
| text = ieFormat(text); | ||
| } | ||
| // Normalize URLs: convert absolute URLs back to relative for comparison | ||
| // The browser resolves relative URLs when reading from DOM, but we want to compare against the original relative URLs | ||
| lessOutput = lessOutput.replace(/url\("http:\/\/localhost:8081\/packages\/less\/node_modules\/@less\/test-data\/tests-unit\/([^"]+)"\)/g, 'url("$1")'); | ||
| // Also normalize directory-prefixed relative URLs (e.g., "at-rules/myfont.woff2" -> "myfont.woff2") | ||
| // This happens because the browser resolves URLs relative to the HTML document location | ||
| lessOutput = lessOutput.replace(/url\("([a-z-]+\/)([^"]+)"\)/g, 'url("$2")'); | ||
| // Also normalize @import statements that get resolved to absolute URLs | ||
| lessOutput = lessOutput.replace(/@import "http:\/\/localhost:8081\/packages\/less\/node_modules\/@less\/test-data\/tests-unit\/([^"]+)"(.*);/g, '@import "$1"$2;'); | ||
| // Also normalize @import with directory prefix (e.g., "at-rules-keyword-comments/test.css" -> "test.css") | ||
| lessOutput = lessOutput.replace(/@import "([a-z-]+\/)([^"]+)"(.*);/g, '@import "$2"$3;'); | ||
| expect(lessOutput).to.equal(text); | ||
| done(); | ||
| }) | ||
| .catch(function(err) { | ||
| done(err); | ||
| }); | ||
| }) | ||
| .catch(function(err) { | ||
| done(err); | ||
| }); | ||
| }); | ||
| }; | ||
| // TODO: do it cleaner - the same way as in css | ||
| function extractId(href) { | ||
| return href.replace(/^[a-z-]+:\/+?[^\/]+/i, '') // Remove protocol & domain | ||
| .replace(/^\//, '') // Remove root / | ||
| .replace(/\.[a-zA-Z]+$/, '') // Remove simple extension | ||
| .replace(/[^\.\w-]+/g, '-') // Replace illegal characters | ||
| .replace(/\./g, ':'); // Replace dots with colons(for valid id) | ||
| } | ||
| waitFor = function (waitFunc) { | ||
| return new Promise(function (resolve) { | ||
| var timeoutId = setInterval(function () { | ||
| if (waitFunc()) { | ||
| clearInterval(timeoutId); | ||
| resolve(); | ||
| } | ||
| }, 5); | ||
| }); | ||
| }; | ||
| testErrorSheet = function (sheet) { | ||
| it(sheet.id + ' should match an error', function (done) { | ||
| var lessHref = sheet.href, | ||
| id = 'less-error-message:' + extractId(lessHref), | ||
| errorHref = lessHref.replace(/.less$/, '.txt'), | ||
| errorFile = loadFile(errorHref), | ||
| actualErrorElement, | ||
| actualErrorMsg; | ||
| // Less.js sets 10ms timer in order to add error message on top of page. | ||
| waitFor(function () { | ||
| actualErrorElement = document.getElementById(id); | ||
| return actualErrorElement !== null; | ||
| }).then(function () { | ||
| var innerText = (actualErrorElement.innerHTML | ||
| .replace(/<h3>|<\/?p>|<a href="[^"]*">|<\/a>|<ul>|<\/?pre( class="?[^">]*"?)?>|<\/li>|<\/?label>/ig, '') | ||
| .replace(/<\/h3>/ig, ' ') | ||
| .replace(/<li>|<\/ul>|<br>/ig, '\n')) | ||
| .replace(/&/ig, '&') | ||
| // for IE8 | ||
| .replace(/\r\n/g, '\n') | ||
| .replace(/\. \nin/, '. in'); | ||
| actualErrorMsg = innerText | ||
| .replace(/\n\d+/g, function (lineNo) { | ||
| return lineNo + ' '; | ||
| }) | ||
| .replace(/\n\s*in /g, ' in ') | ||
| .replace(/\n{2,}/g, '\n') | ||
| .replace(/\nStack Trace\n[\s\S]*/i, '') | ||
| .replace(/\n$/, '') | ||
| .trim(); | ||
| actualErrorMsg = actualErrorMsg | ||
| .replace(/ in [\w\-]+\.less( on line \d+, column \d+)?:?$/, '') // Remove filename and optional line/column from end of error message | ||
| .replace(/\{path\}/g, '') | ||
| .replace(/\{pathrel\}/g, '') | ||
| .replace(/\{pathhref\}/g, 'http://localhost:8081/packages/less/node_modules/@less/test-data/tests-error/eval/') | ||
| .replace(/\{404status\}/g, ' (404)') | ||
| .replace(/\{node\}[\s\S]*\{\/node\}/g, '') | ||
| .replace(/\n$/, '') | ||
| .trim(); | ||
| errorFile | ||
| .then(function (errorTxt) { | ||
| errorTxt = errorTxt | ||
| .replace(/\{path\}/g, '') | ||
| .replace(/\{pathrel\}/g, '') | ||
| .replace(/\{pathhref\}/g, 'http://localhost:8081/packages/less/node_modules/@less/test-data/tests-error/eval/') | ||
| .replace(/\{404status\}/g, ' (404)') | ||
| .replace(/\{node\}[\s\S]*\{\/node\}/g, '') | ||
| .replace(/\n$/, '') | ||
| .trim(); | ||
| expect(actualErrorMsg).to.equal(errorTxt); | ||
| if (errorTxt == actualErrorMsg) { | ||
| actualErrorElement.style.display = 'none'; | ||
| } | ||
| done(); | ||
| }) | ||
| .catch(function (err) { | ||
| done(err); | ||
| }); | ||
| }); | ||
| }); | ||
| }; | ||
| testErrorSheetConsole = function (sheet) { | ||
| it(sheet.id + ' should match an error', function (done) { | ||
| var lessHref = sheet.href, | ||
| id = sheet.id.replace(/^original-less:/, 'less-error-message:'), | ||
| errorHref = lessHref.replace(/.less$/, '.txt'), | ||
| errorFile = loadFile(errorHref), | ||
| actualErrorElement = document.getElementById(id), | ||
| actualErrorMsg = logMessages[logMessages.length - 1] | ||
| .replace(/\nStack Trace\n[\s\S]*/, ''); | ||
| describe('the error', function () { | ||
| expect(actualErrorElement).to.be.null; | ||
| }); | ||
| errorFile | ||
| .then(function (errorTxt) { | ||
| errorTxt | ||
| .replace(/\{path\}/g, '') | ||
| .replace(/\{pathrel\}/g, '') | ||
| .replace(/\{pathhref\}/g, 'http://localhost:8081/browser/less/') | ||
| .replace(/\{404status\}/g, ' (404)') | ||
| .replace(/\{node\}.*\{\/node\}/g, '') | ||
| .trim(); | ||
| expect(actualErrorMsg).to.equal(errorTxt); | ||
| done(); | ||
| }); | ||
| }); | ||
| }; | ||
| loadFile = function (href) { | ||
| return new Promise(function (resolve, reject) { | ||
| var request = new XMLHttpRequest(); | ||
| request.open('GET', href, true); | ||
| request.onreadystatechange = function () { | ||
| if (request.readyState == 4) { | ||
| resolve(request.responseText.replace(/\r/g, '')); | ||
| } | ||
| }; | ||
| request.send(null); | ||
| }); | ||
| }; |
| .test { | ||
| color: red; | ||
| } |
| .testisimported { | ||
| color: gainsboro; | ||
| } | ||
| .test { | ||
| color1: green; | ||
| color2: purple; | ||
| scalar: 20; | ||
| } |
| .test { | ||
| val: http://localhost:8081/packages/less/tmp/browser/test-runner-browser.html; | ||
| } |
| hr {height:50px;} | ||
| .test { | ||
| color: white; | ||
| } |
| @import "http://localhost:8081/packages/less/test/browser/less/imports/modify-this.css"; | ||
| @import "http://localhost:8081/packages/less/test/browser/less/imports/modify-again.css"; | ||
| .modify { | ||
| my-url: url("http://localhost:8081/packages/less/test/browser/less/imports/a.png"); | ||
| } | ||
| .modify { | ||
| my-url: url("http://localhost:8081/packages/less/test/browser/less/imports/b.png"); | ||
| } | ||
| @font-face { | ||
| src: url("/fonts/garamond-pro.ttf"); | ||
| src: local(Futura-Medium), url(http://localhost:8081/packages/less/test/browser/less/relative-urls/fonts.svg#MyGeometricModern) format("svg"); | ||
| } | ||
| #shorthands { | ||
| background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px; | ||
| } | ||
| #misc { | ||
| background-image: url(http://localhost:8081/packages/less/test/browser/less/relative-urls/images/image.jpg); | ||
| background: url("#inline-svg"); | ||
| } | ||
| #data-uri { | ||
| background: url(data:image/png;charset=utf-8;base64, | ||
| kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/ | ||
| k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U | ||
| kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC); | ||
| background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==); | ||
| background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700); | ||
| } | ||
| #svg-data-uri { | ||
| background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>'); | ||
| } | ||
| .comma-delimited { | ||
| background: url(http://localhost:8081/packages/less/test/browser/less/relative-urls/bg.jpg) no-repeat, url(http://localhost:8081/packages/less/test/browser/less/relative-urls/bg.png) repeat-x top left, url(http://localhost:8081/packages/less/test/browser/less/relative-urls/bg); | ||
| } | ||
| .values { | ||
| url: url('http://localhost:8081/packages/less/test/browser/less/relative-urls/Trebuchet'); | ||
| } |
| @import "http://localhost:8081/packages/less/test/browser/less/imports/modify-this.css"; | ||
| @import "http://localhost:8081/packages/less/test/browser/less/imports/modify-again.css"; | ||
| .modify { | ||
| my-url: url("http://localhost:8081/packages/less/test/browser/less/imports/a.png"); | ||
| } | ||
| .modify { | ||
| my-url: url("http://localhost:8081/packages/less/test/browser/less/imports/b.png"); | ||
| } | ||
| @font-face { | ||
| src: url("/fonts/garamond-pro.ttf"); | ||
| src: local(Futura-Medium), url(http://localhost:8081/packages/less/test/browser/less/rewrite-urls/fonts.svg#MyGeometricModern) format("svg"); | ||
| } | ||
| #shorthands { | ||
| background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px; | ||
| } | ||
| #misc { | ||
| background-image: url(http://localhost:8081/packages/less/test/browser/less/rewrite-urls/images/image.jpg); | ||
| background: url("#inline-svg"); | ||
| } | ||
| #data-uri { | ||
| background: url(data:image/png;charset=utf-8;base64, | ||
| kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/ | ||
| k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U | ||
| kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC); | ||
| background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==); | ||
| background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700); | ||
| } | ||
| #svg-data-uri { | ||
| background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>'); | ||
| } | ||
| .comma-delimited { | ||
| background: url(http://localhost:8081/packages/less/test/browser/less/rewrite-urls/bg.jpg) no-repeat, url(http://localhost:8081/packages/less/test/browser/less/rewrite-urls/bg.png) repeat-x top left, url(http://localhost:8081/packages/less/test/browser/less/rewrite-urls/bg); | ||
| } | ||
| .values { | ||
| url: url('http://localhost:8081/packages/less/test/browser/less/rewrite-urls/Trebuchet'); | ||
| } |
| @import "https://www.github.com/cloudhead/imports/modify-this.css"; | ||
| @import "https://www.github.com/cloudhead/imports/modify-again.css"; | ||
| .modify { | ||
| my-url: url("https://www.github.com/cloudhead/imports/a.png"); | ||
| } | ||
| .modify { | ||
| my-url: url("https://www.github.com/cloudhead/imports/b.png"); | ||
| } | ||
| @font-face { | ||
| src: url("/fonts/garamond-pro.ttf"); | ||
| src: local(Futura-Medium), url(https://www.github.com/cloudhead/less.js/fonts.svg#MyGeometricModern) format("svg"); | ||
| } | ||
| #shorthands { | ||
| background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px; | ||
| } | ||
| #misc { | ||
| background-image: url(https://www.github.com/cloudhead/less.js/images/image.jpg); | ||
| } | ||
| #data-uri { | ||
| background: url(data:image/png;charset=utf-8;base64, | ||
| kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/ | ||
| k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U | ||
| kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC); | ||
| background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==); | ||
| background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700); | ||
| } | ||
| #svg-data-uri { | ||
| background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>'); | ||
| } | ||
| .comma-delimited { | ||
| background: url(https://www.github.com/cloudhead/less.js/bg.jpg) no-repeat, url(https://www.github.com/cloudhead/less.js/bg.png) repeat-x top left, url(https://www.github.com/cloudhead/less.js/bg); | ||
| } | ||
| .values { | ||
| url: url('https://www.github.com/cloudhead/less.js/Trebuchet'); | ||
| } |
| @import "https://www.github.com/cloudhead/imports/modify-this.css"; | ||
| @import "https://www.github.com/cloudhead/imports/modify-again.css"; | ||
| .modify { | ||
| my-url: url("https://www.github.com/cloudhead/imports/a.png"); | ||
| } | ||
| .modify { | ||
| my-url: url("https://www.github.com/cloudhead/imports/b.png"); | ||
| } | ||
| @font-face { | ||
| src: url("/fonts/garamond-pro.ttf"); | ||
| src: local(Futura-Medium), url(https://www.github.com/cloudhead/less.js/fonts.svg#MyGeometricModern) format("svg"); | ||
| } | ||
| #shorthands { | ||
| background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px; | ||
| } | ||
| #misc { | ||
| background-image: url(https://www.github.com/cloudhead/less.js/images/image.jpg); | ||
| } | ||
| #data-uri { | ||
| background: url(data:image/png;charset=utf-8;base64, | ||
| kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/ | ||
| k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U | ||
| kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC); | ||
| background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==); | ||
| background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700); | ||
| } | ||
| #svg-data-uri { | ||
| background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>'); | ||
| } | ||
| .comma-delimited { | ||
| background: url(https://www.github.com/cloudhead/less.js/bg.jpg) no-repeat, url(https://www.github.com/cloudhead/less.js/bg.png) repeat-x top left, url(https://www.github.com/cloudhead/less.js/bg); | ||
| } | ||
| .values { | ||
| url: url('https://www.github.com/cloudhead/less.js/Trebuchet'); | ||
| } |
| @import "https://localhost/modify-this.css"; | ||
| @import "https://localhost/modify-again.css"; | ||
| .modify { | ||
| my-url: url("https://localhost/a.png"); | ||
| } | ||
| .modify { | ||
| my-url: url("https://localhost/b.png"); | ||
| } | ||
| @font-face { | ||
| src: url("/fonts/garamond-pro.ttf"); | ||
| src: local(Futura-Medium), url(https://localhost/fonts.svg#MyGeometricModern) format("svg"); | ||
| } | ||
| #shorthands { | ||
| background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px; | ||
| } | ||
| #misc { | ||
| background-image: url(https://localhost/images/image.jpg); | ||
| } | ||
| #data-uri { | ||
| background: url(data:image/png;charset=utf-8;base64, | ||
| kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/ | ||
| k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U | ||
| kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC); | ||
| background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==); | ||
| background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700); | ||
| } | ||
| #svg-data-uri { | ||
| background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>'); | ||
| } | ||
| .comma-delimited { | ||
| background: url(https://localhost/bg.jpg) no-repeat, url(https://localhost/bg.png) repeat-x top left, url(https://localhost/bg); | ||
| } | ||
| .values { | ||
| url: url('https://localhost/Trebuchet'); | ||
| } |
| @import "http://localhost:8081/packages/less/test/browser/less/modify-this.css"; | ||
| @import "http://localhost:8081/packages/less/test/browser/less/modify-again.css"; | ||
| .modify { | ||
| my-url: url("http://localhost:8081/packages/less/test/browser/less/a.png"); | ||
| } | ||
| .modify { | ||
| my-url: url("http://localhost:8081/packages/less/test/browser/less/b.png"); | ||
| } | ||
| .gray-gradient { | ||
| background: url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201%201%22%3E%3ClinearGradient%20id%3D%22g%22%20x1%3D%220%25%22%20y1%3D%220%25%22%20x2%3D%220%25%22%20y2%3D%22100%25%22%3E%3Cstop%20offset%3D%220%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220%22%2F%3E%3Cstop%20offset%3D%2260%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.05%22%2F%3E%3Cstop%20offset%3D%2270%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.1%22%2F%3E%3Cstop%20offset%3D%2273%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.15%22%2F%3E%3Cstop%20offset%3D%2275%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.2%22%2F%3E%3Cstop%20offset%3D%2280%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.25%22%2F%3E%3Cstop%20offset%3D%2285%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.3%22%2F%3E%3Cstop%20offset%3D%2288%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.35%22%2F%3E%3Cstop%20offset%3D%2290%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.4%22%2F%3E%3Cstop%20offset%3D%2295%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.45%22%2F%3E%3Cstop%20offset%3D%22100%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.5%22%2F%3E%3C%2FlinearGradient%3E%3Crect%20x%3D%220%22%20y%3D%220%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22url(%23g)%22%20%2F%3E%3C%2Fsvg%3E'); | ||
| } | ||
| @font-face { | ||
| src: url("/fonts/garamond-pro.ttf"); | ||
| src: local(Futura-Medium), url(http://localhost:8081/packages/less/test/browser/less/fonts.svg#MyGeometricModern) format("svg"); | ||
| not-a-comment: url(//z); | ||
| } | ||
| #shorthands { | ||
| background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px; | ||
| } | ||
| #misc { | ||
| background-image: url(http://localhost:8081/packages/less/test/browser/less/images/image.jpg); | ||
| } | ||
| #data-uri { | ||
| background: url(data:image/png;charset=utf-8;base64, | ||
| kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/ | ||
| k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U | ||
| kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC); | ||
| background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==); | ||
| background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700); | ||
| } | ||
| #svg-data-uri { | ||
| background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>'); | ||
| } | ||
| .comma-delimited { | ||
| background: url(http://localhost:8081/packages/less/test/browser/less/bg.jpg) no-repeat, url(http://localhost:8081/packages/less/test/browser/less/bg.png) repeat-x top left, url(http://localhost:8081/packages/less/test/browser/less/bg); | ||
| } | ||
| .values { | ||
| url: url('http://localhost:8081/packages/less/test/browser/less/Trebuchet'); | ||
| } | ||
| #data-uri { | ||
| uri: url('http://localhost:8081/packages/less/test/data/image.jpg'); | ||
| } | ||
| #data-uri-guess { | ||
| uri: url('http://localhost:8081/packages/less/test/data/image.jpg'); | ||
| } | ||
| #data-uri-ascii { | ||
| uri-1: url('http://localhost:8081/packages/less/test/data/page.html'); | ||
| uri-2: url('http://localhost:8081/packages/less/test/data/page.html'); | ||
| } | ||
| #svg-functions { | ||
| background-image: url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201%201%22%3E%3ClinearGradient%20id%3D%22g%22%20x1%3D%220%25%22%20y1%3D%220%25%22%20x2%3D%220%25%22%20y2%3D%22100%25%22%3E%3Cstop%20offset%3D%220%25%22%20stop-color%3D%22%23000000%22%2F%3E%3Cstop%20offset%3D%22100%25%22%20stop-color%3D%22%23ffffff%22%2F%3E%3C%2FlinearGradient%3E%3Crect%20x%3D%220%22%20y%3D%220%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22url(%23g)%22%20%2F%3E%3C%2Fsvg%3E'); | ||
| background-image: url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201%201%22%3E%3ClinearGradient%20id%3D%22g%22%20x1%3D%220%25%22%20y1%3D%220%25%22%20x2%3D%220%25%22%20y2%3D%22100%25%22%3E%3Cstop%20offset%3D%220%25%22%20stop-color%3D%22%23000000%22%2F%3E%3Cstop%20offset%3D%223%25%22%20stop-color%3D%22%23ffa500%22%2F%3E%3Cstop%20offset%3D%22100%25%22%20stop-color%3D%22%23ffffff%22%2F%3E%3C%2FlinearGradient%3E%3Crect%20x%3D%220%22%20y%3D%220%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22url(%23g)%22%20%2F%3E%3C%2Fsvg%3E'); | ||
| background-image: url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201%201%22%3E%3ClinearGradient%20id%3D%22g%22%20x1%3D%220%25%22%20y1%3D%220%25%22%20x2%3D%220%25%22%20y2%3D%22100%25%22%3E%3Cstop%20offset%3D%221%25%22%20stop-color%3D%22%23c4c4c4%22%2F%3E%3Cstop%20offset%3D%223%25%22%20stop-color%3D%22%23ffa500%22%2F%3E%3Cstop%20offset%3D%225%25%22%20stop-color%3D%22%23008000%22%2F%3E%3Cstop%20offset%3D%2295%25%22%20stop-color%3D%22%23ffffff%22%2F%3E%3C%2FlinearGradient%3E%3Crect%20x%3D%220%22%20y%3D%220%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22url(%23g)%22%20%2F%3E%3C%2Fsvg%3E'); | ||
| } |
| module.exports = { | ||
| current: { | ||
| // src is used to build list of less files to compile | ||
| src: [ | ||
| 'benchmark/benchmark.less' | ||
| ], | ||
| options: { | ||
| helpers: 'benchmark/browseroptions.js', | ||
| specs: 'benchmark/browserspec.js', | ||
| outfile: 'tmp/browser/test-runner-benchmark-current.html' | ||
| } | ||
| }, | ||
| v3_10_3: { | ||
| // src is used to build list of less files to compile | ||
| src: [ | ||
| 'benchmark/benchmark.less' | ||
| ], | ||
| options: { | ||
| helpers: 'benchmark/browseroptions.js', | ||
| specs: 'benchmark/browserspec.js', | ||
| outfile: 'tmp/browser/test-runner-benchmark-v3_10_3.html', | ||
| less: 'https://cdnjs.cloudflare.com/ajax/libs/less.js/3.10.3/less.min.js' | ||
| } | ||
| }, | ||
| v3_9_0: { | ||
| // src is used to build list of less files to compile | ||
| src: [ | ||
| 'benchmark/benchmark.less' | ||
| ], | ||
| options: { | ||
| helpers: 'benchmark/browseroptions.js', | ||
| specs: 'benchmark/browserspec.js', | ||
| outfile: 'tmp/browser/test-runner-benchmark-v3_9_0.html', | ||
| less: 'https://cdnjs.cloudflare.com/ajax/libs/less.js/3.9.0/less.min.js' | ||
| } | ||
| }, | ||
| v2_7_3: { | ||
| // src is used to build list of less files to compile | ||
| src: [ | ||
| 'benchmark/benchmark.less' | ||
| ], | ||
| options: { | ||
| helpers: 'benchmark/browseroptions.js', | ||
| specs: 'benchmark/browserspec.js', | ||
| outfile: 'tmp/browser/test-runner-benchmark-v2_7_3.html', | ||
| less: 'https://cdnjs.cloudflare.com/ajax/libs/less.js/2.7.3/less.min.js' | ||
| } | ||
| } | ||
| } |
| const template = require('./template') | ||
| let config | ||
| const fs = require('fs-extra') | ||
| const path = require('path') | ||
| const globby = require('globby') | ||
| const { runner } = require('../../mocha-playwright/runner') | ||
| if (process.argv[2]) { | ||
| config = require(`./${process.argv[2]}.config`) | ||
| } else { | ||
| config = require('./runner.config') | ||
| } | ||
| /** | ||
| * Generate templates and run tests | ||
| */ | ||
| const tests = [] | ||
| const cwd = process.cwd() | ||
| const tmpDir = path.join(cwd, 'tmp', 'browser') | ||
| fs.ensureDirSync(tmpDir) | ||
| fs.copySync(path.join(cwd, 'test', 'browser', 'common.js'), path.join(tmpDir, 'common.js')) | ||
| let numTests = 0 | ||
| let passedTests = 0 | ||
| let failedTests = 0 | ||
| /** Will run the runners in a series */ | ||
| function runSerial(tasks) { | ||
| var result = Promise.resolve() | ||
| start = Date.now() | ||
| tasks.forEach(task => { | ||
| result = result.then(result => { | ||
| if (result && result.result && result.result.stats) { | ||
| const stats = result.result.stats | ||
| numTests += stats.tests | ||
| passedTests += stats.passes | ||
| failedTests += stats.failures | ||
| } | ||
| return task() | ||
| }, err => { | ||
| console.log(err) | ||
| failedTests += 1 | ||
| }) | ||
| }) | ||
| return result | ||
| } | ||
| Object.entries(config).forEach(entry => { | ||
| const test = entry[1] | ||
| const paths = globby.sync(test.src) | ||
| const templateString = template(paths, test.options.helpers, test.options.specs) | ||
| fs.writeFileSync(path.join(cwd, test.options.outfile), templateString) | ||
| tests.push(() => { | ||
| const file = 'http://localhost:8081/packages/less/' + test.options.outfile | ||
| console.log(file) | ||
| return runner({ | ||
| file, | ||
| timeout: 3500, | ||
| args: ['disable-web-security', 'no-sandbox', 'disable-setuid-sandbox'], | ||
| }) | ||
| }) | ||
| }) | ||
| module.exports = () => runSerial(tests).then(() => { | ||
| if (failedTests > 0) { | ||
| process.stderr.write(failedTests + ' Failed, ' + passedTests + ' passed\n'); | ||
| } else { | ||
| process.stdout.write('All Passed ' + passedTests + ' run\n'); | ||
| } | ||
| if (failedTests) { | ||
| process.on('exit', function() { process.reallyExit(1); }); | ||
| } | ||
| process.exit() | ||
| }, err => { | ||
| process.stderr.write(err.message); | ||
| process.exit() | ||
| }) |
| var path = require('path'); | ||
| var resolve = require('resolve') | ||
| var { forceCovertToBrowserPath } = require('./utils'); | ||
| /** Root of repo */ | ||
| var testFolder = forceCovertToBrowserPath(path.dirname(resolve.sync('@less/test-data'))); | ||
| var testsUnitFolder = forceCovertToBrowserPath(path.join(testFolder, 'tests-unit')); | ||
| var testsConfigFolder = forceCovertToBrowserPath(path.join(testFolder, 'tests-config')); | ||
| var localTests = forceCovertToBrowserPath(path.resolve(__dirname, '..')); | ||
| module.exports = { | ||
| main: { | ||
| // src is used to build list of less files to compile | ||
| src: [ | ||
| `${testsUnitFolder}/*/*.less`, | ||
| `!${testsUnitFolder}/plugin-preeval/plugin-preeval.less`, // uses ES6 syntax | ||
| // Don't test NPM import, obviously | ||
| `!${testsUnitFolder}/plugin-module/plugin-module.less`, | ||
| `!${testsUnitFolder}/import/import-module.less`, | ||
| `!${testsUnitFolder}/javascript/javascript.less`, | ||
| `!${testsUnitFolder}/urls/urls.less`, | ||
| `!${testsUnitFolder}/empty/empty.less`, | ||
| `!${testsUnitFolder}/color-functions/operations.less`, // conflicts with operations/operations.less | ||
| // Exclude debug line numbers tests - these are Node.js only (dumpLineNumbers is deprecated) | ||
| `!${testsConfigFolder}/debug/**/*.less` | ||
| ], | ||
| options: { | ||
| helpers: 'test/browser/runner-main-options.js', | ||
| specs: 'test/browser/runner-main-spec.js', | ||
| outfile: 'tmp/browser/test-runner-main.html' | ||
| } | ||
| }, | ||
| strictUnits: { | ||
| src: [`${testsConfigFolder}/units/strict/*.less`], | ||
| options: { | ||
| helpers: 'test/browser/runner-strict-units-options.js', | ||
| specs: 'test/browser/runner-strict-units-spec.js', | ||
| outfile: 'tmp/browser/test-runner-strict-units.html' | ||
| } | ||
| }, | ||
| errors: { | ||
| src: [ | ||
| `${testFolder}/tests-error/eval/*.less`, | ||
| `${testFolder}/tests-error/parse/*.less`, | ||
| `${localTests}/less/errors/*.less` | ||
| ], | ||
| options: { | ||
| timeout: 20000, | ||
| helpers: 'test/browser/runner-errors-options.js', | ||
| specs: 'test/browser/runner-errors-spec.js', | ||
| outfile: 'tmp/browser/test-runner-errors.html' | ||
| } | ||
| }, | ||
| noJsErrors: { | ||
| src: [`${testsConfigFolder}/no-js-errors/*.less`], | ||
| options: { | ||
| helpers: 'test/browser/runner-no-js-errors-options.js', | ||
| specs: 'test/browser/runner-no-js-errors-spec.js', | ||
| outfile: 'tmp/browser/test-runner-no-js-errors.html' | ||
| } | ||
| }, | ||
| browser: { | ||
| src: [ | ||
| `${localTests}/less/*.less`, | ||
| `${localTests}/less/plugin/*.less` | ||
| ], | ||
| options: { | ||
| helpers: 'test/browser/runner-browser-options.js', | ||
| specs: 'test/browser/runner-browser-spec.js', | ||
| outfile: 'tmp/browser/test-runner-browser.html' | ||
| } | ||
| }, | ||
| relativeUrls: { | ||
| src: [`${localTests}/less/relative-urls/*.less`], | ||
| options: { | ||
| helpers: 'test/browser/runner-relative-urls-options.js', | ||
| specs: 'test/browser/runner-relative-urls-spec.js', | ||
| outfile: 'tmp/browser/test-runner-relative-urls.html' | ||
| } | ||
| }, | ||
| rewriteUrls: { | ||
| src: [`${localTests}/less/rewrite-urls/*.less`], | ||
| options: { | ||
| helpers: 'test/browser/runner-rewrite-urls-options.js', | ||
| specs: 'test/browser/runner-rewrite-urls-spec.js', | ||
| outfile: 'tmp/browser/test-runner-rewrite-urls.html' | ||
| } | ||
| }, | ||
| rootpath: { | ||
| src: [`${localTests}/less/rootpath/*.less`], | ||
| options: { | ||
| helpers: 'test/browser/runner-rootpath-options.js', | ||
| specs: 'test/browser/runner-rootpath-spec.js', | ||
| outfile: 'tmp/browser/test-runner-rootpath.html' | ||
| } | ||
| }, | ||
| rootpathRelative: { | ||
| src: [`${localTests}/less/rootpath-relative/*.less`], | ||
| options: { | ||
| helpers: 'test/browser/runner-rootpath-relative-options.js', | ||
| specs: 'test/browser/runner-rootpath-relative-spec.js', | ||
| outfile: 'tmp/browser/test-runner-rootpath-relative.html' | ||
| } | ||
| }, | ||
| rootpathRewriteUrls: { | ||
| src: [`${localTests}/less/rootpath-rewrite-urls/*.less`], | ||
| options: { | ||
| helpers: | ||
| 'test/browser/runner-rootpath-rewrite-urls-options.js', | ||
| specs: 'test/browser/runner-rootpath-rewrite-urls-spec.js', | ||
| outfile: | ||
| 'tmp/browser/test-runner-rootpath-rewrite-urls.html' | ||
| } | ||
| }, | ||
| production: { | ||
| src: [`${localTests}/less/production/*.less`], | ||
| options: { | ||
| helpers: 'test/browser/runner-production-options.js', | ||
| specs: 'test/browser/runner-production-spec.js', | ||
| outfile: 'tmp/browser/test-runner-production.html' | ||
| } | ||
| }, | ||
| modifyVars: { | ||
| src: [`${localTests}/less/modify-vars/*.less`], | ||
| options: { | ||
| helpers: 'test/browser/runner-modify-vars-options.js', | ||
| specs: 'test/browser/runner-modify-vars-spec.js', | ||
| outfile: 'tmp/browser/test-runner-modify-vars.html' | ||
| } | ||
| }, | ||
| globalVars: { | ||
| src: [`${localTests}/less/global-vars/*.less`], | ||
| options: { | ||
| helpers: 'test/browser/runner-global-vars-options.js', | ||
| specs: 'test/browser/runner-global-vars-spec.js', | ||
| outfile: 'tmp/browser/test-runner-global-vars.html' | ||
| } | ||
| }, | ||
| postProcessorPlugin: { | ||
| src: [`${testsConfigFolder}/postProcessorPlugin/*.less`], | ||
| options: { | ||
| helpers: [ | ||
| 'test/plugins/postprocess/index.js', | ||
| 'test/browser/runner-postProcessorPlugin-options.js' | ||
| ], | ||
| specs: 'test/browser/runner-postProcessorPlugin.js', | ||
| outfile: | ||
| 'tmp/browser/test-runner-post-processor-plugin.html' | ||
| } | ||
| }, | ||
| preProcessorPlugin: { | ||
| src: [`${testsConfigFolder}/preProcessorPlugin/*.less`], | ||
| options: { | ||
| helpers: [ | ||
| 'test/plugins/preprocess/index.js', | ||
| 'test/browser/runner-preProcessorPlugin-options.js' | ||
| ], | ||
| specs: 'test/browser/runner-preProcessorPlugin.js', | ||
| outfile: 'tmp/browser/test-runner-pre-processor-plugin.html' | ||
| } | ||
| }, | ||
| visitorPlugin: { | ||
| src: [`${testsConfigFolder}/visitorPlugin/*.less`], | ||
| options: { | ||
| helpers: [ | ||
| 'test/plugins/visitor/index.js', | ||
| 'test/browser/runner-VisitorPlugin-options.js' | ||
| ], | ||
| specs: 'test/browser/runner-VisitorPlugin.js', | ||
| outfile: 'tmp/browser/test-runner-visitor-plugin.html' | ||
| } | ||
| }, | ||
| filemanagerPlugin: { | ||
| src: [`${testsConfigFolder}/filemanagerPlugin/*.less`], | ||
| options: { | ||
| helpers: [ | ||
| 'test/plugins/filemanager/index.js', | ||
| 'test/browser/runner-filemanagerPlugin-options.js' | ||
| ], | ||
| specs: 'test/browser/runner-filemanagerPlugin.js', | ||
| outfile: 'tmp/browser/test-runner-filemanager-plugin.html' | ||
| } | ||
| } | ||
| } |
| const runner = require('./generate') | ||
| runner() |
| const html = require('html-template-tag') | ||
| const path = require('path') | ||
| const { forceCovertToBrowserPath } = require('./utils') | ||
| const webRoot = path.resolve(__dirname, '../../../../../'); | ||
| const mochaDir = forceCovertToBrowserPath(path.relative(webRoot, path.dirname(require.resolve('mocha')))) | ||
| const chaiDir = forceCovertToBrowserPath(path.relative(webRoot, path.dirname(require.resolve('chai')))) | ||
| const mochaTeamCityDir = forceCovertToBrowserPath(path.relative(webRoot, path.dirname(require.resolve('mocha-teamcity-reporter')))) | ||
| /** | ||
| * Generates HTML templates from list of test sheets | ||
| */ | ||
| module.exports = (stylesheets, helpers, spec, less) => { | ||
| if (!Array.isArray(helpers)) { | ||
| helpers = [helpers] | ||
| } | ||
| return html` | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Less.js Spec Runner</title> | ||
| <!-- for each test, generate CSS/LESS link tags --> | ||
| $${stylesheets.map(function(fullLessName) { | ||
| var pathParts = fullLessName.split('/'); | ||
| var fullCssName = fullLessName.replace(/less$/, 'css'); | ||
| // Check if the CSS file exists in the same directory as the LESS file | ||
| var fs = require('fs'); | ||
| var cssExists = fs.existsSync(fullCssName); | ||
| // If not, try the css/ directory for local browser tests | ||
| if (!cssExists && fullLessName.includes('/test/browser/less/')) { | ||
| var cssInCssDir = fullLessName.replace('/test/browser/less/', '/test/browser/css/').replace(/less$/, 'css'); | ||
| if (fs.existsSync(cssInCssDir)) { | ||
| fullCssName = cssInCssDir; | ||
| } | ||
| } | ||
| var lessName = pathParts[pathParts.length - 1]; | ||
| var name = lessName.split('.')[0]; | ||
| return ` | ||
| <!-- the tags to be generated --> | ||
| <link id="original-less:test-less-${name}" title="test-less-${name}" rel="stylesheet/less" type="text/css" href="/${path.relative(webRoot, fullLessName)}"> | ||
| <link id="expected-less:test-less-${name}" rel="stylesheet" type="text/css" href="/${path.relative(webRoot, fullCssName)}"> | ||
| ` }).join('')} | ||
| $${helpers.map(helper => ` | ||
| <script src="../../${helper}"></script> | ||
| `).join('')} | ||
| <link rel="stylesheet" href="/${mochaDir}/mocha.css"> | ||
| </head> | ||
| <body> | ||
| <!-- content --> | ||
| <div id="mocha"></div> | ||
| <script src="/${mochaDir}/mocha.js"></script> | ||
| <script src="/${mochaTeamCityDir}/teamcityBrowser.js"></script> | ||
| <script src="/${chaiDir}/chai.js"></script> | ||
| <script> | ||
| expect = chai.expect | ||
| mocha.setup({ | ||
| ui: 'bdd', | ||
| timeout: 2500 | ||
| }); | ||
| </script> | ||
| <script src="common.js"></script> | ||
| <script src="../../${spec}"></script> | ||
| <script src="${less || 'less.min.js'}"></script> | ||
| <script> | ||
| /** Saucelabs config */ | ||
| onload = function() { | ||
| var runner = mocha.run(); | ||
| var failedTests = []; | ||
| runner.on('end', function() { | ||
| window.mochaResults = runner.stats; | ||
| window.mochaResults.reports = failedTests; | ||
| }); | ||
| runner.on('fail', logFailure); | ||
| function logFailure(test, err){ | ||
| var flattenTitles = function(test){ | ||
| var titles = []; | ||
| while (test.parent.title) { | ||
| titles.push(test.parent.title); | ||
| test = test.parent; | ||
| } | ||
| return titles.reverse(); | ||
| }; | ||
| failedTests.push({name: test.title, result: false, message: err.message, stack: err.stack, titles: flattenTitles(test) }); | ||
| }; | ||
| }; | ||
| </script> | ||
| </body> | ||
| </html> | ||
| ` | ||
| } |
| /** | ||
| * utils for covert browser paths, | ||
| * fix https://github.com/less/less.js/pull/4213 | ||
| * | ||
| * @param {string} path | ||
| * @returns {string} | ||
| */ | ||
| function forceCovertToBrowserPath (path) { | ||
| return (path || '').replace(/\\/g, '/'); | ||
| } | ||
| module.exports = { | ||
| forceCovertToBrowserPath | ||
| } |
| .a { | ||
| prop: (3 / #fff); | ||
| } |
| less: OperationError: Can't subtract or divide a color from a number in {pathhref}console-errors/test-error.less on line null, column 0: | ||
| 1 prop: (3 / #fff); |
| .test-height{ | ||
| height: image-height("../data/image.jpg") | ||
| } |
| RuntimeError: Error evaluating function `image-height`: Image size functions are not supported in browser version of less in image-height-error.less on line 2, column 11: | ||
| 1 .test-height{ | ||
| 2 height: image-height("../data/image.jpg") | ||
| 3 } |
| .test-size{ | ||
| size: image-size("../data/image.jpg") | ||
| } |
| RuntimeError: Error evaluating function `image-size`: Image size functions are not supported in browser version of less in image-size-error.less on line 2, column 9: | ||
| 1 .test-size{ | ||
| 2 size: image-size("../data/image.jpg") | ||
| 3 } |
| .test-width{ | ||
| width: image-width("../data/image.jpg") | ||
| } |
| RuntimeError: Error evaluating function `image-width`: Image size functions are not supported in browser version of less in image-width-error.less on line 2, column 10: | ||
| 1 .test-width{ | ||
| 2 width: image-width("../data/image.jpg") | ||
| 3 } |
| .test { | ||
| color: @global-var; | ||
| } |
| @import "modify-this.css"; | ||
| .modify { | ||
| my-url: url("a.png"); | ||
| } |
| @import "modify-again.css"; | ||
| .modify { | ||
| my-url: url("b.png"); | ||
| } |
| @var2: blue; | ||
| .testisimported { | ||
| color: gainsboro; | ||
| } |
| @import "imports/simple2"; | ||
| @var1: red; | ||
| @scale: 10; | ||
| .test { | ||
| color1: @var1; | ||
| color2: @var2; | ||
| scalar: @scale | ||
| } |
| @import "svg-gradient-mixin.less"; | ||
| .gray-gradient { | ||
| .gradient-mixin(#999); | ||
| } |
| .gradient-mixin(@color) { | ||
| background: svg-gradient(to bottom, | ||
| fade(@color, 0%) 0%, | ||
| fade(@color, 5%) 60%, | ||
| fade(@color, 10%) 70%, | ||
| fade(@color, 15%) 73%, | ||
| fade(@color, 20%) 75%, | ||
| fade(@color, 25%) 80%, | ||
| fade(@color, 30%) 85%, | ||
| fade(@color, 35%) 88%, | ||
| fade(@color, 40%) 90%, | ||
| fade(@color, 45%) 95%, | ||
| fade(@color, 50%) 100% | ||
| ); | ||
| } |
| functions.add('func', function() { | ||
| return less.anonymous(location.href); | ||
| }); |
| @plugin "plugin"; | ||
| .test { | ||
| val: func(); | ||
| } |
| @color: white; | ||
| .test { | ||
| color: @color; | ||
| } |
| @import ".././imports/urls.less"; | ||
| @import "http://localhost:8081/packages/less/test/browser/less/imports/urls2.less"; | ||
| @font-face { | ||
| src: url("/fonts/garamond-pro.ttf"); | ||
| src: local(Futura-Medium), | ||
| url(fonts.svg#MyGeometricModern) format("svg"); | ||
| } | ||
| #shorthands { | ||
| background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px; | ||
| } | ||
| #misc { | ||
| background-image: url(images/image.jpg); | ||
| background: url("#inline-svg"); | ||
| } | ||
| #data-uri { | ||
| background: url(data:image/png;charset=utf-8;base64, | ||
| kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/ | ||
| k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U | ||
| kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC); | ||
| background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==); | ||
| background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700); | ||
| } | ||
| #svg-data-uri { | ||
| background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>'); | ||
| } | ||
| .comma-delimited { | ||
| background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg); | ||
| } | ||
| .values { | ||
| @a: 'Trebuchet'; | ||
| url: url(@a); | ||
| } |
| @import ".././imports/urls.less"; | ||
| @import "http://localhost:8081/packages/less/test/browser/less/imports/urls2.less"; | ||
| @font-face { | ||
| src: url("/fonts/garamond-pro.ttf"); | ||
| src: local(Futura-Medium), | ||
| url(fonts.svg#MyGeometricModern) format("svg"); | ||
| } | ||
| #shorthands { | ||
| background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px; | ||
| } | ||
| #misc { | ||
| background-image: url(images/image.jpg); | ||
| background: url("#inline-svg"); | ||
| } | ||
| #data-uri { | ||
| background: url(data:image/png;charset=utf-8;base64, | ||
| kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/ | ||
| k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U | ||
| kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC); | ||
| background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==); | ||
| background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700); | ||
| } | ||
| #svg-data-uri { | ||
| background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>'); | ||
| } | ||
| .comma-delimited { | ||
| background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg); | ||
| } | ||
| .values { | ||
| @a: 'Trebuchet'; | ||
| url: url(@a); | ||
| } |
| @import "../imports/urls.less"; | ||
| @import "http://localhost:8081/packages/less/test/browser/less/imports/urls2.less"; | ||
| @font-face { | ||
| src: url("/fonts/garamond-pro.ttf"); | ||
| src: local(Futura-Medium), | ||
| url(fonts.svg#MyGeometricModern) format("svg"); | ||
| } | ||
| #shorthands { | ||
| background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px; | ||
| } | ||
| #misc { | ||
| background-image: url(images/image.jpg); | ||
| } | ||
| #data-uri { | ||
| background: url(data:image/png;charset=utf-8;base64, | ||
| kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/ | ||
| k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U | ||
| kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC); | ||
| background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==); | ||
| background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700); | ||
| } | ||
| #svg-data-uri { | ||
| background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>'); | ||
| } | ||
| .comma-delimited { | ||
| background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg); | ||
| } | ||
| .values { | ||
| @a: 'Trebuchet'; | ||
| url: url(@a); | ||
| } |
| @import "../imports/urls.less"; | ||
| @import "http://localhost:8081/packages/less/test/browser/less/imports/urls2.less"; | ||
| @font-face { | ||
| src: url("/fonts/garamond-pro.ttf"); | ||
| src: local(Futura-Medium), | ||
| url(fonts.svg#MyGeometricModern) format("svg"); | ||
| } | ||
| #shorthands { | ||
| background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px; | ||
| } | ||
| #misc { | ||
| background-image: url(images/image.jpg); | ||
| } | ||
| #data-uri { | ||
| background: url(data:image/png;charset=utf-8;base64, | ||
| kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/ | ||
| k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U | ||
| kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC); | ||
| background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==); | ||
| background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700); | ||
| } | ||
| #svg-data-uri { | ||
| background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>'); | ||
| } | ||
| .comma-delimited { | ||
| background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg); | ||
| } | ||
| .values { | ||
| @a: 'Trebuchet'; | ||
| url: url(@a); | ||
| } |
| @import "../imports/urls.less"; | ||
| @import "http://localhost:8081/packages/less/test/browser/less/imports/urls2.less"; | ||
| @font-face { | ||
| src: url("/fonts/garamond-pro.ttf"); | ||
| src: local(Futura-Medium), | ||
| url(fonts.svg#MyGeometricModern) format("svg"); | ||
| } | ||
| #shorthands { | ||
| background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px; | ||
| } | ||
| #misc { | ||
| background-image: url(images/image.jpg); | ||
| } | ||
| #data-uri { | ||
| background: url(data:image/png;charset=utf-8;base64, | ||
| kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/ | ||
| k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U | ||
| kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC); | ||
| background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==); | ||
| background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700); | ||
| } | ||
| #svg-data-uri { | ||
| background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>'); | ||
| } | ||
| .comma-delimited { | ||
| background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg); | ||
| } | ||
| .values { | ||
| @a: 'Trebuchet'; | ||
| url: url(@a); | ||
| } |
| @import "imports/urls.less"; | ||
| @import "http://localhost:8081/packages/less/test/browser/less/imports/urls2.less"; | ||
| @import "http://localhost:8081/packages/less/test/browser/less/nested-gradient-with-svg-gradient/mixin-consumer.less"; | ||
| @font-face { | ||
| src: url("/fonts/garamond-pro.ttf"); | ||
| src: local(Futura-Medium), | ||
| url(fonts.svg#MyGeometricModern) format("svg"); | ||
| not-a-comment: url(//z); | ||
| } | ||
| #shorthands { | ||
| background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px; | ||
| } | ||
| #misc { | ||
| background-image: url(images/image.jpg); | ||
| } | ||
| #data-uri { | ||
| background: url(data:image/png;charset=utf-8;base64, | ||
| kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/ | ||
| k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U | ||
| kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC); | ||
| background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==); | ||
| background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700); | ||
| } | ||
| #svg-data-uri { | ||
| background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>'); | ||
| } | ||
| .comma-delimited { | ||
| background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg); | ||
| } | ||
| .values { | ||
| @a: 'Trebuchet'; | ||
| url: url(@a); | ||
| } | ||
| #data-uri { | ||
| uri: data-uri('image/jpeg;base64', '../../data/image.jpg'); | ||
| } | ||
| #data-uri-guess { | ||
| uri: data-uri('../../data/image.jpg'); | ||
| } | ||
| #data-uri-ascii { | ||
| uri-1: data-uri('text/html', '../../data/page.html'); | ||
| uri-2: data-uri('../../data/page.html'); | ||
| } | ||
| #svg-functions { | ||
| @colorlist1: black, white; | ||
| background-image: svg-gradient(to bottom, @colorlist1); | ||
| background-image: svg-gradient(to bottom, black white); | ||
| background-image: svg-gradient(to bottom, black, orange 3%, white); | ||
| @colorlist2: black, orange 3%, white; | ||
| background-image: svg-gradient(to bottom, @colorlist2); | ||
| @green_5: green 5%; | ||
| @orange_percentage: 3%; | ||
| @orange_color: orange; | ||
| @colorlist3: (mix(black, white) + #444) 1%, @orange_color @orange_percentage, ((@green_5)), white 95%; | ||
| background-image: svg-gradient(to bottom,@colorlist3); | ||
| background-image: svg-gradient(to bottom, (mix(black, white) + #444) 1%, @orange_color @orange_percentage, ((@green_5)), white 95%); | ||
| } |
| var less = { | ||
| logLevel: 4, | ||
| errorReporting: 'console', | ||
| javascriptEnabled: true, | ||
| math: 'always' | ||
| }; | ||
| // test inline less in style tags by grabbing an assortment of less files and doing `@import`s | ||
| var testFiles = ['charsets/charsets', 'color-functions/basic', 'comments/comments', 'css-3/css-3', 'strings/strings', 'media/media', 'mixins/mixins'], | ||
| testSheets = []; | ||
| // setup style tags with less and link tags pointing to expected css output | ||
| /** | ||
| * @todo - generate the node_modules path for this file and in templates | ||
| */ | ||
| var lessFolder = '../../node_modules/@less/test-data/tests-unit' | ||
| var cssFolder = '../../node_modules/@less/test-data/tests-unit' | ||
| for (var i = 0; i < testFiles.length; i++) { | ||
| var file = testFiles[i], | ||
| lessPath = lessFolder + '/' + file + '.less', | ||
| cssPath = cssFolder + '/' + file + '.css', | ||
| lessStyle = document.createElement('style'), | ||
| cssLink = document.createElement('link'), | ||
| lessText = '@import "' + lessPath + '";'; | ||
| lessStyle.type = 'text/less'; | ||
| lessStyle.id = file; | ||
| lessStyle.href = file; | ||
| if (lessStyle.styleSheet === undefined) { | ||
| lessStyle.appendChild(document.createTextNode(lessText)); | ||
| } | ||
| cssLink.rel = 'stylesheet'; | ||
| cssLink.type = 'text/css'; | ||
| cssLink.href = cssPath; | ||
| cssLink.id = 'expected-' + file; | ||
| var head = document.getElementsByTagName('head')[0]; | ||
| head.appendChild(lessStyle); | ||
| if (lessStyle.styleSheet) { | ||
| lessStyle.styleSheet.cssText = lessText; | ||
| } | ||
| head.appendChild(cssLink); | ||
| testSheets[i] = lessStyle; | ||
| } |
| describe('less.js browser behaviour', function() { | ||
| testLessEqualsInDocument(); | ||
| it('has some log messages', function() { | ||
| expect(logMessages.length).to.be.above(0); | ||
| }); | ||
| for (var i = 0; i < testFiles.length; i++) { | ||
| var sheet = testSheets[i]; | ||
| testSheet(sheet); | ||
| } | ||
| }); |
| less.errorReporting = 'console'; | ||
| describe('less.js error reporting console test', function() { | ||
| testLessErrorsInDocument(true); | ||
| }); |
| var less = { | ||
| strictUnits: true, | ||
| math: 'strict-legacy', | ||
| logLevel: 4, | ||
| javascriptEnabled: true | ||
| }; |
| describe('less.js error tests', function() { | ||
| testLessErrorsInDocument(); | ||
| }); |
| var less = { | ||
| logLevel: 4, | ||
| errorReporting: 'console', | ||
| plugins: [AddFilePlugin] | ||
| }; |
| describe('less.js filemanager Plugin', function() { | ||
| testLessEqualsInDocument(); | ||
| }); |
| var less = { | ||
| logLevel: 4, | ||
| errorReporting: 'console', | ||
| globalVars: { | ||
| '@global-var': 'red' | ||
| } | ||
| }; |
| describe('less.js global vars', function() { | ||
| testLessEqualsInDocument(); | ||
| }); |
| var less = { | ||
| logLevel: 4, | ||
| errorReporting: 'console' | ||
| }; | ||
| less.functions = { | ||
| add: function(a, b) { | ||
| return new(less.tree.Dimension)(a.value + b.value); | ||
| }, | ||
| increment: function(a) { | ||
| return new(less.tree.Dimension)(a.value + 1); | ||
| }, | ||
| _color: function(str) { | ||
| if (str.value === 'evil red') { | ||
| return new(less.tree.Color)('600'); | ||
| } | ||
| } | ||
| }; |
| console.warn('start spec'); | ||
| describe('less.js main tests', function() { | ||
| testLessEqualsInDocument(); | ||
| it('the global environment', function() { | ||
| expect(window.require).to.be.undefined; | ||
| }); | ||
| }); |
| /* exported less */ | ||
| var less = { | ||
| logLevel: 4, | ||
| errorReporting: 'console' | ||
| }; |
| var alreadyRun = false; | ||
| describe('less.js modify vars', function () { | ||
| beforeEach(function (done) { | ||
| // simulating "setUp" or "beforeAll" method | ||
| if (alreadyRun) { | ||
| done(); | ||
| return; | ||
| } | ||
| alreadyRun = true; | ||
| less.pageLoadFinished | ||
| .then(function () { | ||
| less.modifyVars({ | ||
| var1: 'green', | ||
| var2: 'purple', | ||
| scale: 20 | ||
| }).then(function () { | ||
| done(); | ||
| }); | ||
| }); | ||
| }); | ||
| testLessEqualsInDocument(); | ||
| it('Should log only 2 XHR requests', function (done) { | ||
| var xhrLogMessages = logMessages.filter(function (item) { | ||
| return (/XHR: Getting '/).test(item); | ||
| }); | ||
| expect(xhrLogMessages.length).to.equal(2); | ||
| done(); | ||
| }); | ||
| }); |
| var less = {logLevel: 4}; | ||
| less.strictUnits = true; | ||
| less.javascriptEnabled = false; |
| describe('less.js javascript disabled error tests', function() { | ||
| testLessErrorsInDocument(); | ||
| }); |
| var less = {logLevel: 4, | ||
| errorReporting: 'console', | ||
| plugins: [postProcessorPlugin]}; |
| describe('less.js postProcessor Plugin', function() { | ||
| testLessEqualsInDocument(); | ||
| }); |
| var less = {logLevel: 4, | ||
| errorReporting: 'console', | ||
| plugins: [preProcessorPlugin]}; |
| describe('less.js preProcessor Plugin', function() { | ||
| testLessEqualsInDocument(); | ||
| }); |
| var less = {logLevel: 1, | ||
| errorReporting: 'console'}; | ||
| less.env = 'production'; |
| describe('less.js production behaviour', function() { | ||
| it('doesn\'t log any messages', function() { | ||
| expect(logMessages.length).to.equal(0); | ||
| }); | ||
| }); |
| var less = {logLevel: 4, | ||
| errorReporting: 'console'}; | ||
| less.relativeUrls = true; |
| describe('less.js browser test - relative url\'s', function() { | ||
| testLessEqualsInDocument(); | ||
| }); |
| var less = {logLevel: 4, | ||
| errorReporting: 'console'}; | ||
| less.rewriteUrls = 'all'; |
| describe('less.js browser test - rewrite urls', function() { | ||
| testLessEqualsInDocument(); | ||
| }); |
| var less = {logLevel: 4, | ||
| errorReporting: 'console'}; | ||
| less.rootpath = 'https://localhost/'; |
| var less = {logLevel: 4, | ||
| errorReporting: 'console'}; | ||
| less.rootpath = 'https://www.github.com/cloudhead/less.js/'; | ||
| less.relativeUrls = true; |
| describe('less.js browser test - rootpath and relative urls', function() { | ||
| testLessEqualsInDocument(); | ||
| }); |
| var less = {logLevel: 4, | ||
| errorReporting: 'console'}; | ||
| less.rootpath = 'https://www.github.com/cloudhead/less.js/'; | ||
| less.rewriteUrls = 'all'; |
| describe('less.js browser test - rootpath and rewrite urls', function() { | ||
| testLessEqualsInDocument(); | ||
| }); |
| describe('less.js browser test - rootpath url\'s', function() { | ||
| testLessEqualsInDocument(); | ||
| }); |
| var less = { | ||
| logLevel: 4, | ||
| errorReporting: 'console', | ||
| strictMath: true, | ||
| strictUnits: true }; |
| describe('less.js strict units tests', function() { | ||
| testLessEqualsInDocument(); | ||
| }); |
| var less = {logLevel: 4, | ||
| errorReporting: 'console', | ||
| plugins: [VisitorPlugin]}; |
| describe('less.js Visitor Plugin', function() { | ||
| testLessEqualsInDocument(); | ||
| }); |
-307
| // Mock needle for HTTP requests BEFORE any other requires | ||
| const Module = require('module'); | ||
| const originalRequire = Module.prototype.require; | ||
| Module.prototype.require = function(id) { | ||
| if (id === 'needle') { | ||
| return { | ||
| get: function(url, options, callback) { | ||
| // Handle CDN requests | ||
| if (url.includes('cdn.jsdelivr.net')) { | ||
| if (url.includes('selectors.less')) { | ||
| setTimeout(() => { | ||
| callback(null, { statusCode: 200 }, fs.readFileSync(path.join(__dirname, '../../test-data/tests-unit/selectors/selectors.less'), 'utf8')); | ||
| }, 10); | ||
| return; | ||
| } | ||
| if (url.includes('media.less')) { | ||
| setTimeout(() => { | ||
| callback(null, { statusCode: 200 }, fs.readFileSync(path.join(__dirname, '../../test-data/tests-unit/media/media.less'), 'utf8')); | ||
| }, 10); | ||
| return; | ||
| } | ||
| if (url.includes('empty.less')) { | ||
| setTimeout(() => { | ||
| callback(null, { statusCode: 200 }, fs.readFileSync(path.join(__dirname, '../../test-data/tests-unit/empty/empty.less'), 'utf8')); | ||
| }, 10); | ||
| return; | ||
| } | ||
| } | ||
| // Handle redirect test - simulate needle's automatic redirect handling | ||
| if (url.includes('example.com/redirect.less')) { | ||
| setTimeout(() => { | ||
| // Simulate the final response after needle automatically follows the redirect | ||
| callback(null, { statusCode: 200 }, 'h1 { color: blue; }'); | ||
| }, 10); | ||
| return; | ||
| } | ||
| if (url.includes('example.com/target.less')) { | ||
| setTimeout(() => { | ||
| callback(null, { statusCode: 200 }, 'h1 { color: blue; }'); | ||
| }, 10); | ||
| return; | ||
| } | ||
| // Default error for unmocked URLs | ||
| setTimeout(() => { | ||
| callback(new Error('Unmocked URL: ' + url), null, null); | ||
| }, 10); | ||
| } | ||
| }; | ||
| } | ||
| return originalRequire.apply(this, arguments); | ||
| }; | ||
| // Now load other modules after mocking is set up | ||
| var path = require('path'), | ||
| fs = require('fs'), | ||
| lessTest = require('./less-test'), | ||
| stylize = require('../lib/less-node/lessc-helper').stylize; | ||
| // Parse command line arguments for test filtering | ||
| var args = process.argv.slice(2); | ||
| var testFilter = args.length > 0 ? args[0] : null; | ||
| // Create the test runner with the filter | ||
| var lessTester = lessTest(testFilter); | ||
| // HTTP mocking is now handled by needle mocking above | ||
| // Test HTTP redirect functionality | ||
| function testHttpRedirects() { | ||
| const less = require('../lib/less-node').default; | ||
| console.log('🧪 Testing HTTP redirect functionality...'); | ||
| const redirectTest = ` | ||
| @import "https://example.com/redirect.less"; | ||
| h1 { color: red; } | ||
| `; | ||
| return less.render(redirectTest, { | ||
| filename: 'test-redirect.less' | ||
| }).then(result => { | ||
| console.log('✅ HTTP redirect test SUCCESS:'); | ||
| console.log(result.css); | ||
| // Check if both imported and local content are present | ||
| if (result.css.includes('color: blue') && result.css.includes('color: red')) { | ||
| console.log('🎉 HTTP redirect test PASSED - both imported and local content found'); | ||
| return true; | ||
| } else { | ||
| console.log('❌ HTTP redirect test FAILED - missing expected content'); | ||
| return false; | ||
| } | ||
| }).catch(err => { | ||
| console.log('❌ HTTP redirect test ERROR:'); | ||
| console.log(err.message); | ||
| return false; | ||
| }); | ||
| } | ||
| // Test import-remote functionality | ||
| function testImportRemote() { | ||
| const less = require('../lib/less-node').default; | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| console.log('🧪 Testing import-remote functionality...'); | ||
| const testFile = path.join(__dirname, '../../test-data/tests-unit/import/import-remote.less'); | ||
| const expectedFile = path.join(__dirname, '../../test-data/tests-unit/import/import-remote.css'); | ||
| const content = fs.readFileSync(testFile, 'utf8'); | ||
| const expected = fs.readFileSync(expectedFile, 'utf8'); | ||
| return less.render(content, { | ||
| filename: testFile | ||
| }).then(result => { | ||
| console.log('✅ Import-remote test SUCCESS:'); | ||
| console.log('Expected:', expected.trim()); | ||
| console.log('Actual:', result.css.trim()); | ||
| if (result.css.trim() === expected.trim()) { | ||
| console.log('🎉 Import-remote test PASSED - CDN imports and variable resolution working'); | ||
| return true; | ||
| } else { | ||
| console.log('❌ Import-remote test FAILED - output mismatch'); | ||
| return false; | ||
| } | ||
| }).catch(err => { | ||
| console.log('❌ Import-remote test ERROR:'); | ||
| console.log(err.message); | ||
| return false; | ||
| }); | ||
| } | ||
| console.log('\n' + stylize('Less', 'underline') + '\n'); | ||
| if (testFilter) { | ||
| console.log('Running tests matching: ' + testFilter + '\n'); | ||
| } | ||
| // Glob patterns for main test runs (excluding problematic tests that will run separately) | ||
| var globPatterns = [ | ||
| 'tests-config/*/*.less', | ||
| 'tests-unit/*/*.less', | ||
| // Debug tests have nested subdirectories (comments/, mediaquery/, all/) | ||
| 'tests-config/debug/*/linenumbers-*.less', | ||
| '!tests-config/sourcemaps/**/*.less', // Exclude sourcemaps (need special handling) | ||
| '!tests-config/sourcemaps-empty/*', // Exclude sourcemaps-empty (need special handling) | ||
| '!tests-config/sourcemaps-disable-annotation/*', // Exclude sourcemaps-disable-annotation (need special handling) | ||
| '!tests-config/sourcemaps-variable-selector/*', // Exclude sourcemaps-variable-selector (need special handling) | ||
| '!tests-config/globalVars/*', // Exclude globalVars (need JSON config handling) | ||
| '!tests-config/modifyVars/*', // Exclude modifyVars (need JSON config handling) | ||
| '!tests-config/js-type-errors/*', // Exclude js-type-errors (need special test function) | ||
| '!tests-config/no-js-errors/*', // Exclude no-js-errors (need special test function) | ||
| '!tests-unit/import/import-remote.less', // Exclude import-remote (tested separately in isolation) | ||
| // HTTP import tests are now included since we have needle mocking | ||
| ]; | ||
| var testMap = [ | ||
| // Main test runs using glob patterns (cosmiconfig handles configs) | ||
| { | ||
| patterns: globPatterns | ||
| }, | ||
| // Error tests | ||
| { | ||
| patterns: ['tests-error/eval/*.less'], | ||
| verifyFunction: lessTester.testErrors | ||
| }, | ||
| { | ||
| patterns: ['tests-error/parse/*.less'], | ||
| verifyFunction: lessTester.testErrors | ||
| }, | ||
| // Special test cases with specific handling | ||
| { | ||
| patterns: ['tests-config/js-type-errors/*.less'], | ||
| verifyFunction: lessTester.testTypeErrors | ||
| }, | ||
| { | ||
| patterns: ['tests-config/no-js-errors/*.less'], | ||
| verifyFunction: lessTester.testErrors | ||
| }, | ||
| // Sourcemap tests with special handling | ||
| { | ||
| patterns: [ | ||
| 'tests-config/sourcemaps/**/*.less', | ||
| 'tests-config/sourcemaps-url/**/*.less', | ||
| 'tests-config/sourcemaps-rootpath/**/*.less', | ||
| 'tests-config/sourcemaps-basepath/**/*.less', | ||
| 'tests-config/sourcemaps-include-source/**/*.less' | ||
| ], | ||
| verifyFunction: lessTester.testSourcemap, | ||
| getFilename: function(filename, type, baseFolder) { | ||
| if (type === 'vars') { | ||
| return path.join(baseFolder, filename) + '.json'; | ||
| } | ||
| // Extract just the filename (without directory) for the JSON file | ||
| var jsonFilename = path.basename(filename); | ||
| // For sourcemap type, return path relative to test directory | ||
| if (type === 'sourcemap') { | ||
| return path.join('test/sourcemaps', jsonFilename) + '.json'; | ||
| } | ||
| return path.join('test/sourcemaps', jsonFilename) + '.json'; | ||
| } | ||
| }, | ||
| { | ||
| patterns: ['tests-config/sourcemaps-empty/*.less'], | ||
| verifyFunction: lessTester.testEmptySourcemap | ||
| }, | ||
| { | ||
| patterns: ['tests-config/sourcemaps-disable-annotation/*.less'], | ||
| verifyFunction: lessTester.testSourcemapWithoutUrlAnnotation | ||
| }, | ||
| { | ||
| patterns: ['tests-config/sourcemaps-variable-selector/*.less'], | ||
| verifyFunction: lessTester.testSourcemapWithVariableInSelector | ||
| }, | ||
| // Import tests with JSON configs | ||
| { | ||
| patterns: ['tests-config/globalVars/*.less'], | ||
| lessOptions: { | ||
| globalVars: function(file) { | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const basename = path.basename(file, '.less'); | ||
| const jsonPath = path.join(path.dirname(file), basename + '.json'); | ||
| try { | ||
| return JSON.parse(fs.readFileSync(jsonPath, 'utf8')); | ||
| } catch (e) { | ||
| return {}; | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| patterns: ['tests-config/modifyVars/*.less'], | ||
| lessOptions: { | ||
| modifyVars: function(file) { | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const basename = path.basename(file, '.less'); | ||
| const jsonPath = path.join(path.dirname(file), basename + '.json'); | ||
| try { | ||
| return JSON.parse(fs.readFileSync(jsonPath, 'utf8')); | ||
| } catch (e) { | ||
| return {}; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ]; | ||
| // Note: needle mocking is set up globally at the top of the file | ||
| testMap.forEach(function(testConfig) { | ||
| // For glob patterns, pass lessOptions as the first parameter and patterns as the second | ||
| if (testConfig.patterns) { | ||
| lessTester.runTestSet( | ||
| testConfig.lessOptions || {}, // First param: options (including lessOptions) | ||
| testConfig.patterns, // Second param: patterns | ||
| testConfig.verifyFunction || null, // Third param: verifyFunction | ||
| testConfig.nameModifier || null, // Fourth param: nameModifier | ||
| testConfig.doReplacements || null, // Fifth param: doReplacements | ||
| testConfig.getFilename || null // Sixth param: getFilename | ||
| ); | ||
| } else { | ||
| // Legacy format for non-glob tests | ||
| var args = [ | ||
| testConfig.options || {}, // First param: options | ||
| testConfig.foldername, // Second param: foldername | ||
| testConfig.verifyFunction || null, // Third param: verifyFunction | ||
| testConfig.nameModifier || null, // Fourth param: nameModifier | ||
| testConfig.doReplacements || null, // Fifth param: doReplacements | ||
| testConfig.getFilename || null // Sixth param: getFilename | ||
| ]; | ||
| lessTester.runTestSet.apply(lessTester, args); | ||
| } | ||
| }); | ||
| // Special synchronous tests | ||
| lessTester.testSyncronous({syncImport: true}, 'tests-unit/import/import'); | ||
| lessTester.testSyncronous({syncImport: true}, 'tests-config/math-strict/css'); | ||
| lessTester.testNoOptions(); | ||
| lessTester.testDisablePluginRule(); | ||
| lessTester.testJSImport(); | ||
| lessTester.finished(); | ||
| // Test HTTP redirect functionality | ||
| console.log('\nTesting HTTP redirect functionality...'); | ||
| testHttpRedirects(); | ||
| console.log('HTTP redirect test completed'); | ||
| // Test import-remote functionality in isolation | ||
| console.log('\nTesting import-remote functionality...'); | ||
| testImportRemote(); | ||
| console.log('Import-remote test completed'); |
| /* jshint latedef: nofunc */ | ||
| var semver = require('semver'); | ||
| var logger = require('../lib/less/logger').default; | ||
| var { cosmiconfigSync } = require('cosmiconfig'); | ||
| var glob = require('glob'); | ||
| var isVerbose = process.env.npm_config_loglevel !== 'concise'; | ||
| logger.addListener({ | ||
| info(msg) { | ||
| if (isVerbose) { | ||
| process.stdout.write(msg + '\n'); | ||
| } | ||
| }, | ||
| warn(msg) { | ||
| process.stdout.write(msg + '\n'); | ||
| }, | ||
| error(msg) { | ||
| process.stdout.write(msg + '\n'); | ||
| } | ||
| }); | ||
| module.exports = function(testFilter) { | ||
| var path = require('path'), | ||
| fs = require('fs'), | ||
| clone = require('copy-anything').copy; | ||
| var less = require('../'); | ||
| var stylize = require('../lib/less-node/lessc-helper').stylize; | ||
| var globals = Object.keys(global); | ||
| var oneTestOnly = testFilter || process.argv[2], | ||
| isFinished = false; | ||
| var testFolder = path.dirname(require.resolve('@less/test-data')); | ||
| var lessFolder = testFolder; | ||
| // Define String.prototype.endsWith if it doesn't exist (in older versions of node) | ||
| // This is required by the testSourceMap function below | ||
| if (typeof String.prototype.endsWith !== 'function') { | ||
| String.prototype.endsWith = function (str) { | ||
| return this.slice(-str.length) === str; | ||
| } | ||
| } | ||
| var queueList = [], | ||
| queueRunning = false; | ||
| function queue(func) { | ||
| if (queueRunning) { | ||
| // console.log("adding to queue"); | ||
| queueList.push(func); | ||
| } else { | ||
| // console.log("first in queue - starting"); | ||
| queueRunning = true; | ||
| func(); | ||
| } | ||
| } | ||
| function release() { | ||
| if (queueList.length) { | ||
| // console.log("running next in queue"); | ||
| var func = queueList.shift(); | ||
| setTimeout(func, 0); | ||
| } else { | ||
| // console.log("stopping queue"); | ||
| queueRunning = false; | ||
| } | ||
| } | ||
| var totalTests = 0, | ||
| failedTests = 0, | ||
| passedTests = 0, | ||
| finishTimer = setInterval(endTest, 500); | ||
| less.functions.functionRegistry.addMultiple({ | ||
| add: function (a, b) { | ||
| return new(less.tree.Dimension)(a.value + b.value); | ||
| }, | ||
| increment: function (a) { | ||
| return new(less.tree.Dimension)(a.value + 1); | ||
| }, | ||
| _color: function (str) { | ||
| if (str.value === 'evil red') { return new(less.tree.Color)('600'); } | ||
| } | ||
| }); | ||
| function validateSourcemapMappings(sourcemap, lessFile, compiledCSS) { | ||
| // Validate sourcemap mappings using SourceMapConsumer | ||
| var SourceMapConsumer = require('source-map').SourceMapConsumer; | ||
| // sourcemap can be either a string or already parsed object | ||
| var sourceMapObj = typeof sourcemap === 'string' ? JSON.parse(sourcemap) : sourcemap; | ||
| var consumer = new SourceMapConsumer(sourceMapObj); | ||
| // Read the LESS source file | ||
| var lessSource = fs.readFileSync(lessFile, 'utf8'); | ||
| var lessLines = lessSource.split('\n'); | ||
| // Use the compiled CSS (remove sourcemap annotation for validation) | ||
| var cssSource = compiledCSS.replace(/\/\*# sourceMappingURL=.*\*\/\s*$/, '').trim(); | ||
| var cssLines = cssSource.split('\n'); | ||
| var errors = []; | ||
| var validatedMappings = 0; | ||
| // Validate mappings for each line in the CSS | ||
| for (var cssLine = 1; cssLine <= cssLines.length; cssLine++) { | ||
| var cssLineContent = cssLines[cssLine - 1]; | ||
| // Skip empty lines | ||
| if (!cssLineContent.trim()) { | ||
| continue; | ||
| } | ||
| // Check mapping for the start of this CSS line | ||
| var mapping = consumer.originalPositionFor({ | ||
| line: cssLine, | ||
| column: 0 | ||
| }); | ||
| if (mapping.source) { | ||
| validatedMappings++; | ||
| // Verify the source file exists in the sourcemap | ||
| if (!sourceMapObj.sources || sourceMapObj.sources.indexOf(mapping.source) === -1) { | ||
| errors.push('Line ' + cssLine + ': mapped to source "' + mapping.source + '" which is not in sources array'); | ||
| } | ||
| // Verify the line number is valid | ||
| if (mapping.line && mapping.line > 0) { | ||
| // If we can find the source file, validate the line exists | ||
| var sourceIndex = sourceMapObj.sources.indexOf(mapping.source); | ||
| if (sourceIndex >= 0 && sourceMapObj.sourcesContent && sourceMapObj.sourcesContent[sourceIndex] !== undefined && sourceMapObj.sourcesContent[sourceIndex] !== null) { | ||
| var sourceContent = sourceMapObj.sourcesContent[sourceIndex]; | ||
| // Ensure sourceContent is a string (it should be, but be defensive) | ||
| if (typeof sourceContent !== 'string') { | ||
| sourceContent = String(sourceContent); | ||
| } | ||
| // Split by newline - handle both \n and \r\n | ||
| var sourceLines = sourceContent.split(/\r?\n/); | ||
| if (mapping.line > sourceLines.length) { | ||
| errors.push('Line ' + cssLine + ': mapped to line ' + mapping.line + ' in "' + mapping.source + '" but source only has ' + sourceLines.length + ' lines'); | ||
| } | ||
| } else if (sourceIndex >= 0) { | ||
| // Source content not embedded, try to validate against the actual file if it matches | ||
| // This is a best-effort validation | ||
| } | ||
| } | ||
| } | ||
| } | ||
| // Validate that all sources in the sourcemap are valid | ||
| if (sourceMapObj.sources) { | ||
| sourceMapObj.sources.forEach(function(source, index) { | ||
| if (sourceMapObj.sourcesContent && sourceMapObj.sourcesContent[index]) { | ||
| // Source content is embedded, validate it's not empty | ||
| if (!sourceMapObj.sourcesContent[index].trim()) { | ||
| errors.push('Source "' + source + '" has empty content'); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
| if (consumer.destroy && typeof consumer.destroy === 'function') { | ||
| consumer.destroy(); | ||
| } | ||
| return { | ||
| valid: errors.length === 0, | ||
| errors: errors, | ||
| mappingsValidated: validatedMappings | ||
| }; | ||
| } | ||
| function testSourcemap(name, err, compiledLess, doReplacements, sourcemap, baseFolder, getFilename) { | ||
| if (err) { | ||
| fail('ERROR: ' + (err && err.message)); | ||
| return; | ||
| } | ||
| // Check the sourceMappingURL at the bottom of the file | ||
| // Default expected URL is name + '.css.map', but can be overridden by sourceMapURL option | ||
| var sourceMappingPrefix = '/*# sourceMappingURL=', | ||
| sourceMappingSuffix = ' */'; | ||
| var indexOfSourceMappingPrefix = compiledLess.indexOf(sourceMappingPrefix); | ||
| if (indexOfSourceMappingPrefix === -1) { | ||
| fail('ERROR: sourceMappingURL was not found in ' + baseFolder + '/' + name + '.css.'); | ||
| return; | ||
| } | ||
| var startOfSourceMappingValue = indexOfSourceMappingPrefix + sourceMappingPrefix.length, | ||
| indexOfSuffix = compiledLess.indexOf(sourceMappingSuffix, startOfSourceMappingValue), | ||
| actualSourceMapURL = compiledLess.substring(startOfSourceMappingValue, indexOfSuffix === -1 ? compiledLess.length : indexOfSuffix).trim(); | ||
| // For tests with custom sourceMapURL, we just verify it exists and is non-empty | ||
| // The actual value will be validated by comparing the sourcemap JSON | ||
| if (!actualSourceMapURL) { | ||
| fail('ERROR: sourceMappingURL is empty in ' + baseFolder + '/' + name + '.css.'); | ||
| return; | ||
| } | ||
| // Use getFilename if available (for sourcemap tests with subdirectories) | ||
| var jsonPath; | ||
| if (getFilename && typeof getFilename === 'function') { | ||
| jsonPath = getFilename(name, 'sourcemap', baseFolder); | ||
| } else { | ||
| // Fallback: extract just the filename for sourcemap JSON files | ||
| var jsonFilename = path.basename(name); | ||
| jsonPath = path.join('test/sourcemaps', jsonFilename) + '.json'; | ||
| } | ||
| fs.readFile(jsonPath, 'utf8', function (e, expectedSourcemap) { | ||
| process.stdout.write('- ' + path.join(baseFolder, name) + ': '); | ||
| if (e) { | ||
| fail('ERROR: Could not read expected sourcemap file: ' + jsonPath + ' - ' + e.message); | ||
| return; | ||
| } | ||
| // Apply doReplacements to the expected sourcemap to handle {path} placeholders | ||
| // This normalizes absolute paths that differ between environments | ||
| // For sourcemaps, we need to ensure {path} uses forward slashes to avoid breaking JSON | ||
| // (backslashes in JSON strings need escaping, and sourcemaps should use forward slashes anyway) | ||
| var replacementPath = path.join(path.dirname(path.join(baseFolder, name) + '.less'), '/'); | ||
| // Normalize to forward slashes for sourcemap JSON (web-compatible) | ||
| replacementPath = replacementPath.replace(/\\/g, '/'); | ||
| // Replace {path} with normalized forward-slash path BEFORE calling doReplacements | ||
| // This ensures the JSON is always valid and uses web-compatible paths | ||
| expectedSourcemap = expectedSourcemap.replace(/\{path\}/g, replacementPath); | ||
| // Also handle other placeholders that might be in the sourcemap (but {path} is already done) | ||
| expectedSourcemap = doReplacements(expectedSourcemap, baseFolder, path.join(baseFolder, name) + '.less'); | ||
| // Normalize paths in sourcemap JSON to use forward slashes (web-compatible) | ||
| // We need to parse the JSON, normalize the file property, then stringify for comparison | ||
| // This avoids breaking escape sequences like \n in the JSON string | ||
| function normalizeSourcemapPaths(sm) { | ||
| try { | ||
| var parsed = typeof sm === 'string' ? JSON.parse(sm) : sm; | ||
| if (parsed.file) { | ||
| parsed.file = parsed.file.replace(/\\/g, '/'); | ||
| } | ||
| // Also normalize paths in sources array | ||
| if (parsed.sources && Array.isArray(parsed.sources)) { | ||
| parsed.sources = parsed.sources.map(function(src) { | ||
| return src.replace(/\\/g, '/'); | ||
| }); | ||
| } | ||
| return JSON.stringify(parsed, null, 0); | ||
| } catch (parseErr) { | ||
| // If parsing fails, return original (shouldn't happen) | ||
| return sm; | ||
| } | ||
| } | ||
| var normalizedSourcemap = normalizeSourcemapPaths(sourcemap); | ||
| var normalizedExpected = normalizeSourcemapPaths(expectedSourcemap); | ||
| if (normalizedSourcemap === normalizedExpected) { | ||
| // Validate the sourcemap mappings are correct | ||
| // Find the actual LESS file - it might be in a subdirectory | ||
| var nameParts = name.split('/'); | ||
| var lessFileName = nameParts[nameParts.length - 1]; | ||
| var lessFileDir = nameParts.length > 1 ? nameParts.slice(0, -1).join('/') : ''; | ||
| var lessFile = path.join(lessFolder, lessFileDir, lessFileName) + '.less'; | ||
| // Only validate if the LESS file exists | ||
| if (fs.existsSync(lessFile)) { | ||
| try { | ||
| // Parse the sourcemap once for validation (avoid re-parsing) | ||
| // Use the original sourcemap string, not the normalized one | ||
| var sourceMapObjForValidation = typeof sourcemap === 'string' ? JSON.parse(sourcemap) : sourcemap; | ||
| var validation = validateSourcemapMappings(sourceMapObjForValidation, lessFile, compiledLess); | ||
| if (!validation.valid) { | ||
| fail('ERROR: Sourcemap validation failed:\n' + validation.errors.join('\n')); | ||
| return; | ||
| } | ||
| if (isVerbose && validation.mappingsValidated > 0) { | ||
| process.stdout.write(' (validated ' + validation.mappingsValidated + ' mappings)'); | ||
| } | ||
| } catch (validationErr) { | ||
| if (isVerbose) { | ||
| process.stdout.write(' (validation error: ' + validationErr.message + ')'); | ||
| } | ||
| // Don't fail the test if validation has an error, just log it | ||
| } | ||
| } | ||
| ok('OK'); | ||
| } else if (err) { | ||
| fail('ERROR: ' + (err && err.message)); | ||
| if (isVerbose) { | ||
| process.stdout.write('\n'); | ||
| process.stdout.write(err.stack + '\n'); | ||
| } | ||
| } else { | ||
| difference('FAIL', normalizedExpected, normalizedSourcemap); | ||
| } | ||
| }); | ||
| } | ||
| function testSourcemapWithoutUrlAnnotation(name, err, compiledLess, doReplacements, sourcemap, baseFolder) { | ||
| if (err) { | ||
| fail('ERROR: ' + (err && err.message)); | ||
| return; | ||
| } | ||
| // This matches with strings that end($) with source mapping url annotation. | ||
| var sourceMapRegExp = /\/\*# sourceMappingURL=.+\.css\.map \*\/$/; | ||
| if (sourceMapRegExp.test(compiledLess)) { | ||
| fail('ERROR: sourceMappingURL found in ' + baseFolder + '/' + name + '.css.'); | ||
| return; | ||
| } | ||
| // Even if annotation is not necessary, the map file should be there. | ||
| fs.readFile(path.join('test/', name) + '.json', 'utf8', function (e, expectedSourcemap) { | ||
| process.stdout.write('- ' + path.join(baseFolder, name) + ': '); | ||
| if (sourcemap === expectedSourcemap) { | ||
| ok('OK'); | ||
| } else if (err) { | ||
| fail('ERROR: ' + (err && err.message)); | ||
| if (isVerbose) { | ||
| process.stdout.write('\n'); | ||
| process.stdout.write(err.stack + '\n'); | ||
| } | ||
| } else { | ||
| difference('FAIL', expectedSourcemap, sourcemap); | ||
| } | ||
| }); | ||
| } | ||
| function testEmptySourcemap(name, err, compiledLess, doReplacements, sourcemap, baseFolder) { | ||
| process.stdout.write('- ' + path.join(baseFolder, name) + ': '); | ||
| if (err) { | ||
| fail('ERROR: ' + (err && err.message)); | ||
| } else { | ||
| var expectedSourcemap = undefined; | ||
| if ( compiledLess !== '' ) { | ||
| difference('\nCompiledLess must be empty', '', compiledLess); | ||
| } else if (sourcemap !== expectedSourcemap) { | ||
| fail('Sourcemap must be undefined'); | ||
| } else { | ||
| ok('OK'); | ||
| } | ||
| } | ||
| } | ||
| function testSourcemapWithVariableInSelector(name, err, compiledLess, doReplacements, sourcemap, baseFolder) { | ||
| if (err) { | ||
| fail('ERROR: ' + (err && err.message)); | ||
| return; | ||
| } | ||
| // Even if annotation is not necessary, the map file should be there. | ||
| fs.readFile(path.join('test/', name) + '.json', 'utf8', function (e, expectedSourcemap) { | ||
| process.stdout.write('- ' + path.join(baseFolder, name) + ': '); | ||
| if (sourcemap === expectedSourcemap) { | ||
| ok('OK'); | ||
| } else if (err) { | ||
| fail('ERROR: ' + (err && err.message)); | ||
| if (isVerbose) { | ||
| process.stdout.write('\n'); | ||
| process.stdout.write(err.stack + '\n'); | ||
| } | ||
| } else { | ||
| difference('FAIL', expectedSourcemap, sourcemap); | ||
| } | ||
| }); | ||
| } | ||
| function testImports(name, err, compiledLess, doReplacements, sourcemap, baseFolder, imports) { | ||
| if (err) { | ||
| fail('ERROR: ' + (err && err.message)); | ||
| return; | ||
| } | ||
| function stringify(str) { | ||
| return JSON.stringify(imports, null, ' ') | ||
| } | ||
| /** Imports are not sorted */ | ||
| const importsString = stringify(imports.sort()) | ||
| fs.readFile(path.join(lessFolder, name) + '.json', 'utf8', function (e, expectedImports) { | ||
| if (e) { | ||
| fail('ERROR: ' + (e && e.message)); | ||
| return; | ||
| } | ||
| process.stdout.write('- ' + path.join(baseFolder, name) + ': '); | ||
| expectedImports = stringify(JSON.parse(expectedImports).sort()); | ||
| expectedImports = globalReplacements(expectedImports, baseFolder); | ||
| if (expectedImports === importsString) { | ||
| ok('OK'); | ||
| } else if (err) { | ||
| fail('ERROR: ' + (err && err.message)); | ||
| if (isVerbose) { | ||
| process.stdout.write('\n'); | ||
| process.stdout.write(err.stack + '\n'); | ||
| } | ||
| } else { | ||
| difference('FAIL', expectedImports, importsString); | ||
| } | ||
| }); | ||
| } | ||
| function testErrors(name, err, compiledLess, doReplacements, sourcemap, baseFolder) { | ||
| fs.readFile(path.join(baseFolder, name) + '.txt', 'utf8', function (e, expectedErr) { | ||
| process.stdout.write('- ' + path.join(baseFolder, name) + ': '); | ||
| expectedErr = doReplacements(expectedErr, baseFolder, err && err.filename); | ||
| if (!err) { | ||
| if (compiledLess) { | ||
| fail('No Error', 'red'); | ||
| } else { | ||
| fail('No Error, No Output'); | ||
| } | ||
| } else { | ||
| var errMessage = err.toString(); | ||
| if (errMessage === expectedErr) { | ||
| ok('OK'); | ||
| } else { | ||
| difference('FAIL', expectedErr, errMessage); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
| // To fix ci fail about error format change in upstream v8 project | ||
| // https://github.com/v8/v8/commit/c0fd89c3c089e888c4f4e8582e56db7066fa779b | ||
| // Node 16.9.0+ include this change via https://github.com/nodejs/node/pull/39947 | ||
| function testTypeErrors(name, err, compiledLess, doReplacements, sourcemap, baseFolder) { | ||
| const fileSuffix = semver.gte(process.version, 'v16.9.0') ? '-2.txt' : '.txt'; | ||
| fs.readFile(path.join(baseFolder, name) + fileSuffix, 'utf8', function (e, expectedErr) { | ||
| process.stdout.write('- ' + path.join(baseFolder, name) + ': '); | ||
| expectedErr = doReplacements(expectedErr, baseFolder, err && err.filename); | ||
| if (!err) { | ||
| if (compiledLess) { | ||
| fail('No Error', 'red'); | ||
| } else { | ||
| fail('No Error, No Output'); | ||
| } | ||
| } else { | ||
| var errMessage = err.toString(); | ||
| if (errMessage === expectedErr) { | ||
| ok('OK'); | ||
| } else { | ||
| difference('FAIL', expectedErr, errMessage); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
| // https://github.com/less/less.js/issues/3112 | ||
| function testJSImport() { | ||
| process.stdout.write('- Testing root function registry'); | ||
| less.functions.functionRegistry.add('ext', function() { | ||
| return new less.tree.Anonymous('file'); | ||
| }); | ||
| var expected = '@charset "utf-8";\n'; | ||
| toCSS({}, path.join(lessFolder, 'tests-config', 'root-registry', 'root.less'), function(error, output) { | ||
| if (error) { | ||
| return fail('ERROR: ' + error); | ||
| } | ||
| if (output.css === expected) { | ||
| return ok('OK'); | ||
| } | ||
| difference('FAIL', expected, output.css); | ||
| }); | ||
| } | ||
| function globalReplacements(input, directory, filename) { | ||
| var path = require('path'); | ||
| var p = filename ? path.join(path.dirname(filename), '/') : directory; | ||
| // For debug tests in subdirectories (comments/, mediaquery/, all/), | ||
| // the import/ directory and main linenumbers.less file are at the parent debug/ level, not in the subdirectory | ||
| var isDebugSubdirectory = false; | ||
| var debugParentPath = null; | ||
| if (directory) { | ||
| // Normalize directory path separators for matching | ||
| var normalizedDir = directory.replace(/\\/g, '/'); | ||
| // Check if we're in a debug subdirectory | ||
| if (normalizedDir.includes('/debug/') && (normalizedDir.includes('/comments/') || normalizedDir.includes('/mediaquery/') || normalizedDir.includes('/all/'))) { | ||
| isDebugSubdirectory = true; | ||
| // Extract the debug/ directory path (parent of the subdirectory) | ||
| // Match everything up to and including /debug/ (works with both absolute and relative paths) | ||
| var debugMatch = normalizedDir.match(/(.+\/debug)\//); | ||
| if (debugMatch) { | ||
| debugParentPath = debugMatch[1]; | ||
| } | ||
| } | ||
| } | ||
| if (isDebugSubdirectory && debugParentPath) { | ||
| // For {path} placeholder, use the parent debug/ directory | ||
| // Convert back to native path format | ||
| p = debugParentPath.replace(/\//g, path.sep) + path.sep; | ||
| } | ||
| var pathimport; | ||
| if (isDebugSubdirectory && debugParentPath) { | ||
| pathimport = path.join(debugParentPath.replace(/\//g, path.sep), 'import') + path.sep; | ||
| } else { | ||
| pathimport = path.join(directory + 'import/'); | ||
| } | ||
| var pathesc = p.replace(/[.:/\\]/g, function(a) { return '\\' + (a == '\\' ? '\/' : a); }), | ||
| pathimportesc = pathimport.replace(/[.:/\\]/g, function(a) { return '\\' + (a == '\\' ? '\/' : a); }); | ||
| return input.replace(/\{path\}/g, p) | ||
| .replace(/\{node\}/g, '') | ||
| .replace(/\{\/node\}/g, '') | ||
| .replace(/\{pathhref\}/g, '') | ||
| .replace(/\{404status\}/g, '') | ||
| .replace(/\{nodepath\}/g, path.join(process.cwd(), 'node_modules', '/')) | ||
| .replace(/\{pathrel\}/g, path.join(path.relative(lessFolder, p), '/')) | ||
| .replace(/\{pathesc\}/g, pathesc) | ||
| .replace(/\{pathimport\}/g, pathimport) | ||
| .replace(/\{pathimportesc\}/g, pathimportesc) | ||
| .replace(/\r\n/g, '\n'); | ||
| } | ||
| function checkGlobalLeaks() { | ||
| return Object.keys(global).filter(function(v) { | ||
| return globals.indexOf(v) < 0; | ||
| }); | ||
| } | ||
| function testSyncronous(options, filenameNoExtension) { | ||
| if (oneTestOnly && ('Test Sync ' + filenameNoExtension) !== oneTestOnly) { | ||
| return; | ||
| } | ||
| totalTests++; | ||
| queue(function() { | ||
| var isSync = true; | ||
| toCSS(options, path.join(lessFolder, filenameNoExtension + '.less'), function (err, result) { | ||
| process.stdout.write('- Test Sync ' + filenameNoExtension + ': '); | ||
| if (isSync) { | ||
| ok('OK'); | ||
| } else { | ||
| fail('Not Sync'); | ||
| } | ||
| release(); | ||
| }); | ||
| isSync = false; | ||
| }); | ||
| } | ||
| function runTestSet(options, foldername, verifyFunction, nameModifier, doReplacements, getFilename) { | ||
| // Handle case where first parameter is glob patterns (no options object) | ||
| if (Array.isArray(options)) { | ||
| // First parameter is glob patterns, no options object | ||
| foldername = options; | ||
| options = {}; | ||
| } else if (typeof options === 'string') { | ||
| // First parameter is foldername (no options object) | ||
| foldername = options; | ||
| options = {}; | ||
| } else { | ||
| options = options ? clone(options) : {}; | ||
| } | ||
| runTestSetInternal(lessFolder, options, foldername, verifyFunction, nameModifier, doReplacements, getFilename); | ||
| } | ||
| function runTestSetNormalOnly(options, foldername, verifyFunction, nameModifier, doReplacements, getFilename) { | ||
| runTestSetInternal(lessFolder, options, foldername, verifyFunction, nameModifier, doReplacements, getFilename); | ||
| } | ||
| function runTestSetInternal(baseFolder, opts, foldername, verifyFunction, nameModifier, doReplacements, getFilename) { | ||
| foldername = foldername || ''; | ||
| var originalOptions = opts || {}; | ||
| if (!doReplacements) { | ||
| doReplacements = globalReplacements; | ||
| } | ||
| // Handle glob patterns with exclusions | ||
| if (Array.isArray(foldername)) { | ||
| var patterns = foldername; | ||
| var includePatterns = []; | ||
| var excludePatterns = []; | ||
| patterns.forEach(function(pattern) { | ||
| if (pattern.startsWith('!')) { | ||
| excludePatterns.push(pattern.substring(1)); | ||
| } else { | ||
| includePatterns.push(pattern); | ||
| } | ||
| }); | ||
| // Use glob to find all matching files, excluding the excluded patterns | ||
| var allFiles = []; | ||
| includePatterns.forEach(function(pattern) { | ||
| var files = glob.sync(pattern, { | ||
| cwd: baseFolder, | ||
| absolute: true, | ||
| ignore: excludePatterns | ||
| }); | ||
| allFiles = allFiles.concat(files); | ||
| }); | ||
| // Note: needle mocking is set up globally in index.js | ||
| // Process each .less file found | ||
| allFiles.forEach(function(filePath) { | ||
| if (/\.less$/.test(filePath)) { | ||
| var file = path.basename(filePath); | ||
| // For glob patterns, we need to construct the relative path differently | ||
| // The filePath is absolute, so we need to get the path relative to the test-data directory | ||
| var relativePath = path.relative(baseFolder, path.dirname(filePath)) + '/'; | ||
| // Only process files that have corresponding .css files (these are the actual tests) | ||
| var cssPath = path.join(path.dirname(filePath), path.basename(file, '.less') + '.css'); | ||
| if (fs.existsSync(cssPath)) { | ||
| // Process this file using the existing logic | ||
| processFileWithInfo({ | ||
| file: file, | ||
| fullPath: filePath, | ||
| relativePath: relativePath | ||
| }); | ||
| } | ||
| } | ||
| }); | ||
| return; | ||
| } | ||
| function processFileWithInfo(fileInfo) { | ||
| var file = fileInfo.file; | ||
| var fullPath = fileInfo.fullPath; | ||
| var relativePath = fileInfo.relativePath; | ||
| // Load config for this specific file using cosmiconfig | ||
| var configResult = cosmiconfigSync('styles').search(path.dirname(fullPath)); | ||
| // Deep clone the original options to prevent Less from modifying shared objects | ||
| var options = JSON.parse(JSON.stringify(originalOptions || {})); | ||
| if (configResult && configResult.config && configResult.config.language && configResult.config.language.less) { | ||
| // Deep clone and merge the language.less settings with the original options | ||
| var lessConfig = JSON.parse(JSON.stringify(configResult.config.language.less)); | ||
| Object.keys(lessConfig).forEach(function(key) { | ||
| options[key] = lessConfig[key]; | ||
| }); | ||
| } | ||
| // Merge any lessOptions from the testMap (for dynamic options like getVars functions) | ||
| if (originalOptions && originalOptions.lessOptions) { | ||
| Object.keys(originalOptions.lessOptions).forEach(function(key) { | ||
| var value = originalOptions.lessOptions[key]; | ||
| if (typeof value === 'function') { | ||
| // For functions, call them with the file path | ||
| var result = value(fullPath); | ||
| options[key] = result; | ||
| } else { | ||
| // For static values, use them directly | ||
| options[key] = value; | ||
| } | ||
| }); | ||
| } | ||
| // Don't pass stylize to less.render as it's not a valid option | ||
| var name = getBasename(file, relativePath); | ||
| if (oneTestOnly && typeof oneTestOnly === 'string' && !name.includes(oneTestOnly)) { | ||
| return; | ||
| } | ||
| totalTests++; | ||
| if (options.sourceMap && !options.sourceMap.sourceMapFileInline) { | ||
| // Set test infrastructure defaults only if not already set by styles.config.cjs | ||
| // Less.js core (parse-tree.js) will handle normalization of: | ||
| // - sourceMapBasepath (defaults to input file's directory) | ||
| // - sourceMapInputFilename (defaults to options.filename) | ||
| // - sourceMapFilename (derived from sourceMapOutputFilename or input filename) | ||
| // - sourceMapOutputFilename (derived from input filename if not set) | ||
| if (!options.sourceMap.sourceMapOutputFilename) { | ||
| // Needed for sourcemap file name in JSON output | ||
| options.sourceMap.sourceMapOutputFilename = name + '.css'; | ||
| } | ||
| if (!options.sourceMap.sourceMapRootpath) { | ||
| // Test-specific default for consistent test output paths | ||
| options.sourceMap.sourceMapRootpath = 'testweb/'; | ||
| } | ||
| } | ||
| options.getVars = function(file) { | ||
| try { | ||
| return JSON.parse(fs.readFileSync(getFilename(getBasename(file, relativePath), 'vars', baseFolder), 'utf8')); | ||
| } | ||
| catch (e) { | ||
| return {}; | ||
| } | ||
| }; | ||
| var doubleCallCheck = false; | ||
| queue(function() { | ||
| toCSS(options, fullPath, function (err, result) { | ||
| if (doubleCallCheck) { | ||
| totalTests++; | ||
| fail('less is calling back twice'); | ||
| process.stdout.write(doubleCallCheck + '\n'); | ||
| process.stdout.write((new Error()).stack + '\n'); | ||
| return; | ||
| } | ||
| doubleCallCheck = (new Error()).stack; | ||
| /** | ||
| * @todo - refactor so the result object is sent to the verify function | ||
| */ | ||
| if (verifyFunction) { | ||
| var verificationResult = verifyFunction( | ||
| name, err, result && result.css, doReplacements, result && result.map, baseFolder, result && result.imports, getFilename | ||
| ); | ||
| release(); | ||
| return verificationResult; | ||
| } | ||
| if (err) { | ||
| fail('ERROR: ' + (err && err.message)); | ||
| if (isVerbose) { | ||
| process.stdout.write('\n'); | ||
| if (err.stack) { | ||
| process.stdout.write(err.stack + '\n'); | ||
| } else { | ||
| // this sometimes happen - show the whole error object | ||
| console.log(err); | ||
| } | ||
| } | ||
| release(); | ||
| return; | ||
| } | ||
| var css_name = name; | ||
| if (nameModifier) { css_name = nameModifier(name); } | ||
| // Check if we're using the new co-located structure (tests-unit/ or tests-config/) or the old separated structure | ||
| var cssPath; | ||
| if (relativePath.startsWith('tests-unit/') || relativePath.startsWith('tests-config/')) { | ||
| // New co-located structure: CSS file is in the same directory as LESS file | ||
| cssPath = path.join(path.dirname(fullPath), path.basename(file, '.less') + '.css'); | ||
| } else { | ||
| // Old separated structure: CSS file is in separate css/ folder | ||
| // Windows compatibility: css_name may already contain path separators | ||
| // Use path.join with empty string to let path.join handle normalization | ||
| cssPath = path.join(testFolder, css_name) + '.css'; | ||
| } | ||
| // For the new structure, we need to handle replacements differently | ||
| var replacementPath; | ||
| if (relativePath.startsWith('tests-unit/') || relativePath.startsWith('tests-config/')) { | ||
| replacementPath = path.dirname(fullPath); | ||
| // Ensure replacementPath ends with a path separator for consistent matching | ||
| if (!replacementPath.endsWith(path.sep)) { | ||
| replacementPath += path.sep; | ||
| } | ||
| } else { | ||
| replacementPath = path.join(baseFolder, relativePath); | ||
| } | ||
| var testName = fullPath.replace(/\.less$/, ''); | ||
| process.stdout.write('- ' + testName + ': '); | ||
| var css = fs.readFileSync(cssPath, 'utf8'); | ||
| css = css && doReplacements(css, replacementPath); | ||
| if (result.css === css) { ok('OK'); } | ||
| else { | ||
| difference('FAIL', css, result.css); | ||
| } | ||
| release(); | ||
| }); | ||
| }); | ||
| } | ||
| function getBasename(file, relativePath) { | ||
| var basePath = relativePath || foldername; | ||
| // Ensure basePath ends with a slash for proper path construction | ||
| if (basePath.charAt(basePath.length - 1) !== '/') { | ||
| basePath = basePath + '/'; | ||
| } | ||
| return basePath + path.basename(file, '.less'); | ||
| } | ||
| // This function is only called for non-glob patterns now | ||
| // For glob patterns, we use the glob library in the calling code | ||
| var dirPath = path.join(baseFolder, foldername); | ||
| var items = fs.readdirSync(dirPath); | ||
| items.forEach(function(item) { | ||
| if (/\.less$/.test(item)) { | ||
| processFileWithInfo({ | ||
| file: item, | ||
| fullPath: path.join(dirPath, item), | ||
| relativePath: foldername | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
| function diff(left, right) { | ||
| // Configure chalk to always show colors | ||
| var chalk = require('chalk'); | ||
| chalk.level = 3; // Force colors on | ||
| // Use jest-diff for much clearer output like Vitest | ||
| var diffResult = require('jest-diff').diffStringsUnified(left || '', right || '', { | ||
| expand: false, | ||
| includeChangeCounts: true, | ||
| contextLines: 1, | ||
| aColor: chalk.red, | ||
| bColor: chalk.green, | ||
| changeColor: chalk.inverse, | ||
| commonColor: chalk.dim | ||
| }); | ||
| // jest-diff returns a string with ANSI colors, so we can output it directly | ||
| process.stdout.write(diffResult + '\n'); | ||
| } | ||
| function fail(msg) { | ||
| process.stdout.write(stylize(msg, 'red') + '\n'); | ||
| failedTests++; | ||
| endTest(); | ||
| } | ||
| function difference(msg, left, right) { | ||
| process.stdout.write(stylize(msg, 'yellow') + '\n'); | ||
| failedTests++; | ||
| // Only show the diff, not the full text | ||
| process.stdout.write(stylize('Diff:', 'yellow') + '\n'); | ||
| diff(left || '', right || ''); | ||
| endTest(); | ||
| } | ||
| function ok(msg) { | ||
| process.stdout.write(stylize(msg, 'green') + '\n'); | ||
| passedTests++; | ||
| endTest(); | ||
| } | ||
| function finished() { | ||
| isFinished = true; | ||
| endTest(); | ||
| } | ||
| function endTest() { | ||
| if (isFinished && ((failedTests + passedTests) >= totalTests)) { | ||
| clearInterval(finishTimer); | ||
| var leaked = checkGlobalLeaks(); | ||
| process.stdout.write('\n'); | ||
| if (failedTests > 0) { | ||
| process.stdout.write(failedTests + stylize(' Failed', 'red') + ', ' + passedTests + ' passed\n'); | ||
| } else { | ||
| process.stdout.write(stylize('All Passed ', 'green') + passedTests + ' run\n'); | ||
| } | ||
| if (leaked.length > 0) { | ||
| process.stdout.write('\n'); | ||
| process.stdout.write(stylize('Global leak detected: ', 'red') + leaked.join(', ') + '\n'); | ||
| } | ||
| if (leaked.length || failedTests) { | ||
| process.on('exit', function() { process.reallyExit(1); }); | ||
| } | ||
| } | ||
| } | ||
| function contains(fullArray, obj) { | ||
| for (var i = 0; i < fullArray.length; i++) { | ||
| if (fullArray[i] === obj) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
| /** | ||
| * | ||
| * @param {Object} options | ||
| * @param {string} filePath | ||
| * @param {Function} callback | ||
| */ | ||
| function toCSS(options, filePath, callback) { | ||
| // Deep clone options to prevent modifying the original, but preserve functions | ||
| var originalOptions = options || {}; | ||
| options = JSON.parse(JSON.stringify(originalOptions)); | ||
| // Restore functions that were lost in JSON serialization | ||
| if (originalOptions.getVars) { | ||
| options.getVars = originalOptions.getVars; | ||
| } | ||
| var str = fs.readFileSync(filePath, 'utf8'), addPath = path.dirname(filePath); | ||
| // Initialize paths array if it doesn't exist | ||
| if (typeof options.paths !== 'string') { | ||
| options.paths = options.paths || []; | ||
| } else { | ||
| options.paths = [options.paths]; | ||
| } | ||
| // Add the current directory to paths if not already present | ||
| if (!contains(options.paths, addPath)) { | ||
| options.paths.push(addPath); | ||
| } | ||
| // Resolve all paths relative to the test file's directory | ||
| options.paths = options.paths.map(searchPath => { | ||
| if (path.isAbsolute(searchPath)) { | ||
| return searchPath; | ||
| } | ||
| // Resolve relative to the test file's directory | ||
| return path.resolve(path.dirname(filePath), searchPath); | ||
| }) | ||
| options.filename = path.resolve(process.cwd(), filePath); | ||
| options.optimization = options.optimization || 0; | ||
| // Note: globalVars and modifyVars are now handled via styles.config.cjs or lessOptions | ||
| if (options.plugin) { | ||
| var Plugin = require(path.resolve(process.cwd(), options.plugin)); | ||
| options.plugins = [Plugin]; | ||
| } | ||
| less.render(str, options, callback); | ||
| } | ||
| function testNoOptions() { | ||
| if (oneTestOnly && 'Integration' !== oneTestOnly) { | ||
| return; | ||
| } | ||
| totalTests++; | ||
| try { | ||
| process.stdout.write('- Integration - creating parser without options: '); | ||
| less.render(''); | ||
| } catch (e) { | ||
| fail(stylize('FAIL\n', 'red')); | ||
| return; | ||
| } | ||
| ok(stylize('OK\n', 'green')); | ||
| } | ||
| // HTTP redirect testing is now handled directly in test/index.js | ||
| function testDisablePluginRule() { | ||
| less.render( | ||
| '@plugin "../../plugin/some_plugin";', | ||
| {disablePluginRule: true}, | ||
| function(err) { | ||
| // TODO: Need a better way of identifing exactly which error is thrown. Checking | ||
| // text like this tends to be rather brittle. | ||
| const EXPECTED = '@plugin statements are not allowed when disablePluginRule is set to true'; | ||
| if (!err || String(err).indexOf(EXPECTED) < 0) { | ||
| fail('ERROR: Expected "' + EXPECTED + '" error'); | ||
| return; | ||
| } | ||
| ok(stylize('OK\n', 'green')); | ||
| } | ||
| ); | ||
| } | ||
| return { | ||
| runTestSet: runTestSet, | ||
| runTestSetNormalOnly: runTestSetNormalOnly, | ||
| testSyncronous: testSyncronous, | ||
| testErrors: testErrors, | ||
| testTypeErrors: testTypeErrors, | ||
| testSourcemap: testSourcemap, | ||
| testSourcemapWithoutUrlAnnotation: testSourcemapWithoutUrlAnnotation, | ||
| testSourcemapWithVariableInSelector: testSourcemapWithVariableInSelector, | ||
| testImports: testImports, | ||
| testEmptySourcemap: testEmptySourcemap, | ||
| testNoOptions: testNoOptions, | ||
| testDisablePluginRule: testDisablePluginRule, | ||
| testJSImport: testJSImport, | ||
| finished: finished | ||
| }; | ||
| }; |
| 'use strict'; | ||
| const path = require('path'); | ||
| const util = require('util'); | ||
| const { chromium } = require('playwright'); | ||
| const TIMEOUT_MILLISECONDS = 60000; | ||
| function initMocha(reporter) { | ||
| console.log = (console => { | ||
| const log = console.log.bind(console); | ||
| return (...args) => args.length ? log(...args) : log(''); | ||
| })(console); | ||
| function shimMochaInstance(m) { | ||
| const originalReporter = m.reporter.bind(m); | ||
| let reporterIsChanged = false; | ||
| m.reporter = (...args) => { | ||
| reporterIsChanged = true; | ||
| originalReporter(...args); | ||
| }; | ||
| const run = m.run.bind(m); | ||
| m.run = () => { | ||
| const all = [], pending = [], failures = [], passes = []; | ||
| function error(err) { | ||
| if (!err) return {}; | ||
| let res = {}; | ||
| Object.getOwnPropertyNames(err).forEach(key => res[key] = err[key]); | ||
| return res; | ||
| } | ||
| function clean(test) { | ||
| return { | ||
| title: test.title, | ||
| fullTitle: test.fullTitle(), | ||
| duration: test.duration, | ||
| err: error(test.err) | ||
| }; | ||
| } | ||
| function result(stats) { | ||
| return { | ||
| result: { | ||
| stats: { | ||
| tests: all.length, | ||
| passes: passes.length, | ||
| pending: pending.length, | ||
| failures: failures.length, | ||
| start: stats.start.toISOString(), | ||
| end: stats.end.toISOString(), | ||
| duration: stats.duration | ||
| }, | ||
| tests: all.map(clean), | ||
| pending: pending.map(clean), | ||
| failures: failures.map(clean), | ||
| passes: passes.map(clean) | ||
| }, | ||
| coverage: window.__coverage__ | ||
| }; | ||
| } | ||
| function setResult() { | ||
| !window.__mochaResult__ && (window.__mochaResult__ = result(this.stats)); | ||
| } | ||
| !reporterIsChanged && m.setup({ | ||
| reporter: Mocha.reporters[reporter] || Mocha.reporters.spec | ||
| }); | ||
| const runner = run(() => setTimeout(() => setResult.call(runner), 0)) | ||
| .on('pass', test => { passes.push(test); all.push(test); }) | ||
| .on('fail', test => { failures.push(test); all.push(test); }) | ||
| .on('pending', test => { pending.push(test); all.push(test); }) | ||
| .on('end', setResult); | ||
| return runner; | ||
| }; | ||
| } | ||
| function shimMochaProcess(M) { | ||
| // Mocha needs a process.stdout.write in order to change the cursor position. | ||
| !M.process && (M.process = {}); | ||
| !M.process.stdout && (M.process.stdout = {}); | ||
| M.process.stdout.write = data => console.log('stdout:', data); | ||
| M.reporters.Base.useColors = true; | ||
| M.reporters.none = function None(runner) { | ||
| M.reporters.Base.call(this, runner); | ||
| }; | ||
| } | ||
| Object.defineProperty(window, 'mocha', { | ||
| get: function() { return undefined }, | ||
| set: function(m) { | ||
| shimMochaInstance(m); | ||
| delete window.mocha; | ||
| window.mocha = m | ||
| }, | ||
| configurable: true | ||
| }) | ||
| Object.defineProperty(window, 'Mocha', { | ||
| get: function() { return undefined }, | ||
| set: function(m) { | ||
| shimMochaProcess(m); | ||
| delete window.Mocha; | ||
| window.Mocha = m; | ||
| }, | ||
| configurable: true | ||
| }); | ||
| } | ||
| function configureViewport(width, height, page) { | ||
| if (!width && !height) return page; | ||
| let viewport = page.viewport(); | ||
| width && (viewport.width = width); | ||
| height && (viewport.height = height); | ||
| return page.setViewport(viewport).then(() => page); | ||
| } | ||
| function handleConsole(msg) { | ||
| const args = msg.args() || []; | ||
| Promise.all(args.map(a => a.jsonValue().catch(error => { | ||
| console.warn('Failed to retrieve JSON value from argument:', error); | ||
| return ''; | ||
| }))) | ||
| .then(args => { | ||
| // process stdout stub | ||
| let isStdout = args[0] === 'stdout:'; | ||
| isStdout && (args = args.slice(1)); | ||
| let msg = util.format(...args); | ||
| !isStdout && msg && (msg += '\n'); | ||
| process.stdout.write(msg); | ||
| }); | ||
| } | ||
| function prepareUrl(filePath) { | ||
| if (/^[a-zA-Z]+:\/\//.test(filePath)) { | ||
| // path is URL | ||
| return filePath; | ||
| } | ||
| // local path | ||
| let resolvedPath = path.resolve(filePath); | ||
| return `file://${resolvedPath}`; | ||
| } | ||
| exports.runner = function ({ file, reporter, timeout, width, height, args, executablePath, visible, polling }) { | ||
| return new Promise(resolve => { | ||
| // validate options | ||
| if (!file) { | ||
| throw new Error('Test page path is required.'); | ||
| } | ||
| args = [].concat(args || []).map(arg => '--' + arg); | ||
| !timeout && (timeout = TIMEOUT_MILLISECONDS); | ||
| /^\d+$/.test(polling) && (polling = parseInt(polling)); | ||
| const url = prepareUrl(file); | ||
| const options = { | ||
| ignoreHTTPSErrors: true, | ||
| headless: !visible, | ||
| executablePath, | ||
| args | ||
| }; | ||
| const result = chromium.launch(options) | ||
| .then(browser => browser.newContext() | ||
| .then(context => context.newPage() | ||
| .then(page => { | ||
| if (width || height) { | ||
| return page.setViewportSize({ width: width || 800, height: height || 600 }).then(() => page); | ||
| } | ||
| return page; | ||
| }) | ||
| .then(page => { | ||
| page.on('console', handleConsole); | ||
| page.on('dialog', dialog => dialog.dismiss()); | ||
| page.on('pageerror', err => console.error(err)); | ||
| return page.addInitScript(initMocha, reporter) | ||
| .then(() => page.goto(url)) | ||
| .then(() => page.waitForFunction(() => window.__mochaResult__, { timeout, polling })) | ||
| .then(() => page.evaluate(() => window.__mochaResult__)) | ||
| .then(result => { | ||
| if (!result) { | ||
| throw new Error('Mocha results not found after waiting. The tests may not have run correctly.'); | ||
| } | ||
| // Close browser before resolving result | ||
| return browser.close().then(() => result); | ||
| }); | ||
| }) | ||
| ) | ||
| ); | ||
| resolve(result); | ||
| }); | ||
| }; |
| var less; | ||
| // Dist fallback for NPM-installed Less (for plugins that do testing) | ||
| try { | ||
| less = require('../tmp/less.cjs.js'); | ||
| } | ||
| catch (e) { | ||
| less = require('../dist/less.cjs.js'); | ||
| } | ||
| var fs = require('fs'); | ||
| var input = fs.readFileSync('./test/less/modifyVars/extended.less', 'utf8'); | ||
| var expectedCss = fs.readFileSync('./test/css/modifyVars/extended.css', 'utf8'); | ||
| var options = { | ||
| modifyVars: JSON.parse(fs.readFileSync('./test/less/modifyVars/extended.json', 'utf8')) | ||
| }; | ||
| less.render(input, options, function (err, result) { | ||
| if (err) { | ||
| console.log(err); | ||
| } | ||
| if (result.css === expectedCss) { | ||
| console.log('PASS'); | ||
| } else { | ||
| console.log('FAIL'); | ||
| } | ||
| }); |
| (function(exports) { | ||
| var plugin = function(less) { | ||
| var FileManager = less.FileManager, TestFileManager = new FileManager(); | ||
| function TestFileManager() { } | ||
| TestFileManager.loadFile = function (filename, currentDirectory, options, environment, callback) { | ||
| if (filename.match(/.*\.test$/)) { | ||
| return less.environment.fileManagers[0].loadFile('colors.test', currentDirectory, options, environment, callback); | ||
| } | ||
| return less.environment.fileManagers[0].loadFile(filename, currentDirectory, options, environment, callback); | ||
| }; | ||
| return TestFileManager; | ||
| }; | ||
| exports.install = function(less, pluginManager) { | ||
| less.environment.addFileManager(new plugin(less)); | ||
| }; | ||
| })(typeof exports === 'undefined' ? this['AddFilePlugin'] = {} : exports); |
| (function(exports) { | ||
| var postProcessor = function() {}; | ||
| postProcessor.prototype = { | ||
| process: function (css) { | ||
| return 'hr {height:50px;}\n' + css; | ||
| } | ||
| }; | ||
| exports.install = function(less, pluginManager) { | ||
| pluginManager.addPostProcessor( new postProcessor()); | ||
| }; | ||
| })(typeof exports === 'undefined' ? this['postProcessorPlugin'] = {} : exports); |
| (function(exports) { | ||
| var preProcessor = function() {}; | ||
| preProcessor.prototype = { | ||
| process : function (src, extra) { | ||
| var injected = '@color: red;\n'; | ||
| var ignored = extra.imports.contentsIgnoredChars; | ||
| var fileInfo = extra.fileInfo; | ||
| ignored[fileInfo.filename] = ignored[fileInfo.filename] || 0; | ||
| ignored[fileInfo.filename] += injected.length; | ||
| return injected + src; | ||
| } | ||
| }; | ||
| exports.install = function(less, pluginManager) { | ||
| pluginManager.addPreProcessor( new preProcessor() ); | ||
| }; | ||
| })(typeof exports === 'undefined' ? this['preProcessorPlugin'] = {} : exports); |
| (function(exports) { | ||
| var RemoveProperty = function(less) { | ||
| this._visitor = new less.visitors.Visitor(this); | ||
| }; | ||
| RemoveProperty.prototype = { | ||
| isReplacing: true, | ||
| run: function (root) { | ||
| return this._visitor.visit(root); | ||
| }, | ||
| visitDeclaration: function (ruleNode, visitArgs) { | ||
| if (ruleNode.name != '-some-aribitrary-property') { | ||
| return ruleNode; | ||
| } else { | ||
| return []; | ||
| } | ||
| } | ||
| }; | ||
| exports.install = function(less, pluginManager) { | ||
| pluginManager.addVisitor( new RemoveProperty(less)); | ||
| }; | ||
| })(typeof exports === 'undefined' ? this['VisitorPlugin'] = {} : exports); |
| Tests are generally organized in the `less/` folder by what options are set in index.js. | ||
| The main tests are located under `less/_main/` |
| {"version":3,"sources":["testweb/sourcemaps-disable-annotation/basic.less"],"names":[],"mappings":"AAAA;;EAEE,YAAA","file":"sourcemaps-disable-annotation/basic.css"} |
| {"version":3,"sources":["testweb/sourcemaps-variable-selector/basic.less"],"names":[],"mappings":"AAEC;EACG,eAAA","file":"sourcemaps-variable-selector/basic.css"} |
| {"version":3,"sources":["testweb/sourcemaps/basic.less","testweb/sourcemaps/imported.css"],"names":[],"mappings":"AAMA;EACE,YAAA;EAJA,UAAA;EAWA,iBAAA;EALA,WAAA;EACA,iBAAA;;AAJF,EASE;AATF,EASM;EACF,gBAAA;;AACA,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFA;AAEF,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFA;EAGA,UAAA;;AALN;AAAI;AAUJ;EATE,iBAAA;;AADF,EAEE;AAFE,EAEF;AAFF,EAEM;AAFF,EAEE;AAQN,OARE;AAQF,OARM;EACF,gBAAA;;AACA,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,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;AAKJ;AAMA;EALE,kBAAA;EACA,YAAA;EACA,eAAA;;AAGF;EAEE,mBAAA;EACA,YAAA;;AAIF,WACE;EACE,gBAAA;;AAFJ,WACE,GAGE;EACE,qBAAA;;AALN,WACE,GAGE,GAGE;EACE,qBAAA;;AAEA,WATN,GAGE,GAGE,EAGG;EACC,cAAA;;AAGF,WAbN,GAGE,GAGE,EAOG;EACC,cAAA;;AAYT;EACC,cAAA;;AAIF,OACE,QACE,QACE;EACE,cAAA","file":"{path}comprehensive.css"} |
| {"version":3,"sources":["testweb/sourcemaps/custom-props.less"],"names":[],"mappings":"AAEA;EACC,uBAHO,UAGP;EACA,OAAO,eAAP;EACA,sBALO,UAKP","file":"sourcemaps/custom-props.css"} |
| <html> | ||
| <link type="text/css" rel="stylesheet" media="all" href="import.css"> | ||
| <link type="text/css" rel="stylesheet" media="all" href="basic.css"> | ||
| <head> | ||
| </head> | ||
| <body> | ||
| <div id="import-test">id import-test</div> | ||
| <div id="import">id import-test</div> | ||
| <div class="imported inline">class imported inline</div> | ||
| <div id="mixin">class mixin</div> | ||
| <div class="a">class a</div> | ||
| <div class="b">class b</div> | ||
| <div class="b">class b<div class="c">class c</div></div> | ||
| <div class="a">class a<div class="d">class d</div></div> | ||
| <div class="extend">class extend<div class="c">class c</div></div> | ||
| </body> | ||
| </html> |
| {"version":3,"sources":["testweb/sourcemaps-basepath.less"],"names":[],"mappings":"AAEA;EACE,eAAA;EACA,gBAAA;;AAGF;EACE,iBAAA","file":"tests-config/sourcemaps-basepath/sourcemaps-basepath.css"} |
| {"version":3,"sources":["testweb/sourcemaps-include-source.less"],"names":[],"mappings":"AAGA;EACE,mBAAA;EACA,YAAA;EACA,kBAAA;;AAGF;EACE,mBAAA","file":"tests-config/sourcemaps-include-source/sourcemaps-include-source.css","sourcesContent":["@primary: #007bff;\n@secondary: #6c757d;\n\n.button {\n background: @primary;\n color: white;\n padding: 10px 20px;\n}\n\n.secondary {\n background: @secondary;\n}\n\n"]} |
| {"version":3,"sources":["https://example.com/less/sourcemaps-rootpath.less"],"names":[],"mappings":"AAEA;EACE,aAAA;EACA,YAAA;;AAGF;EACE,WAAA","file":"tests-config/sourcemaps-rootpath/sourcemaps-rootpath.css"} |
| {"version":3,"sources":["testweb/sourcemaps-url.less"],"names":[],"mappings":"AAEA;EACE,UAAA;EACA,gBAAA;;AAGF;EACE,YAAA","file":"tests-config/sourcemaps-url/sourcemaps-url.css"} |
| // https://github.com/less/less.js/issues/3533 | ||
| console.log('Testing ES6 imports...') | ||
| import less from '..'; | ||
| const lessRender = less.render; | ||
| // then I call lessRender on something | ||
| lessRender(` | ||
| body { | ||
| a: 1; | ||
| b: 2; | ||
| c: 30; | ||
| d: 4; | ||
| }`, {sourceMap: {}}, function(error: any, output: any) { | ||
| if (error) | ||
| console.error(error) | ||
| }) |
| { | ||
| "extends": "./tsconfig", | ||
| "compilerOptions": { | ||
| "rootDir": "./src", | ||
| }, | ||
| "include": ["src/**/*"] | ||
| } |
| { | ||
| "compilerOptions": { | ||
| "outDir": "./lib", | ||
| "moduleResolution": "node", | ||
| "rootDir": ".", | ||
| "allowJs": true, | ||
| "sourceMap": true, | ||
| "inlineSources": true, | ||
| "esModuleInterop": true, | ||
| "importHelpers": true, | ||
| "noImplicitAny": true, | ||
| "target": "ES5" | ||
| }, | ||
| "ts-node": { | ||
| "compilerOptions": { | ||
| "rootDir": "." | ||
| } | ||
| }, | ||
| "include": ["**/*"], | ||
| "exclude": ["node_modules", "lib/**/*"] | ||
| } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed or built. Malicious packages often use scripts that run automatically to execute payloads or fetch additional code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 12 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
9
-10%49
-2%0
-100%152
-16.48%Yes
NaN2043437
-32.24%120
-64.29%27295
-4.45%354
34.09%+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
Updated