Repository: less/less.js
Branch: master
Commit: ea62d748d48c
Files: 904
Total size: 1.8 MB
Directory structure:
gitextract_l41uqth4/
├── .all-contributorsrc
├── .coderabbit.yaml
├── .editorconfig
├── .gitattributes
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug.md
│ │ └── config.yml
│ ├── PULL_REQUEST_TEMPLATE.md
│ ├── SECURITY.md
│ ├── TESTING_PUBLISHING.md
│ ├── stale.yml
│ └── workflows/
│ ├── ci.yml
│ ├── create-release-pr.yml
│ └── publish.yml
├── .gitignore
├── .husky/
│ ├── post-merge
│ └── pre-commit
├── .nvmrc
├── .vscode/
│ └── launch.json
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── package-lock.json
├── package.json
├── packages/
│ ├── less/
│ │ ├── .eslintignore
│ │ ├── .eslintrc.cjs
│ │ ├── .gitignore
│ │ ├── .npmignore
│ │ ├── Gruntfile.cjs
│ │ ├── README.md
│ │ ├── benchmark/
│ │ │ ├── benchmark-import-reference-target.less
│ │ │ ├── benchmark-import-target.less
│ │ │ ├── benchmark-runner.js
│ │ │ ├── benchmark-v3.less
│ │ │ ├── benchmark-v37.less
│ │ │ ├── benchmark-v39.less
│ │ │ ├── benchmark.less
│ │ │ ├── index.js
│ │ │ ├── results/
│ │ │ │ ├── .gitignore
│ │ │ │ ├── latest/
│ │ │ │ │ └── macbook-pro_arm64.json
│ │ │ │ └── runs/
│ │ │ │ ├── 2026-03-09T21-34-11Z_macbook-pro_arm64.json
│ │ │ │ └── 2026-03-09_macbook-pro_arm64.json
│ │ │ └── run-historical.sh
│ │ ├── bin/
│ │ │ └── lessc
│ │ ├── bower.json
│ │ ├── build/
│ │ │ ├── banner.js
│ │ │ └── rollup.js
│ │ ├── index.cjs
│ │ ├── lib/
│ │ │ ├── less/
│ │ │ │ ├── constants.js
│ │ │ │ ├── contexts.js
│ │ │ │ ├── data/
│ │ │ │ │ ├── colors.js
│ │ │ │ │ ├── index.js
│ │ │ │ │ └── unit-conversions.js
│ │ │ │ ├── default-options.js
│ │ │ │ ├── deprecation.js
│ │ │ │ ├── environment/
│ │ │ │ │ ├── abstract-file-manager.js
│ │ │ │ │ ├── abstract-plugin-loader.js
│ │ │ │ │ ├── environment-api.ts
│ │ │ │ │ ├── environment.js
│ │ │ │ │ └── file-manager-api.ts
│ │ │ │ ├── functions/
│ │ │ │ │ ├── boolean.js
│ │ │ │ │ ├── color-blending.js
│ │ │ │ │ ├── color.js
│ │ │ │ │ ├── data-uri.js
│ │ │ │ │ ├── default.js
│ │ │ │ │ ├── function-caller.js
│ │ │ │ │ ├── function-registry.js
│ │ │ │ │ ├── index.js
│ │ │ │ │ ├── list.js
│ │ │ │ │ ├── math-helper.js
│ │ │ │ │ ├── math.js
│ │ │ │ │ ├── number.js
│ │ │ │ │ ├── string.js
│ │ │ │ │ ├── style.js
│ │ │ │ │ ├── svg.js
│ │ │ │ │ └── types.js
│ │ │ │ ├── import-manager.js
│ │ │ │ ├── index.js
│ │ │ │ ├── less-error.js
│ │ │ │ ├── logger.js
│ │ │ │ ├── parse-tree.js
│ │ │ │ ├── parse.js
│ │ │ │ ├── parser/
│ │ │ │ │ ├── parser-input.js
│ │ │ │ │ └── parser.js
│ │ │ │ ├── plugin-manager.js
│ │ │ │ ├── render.js
│ │ │ │ ├── source-map-builder.js
│ │ │ │ ├── source-map-output.js
│ │ │ │ ├── transform-tree.js
│ │ │ │ ├── tree/
│ │ │ │ │ ├── anonymous.js
│ │ │ │ │ ├── assignment.js
│ │ │ │ │ ├── atrule-syntax.js
│ │ │ │ │ ├── atrule.js
│ │ │ │ │ ├── attribute.js
│ │ │ │ │ ├── call.js
│ │ │ │ │ ├── color.js
│ │ │ │ │ ├── combinator.js
│ │ │ │ │ ├── comment.js
│ │ │ │ │ ├── condition.js
│ │ │ │ │ ├── container.js
│ │ │ │ │ ├── debug-info.js
│ │ │ │ │ ├── declaration.js
│ │ │ │ │ ├── detached-ruleset.js
│ │ │ │ │ ├── dimension.js
│ │ │ │ │ ├── element.js
│ │ │ │ │ ├── expression.js
│ │ │ │ │ ├── extend.js
│ │ │ │ │ ├── import.js
│ │ │ │ │ ├── index.js
│ │ │ │ │ ├── javascript.js
│ │ │ │ │ ├── js-eval-node.js
│ │ │ │ │ ├── keyword.js
│ │ │ │ │ ├── media.js
│ │ │ │ │ ├── merge-rules.js
│ │ │ │ │ ├── mixin-call.js
│ │ │ │ │ ├── mixin-definition.js
│ │ │ │ │ ├── namespace-value.js
│ │ │ │ │ ├── negative.js
│ │ │ │ │ ├── nested-at-rule.js
│ │ │ │ │ ├── node.js
│ │ │ │ │ ├── operation.js
│ │ │ │ │ ├── paren.js
│ │ │ │ │ ├── property.js
│ │ │ │ │ ├── query-in-parens.js
│ │ │ │ │ ├── quoted.js
│ │ │ │ │ ├── ruleset.js
│ │ │ │ │ ├── selector.js
│ │ │ │ │ ├── unicode-descriptor.js
│ │ │ │ │ ├── unit.js
│ │ │ │ │ ├── url.js
│ │ │ │ │ ├── value.js
│ │ │ │ │ ├── variable-call.js
│ │ │ │ │ └── variable.js
│ │ │ │ ├── utils.js
│ │ │ │ └── visitors/
│ │ │ │ ├── extend-visitor.js
│ │ │ │ ├── import-sequencer.js
│ │ │ │ ├── import-visitor.js
│ │ │ │ ├── index.js
│ │ │ │ ├── join-selector-visitor.js
│ │ │ │ ├── set-tree-visibility-visitor.js
│ │ │ │ ├── to-css-visitor.js
│ │ │ │ └── visitor.js
│ │ │ ├── less-browser/
│ │ │ │ ├── add-default-options.js
│ │ │ │ ├── bootstrap.js
│ │ │ │ ├── browser.js
│ │ │ │ ├── cache.js
│ │ │ │ ├── error-reporting.js
│ │ │ │ ├── file-manager.js
│ │ │ │ ├── image-size.js
│ │ │ │ ├── index.js
│ │ │ │ ├── log-listener.js
│ │ │ │ ├── plugin-loader.js
│ │ │ │ └── utils.js
│ │ │ └── less-node/
│ │ │ ├── environment.js
│ │ │ ├── file-manager.js
│ │ │ ├── fs.js
│ │ │ ├── image-size.js
│ │ │ ├── index.js
│ │ │ ├── lessc-helper.js
│ │ │ ├── plugin-loader.js
│ │ │ └── url-file-manager.js
│ │ ├── package.json
│ │ ├── scripts/
│ │ │ ├── coverage-lines.js
│ │ │ ├── coverage-report.js
│ │ │ └── postinstall.js
│ │ ├── test/
│ │ │ ├── .eslintrc.json
│ │ │ ├── README.md
│ │ │ ├── browser/
│ │ │ │ ├── common.js
│ │ │ │ ├── css/
│ │ │ │ │ ├── global-vars/
│ │ │ │ │ │ └── simple.css
│ │ │ │ │ ├── modify-vars/
│ │ │ │ │ │ └── simple.css
│ │ │ │ │ ├── plugin/
│ │ │ │ │ │ └── plugin.css
│ │ │ │ │ ├── postProcessor/
│ │ │ │ │ │ └── postProcessor.css
│ │ │ │ │ ├── relative-urls/
│ │ │ │ │ │ └── urls.css
│ │ │ │ │ ├── rewrite-urls/
│ │ │ │ │ │ └── urls.css
│ │ │ │ │ ├── rootpath/
│ │ │ │ │ │ └── urls.css
│ │ │ │ │ ├── rootpath-relative/
│ │ │ │ │ │ └── urls.css
│ │ │ │ │ ├── rootpath-rewrite-urls/
│ │ │ │ │ │ └── urls.css
│ │ │ │ │ └── urls.css
│ │ │ │ ├── generator/
│ │ │ │ │ ├── benchmark.config.cjs
│ │ │ │ │ ├── generate.cjs
│ │ │ │ │ ├── generate.js
│ │ │ │ │ ├── runner.cjs
│ │ │ │ │ ├── runner.config.cjs
│ │ │ │ │ ├── runner.js
│ │ │ │ │ ├── template.cjs
│ │ │ │ │ └── utils.cjs
│ │ │ │ ├── less/
│ │ │ │ │ ├── console-errors/
│ │ │ │ │ │ ├── test-error.less
│ │ │ │ │ │ └── test-error.txt
│ │ │ │ │ ├── errors/
│ │ │ │ │ │ ├── image-height-error.less
│ │ │ │ │ │ ├── image-height-error.txt
│ │ │ │ │ │ ├── image-size-error.less
│ │ │ │ │ │ ├── image-size-error.txt
│ │ │ │ │ │ ├── image-width-error.less
│ │ │ │ │ │ └── image-width-error.txt
│ │ │ │ │ ├── global-vars/
│ │ │ │ │ │ └── simple.less
│ │ │ │ │ ├── imports/
│ │ │ │ │ │ ├── urls.less
│ │ │ │ │ │ └── urls2.less
│ │ │ │ │ ├── modify-vars/
│ │ │ │ │ │ ├── imports/
│ │ │ │ │ │ │ └── simple2.less
│ │ │ │ │ │ └── simple.less
│ │ │ │ │ ├── nested-gradient-with-svg-gradient/
│ │ │ │ │ │ ├── mixin-consumer.less
│ │ │ │ │ │ └── svg-gradient-mixin.less
│ │ │ │ │ ├── plugin/
│ │ │ │ │ │ ├── plugin.js
│ │ │ │ │ │ └── plugin.less
│ │ │ │ │ ├── postProcessor/
│ │ │ │ │ │ └── postProcessor.less
│ │ │ │ │ ├── relative-urls/
│ │ │ │ │ │ └── urls.less
│ │ │ │ │ ├── rewrite-urls/
│ │ │ │ │ │ └── urls.less
│ │ │ │ │ ├── rootpath/
│ │ │ │ │ │ └── urls.less
│ │ │ │ │ ├── rootpath-relative/
│ │ │ │ │ │ └── urls.less
│ │ │ │ │ ├── rootpath-rewrite-urls/
│ │ │ │ │ │ └── urls.less
│ │ │ │ │ └── urls.less
│ │ │ │ ├── runner-VisitorPlugin-options.js
│ │ │ │ ├── runner-VisitorPlugin.js
│ │ │ │ ├── runner-browser-options.js
│ │ │ │ ├── runner-browser-spec.js
│ │ │ │ ├── runner-console-errors.js
│ │ │ │ ├── runner-errors-options.js
│ │ │ │ ├── runner-errors-spec.js
│ │ │ │ ├── runner-filemanagerPlugin-options.js
│ │ │ │ ├── runner-filemanagerPlugin.js
│ │ │ │ ├── runner-global-vars-options.js
│ │ │ │ ├── runner-global-vars-spec.js
│ │ │ │ ├── runner-main-options.js
│ │ │ │ ├── runner-main-spec.js
│ │ │ │ ├── runner-modify-vars-options.js
│ │ │ │ ├── runner-modify-vars-spec.js
│ │ │ │ ├── runner-no-js-errors-options.js
│ │ │ │ ├── runner-no-js-errors-spec.js
│ │ │ │ ├── runner-postProcessorPlugin-options.js
│ │ │ │ ├── runner-postProcessorPlugin.js
│ │ │ │ ├── runner-preProcessorPlugin-options.js
│ │ │ │ ├── runner-preProcessorPlugin.js
│ │ │ │ ├── runner-production-options.js
│ │ │ │ ├── runner-production-spec.js
│ │ │ │ ├── runner-relative-urls-options.js
│ │ │ │ ├── runner-relative-urls-spec.js
│ │ │ │ ├── runner-rewrite-urls-options.js
│ │ │ │ ├── runner-rewrite-urls-spec.js
│ │ │ │ ├── runner-rootpath-options.js
│ │ │ │ ├── runner-rootpath-relative-options.js
│ │ │ │ ├── runner-rootpath-relative-spec.js
│ │ │ │ ├── runner-rootpath-rewrite-urls-options.js
│ │ │ │ ├── runner-rootpath-rewrite-urls-spec.js
│ │ │ │ ├── runner-rootpath-spec.js
│ │ │ │ ├── runner-strict-units-options.js
│ │ │ │ └── runner-strict-units-spec.js
│ │ │ ├── exports/
│ │ │ │ ├── import-patterns.cjs
│ │ │ │ ├── webpack-browser-entry.js
│ │ │ │ └── webpack-browser.cjs
│ │ │ ├── index.js
│ │ │ ├── less-test.js
│ │ │ ├── mocha-playwright/
│ │ │ │ └── runner.js
│ │ │ ├── modify-vars.js
│ │ │ ├── plugins/
│ │ │ │ ├── filemanager/
│ │ │ │ │ └── index.cjs
│ │ │ │ ├── postprocess/
│ │ │ │ │ └── index.cjs
│ │ │ │ ├── preprocess/
│ │ │ │ │ └── index.cjs
│ │ │ │ └── visitor/
│ │ │ │ └── index.cjs
│ │ │ ├── sourcemaps/
│ │ │ │ ├── basic.json
│ │ │ │ ├── comprehensive.json
│ │ │ │ ├── custom-props.json
│ │ │ │ ├── index.html
│ │ │ │ ├── sourcemaps-basepath.json
│ │ │ │ ├── sourcemaps-include-source.json
│ │ │ │ ├── sourcemaps-rootpath.json
│ │ │ │ └── sourcemaps-url.json
│ │ │ ├── sourcemaps-disable-annotation/
│ │ │ │ └── basic.json
│ │ │ ├── sourcemaps-variable-selector/
│ │ │ │ └── basic.json
│ │ │ ├── test-cjs-suite.cjs
│ │ │ ├── test-cjs.cjs
│ │ │ └── test-es6.js
│ │ ├── test.less
│ │ └── tsconfig.json
│ ├── test-data/
│ │ ├── data/
│ │ │ └── page.html
│ │ ├── index.js
│ │ ├── package.json
│ │ ├── plugin/
│ │ │ ├── plugin-collection.js
│ │ │ ├── plugin-global.js
│ │ │ ├── plugin-local.js
│ │ │ ├── plugin-preeval.js
│ │ │ ├── plugin-scope1.js
│ │ │ ├── plugin-scope2.js
│ │ │ ├── plugin-set-options-v2.js
│ │ │ ├── plugin-set-options-v3.js
│ │ │ ├── plugin-set-options.js
│ │ │ ├── plugin-simple.js
│ │ │ ├── plugin-transitive.js
│ │ │ ├── plugin-transitive.less
│ │ │ └── plugin-tree-nodes.js
│ │ ├── tests-config/
│ │ │ ├── 3rd-party/
│ │ │ │ ├── bootstrap4.css
│ │ │ │ ├── bootstrap4.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── at-rules-compressed/
│ │ │ │ ├── at-rules-compressed.css
│ │ │ │ ├── at-rules-compressed.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── at-rules-compressed-evaluation/
│ │ │ │ ├── at-rules-compressed-evaluation.css
│ │ │ │ ├── at-rules-compressed-evaluation.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── compression/
│ │ │ │ ├── compression.css
│ │ │ │ ├── compression.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── debug/
│ │ │ │ ├── all/
│ │ │ │ │ ├── linenumbers-all.css
│ │ │ │ │ ├── linenumbers-all.less
│ │ │ │ │ └── styles.config.cjs
│ │ │ │ ├── comments/
│ │ │ │ │ ├── linenumbers-comments.css
│ │ │ │ │ ├── linenumbers-comments.less
│ │ │ │ │ └── styles.config.cjs
│ │ │ │ ├── import/
│ │ │ │ │ └── test.less
│ │ │ │ ├── linenumbers.less
│ │ │ │ └── mediaquery/
│ │ │ │ ├── linenumbers-mediaquery.css
│ │ │ │ ├── linenumbers-mediaquery.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── filemanagerPlugin/
│ │ │ │ ├── colors.test
│ │ │ │ ├── filemanager.css
│ │ │ │ ├── filemanager.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── globalVars/
│ │ │ │ ├── extended.css
│ │ │ │ ├── extended.json
│ │ │ │ ├── extended.less
│ │ │ │ ├── simple.css
│ │ │ │ ├── simple.json
│ │ │ │ ├── simple.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── import-redirect/
│ │ │ │ └── import-redirect.less
│ │ │ ├── include-path/
│ │ │ │ ├── import-test-e.less
│ │ │ │ ├── include-path.css
│ │ │ │ ├── include-path.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── include-path-string/
│ │ │ │ ├── include-path-string.css
│ │ │ │ ├── include-path-string.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── js-type-errors/
│ │ │ │ ├── js-type-error-2.txt
│ │ │ │ ├── js-type-error.less
│ │ │ │ ├── js-type-error.txt
│ │ │ │ └── styles.config.cjs
│ │ │ ├── math/
│ │ │ │ ├── always/
│ │ │ │ │ ├── mixins-guards.css
│ │ │ │ │ └── no-sm-operations.css
│ │ │ │ ├── parens-division/
│ │ │ │ │ ├── media-math.css
│ │ │ │ │ ├── mixins-args.css
│ │ │ │ │ ├── new-division.css
│ │ │ │ │ └── parens.css
│ │ │ │ └── strict/
│ │ │ │ ├── css.css
│ │ │ │ ├── media-math.css
│ │ │ │ ├── mixins-args.css
│ │ │ │ └── parens.css
│ │ │ ├── math-always/
│ │ │ │ ├── mixins-guards.less
│ │ │ │ ├── no-sm-operations.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── math-parens-division/
│ │ │ │ ├── media-math.less
│ │ │ │ ├── mixins-args.less
│ │ │ │ ├── new-division.less
│ │ │ │ ├── parens.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── math-strict/
│ │ │ │ ├── css.less
│ │ │ │ ├── media-math.less
│ │ │ │ ├── mixins-args.less
│ │ │ │ ├── parens.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── modifyVars/
│ │ │ │ ├── extended.css
│ │ │ │ ├── extended.json
│ │ │ │ ├── extended.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── namespacing/
│ │ │ │ ├── imports/
│ │ │ │ │ ├── a-better-bootstrap.less
│ │ │ │ │ └── library.less
│ │ │ │ ├── namespacing-1.css
│ │ │ │ ├── namespacing-1.less
│ │ │ │ ├── namespacing-2.css
│ │ │ │ ├── namespacing-2.less
│ │ │ │ ├── namespacing-3.css
│ │ │ │ ├── namespacing-3.less
│ │ │ │ ├── namespacing-4.css
│ │ │ │ ├── namespacing-4.less
│ │ │ │ ├── namespacing-5.css
│ │ │ │ ├── namespacing-5.less
│ │ │ │ ├── namespacing-6.css
│ │ │ │ ├── namespacing-6.less
│ │ │ │ ├── namespacing-7.css
│ │ │ │ ├── namespacing-7.less
│ │ │ │ ├── namespacing-8.css
│ │ │ │ ├── namespacing-8.less
│ │ │ │ ├── namespacing-functions.css
│ │ │ │ ├── namespacing-functions.less
│ │ │ │ ├── namespacing-media.css
│ │ │ │ ├── namespacing-media.less
│ │ │ │ ├── namespacing-operations.css
│ │ │ │ ├── namespacing-operations.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── no-js-errors/
│ │ │ │ ├── no-js-errors.less
│ │ │ │ ├── no-js-errors.txt
│ │ │ │ └── styles.config.cjs
│ │ │ ├── postProcessorPlugin/
│ │ │ │ ├── postProcessor.css
│ │ │ │ ├── postProcessor.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── preProcessorPlugin/
│ │ │ │ ├── preProcessor.css
│ │ │ │ ├── preProcessor.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── process-imports/
│ │ │ │ ├── google.css
│ │ │ │ ├── google.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── rewrite-urls-all/
│ │ │ │ ├── folder/
│ │ │ │ │ └── file.less
│ │ │ │ ├── rewrite-urls-all.css
│ │ │ │ ├── rewrite-urls-all.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── rewrite-urls-local/
│ │ │ │ ├── folder/
│ │ │ │ │ └── file.less
│ │ │ │ ├── rewrite-urls-local.css
│ │ │ │ ├── rewrite-urls-local.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── root-registry/
│ │ │ │ ├── file.less
│ │ │ │ └── root.less
│ │ │ ├── rootpath-rewrite-urls-all/
│ │ │ │ ├── folder/
│ │ │ │ │ └── file.less
│ │ │ │ ├── rootpath-rewrite-urls-all.css
│ │ │ │ ├── rootpath-rewrite-urls-all.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── rootpath-rewrite-urls-local/
│ │ │ │ ├── folder/
│ │ │ │ │ └── file.less
│ │ │ │ ├── rootpath-rewrite-urls-local.css
│ │ │ │ ├── rootpath-rewrite-urls-local.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── sourcemaps/
│ │ │ │ ├── basic.json
│ │ │ │ ├── basic.less
│ │ │ │ ├── comprehensive/
│ │ │ │ │ ├── comprehensive.css
│ │ │ │ │ ├── comprehensive.less
│ │ │ │ │ └── styles.config.cjs
│ │ │ │ ├── custom-props.less
│ │ │ │ ├── imported.css
│ │ │ │ └── styles.config.cjs
│ │ │ ├── sourcemaps-basepath/
│ │ │ │ ├── sourcemaps-basepath.css
│ │ │ │ ├── sourcemaps-basepath.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── sourcemaps-disable-annotation/
│ │ │ │ ├── basic.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── sourcemaps-empty/
│ │ │ │ ├── empty.less
│ │ │ │ ├── styles.config.cjs
│ │ │ │ └── var-defs.less
│ │ │ ├── sourcemaps-include-source/
│ │ │ │ ├── sourcemaps-include-source.css
│ │ │ │ ├── sourcemaps-include-source.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── sourcemaps-rootpath/
│ │ │ │ ├── sourcemaps-rootpath.css
│ │ │ │ ├── sourcemaps-rootpath.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── sourcemaps-url/
│ │ │ │ ├── sourcemaps-url.css
│ │ │ │ ├── sourcemaps-url.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── sourcemaps-variable-selector/
│ │ │ │ ├── basic.less
│ │ │ │ ├── styles.config.cjs
│ │ │ │ └── vars.less
│ │ │ ├── static-urls/
│ │ │ │ ├── styles.config.cjs
│ │ │ │ ├── urls.css
│ │ │ │ └── urls.less
│ │ │ ├── strict-imports/
│ │ │ │ ├── imported.less
│ │ │ │ ├── strict-imports.css
│ │ │ │ ├── strict-imports.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── units/
│ │ │ │ ├── no-strict/
│ │ │ │ │ ├── no-strict.css
│ │ │ │ │ ├── no-strict.less
│ │ │ │ │ └── styles.config.cjs
│ │ │ │ └── strict/
│ │ │ │ ├── strict-units.css
│ │ │ │ ├── strict-units.less
│ │ │ │ └── styles.config.cjs
│ │ │ ├── url-args/
│ │ │ │ ├── styles.config.cjs
│ │ │ │ ├── urls.css
│ │ │ │ └── urls.less
│ │ │ └── visitorPlugin/
│ │ │ ├── styles.config.cjs
│ │ │ ├── visitor.css
│ │ │ └── visitor.less
│ │ ├── tests-error/
│ │ │ ├── eval/
│ │ │ │ ├── add-mixed-units.less
│ │ │ │ ├── add-mixed-units.txt
│ │ │ │ ├── add-mixed-units2.less
│ │ │ │ ├── add-mixed-units2.txt
│ │ │ │ ├── at-rules-undefined-var.less
│ │ │ │ ├── at-rules-undefined-var.txt
│ │ │ │ ├── color-func-invalid-color-2.less
│ │ │ │ ├── color-func-invalid-color-2.txt
│ │ │ │ ├── color-func-invalid-color.less
│ │ │ │ ├── color-func-invalid-color.txt
│ │ │ │ ├── css-guard-default-func.less
│ │ │ │ ├── css-guard-default-func.txt
│ │ │ │ ├── detached-ruleset-1.less
│ │ │ │ ├── detached-ruleset-1.txt
│ │ │ │ ├── detached-ruleset-2.less
│ │ │ │ ├── detached-ruleset-2.txt
│ │ │ │ ├── detached-ruleset-3.less
│ │ │ │ ├── detached-ruleset-3.txt
│ │ │ │ ├── detached-ruleset-5.less
│ │ │ │ ├── detached-ruleset-5.txt
│ │ │ │ ├── divide-mixed-units.less
│ │ │ │ ├── divide-mixed-units.txt
│ │ │ │ ├── extend-no-selector.less
│ │ │ │ ├── extend-no-selector.txt
│ │ │ │ ├── functions-1.less
│ │ │ │ ├── functions-1.txt
│ │ │ │ ├── functions-10-keyword.less
│ │ │ │ ├── functions-10-keyword.txt
│ │ │ │ ├── functions-11-operation.less
│ │ │ │ ├── functions-11-operation.txt
│ │ │ │ ├── functions-12-quoted.less
│ │ │ │ ├── functions-12-quoted.txt
│ │ │ │ ├── functions-13-selector.less
│ │ │ │ ├── functions-13-selector.txt
│ │ │ │ ├── functions-14-url.less
│ │ │ │ ├── functions-14-url.txt
│ │ │ │ ├── functions-15-value.less
│ │ │ │ ├── functions-15-value.txt
│ │ │ │ ├── functions-3-assignment.less
│ │ │ │ ├── functions-3-assignment.txt
│ │ │ │ ├── functions-4-call.less
│ │ │ │ ├── functions-4-call.txt
│ │ │ │ ├── functions-5-color-2.less
│ │ │ │ ├── functions-5-color-2.txt
│ │ │ │ ├── functions-5-color.less
│ │ │ │ ├── functions-5-color.txt
│ │ │ │ ├── functions-6-condition.less
│ │ │ │ ├── functions-6-condition.txt
│ │ │ │ ├── functions-7-dimension.less
│ │ │ │ ├── functions-7-dimension.txt
│ │ │ │ ├── functions-8-element.less
│ │ │ │ ├── functions-8-element.txt
│ │ │ │ ├── functions-9-expression.less
│ │ │ │ ├── functions-9-expression.txt
│ │ │ │ ├── import-missing.less
│ │ │ │ ├── import-missing.txt
│ │ │ │ ├── import-subfolder1.less
│ │ │ │ ├── import-subfolder1.txt
│ │ │ │ ├── imports/
│ │ │ │ │ ├── import-subfolder1.less
│ │ │ │ │ ├── import-test.less
│ │ │ │ │ └── subfolder/
│ │ │ │ │ └── mixin-not-defined.less
│ │ │ │ ├── javascript-undefined-var.less
│ │ │ │ ├── javascript-undefined-var.txt
│ │ │ │ ├── mixin-not-defined-2.less
│ │ │ │ ├── mixin-not-defined-2.txt
│ │ │ │ ├── mixin-not-defined.less
│ │ │ │ ├── mixin-not-defined.txt
│ │ │ │ ├── mixin-not-matched.less
│ │ │ │ ├── mixin-not-matched.txt
│ │ │ │ ├── mixin-not-matched2.less
│ │ │ │ ├── mixin-not-matched2.txt
│ │ │ │ ├── mixin-not-visible-in-scope-1.less
│ │ │ │ ├── mixin-not-visible-in-scope-1.txt
│ │ │ │ ├── mixins-guards-default-func-1.less
│ │ │ │ ├── mixins-guards-default-func-1.txt
│ │ │ │ ├── mixins-guards-default-func-2.less
│ │ │ │ ├── mixins-guards-default-func-2.txt
│ │ │ │ ├── mixins-guards-default-func-3.less
│ │ │ │ ├── mixins-guards-default-func-3.txt
│ │ │ │ ├── multiple-guards-on-css-selectors.less
│ │ │ │ ├── multiple-guards-on-css-selectors.txt
│ │ │ │ ├── multiple-guards-on-css-selectors2.less
│ │ │ │ ├── multiple-guards-on-css-selectors2.txt
│ │ │ │ ├── multiply-mixed-units.less
│ │ │ │ ├── multiply-mixed-units.txt
│ │ │ │ ├── namespace-property-not-found.less
│ │ │ │ ├── namespace-property-not-found.txt
│ │ │ │ ├── namespace-variable-not-found.less
│ │ │ │ ├── namespace-variable-not-found.txt
│ │ │ │ ├── namespacing-2.less
│ │ │ │ ├── namespacing-2.txt
│ │ │ │ ├── namespacing-3.less
│ │ │ │ ├── namespacing-3.txt
│ │ │ │ ├── namespacing-4.less
│ │ │ │ ├── namespacing-4.txt
│ │ │ │ ├── percentage-non-number-argument.less
│ │ │ │ ├── percentage-non-number-argument.txt
│ │ │ │ ├── plugin/
│ │ │ │ │ ├── plugin-error-2.js
│ │ │ │ │ ├── plugin-error-3.js
│ │ │ │ │ └── plugin-error.js
│ │ │ │ ├── plugin-1.less
│ │ │ │ ├── plugin-1.txt
│ │ │ │ ├── plugin-2.less
│ │ │ │ ├── plugin-2.txt
│ │ │ │ ├── plugin-3.less
│ │ │ │ ├── plugin-3.txt
│ │ │ │ ├── property-in-root.less
│ │ │ │ ├── property-in-root.txt
│ │ │ │ ├── property-in-root2.less
│ │ │ │ ├── property-in-root2.txt
│ │ │ │ ├── property-in-root3.less
│ │ │ │ ├── property-in-root3.txt
│ │ │ │ ├── property-interp-not-defined.less
│ │ │ │ ├── property-interp-not-defined.txt
│ │ │ │ ├── property-undefined.less
│ │ │ │ ├── property-undefined.txt
│ │ │ │ ├── recursive-property.less
│ │ │ │ ├── recursive-property.txt
│ │ │ │ ├── recursive-variable.less
│ │ │ │ ├── recursive-variable.txt
│ │ │ │ ├── root-func-undefined-1.less
│ │ │ │ ├── root-func-undefined-1.txt
│ │ │ │ ├── root-func-undefined-2.less
│ │ │ │ ├── root-func-undefined-2.txt
│ │ │ │ ├── styles.config.cjs
│ │ │ │ ├── svg-gradient1.less
│ │ │ │ ├── svg-gradient1.txt
│ │ │ │ ├── svg-gradient2.less
│ │ │ │ ├── svg-gradient2.txt
│ │ │ │ ├── svg-gradient3.less
│ │ │ │ ├── svg-gradient3.txt
│ │ │ │ ├── svg-gradient4.less
│ │ │ │ ├── svg-gradient4.txt
│ │ │ │ ├── svg-gradient5.less
│ │ │ │ ├── svg-gradient5.txt
│ │ │ │ ├── svg-gradient6.less
│ │ │ │ ├── svg-gradient6.txt
│ │ │ │ ├── unit-function.less
│ │ │ │ └── unit-function.txt
│ │ │ └── parse/
│ │ │ ├── at-rules-unmatching-block.less
│ │ │ ├── at-rules-unmatching-block.txt
│ │ │ ├── bad-variable-declaration1.less
│ │ │ ├── bad-variable-declaration1.txt
│ │ │ ├── custom-property-unmatched-block-1.less
│ │ │ ├── custom-property-unmatched-block-1.txt
│ │ │ ├── custom-property-unmatched-block-2.less
│ │ │ ├── custom-property-unmatched-block-2.txt
│ │ │ ├── custom-property-unmatched-block-3.less
│ │ │ ├── custom-property-unmatched-block-3.txt
│ │ │ ├── detached-ruleset-6.less
│ │ │ ├── detached-ruleset-6.txt
│ │ │ ├── extend-not-at-end.less
│ │ │ ├── extend-not-at-end.txt
│ │ │ ├── import-malformed.less
│ │ │ ├── import-malformed.txt
│ │ │ ├── import-no-semi.less
│ │ │ ├── import-no-semi.txt
│ │ │ ├── import-subfolder2.less
│ │ │ ├── import-subfolder2.txt
│ │ │ ├── imports/
│ │ │ │ ├── import-subfolder2.less
│ │ │ │ └── subfolder/
│ │ │ │ └── parse-error-curly-bracket.less
│ │ │ ├── invalid-color-with-comment.less
│ │ │ ├── invalid-color-with-comment.txt
│ │ │ ├── mixed-mixin-definition-args-1.less
│ │ │ ├── mixed-mixin-definition-args-1.txt
│ │ │ ├── mixed-mixin-definition-args-2.less
│ │ │ ├── mixed-mixin-definition-args-2.txt
│ │ │ ├── mixins-guards-cond-expected.less
│ │ │ ├── mixins-guards-cond-expected.txt
│ │ │ ├── parens-error-1.less
│ │ │ ├── parens-error-1.txt
│ │ │ ├── parens-error-2.less
│ │ │ ├── parens-error-2.txt
│ │ │ ├── parens-error-3.less
│ │ │ ├── parens-error-3.txt
│ │ │ ├── parse-error-curly-bracket.less
│ │ │ ├── parse-error-curly-bracket.txt
│ │ │ ├── parse-error-media-no-block-1.less
│ │ │ ├── parse-error-media-no-block-1.txt
│ │ │ ├── parse-error-media-no-block-2.less
│ │ │ ├── parse-error-media-no-block-2.txt
│ │ │ ├── parse-error-media-no-block-3.less
│ │ │ ├── parse-error-media-no-block-3.txt
│ │ │ ├── parse-error-missing-bracket.less
│ │ │ ├── parse-error-missing-bracket.txt
│ │ │ ├── parse-error-missing-parens.less
│ │ │ ├── parse-error-missing-parens.txt
│ │ │ ├── parse-error-with-import.less
│ │ │ ├── parse-error-with-import.txt
│ │ │ ├── percentage-missing-space.less
│ │ │ ├── percentage-missing-space.txt
│ │ │ ├── property-asterisk-only-name.less
│ │ │ ├── property-asterisk-only-name.txt
│ │ │ ├── single-character.less
│ │ │ ├── single-character.txt
│ │ │ └── styles.config.cjs
│ │ └── tests-unit/
│ │ ├── at-rules/
│ │ │ ├── at-rules.css
│ │ │ └── at-rules.less
│ │ ├── at-rules-declarations/
│ │ │ ├── at-rules-declarations.css
│ │ │ └── at-rules-declarations.less
│ │ ├── at-rules-empty/
│ │ │ ├── at-rules-empty.css
│ │ │ └── at-rules-empty.less
│ │ ├── at-rules-empty-block/
│ │ │ ├── at-rules-empty-block.css
│ │ │ └── at-rules-empty-block.less
│ │ ├── at-rules-keyword-comments/
│ │ │ ├── at-rules-keyword-comments.css
│ │ │ └── at-rules-keyword-comments.less
│ │ ├── at-rules-targeted/
│ │ │ ├── at-rules-targeted.css
│ │ │ └── at-rules-targeted.less
│ │ ├── calc/
│ │ │ ├── calc.css
│ │ │ └── calc.less
│ │ ├── charsets/
│ │ │ ├── charsets.css
│ │ │ ├── charsets.less
│ │ │ └── import/
│ │ │ └── import-charset-test.less
│ │ ├── color-functions/
│ │ │ ├── alpha.css
│ │ │ ├── alpha.less
│ │ │ ├── basic.css
│ │ │ ├── basic.less
│ │ │ ├── comprehensive.css
│ │ │ ├── comprehensive.less
│ │ │ ├── formats.css
│ │ │ ├── formats.less
│ │ │ ├── modern-syntax.css
│ │ │ ├── modern-syntax.less
│ │ │ ├── modern.css
│ │ │ ├── modern.less
│ │ │ ├── operations.css
│ │ │ ├── operations.less
│ │ │ ├── rgba.css
│ │ │ └── rgba.less
│ │ ├── comments/
│ │ │ ├── comments.css
│ │ │ ├── comments.less
│ │ │ ├── comments2.css
│ │ │ └── comments2.less
│ │ ├── container/
│ │ │ ├── container.css
│ │ │ └── container.less
│ │ ├── css-3/
│ │ │ ├── css-3.css
│ │ │ └── css-3.less
│ │ ├── css-escapes/
│ │ │ ├── css-escapes.css
│ │ │ └── css-escapes.less
│ │ ├── css-grid/
│ │ │ ├── css-grid.css
│ │ │ └── css-grid.less
│ │ ├── css-guards/
│ │ │ ├── css-guards.css
│ │ │ └── css-guards.less
│ │ ├── detached-rulesets/
│ │ │ ├── detached-rulesets.css
│ │ │ └── detached-rulesets.less
│ │ ├── directives-bubbling/
│ │ │ ├── directives-bubbling.css
│ │ │ └── directives-bubbling.less
│ │ ├── empty/
│ │ │ ├── empty.css
│ │ │ └── empty.less
│ │ ├── extend/
│ │ │ ├── extend-clearfix.css
│ │ │ ├── extend-clearfix.less
│ │ │ ├── extend.css
│ │ │ └── extend.less
│ │ ├── extend-chaining/
│ │ │ ├── extend-chaining.css
│ │ │ └── extend-chaining.less
│ │ ├── extend-clearfix/
│ │ │ ├── extend-clearfix.css
│ │ │ └── extend-clearfix.less
│ │ ├── extend-exact/
│ │ │ ├── extend-exact.css
│ │ │ └── extend-exact.less
│ │ ├── extend-media/
│ │ │ ├── extend-media.css
│ │ │ └── extend-media.less
│ │ ├── extend-nest/
│ │ │ ├── extend-nest.css
│ │ │ └── extend-nest.less
│ │ ├── extend-selector/
│ │ │ ├── extend-selector.css
│ │ │ └── extend-selector.less
│ │ ├── extract-and-length/
│ │ │ ├── extract-and-length.css
│ │ │ └── extract-and-length.less
│ │ ├── functions/
│ │ │ ├── functions.css
│ │ │ └── functions.less
│ │ ├── functions-each/
│ │ │ ├── functions-each.css
│ │ │ └── functions-each.less
│ │ ├── ie-filters/
│ │ │ ├── ie-filters.css
│ │ │ └── ie-filters.less
│ │ ├── impor/
│ │ │ ├── impor.css
│ │ │ └── impor.less
│ │ ├── import/
│ │ │ ├── import/
│ │ │ │ ├── css-import.less
│ │ │ │ ├── deeper/
│ │ │ │ │ ├── deeper-2/
│ │ │ │ │ │ ├── url-import-2.less
│ │ │ │ │ │ └── url-import.less
│ │ │ │ │ ├── import-once-test-a.less
│ │ │ │ │ └── url-import.less
│ │ │ │ ├── import-and-relative-paths-test.less
│ │ │ │ ├── import-charset-test.less
│ │ │ │ ├── import-inline-invalid-css.less
│ │ │ │ ├── import-interpolation.less
│ │ │ │ ├── import-interpolation2.less
│ │ │ │ ├── import-once-test-c.less
│ │ │ │ ├── import-reference.less
│ │ │ │ ├── import-test-a.less
│ │ │ │ ├── import-test-b.less
│ │ │ │ ├── import-test-c.less
│ │ │ │ ├── import-test-d.css
│ │ │ │ ├── import-test-e.less
│ │ │ │ ├── import-test-f.less
│ │ │ │ ├── imports/
│ │ │ │ │ ├── font.less
│ │ │ │ │ └── logo.less
│ │ │ │ ├── interpolation-vars.less
│ │ │ │ ├── invalid-css.less
│ │ │ │ ├── json/
│ │ │ │ │ ├── index.json
│ │ │ │ │ └── index.less
│ │ │ │ ├── layer-import-2.css
│ │ │ │ ├── layer-import-3.css
│ │ │ │ ├── layer-import-4.css
│ │ │ │ ├── layer-import-5.css
│ │ │ │ ├── layer-import.less
│ │ │ │ └── urls.less
│ │ │ ├── import-inline.css
│ │ │ ├── import-inline.less
│ │ │ ├── import-interpolation.css
│ │ │ ├── import-interpolation.less
│ │ │ ├── import-module.css
│ │ │ ├── import-module.less
│ │ │ ├── import-once.css
│ │ │ ├── import-once.less
│ │ │ ├── import-reference-issues/
│ │ │ │ ├── appender-reference-1968.less
│ │ │ │ ├── comments-2991.less
│ │ │ │ ├── global-scope-import.less
│ │ │ │ ├── global-scope-nested.less
│ │ │ │ ├── mixin-1968.less
│ │ │ │ ├── multiple-import-nested.less
│ │ │ │ ├── multiple-import.less
│ │ │ │ ├── simple-mixin.css
│ │ │ │ └── simple-ruleset-2162.less
│ │ │ ├── import-reference-issues.css
│ │ │ ├── import-reference-issues.less
│ │ │ ├── import-reference.css
│ │ │ ├── import-reference.less
│ │ │ ├── import-remote.css
│ │ │ ├── import-remote.less
│ │ │ ├── import.css
│ │ │ ├── import.less
│ │ │ └── styles.config.cjs
│ │ ├── javascript/
│ │ │ ├── javascript.css
│ │ │ ├── javascript.less
│ │ │ └── styles.config.cjs
│ │ ├── layer/
│ │ │ ├── assets/
│ │ │ │ └── import/
│ │ │ │ └── layer-import.less
│ │ │ ├── import/
│ │ │ │ └── layer-import.less
│ │ │ ├── layer.css
│ │ │ └── layer.less
│ │ ├── lazy-eval/
│ │ │ ├── lazy-eval.css
│ │ │ └── lazy-eval.less
│ │ ├── media/
│ │ │ ├── media.css
│ │ │ └── media.less
│ │ ├── merge/
│ │ │ ├── merge.css
│ │ │ └── merge.less
│ │ ├── mixin-noparens/
│ │ │ ├── mixin-noparens.css
│ │ │ └── mixin-noparens.less
│ │ ├── mixins/
│ │ │ ├── maps.css
│ │ │ ├── maps.less
│ │ │ ├── mixins-advanced.css
│ │ │ ├── mixins-advanced.less
│ │ │ ├── mixins.css
│ │ │ └── mixins.less
│ │ ├── mixins-closure/
│ │ │ ├── mixins-closure.css
│ │ │ └── mixins-closure.less
│ │ ├── mixins-guards/
│ │ │ ├── mixins-guards.css
│ │ │ └── mixins-guards.less
│ │ ├── mixins-guards-default-func/
│ │ │ ├── mixins-guards-default-func.css
│ │ │ └── mixins-guards-default-func.less
│ │ ├── mixins-important/
│ │ │ ├── mixins-important.css
│ │ │ └── mixins-important.less
│ │ ├── mixins-interpolated/
│ │ │ ├── mixins-interpolated.css
│ │ │ └── mixins-interpolated.less
│ │ ├── mixins-named-args/
│ │ │ ├── mixins-named-args.css
│ │ │ └── mixins-named-args.less
│ │ ├── mixins-nested/
│ │ │ ├── mixins-nested.css
│ │ │ └── mixins-nested.less
│ │ ├── mixins-pattern/
│ │ │ ├── mixins-pattern.css
│ │ │ └── mixins-pattern.less
│ │ ├── namespace-targeted/
│ │ │ ├── namespace-targeted.css
│ │ │ └── namespace-targeted.less
│ │ ├── nesting/
│ │ │ ├── nesting.css
│ │ │ └── nesting.less
│ │ ├── no-output/
│ │ │ ├── no-output.css
│ │ │ └── no-output.less
│ │ ├── operations/
│ │ │ ├── operations-advanced.css
│ │ │ ├── operations-advanced.less
│ │ │ ├── operations.css
│ │ │ └── operations.less
│ │ ├── parse-interpolation/
│ │ │ ├── parse-interpolation.css
│ │ │ └── parse-interpolation.less
│ │ ├── parser-property-interp/
│ │ │ ├── parser-property-interp.css
│ │ │ └── parser-property-interp.less
│ │ ├── parser-slashed-combinator/
│ │ │ ├── parser-slashed-combinator.css
│ │ │ └── parser-slashed-combinator.less
│ │ ├── permissive-parse/
│ │ │ ├── permissive-parse.css
│ │ │ └── permissive-parse.less
│ │ ├── plugi/
│ │ │ ├── plugi.css
│ │ │ └── plugi.less
│ │ ├── plugin/
│ │ │ ├── plugin.css
│ │ │ └── plugin.less
│ │ ├── plugin-module/
│ │ │ ├── plugin-module.css
│ │ │ └── plugin-module.less
│ │ ├── plugin-preeval/
│ │ │ ├── plugin-preeval.css
│ │ │ └── plugin-preeval.less
│ │ ├── property-accessors/
│ │ │ ├── property-accessors.css
│ │ │ └── property-accessors.less
│ │ ├── property-name-interp/
│ │ │ ├── property-name-interp.css
│ │ │ └── property-name-interp.less
│ │ ├── property-targeted/
│ │ │ ├── property-targeted.css
│ │ │ └── property-targeted.less
│ │ ├── rulesets/
│ │ │ ├── rulesets.css
│ │ │ └── rulesets.less
│ │ ├── scope/
│ │ │ ├── scope.css
│ │ │ └── scope.less
│ │ ├── selectors/
│ │ │ ├── selectors.css
│ │ │ └── selectors.less
│ │ ├── starting-style/
│ │ │ ├── starting-style.css
│ │ │ └── starting-style.less
│ │ ├── strings/
│ │ │ ├── strings.css
│ │ │ └── strings.less
│ │ ├── styles.config.cjs
│ │ ├── tailwind/
│ │ │ ├── tailwind.css
│ │ │ └── tailwind.less
│ │ ├── urls/
│ │ │ ├── actual.css
│ │ │ ├── assets/
│ │ │ │ └── nested-gradient-with-svg-gradient/
│ │ │ │ ├── mixin-consumer.less
│ │ │ │ └── svg-gradient-mixin.less
│ │ │ ├── css/
│ │ │ │ └── background.css
│ │ │ ├── import/
│ │ │ │ ├── import-and-relative-paths-test.less
│ │ │ │ ├── import-test-d.css
│ │ │ │ └── imports/
│ │ │ │ ├── font.less
│ │ │ │ └── logo.less
│ │ │ ├── nested-gradient-with-svg-gradient/
│ │ │ │ ├── mixin-consumer.less
│ │ │ │ └── svg-gradient-mixin.less
│ │ │ ├── urls.css
│ │ │ └── urls.less
│ │ ├── variables/
│ │ │ ├── variable-advanced.css
│ │ │ ├── variable-advanced.less
│ │ │ ├── variables.css
│ │ │ └── variables.less
│ │ ├── variables-in-at-rules/
│ │ │ ├── variables-in-at-rules.css
│ │ │ └── variables-in-at-rules.less
│ │ └── whitespace/
│ │ ├── whitespace.css
│ │ └── whitespace.less
│ └── test-import-module/
│ ├── one/
│ │ ├── 1.less
│ │ └── two/
│ │ ├── 2.less
│ │ └── three/
│ │ └── 3.less
│ └── package.json
├── pnpm-workspace.yaml
└── scripts/
├── bump-and-publish.js
├── post-merge-version-fix.js
├── publish-beta.js
└── test-release-automation.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .all-contributorsrc
================================================
{
"projectName": "Less.js",
"projectOwner": "The Less CSS Team",
"repoType": "github",
"repoHost": "https://github.com/less/less.js",
"files": [
"README.md"
],
"imageSize": 100,
"commit": true,
"commitConvention": "gitmoji",
"contributors": [
{
"login": "matthew-dean",
"name": "Matthew Dean",
"avatar_url": "https://avatars.githubusercontent.com/u/414752?v=4",
"profile": "https://github.com/matthew-dean",
"contributions": [
"code",
"doc",
"maintenance",
"projectManagement"
]
},
{
"login": "cloudhead",
"name": "Alexis Sellier",
"avatar_url": "https://avatars.githubusercontent.com/u/40774?v=4",
"profile": "https://cloudhead.io/",
"contributions": [
"code",
"doc"
]
},
{
"login": "lukeapage",
"name": "Luke Page",
"avatar_url": "https://avatars.githubusercontent.com/u/309321?v=4",
"profile": "https://github.com/lukeapage",
"contributions": [
"code"
]
},
{
"login": "seven-phases-max",
"name": "Max Mikhailov",
"avatar_url": "https://avatars.githubusercontent.com/u/5304376?v=4",
"profile": "https://github.com/seven-phases-max",
"contributions": [
"code"
]
},
{
"login": "iChenLei",
"name": "Lei Chen",
"avatar_url": "https://avatars.githubusercontent.com/u/14012511?v=4",
"profile": "https://github.com/iChenLei",
"contributions": [
"code",
"bug",
"doc"
]
},
{
"login": "puckowski",
"name": "Daniel Puckowski",
"avatar_url": "https://avatars.githubusercontent.com/u/3059609?v=4",
"profile": "https://github.com/puckowski",
"contributions": [
"code",
"bug"
]
}
],
"contributorsPerLine": 7,
"linkToUsage": true
}
================================================
FILE: .coderabbit.yaml
================================================
reviews:
max_files: 200
================================================
FILE: .editorconfig
================================================
# @see http://editorconfig.org/
# the buck stops here
root = true
# all files
[*]
end_of_line = LF
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
================================================
FILE: .gitattributes
================================================
*.js text eol=lf
*.svg text eol=lf
lessc text eol=lf
*.less text eol=lf
*.css text eol=lf
*.htm text eol=lf
*.html text eol=lf
*.jpg binary
*.png binary
*.jpeg binary
# From https://github.com/alexkaratarakis/gitattributes/blob/master/Web.gitattributes
*.lock text -diff
package-lock.json text -diff
================================================
FILE: .github/ISSUE_TEMPLATE/bug.md
================================================
---
name: "\U0001F41E Bug report"
about: Something isn’t working as expected
title: ''
labels: 'bug'
assignees: ''
---
**To reproduce:**
```less
// less code here
```
**Current behavior:**
**Expected behavior:**
**Environment information:**
- `less` version:
- `nodejs` version:
- `operating system`:
================================================
FILE: .github/ISSUE_TEMPLATE/config.yml
================================================
blank_issues_enabled: false
contact_links:
- name: ✨ Feature Request / idea
url: https://github.com/less/less.js/discussions/new
about: Missing something in Less? Let us know.
- name: 💬 Question / Discussion
url: https://github.com/less/less.js/discussions/new
about: Feel free to ask anything
- name: 📖 View documentation
url: https://lesscss.org
about: Official Less documentation
- name: ❓ StackOverflow
url: https://stackoverflow.com/questions/tagged/less
about: Ask question or find answers on Stack overflow
================================================
FILE: .github/PULL_REQUEST_TEMPLATE.md
================================================
**What**:
**Why**:
**Checklist**:
- [ ] Documentation
- [ ] Added/updated unit tests
- [ ] Code complete
================================================
FILE: .github/SECURITY.md
================================================
## Security contact information
To report a security vulnerability, please use the
[Tidelift security contact](https://tidelift.com/security).
Tidelift will coordinate the fix and disclosure.
================================================
FILE: .github/TESTING_PUBLISHING.md
================================================
# Testing the Publishing Flow
This guide explains how to test the publishing workflow without actually publishing to npm.
## Dry Run Mode
The publishing script supports a dry-run mode that shows what would happen without making any changes:
```bash
# Test from master branch
git checkout master
DRY_RUN=true pnpm run publish
# Or use the flag
pnpm run publish --dry-run
```
Dry-run mode will:
- ✅ Show what version would be created
- ✅ Show what packages would be published
- ✅ Show what git operations would happen
- ❌ **NOT** commit any changes
- ❌ **NOT** create git tags
- ❌ **NOT** push to remote
- ❌ **NOT** publish to npm
## Testing Locally
### 1. Test Version Calculation
```bash
# Check current version
node -p "require('./packages/less/package.json').version"
# Run dry-run to see what version would be created
DRY_RUN=true pnpm run publish
```
### 2. Test Branch Validation
```bash
# Try from a feature branch (should fail)
git checkout -b test-branch
pnpm run publish
# Should error: "Publishing is only allowed from 'master' or 'alpha' branches"
```
### 3. Test Alpha Branch Validations
```bash
# Switch to alpha branch
git checkout alpha
# Test with dry-run
DRY_RUN=true GITHUB_REF_NAME=alpha pnpm run publish
# This will show:
# - Version validation (must contain -alpha.)
# - Master sync check
# - Version comparison with master
```
### 4. Test Version Override
```bash
# Test explicit version override
EXPLICIT_VERSION=4.5.0 DRY_RUN=true pnpm run publish
# Should show: "✨ Using explicit version: 4.5.0"
```
## Testing the GitHub Actions Workflow
### 1. Test Workflow Syntax
```bash
# Validate workflow YAML
gh workflow view publish.yml
# Or use act (local GitHub Actions runner)
act push -W .github/workflows/publish.yml
```
### 2. Test on a Test Branch
Create a test branch that mimics master/alpha:
```bash
# Create test branch from master
git checkout -b test-publish-master master
# Make a small change
echo "# test" >> TEST.md
git add TEST.md
git commit -m "test: publishing workflow"
# Push to trigger workflow (if you want to test the full flow)
# Note: This will actually try to publish if version changed!
```
### 3. Test Workflow Manually
You can manually trigger the workflow from GitHub Actions UI:
1. Go to Actions tab
2. Select "Publish to NPM" workflow
3. Click "Run workflow"
4. Select branch and run
**Warning**: This will actually publish if conditions are met!
## Testing Specific Scenarios
### Test Master Branch Publishing
```bash
git checkout master
DRY_RUN=true pnpm run publish
# Should show:
# - Patch version increment (e.g., 4.4.2 → 4.4.3)
# - Publishing with 'latest' tag
# - Regular release creation
```
### Test Alpha Branch Publishing
```bash
git checkout alpha
DRY_RUN=true GITHUB_REF_NAME=alpha pnpm run publish
# Should show:
# - Alpha version increment (e.g., 5.0.0-alpha.1 → 5.0.0-alpha.2)
# - Publishing with 'alpha' tag
# - Pre-release creation
# - All alpha validations passing
```
### Test Version Validation
```bash
# Test that alpha versions can't go to latest
# (This is enforced in the script, so it will fail before publishing)
# Test that non-alpha versions can't go to alpha tag
# (Also enforced in the script)
```
## Safe Testing Checklist
Before actually publishing:
- [ ] Run dry-run mode to verify version calculation
- [ ] Verify branch restrictions work (try from wrong branch)
- [ ] Test alpha validations (if testing alpha branch)
- [ ] Check that version override works (if needed)
- [ ] Verify package.json files would be updated correctly
- [ ] Review what git operations would happen
- [ ] Confirm npm tag assignment is correct
## Troubleshooting
### Script fails with "branch not allowed"
Make sure you're on `master` or `alpha` branch, or set `GITHUB_REF_NAME` environment variable:
```bash
GITHUB_REF_NAME=master DRY_RUN=true pnpm run publish
```
### Version calculation seems wrong
Check the current version in `packages/less/package.json`:
```bash
node -p "require('./packages/less/package.json').version"
```
### Alpha validations failing
Make sure:
- Alpha branch is up-to-date with master
- Current version contains `-alpha.`
- Alpha base version is >= master version
## Real Publishing Test (Use with Caution)
If you want to test the actual publishing flow:
1. **Use a test npm package** (create a scoped package like `@your-username/less-test`)
2. **Temporarily modify the script** to use your test package name
3. **Test on a separate branch** that won't trigger the workflow
4. **Clean up** after testing
**Never test on the actual `less` package unless you're ready to publish!**
================================================
FILE: .github/stale.yml
================================================
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 120
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 30
# Issues with these labels will never be considered stale
exemptLabels:
- up-for-grabs
- bug
- "high priority" # if it's been prioritized, don't mark stale
- "medium priority"
- "low priority"
- "needs decision"
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
================================================
FILE: .github/workflows/ci.yml
================================================
# Github actions workflow name
name: CI
# Triggers the workflow on push or pull request events
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
test:
name: 'Tests on ${{matrix.os}} with Node "${{matrix.node}}"'
strategy:
fail-fast: false
matrix:
# Test all mainstream operating systems
os: [ubuntu-latest, macos-latest, windows-latest]
node: ['current']
include:
- os: ubuntu-latest
node: 'lts/*'
- os: ubuntu-latest
node: 'lts/-1'
- os: ubuntu-latest
node: 'lts/-2'
- os: ubuntu-latest
node: 'lts/-3'
runs-on: ${{ matrix.os }}
# This has copy/paste steps and should be refactored using DRY
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Print put node & npm version
run: node --version && pnpm --version
- name: Install chromium
run: pnpm exec playwright install chromium
- name: Run node tests (ESM + CJS)
run: pnpm run test:node
================================================
FILE: .github/workflows/create-release-pr.yml
================================================
name: Create Release PR
# When code lands on master or alpha (not a release PR merge itself),
# automatically create or update a release pull request that bumps the
# version. Maintainers then merge that PR to trigger publishing.
#
# master → "chore: release vX.Y.Z" PR targets master
# alpha → "chore: alpha release vX.Y.Z" PR targets alpha
on:
push:
branches:
- master
- alpha
# Only trigger for commits that touch package source files.
paths:
- 'packages/**'
permissions:
contents: write
pull-requests: write
jobs:
create-release-pr:
name: Create or Update Release PR
runs-on: ubuntu-latest
# Skip if this push is itself the merge of a release PR (prevents an
# infinite loop). We catch both squash-merged and regular-merged commits
# for both the master and alpha release PR title conventions.
if: |
github.repository == 'less/less.js' &&
!contains(github.event.head_commit.message, 'chore: release v') &&
!contains(github.event.head_commit.message, 'chore: alpha release v') &&
!contains(github.event.head_commit.message, '/release-v') &&
!contains(github.event.head_commit.message, '/alpha-release-v')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install pnpm
uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Determine next version
id: version
run: |
BRANCH="${{ github.ref_name }}"
CURRENT=$(node -p "require('./packages/less/package.json').version")
if [ "$BRANCH" = "alpha" ]; then
# Alpha: increment the alpha prerelease number.
# X.Y.Z-alpha.N → X.Y.Z-alpha.(N+1)
# If package.json doesn't carry an alpha version yet, bump the
# major and start a fresh alpha.1 series.
NEXT=$(node -e "
const cur = process.argv[1];
const m = cur.match(/^(\d+\.\d+\.\d+)-alpha\.(\d+)$/);
if (m) {
process.stdout.write(m[1] + '-alpha.' + (parseInt(m[2], 10) + 1));
} else {
const parts = cur.replace(/-.*/, '').split('.');
const nextMajor = parseInt(parts[0], 10) + 1;
process.stdout.write(nextMajor + '.0.0-alpha.1');
}
" "$CURRENT")
echo "next_version=$NEXT" >> "$GITHUB_OUTPUT"
echo "branch=chore/alpha-release-v$NEXT" >> "$GITHUB_OUTPUT"
echo "release_base=alpha" >> "$GITHUB_OUTPUT"
else
# Master: patch-increment from the latest npm published version.
NPM_VERSION=$(npm view less version 2>/dev/null || echo "")
NEXT=$(node -e "
const semver = require('semver');
const cur = process.argv[1];
const npm = process.argv[2] || null;
if (npm && semver.valid(cur) && semver.gt(cur, npm)) {
process.stdout.write(cur);
} else {
const base = npm || cur;
process.stdout.write(semver.inc(base, 'patch'));
}
" "$CURRENT" "$NPM_VERSION")
echo "next_version=$NEXT" >> "$GITHUB_OUTPUT"
echo "branch=chore/release-v$NEXT" >> "$GITHUB_OUTPUT"
echo "release_base=master" >> "$GITHUB_OUTPUT"
fi
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Create or update release branch and PR
env:
NEXT_VERSION: ${{ steps.version.outputs.next_version }}
RELEASE_BRANCH: ${{ steps.version.outputs.branch }}
RELEASE_BASE: ${{ steps.version.outputs.release_base }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
if [ "$RELEASE_BASE" = "alpha" ]; then
TITLE="chore: alpha release v${NEXT_VERSION}"
else
TITLE="chore: release v${NEXT_VERSION}"
fi
# Create or reset the release branch off the latest base branch so it
# always includes all recent commits.
if git ls-remote --exit-code origin "refs/heads/${RELEASE_BRANCH}" &>/dev/null; then
git fetch origin "${RELEASE_BRANCH}"
git checkout -B "${RELEASE_BRANCH}" "origin/${RELEASE_BASE}"
else
git checkout -b "${RELEASE_BRANCH}"
fi
# Bump version in all package.json files.
node -e "
const fs = require('fs');
const version = process.env.NEXT_VERSION;
const dirs = fs.readdirSync('packages', { withFileTypes: true })
.filter(d => d.isDirectory())
.map(d => 'packages/' + d.name + '/package.json');
for (const f of ['package.json', ...dirs].filter(f => fs.existsSync(f))) {
const pkg = JSON.parse(fs.readFileSync(f, 'utf8'));
if (!pkg.version) continue;
pkg.version = version;
fs.writeFileSync(f, JSON.stringify(pkg, null, '\t') + '\n');
}
"
git add package.json packages/*/package.json
COMMITTED=false
if git diff --cached --quiet; then
echo "No version changes; branch is already at v${NEXT_VERSION}"
else
git commit -m "${TITLE}"
COMMITTED=true
fi
# If no new commit was created the release branch has no commits
# ahead of master, so pushing it and trying to open a PR would fail
# with "no commits between head and base". Instead, just report
# whether an existing release PR is open and exit cleanly.
if [ "$COMMITTED" = "false" ]; then
EXISTING=$(gh pr list --head "${RELEASE_BRANCH}" --base "${RELEASE_BASE}" \
--json number --jq '.[0].number' 2>/dev/null || echo "")
if [ -n "${EXISTING}" ]; then
echo "✅ No new changes; release PR #${EXISTING} already exists"
else
echo "✅ No version bump needed and no existing release PR; nothing to do"
fi
exit 0
fi
# --force-with-lease refuses to overwrite if the remote has advanced
# past what we fetched, which protects against concurrent workflow
# runs. This is intentional: if two code PRs land simultaneously the
# second run will fail-fast here and the release branch stays coherent.
git push origin "${RELEASE_BRANCH}" --force-with-lease
# Open a PR if one doesn't already exist for this version.
EXISTING=$(gh pr list --head "${RELEASE_BRANCH}" --base "${RELEASE_BASE}" \
--json number --jq '.[0].number' 2>/dev/null || echo "")
if [ -z "${EXISTING}" ]; then
BODY="## Release v${NEXT_VERSION}
This PR bumps the version to \`${NEXT_VERSION}\` and will trigger an npm publish when merged.
**Before merging:**
- [ ] Update CHANGELOG.md with changes for this release
- [ ] Verify all CI checks pass"
gh pr create \
--title "${TITLE}" \
--body "${BODY}" \
--base "${RELEASE_BASE}" \
--head "${RELEASE_BRANCH}"
echo "✅ Created release PR for v${NEXT_VERSION}"
else
echo "✅ Release PR #${EXISTING} already exists; branch updated to include latest ${RELEASE_BASE} commits"
fi
================================================
FILE: .github/workflows/publish.yml
================================================
name: Publish to NPM
on:
# Publish when a release PR is merged:
# master branch: "chore: release vX.Y.Z" PR → publishes latest
# alpha branch: "chore: alpha release vX.Y.Z" PR → publishes alpha
# Both release PRs are created automatically by create-release-pr.yml.
pull_request:
types: [closed]
branches:
- master
- alpha
permissions:
id-token: write # Required for OIDC trusted publishing
contents: write # Required for creating releases and pushing tags
jobs:
publish:
name: Publish to NPM
runs-on: ubuntu-latest
# Only run when a release PR with the expected title is merged into master
# or alpha. Any other PR close (or merge without the right title) is
# silently skipped.
if: |
github.repository == 'less/less.js' &&
github.event.pull_request.merged == true &&
(
(github.event.pull_request.base.ref == 'master' &&
startsWith(github.event.pull_request.title, 'chore: release v')) ||
(github.event.pull_request.base.ref == 'alpha' &&
startsWith(github.event.pull_request.title, 'chore: alpha release v'))
)
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
# Check out the base branch (master or alpha) post-merge so the
# version bump from the release PR is already present.
ref: ${{ github.event.pull_request.base.ref }}
- name: Install pnpm
uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run node tests (ESM + CJS)
run: pnpm run test:node
- name: Build
run: |
cd packages/less
pnpm run build
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Determine branch and tag type
id: branch-info
run: |
# Always a pull_request event; base.ref is master or alpha.
BRANCH="${{ github.event.pull_request.base.ref }}"
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
if [ "$BRANCH" = "alpha" ]; then
echo "is_alpha=true" >> $GITHUB_OUTPUT
echo "npm_tag=alpha" >> $GITHUB_OUTPUT
echo "release_type=prerelease" >> $GITHUB_OUTPUT
else
echo "is_alpha=false" >> $GITHUB_OUTPUT
echo "npm_tag=latest" >> $GITHUB_OUTPUT
echo "release_type=release" >> $GITHUB_OUTPUT
fi
- name: Validate alpha branch requirements
if: steps.branch-info.outputs.is_alpha == 'true'
run: |
# Fetch master branch
git fetch origin master:master || true
# Check 1: Alpha branch must not be behind master
echo "🔍 Checking if alpha branch is up to date with master..."
MASTER_COMMITS=$(git rev-list --count alpha..master 2>/dev/null || echo "0")
if [ "$MASTER_COMMITS" -gt 0 ]; then
echo "❌ ERROR: Alpha branch is behind master by $MASTER_COMMITS commit(s)"
echo " Alpha branch must include all commits from master before publishing"
exit 1
fi
echo "✅ Alpha branch is up to date with master"
# Check 2: Get current version and validate it contains 'alpha'
CURRENT_VERSION=$(node -p "require('./packages/less/package.json').version")
echo "📦 Current version: $CURRENT_VERSION"
if [[ ! "$CURRENT_VERSION" =~ -alpha\. ]]; then
echo "❌ ERROR: Alpha branch version must contain '-alpha.'"
echo " Current version: $CURRENT_VERSION"
echo " Expected format: X.Y.Z-alpha.N"
exit 1
fi
echo "✅ Version contains 'alpha' suffix"
# Check 3: Alpha base version must be >= master version
echo "🔍 Comparing alpha base version with master version..."
MASTER_VERSION=$(git show master:packages/less/package.json 2>/dev/null | node -p "try { JSON.parse(require('fs').readFileSync(0, 'utf-8')).version } catch(e) { '0.0.0' }" || echo "0.0.0")
if [ "$MASTER_VERSION" = "0.0.0" ]; then
echo "⚠️ Could not determine master version, skipping comparison"
else
echo "📦 Master version: $MASTER_VERSION"
# Extract base version (remove -alpha.X suffix)
ALPHA_BASE=$(echo "$CURRENT_VERSION" | sed 's/-alpha\.[0-9]*$//')
echo "📦 Alpha base version: $ALPHA_BASE"
# Compare versions using semver from root workspace
COMPARE_RESULT=$(node -e "
const semver = require('semver');
const alphaBase = process.argv[1];
const master = process.argv[2];
if (semver.lt(alphaBase, master)) {
console.log('ERROR');
} else {
console.log('OK');
}
" "$ALPHA_BASE" "$MASTER_VERSION" 2>/dev/null || echo "ERROR")
if [ "$COMPARE_RESULT" = "ERROR" ]; then
echo "❌ ERROR: Alpha base version ($ALPHA_BASE) is lower than master version ($MASTER_VERSION)"
echo " According to semver, alpha base version must be >= master version"
exit 1
fi
echo "✅ Alpha base version is >= master version"
fi
- name: Ensure npm 11.5.1 or later for trusted publishing
run: npm install -g npm@latest
- name: Bump version and publish
id: publish
env:
# Pass the resolved base branch name (master or alpha) so that
# bump-and-publish.js knows which branch it is publishing for.
GITHUB_REF_NAME: ${{ steps.branch-info.outputs.branch }}
run: |
pnpm run publish
# Extract version from package.json
VERSION=$(node -p "require('./packages/less/package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${{ steps.publish.outputs.tag }}"
VERSION="${{ steps.publish.outputs.version }}"
IS_ALPHA="${{ steps.branch-info.outputs.is_alpha }}"
if [ "$IS_ALPHA" = "true" ]; then
TITLE="Alpha Release $TAG"
PRERELEASE="--prerelease"
BODY="## Alpha Release
This is an alpha release from the alpha branch.
## Installation
\`\`\`bash
npm install less@${VERSION} --tag alpha
\`\`\`
Or:
\`\`\`bash
npm install less@alpha
\`\`\`"
else
TITLE="Release $TAG"
PRERELEASE=""
BODY="## Changes
See [CHANGELOG.md](https://github.com/less/less.js/blob/master/CHANGELOG.md) for details.
## Installation
\`\`\`bash
npm install less@${VERSION}
\`\`\`"
fi
if gh release view "$TAG" &>/dev/null; then
echo "Release $TAG already exists, uploading assets to existing release"
gh release upload "$TAG" packages/less/dist/less.js packages/less/dist/less.min.js --clobber
else
gh release create "$TAG" \
--title "$TITLE" \
$PRERELEASE \
--notes "$BODY" \
packages/less/dist/less.js \
packages/less/dist/less.min.js
fi
================================================
FILE: .gitignore
================================================
# OS and IDE
.emacs*
*.flymake
*~
.#*
.idea
*.iml
*.sublime-*
.DS_Store
# npm
node_modules
!package-lock.json
npm-debug.log
# Coverage
.nyc_output
coverage
*.lcov
# Build output
dist
# Claude Code
.claude/
================================================
FILE: .husky/post-merge
================================================
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# Post-merge hook to preserve alpha versions when merging master into alpha
node scripts/post-merge-version-fix.js
================================================
FILE: .husky/pre-commit
================================================
cd packages/less && npm run typecheck && cd ../..
pnpm test
================================================
FILE: .nvmrc
================================================
v18
================================================
FILE: .vscode/launch.json
================================================
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Less test",
"program": "${workspaceFolder}/packages/less/test/index.js",
"cwd": "${workspaceFolder}/packages/less",
"console": "integratedTerminal"
},
{
"type": "node",
"request": "launch",
"name": "Benchmark test",
"program": "${workspaceFolder}/packages/less/benchmark/index.js",
"cwd": "${workspaceFolder}/packages/less",
"console": "integratedTerminal"
}
]
}
================================================
FILE: CHANGELOG.md
================================================
## Change Log
### v4.6.0 (2026-03-09)
#### Bug Fixes
- [#4414](https://github.com/less/less.js/pull/4414) Fix pre-existing bugs in tree nodes: selector `this` binding, atrule parenting, mixin-call error propagation, container/media functionRegistry guard (@matthew-dean)
- [#4408](https://github.com/less/less.js/pull/4408) Fix [#4358](https://github.com/less/less.js/issues/4358) Resolve parent selectors in comma-separated pseudo-selector lists (@matthew-dean)
- [#4407](https://github.com/less/less.js/pull/4407) Fix [#4331](https://github.com/less/less.js/issues/4331) Exclude CSS at-rule keywords from declarationCall parsing (@matthew-dean)
- [#4389](https://github.com/less/less.js/pull/4389) Fix [#4354](https://github.com/less/less.js/issues/4354) Unknown at-rule expression commas (@puckowski)
- [#4404](https://github.com/less/less.js/pull/4404) Fix no-prototype-builtins issues in Ruleset and ToCSSVisitor (@matthew-dean)
- [#4236](https://github.com/less/less.js/pull/4236) Fix import subpath module bug (@nicolo-ribaudo)
- [#4327](https://github.com/less/less.js/pull/4327) Remove duplicate length check from expression.genCSS() (@nicolo-ribaudo)
- [#3791](https://github.com/less/less.js/pull/3791) Handle the lack of optional dependencies (@nicolo-ribaudo)
#### Features & Improvements
- [#4413](https://github.com/less/less.js/pull/4413) Add JSDoc type annotations for all tree node files (@matthew-dean)
- [#4412](https://github.com/less/less.js/pull/4412) Convert prototype-based tree nodes to ES6 classes (@matthew-dean)
- [#4411](https://github.com/less/less.js/pull/4411) Migrate to native ESM with no build step (@matthew-dean)
- [#4410](https://github.com/less/less.js/pull/4410) Optimize hot paths and fix benchmark infrastructure (@matthew-dean)
- [#4409](https://github.com/less/less.js/pull/4409) Code quality cleanup for container queries and related code (@matthew-dean)
#### Deprecation Warnings
- [#4402](https://github.com/less/less.js/pull/4402) Add deprecation warnings for features removed in Less 5.x, container query variable name fix, deprecation notice fix (@matthew-dean, @puckowski)
#### Chores
- [#4406](https://github.com/less/less.js/pull/4406) Add test for number with underscore parsing (@matthew-dean)
- [#4386](https://github.com/less/less.js/pull/4386) Update README.md copyright (@matthew-dean)
- [#3782](https://github.com/less/less.js/pull/3782) Remove phantom stuff (@nicolo-ribaudo)
- [#3702](https://github.com/less/less.js/pull/3702) Replace deprecated String.prototype.substr() (@nicolo-ribaudo)
- [#4265](https://github.com/less/less.js/pull/4265) Remove redundant return from parsers.blockRuleset() (@nicolo-ribaudo)
- [#4271](https://github.com/less/less.js/pull/4271) Remove unused parsers.entities.propertyCurly() (@nicolo-ribaudo)
### v4.5.1 (2025-12-28)
_Automated patch release — no user-facing changes._
### v4.4.2 (2025-08-27)
- [#4357](https://github.com/less/less.js/pull/4357) Migrate Less test data to use valid CSS (@matthew-dean)
- [#4363](https://github.com/less/less.js/pull/4363) Fix [#4362] no spacing regression for function (@puckowski)
### v4.4.1 (2025-07-25)
- [#4342](https://github.com/less/less.js/pull/4342) Add support for CSS scroll state container queries (@puckowski)
- [#4349](https://github.com/less/less.js/pull/4349) Fix [#4348](https://github.com/less/less.js/issues/4348) parse layer nesting syntax (@puckowski)
### v4.4.0 (2025-05-31)
- [#4337](https://github.com/less/less.js/pull/4337) Add support for layer at-rule (@puckowski)
- [#4340](https://github.com/less/less.js/pull/4340) Add support for import at-rule layer functionality (@puckowski)
- [#4346](https://github.com/less/less.js/pull/4346) Fix [#4343](https://github.com/less/less.js/issues/4343) add color operands (@puckowski)
### v4.3.0 (2025-04-04)
- [#4319](https://github.com/less/less.js/pull/4319) Add deprecation warnings to Less output during parsing and new quiet flag (@matthew-dean)
- [#4320](https://github.com/less/less.js/pull/4320) Update README.md to remove Lerna reference (@matthew-dean)
- [#4322](https://github.com/less/less.js/pull/4322) Revise Playwright install method for CI stability (@puckowski)
- [#4333](https://github.com/less/less.js/pull/4333) Add support for ```starting-style``` at rule. (@puckowski)
### v4.2.2 (2025-01-04)
- [#4290](https://github.com/less/less.js/pull/4290) Fix [#4268](https://github.com/less/less.js/issues/4268) nested pseudo-selector parsing (@puckowski)
- [#4291](https://github.com/less/less.js/pull/4291) Enhance Less.js test environment setup (#4291) (@iChenLei)
- [#4295](https://github.com/less/less.js/pull/4295) Fix [#4252](https://github.com/less/less.js/issues/4252) container queries created via mixin evaluating variables incorrectly (@puckowski)
- [#4294](https://github.com/less/less.js/pull/4294) Fix [#3737](https://github.com/less/less.js/issues/3737) allow blank variable declarationd (@puckowski)
- [#4292](https://github.com/less/less.js/pull/4292) Fix [#4258](https://github.com/less/less.js/issues/4258) variable interpolation after math (@puckowski)
- [#4293](https://github.com/less/less.js/pull/4293) Fix [#4264](https://github.com/less/less.js/issues/4264) strip line comment from expression (@puckowski)
- [#4302](https://github.com/less/less.js/pull/4302) Fix [#4301](https://github.com/less/less.js/issues/4301) at-rule declarations missing (@puckowski)
- [#4309](https://github.com/less/less.js/pull/4309) Fix Node 23 CI (#4309) (@iChenLei)
### v4.2.1 (2024-09-26)
- [#4237](https://github.com/less/less.js/pull/4237) Fix [#4235](https://github.com/less/less.js/issues/4235) container style queries extra space resolved (@puckowski)
### v4.2.0 (2023-08-06)
- [#3811](https://github.com/less/less.js/pull/3811) add support for [container queries](https://www.w3.org/TR/css-contain-3) (@puckowski)
- [#3761](https://github.com/less/less.js/pull/3761) fix faulty source map generation with variables in selectors, fixes [#3567](https://github.com/less/less.js/issues/3567) (@pgoldberg)
- [#3700](https://github.com/less/less.js/pull/3700) parsing variables fail when there is no trailing semicolon (@b-kelly)
- [#3719](https://github.com/less/less.js/pull/3719) modify `this` pointer so that it is not empty. (@lumburr)
- [#3649](https://github.com/less/less.js/pull/3649) fixes [#2991](https://github.com/less/less.js/issues/2991) empty @media queries generated when compiling less file with (reference) to bootstrap (@MoonCoral)
### v4.1.3 (2022-06-09)
- [#3673](https://github.com/less/less.js/pull/3673) Feat: add support for case-insensitive attribute selectors (#3673) (@iChenLei)
- [#3710](https://github.com/less/less.js/pull/3701) Feat: add `disablePluginRule` flag for render() options (#3710) (@broofa @edhgoose)
- [#3656](https://github.com/less/less.js/pull/3656) Fix [#3655](https://github.com/less/less.js/issues/3655) for param tag is null (#3658) (@langren1353)
- [#3658](https://github.com/less/less.js/pull/3658) Fix [#3646](https://github.com/less/less.js/issues/3656) forcefully change unsupported input to strings (#3658) (@gzb1128)
- [#3668](https://github.com/less/less.js/pull/3668) Fix change keyword plugin and import regexp (#3668) (@iChenLei)
- [#3613](https://github.com/less/less.js/pull/3613) Fix [#3591](https://github.com/less/less.js/issues/3591): refactor debugInfo from class to function (#3613) (@drdevlin)
- [#3716](https://github.com/less/less.js/pull/3716) Fix https failures on macOS (#3716) (@joeyparrish)
### v4.1.2 (2021-10-04)
- [#3602](https://github.com/less/less.js/pull/3602) Fix currentFileInfo and index properties on nodes (#3602) (@bjpbakker)
- [#3626](https://github.com/less/less.js/pull/3626) Fix [#3616](https://github.com/less/less.js/issues/3616) IfStatement requires double parentheses when dividing (#3626) (@iChenLei)
- [#3630](https://github.com/less/less.js/pull/3630) Fix needle dependency warning typo. (#3630) (@cjwilsontech)
### v4.1.1 (2021-01-31)
- [#3597](https://github.com/less/less.js/pull/3597) Fix expected response when there's a socket error (#3597) (@zxfrank)
- [#3589](https://github.com/less/less.js/pull/3589) Fixes [#3586](https://github.com/less/less.js/issues/3586) (#3589) (@matthew-dean)
### v4.1.0 (2021-01-10)
- [#3582](https://github.com/less/less.js/pull/3582) Fix [#3576](https://github.com/less/less.js/issues/3576) import redirects. Replace native-request with needle. (#3582) (@zaquest)
- [#3583](https://github.com/less/less.js/pull/3583) Update rollup and other build dependencies (#3583) (@pravi)
- [#3588](https://github.com/less/less.js/pull/3588) Roll back paren requirement on mixin calls (#3588) (@matthew-dean)
### v4.0.0 (2020-12-18)
- [#3573](https://github.com/less/less.js/pull/3573) v4.0.0 (#3573) (@matthew-dean)
### v3.13.1 (2020-12-18)
- [#3575](https://github.com/less/less.js/pull/3575) Fixes #3574 (#3575) (@matthew-dean)
### v3.13.0 (2020-12-12)
- [#3572](https://github.com/less/less.js/pull/3572) Fixes #3434 - memory / runtime improvements (#3572) (@matthew-dean)
- [#3550](https://github.com/less/less.js/pull/3550) Examples contain more valid CSS, to test with a new parser (#3550) (@matthew-dean)
- [#3546](https://github.com/less/less.js/pull/3546) Bug fixes - fixes #3446 #3368 (#3546) (@matthew-dean)
### v3.12.2 (2020-07-16)
- [#3545](https://github.com/less/less.js/pull/3545) Release 3.12.2 (#3545) (@matthew-dean)
### v3.12.1 (2020-07-16)
- [#3544](https://github.com/less/less.js/pull/3544) Fixes #3533 (#3544) (@matthew-dean)
- [#3543](https://github.com/less/less.js/pull/3543) Fixes #3541 (#3543) (@matthew-dean)
### v3.12.0 (2020-07-13)
- [#3540](https://github.com/less/less.js/pull/3540) v3.12.0-RC.2 (#3540) (@matthew-dean)
- [#3532](https://github.com/less/less.js/pull/3532) Fixes #3371 Allow conditional evaluation of function args (#3532) (@matthew-dean)
- [#3531](https://github.com/less/less.js/pull/3531) Remove lib folder from git (#3531) (@matthew-dean)
- [#3530](https://github.com/less/less.js/pull/3530) Move changelog to root (#3530) (@matthew-dean)
- [#3529](https://github.com/less/less.js/pull/3529) Duplicate dist files in root for older links (#3529) (@matthew-dean)
- [#3525](https://github.com/less/less.js/pull/3525) Test-data module (#3525) (@matthew-dean)
- [#3523](https://github.com/less/less.js/pull/3523) Fixes #3504 / organizes tests (#3523) (@matthew-dean)
- [#3501](https://github.com/less/less.js/pull/3501) Restore nuked scripts (?), replace dependencies (#3501) (#3522) (@matthew-dean)
- [#3521](https://github.com/less/less.js/pull/3521) Lerna refactor / TS compiling w/o bundling (#3521) (@matthew-dean)
- [#3517](https://github.com/less/less.js/pull/3517) Resolve #3398 Add flag to disable sourcemap url annotation (#3517) (@hirosato)
- [#3294](https://github.com/less/less.js/pull/3294) fix(#3294): use loadFileSync when loading plugins with syncImport: true (#3506) (@Justineo)
### v3.11.3 (2020-06-05)
- [#3509](https://github.com/less/less.js/pull/3509) Fixes #3508 (#3509) (@matthew-dean)
### v3.11.2 (2020-06-01)
- [#3498](https://github.com/less/less.js/pull/3498) Remove tree caching in import manager (#3498) (@matthew-dean)
- [#3482](https://github.com/less/less.js/pull/3482) issue#3481 ignore missing debugInfo (#3482) (@5UtJAjiRWj1q)
- [#3494](https://github.com/less/less.js/pull/3494) Additional check to avoid evaluating an expression if it is a comment (#3494) (@rgroothuijsen)
- [#3490](https://github.com/less/less.js/pull/3490) fix: Use make-dir instead of mkdirp (#3490) (@eps1lon)
- [#3493](https://github.com/less/less.js/pull/3493) Properly exit calc mode after use (#3493) (@rgroothuijsen)
- [#3477](https://github.com/less/less.js/pull/3477) Convert to auto-changelog (#3477) (@matthew-dean)
### v3.11.1 (2020-02-11)
- [#3475](https://github.com/less/less.js/pull/3475) Fixes #3469 - Include tslib dependency (#3475) (@matthew-dean)
### v3.11.0 (2020-02-09)
- [#3468](https://github.com/less/less.js/pull/3468) 3.11.0 (#3468) (@matthew-dean)
- [#3453](https://github.com/less/less.js/pull/3453) Import file with dots in file name (#3453) (@life777)
- [#3460](https://github.com/less/less.js/pull/3460) - Fixed replacer when visitor returns array of nodes (#3460) (@lmartorella)
- [#3454](https://github.com/less/less.js/pull/3454) Added financial contributors to the README (#3454) (@monkeywithacupcake)
- [#3431](https://github.com/less/less.js/pull/3431) Fixes #3430: Removed unnecessary 'important' from NamespaceValue. (#3431) (@batchunag)
- [#3426](https://github.com/less/less.js/pull/3426) Fixes #3405 (#3426) (@matthew-dean)
### v3.10.3 (2019-08-23)
- [#3424](https://github.com/less/less.js/pull/3424) Fixes #3423 #3420 (#3424) (@matthew-dean)
- [#3421](https://github.com/less/less.js/pull/3421) Rollup changed for Node 4 compatibility (#3421) (@matthew-dean)
### v3.10.0 (2019-08-17)
- [#3413](https://github.com/less/less.js/pull/3413) Release v3.10.0 (#3413) (@matthew-dean)
### v3.10.0-beta.2 (2019-08-07)
- [#3412](https://github.com/less/less.js/pull/3412) v3.10.0-beta.2 -- Cleanup NPM and git included files (#3412) (@matthew-dean)
### v3.10.0-beta (2019-08-03)
- [#3411](https://github.com/less/less.js/pull/3411) Conversion of Less to ES6 w/ TypeScript type linting support (#3411) (@matthew-dean)
- [#3363](https://github.com/less/less.js/pull/3363) Fixes #3346 #3338 #3345 (#3363) (@matthew-dean)
- [#3364](https://github.com/less/less.js/pull/3364) Operation.prototype.accept Issues#3327 (#3364) (@legu2009)
- [#3360](https://github.com/less/less.js/pull/3360) Ignore undefined content in generating source maps (#3360) (@cthrax)
- [#3305](https://github.com/less/less.js/pull/3305) Avoid Buffer constructor on newer Node.js (#3305) (#3307) (@gabrielschulhof)
- [#3352](https://github.com/less/less.js/pull/3352) Do not pollute window object in less-browser bootstrap (#3352) (@gaiazov)
- [#3337](https://github.com/less/less.js/pull/3337) Use the correct mime type when loading a plugin (#3337) (@g3rv4)
### v3.9.0 (2018-11-29)
- [#3334](https://github.com/less/less.js/pull/3334) Adds range() function for lists (#3334) (@matthew-dean)
- [#3333](https://github.com/less/less.js/pull/3333) Fixes #3325 #3313 #3328 - each() function fixes (#3333) (@matthew-dean)
- [#3335](https://github.com/less/less.js/pull/3335) Prevent Browserify from bundling Buffer (#3335) (@matthew-dean)
### v3.8.1 (2018-08-08)
- [#3302](https://github.com/less/less.js/pull/3302) v3.8.1 (#3302) (@matthew-dean)
- [#3301](https://github.com/less/less.js/pull/3301) Fixes: #3300 (#3301) (@matthew-dean)
- [#3292](https://github.com/less/less.js/pull/3292) Demonstrate 3.7 fixes #3160 (#3292) (@matthew-dean)
- [#3291](https://github.com/less/less.js/pull/3291) Color function updates - #RRGGBBAA and CSS Variables (#3291) (@matthew-dean)
### v3.8.0 (2018-07-23)
- [#3293](https://github.com/less/less.js/pull/3293) v3.8.0 (#3293) (@matthew-dean)
- [#3248](https://github.com/less/less.js/pull/3248) Feature/rewrite urls (#3248) (@matthew-dean)
### v3.7.1 (2018-07-11)
- [#3284](https://github.com/less/less.js/pull/3284) Release v3.7.1 (#3284) (@matthew-dean)
- [#3283](https://github.com/less/less.js/pull/3283) Fix #3281: console.warning → console.warn (#3283) (@calvinjuarez)
### v3.7.0 (2018-07-11)
- [#3279](https://github.com/less/less.js/pull/3279) v3.7.0 (#3279) (@matthew-dean)
- [#3274](https://github.com/less/less.js/pull/3274) Fixes #1880 - Adds two new math modes and deprecates strictMath (@matthew-dean)
- [#3258](https://github.com/less/less.js/pull/3258) Fixes #2824 - Expressions require a delimiter of some kind in mixin args (@matthew-dean)
- [#3263](https://github.com/less/less.js/pull/3263) Fixes #2270 - Adds each() function to Less functions (@calvinjuarez, @matthew-dean)
### v3.6.0 (2018-07-10)
- [#3278](https://github.com/less/less.js/pull/3278) v3.6.0 (@matthew-dean)
- [#3252](https://github.com/less/less.js/pull/3252) Removes `less-rhino` (broken for a long time) - Fixes #3241 (@matthew-dean)
- [#3259](https://github.com/less/less.js/pull/3259) Removes "double paren" issue for boolean / if function (@matthew-dean)
- [#3276](https://github.com/less/less.js/pull/3276) Bump Jasmine version (@matthew-dean)
- [#3275](https://github.com/less/less.js/pull/3275) Adds Promise polyfill for PhantomJS under Node 9 (@matthew-dean)
- [#3261](https://github.com/less/less.js/pull/3261) Fixes #2791 - svg-gradient() not working in Firefox (@matthew-dean)
- [#3270](https://github.com/less/less.js/pull/3270) Fixes #3231 - Adds UIKit, Bootstrap 3, and Bootstrap 4 to verified tests (@matthew-dean)
### v3.5.3 (2018-07-06)
- [#3272](https://github.com/less/less.js/pull/3272) Reverts operations not being performed in media queries (@matthew-dean)
- [#3257](https://github.com/less/less.js/pull/3257) Fixes #3182 (@matthew-dean)
### v3.5.1 (2018-07-05)
- [#3267](https://github.com/less/less.js/pull/3267) Fixes issue with parentheses following variable in expressions (@matthew-dean)
### v3.5.0 (2018-07-05)
- [#3264](https://github.com/less/less.js/pull/3264) Release v3.5.0 (@matthew-dean)
### v3.5.0-beta.7 (2018-07-04)
- [#3260](https://github.com/less/less.js/pull/3260) Release v3.5.0-beta.7 (#3260) (@matthew-dean)
- [#3256](https://github.com/less/less.js/pull/3256) Allow [] to resolve to last declaration's value (#3256) (@matthew-dean)
### v3.5.0-beta.6 (2018-07-03)
- [#3255](https://github.com/less/less.js/pull/3255) v3.5.0-beta.6 (#3255) (@matthew-dean)
- [#3247](https://github.com/less/less.js/pull/3247) Plugins: If minVersion >= 3.0.0, don't "pre-run" .setOptions() (#3247) (@calvinjuarez)
- [#3254](https://github.com/less/less.js/pull/3254) Tests and parser fixes for namespace values in MQ and mixin args (#3254) (@matthew-dean)
### v3.5.0-beta.5 (2018-07-02)
- [#3251](https://github.com/less/less.js/pull/3251) Bugfix - namespace values (#3251) (@matthew-dean)
- [#3250](https://github.com/less/less.js/pull/3250) Added small breakpoints example with namespaced values (#3250) (@matthew-dean)
### v3.5.0-beta.4 (2018-06-30)
- [#3242](https://github.com/less/less.js/pull/3242) [Feature] Namespaced values (#3242) (@matthew-dean)
- [#3246](https://github.com/less/less.js/pull/3246) Release/v3.5.0 beta.3 (#3246) (@matthew-dean)
- [#3229](https://github.com/less/less.js/pull/3229) Fixes #3187 (couldn't repo, but found bugs) (#3229) (@matthew-dean)
- [#3237](https://github.com/less/less.js/pull/3237) Fixes #3235 (#3237) (@matthew-dean)
### v3.5.0-beta.3 (2018-06-29)
- [#3239](https://github.com/less/less.js/pull/3239) fix: browser cache is always considered stale if .modifyVars wasn't set (#3239) (@balpha)
### v3.5.0-beta.2 (2018-06-27)
- [#3236](https://github.com/less/less.js/pull/3236) v3.5.0-beta.2 (#3236) (@matthew-dean)
- [#3228](https://github.com/less/less.js/pull/3228) Fixes #3205, partial 3.0 math regression #1880 (#3228) (@matthew-dean)
- [#3227](https://github.com/less/less.js/pull/3227) Fixes #1421 - re-parses variable-interpolated elements to selectors (no.2) (#3227) (@matthew-dean)
- [#3223](https://github.com/less/less.js/pull/3223) Fixes #3191 (#3223) (@matthew-dean)
### v3.5.0-beta (2018-06-25)
- [#3230](https://github.com/less/less.js/pull/3230) Release v3.5.0 beta (#3230) (@matthew-dean)
- [#3219](https://github.com/less/less.js/pull/3219) Invalidate less-node file cache if modified (#3219) (@matthew-dean)
- [#3213](https://github.com/less/less.js/pull/3213) Fixes #3147 #2715 (#3213) (@matthew-dean)
- [#3220](https://github.com/less/less.js/pull/3220) Revert "Fixes #1421 - re-parses variable-interpolated elements to selectors" (@matthew-dean)
- [#3217](https://github.com/less/less.js/pull/3217) Revert "Fixes #1421 - re-parses variable-interpolated elements to selectors (#3217)" (@matthew-dean)
- [#3212](https://github.com/less/less.js/pull/3212) Revert "Pull missed code merged into 3.x branch (#3212)" (@matthew-dean)
- [#3215](https://github.com/less/less.js/pull/3215) Revert "Fixes #3195 (#3215)" (@matthew-dean)
- [#3215](https://github.com/less/less.js/pull/3215) Fixes #3195 (#3215) (@matthew-dean)
- [#3212](https://github.com/less/less.js/pull/3212) Pull missed code merged into 3.x branch (#3212) (@matthew-dean)
- [#3217](https://github.com/less/less.js/pull/3217) Fixes #1421 - re-parses variable-interpolated elements to selectors (#3217) (@matthew-dean)
- [#3207](https://github.com/less/less.js/pull/3207) update changelog for 3.0.4 (@akkumar)
- [#3206](https://github.com/less/less.js/pull/3206) Release v3.0.4 (@matthew-dean)
### v3.0.4 (2018-05-07)
- [#3180](https://github.com/less/less.js/pull/3180) update source_map to 0.6.x (@akkumar)
- [#3172](https://github.com/less/less.js/pull/3172) Type checking length units (@jacobwarduk)
- [#3200](https://github.com/less/less.js/pull/3200) Fixes #3181 (@matthew-dean)
### v3.0.3 (2018-04-18)
- [#1](https://github.com/less/less.js/pull/1) Type checking length units (@jacobwarduk)
- [#3177](https://github.com/less/less.js/pull/3177) chore(package): update request to 2.83.0 (@Kartoffelsalat)
- [#3170](https://github.com/less/less.js/pull/3170) `inline` and `less` imports of the same name = race condition (@thorn0)
- [#3168](https://github.com/less/less.js/pull/3168) Fixes #3116 - lessc not loading plugins in 3.0 (@matthew-dean)
### v3.0.1 (2018-02-15)
- [#3163](https://github.com/less/less.js/pull/3163) Merge 3.x into master (@matthew-dean, @barnabycolby, @kirillrogovoy, @maxbrunsfeld, @seven-phases-max, @ryysud, @bdsomer, @wiinci, @nikeee, @anthony-redFox)
### v3.0.0-RC.2 (2018-02-11)
- [#3161](https://github.com/less/less.js/pull/3161) Remove legacy upgrade (@matthew-dean)
- [#3159](https://github.com/less/less.js/pull/3159) Bump to 3.0.0-RC.1 (@matthew-dean)
### v3.0.0-RC.1 (2018-02-04)
- [#3150](https://github.com/less/less.js/pull/3150) Drop node 0.10 and 0.12 and added node 9 matrix testing (@anthony-redFox)
### v2.7.3 (2017-10-24)
- [#3122](https://github.com/less/less.js/pull/3122) Mime update (@nikeee)
- [#3120](https://github.com/less/less.js/pull/3120) Issue3115 ext in node path (@robhuzzey)
- [#3119](https://github.com/less/less.js/pull/3119) Update © year (@wiinci)
- [#3107](https://github.com/less/less.js/pull/3107) pinned request dep to v2.81.0 (@MarkSG93)
### v3.0.0-alpha.3 (2017-10-09)
- [#3096](https://github.com/less/less.js/pull/3096) Switch from request to phin! (@bdsomer)
- [#3082](https://github.com/less/less.js/pull/3082) Add Node.js v8 to Travis CI and AppVeyor (@ryysud)
- [#3079](https://github.com/less/less.js/pull/3079) Initial support for custom parsed functions (`boolean`, `if` etc.) (@seven-phases-max)
- [#3076](https://github.com/less/less.js/pull/3076) Update mergeRules (@seven-phases-max)
### v2.7.2 (2017-01-05)
- [#2908](https://github.com/less/less.js/pull/2908) Added 'request' as optional dependency. (@maxrd2)
- [#2955](https://github.com/less/less.js/pull/2955) Allow less imports of paths like 'dir/css' (@maxbrunsfeld)
- [#2975](https://github.com/less/less.js/pull/2975) Refactor LessError and lesscHelper.formatError (@kirillrogovoy)
- [#2988](https://github.com/less/less.js/pull/2988) Fixes #2987, --source-map-map-inline works as expected (@nicoschoenmaker)
- [#2946](https://github.com/less/less.js/pull/2946) Fixed sourceMapBasepath bug as the option had no affect on the sourceMapURL value. (@barnabycolby)
- [#2941](https://github.com/less/less.js/pull/2941) CI Build Fixes. (@bd82)
- [#2905](https://github.com/less/less.js/pull/2905) Download PhantomJS from CDN (@abrobston)
- [#2866](https://github.com/less/less.js/pull/2866) Changed octals to hex for ES6 strict mode (@mlowijs)
- [#2891](https://github.com/less/less.js/pull/2891) Fix error reporting of lessc executable II (@jhnns)
### v2.7.0 (2016-05-08)
- [#2894](https://github.com/less/less.js/pull/2894) Update my name. (@nex3)
- [#2892](https://github.com/less/less.js/pull/2892) Fix invalid extraction of the host part from URL (@Taritsyn)
- [#2874](https://github.com/less/less.js/pull/2874) removed dependency to unused package "request" (@jeremyVignelles)
- [#2830](https://github.com/less/less.js/pull/2830) make --depends generate no CSS output (@gtalusan)
- [#2860](https://github.com/less/less.js/pull/2860) Remove unreachable code (@shkdee)
- [#2859](https://github.com/less/less.js/pull/2859) Fix typos found by codespell (@stweil)
- [#2858](https://github.com/less/less.js/pull/2858) Fix AST to include text for single line comments (@zzzzBov)
- [#2853](https://github.com/less/less.js/pull/2853) bin/lessc: Make sure path.dirname gets passed strings (@addaleax)
- [#2754](https://github.com/less/less.js/pull/2754) Update contrast function and tests, fixes #2743 (@Synchro)
- [#2785](https://github.com/less/less.js/pull/2785) Allows root (non-value) functions in Less (@seven-phases-max)
- [#2834](https://github.com/less/less.js/pull/2834) Make sourcemap generation a bit faster (@Medium)
### v2.6.1 (2016-03-04)
- [#2827](https://github.com/less/less.js/pull/2827) Revert "Update jit-grunt to version 0.10.0" (@seven-phases-max)
- [#2821](https://github.com/less/less.js/pull/2821) Update jit-grunt to version 0.10.0 (@greenkeeperio-bot)
- [#2797](https://github.com/less/less.js/pull/2797) Disallow whitespace in variable calls (i.e "DR"-calls) (@seven-phases-max)
- [#2820](https://github.com/less/less.js/pull/2820) update grunt-contrib-concat to version 1.0.0 (@greenkeeperio-bot)
- [#2819](https://github.com/less/less.js/pull/2819) Guard expressions regression in 2.6.0 (#2798) (@SomMeri)
- [#2804](https://github.com/less/less.js/pull/2804) use instanceof operator instead of class comparison optimization (@marijaselakovic)
- [#2817](https://github.com/less/less.js/pull/2817) Update grunt-contrib-jshint to version 1.0.0 🚀 (@greenkeeperio-bot)
- [#2815](https://github.com/less/less.js/pull/2815) Update grunt-contrib-clean to version 1.0.0 🚀 (@greenkeeperio-bot)
- [#2813](https://github.com/less/less.js/pull/2813) Fix typo on and/or change (@mbrodala)
- [#2811](https://github.com/less/less.js/pull/2811) Update CHANGELOG.md (@Justineo)
- [#2806](https://github.com/less/less.js/pull/2806) Fix comments after named color regression (@seven-phases-max)
- [#2794](https://github.com/less/less.js/pull/2794) Update grunt-jscs to version 2.7.0 🚀 (@greenkeeperio-bot)
- [#2784](https://github.com/less/less.js/pull/2784) Update grunt-contrib-jasmine to version 1.0.0 🚀 (@greenkeeperio-bot)
- [#2773](https://github.com/less/less.js/pull/2773) Update all dependencies 🌴 (@lukeapage, @greenkeeperio-bot)
### v2.6.0 (2016-01-29)
- [#2788](https://github.com/less/less.js/pull/2788) Update license year in README.md (@prayagverma)
- [#2735](https://github.com/less/less.js/pull/2735) Fix for #2384 and caching enabled with modifyVars set (@less)
- [#2783](https://github.com/less/less.js/pull/2783) Allow unknown non-{}-block at-rules (@seven-phases-max)
- [#2779](https://github.com/less/less.js/pull/2779) Logical operator and now has higher precedence then logical operator or. (@SomMeri)
- [#2775](https://github.com/less/less.js/pull/2775) Parsing Error "Unrecognised input" for color operations with color names #2124 (@SomMeri)
- [#2763](https://github.com/less/less.js/pull/2763) Added "or" keyword and allowed arbitrary logical expression in guards. (@SomMeri)
- [#2731](https://github.com/less/less.js/pull/2731) Faster builds and update npm versions to test against (@paladox)
- [#2759](https://github.com/less/less.js/pull/2759) Fixed extend leaking through nested parent selector. (@SomMeri)
- [#2738](https://github.com/less/less.js/pull/2738) Fail when image-size functions are used in browser-less. (@niom)
- [#2485](https://github.com/less/less.js/pull/2485) Allow underscore in a dimension unit (@seven-phases-max)
- [#2729](https://github.com/less/less.js/pull/2729) Fixing import by reference (@SomMeri)
### v2.5.2 (2015-09-24)
- [#2609](https://github.com/less/less.js/pull/2609) Skip missing optional imports (@mmelvin0)
- [#2644](https://github.com/less/less.js/pull/2644) `percentage` function should throw error if result would be `NaN` (@SomMeri)
- [#2646](https://github.com/less/less.js/pull/2646) Parametric mixins: parameters don't match error (@SomMeri)
- [#2688](https://github.com/less/less.js/pull/2688) Converted CLRFs in error tests (@mishal)
- [#2687](https://github.com/less/less.js/pull/2687) Updated test data files (@mishal)
- [#2642](https://github.com/less/less.js/pull/2642) Fixes import by reference inlines source's inline imports - 2620 (@SomMeri)
- [#2643](https://github.com/less/less.js/pull/2643) Keep shorthand color form the same way as named colors are kept. (@SomMeri)
- [#2677](https://github.com/less/less.js/pull/2677) Reference inline comments. (@betaorbust)
- [#2685](https://github.com/less/less.js/pull/2685) Update travis Node.js version & remove io.js (@demohi)
- [#2637](https://github.com/less/less.js/pull/2637) Undefined source map should result in an empty map file. (@SomMeri)
- [#2607](https://github.com/less/less.js/pull/2607) Remove moot `version` property from bower.json (@kkirsche)
### v2.5.1 (2015-05-21)
- [#2591](https://github.com/less/less.js/pull/2591) Update license attribute (@pdehaan)
- [#2575](https://github.com/less/less.js/pull/2575) Fix synchronously loading/applying stylesheets on page load. (@chipx86)
- [#2568](https://github.com/less/less.js/pull/2568) Add a Gitter chat badge to README.md (@gitter-badger)
- [#2559](https://github.com/less/less.js/pull/2559) Fix for #2558 (@seven-phases-max)
- [#2574](https://github.com/less/less.js/pull/2574) Fix `Ruleset.prototype.find` failing for certain frames (@seven-phases-max)
- [#2550](https://github.com/less/less.js/pull/2550) Update CHANGELOG.md (@chharvey)
### v2.5.0 (2015-04-03)
- [#2530](https://github.com/less/less.js/pull/2530) Proper non-primitive value replacement for `%` and `replace` (@seven-phases-max)
- [#2526](https://github.com/less/less.js/pull/2526) Image size (@bassjobsen)
- [#2533](https://github.com/less/less.js/pull/2533) Fix formatting to meet jscs settings (@seven-phases-max)
- [#2525](https://github.com/less/less.js/pull/2525) Add browser field (@whitecolor)
- [#2522](https://github.com/less/less.js/pull/2522) Fix `@plugin` scoping rules (@rjgotten)
- [#2527](https://github.com/less/less.js/pull/2527) Fix grunt shell:benchmark command (@seven-phases-max)
- [#2520](https://github.com/less/less.js/pull/2520) Fix 2440 (@lukeapage)
- [#2517](https://github.com/less/less.js/pull/2517) Quick fix for naked `url` imports (@seven-phases-max, @wahuneke, @bassjobsen)
- [#2515](https://github.com/less/less.js/pull/2515) re: #2508 - revert #2510 - undo all fixes. issue == WONTFIX (@wahuneke)
- [#2504](https://github.com/less/less.js/pull/2504) optional relative amounts for color functions, see#975 (@bassjobsen)
- [#2512](https://github.com/less/less.js/pull/2512) Fix selectors folding into directives (@rjgotten)
- [#2510](https://github.com/less/less.js/pull/2510) Fix issue 2508 (@wahuneke)
- [#2505](https://github.com/less/less.js/pull/2505) fix for issue #2500 (@bassjobsen)
- [#2479](https://github.com/less/less.js/pull/2479) Import plugin (@rjgotten, @bassjobsen)
- [#2497](https://github.com/less/less.js/pull/2497) Allow detached rulesets as mixin argument defaults (@calvinjuarez)
- [#2488](https://github.com/less/less.js/pull/2488) add jit-grunt to the build chain (@bassjobsen)
- [#2489](https://github.com/less/less.js/pull/2489) add browser postProcessor Plugin test (@bassjobsen)
- [#2473](https://github.com/less/less.js/pull/2473) Bubbling of nested directives (@SomMeri)
- [#2445](https://github.com/less/less.js/pull/2445) allow a list of colors as argument for the svg-gradient function (@bassjobsen)
### v2.4.0 (2015-02-08)
- [#2439](https://github.com/less/less.js/pull/2439) Fix empty sourcemaps (@OhJeez)
- [#2429](https://github.com/less/less.js/pull/2429) Implementing preprocessing plugins (@Justineo, @lukeapage)
- [#2427](https://github.com/less/less.js/pull/2427) Nested mixin changing important 2421 (@SomMeri)
- [#2423](https://github.com/less/less.js/pull/2423) Bug: extend doesn't work when appended on nested selector with & (@SomMeri)
- [#2420](https://github.com/less/less.js/pull/2420) endlines and comments (@bassjobsen)
### v2.3.1 (2015-01-28)
- [#2400](https://github.com/less/less.js/pull/2400) Nested parent selectors &:not(&) - 2026 (@SomMeri)
### v2.3.0 (2015-01-27)
- [#2401](https://github.com/less/less.js/pull/2401) Allow selector interpolation inside pseudoselectors. #1294 (@SomMeri)
- [#2404](https://github.com/less/less.js/pull/2404) Important on parametrized mixin (@SomMeri)
- [#2414](https://github.com/less/less.js/pull/2414) explain inline maps (@bassjobsen)
- [#2392](https://github.com/less/less.js/pull/2392) add support for `isruleset` (@Justineo)
- [#2390](https://github.com/less/less.js/pull/2390) message when sourcemap has been written (@bassjobsen)
- [#2391](https://github.com/less/less.js/pull/2391) Remove BOM in imports. (@DotNetSparky)
- [#2387](https://github.com/less/less.js/pull/2387) Data uri support for include-path (@lukeapage)
- [#2385](https://github.com/less/less.js/pull/2385) checking for doubles when warning for empty extends (@ddprrt)
- [#2380](https://github.com/less/less.js/pull/2380) Colour keyword as variable name reference (@seven-phases-max)
- [#2369](https://github.com/less/less.js/pull/2369) making sure :extend warning does not bubble up, fixes #1618 (@ddprrt)
### v2.2.0 (2015-01-04)
- [#2363](https://github.com/less/less.js/pull/2363) Change error message when caching fails (@bassjobsen)
- [#2337](https://github.com/less/less.js/pull/2337) Better output for the warning when file size exceeds (@bassjobsen)
- [#2319](https://github.com/less/less.js/pull/2319) Expose Less parsing as a top level feature of the less package (@jackwanders)
### v2.1.2 (2014-12-20)
- [#2315](https://github.com/less/less.js/pull/2315) Support non-JSON script attributes (@guybedford)
- [#2313](https://github.com/less/less.js/pull/2313) Remove second 'env:' in .travis.yml. (@vsn4ik)
### v2.1.1 (2014-11-27)
- [#2312](https://github.com/less/less.js/pull/2312) Fix double handling of exceptions (@ForbesLindesay)
- [#2311](https://github.com/less/less.js/pull/2311) Pass this from promise based calling (@ForbesLindesay)
- [#2309](https://github.com/less/less.js/pull/2309) Improve keyword and anonymous input for replace function (fixes #2308). (@seven-phases-max)
### v2.1.0 (2014-11-23)
- [#2298](https://github.com/less/less.js/pull/2298) Small improve in README.md and bower.json. (@vsn4ik)
- [#2297](https://github.com/less/less.js/pull/2297) Package: Updates request to 2.48.0 (@am11)
- [#2296](https://github.com/less/less.js/pull/2296) Fix getting of character at index (@Taritsyn)
- [#2279](https://github.com/less/less.js/pull/2279) Remove livereload cache buster param in extractId (@cgross)
### v2.0.0 (2014-11-09)
- [#2277](https://github.com/less/less.js/pull/2277) create index and browser scripts in root as require targets (@jackwanders, @lukeapage, @seven-phases-max, @Justineo, @lejenome)
- [#2269](https://github.com/less/less.js/pull/2269) Fix for wrong check in abstractFileManager.getPath (@dexif, @lukeapage, @seven-phases-max, @Justineo, @lejenome)
- [#2267](https://github.com/less/less.js/pull/2267) CLI: Fixes source-map-url description (#2264) (@am11)
- [#2268](https://github.com/less/less.js/pull/2268) typo fixes (@vlajos)
- [#2264](https://github.com/less/less.js/pull/2264) CLI: Fixes source-map-url description. (#2264) (@am11)
### v2.0.0-b3 (2014-11-01)
- [#2254](https://github.com/less/less.js/pull/2254) Fix for import relative path for url with parameters (@dexif)
### v2.0.0-b2 (2014-10-26)
- [#2246](https://github.com/less/less.js/pull/2246) Attempt to fix import sequencing (@lukeapage)
- [#2247](https://github.com/less/less.js/pull/2247) Add support for rebeccapurple (#663399) (@le717)
- [#663399](https://github.com/less/less.js/pull/663399) Add rebeccapurple (#663399) (Triangle717)
- [#2243](https://github.com/less/less.js/pull/2243) Support reading less options from its script tag data attributes (@lejenome)
- [#2241](https://github.com/less/less.js/pull/2241) Update CHANGELOG.md (@Justineo)
### v2.0.0-b1 (2014-10-19)
- [#1902](https://github.com/less/less.js/pull/1902) 2.0.0 Pull Request (@lukeapage, @seven-phases-max, @XhmikosR, @levithomason)
- [#2233](https://github.com/less/less.js/pull/2233) Method to scan for and register stylesheets (@levithomason)
- [#2226](https://github.com/less/less.js/pull/2226) Notify when less.js is done processing (@levithomason)
- [#2209](https://github.com/less/less.js/pull/2209) Remove unnecessary semicolon (@joscha)
- [#2217](https://github.com/less/less.js/pull/2217) Fix interpolated selector match regression (@seven-phases-max)
- [#2185](https://github.com/less/less.js/pull/2185) Use SVGs for all readme badges (@theodorejb)
- [#2182](https://github.com/less/less.js/pull/2182) Fixes #1973 (@seven-phases-max)
- [#2181](https://github.com/less/less.js/pull/2181) Case insensitive units parsing and comparison (@lukeapage)
### v1.7.5 (2014-09-03)
- [#2173](https://github.com/less/less.js/pull/2173) Property interpolation fix for `@*` values (@seven-phases-max)
- [#2169](https://github.com/less/less.js/pull/2169) Accept comments in @keyframe and after rule name - merging for next patch release. (@SomMeri)
- [#1921](https://github.com/less/less.js/pull/1921) Pass options object to parser.parse in less.render (@rback)
- [#2136](https://github.com/less/less.js/pull/2136) Fragment handling in data-uri function 1959 (@SomMeri)
- [#2135](https://github.com/less/less.js/pull/2135) Charsets should float on top #2126 (@SomMeri)
- [#2128](https://github.com/less/less.js/pull/2128) Mixin wrongly called (@SomMeri, @obecker, @dhaber)
- [#2144](https://github.com/less/less.js/pull/2144) Updating request dependency (@pdehaan)
- [#2123](https://github.com/less/less.js/pull/2123) Import into media 1645 (@SomMeri, @obecker, @dhaber)
### v1.7.4 (2014-07-27)
- [#2100](https://github.com/less/less.js/pull/2100) Update bower for 1.7.3 (@joscha)
- [#2121](https://github.com/less/less.js/pull/2121) Properties merging should work also inside directives #2035 (@SomMeri)
- [#2120](https://github.com/less/less.js/pull/2120) Misleading error message 2069 (@SomMeri, @obecker, @dhaber)
- [#2117](https://github.com/less/less.js/pull/2117) Fix ordering of @import and @charset rules #1954 #2013 (@SomMeri)
### v1.7.3 (2014-06-22)
- [#2062](https://github.com/less/less.js/pull/2062) Don't round values returned by colour query functions. (@seven-phases-max)
### v1.7.2 (2014-06-22)
- [#2045](https://github.com/less/less.js/pull/2045) Base64 encode source maps (@tim-smart)
### v1.7.1 (2014-06-08)
- [#2022](https://github.com/less/less.js/pull/2022) 2.0.0 refactor chunker and less error (@ForbesLindesay)
- [#2021](https://github.com/less/less.js/pull/2021) 2.0.0 promises (@ForbesLindesay)
- [#1976](https://github.com/less/less.js/pull/1976) Added condition to check if HEX code contain only valid characters (issue #1015) (@peruginni)
- [#2019](https://github.com/less/less.js/pull/2019) Remove the "done" message displayed at the end of the compilation with Rhino. (@gdelhumeau)
- [#2031](https://github.com/less/less.js/pull/2031) Fix a bug: if the less file end line is comments, the lessc command option "modify-var" will have no effect. (@chenboxiang)
- [#2046](https://github.com/less/less.js/pull/2046) window.ActiveXObject in IE11: fix boolean casting (@dkrnl)
- [#2016](https://github.com/less/less.js/pull/2016) e("") fix (@seven-phases-max)
- [#2000](https://github.com/less/less.js/pull/2000) Set CSS text after style element is added to DOM, to fix crash on IE < 9... (@David-Hari)
- [#2002](https://github.com/less/less.js/pull/2002) Fixes #2001 (@seven-phases-max)
- [#1981](https://github.com/less/less.js/pull/1981) fix bug with ../.. paths joining (@kolipka)
- [#1974](https://github.com/less/less.js/pull/1974) Change paths determination for CLI (@dominicbarnes)
- [#1929](https://github.com/less/less.js/pull/1929) Recursive mixin calls regression fix. (@seven-phases-max)
- [#1936](https://github.com/less/less.js/pull/1936) Fix error message when using cleancss with sourcemap (@danielchatfield)
- [#1919](https://github.com/less/less.js/pull/1919) Usage info for url-args option (@bcluca)
- [#1907](https://github.com/less/less.js/pull/1907) Remove trailing spaces from the license header. (@XhmikosR)
- [#1906](https://github.com/less/less.js/pull/1906) Remove twitter-bootstrap tag from SO link (@zlatanvasovic)
### v1.7.0 (2014-02-27)
- [#1890](https://github.com/less/less.js/pull/1890) Let `luma` follow spec (@seven-phases-max, @lukeapage)
- [#1859](https://github.com/less/less.js/pull/1859) detached rulesets (@lukeapage)
- [#1884](https://github.com/less/less.js/pull/1884) Minor `replace` and `%` funcs improvement. (@seven-phases-max)
- [#1855](https://github.com/less/less.js/pull/1855) Adding replace function (@jakebellacera, @mouyang)
- [#1866](https://github.com/less/less.js/pull/1866) Fixed empty args matching for named variadics. (@seven-phases-max)
- [#1860](https://github.com/less/less.js/pull/1860) Support for variables in certain at-rules. (@seven-phases-max)
- [#1847](https://github.com/less/less.js/pull/1847) Property merge with `+_` (replaces #1788) (@seven-phases-max, @mouyang)
### v1.6.3 (2014-02-08)
- [#1844](https://github.com/less/less.js/pull/1844) fix broken test case (@mouyang)
### v1.6.2 (2014-02-02)
- [#1841](https://github.com/less/less.js/pull/1841) Improved missing `(` and `{` error detection. (@seven-phases-max)
- [#1828](https://github.com/less/less.js/pull/1828) Updates bower.json for current version (@ruyadorno)
- [#1823](https://github.com/less/less.js/pull/1823) Improved multiple `default()` guards conflict detection. (@seven-phases-max)
- [#1822](https://github.com/less/less.js/pull/1822) Normalize require-calls for Browserify (@pateketrueke)
- [#1814](https://github.com/less/less.js/pull/1814) Rounding of output numbers. (@seven-phases-max)
- [#1806](https://github.com/less/less.js/pull/1806) rhino version not up to date (#1405) (@obecker, @dhaber)
- [#1815](https://github.com/less/less.js/pull/1815) Correct arguments for tree.Element (@oyejorge)
- [#16](https://github.com/less/less.js/pull/16) Don't lint source-map since its owned by another project (@dhaber)
- [#17](https://github.com/less/less.js/pull/17) Fix empty test (@dhaber)
- [#1803](https://github.com/less/less.js/pull/1803) ability to insert uppercase color names (@wareczek)
- [#1804](https://github.com/less/less.js/pull/1804) small compatibility fix for prototype.js (@cettox)
- [#13](https://github.com/less/less.js/pull/13) Add Support-Map Tests for Rhino (@dhaber)
- [#12](https://github.com/less/less.js/pull/12) Fix for some tests that were failing on my Mac (@dhaber)
- [#11](https://github.com/less/less.js/pull/11) Fix for issue #3: Tests should automatically take latest rhino file (@dhaber)
### v1.6.1 (2014-01-12)
- [#1780](https://github.com/less/less.js/pull/1780) #1778 standardised using starting index, to fix incorrectly mapped sourcemaps (@brenmar)
- [#1797](https://github.com/less/less.js/pull/1797) Updated .jshintrc to highlight for ... in without isOwnProperty (@DHainzl)
- [#1795](https://github.com/less/less.js/pull/1795) Fix for running test cases in a regular browser like Firefox or Chrome (@dhaber)
- [#1773](https://github.com/less/less.js/pull/1773) Fixes "function" test against regular expressions (@matthew-dean)
### v1.6.0 (2014-01-01)
- [#1737](https://github.com/less/less.js/pull/1737) Clamped rgba format color output (@seven-phases-max)
- [#1769](https://github.com/less/less.js/pull/1769) If result of evaluated javascript is a number return it as Dimension. (@lesswtf)
- [#1766](https://github.com/less/less.js/pull/1766) Improved error message for undefined variable in js eval statement. (@seven-phases-max)
- [#1758](https://github.com/less/less.js/pull/1758) Removed redundant code from tree.Selector.match() (@seven-phases-max)
- [#1757](https://github.com/less/less.js/pull/1757) Tree functions cleanup + CSS Guards `default` error. (@seven-phases-max)
- [#1624](https://github.com/less/less.js/pull/1624) Experimental support for mixins with interpolated selectors (@seven-phases-max)
- [#1743](https://github.com/less/less.js/pull/1743) Interleaved property merge fix (@seven-phases-max)
- [#1744](https://github.com/less/less.js/pull/1744) Fix CHANGELOG broken link in README. (@jeffslofish)
- [#1733](https://github.com/less/less.js/pull/1733) Remove alpha from contrast calc (@Synchro)
- [#1704](https://github.com/less/less.js/pull/1704) Color blending functions with transparency. (@seven-phases-max)
- [#1708](https://github.com/less/less.js/pull/1708) Updated Readme for full examples (@SomMeri, @Synchro)
- [#1717](https://github.com/less/less.js/pull/1717) Minifier complains about annotation in non-JSDoc tag (@joscha)
- [#1714](https://github.com/less/less.js/pull/1714) Fix for math expr/ops error messages line/column numbers. (@seven-phases-max)
### v1.5.1 (2013-11-17)
- [#1658](https://github.com/less/less.js/pull/1658) Fixes #1619 (@joshuaspence)
- [#1643](https://github.com/less/less.js/pull/1643) Check location.port for truthiness (@matthewp)
- [#1655](https://github.com/less/less.js/pull/1655) Support specifying custom variables when calling lessc and less.js. (@chipx86)
- [#1628](https://github.com/less/less.js/pull/1628) update bower.json main script (@tomfuertes)
### v1.5.0 (2013-10-21)
- [#1570](https://github.com/less/less.js/pull/1570) proposed solution to #1568: percentage as attribute (@MSamman, @danielfttorres)
- [#1572](https://github.com/less/less.js/pull/1572) util.error is deprecated (@robocoder)
- [#1542](https://github.com/less/less.js/pull/1542) Added `length` function (#1542). Added scalar value handling for `extract` and `length` (#1576). (@seven-phases-max)
- [#1558](https://github.com/less/less.js/pull/1558) Bower package: purge unnecessary files (@danielfttorres)
### v1.5.0-b3 (2013-09-17)
- [#1552](https://github.com/less/less.js/pull/1552) Replace deprecated sys.puts with console.log, resolve #1529 (@picomancer)
- [#1543](https://github.com/less/less.js/pull/1543) Sourcemap basepath option (@andjo)
- [#1412](https://github.com/less/less.js/pull/1412) Allow imports from self-signed SSL hosts (@christopherobin)
### v1.5.0-b2 (2013-09-09)
- [#1537](https://github.com/less/less.js/pull/1537) Fix Changelog link (@radium-v)
### v1.5.0-b1 (2013-09-03)
- [#1519](https://github.com/less/less.js/pull/1519) Update main property value of bower.json (@JacopKane)
- [#1](https://github.com/less/less.js/pull/1) Refactoring browser unit tests into grunt-contrib-jasmine (@SomMeri)
- [#1449](https://github.com/less/less.js/pull/1449) resolves #964 (@jonschlinkert)
### v1.4.2 (2013-07-20)
- [#1425](https://github.com/less/less.js/pull/1425) Windows path fixes (@SLaks)
- [#1388](https://github.com/less/less.js/pull/1388) Add .gitattributes to .npmignore (@dpatti)
### v1.4.0-b3 (2013-04-30)
- [#1278](https://github.com/less/less.js/pull/1278) Better fix for local path (cross-platform) (@losnir)
- [#1277](https://github.com/less/less.js/pull/1277) contributing.md updates. Fellow nerds! please wrap words with `@` signs in backticks! (@jonschlinkert)
- [#1273](https://github.com/less/less.js/pull/1273) Fix for local paths (@losnir)
- [#1244](https://github.com/less/less.js/pull/1244) Add Less license to package.json (@theoreticaLee)
- [#1236](https://github.com/less/less.js/pull/1236) Fixes small typo in command prompt usage text (@buley)
### v1.4.0-b2 (2013-03-18)
- [#1230](https://github.com/less/less.js/pull/1230) package.json edited (@jonschlinkert)
### v1.4.0-b1 (2013-03-08)
- [#1197](https://github.com/less/less.js/pull/1197) Updates copyright year in README.md (@Starefossen)
- [#1148](https://github.com/less/less.js/pull/1148) Better implementation of luma (@Synchro)
- [#1147](https://github.com/less/less.js/pull/1147) HSV support for #1143 (@Synchro)
- [#1145](https://github.com/less/less.js/pull/1145) Contrast percentage fix for #1144 (@Synchro)
- [#933](https://github.com/less/less.js/pull/933) Allow flexible naming for amd support (#933) (@guybedford)
### v1.3.1 (2012-10-18)
- [#889](https://github.com/less/less.js/pull/889) Add dppx and dpcm units to parser dimensions (@feelepxyz)
- [#890](https://github.com/less/less.js/pull/890) Add vmin unit to parser dimensions (@feelepxyz)
- [#879](https://github.com/less/less.js/pull/879) Allow numbers and underscores in attribute selectors (@dmcass)
- [#857](https://github.com/less/less.js/pull/857) Revert adding "transparent" as a color name (@clmsnskr)
- [#753](https://github.com/less/less.js/pull/753) Adding "dpi" as a valid dimensions for media queries (@clarkni5)
- [#800](https://github.com/less/less.js/pull/800) Added 'transparent' as a named color (@SpadarShut)
- [#804](https://github.com/less/less.js/pull/804) Fix for unnamed parameters test fail & failing test for import-once (@jreading)
- [#796](https://github.com/less/less.js/pull/796) fixed issue #795 (@comfuture)
- [#268](https://github.com/less/less.js/pull/268) Implemented named arguments (@jamesfoster)
### v1.3.0 (2012-03-10)
- [#673](https://github.com/less/less.js/pull/673) mocha found a couple global variable leaks. Here's the fix. (@andrewjstone)
- [#634](https://github.com/less/less.js/pull/634) Add @media bubbling/nesting/merging (@NDMarcel)
- [#631](https://github.com/less/less.js/pull/631) Fixed spelling error on benchmark/less-benchmark.js (@highergroundstudio)
- [#601](https://github.com/less/less.js/pull/601) Make parse error handler more robust (@adrianheine)
- [#595](https://github.com/less/less.js/pull/595) Fix callback called two times (@hokaccha, @cloudhead, @chrizel, @fat)
- [#604](https://github.com/less/less.js/pull/604) Fixes #602 (@treshugart)
- [#585](https://github.com/less/less.js/pull/585) newline all selectors whose combined length is greater than 25 chars (@fat)
- [#479](https://github.com/less/less.js/pull/479) CommonJS/AMD module support (@tobias104)
- [#516](https://github.com/less/less.js/pull/516) Improve Windows path support in lessc (@chrizel)
- [#557](https://github.com/less/less.js/pull/557) Fix for issue #466 (@kmchugh)
- [#515](https://github.com/less/less.js/pull/515) Shift the type setting in order to work with Webkit, and fix typo for IE (@imcotton)
- [#527](https://github.com/less/less.js/pull/527) Add function `percentage` (@hokaccha)
### 1.1.5-extend_patch (2011-12-13)
- [#496](https://github.com/less/less.js/pull/496) Removed call to put header into minified build, because it's already there. (@freeeve)
- [#379](https://github.com/less/less.js/pull/379) Accept 2xx statuses even for file requests (@khalsah)
- [#494](https://github.com/less/less.js/pull/494) Adding support for absolute paths on Windows. (@jmcclell)
- [#514](https://github.com/less/less.js/pull/514) Fix java.io.FileNotFoundException when @importing from LESS in subdirectory (@eager)
- [#461](https://github.com/less/less.js/pull/461) require 'util' instead of 'sys' in lessc and less-benchmark.js (@dmcass)
- [#506](https://github.com/less/less.js/pull/506) Issue #393 Add support for "rem" dimensions (@feelepxyz)
- [#507](https://github.com/less/less.js/pull/507) Fixed lessc require('sys') for nodejs 0.6.* (@garth)
- [#492](https://github.com/less/less.js/pull/492) fix comments in operations (ex: *height: 2px * 4 /* ie hack */) (@fat)
- [#458](https://github.com/less/less.js/pull/458) Assignment entities (@fat, @cloudhead, @asolove)
### 1.1.4-lastest (2011-11-14)
- [#445](https://github.com/less/less.js/pull/445) fix undefined reference (@asolove)
- [#450](https://github.com/less/less.js/pull/450) store index on selector element objects for line number inference (@fat)
- [#432](https://github.com/less/less.js/pull/432) #361: Fix for quoted data URIs getting prepended with path (@asolove)
- [#388](https://github.com/less/less.js/pull/388) Rhino support (@erwan)
- [#355](https://github.com/less/less.js/pull/355) support imports with querystrings (google fonts) fix #265 (@revolunet)
- [#340](https://github.com/less/less.js/pull/340) Read less-content from stdin (@snorkypie)
- [#341](https://github.com/less/less.js/pull/341) patch for Issue 322 (@ttfkam)
- [#335](https://github.com/less/less.js/pull/335) update ARGB support, fix IE9 style injection (@ttfkam)
- [#229](https://github.com/less/less.js/pull/229) add fade() function (@bennyschudel)
- [#347](https://github.com/less/less.js/pull/347) support @-moz-keyframes. (@idris)
- [#169](https://github.com/less/less.js/pull/169) (fix) including .less files via absolute path with IE7 (@ldaley)
- [#189](https://github.com/less/less.js/pull/189) Google Chrome(Chromium) support for extensions (@dz0ny)
- [#247](https://github.com/less/less.js/pull/247) New "escape" function (@gilt)
- [#134](https://github.com/less/less.js/pull/134) Fixed issue (#134) where subfiles' @imports were regarding #, ? and url portions thereafter as part of the base url. (@dbergey)
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing to Less.js
Thank you for your interest in contributing to Less.js! Contributions come in many forms—fixing bugs, improving code quality, enhancing tooling, updating documentation, and occasionally adding new features. This guide will help you get started.
## Getting Started
Before you begin, please note: **Words that begin with the at sign (`@`) must be wrapped in backticks!** This prevents unintended notifications to GitHub users. For example, use `` `@username` `` instead of `@username`.
GitHub has many great markdown features—[learn more about them here](https://help.github.com/articles/github-flavored-markdown).
## Reporting Issues
We welcome bug reports and feature requests! To help us help you, please follow these guidelines:
1. **Search for existing issues first.** Many issues have already been reported or resolved. Checking first saves everyone time.
2. **Create an isolated and reproducible test case.** Include [reduced test cases](http://css-tricks.com/reduced-test-cases/) that demonstrate the problem clearly.
3. **Test with the latest version.** Many issues are resolved in newer versions—please update first.
4. **Include examples with source code.** You can use [Less Preview](http://lesscss.org/less-preview/) to create a short test case.
5. **Share as much information as possible.** Include:
- Operating system and version
- How you're using Less (browser, command line, build tool, etc.)
- Browser and version (if applicable)
- Version of Less.js you're using
- Clear steps to reproduce the issue
6. **Suggest solutions if you have them.** If you know how to fix it, share your approach or submit a pull request!
Please report documentation issues in [the documentation project](https://github.com/less/less-docs).
## Feature Requests
When suggesting features:
* **Search existing feature requests first** to see if something similar already exists. Many features are already planned or under consideration.
* **Include a clear and specific use-case.** Help us understand the practical need and how it would be used.
* **Consider alternatives.** Sometimes a function or a 3rd-party build system might be a better fit than a core language feature.
**Note:** Most helpful contributions to Less.js are organizational—addressing bugs, improving code quality, enhancing tooling, and updating documentation. The language features are generally stable, even if not all planned features have been implemented yet.
## Pull Requests
Pull requests are welcome! Here's how to make them go smoothly:
* **For new features, start with a feature request** to get feedback and see how your idea is received.
* **If your PR solves an existing issue**, but approaches it differently, please create a new issue first and discuss it with core contributors. This helps avoid wasted effort.
* The `dist/` folder is gitignored—builds happen automatically during releases.
* **Please add tests** for your work. Run tests using `pnpm test`, which runs both Node.js and browser (Headless Chrome) tests.
### Coding Standards
* Always use spaces, never tabs
* End lines with semicolons
* Aim for ESLint standards
## Developing
If you want to work on an issue, add a comment saying you're taking it on—this helps prevent duplicate work.
Learn more about [developing Less.js](http://lesscss.org/usage/#developing-less).
## Releases
Releases are fully automated! Here's how it works:
### Automated Publishing
When code is pushed to specific branches, GitHub Actions automatically:
1. **Runs tests and builds** the project
2. **Bumps the version** automatically
3. **Publishes to npm** with the appropriate tag
4. **Creates a GitHub release**
### Release Branches
- **`master` branch**:
- Publishes regular releases (e.g., `4.4.2` → `4.4.3`)
- Published to npm with `latest` tag
- Creates regular GitHub releases
- Version auto-increments by patch unless explicitly set
- **`alpha` branch**:
- Publishes alpha releases (e.g., `5.0.0-alpha.1` → `5.0.0-alpha.2`)
- Published to npm with `alpha` tag
- Creates GitHub pre-releases
- Version auto-increments alpha suffix
### How to Publish
**For patch releases (automatic):**
1. Merge your PR into `master`
2. The workflow compares `package.json` against the latest npm version
3. If `package.json` is ahead, it uses that version; otherwise it bumps to the next patch
4. Publishes to npm and creates a GitHub release with `less.js` and `less.min.js` attached
**For minor/major releases:**
1. Create a release branch (e.g., `release/v4.7.0`)
2. Update `version` in all `package.json` files and update `CHANGELOG.md`
3. Merge into `master`
4. The workflow detects the version is ahead of npm and publishes it directly
**For alpha releases:**
1. Make your changes on the `alpha` branch
2. Commit and push
3. The workflow automatically increments the alpha version and publishes
### Version Override
To force a specific version (useful for CI or manual runs), set the `EXPLICIT_VERSION` environment variable:
```bash
EXPLICIT_VERSION=4.7.0 pnpm run publish
```
### Release Assets
Each GitHub release automatically includes:
- `less.js` — the full browser build
- `less.min.js` — the minified browser build
These are built during the workflow and attached to the release. They are not committed to git (the `dist/` directory is gitignored).
### Security
We use npm's [trusted publishing](https://docs.npmjs.com/trusted-publishers) with OIDC authentication. This means:
- No long-lived tokens needed
- Automatic provenance generation
- Enhanced security through short-lived, workflow-specific credentials
The publishing workflow (`.github/workflows/publish.yml`) handles both release types automatically.
### Important Notes
- Publishing only works from `master` or `alpha` branches
- Alpha versions must contain `-alpha.` and are published to the `alpha` tag
- Regular versions are published to the `latest` tag
- Alpha branch must be up-to-date with master before publishing
- Alpha base version must be >= master version (semver)
### Merging Master into Alpha
When merging `master` into `alpha`, the version in `package.json` might be overwritten. We have two layers of protection:
1. **Post-merge git hook** (automatic): Automatically restores alpha versions after merges
- Installed automatically via husky when you run `pnpm install`
- Runs automatically after `git merge`
- Restores and increments the alpha version if it was overwritten
- Prompts you to commit the restored version
2. **Publishing script detection** (safety net): The publishing script also detects overwritten versions
- Searches git history for the last alpha version
- Restores and increments it (e.g., if it was `5.0.0-alpha.3`, it becomes `5.0.0-alpha.4`)
- Updates all package.json files accordingly
**Note**: The git hook is managed by husky and installs automatically. The publishing script protection works as a backup even if the hook isn't installed.
---
Thank you for contributing to Less.js!
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
================================================
FILE: README.md
================================================
This is the Less.js monorepo.
## More information
For general information on the language, configuration options or usage visit [lesscss.org](http://lesscss.org).
Here are other resources for using Less.js:
* [stackoverflow.com][so] is a great place to get answers about Less.
* [Less.js Issues][issues] for reporting bugs
## Contributing
Please read [CONTRIBUTING.md](CONTRIBUTING.md). Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com).
### Reporting Issues
Before opening any issue, please search for existing issues and read the [Issue Guidelines](https://github.com/necolas/issue-guidelines), written by [Nicolas Gallagher](https://github.com/necolas). After that if you find a bug or would like to make feature request, [please open a new issue][issues].
Please report documentation issues in [the documentation project](https://github.com/less/less-docs).
### Development
Read [Developing Less](http://lesscss.org/usage/#developing-less).
## Release History
See the [changelog](CHANGELOG.md)
## Contributors
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
## [License](LICENSE)
Copyright (c) 2009-2025 [Alexis Sellier](http://cloudhead.io) & The Core Less Team
Licensed under the [Apache License](LICENSE).
[so]: http://stackoverflow.com/questions/tagged/less "StackOverflow.com"
[issues]: https://github.com/less/less.js/issues "GitHub Issues for Less.js"
[download]: https://github.com/less/less.js/zipball/master "Download Less.js"
================================================
FILE: package-lock.json
================================================
{
"name": "@less/root",
"version": "4.6.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@less/root",
"version": "4.6.3",
"hasInstallScript": true,
"license": "Apache-2.0",
"devDependencies": {
"all-contributors-cli": "~6.26.1",
"github-changes": "^1.1.2",
"husky": "~9.1.7",
"npm-run-all": "^4.1.5",
"playwright": "1.50.1",
"semver": "^6.3.1"
}
},
"node_modules/@babel/runtime": {
"version": "7.28.6",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.6.tgz",
"integrity": "sha512-05WQkdpL9COIMz4LjTxGpPNCdlpyimKppYNoJ5Di5EUObifl8t4tuLuUBBZEpoLYOmfvIWrsp9fCl0HoPRVTdA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/all-contributors-cli": {
"version": "6.26.1",
"resolved": "https://registry.npmjs.org/all-contributors-cli/-/all-contributors-cli-6.26.1.tgz",
"integrity": "sha512-Ymgo3FJACRBEd1eE653FD1J/+uD0kqpUNYfr9zNC1Qby0LgbhDBzB3EF6uvkAbYpycStkk41J+0oo37Lc02yEw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.6",
"async": "^3.1.0",
"chalk": "^4.0.0",
"didyoumean": "^1.2.1",
"inquirer": "^7.3.3",
"json-fixer": "^1.6.8",
"lodash": "^4.11.2",
"node-fetch": "^2.6.0",
"pify": "^5.0.0",
"yargs": "^15.0.1"
},
"bin": {
"all-contributors": "dist/cli.js"
},
"engines": {
"node": ">=4"
},
"optionalDependencies": {
"prettier": "^2"
}
},
"node_modules/ansi-escapes": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz",
"integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"type-fest": "^0.21.3"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"license": "MIT",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/application-config": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/application-config/-/application-config-0.1.2.tgz",
"integrity": "sha512-Ryjni0MtYYW9Qz2iTIMF5B/4uRJV3dt5f7PYgQ7sjTh3BUf4EvOo83F84Z2//2HP+mUbwRw35/W1jhM5EZhk9Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"application-config-path": "^0.1.0",
"mkdirp": "^0.5.1"
}
},
"node_modules/application-config-path": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/application-config-path/-/application-config-path-0.1.1.tgz",
"integrity": "sha512-zy9cHePtMP0YhwG+CfHm0bgwdnga2X3gZexpdCwEj//dpb+TKajtiC8REEUJUSq6Ab4f9cgNy2l8ObXzCXFkEw==",
"dev": true,
"license": "MIT"
},
"node_modules/array-buffer-byte-length": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.2.tgz",
"integrity": "sha512-LHE+8BuR7RYGDKvnrmcuSq3tDcKv9OFEXQt/HpbZhY7V6h0zlUXutnAD82GiFx9rdieCMjkvtcsPqBwgUl1Iiw==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.3",
"is-array-buffer": "^3.0.5"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/arraybuffer.prototype.slice": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.4.tgz",
"integrity": "sha512-BNoCY6SXXPQ7gF2opIP4GBE+Xw7U+pHMYKuzjgCN3GwiaIR09UUeKfheyIry77QtrCBlC0KK0q5/TER/tYh3PQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"array-buffer-byte-length": "^1.0.1",
"call-bind": "^1.0.8",
"define-properties": "^1.2.1",
"es-abstract": "^1.23.5",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.6",
"is-array-buffer": "^3.0.4"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/asn1": {
"version": "0.1.11",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz",
"integrity": "sha512-Fh9zh3G2mZ8qM/kwsiKwL2U2FmXxVsboP4x1mXjnhKHv3SmzaBZoYvxEQJz/YS2gnCgd8xlAVWcZnQyC9qZBsA==",
"dev": true,
"engines": {
"node": ">=0.4.9"
}
},
"node_modules/assert-plus": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.5.tgz",
"integrity": "sha512-brU24g7ryhRwGCI2y+1dGQmQXiZF7TtIj583S96y0jjdajIe6wn8BuXyELYhvD22dtIxDQVFk04YTJwwdwOYJw==",
"dev": true,
"engines": {
"node": ">=0.8"
}
},
"node_modules/async": {
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz",
"integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==",
"dev": true,
"license": "MIT"
},
"node_modules/async-function": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/async-function/-/async-function-1.0.0.tgz",
"integrity": "sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/available-typed-arrays": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz",
"integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"possible-typed-array-names": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/aws-sign": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/aws-sign/-/aws-sign-0.3.0.tgz",
"integrity": "sha512-pEMJAknifcXqXqYVXzGPIu8mJvxtJxIdpVpAs8HNS+paT+9srRUDMQn+3hULS7WbLmttcmvgMvnDcFujqXJyPw==",
"dev": true,
"engines": {
"node": "*"
}
},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"dev": true,
"license": "MIT"
},
"node_modules/bl": {
"version": "0.9.5",
"resolved": "https://registry.npmjs.org/bl/-/bl-0.9.5.tgz",
"integrity": "sha512-njlCs8XLBIK7LCChTWfzWuIAxkpmmLXcL7/igCofFT1B039Sz0IPnAmosN5QaO22lU4qr8LcUz2ojUlE6pLkRQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"readable-stream": "~1.0.26"
}
},
"node_modules/bluebird": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-1.0.3.tgz",
"integrity": "sha512-97HxegERaUQxXTDVTITyt7QuXEapf5uVXPVXKg6UjPvFC3N46KGvg/obSNZQbekkDbZlzxppDdTjAxel7WSXaA==",
"dev": true,
"license": "MIT"
},
"node_modules/boom": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/boom/-/boom-0.4.2.tgz",
"integrity": "sha512-OvfN8y1oAxxphzkl2SnCS+ztV/uVKTATtgLjWYg/7KwcNyf3rzpHxNQJZCKtsZd4+MteKczhWbSjtEX4bGgU9g==",
"deprecated": "This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).",
"dev": true,
"dependencies": {
"hoek": "0.9.x"
},
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/boom/node_modules/hoek": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/hoek/-/hoek-0.9.1.tgz",
"integrity": "sha512-ZZ6eGyzGjyMTmpSPYVECXy9uNfqBR7x5CavhUaLOeD6W0vWK1mp/b7O3f86XE0Mtfo9rZ6Bh3fnuw9Xr8MF9zA==",
"deprecated": "This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).",
"dev": true,
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/brace-expansion": {
"version": "1.1.12",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz",
"integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==",
"dev": true,
"license": "MIT",
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"node_modules/call-bind": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz",
"integrity": "sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.0",
"es-define-property": "^1.0.0",
"get-intrinsic": "^1.2.4",
"set-function-length": "^1.2.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/call-bind-apply-helpers": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/call-bound": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"get-intrinsic": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/camelcase": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/chardet": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz",
"integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==",
"dev": true,
"license": "MIT"
},
"node_modules/cli-cursor": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz",
"integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==",
"dev": true,
"license": "MIT",
"dependencies": {
"restore-cursor": "^3.1.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/cli-width": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz",
"integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==",
"dev": true,
"license": "ISC",
"engines": {
"node": ">= 10"
}
},
"node_modules/cliui": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",
"integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",
"dev": true,
"license": "ISC",
"dependencies": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^6.2.0"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true,
"license": "MIT"
},
"node_modules/colors": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/colors/-/colors-0.5.1.tgz",
"integrity": "sha512-XjsuUwpDeY98+yz959OlUK6m7mLBM+1MEG5oaenfuQnNnrQk1WvtcvFgN3FNDP3f2NmZ211t0mNEfSEN1h0eIg==",
"dev": true,
"engines": {
"node": ">=0.1.90"
}
},
"node_modules/combined-stream": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.7.tgz",
"integrity": "sha512-qfexlmLp9MyrkajQVyjEDb0Vj+KhRgR/rxLiVhaihlT+ZkX0lReqtH6Ack40CvMDERR4b5eFp3CreskpBs1Pig==",
"dev": true,
"dependencies": {
"delayed-stream": "0.0.5"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
"dev": true,
"license": "MIT"
},
"node_modules/cookie-jar": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/cookie-jar/-/cookie-jar-0.3.0.tgz",
"integrity": "sha512-dX1400pzPULr+ZovkIsDEqe7XH8xCAYGT5Dege4Eot44Qs2mS2iJmnh45TxTO5MIsCfrV/JGZVloLhm46AHxNw==",
"dev": true,
"engines": {
"node": "*"
}
},
"node_modules/core-util-is": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",
"dev": true,
"license": "MIT"
},
"node_modules/cross-spawn": {
"version": "6.0.6",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.6.tgz",
"integrity": "sha512-VqCUuhcd1iB+dsv8gxPttb5iZh/D0iubSP21g36KXdEuf6I5JiioesUVjpCdHV9MZRUfVFlvwtIUyPfxo5trtw==",
"dev": true,
"license": "MIT",
"dependencies": {
"nice-try": "^1.0.4",
"path-key": "^2.0.1",
"semver": "^5.5.0",
"shebang-command": "^1.2.0",
"which": "^1.2.9"
},
"engines": {
"node": ">=4.8"
}
},
"node_modules/cross-spawn/node_modules/semver": {
"version": "5.7.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz",
"integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==",
"dev": true,
"license": "ISC",
"bin": {
"semver": "bin/semver"
}
},
"node_modules/cryptiles": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-0.2.2.tgz",
"integrity": "sha512-gvWSbgqP+569DdslUiCelxIv3IYK5Lgmq1UrRnk+s1WxQOQ16j3GPDcjdtgL5Au65DU/xQi6q3xPtf5Kta+3IQ==",
"deprecated": "This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).",
"dev": true,
"dependencies": {
"boom": "0.4.x"
},
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/ctype": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/ctype/-/ctype-0.5.3.tgz",
"integrity": "sha512-T6CEkoSV4q50zW3TlTHMbzy1E5+zlnNcY+yb7tWVYlTwPhx9LpnfAkd4wecpWknDyptp4k97LUZeInlf6jdzBg==",
"dev": true,
"engines": {
"node": ">= 0.4"
}
},
"node_modules/data-view-buffer": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.2.tgz",
"integrity": "sha512-EmKO5V3OLXh1rtK2wgXRansaK1/mtVdTUEiEI0W8RkvgT05kfxaH29PliLnpLP73yYO6142Q72QNa8Wx/A5CqQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.3",
"es-errors": "^1.3.0",
"is-data-view": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/data-view-byte-length": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/data-view-byte-length/-/data-view-byte-length-1.0.2.tgz",
"integrity": "sha512-tuhGbE6CfTM9+5ANGf+oQb72Ky/0+s3xKUpHvShfiz2RxMFgFPjsXuRLBVMtvMs15awe45SRb83D6wH4ew6wlQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.3",
"es-errors": "^1.3.0",
"is-data-view": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/inspect-js"
}
},
"node_modules/data-view-byte-offset": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/data-view-byte-offset/-/data-view-byte-offset-1.0.1.tgz",
"integrity": "sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"is-data-view": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/decamelize": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/define-data-property": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
"integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
"dev": true,
"license": "MIT",
"dependencies": {
"es-define-property": "^1.0.0",
"es-errors": "^1.3.0",
"gopd": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/define-properties": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz",
"integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==",
"dev": true,
"license": "MIT",
"dependencies": {
"define-data-property": "^1.0.1",
"has-property-descriptors": "^1.0.0",
"object-keys": "^1.1.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/delayed-stream": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz",
"integrity": "sha512-v+7uBd1pqe5YtgPacIIbZ8HuHeLFVNe4mUEyFDXL6KiqzEykjbw+5mXZXpGFgNVasdL4jWKgaKIXrEHiynN1LA==",
"dev": true,
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/didyoumean": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz",
"integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==",
"dev": true,
"license": "Apache-2.0"
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.1",
"es-errors": "^1.3.0",
"gopd": "^1.2.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/duplexer2": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz",
"integrity": "sha512-+AWBwjGadtksxjOQSFDhPNQbed7icNXApT4+2BNpsXzcCBiInq2H9XW0O8sfHFaPmnQRs7cg/P0fAr2IWQSW0g==",
"dev": true,
"license": "BSD",
"dependencies": {
"readable-stream": "~1.1.9"
}
},
"node_modules/duplexer2/node_modules/readable-stream": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"dev": true,
"license": "MIT"
},
"node_modules/error-ex": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.4.tgz",
"integrity": "sha512-sqQamAnR14VgCr1A618A3sGrygcpK+HEbenA/HiEAkkUwcZIIB/tgWqHFxWgOyDh4nB4JCRimh79dR5Ywc9MDQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"is-arrayish": "^0.2.1"
}
},
"node_modules/es-abstract": {
"version": "1.24.1",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.24.1.tgz",
"integrity": "sha512-zHXBLhP+QehSSbsS9Pt23Gg964240DPd6QCf8WpkqEXxQ7fhdZzYsocOr5u7apWonsS5EjZDmTF+/slGMyasvw==",
"dev": true,
"license": "MIT",
"dependencies": {
"array-buffer-byte-length": "^1.0.2",
"arraybuffer.prototype.slice": "^1.0.4",
"available-typed-arrays": "^1.0.7",
"call-bind": "^1.0.8",
"call-bound": "^1.0.4",
"data-view-buffer": "^1.0.2",
"data-view-byte-length": "^1.0.2",
"data-view-byte-offset": "^1.0.1",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.1.1",
"es-set-tostringtag": "^2.1.0",
"es-to-primitive": "^1.3.0",
"function.prototype.name": "^1.1.8",
"get-intrinsic": "^1.3.0",
"get-proto": "^1.0.1",
"get-symbol-description": "^1.1.0",
"globalthis": "^1.0.4",
"gopd": "^1.2.0",
"has-property-descriptors": "^1.0.2",
"has-proto": "^1.2.0",
"has-symbols": "^1.1.0",
"hasown": "^2.0.2",
"internal-slot": "^1.1.0",
"is-array-buffer": "^3.0.5",
"is-callable": "^1.2.7",
"is-data-view": "^1.0.2",
"is-negative-zero": "^2.0.3",
"is-regex": "^1.2.1",
"is-set": "^2.0.3",
"is-shared-array-buffer": "^1.0.4",
"is-string": "^1.1.1",
"is-typed-array": "^1.1.15",
"is-weakref": "^1.1.1",
"math-intrinsics": "^1.1.0",
"object-inspect": "^1.13.4",
"object-keys": "^1.1.1",
"object.assign": "^4.1.7",
"own-keys": "^1.0.1",
"regexp.prototype.flags": "^1.5.4",
"safe-array-concat": "^1.1.3",
"safe-push-apply": "^1.0.0",
"safe-regex-test": "^1.1.0",
"set-proto": "^1.0.0",
"stop-iteration-iterator": "^1.1.0",
"string.prototype.trim": "^1.2.10",
"string.prototype.trimend": "^1.0.9",
"string.prototype.trimstart": "^1.0.8",
"typed-array-buffer": "^1.0.3",
"typed-array-byte-length": "^1.0.3",
"typed-array-byte-offset": "^1.0.4",
"typed-array-length": "^1.0.7",
"unbox-primitive": "^1.1.0",
"which-typed-array": "^1.1.19"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-object-atoms": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
"dev": true,
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-set-tostringtag": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
"integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
"dev": true,
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.6",
"has-tostringtag": "^1.0.2",
"hasown": "^2.0.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-to-primitive": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.3.0.tgz",
"integrity": "sha512-w+5mJ3GuFL+NjVtJlvydShqE1eN3h3PbI7/5LAsYJP/2qtuMXjfL2LpHSRqo4b4eSF5K/DH1JXKUAHSB2UW50g==",
"dev": true,
"license": "MIT",
"dependencies": {
"is-callable": "^1.2.7",
"is-date-object": "^1.0.5",
"is-symbol": "^1.0.4"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/external-editor": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz",
"integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==",
"dev": true,
"license": "MIT",
"dependencies": {
"chardet": "^0.7.0",
"iconv-lite": "^0.4.24",
"tmp": "^0.0.33"
},
"engines": {
"node": ">=4"
}
},
"node_modules/figures": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz",
"integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==",
"dev": true,
"license": "MIT",
"dependencies": {
"escape-string-regexp": "^1.0.5"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"dev": true,
"license": "MIT",
"dependencies": {
"locate-path": "^5.0.0",
"path-exists": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/for-each": {
"version": "0.3.5",
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz",
"integrity": "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==",
"dev": true,
"license": "MIT",
"dependencies": {
"is-callable": "^1.2.7"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/foreach": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.6.tgz",
"integrity": "sha512-k6GAGDyqLe9JaebCsFCoudPPWfihKu8pylYXRlqP1J7ms39iPoTtk2fviNglIeQEwdh0bQeKJ01ZPyuyQvKzwg==",
"dev": true,
"license": "MIT"
},
"node_modules/forever-agent": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.5.2.tgz",
"integrity": "sha512-PDG5Ef0Dob/JsZUxUltJOhm/Y9mlteAE+46y3M9RBz/Rd3QVENJ75aGRhN56yekTUboaBIkd8KVWX2NjF6+91A==",
"dev": true,
"engines": {
"node": "*"
}
},
"node_modules/form-data": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-0.0.8.tgz",
"integrity": "sha512-yzpBIhe8Ll+dYTXjd+4ORxbQktke+abD0dJjedvqsVVayMkb+PgLGatJNLwo95Va75l3YDZ01SrouzyW9bC2Fg==",
"dev": true,
"dependencies": {
"async": "~0.2.7",
"combined-stream": "~0.0.4",
"mime": "~1.2.2"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/form-data/node_modules/async": {
"version": "0.2.10",
"resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz",
"integrity": "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==",
"dev": true
},
"node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"dev": true,
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/function.prototype.name": {
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.8.tgz",
"integrity": "sha512-e5iwyodOHhbMr/yNrc7fDYG4qlbIvI5gajyzPnb5TCwyhjApznQh1BMFou9b30SevY43gCJKXycoCBjMbsuW0Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bind": "^1.0.8",
"call-bound": "^1.0.3",
"define-properties": "^1.2.1",
"functions-have-names": "^1.2.3",
"hasown": "^2.0.2",
"is-callable": "^1.2.7"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/functions-have-names": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz",
"integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==",
"dev": true,
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/generator-function": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/generator-function/-/generator-function-2.0.1.tgz",
"integrity": "sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/get-caller-file": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
"dev": true,
"license": "ISC",
"engines": {
"node": "6.* || 8.* || >= 10.*"
}
},
"node_modules/get-intrinsic": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.1.1",
"function-bind": "^1.1.2",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"has-symbols": "^1.1.0",
"hasown": "^2.0.2",
"math-intrinsics": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
"dev": true,
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/get-symbol-description": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.1.0.tgz",
"integrity": "sha512-w9UMqWwJxHNOvoNzSJ2oPF5wvYcvP7jUvYzhp67yEhTi17ZDBBC1z9pTdGuzjD+EFIqLSYRweZjqfiPzQ06Ebg==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.3",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.6"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/ghauth": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/ghauth/-/ghauth-3.0.0.tgz",
"integrity": "sha512-Ds/q5leXoYu8e+MUJyI1C2mqcvdQ4iTzoOM2WN/p9sh/Z0r609dPUq7mLNa0CoGeKdmesyUmVJOAJeWxQ3tcag==",
"dev": true,
"license": "MIT",
"dependencies": {
"application-config": "~0.1.1",
"bl": "~0.9.4",
"hyperquest": "~1.2.0",
"mkdirp": "~0.5.0",
"read": "~1.0.5",
"xtend": "~4.0.0"
}
},
"node_modules/github": {
"version": "0.1.16",
"resolved": "https://registry.npmjs.org/github/-/github-0.1.16.tgz",
"integrity": "sha512-IVtcAhrb2HsThCNs1MTPuntLk6C1km0Q4A+md/FD/00SgyyJc4+2XsG1UsF2SUM7enumAgP5VKGVqzyyUmuNCw==",
"deprecated": "'github' has been renamed to '@octokit/rest' (https://git.io/vNB11)",
"dev": true
},
"node_modules/github-changes": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/github-changes/-/github-changes-1.1.2.tgz",
"integrity": "sha512-S4lzHQHyPSyHm22JjE+Vsyr8/d797NPmYYpBqwfkPj9qHIbSwENoqKngyfGbaVbmPFTeE6QMgDbcX12TWy+fpg==",
"dev": true,
"license": "MIT",
"dependencies": {
"bluebird": "1.0.3",
"ghauth": "3.0.0",
"github": "0.1.16",
"github-commit-stream": "0.1.0",
"lodash": "2.4.1",
"moment-timezone": "0.5.5",
"nomnom": "1.6.2",
"parse-link-header": "0.1.0",
"semver": "5.4.1"
},
"bin": {
"github-changes": "bin/index.js"
}
},
"node_modules/github-changes/node_modules/lodash": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-2.4.1.tgz",
"integrity": "sha512-qa6QqjA9jJB4AYw+NpD2GI4dzHL6Mv0hL+By6iIul4Ce0C1refrjZJmcGvWdnLUwl4LIPtvzje3UQfGH+nCEsQ==",
"dev": true,
"engines": [
"node",
"rhino"
],
"license": "MIT"
},
"node_modules/github-changes/node_modules/semver": {
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz",
"integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==",
"dev": true,
"license": "ISC",
"bin": {
"semver": "bin/semver"
}
},
"node_modules/github-commit-stream": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/github-commit-stream/-/github-commit-stream-0.1.0.tgz",
"integrity": "sha512-rWmtBtoK/yViLU7VfxXzLCY9aW/cipSGzUz3TE0wNRcHEPxDjI26gFtkRV+lLhJ69cr+MR+NvFUT+MVPZRXLCw==",
"dev": true,
"license": "MIT",
"dependencies": {
"async": "~0.2.9",
"parse-link-header": "~0.1.0",
"request": "~2.22.0",
"through": "~2.3.4"
}
},
"node_modules/github-commit-stream/node_modules/async": {
"version": "0.2.10",
"resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz",
"integrity": "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==",
"dev": true
},
"node_modules/globalthis": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz",
"integrity": "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"define-properties": "^1.2.1",
"gopd": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/graceful-fs": {
"version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
"dev": true,
"license": "ISC"
},
"node_modules/has-bigints": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.1.0.tgz",
"integrity": "sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/has-property-descriptors": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
"integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
"dev": true,
"license": "MIT",
"dependencies": {
"es-define-property": "^1.0.0"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-proto": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.2.0.tgz",
"integrity": "sha512-KIL7eQPfHQRC8+XluaIw7BHUwwqL19bQn4hzNgdr+1wXoU0KKj6rufu47lhY7KbJR2C6T6+PfyN0Ea7wkSS+qQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-tostringtag": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz",
"integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
"dev": true,
"license": "MIT",
"dependencies": {
"has-symbols": "^1.0.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/hawk": {
"version": "0.13.1",
"resolved": "https://registry.npmjs.org/hawk/-/hawk-0.13.1.tgz",
"integrity": "sha512-f/1H9bruKJfgLN2KFd+666ILQvJYsJcxaCoIdHaaD2zgl7RUa08/202pGJXhOmQ1kTEdMTSxPnbCsu4l6JARhQ==",
"deprecated": "This module moved to @hapi/hawk. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.",
"dev": true,
"dependencies": {
"boom": "0.4.x",
"cryptiles": "0.2.x",
"hoek": "0.8.x",
"sntp": "0.2.x"
},
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/hoek": {
"version": "0.8.5",
"resolved": "https://registry.npmjs.org/hoek/-/hoek-0.8.5.tgz",
"integrity": "sha512-NoKdeYUBOlQ7j9dgvT9BEX90rE6HtDkaMFwR6hfOj26LA2Mwyg5026jOpNBhmNrWIGdPnbBK3sQJI3POwh8wqg==",
"deprecated": "This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).",
"dev": true,
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/hosted-git-info": {
"version": "2.8.9",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
"integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==",
"dev": true,
"license": "ISC"
},
"node_modules/http-signature": {
"version": "0.10.1",
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-0.10.1.tgz",
"integrity": "sha512-coK8uR5rq2IMj+Hen+sKPA5ldgbCc1/spPdKCL1Fw6h+D0s/2LzMcRK0Cqufs1h0ryx/niwBHGFu8HC3hwU+lA==",
"dev": true,
"license": "MIT",
"dependencies": {
"asn1": "0.1.11",
"assert-plus": "^0.1.5",
"ctype": "0.5.3"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/husky": {
"version": "9.1.7",
"resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz",
"integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==",
"dev": true,
"license": "MIT",
"bin": {
"husky": "bin.js"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/typicode"
}
},
"node_modules/hyperquest": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/hyperquest/-/hyperquest-1.2.0.tgz",
"integrity": "sha512-N6QwIYr/ENmsE3+0aNA/x8M+jHF0wedvc9ZiGAhg7KK6TxwtJTSR95b0invqaLFPqUrsngYUrc4LVmLtrl7kvw==",
"dev": true,
"license": "MIT",
"dependencies": {
"duplexer2": "~0.0.2",
"through2": "~0.6.3"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"dev": true,
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/indexof": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz",
"integrity": "sha512-i0G7hLJ1z0DE8dsqJa2rycj9dBmNKgXBvotXtZYXakU9oivfB9Uj2ZBC27qqef2U58/ZLwalxa1X/RDCdkHtVg==",
"dev": true
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"dev": true,
"license": "ISC"
},
"node_modules/inquirer": {
"version": "7.3.3",
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.3.3.tgz",
"integrity": "sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-escapes": "^4.2.1",
"chalk": "^4.1.0",
"cli-cursor": "^3.1.0",
"cli-width": "^3.0.0",
"external-editor": "^3.0.3",
"figures": "^3.0.0",
"lodash": "^4.17.19",
"mute-stream": "0.0.8",
"run-async": "^2.4.0",
"rxjs": "^6.6.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0",
"through": "^2.3.6"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/internal-slot": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.1.0.tgz",
"integrity": "sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw==",
"dev": true,
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"hasown": "^2.0.2",
"side-channel": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/is": {
"version": "0.2.7",
"resolved": "https://registry.npmjs.org/is/-/is-0.2.7.tgz",
"integrity": "sha512-ajQCouIvkcSnl2iRdK70Jug9mohIHVX9uKpoWnl115ov0R5mzBvRrXxrnHbsA+8AdwCwc/sfw7HXmd4I5EJBdQ==",
"dev": true,
"engines": {
"node": "*"
}
},
"node_modules/is-array-buffer": {
"version": "3.0.5",
"resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz",
"integrity": "sha512-DDfANUiiG2wC1qawP66qlTugJeL5HyzMpfr8lLK+jMQirGzNod0B12cFB/9q838Ru27sBwfw78/rdoU7RERz6A==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bind": "^1.0.8",
"call-bound": "^1.0.3",
"get-intrinsic": "^1.2.6"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-arrayish": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz",
"integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==",
"dev": true,
"license": "MIT"
},
"node_modules/is-async-function": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-async-function/-/is-async-function-2.1.1.tgz",
"integrity": "sha512-9dgM/cZBnNvjzaMYHVoxxfPj2QXt22Ev7SuuPrs+xav0ukGB0S6d4ydZdEiM48kLx5kDV+QBPrpVnFyefL8kkQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"async-function": "^1.0.0",
"call-bound": "^1.0.3",
"get-proto": "^1.0.1",
"has-tostringtag": "^1.0.2",
"safe-regex-test": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-bigint": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.1.0.tgz",
"integrity": "sha512-n4ZT37wG78iz03xPRKJrHTdZbe3IicyucEtdRsV5yglwc3GyUfbAfpSeD0FJ41NbUNSt5wbhqfp1fS+BgnvDFQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"has-bigints": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-boolean-object": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.2.2.tgz",
"integrity": "sha512-wa56o2/ElJMYqjCjGkXri7it5FbebW5usLw/nPmCMs5DeZ7eziSYZhSmPRn0txqeW4LnAmQQU7FgqLpsEFKM4A==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.3",
"has-tostringtag": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-callable": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz",
"integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-core-module": {
"version": "2.16.1",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz",
"integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==",
"dev": true,
"license": "MIT",
"dependencies": {
"hasown": "^2.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-data-view": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-data-view/-/is-data-view-1.0.2.tgz",
"integrity": "sha512-RKtWF8pGmS87i2D6gqQu/l7EYRlVdfzemCJN/P3UOs//x1QE7mfhvzHIApBTRf7axvT6DMGwSwBXYCT0nfB9xw==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"get-intrinsic": "^1.2.6",
"is-typed-array": "^1.1.13"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-date-object": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.1.0.tgz",
"integrity": "sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"has-tostringtag": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-finalizationregistry": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/is-finalizationregistry/-/is-finalizationregistry-1.1.1.tgz",
"integrity": "sha512-1pC6N8qWJbWoPtEjgcL2xyhQOP491EQjeUo3qTKcmV8YSDDJrOepfG8pcC7h/QgnQHYSv0mJ3Z/ZWxmatVrysg==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-fullwidth-code-point": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/is-generator-function": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.1.2.tgz",
"integrity": "sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.4",
"generator-function": "^2.0.0",
"get-proto": "^1.0.1",
"has-tostringtag": "^1.0.2",
"safe-regex-test": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-map": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.3.tgz",
"integrity": "sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-negative-zero": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.3.tgz",
"integrity": "sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-number-object": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.1.1.tgz",
"integrity": "sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.3",
"has-tostringtag": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-object": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/is-object/-/is-object-0.1.2.tgz",
"integrity": "sha512-GkfZZlIZtpkFrqyAXPQSRBMsaHAw+CgoKe2HXAkjd/sfoI9+hS8PT4wg2rJxdQyUKr7N2vHJbg7/jQtE5l5vBQ==",
"dev": true
},
"node_modules/is-regex": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz",
"integrity": "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"gopd": "^1.2.0",
"has-tostringtag": "^1.0.2",
"hasown": "^2.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-set": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.3.tgz",
"integrity": "sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-shared-array-buffer": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.4.tgz",
"integrity": "sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-string": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/is-string/-/is-string-1.1.1.tgz",
"integrity": "sha512-BtEeSsoaQjlSPBemMQIrY1MY0uM6vnS1g5fmufYOtnxLGUZM2178PKbhsk7Ffv58IX+ZtcvoGwccYsh0PglkAA==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.3",
"has-tostringtag": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-symbol": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.1.1.tgz",
"integrity": "sha512-9gGx6GTtCQM73BgmHQXfDmLtfjjTUDSyoxTCbp5WtoixAhfgsDirWIcVQ/IHpvI5Vgd5i/J5F7B9cN/WlVbC/w==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"has-symbols": "^1.1.0",
"safe-regex-test": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-typed-array": {
"version": "1.1.15",
"resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.15.tgz",
"integrity": "sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"which-typed-array": "^1.1.16"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-weakmap": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.2.tgz",
"integrity": "sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-weakref": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.1.1.tgz",
"integrity": "sha512-6i9mGWSlqzNMEqpCp93KwRS1uUOodk2OJ6b+sq7ZPDSy2WuI5NFIxp/254TytR8ftefexkWn5xNiHUNpPOfSew==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-weakset": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.4.tgz",
"integrity": "sha512-mfcwb6IzQyOKTs84CQMrOwW4gQcaTOAWJ0zzJCl2WSPDrWk/OzDaImWFH3djXhb24g4eudZfLRozAvPGw4d9hQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.3",
"get-intrinsic": "^1.2.6"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==",
"dev": true,
"license": "MIT"
},
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
"dev": true,
"license": "ISC"
},
"node_modules/json-fixer": {
"version": "1.6.15",
"resolved": "https://registry.npmjs.org/json-fixer/-/json-fixer-1.6.15.tgz",
"integrity": "sha512-TuDuZ5KrgyjoCIppdPXBMqiGfota55+odM+j2cQ5rt/XKyKmqGB3Whz1F8SN8+60yYGy/Nu5lbRZ+rx8kBIvBw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.18.9",
"chalk": "^4.1.2",
"pegjs": "^0.10.0"
},
"engines": {
"node": ">=10"
}
},
"node_modules/json-parse-better-errors": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz",
"integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==",
"dev": true,
"license": "MIT"
},
"node_modules/json-stringify-safe": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-4.0.0.tgz",
"integrity": "sha512-qzEpz1SDUb9xvA+LDOkNgjekdV7tuC7zDQf14sqMBtujh8kVbQhF11VWm4DeR99yFNjVSjTTfKa40c9ZQOtwXA==",
"dev": true,
"license": "BSD"
},
"node_modules/load-json-file": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz",
"integrity": "sha512-Kx8hMakjX03tiGTLAIdJ+lL0htKnXjEZN6hk/tozf/WOuYGdZBJrZ+rCJRbVCugsjB3jMLn9746NsQIf5VjBMw==",
"dev": true,
"license": "MIT",
"dependencies": {
"graceful-fs": "^4.1.2",
"parse-json": "^4.0.0",
"pify": "^3.0.0",
"strip-bom": "^3.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/load-json-file/node_modules/pify": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz",
"integrity": "sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=4"
}
},
"node_modules/locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"dev": true,
"license": "MIT",
"dependencies": {
"p-locate": "^4.1.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/lodash": {
"version": "4.17.23",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz",
"integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==",
"dev": true,
"license": "MIT"
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/memorystream": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz",
"integrity": "sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==",
"dev": true,
"engines": {
"node": ">= 0.10.0"
}
},
"node_modules/mime": {
"version": "1.2.11",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.2.11.tgz",
"integrity": "sha512-Ysa2F/nqTNGHhhm9MV8ure4+Hc+Y8AWiqUdHxsO7xu8zc92ND9f3kpALHjaP026Ft17UfxrMt95c50PLUeynBw==",
"dev": true
},
"node_modules/mimic-fn": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz",
"integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/minimatch": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
"integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
"dev": true,
"license": "ISC",
"dependencies": {
"brace-expansion": "^1.1.7"
},
"engines": {
"node": "*"
}
},
"node_modules/minimist": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
"dev": true,
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/mkdirp": {
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
"dev": true,
"license": "MIT",
"dependencies": {
"minimist": "^1.2.6"
},
"bin": {
"mkdirp": "bin/cmd.js"
}
},
"node_modules/moment": {
"version": "2.30.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz",
"integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==",
"dev": true,
"license": "MIT",
"engines": {
"node": "*"
}
},
"node_modules/moment-timezone": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.5.tgz",
"integrity": "sha512-/aaLDQVE4gnDiDIcX2wWgAfBvfmZAz5UEmVkSOL5FIPlVwsDGqvMzp/0N3MttZKUxeofRdnQhB1t7xI0FHLhZw==",
"dev": true,
"license": "MIT",
"dependencies": {
"moment": ">= 2.6.0"
},
"engines": {
"node": "*"
}
},
"node_modules/mute-stream": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz",
"integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==",
"dev": true,
"license": "ISC"
},
"node_modules/nice-try": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz",
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
"dev": true,
"license": "MIT"
},
"node_modules/node-fetch": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"dev": true,
"license": "MIT",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/node-uuid": {
"version": "1.4.8",
"resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz",
"integrity": "sha512-TkCET/3rr9mUuRp+CpO7qfgT++aAxfDRaalQhwPFzI9BY/2rCDn6OfpZOVggi1AXfTPpfkTrg5f5WQx5G1uLxA==",
"deprecated": "Use uuid module instead",
"dev": true,
"bin": {
"uuid": "bin/uuid"
}
},
"node_modules/nomnom": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/nomnom/-/nomnom-1.6.2.tgz",
"integrity": "sha512-mscrcqifc/QKP6/afmtoC84/mK6SKcDTDEfKPMSgJKeV5dtshiw5+AF90uwHyAqHkMIYIEcGkSAJnV6+T9PY/g==",
"deprecated": "Package no longer supported. Contact support@npmjs.com for more info.",
"dev": true,
"dependencies": {
"colors": "0.5.x",
"underscore": "~1.4.4"
}
},
"node_modules/normalize-package-data": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz",
"integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==",
"dev": true,
"license": "BSD-2-Clause",
"dependencies": {
"hosted-git-info": "^2.1.4",
"resolve": "^1.10.0",
"semver": "2 || 3 || 4 || 5",
"validate-npm-package-license": "^3.0.1"
}
},
"node_modules/normalize-package-data/node_modules/semver": {
"version": "5.7.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz",
"integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==",
"dev": true,
"license": "ISC",
"bin": {
"semver": "bin/semver"
}
},
"node_modules/npm-run-all": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/npm-run-all/-/npm-run-all-4.1.5.tgz",
"integrity": "sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^3.2.1",
"chalk": "^2.4.1",
"cross-spawn": "^6.0.5",
"memorystream": "^0.3.1",
"minimatch": "^3.0.4",
"pidtree": "^0.3.0",
"read-pkg": "^3.0.0",
"shell-quote": "^1.6.1",
"string.prototype.padend": "^3.0.0"
},
"bin": {
"npm-run-all": "bin/npm-run-all/index.js",
"run-p": "bin/run-p/index.js",
"run-s": "bin/run-s/index.js"
},
"engines": {
"node": ">= 4"
}
},
"node_modules/npm-run-all/node_modules/ansi-styles": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dev": true,
"license": "MIT",
"dependencies": {
"color-convert": "^1.9.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/npm-run-all/node_modules/chalk": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
"integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^3.2.1",
"escape-string-regexp": "^1.0.5",
"supports-color": "^5.3.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/npm-run-all/node_modules/color-convert": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
"dev": true,
"license": "MIT",
"dependencies": {
"color-name": "1.1.3"
}
},
"node_modules/npm-run-all/node_modules/color-name": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==",
"dev": true,
"license": "MIT"
},
"node_modules/npm-run-all/node_modules/has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=4"
}
},
"node_modules/npm-run-all/node_modules/supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
"dev": true,
"license": "MIT",
"dependencies": {
"has-flag": "^3.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/oauth-sign": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.3.0.tgz",
"integrity": "sha512-Tr31Sh5FnK9YKm7xTUPyDMsNOvMqkVDND0zvK/Wgj7/H9q8mpye0qG2nVzrnsvLhcsX5DtqXD0la0ks6rkPCGQ==",
"dev": true,
"engines": {
"node": "*"
}
},
"node_modules/object-inspect": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/object-keys": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/object.assign": {
"version": "4.1.7",
"resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.7.tgz",
"integrity": "sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bind": "^1.0.8",
"call-bound": "^1.0.3",
"define-properties": "^1.2.1",
"es-object-atoms": "^1.0.0",
"has-symbols": "^1.1.0",
"object-keys": "^1.1.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/onetime": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz",
"integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==",
"dev": true,
"license": "MIT",
"dependencies": {
"mimic-fn": "^2.1.0"
},
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/os-tmpdir": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
"integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/own-keys": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/own-keys/-/own-keys-1.0.1.tgz",
"integrity": "sha512-qFOyK5PjiWZd+QQIh+1jhdb9LpxTF0qs7Pm8o5QHYZ0M3vKqSqzsZaEB6oWlxZ+q2sJBMI/Ktgd2N5ZwQoRHfg==",
"dev": true,
"license": "MIT",
"dependencies": {
"get-intrinsic": "^1.2.6",
"object-keys": "^1.1.1",
"safe-push-apply": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/p-limit": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"dev": true,
"license": "MIT",
"dependencies": {
"p-try": "^2.0.0"
},
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/p-locate": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"dev": true,
"license": "MIT",
"dependencies": {
"p-limit": "^2.2.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/p-try": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/parse-json": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz",
"integrity": "sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw==",
"dev": true,
"license": "MIT",
"dependencies": {
"error-ex": "^1.3.1",
"json-parse-better-errors": "^1.0.1"
},
"engines": {
"node": ">=4"
}
},
"node_modules/parse-link-header": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/parse-link-header/-/parse-link-header-0.1.0.tgz",
"integrity": "sha512-VZ0pZwX3LRTfpDARULYD2C0fHuQqg7TPSGmPoKEHfBBmBhH7KMG3LV27GkUtjezoixE/CCJNAVnNw54IxkskWg==",
"dev": true,
"license": "MIT",
"dependencies": {
"xtend": "~2.0.5"
}
},
"node_modules/parse-link-header/node_modules/object-keys": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.2.0.tgz",
"integrity": "sha512-XODjdR2pBh/1qrjPcbSeSgEtKbYo7LqYNq64/TPuCf7j9SfDD3i21yatKoIy39yIWNvVM59iutfQQpCv1RfFzA==",
"deprecated": "Please update to the latest object-keys",
"dev": true,
"license": "MIT",
"dependencies": {
"foreach": "~2.0.1",
"indexof": "~0.0.1",
"is": "~0.2.6"
}
},
"node_modules/parse-link-header/node_modules/xtend": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-2.0.6.tgz",
"integrity": "sha512-fOZg4ECOlrMl+A6Msr7EIFcON1L26mb4NY5rurSkOex/TWhazOrg6eXD/B0XkuiYcYhQDWLXzQxLMVJ7LXwokg==",
"dev": true,
"dependencies": {
"is-object": "~0.1.2",
"object-keys": "~0.2.0"
},
"engines": {
"node": ">=0.4"
}
},
"node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/path-key": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz",
"integrity": "sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=4"
}
},
"node_modules/path-parse": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
"dev": true,
"license": "MIT"
},
"node_modules/path-type": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz",
"integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==",
"dev": true,
"license": "MIT",
"dependencies": {
"pify": "^3.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/path-type/node_modules/pify": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz",
"integrity": "sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=4"
}
},
"node_modules/pegjs": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/pegjs/-/pegjs-0.10.0.tgz",
"integrity": "sha512-qI5+oFNEGi3L5HAxDwN2LA4Gg7irF70Zs25edhjld9QemOgp0CbvMtbFcMvFtEo1OityPrcCzkQFB8JP/hxgow==",
"dev": true,
"license": "MIT",
"bin": {
"pegjs": "bin/pegjs"
},
"engines": {
"node": ">=0.10"
}
},
"node_modules/pidtree": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.3.1.tgz",
"integrity": "sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA==",
"dev": true,
"license": "MIT",
"bin": {
"pidtree": "bin/pidtree.js"
},
"engines": {
"node": ">=0.10"
}
},
"node_modules/pify": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-5.0.0.tgz",
"integrity": "sha512-eW/gHNMlxdSP6dmG6uJip6FXN0EQBwm2clYYd8Wul42Cwu/DK8HEftzsapcNdYe2MfLiIwZqsDk2RDEsTE79hA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/playwright": {
"version": "1.50.1",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.50.1.tgz",
"integrity": "sha512-G8rwsOQJ63XG6BbKj2w5rHeavFjy5zynBA9zsJMMtBoe/Uf757oG12NXz6e6OirF7RCrTVAKFXbLmn1RbL7Qaw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"playwright-core": "1.50.1"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=18"
},
"optionalDependencies": {
"fsevents": "2.3.2"
}
},
"node_modules/playwright-core": {
"version": "1.50.1",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.50.1.tgz",
"integrity": "sha512-ra9fsNWayuYumt+NiM069M6OkcRb1FZSK8bgi66AtpFoWkg2+y0bJSNmkFrWhMbEBbVKC/EruAHH3g0zmtwGmQ==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"playwright-core": "cli.js"
},
"engines": {
"node": ">=18"
}
},
"node_modules/possible-typed-array-names": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz",
"integrity": "sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/prettier": {
"version": "2.8.8",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
"dev": true,
"license": "MIT",
"optional": true,
"bin": {
"prettier": "bin-prettier.js"
},
"engines": {
"node": ">=10.13.0"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/qs": {
"version": "0.6.6",
"resolved": "https://registry.npmjs.org/qs/-/qs-0.6.6.tgz",
"integrity": "sha512-kN+yNdAf29Jgp+AYHUmC7X4QdJPR8czuMWLNLc0aRxkQ7tB3vJQEONKKT9ou/rW7EbqVec11srC9q9BiVbcnHA==",
"dev": true,
"engines": {
"node": "*"
}
},
"node_modules/read": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz",
"integrity": "sha512-rSOKNYUmaxy0om1BNjMN4ezNT6VKK+2xF4GBhc81mkH7L60i6dp8qPYrkndNLT3QPphoII3maL9PVC9XmhHwVQ==",
"dev": true,
"license": "ISC",
"dependencies": {
"mute-stream": "~0.0.4"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/read-pkg": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz",
"integrity": "sha512-BLq/cCO9two+lBgiTYNqD6GdtK8s4NpaWrl6/rCO9w0TUS8oJl7cmToOZfRYllKTISY6nt1U7jQ53brmKqY6BA==",
"dev": true,
"license": "MIT",
"dependencies": {
"load-json-file": "^4.0.0",
"normalize-package-data": "^2.3.2",
"path-type": "^3.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/readable-stream": {
"version": "1.0.34",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
"integrity": "sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg==",
"dev": true,
"license": "MIT",
"dependencies": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"node_modules/reflect.getprototypeof": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz",
"integrity": "sha512-00o4I+DVrefhv+nX0ulyi3biSHCPDe+yLv5o/p6d/UVlirijB8E16FtfwSAi4g3tcqrQ4lRAqQSoFEZJehYEcw==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bind": "^1.0.8",
"define-properties": "^1.2.1",
"es-abstract": "^1.23.9",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.0.0",
"get-intrinsic": "^1.2.7",
"get-proto": "^1.0.1",
"which-builtin-type": "^1.2.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/regexp.prototype.flags": {
"version": "1.5.4",
"resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz",
"integrity": "sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bind": "^1.0.8",
"define-properties": "^1.2.1",
"es-errors": "^1.3.0",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"set-function-name": "^2.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/request": {
"version": "2.22.0",
"resolved": "https://registry.npmjs.org/request/-/request-2.22.0.tgz",
"integrity": "sha512-s05oCBjWuzNi/UbZtvwOnSJ85/lHUdYPriJyFUwdxHKr8VcZHB0wx0eTX8y5hCH3p7OTDi9iQUqMFyDkW6K7EQ==",
"deprecated": "request has been deprecated, see https://github.com/request/request/issues/3142",
"dev": true,
"engines": [
"node >= 0.8.0"
],
"dependencies": {
"aws-sign": "~0.3.0",
"cookie-jar": "~0.3.0",
"forever-agent": "~0.5.0",
"form-data": "0.0.8",
"hawk": "~0.13.0",
"http-signature": "~0.10.0",
"json-stringify-safe": "~4.0.0",
"mime": "~1.2.9",
"node-uuid": "~1.4.0",
"oauth-sign": "~0.3.0",
"qs": "~0.6.0",
"tunnel-agent": "~0.3.0"
}
},
"node_modules/require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/require-main-filename": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
"dev": true,
"license": "ISC"
},
"node_modules/resolve": {
"version": "1.22.11",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.11.tgz",
"integrity": "sha512-RfqAvLnMl313r7c9oclB1HhUEAezcpLjz95wFH4LVuhk9JF/r22qmVP9AMmOU4vMX7Q8pN8jwNg/CSpdFnMjTQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"is-core-module": "^2.16.1",
"path-parse": "^1.0.7",
"supports-preserve-symlinks-flag": "^1.0.0"
},
"bin": {
"resolve": "bin/resolve"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/restore-cursor": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz",
"integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==",
"dev": true,
"license": "MIT",
"dependencies": {
"onetime": "^5.1.0",
"signal-exit": "^3.0.2"
},
"engines": {
"node": ">=8"
}
},
"node_modules/run-async": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz",
"integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.12.0"
}
},
"node_modules/rxjs": {
"version": "6.6.7",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz",
"integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"tslib": "^1.9.0"
},
"engines": {
"npm": ">=2.0.0"
}
},
"node_modules/safe-array-concat": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.3.tgz",
"integrity": "sha512-AURm5f0jYEOydBj7VQlVvDrjeFgthDdEF5H1dP+6mNpoXOMo1quQqJ4wvJDyRZ9+pO3kGWoOdmV08cSv2aJV6Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bind": "^1.0.8",
"call-bound": "^1.0.2",
"get-intrinsic": "^1.2.6",
"has-symbols": "^1.1.0",
"isarray": "^2.0.5"
},
"engines": {
"node": ">=0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/safe-array-concat/node_modules/isarray": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz",
"integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==",
"dev": true,
"license": "MIT"
},
"node_modules/safe-push-apply": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/safe-push-apply/-/safe-push-apply-1.0.0.tgz",
"integrity": "sha512-iKE9w/Z7xCzUMIZqdBsp6pEQvwuEebH4vdpjcDWnyzaI6yl6O9FHvVpmGelvEHNsoY6wGblkxR6Zty/h00WiSA==",
"dev": true,
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"isarray": "^2.0.5"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/safe-push-apply/node_modules/isarray": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz",
"integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==",
"dev": true,
"license": "MIT"
},
"node_modules/safe-regex-test": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.1.0.tgz",
"integrity": "sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"is-regex": "^1.2.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"dev": true,
"license": "MIT"
},
"node_modules/semver": {
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
"dev": true,
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
}
},
"node_modules/set-blocking": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
"integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==",
"dev": true,
"license": "ISC"
},
"node_modules/set-function-length": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz",
"integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==",
"dev": true,
"license": "MIT",
"dependencies": {
"define-data-property": "^1.1.4",
"es-errors": "^1.3.0",
"function-bind": "^1.1.2",
"get-intrinsic": "^1.2.4",
"gopd": "^1.0.1",
"has-property-descriptors": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/set-function-name": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.2.tgz",
"integrity": "sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"define-data-property": "^1.1.4",
"es-errors": "^1.3.0",
"functions-have-names": "^1.2.3",
"has-property-descriptors": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/set-proto": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/set-proto/-/set-proto-1.0.0.tgz",
"integrity": "sha512-RJRdvCo6IAnPdsvP/7m6bsQqNnn1FCBX5ZNtFL98MmFF/4xAIJTIg1YbHW5DC2W5SKZanrC6i4HsJqlajw/dZw==",
"dev": true,
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/shebang-command": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz",
"integrity": "sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==",
"dev": true,
"license": "MIT",
"dependencies": {
"shebang-regex": "^1.0.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/shebang-regex": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz",
"integrity": "sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/shell-quote": {
"version": "1.8.3",
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.3.tgz",
"integrity": "sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
"integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
"dev": true,
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3",
"side-channel-list": "^1.0.0",
"side-channel-map": "^1.0.1",
"side-channel-weakmap": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-list": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",
"integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
"dev": true,
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-map": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-weakmap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3",
"side-channel-map": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/signal-exit": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
"integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==",
"dev": true,
"license": "ISC"
},
"node_modules/sntp": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/sntp/-/sntp-0.2.4.tgz",
"integrity": "sha512-bDLrKa/ywz65gCl+LmOiIhteP1bhEsAAzhfMedPoiHP3dyYnAevlaJshdqb9Yu0sRifyP/fRqSt8t+5qGIWlGQ==",
"deprecated": "This module moved to @hapi/sntp. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.",
"dev": true,
"dependencies": {
"hoek": "0.9.x"
},
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/sntp/node_modules/hoek": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/hoek/-/hoek-0.9.1.tgz",
"integrity": "sha512-ZZ6eGyzGjyMTmpSPYVECXy9uNfqBR7x5CavhUaLOeD6W0vWK1mp/b7O3f86XE0Mtfo9rZ6Bh3fnuw9Xr8MF9zA==",
"deprecated": "This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).",
"dev": true,
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/spdx-correct": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz",
"integrity": "sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"spdx-expression-parse": "^3.0.0",
"spdx-license-ids": "^3.0.0"
}
},
"node_modules/spdx-exceptions": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz",
"integrity": "sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==",
"dev": true,
"license": "CC-BY-3.0"
},
"node_modules/spdx-expression-parse": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz",
"integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"spdx-exceptions": "^2.1.0",
"spdx-license-ids": "^3.0.0"
}
},
"node_modules/spdx-license-ids": {
"version": "3.0.23",
"resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.23.tgz",
"integrity": "sha512-CWLcCCH7VLu13TgOH+r8p1O/Znwhqv/dbb6lqWy67G+pT1kHmeD/+V36AVb/vq8QMIQwVShJ6Ssl5FPh0fuSdw==",
"dev": true,
"license": "CC0-1.0"
},
"node_modules/stop-iteration-iterator": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz",
"integrity": "sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"internal-slot": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==",
"dev": true,
"license": "MIT"
},
"node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"dev": true,
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/string.prototype.padend": {
"version": "3.1.6",
"resolved": "https://registry.npmjs.org/string.prototype.padend/-/string.prototype.padend-3.1.6.tgz",
"integrity": "sha512-XZpspuSB7vJWhvJc9DLSlrXl1mcA2BdoY5jjnS135ydXqLoqhs96JjDtCkjJEQHvfqZIp9hBuBMgI589peyx9Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bind": "^1.0.7",
"define-properties": "^1.2.1",
"es-abstract": "^1.23.2",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/string.prototype.trim": {
"version": "1.2.10",
"resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.10.tgz",
"integrity": "sha512-Rs66F0P/1kedk5lyYyH9uBzuiI/kNRmwJAR9quK6VOtIpZ2G+hMZd+HQbbv25MgCA6gEffoMZYxlTod4WcdrKA==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bind": "^1.0.8",
"call-bound": "^1.0.2",
"define-data-property": "^1.1.4",
"define-properties": "^1.2.1",
"es-abstract": "^1.23.5",
"es-object-atoms": "^1.0.0",
"has-property-descriptors": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/string.prototype.trimend": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.9.tgz",
"integrity": "sha512-G7Ok5C6E/j4SGfyLCloXTrngQIQU3PWtXGst3yM7Bea9FRURf1S42ZHlZZtsNque2FN2PoUhfZXYLNWwEr4dLQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bind": "^1.0.8",
"call-bound": "^1.0.2",
"define-properties": "^1.2.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/string.prototype.trimstart": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.8.tgz",
"integrity": "sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bind": "^1.0.7",
"define-properties": "^1.2.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/strip-bom": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
"integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=4"
}
},
"node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"license": "MIT",
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/supports-preserve-symlinks-flag": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==",
"dev": true,
"license": "MIT"
},
"node_modules/through2": {
"version": "0.6.5",
"resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz",
"integrity": "sha512-RkK/CCESdTKQZHdmKICijdKKsCRVHs5KsLZ6pACAmF/1GPUQhonHSXWNERctxEp7RmvjdNbZTL5z9V7nSCXKcg==",
"dev": true,
"license": "MIT",
"dependencies": {
"readable-stream": ">=1.0.33-1 <1.1.0-0",
"xtend": ">=4.0.0 <4.1.0-0"
}
},
"node_modules/tmp": {
"version": "0.0.33",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
"integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==",
"dev": true,
"license": "MIT",
"dependencies": {
"os-tmpdir": "~1.0.2"
},
"engines": {
"node": ">=0.6.0"
}
},
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
"dev": true,
"license": "MIT"
},
"node_modules/tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true,
"license": "0BSD"
},
"node_modules/tunnel-agent": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.3.0.tgz",
"integrity": "sha512-jlGqHGoKzyyjhwv/c9omAgohntThMcGtw8RV/RDLlkbbc08kni/akVxO62N8HaXMVbVsK1NCnpSK3N2xCt22ww==",
"dev": true,
"engines": {
"node": "*"
}
},
"node_modules/type-fest": {
"version": "0.21.3",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz",
"integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==",
"dev": true,
"license": "(MIT OR CC0-1.0)",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/typed-array-buffer": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz",
"integrity": "sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.3",
"es-errors": "^1.3.0",
"is-typed-array": "^1.1.14"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/typed-array-byte-length": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/typed-array-byte-length/-/typed-array-byte-length-1.0.3.tgz",
"integrity": "sha512-BaXgOuIxz8n8pIq3e7Atg/7s+DpiYrxn4vdot3w9KbnBhcRQq6o3xemQdIfynqSeXeDrF32x+WvfzmOjPiY9lg==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bind": "^1.0.8",
"for-each": "^0.3.3",
"gopd": "^1.2.0",
"has-proto": "^1.2.0",
"is-typed-array": "^1.1.14"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/typed-array-byte-offset": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/typed-array-byte-offset/-/typed-array-byte-offset-1.0.4.tgz",
"integrity": "sha512-bTlAFB/FBYMcuX81gbL4OcpH5PmlFHqlCCpAl8AlEzMz5k53oNDvN8p1PNOWLEmI2x4orp3raOFB51tv9X+MFQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"available-typed-arrays": "^1.0.7",
"call-bind": "^1.0.8",
"for-each": "^0.3.3",
"gopd": "^1.2.0",
"has-proto": "^1.2.0",
"is-typed-array": "^1.1.15",
"reflect.getprototypeof": "^1.0.9"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/typed-array-length": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.7.tgz",
"integrity": "sha512-3KS2b+kL7fsuk/eJZ7EQdnEmQoaho/r6KUef7hxvltNA5DR8NAUM+8wJMbJyZ4G9/7i3v5zPBIMN5aybAh2/Jg==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bind": "^1.0.7",
"for-each": "^0.3.3",
"gopd": "^1.0.1",
"is-typed-array": "^1.1.13",
"possible-typed-array-names": "^1.0.0",
"reflect.getprototypeof": "^1.0.6"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/unbox-primitive": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.1.0.tgz",
"integrity": "sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.3",
"has-bigints": "^1.0.2",
"has-symbols": "^1.1.0",
"which-boxed-primitive": "^1.1.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/underscore": {
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.4.4.tgz",
"integrity": "sha512-ZqGrAgaqqZM7LGRzNjLnw5elevWb5M8LEoDMadxIW3OWbcv72wMMgKdwOKpd5Fqxe8choLD8HN3iSj3TUh/giQ==",
"dev": true
},
"node_modules/validate-npm-package-license": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
"integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"spdx-correct": "^3.0.0",
"spdx-expression-parse": "^3.0.0"
}
},
"node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
"dev": true,
"license": "BSD-2-Clause"
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"dev": true,
"license": "MIT",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/which": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
"integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
"dev": true,
"license": "ISC",
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"which": "bin/which"
}
},
"node_modules/which-boxed-primitive": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.1.1.tgz",
"integrity": "sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==",
"dev": true,
"license": "MIT",
"dependencies": {
"is-bigint": "^1.1.0",
"is-boolean-object": "^1.2.1",
"is-number-object": "^1.1.1",
"is-string": "^1.1.1",
"is-symbol": "^1.1.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/which-builtin-type": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/which-builtin-type/-/which-builtin-type-1.2.1.tgz",
"integrity": "sha512-6iBczoX+kDQ7a3+YJBnh3T+KZRxM/iYNPXicqk66/Qfm1b93iu+yOImkg0zHbj5LNOcNv1TEADiZ0xa34B4q6Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"function.prototype.name": "^1.1.6",
"has-tostringtag": "^1.0.2",
"is-async-function": "^2.0.0",
"is-date-object": "^1.1.0",
"is-finalizationregistry": "^1.1.0",
"is-generator-function": "^1.0.10",
"is-regex": "^1.2.1",
"is-weakref": "^1.0.2",
"isarray": "^2.0.5",
"which-boxed-primitive": "^1.1.0",
"which-collection": "^1.0.2",
"which-typed-array": "^1.1.16"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/which-builtin-type/node_modules/isarray": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz",
"integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==",
"dev": true,
"license": "MIT"
},
"node_modules/which-collection": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.2.tgz",
"integrity": "sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==",
"dev": true,
"license": "MIT",
"dependencies": {
"is-map": "^2.0.3",
"is-set": "^2.0.3",
"is-weakmap": "^2.0.2",
"is-weakset": "^2.0.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/which-module": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz",
"integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==",
"dev": true,
"license": "ISC"
},
"node_modules/which-typed-array": {
"version": "1.1.20",
"resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.20.tgz",
"integrity": "sha512-LYfpUkmqwl0h9A2HL09Mms427Q1RZWuOHsukfVcKRq9q95iQxdw0ix1JQrqbcDR9PH1QDwf5Qo8OZb5lksZ8Xg==",
"dev": true,
"license": "MIT",
"dependencies": {
"available-typed-arrays": "^1.0.7",
"call-bind": "^1.0.8",
"call-bound": "^1.0.4",
"for-each": "^0.3.5",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"has-tostringtag": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/wrap-ansi": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
"integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/xtend": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
"integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.4"
}
},
"node_modules/y18n": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
"dev": true,
"license": "ISC"
},
"node_modules/yargs": {
"version": "15.4.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",
"integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",
"dev": true,
"license": "MIT",
"dependencies": {
"cliui": "^6.0.0",
"decamelize": "^1.2.0",
"find-up": "^4.1.0",
"get-caller-file": "^2.0.1",
"require-directory": "^2.1.1",
"require-main-filename": "^2.0.0",
"set-blocking": "^2.0.0",
"string-width": "^4.2.0",
"which-module": "^2.0.0",
"y18n": "^4.0.0",
"yargs-parser": "^18.1.2"
},
"engines": {
"node": ">=8"
}
},
"node_modules/yargs-parser": {
"version": "18.1.3",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz",
"integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",
"dev": true,
"license": "ISC",
"dependencies": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
},
"engines": {
"node": ">=6"
}
}
}
}
================================================
FILE: package.json
================================================
{
"name": "@less/root",
"private": true,
"version": "4.6.3",
"description": "Less monorepo",
"homepage": "http://lesscss.org",
"scripts": {
"publish": "node scripts/bump-and-publish.js",
"publish:dry-run": "DRY_RUN=true node scripts/bump-and-publish.js",
"publish:beta": "node scripts/publish-beta.js",
"prepare": "husky",
"changelog": "github-changes -o less -r less.js -a --only-pulls --use-commit-body -m \"(YYYY-MM-DD)\"",
"test": "cd packages/less && npm test",
"test:node": "cd packages/less && npm run test:node",
"test:release": "node scripts/test-release-automation.js",
"postinstall": "npx only-allow pnpm"
},
"author": "Alexis Sellier ",
"contributors": [
"The Core Less Team"
],
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/less/less.js/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/less/less.js.git"
},
"devDependencies": {
"all-contributors-cli": "~6.26.1",
"github-changes": "^1.1.2",
"husky": "~9.1.7",
"npm-run-all": "^4.1.5",
"playwright": "1.50.1",
"semver": "^6.3.1"
},
"packageManager": "pnpm@8.15.0"
}
================================================
FILE: packages/less/.eslintignore
================================================
Gruntfile.js
dist/*
tmp/*
lib/*
test/browser/less.min.js
node_modules
================================================
FILE: packages/less/.eslintrc.cjs
================================================
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
}
},
]
}
================================================
FILE: packages/less/.gitignore
================================================
# project-specific
tmp
dist
test/browser/less.min.js
test/browser/less.min.js.map
test/sourcemaps/**/*.map
test/sourcemaps/*.map
test/sourcemaps/*.css
test/less-bom
lib/**/*.css.map
================================================
FILE: packages/less/.npmignore
================================================
.git
.gitattributes
.travis.yml
.grunt/
appveyor.yml
build/
benchmark/
src/
test/
test/less-bom/
# re-include test files as they can be useful for plugins that do testing
!test/*.js
tmp/
================================================
FILE: packages/less/Gruntfile.cjs
================================================
'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: 'node build/rollup.js --dist'
},
testbuild: {
command: 'node build/rollup.js --browser --out=./tmp/browser/less.min.js'
},
testbrowser: {
command: 'node build/rollup.js --browser --out=./tmp/browser/less.min.js'
},
test: {
command: 'node test/test-es6.js && node test/test-cjs.cjs && node test/exports/import-patterns.cjs && node test/exports/webpack-browser.cjs && node test/index.js'
},
testcjs: {
command: 'node test/test-cjs-suite.cjs'
},
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',
'lib/less*/**/*.js',
'!test/less/errors/plugin/plugin-error.js'
],
options: {
configFile: '.eslintrc.cjs',
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:build',
'shell:testbuild',
'shell:test',
'shell:opts',
'shell:plugin',
'connect',
'shell:runbrowser'
];
var nodeTestTasks = [
'shell:build',
'shell:test',
'shell:testcjs',
'shell:opts',
'shell:plugin'
];
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);
// Node tests only (ESM + CJS) — for prepublish, CI
grunt.registerTask('test:node', nodeTestTasks);
// Run shell option tests (includes deprecated options)
grunt.registerTask('shell-options', ['shell:opts']);
// Run shell plugin test
grunt.registerTask('shell-plugin', ['shell:plugin']);
// Quickly run Node tests (no build step needed)
grunt.registerTask('quicktest', [
'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:benchmark'
]);
};
================================================
FILE: packages/less/README.md
================================================
# Less.js
> The dynamic stylesheet language. [lesscss.org](http://lesscss.org)
Less extends CSS with variables, mixins, functions, nesting, and more — then compiles to standard CSS. Write cleaner stylesheets with less code.
```less
@primary: #4a90d9;
.button {
color: @primary;
&:hover {
color: darken(@primary, 10%);
}
}
```
## Install
```sh
npm install less
```
## Usage
### Node.js
```js
import less from 'less';
const output = await less.render('.class { width: (1 + 1) }');
console.log(output.css);
```
### Command Line
```sh
npx lessc styles.less styles.css
```
### Browser
```html
```
## Why Less?
- **Variables** — define reusable values once
- **Mixins** — reuse groups of declarations across rulesets
- **Nesting** — mirror HTML structure in your stylesheets
- **Functions** — transform colors, manipulate strings, do math
- **Imports** — split stylesheets into manageable pieces
- **Extend** — reduce output size by combining selectors
## Documentation
Full documentation, usage guides, and configuration options at **[lesscss.org](http://lesscss.org)**.
## Contributing
Less.js is open source. [Report bugs](https://github.com/less/less.js/issues), submit pull requests, or help improve the [documentation](https://github.com/less/less-docs).
See [CONTRIBUTING.md](https://github.com/less/less.js/blob/master/CONTRIBUTING.md) for development setup.
## License
Copyright (c) 2009-2025 [Alexis Sellier](http://cloudhead.io) & The Core Less Team
Licensed under the [Apache License](https://github.com/less/less.js/blob/master/LICENSE).
================================================
FILE: packages/less/benchmark/benchmark-import-reference-target.less
================================================
// Target for @import (reference) benchmarking
// These should NOT appear in output unless extended
.ref-button {
display: inline-block;
padding: 8px 16px;
border: 1px solid #ccc;
border-radius: 4px;
cursor: pointer;
background: #f0f0f0;
color: #333;
text-decoration: none;
font-size: 14px;
line-height: 1.5;
text-align: center;
vertical-align: middle;
&:hover {
background: #e0e0e0;
border-color: #999;
}
&:active {
background: #d0d0d0;
}
&.primary {
background: #3498db;
color: #fff;
border-color: #2980b9;
&:hover {
background: #2980b9;
}
}
&.danger {
background: #e74c3c;
color: #fff;
border-color: #c0392b;
&:hover {
background: #c0392b;
}
}
}
.ref-alert {
padding: 12px 20px;
border: 1px solid transparent;
border-radius: 4px;
margin-bottom: 16px;
&.success {
color: #155724;
background: #d4edda;
border-color: #c3e6cb;
}
&.warning {
color: #856404;
background: #fff3cd;
border-color: #ffeeba;
}
&.error {
color: #721c24;
background: #f8d7da;
border-color: #f5c6cb;
}
}
.ref-grid-system {
.row {
display: flex;
flex-wrap: wrap;
margin: 0 -15px;
}
.col {
flex: 1;
padding: 0 15px;
}
.generate-cols(@n, @i: 1) when (@i =< @n) {
.col-@{i} {
flex: 0 0 percentage((@i / @n));
max-width: percentage((@i / @n));
}
.generate-cols(@n, (@i + 1));
}
.generate-cols(12);
}
================================================
FILE: packages/less/benchmark/benchmark-import-target.less
================================================
// Shared mixins and variables for import benchmarking
@import-base-color: #3498db;
@import-accent: #e74c3c;
@import-spacing: 8px;
.imported-mixin(@size: 14px, @weight: normal) {
font-size: @size;
font-weight: @weight;
line-height: @size * 1.5;
}
.imported-box(@w: 100px, @h: 100px) {
width: @w;
height: @h;
background: @import-base-color;
border: 1px solid darken(@import-base-color, 15%);
margin: @import-spacing;
}
.imported-flex(@dir: row, @justify: flex-start, @align: stretch) {
display: flex;
flex-direction: @dir;
justify-content: @justify;
align-items: @align;
}
.imported-grid(@cols: 12, @gap: @import-spacing) {
display: grid;
grid-template-columns: repeat(@cols, 1fr);
gap: @gap;
}
.imported-base {
color: @import-base-color;
padding: @import-spacing;
.imported-mixin();
}
.imported-card {
.imported-box(300px, auto);
padding: @import-spacing * 2;
border-radius: 4px;
}
================================================
FILE: packages/less/benchmark/benchmark-runner.js
================================================
#!/usr/bin/env node
// Portable benchmark runner - dropped into each version's worktree
// Finds the Less compiler, compiles the given file N times, reports JSON results.
//
// Usage: node benchmark-runner.js [runs=30] [warmup=5]
var fs = require('fs');
var path = require('path');
var file = process.argv[2];
var totalRuns = parseInt(process.argv[3]) || 30;
var warmupRuns = parseInt(process.argv[4]) || 5;
var extraOpts = {};
// Parse --key=value options from remaining args
for (var ai = 5; ai < process.argv.length; ai++) {
var optMatch = process.argv[ai].match(/^--([a-z-]+)=(.*)$/);
if (optMatch) { extraOpts[optMatch[1]] = optMatch[2]; }
}
if (!file) {
console.error('Usage: node benchmark-runner.js [runs] [warmup]');
process.exit(1);
}
// Find Less compiler - try multiple paths for different version eras
var less;
var lessPath = '';
var tryPaths = [
// v4.x monorepo (after build)
'./packages/less',
// v3.x / v2.x (lib in repo)
'.',
'./lib/less-node',
// Fallback
'less'
];
for (var i = 0; i < tryPaths.length; i++) {
try {
var p = tryPaths[i];
// Use path.resolve for relative paths, but keep bare package names for Node resolution
var mod = require(p.startsWith('.') ? path.resolve(p) : p);
// Handle both direct export and .default (ESM interop)
less = mod && mod.default ? mod.default : mod;
if (less && (less.render || less.parse)) {
lessPath = p;
break;
}
less = null;
} catch (e) {
// try next
}
}
if (!less) {
console.error(JSON.stringify({ error: 'Could not find Less compiler', tried: tryPaths }));
process.exit(2);
}
// Determine version
var version = 'unknown';
if (less.version) {
if (Array.isArray(less.version)) {
version = less.version.join('.');
} else {
version = String(less.version);
}
}
var filePath = path.resolve(file);
var data = fs.readFileSync(filePath, 'utf8');
var fileDir = path.dirname(filePath);
// Use less.render() - stable across all versions
var renderTimes = [];
var parseTimes = [];
var completed = 0;
var errors = [];
function hrNow() {
var hr = process.hrtime();
return hr[0] * 1000 + hr[1] / 1e6;
}
function runOnce(callback) {
var start = hrNow();
var opts = {
filename: filePath,
paths: [fileDir]
};
// Forward extra options (e.g. --math=always)
for (var key in extraOpts) { opts[key] = extraOpts[key]; }
less.render(data, opts, function (err, output) {
var end = hrNow();
if (err) {
errors.push({ run: completed, error: err.message || String(err) });
callback(err);
return;
}
renderTimes.push(end - start);
completed++;
callback(null);
});
}
function runAll(i) {
if (i >= totalRuns) {
reportResults();
return;
}
runOnce(function (err) {
if (err && errors.length > 3) {
// Too many errors, bail
reportResults();
return;
}
runAll(i + 1);
});
}
function analyze(times, skipWarmup) {
var start = skipWarmup ? warmupRuns : 0;
if (times.length <= start) return null;
var effective = times.slice(start);
var total = 0, min = Infinity, max = 0;
for (var i = 0; i < effective.length; i++) {
total += effective[i];
min = Math.min(min, effective[i]);
max = Math.max(max, effective[i]);
}
var avg = total / effective.length;
// Median
var sorted = effective.slice().sort(function (a, b) { return a - b; });
var mid = Math.floor(sorted.length / 2);
var median = sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
// Standard deviation and coefficient of variation
var sumSqDiff = 0;
for (var i = 0; i < effective.length; i++) {
sumSqDiff += (effective[i] - avg) * (effective[i] - avg);
}
var stddev = Math.sqrt(sumSqDiff / effective.length);
var variancePct = avg === 0 ? 0 : (stddev / avg) * 100;
return {
min: Math.round(min * 100) / 100,
max: Math.round(max * 100) / 100,
avg: Math.round(avg * 100) / 100,
median: Math.round(median * 100) / 100,
stddev: Math.round(stddev * 100) / 100,
variance_pct: Math.round(variancePct * 100) / 100,
samples: effective.length,
throughput_kbs: Math.round(1000 / avg * data.length / 1024)
};
}
function reportResults() {
var result = {
version: version,
lessPath: lessPath,
file: path.basename(file),
fileSize: data.length,
fileSizeKB: Math.round(data.length / 1024 * 10) / 10,
totalRuns: totalRuns,
warmupRuns: warmupRuns,
completedRuns: completed,
errors: errors.length > 0 ? errors : undefined,
render: analyze(renderTimes, true)
};
console.log(JSON.stringify(result));
}
runAll(0);
================================================
FILE: packages/less/benchmark/benchmark-v3.less
================================================
// Benchmark for Less v3.0+ features: if(), boolean(), $prop accessor, @plugin
// This file is standalone and does NOT import the base benchmark.
// --- if() function ---
@mode: dark;
@size: large;
.if-card {
background: if((@mode = dark), #1a1a2e, #ffffff);
color: if((@mode = dark), #eaeaea, #333333);
font-size: if((@size = large), 18px, 14px);
padding: if((@size = large), 24px, 12px);
border: 1px solid if((@mode = dark), #444, #ddd);
}
// if() in loops
.gen-if-variants(@n, @i: 1) when (@i =< @n) {
.variant-@{i} {
color: if((@i > 5), #ff0000, #0000ff);
font-weight: if((mod(@i, 2) = 0), bold, normal);
opacity: if((@i > 8), 0.5, 1);
display: if((@i = @n), none, block);
}
.gen-if-variants(@n, (@i + 1));
}
.gen-if-variants(12);
// --- boolean() function (added v3.6.0) ---
@is-dark: boolean(@mode = dark);
@is-large: boolean(@size = large);
@is-rtl: boolean(1 = 0);
.boolean-test {
.responsive(@flag) when (@flag) {
max-width: 1200px;
margin: 0 auto;
}
.responsive(@flag) when not (@flag) {
width: 100%;
}
.responsive(@is-large);
}
// --- Property accessor $prop ---
.color-definitions {
primary: #3498db;
secondary: #2ecc71;
accent: #e74c3c;
neutral: #95a5a6;
warning: #f39c12;
}
.prop-button {
color: .color-definitions[primary];
border-color: .color-definitions[secondary];
}
.prop-alert-success {
background: .color-definitions[secondary];
border-color: darken(.color-definitions[secondary], 10%);
}
.prop-alert-danger {
background: .color-definitions[accent];
border-color: darken(.color-definitions[accent], 10%);
}
.prop-alert-warning {
background: .color-definitions[warning];
border-color: darken(.color-definitions[warning], 10%);
}
// Spacing scale via property accessor
.spacing-scale {
xs: 4px;
sm: 8px;
md: 16px;
lg: 24px;
xl: 32px;
xxl: 48px;
}
.card-compact {
padding: .spacing-scale[sm];
margin: .spacing-scale[xs];
}
.card-normal {
padding: .spacing-scale[md];
margin: .spacing-scale[sm];
}
.card-spacious {
padding: .spacing-scale[xl];
margin: .spacing-scale[lg];
}
// --- Complex guard + if combos ---
.button-variant(@bg, @border: darken(@bg, 10%), @color: #fff) {
background: @bg;
border-color: @border;
color: if((lightness(@bg) > 60%), #333, @color);
&:hover {
background: darken(@bg, 8%);
border-color: darken(@border, 12%);
}
&:active {
background: darken(@bg, 12%);
}
}
.btn-primary { .button-variant(#3498db); }
.btn-success { .button-variant(#2ecc71); }
.btn-warning { .button-variant(#f1c40f); }
.btn-danger { .button-variant(#e74c3c); }
.btn-light { .button-variant(#f8f9fa); }
.btn-dark { .button-variant(#343a40); }
// --- Stress: many property lookups in a loop ---
.z-index-scale {
dropdown: 1000;
sticky: 1020;
fixed: 1030;
modal-backdrop: 1040;
modal: 1050;
popover: 1060;
tooltip: 1070;
}
.dropdown { z-index: .z-index-scale[dropdown]; }
.sticky-top { z-index: .z-index-scale[sticky]; }
.fixed-top { z-index: .z-index-scale[fixed]; }
.modal-backdrop { z-index: .z-index-scale[modal-backdrop]; }
.modal { z-index: .z-index-scale[modal]; }
.popover { z-index: .z-index-scale[popover]; }
.tooltip { z-index: .z-index-scale[tooltip]; }
================================================
FILE: packages/less/benchmark/benchmark-v37.less
================================================
// Benchmark for Less v3.7+ features: each()
// Standalone file.
// --- each() with lists ---
@breakpoints: xs, sm, md, lg, xl;
each(@breakpoints, {
.container-@{value} {
max-width: if((@value = xs), 100%, if((@value = sm), 540px, if((@value = md), 720px, if((@value = lg), 960px, 1140px))));
margin: 0 auto;
padding: 0 15px;
}
});
// --- each() with maps ---
@colors: {
primary: #3498db;
secondary: #2ecc71;
success: #27ae60;
danger: #e74c3c;
warning: #f39c12;
info: #17a2b8;
light: #f8f9fa;
dark: #343a40;
};
each(@colors, {
.text-@{key} { color: @value; }
.bg-@{key} { background-color: @value; }
.border-@{key} { border-color: @value; }
.btn-@{key} {
background: @value;
border: 1px solid darken(@value, 10%);
color: if((lightness(@value) > 60%), #333, #fff);
&:hover {
background: darken(@value, 8%);
}
}
});
// --- each() generating utility classes ---
@spacings: {
0: 0;
1: 4px;
2: 8px;
3: 16px;
4: 24px;
5: 32px;
};
@directions: top, right, bottom, left;
each(@spacings, .(@size, @key) {
each(@directions, .(@dir) {
.m@{dir}-@{key} {
margin-@{dir}: @size;
}
.p@{dir}-@{key} {
padding-@{dir}: @size;
}
});
});
// --- each() with display properties ---
@displays: block, inline, inline-block, flex, inline-flex, grid, none;
each(@displays, {
.d-@{value} { display: @value; }
});
// --- each() generating component sizes ---
@sm-font: 12px; @sm-pad: 4px 8px; @sm-radius: 2px;
@md-font: 14px; @md-pad: 8px 16px; @md-radius: 4px;
@lg-font: 18px; @lg-pad: 12px 24px; @lg-radius: 6px;
@component-size-names: sm, md, lg;
each(@component-size-names, {
.input-@{value} {
border: 1px solid #ccc;
line-height: 1.5;
}
.badge-@{value} {
display: inline-block;
}
});
// --- each() with float utilities ---
@positions: static, relative, absolute, fixed, sticky;
each(@positions, {
.position-@{value} { position: @value; }
});
// --- Nested each() stress ---
@font-weights: 100, 200, 300, 400, 500, 600, 700, 800, 900;
each(@font-weights, {
.fw-@{value} { font-weight: @value; }
});
@opacities: {
0: 0;
25: 0.25;
50: 0.5;
75: 0.75;
100: 1;
};
each(@opacities, .(@val, @key) {
.opacity-@{key} { opacity: @val; }
});
================================================
FILE: packages/less/benchmark/benchmark-v39.less
================================================
// Benchmark for Less v3.9+ features: range()
// Standalone file.
// --- range() basic ---
@columns: range(1, 12);
each(@columns, {
.col-@{value} {
flex: 0 0 percentage((@value / 12));
max-width: percentage((@value / 12));
}
});
// --- range() for spacing scale ---
@spacing-steps: range(0, 20);
each(@spacing-steps, {
.gap-@{value} {
gap: (@value * 4px);
}
.space-x-@{value} > * + * {
margin-left: (@value * 4px);
}
.space-y-@{value} > * + * {
margin-top: (@value * 4px);
}
});
// --- range() with step for font sizes ---
@font-sizes: range(10px, 48px, 2);
each(@font-sizes, .(@size, @idx) {
.text-size-@{idx} {
font-size: @size;
line-height: @size * 1.5;
}
});
// --- range() for generating a color palette ---
@hue-steps: range(0, 350, 30);
each(@hue-steps, .(@hue, @idx) {
.hue-@{idx} {
color: hsl(@hue, 70%, 50%);
background: hsl(@hue, 70%, 95%);
border-color: hsl(@hue, 70%, 80%);
}
});
// --- range() for grid system ---
@grid-cols: range(1, 24);
each(@grid-cols, {
.grid-span-@{value} {
grid-column: span @value;
}
});
// --- range() for z-index layers ---
@layers: range(1, 10);
each(@layers, {
.z-@{value} {
z-index: @value * 100;
}
});
// --- range() for opacity scale ---
@opacity-steps: range(0, 100, 5);
each(@opacity-steps, .(@val) {
.o-@{val} {
opacity: @val / 100;
}
});
// --- range() for border-radius scale ---
@radius-steps: range(0, 24, 2);
each(@radius-steps, .(@val) {
.rounded-@{val} {
border-radius: (@val * 1px);
}
});
================================================
FILE: packages/less/benchmark/benchmark.less
================================================
@bg: #f01;
@white: #fff;
@grey: #eee;
@black: #000;
@blue: #000;
@accent_colour: #000;
@light_grey: #eee;
@dark_grey: #eee;
@yellow: #422;
@red: #ff0000;
@colour_positive: #ff0000;
@colour_negative: #ff0000;
.box_shadow (...) {
}
.text_shadow (...) {
}
.border_radius (...) {
}
.border_radius_top_left (...) {
}
.border_radius_top_right (...) {
}
.border_radius_bottom_right (...) {
}
.border_radius_bottom_left (...) {
}
.border_radius_top (...) {
}
.border_radius_right (...) {
}
.border_radius_bottom (...) {
}
.border_radius_left (...) {
}
div.browse {
margin: 0 0 20px;
&.class {
padding: 0;
}
div.header {
padding: 10px 10px 9px; text-align: left; background: @bg url('/images/panel_header_bg.png') repeat-x top left;
border-bottom: 1px solid (@bg * 0.66 + @black * 0.33); line-height: 1; height: 18px;
.border_radius_top(3); color: @light_grey;
h3 { font-size: 16px; margin: 0; color: @white; .text_shadow(1, 1, 0, @bg * 0.66 + @black * 0.33); }
span.filter {
float: left; display: block; overflow: hidden; position: relative; z-index: 5;
a {
margin: 0 1px 0 0; display: block; float: left; padding: 0 8px; height: 18px; font-weight: bold; font-size: 10px; line-height: 18px;
text-transform: uppercase; background: url('/images/transparent_backgrounds/black_50.png'); color: @light_grey; text-decoration: none; position: relative; z-index: 3;
.active {
background: @white; color: @black; z-index: 4;
:hover { color: @black; }
}
:hover { color: @white; }
:first-child { .border_radius_left(2); }
:last-child { .border_radius_right(2); margin-right: 0; }
}
}
span.filter.dropdown {
margin: 0; position: relative; overflow: visible;
a {
.border_radius(2); background: @white; color: @black; margin: 0; position: relative; padding-right: 25px;
img { float: left; margin: 4px 5px 0 0; }
b.arrow {
float: right; display: block; height: 0; width: 0; border: 5px solid transparent; border-top: 5px solid @black; border-bottom: none;
position: absolute; top: 6px; right: 10px;
}
:hover {
background: @accent_colour; color: @white;
b.arrow { border-top: 5px solid @white; }
}
}
ul {
position: absolute; top: 100%; left: 0; margin: 1px 0 0; padding: 0; background: @white; .border_radius(2);
.box_shadow(0, 1, 1, @black);
li {
list-style: none; display: block; padding: 0; margin: 0;
a {
display: block; height: 18px; line-height: 18px; color: @black; font-size: 10px; text-transform: uppercase; background: transparent;
border-bottom: 1px solid (@light_grey * 0.66 + @white * 0.33); float: none; margin: 0; .border_radius(0); white-space: nowrap;
:hover { background: url('/images/transparent_backgrounds/accent_colour_25.png'); color: @black; }
}
:last-child {
a { border: none; }
}
}
}
}
span.filter.dropdown.sort { float: left; margin: 0 0 0 10px; }
span.filter.dropdown.localisation { float: left; margin: 0 0 0 10px; }
a.more {
float: right; color: @white; .text_shadow(1, 1, 0, @bg * 0.66 + @black * 0.33); font-size: 14px; font-weight: bold;
position: relative; top: 2px;
:hover { text-decoration: none; }
}
}
> ul {
margin: 0; background: @white; padding: 10px 0 0 10px; .border_radius(3); position: relative;
li {
display: block; float: left; list-style: none; margin: 0 10px 10px 0; padding: 5px; position: relative;
background: @white; width: 130px; border: 1px solid (@light_grey * 0.33 + @white * 0.66); .border_radius(2);
a.remove {
position: absolute; height: 16px; width: 16px; padding: 3px; background: @accent_colour;
.border_radius(99); display: none; z-index: 3; top: -8px; right: -8px;
img { vertical-align: middle; }
}
div.thumbnail {
.border_radius_top(3); position: relative; z-index: 3;
.marker {
position: absolute; padding: 2px; .border_radius(2); z-index: 3;
background: url('/images/transparent_backgrounds/white_75.png'); height: 12px; width: 12px;
}
.marker.coupon {
height: auto; width: auto; top: 10px; right: -3px; padding: 0; background: transparent; overflow: hidden; position: absolute;
b {
display: block; height: 0; width: 0; float: left; border: 14px solid transparent; border-top: 14px solid @accent_colour;
border-bottom: none; border-right: none; float: left;
}
span {
color: @white; font-size: 10px; font-weight: bold; text-transform: uppercase; height: 14px; line-height: 14px; display: block;
padding: 0 4px 0 2px; background: @accent_colour; .text_shadow(1, 1, 0px, (@accent_colour * 0.75 + @black * 0.25)); margin: 0 0 0 14px;
}
}
.marker.video {
position: absolute; left: 50%; top: 50%; background: @white; width: 10px; height: 10px;
b { display: block; width: 0; height: 0; border: 5px solid transparent; border-left: 10px solid @black; border-right: none; }
}
.marker.endorsed_by_me { background: none; padding: 0; right: 0; bottom: -32px; .border_radius(2); background: @white; }
a.thumbnail {
display: block; overflow: hidden; position: relative; text-align: center;
img { position: relative; display: block; margin: auto; }
}
}
div.text {
margin: 3px 0 0; display: block;
a { text-decoration: none; }
a.title {
display: block; text-decoration: none; font-weight: bold; font-size: 12px; line-height: 16px;
white-space: nowrap; height: 16px; overflow: hidden;
:before {
display: block; height: 32px; width: 20px; content: " "; float: right; right: -15px; top: -8px;
background: @white; position: relative; z-index: 1; .box_shadow(-5, 0, 10, @white);
}
}
small {
font-size: 11px; line-height: 13px; color: @grey; display: block; height: 13px; overflow: hidden; white-space: nowrap;
a { font-weight: bold; }
:before {
display: block; height: 32px; width: 20px; content: " "; float: right; right: -15px; top: -8px;
background: @white; position: relative; z-index: 1; .box_shadow(-5, 0, 10, @white);
}
}
}
:hover {
background: @accent_colour;
a.remove { display: block; }
div.thumbnail {
a.marker.remove, a.marker.video {
b { display: inline-block; }
}
a.marker.video { .box_shadow(0, 0, 2, @black); }
}
div.text {
a { color: @white; }
a.title:before { background: @accent_colour; .box_shadow(-5, 0, 10, @accent_colour); }
small {
color: @white * 0.75 + @accent_colour * 0.25;
:before { background: @accent_colour; .box_shadow(-5, 0, 10, @accent_colour); }
}
}
div.footer a { color: @white; }
}
}
> li.ad div.thumbnail a.thumbnail {
width: 130px; height: 97px;
img { width: 100%; height: 100%; }
}
> li.brand div.thumbnail a.thumbnail {
width: 120px; height: 87px; padding: 5px; background: @white; .border_radius(2);
img { max-width: 120px; max-height: 87px; }
}
li.paginate {
margin-bottom: 0;
a {
display: block; position: relative; text-decoration: none; height: 131px;
div.arrow {
background: #81c153 url('/images/button_bg.png') repeat-x left top; border: 1px solid (@accent_colour * 0.75 + @black * 0.25);
height: 44px; .border_radius(99); width: 44px; margin: 0 auto; position: relative; top: 32px;
b { text-indent: -9000px; display: block; border: 10px solid transparent; width: 0; height: 0; position: relative; top: 12px; }
}
div.label {
position: absolute; bottom: 5px; left: 0; right: 0; line-height: 13px;
color: @accent_colour * 0.85 + @black * 0.15; text-decoration: none;
font-weight: bold; font-size: 12px; text-align: center;
}
:hover {
div.arrow { background: #abd56e url('/images/button_bg.png') repeat-x left -44px; }
}
}
:hover { background: transparent; }
}
li.paginate.previous a div b { border-right: 15px solid @white; border-left: none; left: 12px; }
li.paginate.next a div b { border-left: 15px solid @white; border-right: none; left: 16px; }
}
> div.footer {
padding: 9px 10px 10px; background: @light_grey * 0.75 + @white * 0.25; overflow: hidden;
border-top: 1px solid @light_grey; .border_radius_bottom(3);
div.info {
float: left; color: @grey;
strong { color: @black; font-weight: normal; }
}
div.pagination {
float: right;
> * {
display: inline-block; line-height: 1; padding: 0 6px; line-height: 18px; height: 18px; background: @white;
.border_radius(3); text-decoration: none; font-weight: bold;
font-size: 10px; text-transform: uppercase;
}
a { color: @grey; }
a:hover { color: @black; }
span.disabled { color: @light_grey; }
span.current { color: @white; background: @bg; border: none; }
span.current:hover { color: @white; }
}
}
}
div.browse.with_categories { margin: 0 0 0 160px; }
div.browse.with_options > ul { .border_radius_top(0); }
div.browse.with_footer > ul { .border_radius_bottom(0); }
/* Browse List */
div.browse.list {
> ul {
margin: 0; min-height: 320px;
padding: 10px 0 0 10px; overflow: hidden;
> li {
display: block; list-style: none; margin: 0 10px 10px 0; padding: 5px;
.border_radius(3); position: relative; line-height: normal;
.marker {
position: absolute; padding: 2px; .border_radius(2);
background: url('/images/transparent_backgrounds/white_75.png');
img { height: 12px; width: 12px; }
}
img.marker { height: 12px; width: 12px; }
span.marker.new {
color: black; left: -5px; top: -5px; background: none; background-color: @white * 0.1 + @yellow * 0.6 + @red * 0.3; line-height: 1; padding: 2px 5px;
font-weight: bold;
}
a.marker.media_type {
display: inline-block; text-decoration: none; top: 39px; left: 8px;
font-size: 10px;
b { font-weight: normal; margin: 0 0 0 2px; line-height: 1; display: none; }
img { vertical-align: middle; }
}
a.thumbnail {
float: left;
width: 68px; display: block; overflow: hidden;
border: 1px solid @light_grey;
:hover { border-color: @accent_colour; }
}
span.title_brand {
display: block; margin: 0 0 2px 75px;
a { margin: 0; display: inline; }
a.brand_name { font-weight: normal; font-size: 12px; }
}
a.ad_title {
font-weight: bold; font-size: 14px; margin: 0 0 0 75px; display: block;
}
a.brand_name {
font-weight: bold; font-size: 14px; margin: 0 0 0 75px; display: block;
}
small {
display: block; color: @grey; margin: 0 0 0 75px; font-size: 12px;
}
small.brand_name { display: inline; margin: 0; }
ul.chart {
margin: 0 0 0 80px;
height: 39px;
}
ul.networks {
margin: 3px 0 0 75px; padding: 0; overflow: hidden;
li { display: block; float: left; margin: 0 5px 0 0; line-height: 1; }
}
div.points {
display: none;
font-size: 12px; text-align: right;
label { color: @grey; }
}
a.remove { bottom: -3px; right: -3px; }
}
li.ad {
a.thumbnail { height: 51px; }
span.title_brand {
small.brand_name {
display: block;
}
}
}
li.brand {
a.thumbnail { height: 68px; }
}
}
}
div.browse.list.with_options ul { .border_radius_top(0); }
div.browse.list.with_footer ul { .border_radius_bottom(0); }
div.browse.list.cols_2 {
> ul {
> li {
width: 285px; float: left;
:hover {
background: @white;
}
}
}
}
div.browse.ads.list {
> ul {
> li {
height: 53px;
a.thumbnail {
height: 51px;
}
}
}
}
div.browse.brands.list {
> ul {
> li {
height: 68px;
a.thumbnail {
height: 66px;
}
}
}
}
/* Categories List */
#categories {
margin: 40px 0 0; width: 160px; float: left; position: relative; z-index: 1;
ul {
margin: 0; padding: 10px 0 0;
li {
list-style: none; margin: 0; padding: 0; font-size: 14px;
a { color: @grey; display: block; padding: 5px 10px 5px 15px; text-decoration: none; .border_radius_left(3); }
a:hover { color: @black; background: @light_grey * 0.15 + @white * 0.85; }
}
.all a { font-weight: bold; }
.current a {
background: @white; color: @black; border: 1px solid (@light_grey * 0.25 + @white * 0.75); border-right: none; border-left: 5px solid @bg;
padding-left: 10px;
}
}
}
/* Ads > Show */
#ad {
div.header {
overflow: hidden;
h3 { font-size: 16px; margin: 0 0 3px; }
small {
a.category { font-weight: bold; color: @accent_colour; }
span.networks img { position: relative; top: 3px; }
}
span.brand {
float: right; color: @white;
a.brand_name { font-weight: bold; color: @accent_colour; }
}
}
div.content {
padding: 0; position: relative;
a.toggle_size {
display: block; .border_radius(3); background-color: @black; padding: 0 5px 0 26px;
background-position: 5px center; background-repeat: no-repeat; text-decoration: none; margin: 5px 5px 0 0;
position: absolute; top: 0; right: 0; line-height: 25px; z-index: 45;
}
img.creative { margin: 0 auto; max-width: 540px; display: block; }
object { position: relative; z-index: 44; }
object.video { line-height: 0; font-size: 0; }
object embed { position: relative; z-index: 45; line-height: 0; font-size: 0; }
}
div.content.not_video {
padding: 40px; text-align: center;
* { margin-left: auto; margin-right: auto; }
object.flash { margin-bottom: 0; }
}
div.footer {
padding: 0;
div.vote_views {
padding: 5px 10px; overflow: hidden;
div.share { float: right; margin: 2px 0 0 0; }
#login_register_msg, #encourage_vote_msg { line-height: 22px; font-weight: bold; color: @black; }
}
}
}
#sidebar {
#meta {
table {
margin: 0;
tr:last-child td { padding-bottom: 0; }
td {
padding: 0 0 5px;
ul.networks {
margin: 0; padding: 0;
li {
list-style: none; display: inline;
}
li {
}
}
}
td.label { color: @grey; white-space: nowrap; width: 1%; text-align: right; padding-right: 5px; }
}
}
}
/* Voting */
div.voted {
font-size: 12px; line-height: 22px; color: @black; display: inline-block; font-weight: bold;
img { float: left; margin-right: 5px; padding: 3px; .border_radius(3); }
}
#voted_up {
img { background: @colour_positive * 0.66 + @bg * 0.15; }
}
#voted_down {
img { background: @colour_negative * 0.66 + @bg * 0.15; }
}
#encourage_comment {
display: inline-block; line-height: 22px; font-weight: bold;
}
#vote {
overflow: hidden; font-size: 12px; line-height: 22px; color: @black; float: left;
a {
color: @white; font-weight: bold; overflow: hidden; display: block;
width: 16px; text-decoration: none; text-align: center; font-size: 10px; padding: 3px; text-transform: uppercase;
}
a.up {
float: left; background: @colour_positive * 0.66 + @bg * 0.15; .border_radius_left(3);
:hover { background: @colour_positive * 0.85 + @bg * 0.15; }
}
a.down {
float: left; background: @colour_negative * 0.66 + @bg * 0.15; .border_radius_right(3);
margin: 0 5px 0 1px;
:hover { background: @colour_negative * 0.85 + @bg * 0.15; }
}
}
#vote.disabled {
a.up {
background: (@colour_positive * 0.66 + @bg * 0.15) * 0.15 + @grey * 0.85;
:hover { background: (@colour_positive * 0.85 + @bg * 0.15) * 0.25 + @grey * 0.75; }
}
a.down {
background: (@colour_negative * 0.66 + @bg * 0.15) * 0.15 + @grey * 0.85;
:hover { background: (@colour_negative * 0.85 + @bg * 0.15) * 0.25 + @grey * 0.75; }
}
}
/* Panels */
div.panel {
margin: 0 0 20px; position: relative; .box_shadow(0, 0, 3, @light_grey * 0.66 + @white * 0.33); .border_radius(3);
> div.header {
background: @bg url('/images/panel_header_bg.png') repeat-x top left; border-bottom: 1px solid (@bg * 0.66 + @black * 0.33);
padding: 5px 10px 4px; .border_radius_top(3); min-height: 18px;
h2 { font-size: 16px; margin: 0; color: @white; .text_shadow(1, 1, 0, @bg * 0.66 + @black * 0.33); }
h3 { color: @white; font-size: 14px; margin: 0; line-height: 18px; .text_shadow(1, 1, 0, @bg * 0.66 + @black * 0.33); }
small { display: block; font-size: 12px; color: @light_grey * 0.25 + @white * 0.75; }
span.filter {
float: left; display: block; overflow: hidden; position: relative; z-index: 5;
a {
margin: 0 1px 0 0; display: block; float: left; padding: 0 8px; height: 18px; font-weight: bold; font-size: 10px; line-height: 18px;
text-transform: uppercase; background: url('/images/transparent_backgrounds/black_50.png'); color: @light_grey; text-decoration: none; position: relative; z-index: 3;
}
a:first-child { .border_radius_left(2); }
a:last-child { .border_radius_right(2); margin-right: 0; }
a.active { background: @white; color: @black; z-index: 4; }
a:hover { color: @white; }
a.active:hover { color: @black; }
}
span.filter.dropdown {
margin: 0; position: relative; overflow: visible;
a {
.border_radius(2); background: @white; color: @black; margin: 0; position: relative; padding-right: 25px;
img { float: left; margin: 4px 5px 0 0; }
b.arrow {
float: right; display: block; height: 0; width: 0; border: 5px solid transparent; border-top: 5px solid @black; border-bottom: none;
position: absolute; top: 6px; right: 10px;
}
:hover {
background: @accent_colour; color: @white;
b.arrow { border-top: 5px solid @white; }
}
}
ul {
position: absolute; top: 100%; left: 0; margin: 1px 0 0; padding: 0; background: @white; .border_radius(2);
.box_shadow(0, 1, 1, @black);
li {
list-style: none; display: block; padding: 0; margin: 0;
a {
display: block; height: 18px; line-height: 18px; color: @black; font-size: 10px; text-transform: uppercase; background: transparent;
border-bottom: 1px solid (@light_grey * 0.66 + @white * 0.33); float: none; margin: 0; .border_radius(0); white-space: nowrap;
:hover { background: url('/images/transparent_backgrounds/accent_colour_25.png'); color: @black; }
}
}
li:last-child {
a { border: none; }
}
}
}
span.filter.dropdown.sort { float: left; margin: 0 0 0 10px; }
span.filter.dropdown.localisation { float: left; margin: 0 0 0 10px; }
a.more {
float: right; color: @white; .text_shadow(1, 1, 0, @bg * 0.66 + @black * 0.33); font-size: 14px; font-weight: bold;
position: relative; top: 2px;
:hover { text-decoration: none; }
}
}
> div.content {
background: @white; padding: 10px;
.no_padding { padding: 0; }
}
> div.footer {
background: @light_grey * 0.33 + @white * 0.66; border-top: 1px solid (@light_grey * 0.5 + @white * 0.5);
padding: 4px 10px 5px; .border_radius_bottom(3);
}
}
div.panel.no_footer div.content { .border_radius_bottom(3); }
div.panel.no_header div.content { .border_radius_top(3); }
div.panel.collapsable {
div.header {
cursor: pointer;
b.toggle { float: right; border: 5px solid transparent; border-bottom: 5px solid @white; border-top: none; display: block; width: 0; height: 0; margin: 6px 0 0 0; }
}
div.header:hover {
background-color: @bg * 0.75 + @white * 0.25;
}
}
div.panel.collapsed {
div.header {
border-bottom: none; .border_radius(3);
b.toggle { border-bottom: none; border-top: 5px solid @white; }
}
div.blank { border-bottom: none; .border_radius_bottom(3); }
div.content, div.footer { display: none; }
}
/* Sidebar Actions */
#sidebar {
#actions {
.box_shadow(0, 0, 0, transparent);
div.content {
background: url('/images/transparent_backgrounds/accent_colour_10.png'); text-align: center;
p.endorsement {
margin: 0 0 10px; font-size: 14px; font-weight: bold;
small { font-weight: normal; line-height: inherit; margin: 10px 0 0; }
:last-child { margin: 0; }
}
div.share { margin: 5px 0 0; }
a.button {
font-size: 16px; line-height: normal; height: auto; padding: 5px 10px 5px 35px; font-weight: bold; margin: 0; position: relative;
img { position: absolute; top: 3px; left: 6px; }
}
div.flash.notice {
margin: 10px 0 0; font-size: 22px;
small { font-weight: normal; margin: 0 0 10px; }
}
div.flash.notice.done { margin: 0; }
small {
display: block; margin: 10px 0 0; font-size: 11px; color: #808080; line-height: 12px;
img.favicon { vertical-align: middle; }
}
div.blank {
border: none; background: none; padding: 10px 0 0; border-top: 1px solid (@accent_colour * 0.5 + @white * 0.5);
margin: 10px 0 0;
}
}
}
}
/* People Lists */
ul.people {
margin: 0; padding: 10px 0 0 10px; background: @white;
> li {
display: block; margin: 0 10px 10px 0; float: left; padding: 2px; width: 57px; position: relative;
.border_radius(2); background: @white; list-style: none; border: 1px solid (@light_grey * 0.33 + @white * 0.66);
a.avatar {
display: block; width: 59px; height: 59px; overflow: hidden;
img { width: 100%; height: 100%; }
}
a.name { display: block; font-size: 10px; text-align: center; }
:hover {
background: @accent_colour;
a.name { color: @white; }
}
}
}
ul.people.list {
padding: 0;
> li {
margin: 0 0 10px; padding: 0 0 10px; overflow: hidden; float: none; width: auto; .border_radius(0);
border: none; border-bottom: 1px solid (@light_grey * 0.33 + @white * 0.66);
span.points {
float: right; display: block; padding: 5px; background: @light_grey * 0.15 + @white * 0.85; line-height: 1;
text-align: center; width: 50px; height: 30px; .border_radius(3); margin: 0 0 0 10px;
strong { display: block; color: @black; font-size: 16px; margin: 2px 0 0; }
label { color: @grey; text-transform: uppercase; font-size: 10px; }
label.long { display: block; }
label.short { display: none; }
}
a.avatar { float: left; width: 40px; height: 40px; }
a.name { font-size: 14px; font-weight: bold; margin: 0 0 0 50px; text-align: left; }
a.name.long { display: inline; }
a.name.short { display: none; }
span.networks {
display: block; margin: 0 0 0 50px;
img.favicon { vertical-align: middle; }
}
:hover {
background: transparent;
a.name { color: @accent_colour * 0.85 + @black * 0.15; }
}
:last-child { padding-bottom: 0; border-bottom: none; margin-bottom: 0; }
}
}
ul.people.list.small {
> li {
span.points {
padding: 3px 6px; height: 18px; font-size: 9px; line-height: 17px; width: 60px;
strong { font-size: 12px; margin: 0; display: inline; }
label { font-size: 9px; }
label.long { display: none; }
label.short { display: inline; }
}
a.avatar { width: 24px; height: 24px; }
a.name { display: inline; line-height: 24px; margin: 0 0 0 5px; font-size: 12px; height: 24px; }
a.name.long { display: none; }
a.name.short { display: inline; }
span.networks { display: inline; margin: 0; }
:last-child { padding-bottom: 0; border-bottom: none; margin-bottom: 0; }
}
}
ul.people.tiled {
> li {
width: 28px; padding: 2px;
a.avatar { width: 24px; height: 24px; background: @white; padding: 2px; }
a.name, small, span.networks, span.points { display: none; }
}
}
/* Comments */
#comments {
ul {
margin: 0 0 20px; padding: 0;
li {
display: block; list-style: none; padding: 0; margin: 0 0 10px;
span.meta {
margin: 0; overflow: hidden; display: block;
small { font-size: 12px; color: @light_grey; float: right; line-height: 16px; display: inline-block; }
a.avatar {
display: inline-block; height: 16px; width: 16px; position: relative; top: 3px;
img { height: 100%; width: 100%; }
}
a.name { font-weight: bold; line-height: 16px; display: inline-block; }
span.inactive { color: @grey; font-weight: bold; line-height: 16px; display: inline-block; }
}
b.tail {
display: block; width: 0; height: 0; margin: 3px 0 0 10px; border: 5px solid transparent; border-top: none;
border-bottom: 5px solid @white; position: relative; z-index: 2;
}
blockquote {
margin: 0; padding: 10px; .border_radius(3); font-style: normal; background: @white;
color: @dark_grey; .box_shadow(0, 0, 3, @light_grey * 0.66 + @white * 0.33);
}
}
}
form {
margin: 0;
textarea { width: 500px; }
}
}
/* Sidebar Categories */
#sidebar {
#categories {
margin: 0 0 20px;
width: auto;
p { margin: 0; }
}
}
#sidebar {
#ads > ul li, #recommendations > ul li {
width: 81px;
div.thumbnail {
a.thumbnail { height: 60px; width: 81px; }
}
div.text {
a.title { font-size: 11px; height: 14px; line-height: 14px; }
small { display: none; }
}
}
#brands > ul li {
width: 55px;
div.thumbnail {
a.thumbnail {
height: 45px; width: 45px;
img { max-height: 45px; max-width: 45px; }
}
}
div.text { display: none; }
}
}
/* My Account */
#accounts_controller {
#top {
#page_title {
#page_options {
a.button.public_profile {
float: right; font-size: 16px; line-height: 1; height: auto; padding: 8px 35px 8px 15px; position: relative;
b.arrow { display: block; height: 0; width: 0; position: absolute; top: 10px; right: 15px; border: 6px solid transparent; border-right: none; border-left: 6px solid @white; margin: 0; }
}
a.button.goto_dashboard {
float: right; font-size: 16px; line-height: 1; height: auto; padding: 8px 15px 8px 35px; margin-right: 5px; position: relative;
b.arrow { display: block; height: 0; width: 0; position: absolute; top: 10px; left: 15px; border: 6px solid transparent; border-left: none; border-right: 6px solid @white; margin: 0; }
}
}
}
}
#account_nav {
float: left; width: 200px; margin: 0 20px 0 0;
ul.nav {
margin: 0; padding: 0;
li {
margin: 0 0 5px; display: block; list-style: none; padding: 0;
a {
display: block; height: 30px; text-decoration: none; color: @white;
b {
border: 15px solid transparent; border-right: none; border-left: 10px solid transparent; width: 0;
height: 0; float: right; display: none;
}
span {
.border_radius(3); background: @bg; display: block;
line-height: 30px; padding: 0 10px; font-size: 14px; font-weight: bold; margin: 0 10px 0 0;
}
}
:hover {
a {
color: @white;
b { border-left-color: @bg; display: block; }
span { background: @bg; .border_radius_right(0); }
}
}
}
li.current a {
b { border-left-color: @accent_colour; display: block; }
span { background: @accent_colour; color: @white; .border_radius_right(0); }
}
}
}
#main {
> div {
margin: 0 0 20px;
form { margin: 0; }
}
#profile {
a.avatar {
float: left; display: block;
width: 70px; overflow: hidden; position: relative; text-decoration: none;
img { width: 100%; }
span {
display: block; line-height: 1; padding: 3px; margin: 5px 0 0; color: @white; background: @accent_colour;
.border_radius(3); .text_shadow(1, 1, 0, @grey);
text-align: center; font-size: 10px; font-weight: bold; text-transform: uppercase;
}
}
form {
margin: 0 0 0 90px;
h4 { margin: 10px 0 20px; border-bottom: 1px solid (@light_grey * 0.5 + @white * 0.5); padding: 0; color: @bg; font-size: 16px; }
ul.choices {
li { width: 30%; }
}
div.extra { margin-top: 20px; }
}
}
#networks {
ul { margin: 0 -10px -10px 0; padding: 0; overflow: hidden;
li:hover
{
background: @light_grey; display: block; float: left; width: 180px;
padding: 10px; margin: 0 10px 10px 0; list-style: none; .border_radius(3);
position: relative;
* { line-height: normal; }
img { vertical-align: middle; float: left; }
.name { font-weight: bold; font-size: 14px; display: block; margin: -2px 0 0 42px; }
small {
font-size: 12px; color: @grey; display: block; margin-left: 42px;
strong { color: @black; font-weight: normal; }
}
:hover {
}
}
li.installed {
background: @white;
border: 2px solid @accent_colour; padding: 8px;
}
li.unavailable {
.name { color: @black; }
:hover {
background: @light_grey;
}
}
li:hover {
background: @light_grey * 0.5 + @white * 0.5;
}
}
}
}
}
/* Shopping Style Panel */
#shopping_style {
div.header a.button.small { float: right; }
div.content {
p {
margin: 0 0 10px;
label { text-transform: uppercase; font-size: 11px; display: block; color: @bg; font-weight: bold; }
span { color: @black; }
span.toggle { white-space: nowrap; color: @grey; }
:last-child { margin: 0; }
}
p.more { text-align: left; font-weight: normal; }
p.less { display: none; margin: 0; }
}
}
/* People Controller */
#people_controller.index {
#main {
div.panel {
float: left; width: 300px; margin: 0 20px 0 0;
:last-child { margin-right: 0; }
}
}
}
#people_controller.show {
#person_overview, #shopping_style {
a.button.small {
}
}
#content {
#shopping_style {
float: left; width: 240px; margin: 0 20px 0 0;
}
#main { width: 360px; }
}
}
/* Search Results */
#search_results {
margin: 0 0 20px;
li {
:hover {
small { color: @white * 0.75 + @accent_colour * 0.25; }
}
}
}
#search {
div.content {
padding: 20px;
form {
margin: 0; float: none;
span.submit_and_options {
display: block;
}
}
p { margin: 0 0 15px; }
h4 { font-weight: normal; margin: 0 0 5px; }
}
}
/* Recommendations */
#recommendations {
div.browse {
margin: 0; padding: 0; background: none;
ul { min-height: 0; .border_radius(0); }
}
}
/* Blank States */
div.blank {
padding: 20px; background: @bg * 0.05 + @blue * 0.05 + @white * 0.9; position: relative;
border: 1px solid (@bg * 0.1 + @blue * 0.1 + @white * 0.8); z-index: 1;
h4 { font-size: 18px; margin: 0 0 10px; }
h4:last-child { margin: 0; }
p { font-size: 16px; margin: 0 0 10px; }
p:last-child { margin: 0; }
p.with_list_number.large {
span { margin-left: 48px; display: block; color: @white; }
}
p.earn span { font-size: 22px; color: @white; line-height: 48px; font-weight: bold; }
a { white-space: nowrap; }
a.hide {
position: absolute; top: -5px; right: -5px; display: block; height: 16px; width: 16px; padding: 3px; background: #E7E9F6; .border_radius(99);
}
}
div.blank.small {
padding: 10px 20px;
h4 { font-weight: normal; font-size: 16px; }
p { margin: 0; }
}
div.blank.tiny {
padding: 10px 20px;
h4 { font-weight: normal; font-size: 14px; }
p { margin: 0; font-size: 12px; }
}
div.blank.rounded {
.border_radius(3); margin: 0 0 20px;
}
div.blank.rounded.bottom { .border_radius_top(0); }
div.blank.with_border_bottom { border-bottom: 1px solid (@bg * 0.1 + @blue * 0.1 + @white * 0.8); }
div.blank.no_border_top { border-top: none; }
div.blank.no_border_bottom { border-bottom: none; }
div.blank.no_side_borders { border-right: none; border-left: none; }
div.panel {
div.blank {
padding: 10px 20px; overflow: hidden; margin: 0;
h4 { font-weight: normal; font-size: 14px; }
p, ul { margin: 0 0 10px; font-size: 12px; }
p:last-child, ul:last-child { margin: 0; }
}
}
/* Sidebar Browse */
#sidebar {
div.panel {
div.content.browse {
padding: 0; margin: 0;
> ul {
min-height: 0; .border_radius(0);
> li {
div.thumbnail {
a.thumbnail { padding: 5px; }
img.marker.media_type { top: 48px; left: 8px; }
}
div.footer {
a.title, a.name { font-size: 11px; font-weight: normal; }
}
}
}
}
div.content.browse.ads > ul > li {
width: 93px;
> div.thumbnail a.thumbnail { width: 83px; height: 62px; }
}
div.content.browse.brands {
.border_radius(3);
> ul {
background: none;
> li {
width: 52px;
> div.thumbnail {
padding: 3px;
a.thumbnail { width: 42px; height: 42px; padding: 2px; }
}
li.active { background: @accent_colour; }
}
}
}
div.footer {
div.info { float: none; }
div.pagination { float: none; margin: 3px 0 0; }
}
}
}
/* List Numbers */
label.list_number {
float: left; background: url('/images/transparent_backgrounds/black_15.png'); padding: 2px; width: 24px; height: 24px; display: block;
.border_radius(99);
b {
display: block; font-weight: bold; font-size: 14px; color: @white; background: @accent_colour; height: 20px; width: 20px; line-height: 20px;
text-align: center; .border_radius(99); .text_shadow(1, 1, 0px, (@accent_colour * 0.75 + @black * 0.25));
border: 2px solid @white;
}
}
label.list_number.large {
padding: 4px; width: 48px; height: 48px; .border_radius(99); position: relative; left: -10px;
b {
font-size: 28px; height: 40px; width: 40px; .border_radius(99); line-height: 40px;
.text_shadow(2, 2, 0px, (@accent_colour * 0.75 + @black * 0.25)); border-width: 4px;
}
}
/* Dashboard */
#dashboard_controller {
#ads {
span.filter.state { float: right; }
}
#sidebar {
#shopping_style div.content {
p.less { display: block; }
p.more { display: none; }
}
#influences {
div.header {
padding-bottom: 0;
ul.tabs {
position: relative; top: 1px; z-index: 3;
li {
margin: 0 5px 0 0;
a {
border: none; background: url('/images/transparent_backgrounds/white_75.png');
:hover { color: @black; }
}
}
li.active {
a {
background: @white; border: none;
:hover { color: @black; }
}
}
}
}
div.tab_content {
overflow: hidden; padding: 0;
> ul {
padding: 10px 10px 0; max-height: 280px; min-height: 120px; overflow-y: scroll; .border_radius_bottom(3px);
}
}
div.footer {
form {
p {
margin: 0 0 5px;
img.marker { float: right; margin: 5px 0 0 0; }
span.invitee {
line-height: 26px; padding: 3px 3px 0; font-size: 14px;
small { color: @grey; font-size: 12px; }
}
}
p.indent { margin-left: 36px; }
p.submit { margin-top: 10px; }
}
}
}
}
div.panel.full {
> div.content {
margin: 0; padding: 0; background: none;
ul {
li {
width: 148px;
div.thumbnail {
img.marker.media_type { top: 90px; }
a.thumbnail { width: 138px; height: 104px; }
}
}
}
}
}
#people {
form {
padding: 0 0 5px;
input { width: 225px; float: left; margin: 0 5px 0 0; }
a.button { height: 23px; line-height: 23px; width: 60px; padding: 0; text-align: center; }
}
}
}
/* Remove Pages Titles when Browsing */
#ads_controller, #brands_controller {
#page_title { display: none; }
}
/* Brands > Show */
#brands_controller.show {
#ads {
div.filters {
h3 { font-size: 16px; margin: 0; }
span.show { float: right; }
span.filter.dropdown.localisation { float: right; margin: 0 0 0 10px; }
span.filter.state { float: right; margin: 0 0 0 10px; }
}
}
}
/* FAQ */
#pages_controller.faq {
#answers {
h3 { margin-top: 20px; padding-top: 20px; border-top: 1px solid (@light_grey * 0.75 + @white * 0.25); }
h3.first { margin-top: 0; padding-top: 0; border: none; }
}
#questions {
div.content {
padding: 20px;
ul {
margin: 0; padding: 0;
li {
margin: 0 0 10px; list-style: none; display: block; padding: 0;
a { font-size: 14px; }
}
li:last-child {
margin: 0;
}
}
}
}
}
/* Person Overview */
#person_overview {
padding: 20px 10px; position: relative; z-index: 25;
#person {
float: left; width: 620px;
a.avatar {
display: block; float: left; width: 60px; height: 60px;
img { height: 100%; width: 100%; }
}
> div {
margin: 0 0 0 75px; color: @white; font-size: 14px; .text_shadow(1, 1, 0, @bg * 0.66 + @black * 0.33);
}
div.name {
h2 {
margin: 0 0 5px; display: inline;
a {
font-size: 20px; font-weight: bold; .text_shadow(1, 1, 0, @bg * 0.66 + @black * 0.33);
line-height: 1; color: @white; text-decoration: none;
:hover { text-decoration: underline; }
}
a.button.small {
font-size: 10px;
:hover { text-decoration: none; }
}
}
span.points {
float: right; display: block; padding: 5px 10px; .border_radius(2); text-align: center; background: @white; position: relative;
min-width: 45px;
strong { color: @black; font-weight: bold; font-size: 24px; line-height: 1; display: block; .text_shadow(0, 0, 0, transparent); }
label { font-size: 9px; text-transform: uppercase; color: @grey; display: block; .text_shadow(0, 0, 0, transparent); font-weight: bold; }
}
span.points.with_redeem {
.border_radius_bottom(0);
a.button {
display: block; text-align: center; .border_radius_top(0); font-size: 10px; font-weight: bold; padding: 0;
position: absolute; height: 18px; left: 0; right: 0; bottom: -19px; line-height: 18px; text-transform: uppercase; border: none;
}
}
div.options { margin: 0; }
}
div.meta {
color: @white * 0.66 + @bg * 0.33;
span { color: @white; }
label { color: @white * 0.66 + @bg * 0.33; }
ul.networks {
display: inline; margin: 0; padding: 0;
li {
display: inline; line-height: 1;
img { position: relative; vertical-align: middle; top: -1px; }
}
}
}
div.extra {
font-size: 12px; margin-top: 20px; margin-bottom: 20px;
span.toggle {
.text_shadow(1, 1, 0, @bg * 0.66 + @black * 0.33);
a { font-size: 10px; font-weight: bold; text-transform: uppercase; text-decoration: none; color: @accent_colour; }
b.arrow { display: inline-block; width: 0; height: 0; border: 5px solid transparent; position: relative; top: -2px; }
}
#less_info {
span.toggle {
b.arrow { border-top: 5px solid @accent_colour; border-bottom: 0; }
}
}
#more_info {
span.toggle {
float: right;
b.arrow { border-bottom: 5px solid @accent_colour; border-top: 0; }
}
h4 {
color: @white; margin: 0 0 10px 0; border-bottom: 1px solid (@white * 0.25 + @bg * 0.75); .text_shadow(1, 1, 0, @bg * 0.66 + @black * 0.33);
span { font-size: 12px; }
}
p {
margin: 0 0 5px;
label { display: block; float: left; width: 120px; color: @white * 0.66 + @bg * 0.33; }
span { display: block; margin: 0 0 0 130px; }
}
p:last-child { margin: 0; }
}
}
div.login {
margin: 0 0 0 75px;
a.button { font-weight: bold; }
}
}
}
/* Dashboard Nav */
#dashboard_nav {
position: absolute; bottom: 0; left: 10px; margin: 0; padding: 0; overflow: hidden;
li {
display: block; float: left; margin: 0 5px 0 0;
a {
display: block; height: 28px; padding: 0 10px; line-height: 28px; .border_radius_top(2);
text-decoration: none; color: @white; background: url('/images/transparent_backgrounds/accent_colour_30.png'); font-size: 14px;
font-weight: bold;
:hover { background: url('/images/transparent_backgrounds/accent_colour_45.png'); }
}
}
li.active {
a {
background: @white; color: @black;
:hover { color: @black; }
}
}
}
/* Dwellometer */
#dwellometer {
z-index: 45; float: right; .box_shadow(0, 0, 0, transparent); margin: 0;
div.content {
text-align: center; position: relative;
object, object embed { position: relative; z-index: 46; line-height: 0; }
div.title {
position: absolute; bottom: 10px; left: 0; right: 0; z-index: 50;
img { width: 120px; display: block; margin: 0 auto; position: relative; left: -5px; }
}
}
}
/* Activity Stream */
#activity {
div.content {
ul.events {
padding: 0; margin: 0 0 -10px;
li {
margin: 0; padding: 10px 0; border-bottom: 1px solid (@light_grey * 0.33 + @white * 0.66);
list-style: none; overflow: hidden;
small.meta {
font-size: 12px; color: @light_grey; float: right;
}
a.button { float: right; margin: 0 0 10px 10px; }
a.avatar, a.logo, a.thumbnail {
height: 32px; display: block; float: left;
img { width: 100%; height: 100%; }
}
a.avatar, a.logo, a.icon { width: 32px; }
a.thumbnail { width: 42px; }
div.symbols {
float: left; overflow: hidden;
b {
display: block; float: left; margin: 10px 5px 0;
img { height: 12px; width: 12px; }
}
b.voted { margin: 10px 3px 0; padding: 2px; .border_radius(2); }
b.voted.for { background: @colour_positive * 0.33 + @white * 0.66; }
b.voted.against { background: @colour_negative * 0.33 + @white * 0.66; }
}
/* Temporarily removed avatar and symbol */
/* div.symbols a.agent, b { display: none; }*/
div.description {
font-size: 12px; color: @grey;
a.agent { font-weight: bold; }
}
div.comment {
margin-top: 2px;
b.tail {
display: block; margin: 0 0 0 10px; width: 0; height: 0; border: 5px solid transparent;
border-top: none; border-bottom: 5px solid (@light_grey * 0.25 + @white * 0.75);
}
blockquote {
margin: 0; font-style: normal; color: @dark_grey;
.border_radius(3); background: @light_grey * 0.25 + @white * 0.75; padding: 5px 10px;
span.view_comment {
color: @grey;
}
}
}
div.content {
overflow: hidden;
}
}
li.new_comment.ad, li.endorsed.ad, li.voted {
div.description, div.content { margin-left: 106px; }
/* div.description, div.content { margin-left: 53px; }*/
}
li.new_comment.brand, li.replied_to, li.endorsed.brand, li.connected, li.sn_setup {
div.description, div.content { margin-left: 96px; }
/* div.description, div.content { margin-left: 43px; }*/
}
li.replied_to {
div.content {
a.thumbnail, a.logo { margin-top: 7px; }
}
}
li.replied_to.ad {
div.content {
div.comment { margin-left: 52px; }
}
}
li.replied_to.brand {
div.content {
div.comment { margin-left: 42px; }
}
}
li.voted div.description span.action { .border_radius(2); color: @dark_grey; padding: 0 3px; white-space: nowrap; }
li.voted.for div.description span.action { background: @colour_positive * 0.15 + @white * 0.85; }
li.voted.against div.description span.action { background: @colour_negative * 0.15 + @white * 0.85; }
li:first-child { padding-top: 0; }
li:last-child { border-bottom: none; }
li:hover div.content div.comment blockquote span.view_comment {
}
}
}
}
/* Login/Register Modal */
#login_register {
div.location_select,
div.location_search { margin-left: 130px; }
h3 {
small { font-size: 14px; font-weight: normal; display: block; color: @grey; text-align: left; margin: 0; display: block; }
}
}
/* Contact Form in Pages */
#pages_controller {
#sidebar {
#contact {
margin: 15px 0 0;
form {
label { text-align: left; float: none; width: auto; font-size: 12px; font-weight: bold; line-height: 1; margin: 0 0 5px; }
p.submit.indent {
margin: 0;
span.with_cancel { display: none; }
}
}
}
}
}
/* Exclusive Offers */
#offers {
div.content {
a.gift {
display: block; text-align: center;
img { height: 100px; }
}
}
}
div.browse {
margin: 0 0 20px;
&.class {
padding: 0;
}
div.header {
padding: 10px 10px 9px; text-align: left; background: @bg url('/images/panel_header_bg.png') repeat-x top left;
border-bottom: 1px solid (@bg * 0.66 + @black * 0.33); line-height: 1; height: 18px;
.border_radius_top(3); color: @light_grey;
h3 { font-size: 16px; margin: 0; color: @white; .text_shadow(1, 1, 0, @bg * 0.66 + @black * 0.33); }
span.filter {
float: left; display: block; overflow: hidden; position: relative; z-index: 5;
a {
margin: 0 1px 0 0; display: block; float: left; padding: 0 8px; height: 18px; font-weight: bold; font-size: 10px; line-height: 18px;
text-transform: uppercase; background: url('/images/transparent_backgrounds/black_50.png'); color: @light_grey; text-decoration: none; position: relative; z-index: 3;
.active {
background: @white; color: @black; z-index: 4;
:hover { color: @black; }
}
:hover { color: @white; }
:first-child { .border_radius_left(2); }
:last-child { .border_radius_right(2); margin-right: 0; }
}
}
span.filter.dropdown {
margin: 0; position: relative; overflow: visible;
a {
.border_radius(2); background: @white; color: @black; margin: 0; position: relative; padding-right: 25px;
img { float: left; margin: 4px 5px 0 0; }
b.arrow {
float: right; display: block; height: 0; width: 0; border: 5px solid transparent; border-top: 5px solid @black; border-bottom: none;
position: absolute; top: 6px; right: 10px;
}
:hover {
background: @accent_colour; color: @white;
b.arrow { border-top: 5px solid @white; }
}
}
ul {
position: absolute; top: 100%; left: 0; margin: 1px 0 0; padding: 0; background: @white; .border_radius(2);
.box_shadow(0, 1, 1, @black);
li {
list-style: none; display: block; padding: 0; margin: 0;
a {
display: block; height: 18px; line-height: 18px; color: @black; font-size: 10px; text-transform: uppercase; background: transparent;
border-bottom: 1px solid (@light_grey * 0.66 + @white * 0.33); float: none; margin: 0; .border_radius(0); white-space: nowrap;
:hover { background: url('/images/transparent_backgrounds/accent_colour_25.png'); color: @black; }
}
:last-child {
a { border: none; }
}
}
}
}
span.filter.dropdown.sort { float: left; margin: 0 0 0 10px; }
span.filter.dropdown.localisation { float: left; margin: 0 0 0 10px; }
a.more {
float: right; color: @white; .text_shadow(1, 1, 0, @bg * 0.66 + @black * 0.33); font-size: 14px; font-weight: bold;
position: relative; top: 2px;
:hover { text-decoration: none; }
}
}
> ul {
margin: 0; background: @white; padding: 10px 0 0 10px; .border_radius(3); position: relative;
li {
display: block; float: left; list-style: none; margin: 0 10px 10px 0; padding: 5px; position: relative;
background: @white; width: 130px; border: 1px solid (@light_grey * 0.33 + @white * 0.66); .border_radius(2);
a.remove {
position: absolute; height: 16px; width: 16px; padding: 3px; background: @accent_colour;
.border_radius(99); display: none; z-index: 3; top: -8px; right: -8px;
img { vertical-align: middle; }
}
div.thumbnail {
.border_radius_top(3); position: relative; z-index: 3;
.marker {
position: absolute; padding: 2px; .border_radius(2); z-index: 3;
background: url('/images/transparent_backgrounds/white_75.png'); height: 12px; width: 12px;
}
.marker.coupon {
height: auto; width: auto; top: 10px; right: -3px; padding: 0; background: transparent; overflow: hidden; position: absolute;
b {
display: block; height: 0; width: 0; float: left; border: 14px solid transparent; border-top: 14px solid @accent_colour;
border-bottom: none; border-right: none; float: left;
}
span {
color: @white; font-size: 10px; font-weight: bold; text-transform: uppercase; height: 14px; line-height: 14px; display: block;
padding: 0 4px 0 2px; background: @accent_colour; .text_shadow(1, 1, 0px, (@accent_colour * 0.75 + @black * 0.25)); margin: 0 0 0 14px;
}
}
.marker.video {
position: absolute; left: 50%; top: 50%; background: @white; width: 10px; height: 10px;
b { display: block; width: 0; height: 0; border: 5px solid transparent; border-left: 10px solid @black; border-right: none; }
}
.marker.endorsed_by_me { background: none; padding: 0; right: 0; bottom: -32px; .border_radius(2); background: @white; }
a.thumbnail {
display: block; overflow: hidden; position: relative; text-align: center;
img { position: relative; display: block; margin: auto; }
}
}
div.text {
margin: 3px 0 0; display: block;
a { text-decoration: none; }
a.title {
display: block; text-decoration: none; font-weight: bold; font-size: 12px; line-height: 16px;
white-space: nowrap; height: 16px; overflow: hidden;
:before {
display: block; height: 32px; width: 20px; content: " "; float: right; right: -15px; top: -8px;
background: @white; position: relative; z-index: 1; .box_shadow(-5, 0, 10, @white);
}
}
small {
font-size: 11px; line-height: 13px; color: @grey; display: block; height: 13px; overflow: hidden; white-space: nowrap;
a { font-weight: bold; }
:before {
display: block; height: 32px; width: 20px; content: " "; float: right; right: -15px; top: -8px;
background: @white; position: relative; z-index: 1; .box_shadow(-5, 0, 10, @white);
}
}
}
:hover {
background: @accent_colour;
a.remove { display: block; }
div.thumbnail {
a.marker.remove, a.marker.video {
b { display: inline-block; }
}
a.marker.video { .box_shadow(0, 0, 2, @black); }
}
div.text {
a { color: @white; }
a.title:before { background: @accent_colour; .box_shadow(-5, 0, 10, @accent_colour); }
small {
color: @white * 0.75 + @accent_colour * 0.25;
:before { background: @accent_colour; .box_shadow(-5, 0, 10, @accent_colour); }
}
}
div.footer a { color: @white; }
}
}
> li.ad div.thumbnail a.thumbnail {
width: 130px; height: 97px;
img { width: 100%; height: 100%; }
}
> li.brand div.thumbnail a.thumbnail {
width: 120px; height: 87px; padding: 5px; background: @white; .border_radius(2);
img { max-width: 120px; max-height: 87px; }
}
li.paginate {
margin-bottom: 0;
a {
display: block; position: relative; text-decoration: none; height: 131px;
div.arrow {
background: #81c153 url('/images/button_bg.png') repeat-x left top; border: 1px solid (@accent_colour * 0.75 + @black * 0.25);
height: 44px; .border_radius(99); width: 44px; margin: 0 auto; position: relative; top: 32px;
b { text-indent: -9000px; display: block; border: 10px solid transparent; width: 0; height: 0; position: relative; top: 12px; }
}
div.label {
position: absolute; bottom: 5px; left: 0; right: 0; line-height: 13px;
color: @accent_colour * 0.85 + @black * 0.15; text-decoration: none;
font-weight: bold; font-size: 12px; text-align: center;
}
:hover {
div.arrow { background: #abd56e url('/images/button_bg.png') repeat-x left -44px; }
}
}
:hover { background: transparent; }
}
li.paginate.previous a div b { border-right: 15px solid @white; border-left: none; left: 12px; }
li.paginate.next a div b { border-left: 15px solid @white; border-right: none; left: 16px; }
}
> div.footer {
padding: 9px 10px 10px; background: @light_grey * 0.75 + @white * 0.25; overflow: hidden;
border-top: 1px solid @light_grey; .border_radius_bottom(3);
div.info {
float: left; color: @grey;
strong { color: @black; font-weight: normal; }
}
div.pagination {
float: right;
> * {
display: inline-block; line-height: 1; padding: 0 6px; line-height: 18px; height: 18px; background: @white;
.border_radius(3); text-decoration: none; font-weight: bold;
font-size: 10px; text-transform: uppercase;
}
a { color: @grey; }
a:hover { color: @black; }
span.disabled { color: @light_grey; }
span.current { color: @white; background: @bg; border: none; }
span.current:hover { color: @white; }
}
}
}
div.browse.with_categories { margin: 0 0 0 160px; }
div.browse.with_options > ul { .border_radius_top(0); }
div.browse.with_footer > ul { .border_radius_bottom(0); }
/* Browse List */
div.browse.list {
> ul {
margin: 0; min-height: 320px;
padding: 10px 0 0 10px; overflow: hidden;
> li {
display: block; list-style: none; margin: 0 10px 10px 0; padding: 5px;
.border_radius(3); position: relative; line-height: normal;
.marker {
position: absolute; padding: 2px; .border_radius(2);
background: url('/images/transparent_backgrounds/white_75.png');
img { height: 12px; width: 12px; }
}
img.marker { height: 12px; width: 12px; }
span.marker.new {
color: black; left: -5px; top: -5px; background: none; background-color: @white * 0.1 + @yellow * 0.6 + @red * 0.3; line-height: 1; padding: 2px 5px;
font-weight: bold;
}
a.marker.media_type {
display: inline-block; text-decoration: none; top: 39px; left: 8px;
font-size: 10px;
b { font-weight: normal; margin: 0 0 0 2px; line-height: 1; display: none; }
img { vertical-align: middle; }
}
a.thumbnail {
float: left;
width: 68px; display: block; overflow: hidden;
border: 1px solid @light_grey;
:hover { border-color: @accent_colour; }
}
span.title_brand {
display: block; margin: 0 0 2px 75px;
a { margin: 0; display: inline; }
a.brand_name { font-weight: normal; font-size: 12px; }
}
a.ad_title {
font-weight: bold; font-size: 14px; margin: 0 0 0 75px; display: block;
}
a.brand_name {
font-weight: bold; font-size: 14px; margin: 0 0 0 75px; display: block;
}
small {
display: block; color: @grey; margin: 0 0 0 75px; font-size: 12px;
}
small.brand_name { display: inline; margin: 0; }
ul.chart {
margin: 0 0 0 80px;
height: 39px;
}
ul.networks {
margin: 3px 0 0 75px; padding: 0; overflow: hidden;
li { display: block; float: left; margin: 0 5px 0 0; line-height: 1; }
}
div.points {
display: none;
font-size: 12px; text-align: right;
label { color: @grey; }
}
a.remove { bottom: -3px; right: -3px; }
}
li.ad {
a.thumbnail { height: 51px; }
span.title_brand {
small.brand_name {
display: block;
}
}
}
li.brand {
a.thumbnail { height: 68px; }
}
}
}
div.browse.list.with_options ul { .border_radius_top(0); }
div.browse.list.with_footer ul { .border_radius_bottom(0); }
div.browse.list.cols_2 {
> ul {
> li {
width: 285px; float: left;
:hover {
background: @white;
}
}
}
}
div.browse.ads.list {
> ul {
> li {
height: 53px;
a.thumbnail {
height: 51px;
}
}
}
}
div.browse.brands.list {
> ul {
> li {
height: 68px;
a.thumbnail {
height: 66px;
}
}
}
}
/* Categories List */
#categories {
margin: 40px 0 0; width: 160px; float: left; position: relative; z-index: 1;
ul {
margin: 0; padding: 10px 0 0;
li {
list-style: none; margin: 0; padding: 0; font-size: 14px;
a { color: @grey; display: block; padding: 5px 10px 5px 15px; text-decoration: none; .border_radius_left(3); }
a:hover { color: @black; background: @light_grey * 0.15 + @white * 0.85; }
}
.all a { font-weight: bold; }
.current a {
background: @white; color: @black; border: 1px solid (@light_grey * 0.25 + @white * 0.75); border-right: none; border-left: 5px solid @bg;
padding-left: 10px;
}
}
}
/* Ads > Show */
#ad {
div.header {
overflow: hidden;
h3 { font-size: 16px; margin: 0 0 3px; }
small {
a.category { font-weight: bold; color: @accent_colour; }
span.networks img { position: relative; top: 3px; }
}
span.brand {
float: right; color: @white;
a.brand_name { font-weight: bold; color: @accent_colour; }
}
}
div.content {
padding: 0; position: relative;
a.toggle_size {
display: block; .border_radius(3); background-color: @black; padding: 0 5px 0 26px;
background-position: 5px center; background-repeat: no-repeat; text-decoration: none; margin: 5px 5px 0 0;
position: absolute; top: 0; right: 0; line-height: 25px; z-index: 45;
}
img.creative { margin: 0 auto; max-width: 540px; display: block; }
object { position: relative; z-index: 44; }
object.video { line-height: 0; font-size: 0; }
object embed { position: relative; z-index: 45; line-height: 0; font-size: 0; }
}
div.content.not_video {
padding: 40px; text-align: center;
* { margin-left: auto; margin-right: auto; }
object.flash { margin-bottom: 0; }
}
div.footer {
padding: 0;
div.vote_views {
padding: 5px 10px; overflow: hidden;
div.share { float: right; margin: 2px 0 0 0; }
#login_register_msg, #encourage_vote_msg { line-height: 22px; font-weight: bold; color: @black; }
}
}
}
#sidebar {
#meta {
table {
margin: 0;
tr:last-child td { padding-bottom: 0; }
td {
padding: 0 0 5px;
ul.networks {
margin: 0; padding: 0;
li {
list-style: none; display: inline;
}
li {
}
}
}
td.label { color: @grey; white-space: nowrap; width: 1%; text-align: right; padding-right: 5px; }
}
}
}
/* Voting */
div.voted {
font-size: 12px; line-height: 22px; color: @black; display: inline-block; font-weight: bold;
img { float: left; margin-right: 5px; padding: 3px; .border_radius(3); }
}
#voted_up {
img { background: @colour_positive * 0.66 + @bg * 0.15; }
}
#voted_down {
img { background: @colour_negative * 0.66 + @bg * 0.15; }
}
#encourage_comment {
display: inline-block; line-height: 22px; font-weight: bold;
}
#vote {
overflow: hidden; font-size: 12px; line-height: 22px; color: @black; float: left;
a {
color: @white; font-weight: bold; overflow: hidden; display: block;
width: 16px; text-decoration: none; text-align: center; font-size: 10px; padding: 3px; text-transform: uppercase;
}
a.up {
float: left; background: @colour_positive * 0.66 + @bg * 0.15; .border_radius_left(3);
:hover { background: @colour_positive * 0.85 + @bg * 0.15; }
}
a.down {
float: left; background: @colour_negative * 0.66 + @bg * 0.15; .border_radius_right(3);
margin: 0 5px 0 1px;
:hover { background: @colour_negative * 0.85 + @bg * 0.15; }
}
}
#vote.disabled {
a.up {
background: (@colour_positive * 0.66 + @bg * 0.15) * 0.15 + @grey * 0.85;
:hover { background: (@colour_positive * 0.85 + @bg * 0.15) * 0.25 + @grey * 0.75; }
}
a.down {
background: (@colour_negative * 0.66 + @bg * 0.15) * 0.15 + @grey * 0.85;
:hover { background: (@colour_negative * 0.85 + @bg * 0.15) * 0.25 + @grey * 0.75; }
}
}
#sidebar {
#ads > ul li, #recommendations > ul li {
width: 81px;
div.thumbnail {
a.thumbnail { height: 60px; width: 81px; }
}
div.text {
a.title { font-size: 11px; height: 14px; line-height: 14px; }
small { display: none; }
}
}
#brands > ul li {
width: 55px;
div.thumbnail {
a.thumbnail {
height: 45px; width: 45px;
img { max-height: 45px; max-width: 45px; }
}
}
div.text { display: none; }
}
}
/* My Account */
#accounts_controller {
#top {
#page_title {
#page_options {
a.button.public_profile {
float: right; font-size: 16px; line-height: 1; height: auto; padding: 8px 35px 8px 15px; position: relative;
b.arrow { display: block; height: 0; width: 0; position: absolute; top: 10px; right: 15px; border: 6px solid transparent; border-right: none; border-left: 6px solid @white; margin: 0; }
}
a.button.goto_dashboard {
float: right; font-size: 16px; line-height: 1; height: auto; padding: 8px 15px 8px 35px; margin-right: 5px; position: relative;
b.arrow { display: block; height: 0; width: 0; position: absolute; top: 10px; left: 15px; border: 6px solid transparent; border-left: none; border-right: 6px solid @white; margin: 0; }
}
}
}
}
#account_nav {
float: left; width: 200px; margin: 0 20px 0 0;
ul.nav {
margin: 0; padding: 0;
li {
margin: 0 0 5px; display: block; list-style: none; padding: 0;
a {
display: block; height: 30px; text-decoration: none; color: @white;
b {
border: 15px solid transparent; border-right: none; border-left: 10px solid transparent; width: 0;
height: 0; float: right; display: none;
}
span {
.border_radius(3); background: @bg; display: block;
line-height: 30px; padding: 0 10px; font-size: 14px; font-weight: bold; margin: 0 10px 0 0;
}
}
:hover {
a {
color: @white;
b { border-left-color: @bg; display: block; }
span { background: @bg; .border_radius_right(0); }
}
}
}
li.current a {
b { border-left-color: @accent_colour; display: block; }
span { background: @accent_colour; color: @white; .border_radius_right(0); }
}
}
}
#main {
> div {
margin: 0 0 20px;
form { margin: 0; }
}
#profile {
a.avatar {
float: left; display: block;
width: 70px; overflow: hidden; position: relative; text-decoration: none;
img { width: 100%; }
span {
display: block; line-height: 1; padding: 3px; margin: 5px 0 0; color: @white; background: @accent_colour;
.border_radius(3); .text_shadow(1, 1, 0, @grey);
text-align: center; font-size: 10px; font-weight: bold; text-transform: uppercase;
}
}
form {
margin: 0 0 0 90px;
h4 { margin: 10px 0 20px; border-bottom: 1px solid (@light_grey * 0.5 + @white * 0.5); padding: 0; color: @bg; font-size: 16px; }
ul.choices {
li { width: 30%; }
}
div.extra { margin-top: 20px; }
}
}
#networks {
ul { margin: 0 -10px -10px 0; padding: 0; overflow: hidden;
li:hover
{
background: @light_grey; display: block; float: left; width: 180px;
padding: 10px; margin: 0 10px 10px 0; list-style: none; .border_radius(3);
position: relative;
* { line-height: normal; }
img { vertical-align: middle; float: left; }
.name { font-weight: bold; font-size: 14px; display: block; margin: -2px 0 0 42px; }
small {
font-size: 12px; color: @grey; display: block; margin-left: 42px;
strong { color: @black; font-weight: normal; }
}
:hover {
}
}
li.installed {
background: @white;
border: 2px solid @accent_colour; padding: 8px;
}
li.unavailable {
.name { color: @black; }
:hover {
background: @light_grey;
}
}
li:hover {
background: @light_grey * 0.5 + @white * 0.5;
}
}
}
}
}
/* Shopping Style Panel */
#shopping_style {
div.header a.button.small { float: right; }
div.content {
p {
margin: 0 0 10px;
label { text-transform: uppercase; font-size: 11px; display: block; color: @bg; font-weight: bold; }
span { color: @black; }
span.toggle { white-space: nowrap; color: @grey; }
:last-child { margin: 0; }
}
p.more { text-align: left; font-weight: normal; }
p.less { display: none; margin: 0; }
}
}
/* People Controller */
#people_controller.index {
#main {
div.panel {
float: left; width: 300px; margin: 0 20px 0 0;
:last-child { margin-right: 0; }
}
}
}
#people_controller.show {
#person_overview, #shopping_style {
a.button.small {
}
}
#content {
#shopping_style {
float: left; width: 240px; margin: 0 20px 0 0;
}
#main { width: 360px; }
}
}
/* Search Results */
#search_results {
margin: 0 0 20px;
li {
:hover {
small { color: @white * 0.75 + @accent_colour * 0.25; }
}
}
}
#search {
div.content {
padding: 20px;
form {
margin: 0; float: none;
span.submit_and_options {
display: block;
}
}
p { margin: 0 0 15px; }
h4 { font-weight: normal; margin: 0 0 5px; }
}
}
/* Recommendations */
#recommendations {
div.browse {
margin: 0; padding: 0; background: none;
ul { min-height: 0; .border_radius(0); }
}
}
/* Blank States */
div.blank {
padding: 20px; background: @bg * 0.05 + @blue * 0.05 + @white * 0.9; position: relative;
border: 1px solid (@bg * 0.1 + @blue * 0.1 + @white * 0.8); z-index: 1;
h4 { font-size: 18px; margin: 0 0 10px; }
h4:last-child { margin: 0; }
p { font-size: 16px; margin: 0 0 10px; }
p:last-child { margin: 0; }
p.with_list_number.large {
span { margin-left: 48px; display: block; color: @white; }
}
p.earn span { font-size: 22px; color: @white; line-height: 48px; font-weight: bold; }
a { white-space: nowrap; }
a.hide {
position: absolute; top: -5px; right: -5px; display: block; height: 16px; width: 16px; padding: 3px; background: #E7E9F6; .border_radius(99);
}
}
div.blank.small {
padding: 10px 20px;
h4 { font-weight: normal; font-size: 16px; }
p { margin: 0; }
}
div.blank.tiny {
padding: 10px 20px;
h4 { font-weight: normal; font-size: 14px; }
p { margin: 0; font-size: 12px; }
}
div.blank.rounded {
.border_radius(3); margin: 0 0 20px;
}
div.blank.rounded.bottom { .border_radius_top(0); }
div.blank.with_border_bottom { border-bottom: 1px solid (@bg * 0.1 + @blue * 0.1 + @white * 0.8); }
div.blank.no_border_top { border-top: none; }
div.blank.no_border_bottom { border-bottom: none; }
div.blank.no_side_borders { border-right: none; border-left: none; }
div.panel {
div.blank {
padding: 10px 20px; overflow: hidden; margin: 0;
h4 { font-weight: normal; font-size: 14px; }
p, ul { margin: 0 0 10px; font-size: 12px; }
p:last-child, ul:last-child { margin: 0; }
}
}
#yelow {
#short {
color: #fea;
}
#long {
color: #ffeeaa;
}
#rgba {
color: rgba(255, 238, 170, 0.1);
}
}
#blue {
#short {
color: #00f;
}
#long {
color: #0000ff;
}
#rgba {
color: rgba(0, 0, 255, 0.1);
}
}
#overflow {
.a { color: #111111 - #444444; } // #000000
.b { color: #eee + #fff; } // #ffffff
.c { color: #aaa * 3; } // #ffffff
.d { color: #00ee00 + #009900; } // #00ff00
}
#grey {
color: rgb(200, 200, 200);
}
#808080 {
color: hsl(50, 0%, 50%);
}
#00ff00 {
color: hsl(120, 100%, 50%);
}
/******************\
* *
* Comment Header *
* *
\******************/
/*
Comment
*/
/*
* Comment Test
*
* - cloudhead (http://cloudhead.net)
*
*/
////////////////
@var: "content";
////////////////
/* Colors
* ------
* #EDF8FC (background blue)
* #166C89 (darkest blue)
*
* Text:
* #333 (standard text) // A comment within a comment!
* #1F9EC9 (standard link)
*
*/
/* @group Variables
------------------- */
#comments /* boo */ {
/**/ // An empty comment
color: red; /* A C-style comment */
background-color: orange; // A little comment
font-size: 12px;
/* lost comment */ content: @var;
border: 1px solid black;
// padding & margin //
padding: 0;
margin: 2em;
} //
/* commented out
#more-comments {
color: grey;
}
*/
#last { color: blue }
//
.comma-delimited {
background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg);
text-shadow: -1px -1px 1px red, 6px 5px 5px yellow;
-moz-box-shadow: 0pt 0pt 2px rgba(255, 255, 255, 0.4) inset,
0pt 4px 6px rgba(255, 255, 255, 0.4) inset;
}
@font-face {
font-family: Headline;
src: local(Futura-Medium),
url(fonts.svg#MyGeometricModern) format("svg");
}
.other {
-moz-transform: translate(0, 11em) rotate(-90deg);
}
p:not([class*="lead"]) {
color: black;
}
input[type="text"].class#id[attr=32]:not(1) {
color: white;
}
div#id.class[a=1][b=2].class:not(1) {
color: white;
}
ul.comma > li:not(:only-child)::after {
color: white;
}
ol.comma > li:nth-last-child(2)::after {
color: white;
}
li:nth-child(4n+1),
li:nth-child(-5n),
li:nth-child(-n+2) {
color: white;
}
a[href^="http://"] {
color: black;
}
a[href$="http://"] {
color: black;
}
form[data-disabled] {
color: black;
}
p::before {
color: black;
}
@charset "utf-8";
div { color: black; }
div { width: 99%; }
* {
min-width: 45em;
}
h1, h2 > a > p, h3 {
color: none;
}
div.class {
color: blue;
}
div#id {
color: green;
}
.class#id {
color: purple;
}
.one.two.three {
color: grey;
}
@media print {
font-size: 3em;
}
@media screen {
font-size: 10px;
}
@font-face {
font-family: 'Garamond Pro';
src: url("/fonts/garamond-pro.ttf");
}
a:hover, a:link {
color: #999;
}
p, p:first-child {
text-transform: none;
}
q:lang(no) {
quotes: none;
}
p + h1 {
font-size: 2.2em;
}
#shorthands {
border: 1px solid #000;
font: 12px/16px Arial;
margin: 1px 0;
padding: 0 auto;
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#more-shorthands {
margin: 0;
padding: 1px 0 2px 0;
font: normal small/20px 'Trebuchet MS', Verdana, sans-serif;
}
.misc {
-moz-border-radius: 2px;
display: -moz-inline-stack;
width: .1em;
background-color: #009998;
background-image: url(images/image.jpg);
background: -webkit-gradient(linear, left top, left bottom, from(red), to(blue));
margin: ;
}
#important {
color: red !important;
width: 100%!important;
height: 20px ! important;
}
#functions {
@var: 10;
color: color("red");
width: increment(15);
height: undefined("self");
border-width: add(2, 3);
variable: increment(@var);
}
#built-in {
@r: 32;
escaped: e("-Some::weird(#thing, y)");
lighten: lighten(#ff0000, 50%);
darken: darken(#ff0000, 50%);
saturate: saturate(#29332f, 20%);
desaturate: desaturate(#203c31, 20%);
greyscale: greyscale(#203c31);
format: %("rgb(%d, %d, %d)", @r, 128, 64);
format-string: %("hello %s", "world");
eformat: e(%("rgb(%d, %d, %d)", @r, 128, 64));
}
@var: @a;
@a: 100%;
.lazy-eval {
width: @var;
}
.mixin (@a: 1px, @b: 50%) {
width: @a * 5;
height: @b - 1%;
}
.mixina (@style, @width, @color: black) {
border: @width @style @color;
}
.mixiny
(@a: 0, @b: 0) {
margin: @a;
padding: @b;
}
.hidden() {
color: transparent;
}
.two-args {
color: blue;
.mixin(2px, 100%);
.mixina(dotted, 2px);
}
.one-arg {
.mixin(3px);
}
.no-parens {
.mixin();
}
.no-args {
.mixin();
}
.var-args {
@var: 9;
.mixin(@var, @var * 2);
}
.multi-mix {
.mixin(2px, 30%);
.mixiny(4, 5);
}
.maxa(@arg1: 10, @arg2: #f00) {
padding: @arg1 * 2px;
color: @arg2;
}
body {
.maxa(15);
}
@glob: 5;
.global-mixin(@a:2) {
width: @glob + @a;
}
.scope-mix {
.global-mixin(3);
}
.nested-ruleset (@width: 200px) {
width: @width;
.column { margin: @width; }
}
.content {
.nested-ruleset(600px);
}
//
.same-var-name2(@radius) {
radius: @radius;
}
.same-var-name(@radius) {
.same-var-name2(@radius);
}
#same-var-name {
.same-var-name(5px);
}
//
.var-inside () {
@var: 10px;
width: @var;
}
#var-inside { .var-inside(); }
.mix-inner (@var) {
border-width: @var;
}
.mix (@a: 10) {
.inner {
height: @a * 10;
.innest {
width: @a;
.mix-inner(@a * 2);
}
}
}
.class {
.mix(30);
}
.mixin () {
zero: 0;
}
.mixin (@a: 1px) {
one: 1;
}
.mixin (@a) {
one-req: 1;
}
.mixin (@a: 1px, @b: 2px) {
two: 2;
}
.mixin (@a, @b, @c) {
three-req: 3;
}
.mixin (@a: 1px, @b: 2px, @c: 3px) {
three: 3;
}
.zero {
.mixin();
}
.one {
.mixin(1);
}
.two {
.mixin(1, 2);
}
.three {
.mixin(1, 2, 3);
}
//
.mixout ('left') {
left: 1;
}
.mixout ('right') {
right: 1;
}
.left {
.mixout('left');
}
.right {
.mixout('right');
}
//
.border (@side, @width) {
color: black;
.border-side(@side, @width);
}
.border-side (left, @w) {
border-left: @w;
}
.border-side (right, @w) {
border-right: @w;
}
.border-right {
.border(right, 4px);
}
.border-left {
.border(left, 4px);
}
//
.border-radius (@r) {
both: @r * 10;
}
.border-radius (@r, left) {
left: @r;
}
.border-radius (@r, right) {
right: @r;
}
.only-right {
.border-radius(33, right);
}
.only-left {
.border-radius(33, left);
}
.left-right {
.border-radius(33);
}
.mixin { border: 1px solid black; }
.mixout { border-color: orange; }
.borders { border-style: dashed; }
#namespace {
.borders {
border-style: dotted;
}
.biohazard {
content: "death";
.man {
color: transparent;
}
}
}
#theme {
> .mixin {
background-color: grey;
}
}
#container {
color: black;
.mixin();
.mixout();
#theme > .mixin();
}
#header {
.milk {
color: white;
.mixin();
#theme > .mixin();
}
#cookie {
.chips {
#namespace .borders();
.calories {
#container();
}
}
.borders();
}
}
.secure-zone { #namespace .biohazard .man(); }
.direct {
#namespace > .borders();
}
#operations {
color: #110000 + #000011 + #001100; // #111111
height: (10px / 2px) + 6px - 1px * 2; // 9px
width: 2 * 4 - 5em; // 3em
.spacing {
height: (10px / 2px)+6px-1px*2;
width: 2 * 4-5em;
}
subtraction: 20 - 10 - 5 - 5; // 0
division: (20 / 5 / 4); // 1
}
@x: 4;
@y: 12em;
.with-variables {
height: @x + @y; // 16em
width: 12 + @y; // 24em
size: 5cm - @x; // 1cm
}
@z: -2;
.negative {
height: 2px + @z; // 0px
width: 2px - @z; // 4px
}
.shorthands {
padding: -1px 2px 0 -4px; //
}
.colors {
color: #123; // #112233
border-color: #234 + #111111; // #334455
background-color: #222222 - #fff; // #000000
.other {
color: 2 * #111; // #222222
border-color: (#333333 / 3) + #111; // #222222
}
}
.parens {
@var: 1px;
border: (@var * 2) solid black;
margin: (@var * 1) (@var + 2) (4 * 4) 3;
width: (6 * 6);
padding: 2px (6px * 6px);
}
.more-parens {
@var: (2 * 2);
padding: (2 * @var) 4 4 (@var * 1px);
width: (@var * @var) * 6;
height: (7 * 7) + (8 * 8);
margin: 4 * ((5 + 5) / 2) - (@var * 2);
//margin: (6 * 6)px;
}
.nested-parens {
width: 2 * (4 * (2 + (1 + 6))) - 1;
height: ((2+3)*(2+3) / (9-4)) + 1;
}
.mixed-units {
margin: 2px 4em 1 5pc;
padding: (2px + 4px) 1em 2px 2;
}
#first > .one {
> #second .two > #deux {
width: 50%;
#third {
&:focus {
color: black;
#fifth {
> #sixth {
.seventh #eighth {
+ #ninth {
color: purple;
}
}
}
}
}
height: 100%;
}
#fourth, #five, #six {
color: #110000;
.seven, .eight > #nine {
border: 1px solid black;
}
#ten {
color: red;
}
}
}
font-size: 2em;
}
@x: blue;
@z: transparent;
@mix: none;
.mixin {
@mix: #989;
}
.tiny-scope {
color: @mix; // #989
.mixin();
}
.scope1 {
@y: orange;
@z: black;
color: @x; // blue
border-color: @z; // black
.hidden {
@x: #131313;
}
.scope2 {
@y: red;
color: @x; // blue
.scope3 {
@local: white;
color: @y; // red
border-color: @z; // black
background-color: @local; // white
}
}
}h1, h2, h3 {
a, p {
&:hover {
color: red;
}
}
}
#all { color: blue; }
#the { color: blue; }
#same { color: blue; }
ul, li, div, q, blockquote, textarea {
margin: 0;
}
td {
margin: 0;
padding: 0;
}
td, input {
line-height: 1em;
}
#strings {
background-image: url("http://son-of-a-banana.com");
quotes: "~" "~";
content: "#*%:&^,)!.(~*})";
empty: "";
brackets: "{" "}";
}
#comments {
content: "/* hello */ // not-so-secret";
}
#single-quote {
quotes: "'" "'";
content: '""#!&""';
empty: '';
}
@a: 2;
@x: @a * @a;
@y: @x + 1;
@z: @x * 2 + @y;
.variables {
width: @z + 1cm; // 14cm
}
@b: @a * 10;
@c: #888;
@fonts: "Trebuchet MS", Verdana, sans-serif;
@f: @fonts;
@quotes: "~" "~";
@q: @quotes;
.variables {
height: @b + @x + 0px; // 24px
color: @c;
font-family: @f;
quotes: @q;
}
.redefinition {
@var: 4;
@var: 2;
@var: 3;
three: @var;
}
.values {
@a: 'Trebuchet';
font-family: @a, @a, @a;
}
.whitespace
{ color: white; }
.whitespace
{
color: white;
}
.whitespace
{ color: white; }
.whitespace{color:white;}
.whitespace { color : white ; }
.white,
.space,
.mania
{ color: white; }
.no-semi-column { color: white }
.no-semi-column {
color: white;
white-space: pre
}
.no-semi-column {border: 2px solid white}
.newlines {
background: the,
great,
wall;
border: 2px
solid
black;
}
.empty {
}
#yelow {
#short {
color: #fea;
}
#long {
color: #ffeeaa;
}
#rgba {
color: rgba(255, 238, 170, 0.1);
}
}
#blue {
#short {
color: #00f;
}
#long {
color: #0000ff;
}
#rgba {
color: rgba(0, 0, 255, 0.1);
}
}
#overflow {
.a { color: #111111 - #444444; } // #000000
.b { color: #eee + #fff; } // #ffffff
.c { color: #aaa * 3; } // #ffffff
.d { color: #00ee00 + #009900; } // #00ff00
}
#grey {
color: rgb(200, 200, 200);
}
#808080 {
color: hsl(50, 0%, 50%);
}
#00ff00 {
color: hsl(120, 100%, 50%);
}
/******************\
* *
* Comment Header *
* *
\******************/
/*
Comment
*/
/*
* Comment Test
*
* - cloudhead (http://cloudhead.net)
*
*/
////////////////
@var: "content";
////////////////
/* Colors
* ------
* #EDF8FC (background blue)
* #166C89 (darkest blue)
*
* Text:
* #333 (standard text) // A comment within a comment!
* #1F9EC9 (standard link)
*
*/
/* @group Variables
------------------- */
#comments /* boo */ {
/**/ // An empty comment
color: red; /* A C-style comment */
background-color: orange; // A little comment
font-size: 12px;
/* lost comment */ content: @var;
border: 1px solid black;
// padding & margin //
padding: 0;
margin: 2em;
} //
/* commented out
#more-comments {
color: grey;
}
*/
#last { color: blue }
//
.comma-delimited {
background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg);
text-shadow: -1px -1px 1px red, 6px 5px 5px yellow;
-moz-box-shadow: 0pt 0pt 2px rgba(255, 255, 255, 0.4) inset,
0pt 4px 6px rgba(255, 255, 255, 0.4) inset;
}
@font-face {
font-family: Headline;
src: local(Futura-Medium),
url(fonts.svg#MyGeometricModern) format("svg");
}
.other {
-moz-transform: translate(0, 11em) rotate(-90deg);
}
p:not([class*="lead"]) {
color: black;
}
input[type="text"].class#id[attr=32]:not(1) {
color: white;
}
div#id.class[a=1][b=2].class:not(1) {
color: white;
}
ul.comma > li:not(:only-child)::after {
color: white;
}
ol.comma > li:nth-last-child(2)::after {
color: white;
}
li:nth-child(4n+1),
li:nth-child(-5n),
li:nth-child(-n+2) {
color: white;
}
a[href^="http://"] {
color: black;
}
a[href$="http://"] {
color: black;
}
form[data-disabled] {
color: black;
}
p::before {
color: black;
}
@charset "utf-8";
div { color: black; }
div { width: 99%; }
* {
min-width: 45em;
}
h1, h2 > a > p, h3 {
color: none;
}
div.class {
color: blue;
}
div#id {
color: green;
}
.class#id {
color: purple;
}
.one.two.three {
color: grey;
}
@media print {
font-size: 3em;
}
@media screen {
font-size: 10px;
}
@font-face {
font-family: 'Garamond Pro';
src: url("/fonts/garamond-pro.ttf");
}
a:hover, a:link {
color: #999;
}
p, p:first-child {
text-transform: none;
}
q:lang(no) {
quotes: none;
}
p + h1 {
font-size: 2.2em;
}
#shorthands {
border: 1px solid #000;
font: 12px/16px Arial;
margin: 1px 0;
padding: 0 auto;
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#more-shorthands {
margin: 0;
padding: 1px 0 2px 0;
font: normal small/20px 'Trebuchet MS', Verdana, sans-serif;
}
.misc {
-moz-border-radius: 2px;
display: -moz-inline-stack;
width: .1em;
background-color: #009998;
background-image: url(images/image.jpg);
background: -webkit-gradient(linear, left top, left bottom, from(red), to(blue));
margin: ;
}
#important {
color: red !important;
width: 100%!important;
height: 20px ! important;
}
#functions {
@var: 10;
color: color("red");
width: increment(15);
height: undefined("self");
border-width: add(2, 3);
variable: increment(@var);
}
#built-in {
@r: 32;
escaped: e("-Some::weird(#thing, y)");
lighten: lighten(#ff0000, 50%);
darken: darken(#ff0000, 50%);
saturate: saturate(#29332f, 20%);
desaturate: desaturate(#203c31, 20%);
greyscale: greyscale(#203c31);
format: %("rgb(%d, %d, %d)", @r, 128, 64);
format-string: %("hello %s", "world");
eformat: e(%("rgb(%d, %d, %d)", @r, 128, 64));
}
@var: @a;
@a: 100%;
.lazy-eval {
width: @var;
}
.mixin (@a: 1px, @b: 50%) {
width: @a * 5;
height: @b - 1%;
}
.mixina (@style, @width, @color: black) {
border: @width @style @color;
}
.mixiny
(@a: 0, @b: 0) {
margin: @a;
padding: @b;
}
.hidden() {
color: transparent;
}
.two-args {
color: blue;
.mixin(2px, 100%);
.mixina(dotted, 2px);
}
.one-arg {
.mixin(3px);
}
.no-parens {
.mixin();
}
.no-args {
.mixin();
}
.var-args {
@var: 9;
.mixin(@var, @var * 2);
}
.multi-mix {
.mixin(2px, 30%);
.mixiny(4, 5);
}
.maxa(@arg1: 10, @arg2: #f00) {
padding: @arg1 * 2px;
color: @arg2;
}
body {
.maxa(15);
}
@glob: 5;
.global-mixin(@a:2) {
width: @glob + @a;
}
.scope-mix {
.global-mixin(3);
}
.nested-ruleset (@width: 200px) {
width: @width;
.column { margin: @width; }
}
.content {
.nested-ruleset(600px);
}
//
.same-var-name2(@radius) {
radius: @radius;
}
.same-var-name(@radius) {
.same-var-name2(@radius);
}
#same-var-name {
.same-var-name(5px);
}
//
.var-inside () {
@var: 10px;
width: @var;
}
#var-inside { .var-inside(); }
.mix-inner (@var) {
border-width: @var;
}
.mix (@a: 10) {
.inner {
height: @a * 10;
.innest {
width: @a;
.mix-inner(@a * 2);
}
}
}
.class {
.mix(30);
}
.mixin () {
zero: 0;
}
.mixin (@a: 1px) {
one: 1;
}
.mixin (@a) {
one-req: 1;
}
.mixin (@a: 1px, @b: 2px) {
two: 2;
}
.mixin (@a, @b, @c) {
three-req: 3;
}
.mixin (@a: 1px, @b: 2px, @c: 3px) {
three: 3;
}
.zero {
.mixin();
}
.one {
.mixin(1);
}
.two {
.mixin(1, 2);
}
.three {
.mixin(1, 2, 3);
}
//
.mixout ('left') {
left: 1;
}
.mixout ('right') {
right: 1;
}
.left {
.mixout('left');
}
.right {
.mixout('right');
}
//
.border (@side, @width) {
color: black;
.border-side(@side, @width);
}
.border-side (left, @w) {
border-left: @w;
}
.border-side (right, @w) {
border-right: @w;
}
.border-right {
.border(right, 4px);
}
.border-left {
.border(left, 4px);
}
//
.border-radius (@r) {
both: @r * 10;
}
.border-radius (@r, left) {
left: @r;
}
.border-radius (@r, right) {
right: @r;
}
.only-right {
.border-radius(33, right);
}
.only-left {
.border-radius(33, left);
}
.left-right {
.border-radius(33);
}
.mixin { border: 1px solid black; }
.mixout { border-color: orange; }
.borders { border-style: dashed; }
#namespace {
.borders {
border-style: dotted;
}
.biohazard {
content: "death";
.man {
color: transparent;
}
}
}
#theme {
> .mixin {
background-color: grey;
}
}
#container {
color: black;
.mixin();
.mixout();
#theme > .mixin();
}
#header {
.milk {
color: white;
.mixin();
#theme > .mixin();
}
#cookie {
.chips {
#namespace .borders();
.calories {
#container();
}
}
.borders();
}
}
.secure-zone { #namespace .biohazard .man(); }
.direct {
#namespace > .borders();
}
#operations {
color: #110000 + #000011 + #001100; // #111111
height: (10px / 2px) + 6px - 1px * 2; // 9px
width: 2 * 4 - 5em; // 3em
.spacing {
height: (10px / 2px)+6px-1px*2;
width: 2 * 4-5em;
}
subtraction: 20 - 10 - 5 - 5; // 0
division: (20 / 5 / 4); // 1
}
@x: 4;
@y: 12em;
.with-variables {
height: @x + @y; // 16em
width: 12 + @y; // 24em
size: 5cm - @x; // 1cm
}
@z: -2;
.negative {
height: 2px + @z; // 0px
width: 2px - @z; // 4px
}
.shorthands {
padding: -1px 2px 0 -4px; //
}
.colors {
color: #123; // #112233
border-color: #234 + #111111; // #334455
background-color: #222222 - #fff; // #000000
.other {
color: 2 * #111; // #222222
border-color: (#333333 / 3) + #111; // #222222
}
}
.parens {
@var: 1px;
border: (@var * 2) solid black;
margin: (@var * 1) (@var + 2) (4 * 4) 3;
width: (6 * 6);
padding: 2px (6px * 6px);
}
.more-parens {
@var: (2 * 2);
padding: (2 * @var) 4 4 (@var * 1px);
width: (@var * @var) * 6;
height: (7 * 7) + (8 * 8);
margin: 4 * ((5 + 5) / 2) - (@var * 2);
//margin: (6 * 6)px;
}
.nested-parens {
width: 2 * (4 * (2 + (1 + 6))) - 1;
height: ((2+3)*(2+3) / (9-4)) + 1;
}
.mixed-units {
margin: 2px 4em 1 5pc;
padding: (2px + 4px) 1em 2px 2;
}
#first > .one {
> #second .two > #deux {
width: 50%;
#third {
&:focus {
color: black;
#fifth {
> #sixth {
.seventh #eighth {
+ #ninth {
color: purple;
}
}
}
}
}
height: 100%;
}
#fourth, #five, #six {
color: #110000;
.seven, .eight > #nine {
border: 1px solid black;
}
#ten {
color: red;
}
}
}
font-size: 2em;
}
@x: blue;
@z: transparent;
@mix: none;
.mixin {
@mix: #989;
}
.tiny-scope {
color: @mix; // #989
.mixin();
}
.scope1 {
@y: orange;
@z: black;
color: @x; // blue
border-color: @z; // black
.hidden {
@x: #131313;
}
.scope2 {
@y: red;
color: @x; // blue
.scope3 {
@local: white;
color: @y; // red
border-color: @z; // black
background-color: @local; // white
}
}
}h1, h2, h3 {
a, p {
&:hover {
color: red;
}
}
}
#all { color: blue; }
#the { color: blue; }
#same { color: blue; }
ul, li, div, q, blockquote, textarea {
margin: 0;
}
td {
margin: 0;
padding: 0;
}
td, input {
line-height: 1em;
}
#strings {
background-image: url("http://son-of-a-banana.com");
quotes: "~" "~";
content: "#*%:&^,)!.(~*})";
empty: "";
brackets: "{" "}";
}
#comments {
content: "/* hello */ // not-so-secret";
}
#single-quote {
quotes: "'" "'";
content: '""#!&""';
empty: '';
}
@a: 2;
@x: @a * @a;
@y: @x + 1;
@z: @x * 2 + @y;
.variables {
width: @z + 1cm; // 14cm
}
@b: @a * 10;
@c: #888;
@fonts: "Trebuchet MS", Verdana, sans-serif;
@f: @fonts;
@quotes: "~" "~";
@q: @quotes;
.variables {
height: @b + @x + 0px; // 24px
color: @c;
font-family: @f;
quotes: @q;
}
.redefinition {
@var: 4;
@var: 2;
@var: 3;
three: @var;
}
.values {
@a: 'Trebuchet';
font-family: @a, @a, @a;
}
.whitespace
{ color: white; }
.whitespace
{
color: white;
}
.whitespace
{ color: white; }
.whitespace{color:white;}
.whitespace { color : white ; }
.white,
.space,
.mania
{ color: white; }
.no-semi-column { color: white }
.no-semi-column {
color: white;
white-space: pre
}
.no-semi-column {border: 2px solid white}
.newlines {
background: the,
great,
wall;
border: 2px
solid
black;
}
.empty {
}
#yelow {
#short {
color: #fea;
}
#long {
color: #ffeeaa;
}
#rgba {
color: rgba(255, 238, 170, 0.1);
}
}
#blue {
#short {
color: #00f;
}
#long {
color: #0000ff;
}
#rgba {
color: rgba(0, 0, 255, 0.1);
}
}
#overflow {
.a { color: #111111 - #444444; } // #000000
.b { color: #eee + #fff; } // #ffffff
.c { color: #aaa * 3; } // #ffffff
.d { color: #00ee00 + #009900; } // #00ff00
}
#grey {
color: rgb(200, 200, 200);
}
#808080 {
color: hsl(50, 0%, 50%);
}
#00ff00 {
color: hsl(120, 100%, 50%);
}
/******************\
* *
* Comment Header *
* *
\******************/
/*
Comment
*/
/*
* Comment Test
*
* - cloudhead (http://cloudhead.net)
*
*/
////////////////
@var: "content";
////////////////
/* Colors
* ------
* #EDF8FC (background blue)
* #166C89 (darkest blue)
*
* Text:
* #333 (standard text) // A comment within a comment!
* #1F9EC9 (standard link)
*
*/
/* @group Variables
------------------- */
#comments /* boo */ {
/**/ // An empty comment
color: red; /* A C-style comment */
background-color: orange; // A little comment
font-size: 12px;
/* lost comment */ content: @var;
border: 1px solid black;
// padding & margin //
padding: 0;
margin: 2em;
} //
/* commented out
#more-comments {
color: grey;
}
*/
#last { color: blue }
//
.comma-delimited {
background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg);
text-shadow: -1px -1px 1px red, 6px 5px 5px yellow;
-moz-box-shadow: 0pt 0pt 2px rgba(255, 255, 255, 0.4) inset,
0pt 4px 6px rgba(255, 255, 255, 0.4) inset;
}
@font-face {
font-family: Headline;
src: local(Futura-Medium),
url(fonts.svg#MyGeometricModern) format("svg");
}
.other {
-moz-transform: translate(0, 11em) rotate(-90deg);
}
p:not([class*="lead"]) {
color: black;
}
input[type="text"].class#id[attr=32]:not(1) {
color: white;
}
div#id.class[a=1][b=2].class:not(1) {
color: white;
}
ul.comma > li:not(:only-child)::after {
color: white;
}
ol.comma > li:nth-last-child(2)::after {
color: white;
}
li:nth-child(4n+1),
li:nth-child(-5n),
li:nth-child(-n+2) {
color: white;
}
a[href^="http://"] {
color: black;
}
a[href$="http://"] {
color: black;
}
form[data-disabled] {
color: black;
}
p::before {
color: black;
}
@charset "utf-8";
div { color: black; }
div { width: 99%; }
* {
min-width: 45em;
}
h1, h2 > a > p, h3 {
color: none;
}
div.class {
color: blue;
}
div#id {
color: green;
}
.class#id {
color: purple;
}
.one.two.three {
color: grey;
}
@media print {
font-size: 3em;
}
@media screen {
font-size: 10px;
}
@font-face {
font-family: 'Garamond Pro';
src: url("/fonts/garamond-pro.ttf");
}
a:hover, a:link {
color: #999;
}
p, p:first-child {
text-transform: none;
}
q:lang(no) {
quotes: none;
}
p + h1 {
font-size: 2.2em;
}
#shorthands {
border: 1px solid #000;
font: 12px/16px Arial;
margin: 1px 0;
padding: 0 auto;
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#more-shorthands {
margin: 0;
padding: 1px 0 2px 0;
font: normal small/20px 'Trebuchet MS', Verdana, sans-serif;
}
.misc {
-moz-border-radius: 2px;
display: -moz-inline-stack;
width: .1em;
background-color: #009998;
background-image: url(images/image.jpg);
background: -webkit-gradient(linear, left top, left bottom, from(red), to(blue));
margin: ;
}
#important {
color: red !important;
width: 100%!important;
height: 20px ! important;
}
#functions {
@var: 10;
color: color("red");
width: increment(15);
height: undefined("self");
border-width: add(2, 3);
variable: increment(@var);
}
#built-in {
@r: 32;
escaped: e("-Some::weird(#thing, y)");
lighten: lighten(#ff0000, 50%);
darken: darken(#ff0000, 50%);
saturate: saturate(#29332f, 20%);
desaturate: desaturate(#203c31, 20%);
greyscale: greyscale(#203c31);
format: %("rgb(%d, %d, %d)", @r, 128, 64);
format-string: %("hello %s", "world");
eformat: e(%("rgb(%d, %d, %d)", @r, 128, 64));
}
@var: @a;
@a: 100%;
.lazy-eval {
width: @var;
}
.mixin (@a: 1px, @b: 50%) {
width: @a * 5;
height: @b - 1%;
}
.mixina (@style, @width, @color: black) {
border: @width @style @color;
}
.mixiny
(@a: 0, @b: 0) {
margin: @a;
padding: @b;
}
.hidden() {
color: transparent;
}
.two-args {
color: blue;
.mixin(2px, 100%);
.mixina(dotted, 2px);
}
.one-arg {
.mixin(3px);
}
.no-parens {
.mixin();
}
.no-args {
.mixin();
}
.var-args {
@var: 9;
.mixin(@var, @var * 2);
}
.multi-mix {
.mixin(2px, 30%);
.mixiny(4, 5);
}
.maxa(@arg1: 10, @arg2: #f00) {
padding: @arg1 * 2px;
color: @arg2;
}
body {
.maxa(15);
}
@glob: 5;
.global-mixin(@a:2) {
width: @glob + @a;
}
.scope-mix {
.global-mixin(3);
}
.nested-ruleset (@width: 200px) {
width: @width;
.column { margin: @width; }
}
.content {
.nested-ruleset(600px);
}
//
.same-var-name2(@radius) {
radius: @radius;
}
.same-var-name(@radius) {
.same-var-name2(@radius);
}
#same-var-name {
.same-var-name(5px);
}
//
.var-inside () {
@var: 10px;
width: @var;
}
#var-inside { .var-inside(); }
.mix-inner (@var) {
border-width: @var;
}
.mix (@a: 10) {
.inner {
height: @a * 10;
.innest {
width: @a;
.mix-inner(@a * 2);
}
}
}
.class {
.mix(30);
}
.mixin () {
zero: 0;
}
.mixin (@a: 1px) {
one: 1;
}
.mixin (@a) {
one-req: 1;
}
.mixin (@a: 1px, @b: 2px) {
two: 2;
}
.mixin (@a, @b, @c) {
three-req: 3;
}
.mixin (@a: 1px, @b: 2px, @c: 3px) {
three: 3;
}
.zero {
.mixin();
}
.one {
.mixin(1);
}
.two {
.mixin(1, 2);
}
.three {
.mixin(1, 2, 3);
}
//
.mixout ('left') {
left: 1;
}
// ============================================================================
// v2.0+ Features: Extend, Guards, Imports, Property Merging, Detached Rulesets
// ============================================================================
// --- Imports ---
@import "benchmark-import-target.less";
@import (reference) "benchmark-import-reference-target.less";
// --- Extend ---
// Basic extend
.base-button {
display: inline-block;
padding: 8px 16px;
border: 1px solid #ccc;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
text-align: center;
}
.action-button:extend(.base-button) {
background: #3498db;
color: #fff;
}
.cancel-button:extend(.base-button) {
background: #e74c3c;
color: #fff;
}
// Extend all
.nav-base {
list-style: none;
padding: 0;
margin: 0;
li {
display: inline-block;
a {
text-decoration: none;
padding: 8px 12px;
color: #333;
}
}
}
.main-nav:extend(.nav-base all) {
background: #f8f9fa;
border-bottom: 1px solid #dee2e6;
}
.side-nav:extend(.nav-base all) {
background: #343a40;
li a {
color: #fff;
}
}
// Extend from imported reference
.my-button:extend(.ref-button) {}
.my-primary-button:extend(.ref-button all) {}
.my-alert:extend(.ref-alert all) {}
.my-grid:extend(.ref-grid-system all) {}
// Nested extend
.panel {
border: 1px solid #ddd;
border-radius: 4px;
.panel-heading {
padding: 10px 15px;
background: #f5f5f5;
border-bottom: 1px solid #ddd;
}
.panel-body {
padding: 15px;
}
.panel-footer {
padding: 10px 15px;
background: #f5f5f5;
border-top: 1px solid #ddd;
}
}
.card {
&:extend(.panel all);
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.widget {
&:extend(.panel all);
margin-bottom: 20px;
}
// Extend with pseudo-classes
.link-base {
color: #3498db;
text-decoration: none;
&:hover {
color: #2980b9;
text-decoration: underline;
}
&:visited {
color: #8e44ad;
}
&:active {
color: #e74c3c;
}
}
.nav-link:extend(.link-base all) {
font-weight: bold;
}
// --- Guards ---
.generate-spacing(@n, @i: 1) when (@i =< @n) {
.m-@{i} { margin: (@i * 4px); }
.p-@{i} { padding: (@i * 4px); }
.mt-@{i} { margin-top: (@i * 4px); }
.mb-@{i} { margin-bottom: (@i * 4px); }
.ml-@{i} { margin-left: (@i * 4px); }
.mr-@{i} { margin-right: (@i * 4px); }
.pt-@{i} { padding-top: (@i * 4px); }
.pb-@{i} { padding-bottom: (@i * 4px); }
.pl-@{i} { padding-left: (@i * 4px); }
.pr-@{i} { padding-right: (@i * 4px); }
.generate-spacing(@n, (@i + 1));
}
.generate-spacing(10);
.generate-font-sizes(@n, @i: 1) when (@i =< @n) {
.fs-@{i} { font-size: (10px + @i * 2); }
.generate-font-sizes(@n, (@i + 1));
}
.generate-font-sizes(12);
.generate-widths(@n, @i: 1) when (@i =< @n) {
.w-@{i} { width: percentage((@i / @n)); }
.generate-widths(@n, (@i + 1));
}
.generate-widths(12);
// Guards with multiple conditions
.responsive-mixin(@size) when (@size < 576px) {
font-size: 12px;
padding: 4px;
}
.responsive-mixin(@size) when (@size >= 576px) and (@size < 768px) {
font-size: 14px;
padding: 8px;
}
.responsive-mixin(@size) when (@size >= 768px) and (@size < 992px) {
font-size: 16px;
padding: 12px;
}
.responsive-mixin(@size) when (@size >= 992px) {
font-size: 18px;
padding: 16px;
}
.sm { .responsive-mixin(400px); }
.md { .responsive-mixin(700px); }
.lg { .responsive-mixin(800px); }
.xl { .responsive-mixin(1200px); }
// Type-checking guards
.type-guard(@val) when (isnumber(@val)) {
width: @val;
}
.type-guard(@val) when (iscolor(@val)) {
color: @val;
}
.type-guard(@val) when (isstring(@val)) {
content: @val;
}
.guard-number { .type-guard(100px); }
.guard-color { .type-guard(#ff0000); }
.guard-string { .type-guard("hello"); }
// --- Property Merging ---
.shadow-base {
box-shadow+: 0 1px 3px rgba(0,0,0,0.12);
}
.shadow-elevated {
.shadow-base();
box-shadow+: 0 4px 6px rgba(0,0,0,0.1);
}
.shadow-floating {
.shadow-elevated();
box-shadow+: 0 10px 20px rgba(0,0,0,0.15);
}
.transform-base {
transform+_: translateX(10px);
}
.transform-combo {
.transform-base();
transform+_: rotate(45deg);
transform+_: scale(1.2);
}
.transition-multi {
transition+: color 0.3s ease;
transition+: background 0.3s ease;
transition+: border-color 0.3s ease;
transition+: box-shadow 0.3s ease;
}
.font-stack {
font-family+: "Helvetica Neue";
font-family+: Arial;
font-family+: sans-serif;
}
// --- Detached Rulesets ---
@media-mobile: {
font-size: 14px;
padding: 8px;
margin: 4px;
};
@media-desktop: {
font-size: 16px;
padding: 16px;
margin: 8px;
};
@theme-light: {
background: #ffffff;
color: #333333;
border-color: #dddddd;
};
@theme-dark: {
background: #1a1a2e;
color: #eaeaea;
border-color: #444444;
};
.mobile-component {
@media-mobile();
border: 1px solid #ccc;
}
.desktop-component {
@media-desktop();
border: 1px solid #999;
}
.light-section {
@theme-light();
.heading { font-weight: bold; }
}
.dark-section {
@theme-dark();
.heading { font-weight: bold; }
}
// Detached rulesets passed as arguments
.apply-theme(@theme) {
@theme();
padding: 20px;
border-radius: 8px;
}
.themed-card-light {
.apply-theme(@theme-light);
}
.themed-card-dark {
.apply-theme(@theme-dark);
}
// --- Complex Nesting & Selectors ---
.component {
display: block;
& + & { margin-top: 16px; }
& > &-inner { padding: 8px; }
&&-active { background: #e8f4fd; }
&-header, &-footer { padding: 12px; }
&-body {
padding: 16px;
&--large { padding: 24px; }
&--compact { padding: 8px; }
}
}
// --- Color Functions Stress ---
@base-hue: 210;
.color-gen(@i) when (@i > 0) {
.color-@{i} {
color: hsl(@base-hue, percentage((@i / 20)), 50%);
background: lighten(hsl(@base-hue, 80%, 50%), @i * 2%);
border-color: darken(hsl(@base-hue, 80%, 50%), @i * 2%);
outline-color: spin(hsl(@base-hue, 80%, 50%), @i * 15);
text-shadow: 0 1px 0 fade(#000, @i * 5%);
box-shadow: 0 0 (@i * 1px) saturate(hsl(@base-hue, 50%, 50%), @i * 3%);
}
.color-gen((@i - 1));
}
.color-gen(20);
// --- String Interpolation & Escaping ---
@base-url: "/assets/images";
@icon-prefix: "icon";
.generate-icons(@n, @i: 1) when (@i =< @n) {
.@{icon-prefix}-@{i} {
background-image: url("@{base-url}/@{icon-prefix}-@{i}.svg");
width: (16px + @i * 2);
height: (16px + @i * 2);
}
.generate-icons(@n, (@i + 1));
}
.generate-icons(20);
// --- Namespaces ---
#util {
.clearfix() {
&::after {
content: "";
display: table;
clear: both;
}
}
.ellipsis() {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.visually-hidden() {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}
.center-block() {
display: block;
margin-left: auto;
margin-right: auto;
}
}
.container { #util > .clearfix(); }
.title { #util > .ellipsis(); }
.sr-only { #util > .visually-hidden(); }
.image { #util > .center-block(); }
// --- Math & Unit Functions ---
.math-stress {
a: ceil(4.3px);
b: floor(4.7px);
c: round(4.567px, 2);
d: percentage(0.5);
e: sqrt(25px);
f: abs(-18px);
g: min(3px, 42px, 1px, 16px);
h: max(3px, 42px, 1px, 16px);
i: mod(11px, 3);
j: convert(1s, ms);
k: unit(5em, px);
l: unit(100px);
}
// --- Large Loop Stress (recursive mixin) ---
.gen-grid(@cols, @i: 1) when (@i =< @cols) {
.grid-col-@{i}-of-@{cols} {
width: percentage((@i / @cols));
float: left;
padding: 0 15px;
box-sizing: border-box;
}
.grid-push-@{i}-of-@{cols} {
margin-left: percentage((@i / @cols));
}
.grid-pull-@{i}-of-@{cols} {
margin-right: percentage((@i / @cols));
}
.grid-offset-@{i}-of-@{cols} {
margin-left: percentage((@i / @cols));
}
.gen-grid(@cols, (@i + 1));
}
.gen-grid(24);
// --- Deeply Nested Extend Chains ---
.typography-base {
font-family: sans-serif;
line-height: 1.6;
}
.heading-base:extend(.typography-base) {
font-weight: bold;
margin-bottom: 0.5em;
}
h1:extend(.heading-base) { font-size: 2.5em; }
h2:extend(.heading-base) { font-size: 2em; }
h3:extend(.heading-base) { font-size: 1.75em; }
h4:extend(.heading-base) { font-size: 1.5em; }
h5:extend(.heading-base) { font-size: 1.25em; }
h6:extend(.heading-base) { font-size: 1em; }
.prose {
h1:extend(h1) {}
h2:extend(h2) {}
h3:extend(h3) {}
p:extend(.typography-base) {
margin-bottom: 1em;
}
}
// --- Mixin with Variable Argument Lists ---
.multi-bg(@bgs...) {
background: @bgs;
}
.hero-section {
.multi-bg(
linear-gradient(rgba(0,0,0,0.3), rgba(0,0,0,0.3)),
url("/images/hero.jpg") center/cover no-repeat
);
min-height: 400px;
}
// --- Scope & Variable Hoisting Stress ---
.scope-outer {
@var: outer;
.scope-inner {
@var: inner;
.scope-deepest {
content: @var;
@var: deepest;
}
content: @var;
}
content: @var;
}
// --- Guard + Extend Combo ---
.status-mixin(@type) when (@type = success) {
color: #155724;
background-color: #d4edda;
border-color: #c3e6cb;
}
.status-mixin(@type) when (@type = warning) {
color: #856404;
background-color: #fff3cd;
border-color: #ffeeba;
}
.status-mixin(@type) when (@type = danger) {
color: #721c24;
background-color: #f8d7da;
border-color: #f5c6cb;
}
.status-mixin(@type) when (@type = info) {
color: #0c5460;
background-color: #d1ecf1;
border-color: #bee5eb;
}
.alert-success { .status-mixin(success); }
.alert-warning { .status-mixin(warning); }
.alert-danger { .status-mixin(danger); }
.alert-info { .status-mixin(info); }
.toast-success:extend(.alert-success all) {}
.toast-warning:extend(.alert-warning all) {}
.toast-danger:extend(.alert-danger all) {}
.toast-info:extend(.alert-info all) {}
================================================
FILE: packages/less/benchmark/index.js
================================================
import path from 'path';
import fs from 'fs';
import { fileURLToPath } from 'url';
import less from '../lib/less-node/index.js';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
let file = path.join(__dirname, 'benchmark.less');
if (process.argv[2]) { file = path.resolve(process.argv[2]); }
fs.readFile(file, 'utf8', function (e, data) {
console.log('Benchmarking...\n', path.basename(file) + ' (' +
parseInt(data.length / 1024) + ' KB)', '');
const renderBenchmark = [];
const parserBenchmark = [];
const evalBenchmark = [];
const totalruns = 30;
const ignoreruns = 5;
let i = 0;
nextRun();
function nextRun() {
const start = performance.now();
less.parse(data, { filename: file, paths: [path.dirname(file)] }, function(err, root, imports, options) {
if (err) {
console.log(err);
process.exit(3);
}
const parserEnd = performance.now();
const tree = new less.ParseTree(root, imports);
tree.toCSS(options);
const renderEnd = performance.now();
renderBenchmark.push(renderEnd - start);
parserBenchmark.push(parserEnd - start);
evalBenchmark.push(renderEnd - parserEnd);
i += 1;
if (i < totalruns) {
nextRun();
}
else {
finish();
}
});
}
function finish() {
function analyze(benchmark, benchMarkData) {
console.log('----------------------');
console.log(benchmark);
console.log('----------------------');
let totalTime = 0;
let mintime = Infinity;
let maxtime = 0;
for (let i = ignoreruns; i < totalruns; i++) {
totalTime += benchMarkData[i];
mintime = Math.min(mintime, benchMarkData[i]);
maxtime = Math.max(maxtime, benchMarkData[i]);
}
const avgtime = totalTime / (totalruns - ignoreruns);
const variation = maxtime - mintime;
const variationperc = (variation / avgtime) * 100;
console.log('Min. Time: ' + Math.round(mintime) + ' ms');
console.log('Max. Time: ' + Math.round(maxtime) + ' ms');
console.log('Total Average Time: ' + Math.round(avgtime) + ' ms (' +
parseInt(1000 / avgtime *
data.length / 1024) + ' KB\/s)');
console.log('+/- ' + Math.round(variationperc) + '%');
console.log('');
}
analyze('Parsing', parserBenchmark);
analyze('Evaluation', evalBenchmark);
analyze('Render Time', renderBenchmark);
}
});
================================================
FILE: packages/less/benchmark/results/.gitignore
================================================
# Legacy flat files (migrated to runs/ + latest/)
system-info.json
benchmark-results.json
v*.json
================================================
FILE: packages/less/benchmark/results/latest/macbook-pro_arm64.json
================================================
{
"system": {
"system_id": "macbook-pro_arm64",
"hostname": "MacBook-Pro.local",
"platform": "Darwin",
"arch": "arm64",
"os_version": "25.3.0",
"cpus": "14",
"cpu_model": "Apple M4 Pro",
"total_memory_gb": 48.0,
"node_version": "v24.11.1",
"date": "2026-03-09T21:34:11Z"
},
"versions": [
{
"tag": "v2.0.0",
"version": "2.0.0",
"node_version": "v18.20.8",
"date": "2026-03-09T21:34:21Z",
"benchmarks": {
"benchmark.less": {
"version": "2.0.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 29.27,
"max": 87.45,
"avg": 46.87,
"median": 46.89,
"stddev": 16.56,
"variance_pct": 35.33,
"samples": 12,
"throughput_kbs": 2224
}
}
}
},
{
"tag": "v2.1.2",
"version": "2.1.2",
"node_version": "v18.20.8",
"date": "2026-03-09T21:34:26Z",
"benchmarks": {
"benchmark.less": {
"error": "Extra data: line 2 column 1 (char 283)"
}
}
},
{
"tag": "v2.2.0",
"version": "2.2.0",
"node_version": "v18.20.8",
"date": "2026-03-09T21:34:42Z",
"benchmarks": {
"benchmark.less": {
"version": "2.2.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 28.99,
"max": 62.52,
"avg": 38.51,
"median": 31.32,
"stddev": 12.38,
"variance_pct": 32.15,
"samples": 12,
"throughput_kbs": 2706
}
}
}
},
{
"tag": "v2.3.1",
"version": "2.3.1",
"node_version": "v18.20.8",
"date": "2026-03-09T21:34:47Z",
"benchmarks": {
"benchmark.less": {
"version": "2.3.1",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 30.8,
"max": 63.72,
"avg": 38.42,
"median": 33.57,
"stddev": 11.47,
"variance_pct": 29.85,
"samples": 12,
"throughput_kbs": 2713
}
}
}
},
{
"tag": "v2.4.0",
"version": "2.4.0",
"node_version": "v18.20.8",
"date": "2026-03-09T21:34:52Z",
"benchmarks": {
"benchmark.less": {
"version": "2.4.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 27.39,
"max": 57.2,
"avg": 35.24,
"median": 31.11,
"stddev": 9.93,
"variance_pct": 28.18,
"samples": 12,
"throughput_kbs": 2957
}
}
}
},
{
"tag": "v2.5.3",
"version": "2.5.3",
"node_version": "v18.20.8",
"date": "2026-03-09T21:34:56Z",
"benchmarks": {
"benchmark.less": {
"version": "2.5.3",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 29.83,
"max": 63.6,
"avg": 37.57,
"median": 30.87,
"stddev": 11.91,
"variance_pct": 31.69,
"samples": 12,
"throughput_kbs": 2774
}
}
}
},
{
"tag": "v2.6.1",
"version": "2.6.1",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:02Z",
"benchmarks": {
"benchmark.less": {
"version": "2.6.1",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 33.64,
"max": 69,
"avg": 42.08,
"median": 37.52,
"stddev": 11.96,
"variance_pct": 28.41,
"samples": 12,
"throughput_kbs": 2477
}
}
}
},
{
"tag": "v2.7.3",
"version": "2.7.3",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:08Z",
"benchmarks": {
"benchmark.less": {
"version": "2.7.3",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 33.99,
"max": 72.46,
"avg": 44.36,
"median": 36.95,
"stddev": 13,
"variance_pct": 29.29,
"samples": 12,
"throughput_kbs": 2349
}
}
}
},
{
"tag": "v3.0.4",
"version": "3.0.4",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:14Z",
"benchmarks": {
"benchmark.less": {
"version": "3.0.4",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 37.07,
"max": 75.95,
"avg": 43.98,
"median": 39.29,
"stddev": 10.66,
"variance_pct": 24.25,
"samples": 12,
"throughput_kbs": 2370
}
}
}
},
{
"tag": "v3.5.3",
"version": "3.5.3",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:18Z",
"benchmarks": {
"benchmark.less": {
"version": "3.5.3",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 35.09,
"max": 52.73,
"avg": 43.96,
"median": 42.4,
"stddev": 5.5,
"variance_pct": 12.5,
"samples": 12,
"throughput_kbs": 2371
}
}
}
},
{
"tag": "v3.6.0",
"version": "3.6.0",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:23Z",
"benchmarks": {
"benchmark.less": {
"version": "3.6.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 37.97,
"max": 49.87,
"avg": 42.39,
"median": 40.92,
"stddev": 3.8,
"variance_pct": 8.97,
"samples": 12,
"throughput_kbs": 2459
}
},
"benchmark-v3.less": {
"version": "3.6.0",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.16,
"max": 4.09,
"avg": 2.94,
"median": 2.87,
"stddev": 0.63,
"variance_pct": 21.61,
"samples": 12,
"throughput_kbs": 1076
}
}
}
},
{
"tag": "v3.7.1",
"version": "3.7.1",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:28Z",
"benchmarks": {
"benchmark.less": {
"version": "3.7.1",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 37.82,
"max": 52.26,
"avg": 43.33,
"median": 40.85,
"stddev": 4.7,
"variance_pct": 10.84,
"samples": 12,
"throughput_kbs": 2405
}
},
"benchmark-v3.less": {
"version": "3.7.1",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.02,
"max": 3.55,
"avg": 2.74,
"median": 2.89,
"stddev": 0.52,
"variance_pct": 19.1,
"samples": 12,
"throughput_kbs": 1154
}
},
"benchmark-v37.less": {
"version": "3.7.1",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.63,
"max": 3.59,
"avg": 2.81,
"median": 2.9,
"stddev": 0.67,
"variance_pct": 23.77,
"samples": 12,
"throughput_kbs": 788
}
}
}
},
{
"tag": "v3.8.1",
"version": "3.8.1",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:35Z",
"benchmarks": {
"benchmark.less": {
"version": "3.8.1",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 38.31,
"max": 49.98,
"avg": 43.22,
"median": 41.04,
"stddev": 4.17,
"variance_pct": 9.64,
"samples": 12,
"throughput_kbs": 2412
}
},
"benchmark-v3.less": {
"version": "3.8.1",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.06,
"max": 3.99,
"avg": 2.98,
"median": 2.91,
"stddev": 0.66,
"variance_pct": 22.1,
"samples": 12,
"throughput_kbs": 1062
}
},
"benchmark-v37.less": {
"version": "3.8.1",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.8,
"max": 4.64,
"avg": 3.22,
"median": 3.06,
"stddev": 0.91,
"variance_pct": 28.34,
"samples": 12,
"throughput_kbs": 688
}
}
}
},
{
"tag": "v3.9.0",
"version": "3.9.0",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:41Z",
"benchmarks": {
"benchmark.less": {
"version": "3.9.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 38.78,
"max": 54.91,
"avg": 44.19,
"median": 40.7,
"stddev": 5.9,
"variance_pct": 13.35,
"samples": 12,
"throughput_kbs": 2358
}
},
"benchmark-v3.less": {
"version": "3.9.0",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.16,
"max": 4.04,
"avg": 3.01,
"median": 3.04,
"stddev": 0.62,
"variance_pct": 20.71,
"samples": 12,
"throughput_kbs": 1051
}
},
"benchmark-v37.less": {
"version": "3.9.0",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.68,
"max": 4.06,
"avg": 2.87,
"median": 2.87,
"stddev": 0.76,
"variance_pct": 26.57,
"samples": 12,
"throughput_kbs": 774
}
},
"benchmark-v39.less": {
"version": "3.9.0",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.06,
"max": 8.97,
"avg": 4.06,
"median": 3.91,
"stddev": 1.85,
"variance_pct": 45.62,
"samples": 12,
"throughput_kbs": 375
}
}
}
},
{
"tag": "v3.10.3",
"version": "3.10.3",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:52Z",
"benchmarks": {
"benchmark.less": {
"version": "3.10.3",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 118.01,
"max": 152.74,
"avg": 130.23,
"median": 126.14,
"stddev": 10.09,
"variance_pct": 7.75,
"samples": 12,
"throughput_kbs": 800
}
},
"benchmark-v3.less": {
"version": "3.10.3",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 3.64,
"max": 9.65,
"avg": 5.79,
"median": 5.61,
"stddev": 1.75,
"variance_pct": 30.26,
"samples": 12,
"throughput_kbs": 546
}
},
"benchmark-v37.less": {
"version": "3.10.3",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 3.84,
"max": 10.64,
"avg": 6.08,
"median": 5.57,
"stddev": 1.81,
"variance_pct": 29.73,
"samples": 12,
"throughput_kbs": 365
}
},
"benchmark-v39.less": {
"version": "3.10.3",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 9.19,
"max": 16.24,
"avg": 11.6,
"median": 10.95,
"stddev": 2.13,
"variance_pct": 18.39,
"samples": 12,
"throughput_kbs": 131
}
}
}
},
{
"tag": "v3.11.3",
"version": "3.11.3",
"node_version": "v18.20.8",
"date": "2026-03-09T21:36:02Z",
"benchmarks": {
"benchmark.less": {
"version": "3.11.3",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 123.6,
"max": 184.63,
"avg": 141.98,
"median": 135.73,
"stddev": 17,
"variance_pct": 11.97,
"samples": 12,
"throughput_kbs": 734
}
},
"benchmark-v3.less": {
"version": "3.11.3",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 4.07,
"max": 10.74,
"avg": 6.67,
"median": 6.18,
"stddev": 1.94,
"variance_pct": 29.07,
"samples": 12,
"throughput_kbs": 474
}
},
"benchmark-v37.less": {
"version": "3.11.3",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 5.7,
"max": 10.64,
"avg": 7.81,
"median": 7.46,
"stddev": 1.39,
"variance_pct": 17.78,
"samples": 12,
"throughput_kbs": 284
}
},
"benchmark-v39.less": {
"version": "3.11.3",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 6.23,
"max": 14.21,
"avg": 7.67,
"median": 6.97,
"stddev": 2.09,
"variance_pct": 27.21,
"samples": 12,
"throughput_kbs": 198
}
}
}
},
{
"tag": "v3.12.2",
"version": "3.12.2",
"node_version": "v18.20.8",
"date": "2026-03-09T21:36:16Z",
"benchmarks": {
"benchmark.less": {
"version": "3.12.2",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 165.65,
"max": 209.38,
"avg": 187.15,
"median": 185.42,
"stddev": 12.88,
"variance_pct": 6.88,
"samples": 12,
"throughput_kbs": 557
}
},
"benchmark-v3.less": {
"version": "3.12.2",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 3.76,
"max": 9.79,
"avg": 5.58,
"median": 5.53,
"stddev": 1.63,
"variance_pct": 29.32,
"samples": 12,
"throughput_kbs": 567
}
},
"benchmark-v37.less": {
"version": "3.12.2",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 4.22,
"max": 8.17,
"avg": 5.92,
"median": 5.82,
"stddev": 1.04,
"variance_pct": 17.62,
"samples": 12,
"throughput_kbs": 375
}
},
"benchmark-v39.less": {
"version": "3.12.2",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 7.43,
"max": 21.7,
"avg": 10.87,
"median": 9.85,
"stddev": 3.5,
"variance_pct": 32.22,
"samples": 12,
"throughput_kbs": 140
}
}
}
},
{
"tag": "v4.0.0",
"version": "4.0.0",
"node_version": "v20.19.6",
"date": "2026-03-09T21:36:27Z",
"benchmarks": {
"benchmark.less": {
"version": "4.0.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 35.71,
"max": 68.55,
"avg": 44.82,
"median": 39.85,
"stddev": 10.75,
"variance_pct": 24,
"samples": 12,
"throughput_kbs": 2326
}
},
"benchmark-v3.less": {
"version": "4.0.0",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 0,
"errors": [
{
"run": 0,
"error": "Error evaluating function `if`: tslib_1.__spreadArray is not a function"
},
{
"run": 0,
"error": "Error evaluating function `if`: tslib_1.__spreadArray is not a function"
},
{
"run": 0,
"error": "Error evaluating function `if`: tslib_1.__spreadArray is not a function"
},
{
"run": 0,
"error": "Error evaluating function `if`: tslib_1.__spreadArray is not a function"
}
],
"render": null
},
"benchmark-v37.less": {
"version": "4.0.0",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 0,
"errors": [
{
"run": 0,
"error": "Error evaluating function `if`: tslib_1.__spreadArray is not a function"
},
{
"run": 0,
"error": "Error evaluating function `if`: tslib_1.__spreadArray is not a function"
},
{
"run": 0,
"error": "Error evaluating function `if`: tslib_1.__spreadArray is not a function"
},
{
"run": 0,
"error": "Error evaluating function `if`: tslib_1.__spreadArray is not a function"
}
],
"render": null
},
"benchmark-v39.less": {
"version": "4.0.0",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.9,
"max": 11.57,
"avg": 4,
"median": 3.28,
"stddev": 2.63,
"variance_pct": 65.62,
"samples": 12,
"throughput_kbs": 380
}
}
}
},
{
"tag": "v4.1.3",
"version": "4.1.3",
"node_version": "v20.19.6",
"date": "2026-03-09T21:36:35Z",
"benchmarks": {
"benchmark.less": {
"version": "4.1.3",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 35.55,
"max": 68.29,
"avg": 43.74,
"median": 39.45,
"stddev": 10.63,
"variance_pct": 24.31,
"samples": 12,
"throughput_kbs": 2383
}
},
"benchmark-v3.less": {
"version": "4.1.3",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.51,
"max": 4.32,
"avg": 2.59,
"median": 2.52,
"stddev": 0.88,
"variance_pct": 34,
"samples": 12,
"throughput_kbs": 1220
}
},
"benchmark-v37.less": {
"version": "4.1.3",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.69,
"max": 4.27,
"avg": 3,
"median": 3.18,
"stddev": 0.8,
"variance_pct": 26.75,
"samples": 12,
"throughput_kbs": 738
}
},
"benchmark-v39.less": {
"version": "4.1.3",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.86,
"max": 11.57,
"avg": 4,
"median": 3.49,
"stddev": 2.58,
"variance_pct": 64.45,
"samples": 12,
"throughput_kbs": 380
}
}
}
},
{
"tag": "v4.2.2",
"version": "4.2.2",
"node_version": "v20.19.6",
"date": "2026-03-09T21:36:43Z",
"benchmarks": {
"benchmark.less": {
"version": "4.2.2",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 33.06,
"max": 71.26,
"avg": 41.5,
"median": 35.42,
"stddev": 12.93,
"variance_pct": 31.15,
"samples": 12,
"throughput_kbs": 2511
}
},
"benchmark-v3.less": {
"version": "4.2.2",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.68,
"max": 4.18,
"avg": 2.67,
"median": 2.69,
"stddev": 0.79,
"variance_pct": 29.71,
"samples": 12,
"throughput_kbs": 1184
}
},
"benchmark-v37.less": {
"version": "4.2.2",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.97,
"max": 10.6,
"avg": 3.77,
"median": 3.76,
"stddev": 2.2,
"variance_pct": 58.39,
"samples": 12,
"throughput_kbs": 587
}
},
"benchmark-v39.less": {
"version": "4.2.2",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.35,
"max": 9.8,
"avg": 4.85,
"median": 4.98,
"stddev": 2.16,
"variance_pct": 44.58,
"samples": 12,
"throughput_kbs": 314
}
}
}
},
{
"tag": "v4.3.0",
"version": "4.3.0",
"node_version": "v20.19.6",
"date": "2026-03-09T21:36:54Z",
"benchmarks": {
"benchmark.less": {
"version": "4.3.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 34.18,
"max": 73.61,
"avg": 43.07,
"median": 37.23,
"stddev": 12.22,
"variance_pct": 28.38,
"samples": 12,
"throughput_kbs": 2420
}
},
"benchmark-v3.less": {
"version": "4.3.0",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.63,
"max": 3.81,
"avg": 2.52,
"median": 2.45,
"stddev": 0.75,
"variance_pct": 29.7,
"samples": 12,
"throughput_kbs": 1254
}
},
"benchmark-v37.less": {
"version": "4.3.0",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.01,
"max": 9.44,
"avg": 3.51,
"median": 3.37,
"stddev": 1.9,
"variance_pct": 54.29,
"samples": 12,
"throughput_kbs": 632
}
},
"benchmark-v39.less": {
"version": "4.3.0",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.22,
"max": 9.85,
"avg": 4.7,
"median": 4.26,
"stddev": 2.16,
"variance_pct": 46.07,
"samples": 12,
"throughput_kbs": 324
}
}
}
},
{
"tag": "v4.4.2",
"version": "4.4.2",
"node_version": "v20.19.6",
"date": "2026-03-09T21:37:06Z",
"benchmarks": {
"benchmark.less": {
"version": "4.4.2",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 34.87,
"max": 73.71,
"avg": 45.83,
"median": 40.47,
"stddev": 11.86,
"variance_pct": 25.87,
"samples": 12,
"throughput_kbs": 2274
}
},
"benchmark-v3.less": {
"version": "4.4.2",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.55,
"max": 3.67,
"avg": 2.53,
"median": 2.53,
"stddev": 0.66,
"variance_pct": 26.12,
"samples": 12,
"throughput_kbs": 1249
}
},
"benchmark-v37.less": {
"version": "4.4.2",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.51,
"max": 10.07,
"avg": 3.59,
"median": 3.48,
"stddev": 2.11,
"variance_pct": 58.91,
"samples": 12,
"throughput_kbs": 618
}
},
"benchmark-v39.less": {
"version": "4.4.2",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.47,
"max": 10.4,
"avg": 4.92,
"median": 4.59,
"stddev": 2.24,
"variance_pct": 45.65,
"samples": 12,
"throughput_kbs": 310
}
}
}
},
{
"tag": "v4.5.1",
"version": "4.5.1",
"node_version": "v20.19.6",
"date": "2026-03-09T21:37:14Z",
"benchmarks": {
"benchmark.less": {
"version": "4.5.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 39.63,
"max": 72.55,
"avg": 47.4,
"median": 42.16,
"stddev": 11.09,
"variance_pct": 23.39,
"samples": 12,
"throughput_kbs": 2199
}
},
"benchmark-v3.less": {
"version": "4.5.0",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.61,
"max": 3.47,
"avg": 2.57,
"median": 2.62,
"stddev": 0.67,
"variance_pct": 26.21,
"samples": 12,
"throughput_kbs": 1231
}
},
"benchmark-v37.less": {
"version": "4.5.0",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.65,
"max": 9.51,
"avg": 3.79,
"median": 3.62,
"stddev": 1.96,
"variance_pct": 51.77,
"samples": 12,
"throughput_kbs": 585
}
},
"benchmark-v39.less": {
"version": "4.5.0",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.18,
"max": 10.1,
"avg": 4.62,
"median": 4.73,
"stddev": 2.14,
"variance_pct": 46.29,
"samples": 12,
"throughput_kbs": 330
}
}
}
}
]
}
================================================
FILE: packages/less/benchmark/results/runs/2026-03-09T21-34-11Z_macbook-pro_arm64.json
================================================
{
"system": {
"system_id": "macbook-pro_arm64",
"hostname": "MacBook-Pro.local",
"platform": "Darwin",
"arch": "arm64",
"os_version": "25.3.0",
"cpus": "14",
"cpu_model": "Apple M4 Pro",
"total_memory_gb": 48.0,
"node_version": "v24.11.1",
"date": "2026-03-09T21:34:11Z"
},
"versions": [
{
"tag": "v2.0.0",
"version": "2.0.0",
"node_version": "v18.20.8",
"date": "2026-03-09T21:34:21Z",
"benchmarks": {
"benchmark.less": {
"version": "2.0.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 29.27,
"max": 87.45,
"avg": 46.87,
"median": 46.89,
"stddev": 16.56,
"variance_pct": 35.33,
"samples": 12,
"throughput_kbs": 2224
}
}
}
},
{
"tag": "v2.1.2",
"version": "2.1.2",
"node_version": "v18.20.8",
"date": "2026-03-09T21:34:26Z",
"benchmarks": {
"benchmark.less": {
"error": "Extra data: line 2 column 1 (char 283)"
}
}
},
{
"tag": "v2.2.0",
"version": "2.2.0",
"node_version": "v18.20.8",
"date": "2026-03-09T21:34:42Z",
"benchmarks": {
"benchmark.less": {
"version": "2.2.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 28.99,
"max": 62.52,
"avg": 38.51,
"median": 31.32,
"stddev": 12.38,
"variance_pct": 32.15,
"samples": 12,
"throughput_kbs": 2706
}
}
}
},
{
"tag": "v2.3.1",
"version": "2.3.1",
"node_version": "v18.20.8",
"date": "2026-03-09T21:34:47Z",
"benchmarks": {
"benchmark.less": {
"version": "2.3.1",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 30.8,
"max": 63.72,
"avg": 38.42,
"median": 33.57,
"stddev": 11.47,
"variance_pct": 29.85,
"samples": 12,
"throughput_kbs": 2713
}
}
}
},
{
"tag": "v2.4.0",
"version": "2.4.0",
"node_version": "v18.20.8",
"date": "2026-03-09T21:34:52Z",
"benchmarks": {
"benchmark.less": {
"version": "2.4.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 27.39,
"max": 57.2,
"avg": 35.24,
"median": 31.11,
"stddev": 9.93,
"variance_pct": 28.18,
"samples": 12,
"throughput_kbs": 2957
}
}
}
},
{
"tag": "v2.5.3",
"version": "2.5.3",
"node_version": "v18.20.8",
"date": "2026-03-09T21:34:56Z",
"benchmarks": {
"benchmark.less": {
"version": "2.5.3",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 29.83,
"max": 63.6,
"avg": 37.57,
"median": 30.87,
"stddev": 11.91,
"variance_pct": 31.69,
"samples": 12,
"throughput_kbs": 2774
}
}
}
},
{
"tag": "v2.6.1",
"version": "2.6.1",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:02Z",
"benchmarks": {
"benchmark.less": {
"version": "2.6.1",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 33.64,
"max": 69,
"avg": 42.08,
"median": 37.52,
"stddev": 11.96,
"variance_pct": 28.41,
"samples": 12,
"throughput_kbs": 2477
}
}
}
},
{
"tag": "v2.7.3",
"version": "2.7.3",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:08Z",
"benchmarks": {
"benchmark.less": {
"version": "2.7.3",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 33.99,
"max": 72.46,
"avg": 44.36,
"median": 36.95,
"stddev": 13,
"variance_pct": 29.29,
"samples": 12,
"throughput_kbs": 2349
}
}
}
},
{
"tag": "v3.0.4",
"version": "3.0.4",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:14Z",
"benchmarks": {
"benchmark.less": {
"version": "3.0.4",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 37.07,
"max": 75.95,
"avg": 43.98,
"median": 39.29,
"stddev": 10.66,
"variance_pct": 24.25,
"samples": 12,
"throughput_kbs": 2370
}
}
}
},
{
"tag": "v3.5.3",
"version": "3.5.3",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:18Z",
"benchmarks": {
"benchmark.less": {
"version": "3.5.3",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 35.09,
"max": 52.73,
"avg": 43.96,
"median": 42.4,
"stddev": 5.5,
"variance_pct": 12.5,
"samples": 12,
"throughput_kbs": 2371
}
}
}
},
{
"tag": "v3.6.0",
"version": "3.6.0",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:23Z",
"benchmarks": {
"benchmark.less": {
"version": "3.6.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 37.97,
"max": 49.87,
"avg": 42.39,
"median": 40.92,
"stddev": 3.8,
"variance_pct": 8.97,
"samples": 12,
"throughput_kbs": 2459
}
},
"benchmark-v3.less": {
"version": "3.6.0",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.16,
"max": 4.09,
"avg": 2.94,
"median": 2.87,
"stddev": 0.63,
"variance_pct": 21.61,
"samples": 12,
"throughput_kbs": 1076
}
}
}
},
{
"tag": "v3.7.1",
"version": "3.7.1",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:28Z",
"benchmarks": {
"benchmark.less": {
"version": "3.7.1",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 37.82,
"max": 52.26,
"avg": 43.33,
"median": 40.85,
"stddev": 4.7,
"variance_pct": 10.84,
"samples": 12,
"throughput_kbs": 2405
}
},
"benchmark-v3.less": {
"version": "3.7.1",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.02,
"max": 3.55,
"avg": 2.74,
"median": 2.89,
"stddev": 0.52,
"variance_pct": 19.1,
"samples": 12,
"throughput_kbs": 1154
}
},
"benchmark-v37.less": {
"version": "3.7.1",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.63,
"max": 3.59,
"avg": 2.81,
"median": 2.9,
"stddev": 0.67,
"variance_pct": 23.77,
"samples": 12,
"throughput_kbs": 788
}
}
}
},
{
"tag": "v3.8.1",
"version": "3.8.1",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:35Z",
"benchmarks": {
"benchmark.less": {
"version": "3.8.1",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 38.31,
"max": 49.98,
"avg": 43.22,
"median": 41.04,
"stddev": 4.17,
"variance_pct": 9.64,
"samples": 12,
"throughput_kbs": 2412
}
},
"benchmark-v3.less": {
"version": "3.8.1",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.06,
"max": 3.99,
"avg": 2.98,
"median": 2.91,
"stddev": 0.66,
"variance_pct": 22.1,
"samples": 12,
"throughput_kbs": 1062
}
},
"benchmark-v37.less": {
"version": "3.8.1",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.8,
"max": 4.64,
"avg": 3.22,
"median": 3.06,
"stddev": 0.91,
"variance_pct": 28.34,
"samples": 12,
"throughput_kbs": 688
}
}
}
},
{
"tag": "v3.9.0",
"version": "3.9.0",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:41Z",
"benchmarks": {
"benchmark.less": {
"version": "3.9.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 38.78,
"max": 54.91,
"avg": 44.19,
"median": 40.7,
"stddev": 5.9,
"variance_pct": 13.35,
"samples": 12,
"throughput_kbs": 2358
}
},
"benchmark-v3.less": {
"version": "3.9.0",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.16,
"max": 4.04,
"avg": 3.01,
"median": 3.04,
"stddev": 0.62,
"variance_pct": 20.71,
"samples": 12,
"throughput_kbs": 1051
}
},
"benchmark-v37.less": {
"version": "3.9.0",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.68,
"max": 4.06,
"avg": 2.87,
"median": 2.87,
"stddev": 0.76,
"variance_pct": 26.57,
"samples": 12,
"throughput_kbs": 774
}
},
"benchmark-v39.less": {
"version": "3.9.0",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.06,
"max": 8.97,
"avg": 4.06,
"median": 3.91,
"stddev": 1.85,
"variance_pct": 45.62,
"samples": 12,
"throughput_kbs": 375
}
}
}
},
{
"tag": "v3.10.3",
"version": "3.10.3",
"node_version": "v18.20.8",
"date": "2026-03-09T21:35:52Z",
"benchmarks": {
"benchmark.less": {
"version": "3.10.3",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 118.01,
"max": 152.74,
"avg": 130.23,
"median": 126.14,
"stddev": 10.09,
"variance_pct": 7.75,
"samples": 12,
"throughput_kbs": 800
}
},
"benchmark-v3.less": {
"version": "3.10.3",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 3.64,
"max": 9.65,
"avg": 5.79,
"median": 5.61,
"stddev": 1.75,
"variance_pct": 30.26,
"samples": 12,
"throughput_kbs": 546
}
},
"benchmark-v37.less": {
"version": "3.10.3",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 3.84,
"max": 10.64,
"avg": 6.08,
"median": 5.57,
"stddev": 1.81,
"variance_pct": 29.73,
"samples": 12,
"throughput_kbs": 365
}
},
"benchmark-v39.less": {
"version": "3.10.3",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 9.19,
"max": 16.24,
"avg": 11.6,
"median": 10.95,
"stddev": 2.13,
"variance_pct": 18.39,
"samples": 12,
"throughput_kbs": 131
}
}
}
},
{
"tag": "v3.11.3",
"version": "3.11.3",
"node_version": "v18.20.8",
"date": "2026-03-09T21:36:02Z",
"benchmarks": {
"benchmark.less": {
"version": "3.11.3",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 123.6,
"max": 184.63,
"avg": 141.98,
"median": 135.73,
"stddev": 17,
"variance_pct": 11.97,
"samples": 12,
"throughput_kbs": 734
}
},
"benchmark-v3.less": {
"version": "3.11.3",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 4.07,
"max": 10.74,
"avg": 6.67,
"median": 6.18,
"stddev": 1.94,
"variance_pct": 29.07,
"samples": 12,
"throughput_kbs": 474
}
},
"benchmark-v37.less": {
"version": "3.11.3",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 5.7,
"max": 10.64,
"avg": 7.81,
"median": 7.46,
"stddev": 1.39,
"variance_pct": 17.78,
"samples": 12,
"throughput_kbs": 284
}
},
"benchmark-v39.less": {
"version": "3.11.3",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 6.23,
"max": 14.21,
"avg": 7.67,
"median": 6.97,
"stddev": 2.09,
"variance_pct": 27.21,
"samples": 12,
"throughput_kbs": 198
}
}
}
},
{
"tag": "v3.12.2",
"version": "3.12.2",
"node_version": "v18.20.8",
"date": "2026-03-09T21:36:16Z",
"benchmarks": {
"benchmark.less": {
"version": "3.12.2",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 165.65,
"max": 209.38,
"avg": 187.15,
"median": 185.42,
"stddev": 12.88,
"variance_pct": 6.88,
"samples": 12,
"throughput_kbs": 557
}
},
"benchmark-v3.less": {
"version": "3.12.2",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 3.76,
"max": 9.79,
"avg": 5.58,
"median": 5.53,
"stddev": 1.63,
"variance_pct": 29.32,
"samples": 12,
"throughput_kbs": 567
}
},
"benchmark-v37.less": {
"version": "3.12.2",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 4.22,
"max": 8.17,
"avg": 5.92,
"median": 5.82,
"stddev": 1.04,
"variance_pct": 17.62,
"samples": 12,
"throughput_kbs": 375
}
},
"benchmark-v39.less": {
"version": "3.12.2",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 7.43,
"max": 21.7,
"avg": 10.87,
"median": 9.85,
"stddev": 3.5,
"variance_pct": 32.22,
"samples": 12,
"throughput_kbs": 140
}
}
}
},
{
"tag": "v4.0.0",
"version": "4.0.0",
"node_version": "v20.19.6",
"date": "2026-03-09T21:36:27Z",
"benchmarks": {
"benchmark.less": {
"version": "4.0.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 35.71,
"max": 68.55,
"avg": 44.82,
"median": 39.85,
"stddev": 10.75,
"variance_pct": 24,
"samples": 12,
"throughput_kbs": 2326
}
},
"benchmark-v3.less": {
"version": "4.0.0",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 0,
"errors": [
{
"run": 0,
"error": "Error evaluating function `if`: tslib_1.__spreadArray is not a function"
},
{
"run": 0,
"error": "Error evaluating function `if`: tslib_1.__spreadArray is not a function"
},
{
"run": 0,
"error": "Error evaluating function `if`: tslib_1.__spreadArray is not a function"
},
{
"run": 0,
"error": "Error evaluating function `if`: tslib_1.__spreadArray is not a function"
}
],
"render": null
},
"benchmark-v37.less": {
"version": "4.0.0",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 0,
"errors": [
{
"run": 0,
"error": "Error evaluating function `if`: tslib_1.__spreadArray is not a function"
},
{
"run": 0,
"error": "Error evaluating function `if`: tslib_1.__spreadArray is not a function"
},
{
"run": 0,
"error": "Error evaluating function `if`: tslib_1.__spreadArray is not a function"
},
{
"run": 0,
"error": "Error evaluating function `if`: tslib_1.__spreadArray is not a function"
}
],
"render": null
},
"benchmark-v39.less": {
"version": "4.0.0",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.9,
"max": 11.57,
"avg": 4,
"median": 3.28,
"stddev": 2.63,
"variance_pct": 65.62,
"samples": 12,
"throughput_kbs": 380
}
}
}
},
{
"tag": "v4.1.3",
"version": "4.1.3",
"node_version": "v20.19.6",
"date": "2026-03-09T21:36:35Z",
"benchmarks": {
"benchmark.less": {
"version": "4.1.3",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 35.55,
"max": 68.29,
"avg": 43.74,
"median": 39.45,
"stddev": 10.63,
"variance_pct": 24.31,
"samples": 12,
"throughput_kbs": 2383
}
},
"benchmark-v3.less": {
"version": "4.1.3",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.51,
"max": 4.32,
"avg": 2.59,
"median": 2.52,
"stddev": 0.88,
"variance_pct": 34,
"samples": 12,
"throughput_kbs": 1220
}
},
"benchmark-v37.less": {
"version": "4.1.3",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.69,
"max": 4.27,
"avg": 3,
"median": 3.18,
"stddev": 0.8,
"variance_pct": 26.75,
"samples": 12,
"throughput_kbs": 738
}
},
"benchmark-v39.less": {
"version": "4.1.3",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.86,
"max": 11.57,
"avg": 4,
"median": 3.49,
"stddev": 2.58,
"variance_pct": 64.45,
"samples": 12,
"throughput_kbs": 380
}
}
}
},
{
"tag": "v4.2.2",
"version": "4.2.2",
"node_version": "v20.19.6",
"date": "2026-03-09T21:36:43Z",
"benchmarks": {
"benchmark.less": {
"version": "4.2.2",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 33.06,
"max": 71.26,
"avg": 41.5,
"median": 35.42,
"stddev": 12.93,
"variance_pct": 31.15,
"samples": 12,
"throughput_kbs": 2511
}
},
"benchmark-v3.less": {
"version": "4.2.2",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.68,
"max": 4.18,
"avg": 2.67,
"median": 2.69,
"stddev": 0.79,
"variance_pct": 29.71,
"samples": 12,
"throughput_kbs": 1184
}
},
"benchmark-v37.less": {
"version": "4.2.2",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.97,
"max": 10.6,
"avg": 3.77,
"median": 3.76,
"stddev": 2.2,
"variance_pct": 58.39,
"samples": 12,
"throughput_kbs": 587
}
},
"benchmark-v39.less": {
"version": "4.2.2",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.35,
"max": 9.8,
"avg": 4.85,
"median": 4.98,
"stddev": 2.16,
"variance_pct": 44.58,
"samples": 12,
"throughput_kbs": 314
}
}
}
},
{
"tag": "v4.3.0",
"version": "4.3.0",
"node_version": "v20.19.6",
"date": "2026-03-09T21:36:54Z",
"benchmarks": {
"benchmark.less": {
"version": "4.3.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 34.18,
"max": 73.61,
"avg": 43.07,
"median": 37.23,
"stddev": 12.22,
"variance_pct": 28.38,
"samples": 12,
"throughput_kbs": 2420
}
},
"benchmark-v3.less": {
"version": "4.3.0",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.63,
"max": 3.81,
"avg": 2.52,
"median": 2.45,
"stddev": 0.75,
"variance_pct": 29.7,
"samples": 12,
"throughput_kbs": 1254
}
},
"benchmark-v37.less": {
"version": "4.3.0",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.01,
"max": 9.44,
"avg": 3.51,
"median": 3.37,
"stddev": 1.9,
"variance_pct": 54.29,
"samples": 12,
"throughput_kbs": 632
}
},
"benchmark-v39.less": {
"version": "4.3.0",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.22,
"max": 9.85,
"avg": 4.7,
"median": 4.26,
"stddev": 2.16,
"variance_pct": 46.07,
"samples": 12,
"throughput_kbs": 324
}
}
}
},
{
"tag": "v4.4.2",
"version": "4.4.2",
"node_version": "v20.19.6",
"date": "2026-03-09T21:37:06Z",
"benchmarks": {
"benchmark.less": {
"version": "4.4.2",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 34.87,
"max": 73.71,
"avg": 45.83,
"median": 40.47,
"stddev": 11.86,
"variance_pct": 25.87,
"samples": 12,
"throughput_kbs": 2274
}
},
"benchmark-v3.less": {
"version": "4.4.2",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.55,
"max": 3.67,
"avg": 2.53,
"median": 2.53,
"stddev": 0.66,
"variance_pct": 26.12,
"samples": 12,
"throughput_kbs": 1249
}
},
"benchmark-v37.less": {
"version": "4.4.2",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.51,
"max": 10.07,
"avg": 3.59,
"median": 3.48,
"stddev": 2.11,
"variance_pct": 58.91,
"samples": 12,
"throughput_kbs": 618
}
},
"benchmark-v39.less": {
"version": "4.4.2",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.47,
"max": 10.4,
"avg": 4.92,
"median": 4.59,
"stddev": 2.24,
"variance_pct": 45.65,
"samples": 12,
"throughput_kbs": 310
}
}
}
},
{
"tag": "v4.5.1",
"version": "4.5.1",
"node_version": "v20.19.6",
"date": "2026-03-09T21:37:14Z",
"benchmarks": {
"benchmark.less": {
"version": "4.5.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106724,
"fileSizeKB": 104.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 39.63,
"max": 72.55,
"avg": 47.4,
"median": 42.16,
"stddev": 11.09,
"variance_pct": 23.39,
"samples": 12,
"throughput_kbs": 2199
}
},
"benchmark-v3.less": {
"version": "4.5.0",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.61,
"max": 3.47,
"avg": 2.57,
"median": 2.62,
"stddev": 0.67,
"variance_pct": 26.21,
"samples": 12,
"throughput_kbs": 1231
}
},
"benchmark-v37.less": {
"version": "4.5.0",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 1.65,
"max": 9.51,
"avg": 3.79,
"median": 3.62,
"stddev": 1.96,
"variance_pct": 51.77,
"samples": 12,
"throughput_kbs": 585
}
},
"benchmark-v39.less": {
"version": "4.5.0",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1558,
"fileSizeKB": 1.5,
"totalRuns": 15,
"warmupRuns": 3,
"completedRuns": 15,
"render": {
"min": 2.18,
"max": 10.1,
"avg": 4.62,
"median": 4.73,
"stddev": 2.14,
"variance_pct": 46.29,
"samples": 12,
"throughput_kbs": 330
}
}
}
}
]
}
================================================
FILE: packages/less/benchmark/results/runs/2026-03-09_macbook-pro_arm64.json
================================================
{
"system": {
"hostname": "MacBook-Pro.local",
"platform": "Darwin",
"arch": "arm64",
"os_version": "25.3.0",
"cpus": "14",
"cpu_model": "Apple M4 Pro",
"total_memory_gb": 48.0,
"node_version": "v24.11.1",
"date": "2026-03-09T18:54:01Z",
"system_id": "macbook-pro_arm64"
},
"versions": [
{
"tag": "v3.5.0",
"version": "3.5.0",
"node_version": "v18.20.8",
"date": "2026-03-09T18:54:04Z",
"benchmarks": {
"benchmark.less": {
"version": "3.5.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106712,
"fileSizeKB": 104.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 32.57,
"max": 50.01,
"avg": 38.55,
"median": 37.68,
"stddev": 3.96,
"variance_pct": 45.24,
"samples": 25,
"throughput_kbs": 2703
}
}
}
},
{
"tag": "v3.6.0",
"version": "3.6.0",
"node_version": "v18.20.8",
"date": "2026-03-09T18:54:10Z",
"benchmarks": {
"benchmark.less": {
"version": "3.6.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106712,
"fileSizeKB": 104.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 32.58,
"max": 44.99,
"avg": 36.81,
"median": 36.45,
"stddev": 3.29,
"variance_pct": 33.71,
"samples": 25,
"throughput_kbs": 2831
}
},
"benchmark-v3.less": {
"version": "3.6.0",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 1.41,
"max": 10.1,
"avg": 2.61,
"median": 1.97,
"stddev": 1.74,
"variance_pct": 333.37,
"samples": 25,
"throughput_kbs": 1213
}
}
}
},
{
"tag": "v3.7.0",
"version": "3.7.0",
"node_version": "v18.20.8",
"date": "2026-03-09T18:54:15Z",
"benchmarks": {
"benchmark.less": {
"version": "3.7.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106712,
"fileSizeKB": 104.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 35.95,
"max": 46.06,
"avg": 39.24,
"median": 38.01,
"stddev": 2.69,
"variance_pct": 25.77,
"samples": 25,
"throughput_kbs": 2656
}
},
"benchmark-v3.less": {
"version": "3.7.0",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 1.31,
"max": 9.52,
"avg": 2.63,
"median": 2.15,
"stddev": 1.69,
"variance_pct": 311.76,
"samples": 25,
"throughput_kbs": 1201
}
},
"benchmark-v37.less": {
"version": "3.7.0",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 1.18,
"max": 8.96,
"avg": 2.67,
"median": 1.95,
"stddev": 1.72,
"variance_pct": 291.4,
"samples": 25,
"throughput_kbs": 831
}
}
}
},
{
"tag": "v3.8.0",
"version": "3.8.0",
"node_version": "v18.20.8",
"date": "2026-03-09T18:54:21Z",
"benchmarks": {
"benchmark.less": {
"version": "3.8.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106712,
"fileSizeKB": 104.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 36.69,
"max": 45.5,
"avg": 39.95,
"median": 39.1,
"stddev": 2.52,
"variance_pct": 22.05,
"samples": 25,
"throughput_kbs": 2609
}
},
"benchmark-v3.less": {
"version": "3.8.0",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 1.49,
"max": 8.69,
"avg": 2.64,
"median": 2.09,
"stddev": 1.53,
"variance_pct": 273.14,
"samples": 25,
"throughput_kbs": 1200
}
},
"benchmark-v37.less": {
"version": "3.8.0",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 1.18,
"max": 7.68,
"avg": 2.58,
"median": 1.91,
"stddev": 1.45,
"variance_pct": 252.07,
"samples": 25,
"throughput_kbs": 860
}
}
}
},
{
"tag": "v3.9.0",
"version": "3.9.0",
"node_version": "v18.20.8",
"date": "2026-03-09T18:54:33Z",
"benchmarks": {
"benchmark.less": {
"version": "3.9.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106712,
"fileSizeKB": 104.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 32.62,
"max": 47.69,
"avg": 40.2,
"median": 39.67,
"stddev": 3.89,
"variance_pct": 37.47,
"samples": 25,
"throughput_kbs": 2592
}
},
"benchmark-v3.less": {
"version": "3.9.0",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 1.49,
"max": 8.91,
"avg": 2.56,
"median": 1.95,
"stddev": 1.55,
"variance_pct": 289.49,
"samples": 25,
"throughput_kbs": 1233
}
},
"benchmark-v37.less": {
"version": "3.9.0",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 1.2,
"max": 9.29,
"avg": 2.63,
"median": 2.03,
"stddev": 1.68,
"variance_pct": 307.32,
"samples": 25,
"throughput_kbs": 842
}
},
"benchmark-v39.less": {
"version": "3.9.0",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1554,
"fileSizeKB": 1.5,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 1.33,
"max": 11.52,
"avg": 3.12,
"median": 2.18,
"stddev": 2.18,
"variance_pct": 326.59,
"samples": 25,
"throughput_kbs": 486
}
}
}
},
{
"tag": "v3.10.0",
"version": "3.10.0",
"node_version": "v18.20.8",
"date": "2026-03-09T18:54:44Z",
"benchmarks": {
"benchmark.less": {
"version": "3.10.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106712,
"fileSizeKB": 104.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 103.26,
"max": 176.43,
"avg": 125.98,
"median": 125.46,
"stddev": 15.69,
"variance_pct": 58.08,
"samples": 25,
"throughput_kbs": 827
}
},
"benchmark-v3.less": {
"version": "3.10.0",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 2.67,
"max": 8.79,
"avg": 4.63,
"median": 4.18,
"stddev": 1.6,
"variance_pct": 132.21,
"samples": 25,
"throughput_kbs": 683
}
},
"benchmark-v37.less": {
"version": "3.10.0",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 3.31,
"max": 19.77,
"avg": 5.42,
"median": 4.64,
"stddev": 3.33,
"variance_pct": 303.98,
"samples": 25,
"throughput_kbs": 409
}
},
"benchmark-v39.less": {
"version": "3.10.0",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1554,
"fileSizeKB": 1.5,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 4.5,
"max": 21.31,
"avg": 7.16,
"median": 6.55,
"stddev": 3.01,
"variance_pct": 234.62,
"samples": 25,
"throughput_kbs": 212
}
}
}
},
{
"tag": "v3.11.0",
"version": "3.11.0",
"node_version": "v18.20.8",
"date": "2026-03-09T18:54:56Z",
"benchmarks": {
"benchmark.less": {
"version": "3.11.0",
"lessPath": ".",
"file": "benchmark.less",
"fileSize": 106712,
"fileSizeKB": 104.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 104.12,
"max": 154.95,
"avg": 122.9,
"median": 119.99,
"stddev": 12.94,
"variance_pct": 41.36,
"samples": 25,
"throughput_kbs": 848
}
},
"benchmark-v3.less": {
"version": "3.11.0",
"lessPath": ".",
"file": "benchmark-v3.less",
"fileSize": 3237,
"fileSizeKB": 3.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 2.84,
"max": 9.74,
"avg": 4.69,
"median": 4.33,
"stddev": 1.66,
"variance_pct": 146.96,
"samples": 25,
"throughput_kbs": 673
}
},
"benchmark-v37.less": {
"version": "3.11.0",
"lessPath": ".",
"file": "benchmark-v37.less",
"fileSize": 2270,
"fileSizeKB": 2.2,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 3.29,
"max": 14.99,
"avg": 5.88,
"median": 5.08,
"stddev": 2.63,
"variance_pct": 198.81,
"samples": 25,
"throughput_kbs": 377
}
},
"benchmark-v39.less": {
"version": "3.11.0",
"lessPath": ".",
"file": "benchmark-v39.less",
"fileSize": 1554,
"fileSizeKB": 1.5,
"totalRuns": 30,
"warmupRuns": 5,
"completedRuns": 30,
"render": {
"min": 9.79,
"max": 22.26,
"avg": 11.71,
"median": 11.12,
"stddev": 2.4,
"variance_pct": 106.47,
"samples": 25,
"throughput_kbs": 130
}
}
}
},
{
"tag": "v4.2.0",
"version": "4.2.0",
"node_version": "v20.19.6",
"date": "2026-03-09T18:55:29Z",
"benchmarks": {
"benchmark.less": {
"error": "Could not find Less compiler",
"tried": [
"./packages/less",
".",
"./lib/less-node",
"less"
]
},
"benchmark-v3.less": {
"error": "Could not find Less compiler",
"tried": [
"./packages/less",
".",
"./lib/less-node",
"less"
]
},
"benchmark-v37.less": {
"error": "Could not find Less compiler",
"tried": [
"./packages/less",
".",
"./lib/less-node",
"less"
]
},
"benchmark-v39.less": {
"error": "Could not find Less compiler",
"tried": [
"./packages/less",
".",
"./lib/less-node",
"less"
]
}
}
}
]
}
================================================
FILE: packages/less/benchmark/run-historical.sh
================================================
#!/usr/bin/env bash
set -euo pipefail
# Historical Less Benchmark Runner
# Benchmarks every major/minor Less release from v2.0.0 through v4.4.x
# Uses git worktrees for isolation, fnm for Node version management.
#
# Usage: ./run-historical.sh [--versions "v2.0.0 v3.0.0 ..."] [--runs 30] [--warmup 5]
#
# Results are saved to benchmark/results/
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
RESULTS_DIR="$SCRIPT_DIR/results"
RUNS_DIR="$RESULTS_DIR/runs"
LATEST_DIR="$RESULTS_DIR/latest"
WORKTREE_BASE="/tmp/less-bench-worktrees"
BENCHMARK_DIR="$SCRIPT_DIR"
RUNS=30
WARMUP=5
NODE_FOR_OLD="v18.20.8" # v2.x/v3.x
NODE_FOR_NEW="v20.19.6" # v4.x
NODE_DEFAULT="" # will be set to current
# Versions chosen to capture significant performance changes.
# Pruned from full v2.0–v4.5 benchmark data (2026-03-09, M4 Pro):
# Dropped v2.1 (broken), v2.5 (<1% from v2.4), v2.7 (<2% from v2.6),
# v3.6–v3.9 (all within 1ms of each other), v4.1 (<1% from v4.0).
# Use --versions to override with the full set if needed.
ALL_VERSIONS=(
v2.0.0 v2.2.0 v2.3.1 v2.4.0 v2.6.1
v3.0.4 v3.5.3 v3.10.3 v3.11.3 v3.12.2
v4.0.0 v4.2.2 v4.3.0 v4.4.2 v4.5.1
)
VERSIONS=("${ALL_VERSIONS[@]}")
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--versions) IFS=' ' read -ra VERSIONS <<< "$2"; shift 2 ;;
--runs) RUNS="$2"; shift 2 ;;
--warmup) WARMUP="$2"; shift 2 ;;
*) echo "Unknown option: $1"; exit 1 ;;
esac
done
# Benchmark files and their minimum required versions (parallel arrays)
BENCH_FILE_NAMES=(benchmark.less benchmark-v3.less benchmark-v37.less benchmark-v39.less)
BENCH_FILE_MINVS=(2.0.0 3.6.0 3.7.0 3.9.0)
# ----- Helpers -----
log() { echo "$(date '+%H:%M:%S') | $*"; }
err() { echo "$(date '+%H:%M:%S') | ERROR: $*" >&2; }
version_ge() {
# Returns 0 if $1 >= $2 (semantic version comparison)
printf '%s\n%s' "$2" "$1" | sort -V -C
}
strip_v() { echo "${1#v}"; }
pick_node_version() {
local ver="$1"
local major="${ver%%.*}"
if [[ "$major" -ge 4 ]]; then
echo "$NODE_FOR_NEW"
else
echo "$NODE_FOR_OLD"
fi
}
use_node() {
local nv="$1"
if command -v fnm &>/dev/null; then
fnm install "$nv" &>/dev/null || true
eval "$(fnm env --shell bash)"
fnm use "$nv" &>/dev/null
fi
}
restore_node() {
if [[ -n "$NODE_DEFAULT" ]] && command -v fnm &>/dev/null; then
eval "$(fnm env --shell bash)"
fnm use "$NODE_DEFAULT" &>/dev/null
fi
}
is_monorepo() {
local tag="$1"
git -C "$REPO_ROOT" show "$tag:packages/less/package.json" &>/dev/null 2>&1
}
get_system_info() {
python3 -c "
import json, platform, subprocess, datetime, re
def run(cmd):
try:
return subprocess.check_output(cmd, shell=True, stderr=subprocess.DEVNULL).decode().strip()
except:
return 'unknown'
hostname = platform.node()
arch = platform.machine()
# Generate a stable, filesystem-safe system ID
system_id = re.sub(r'[^a-zA-Z0-9_-]', '-', hostname.split('.')[0].lower()) + '_' + arch
info = {
'system_id': system_id,
'hostname': hostname,
'platform': platform.system(),
'arch': arch,
'os_version': platform.release(),
'cpus': run('sysctl -n hw.ncpu') if platform.system() == 'Darwin' else run('nproc'),
'cpu_model': run('sysctl -n machdep.cpu.brand_string') if platform.system() == 'Darwin' else run(\"grep 'model name' /proc/cpuinfo | head -1 | cut -d: -f2\").strip(),
'total_memory_gb': round(int(run('sysctl -n hw.memsize') or '0') / 1073741824, 1) if platform.system() == 'Darwin' else 'unknown',
'node_version': run('node -v'),
'date': datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')
}
print(json.dumps(info, indent=2))
"
}
# ----- Setup -----
mkdir -p "$RUNS_DIR" "$LATEST_DIR" "$WORKTREE_BASE"
NODE_DEFAULT="$(node -v)"
# Shared TypeScript compiler fallback (for versions where npm install can't get tsc)
TSC_FALLBACK_DIR="$WORKTREE_BASE/.tsc-fallback"
TSC_FALLBACK=""
ensure_tsc_fallback() {
if [[ -n "$TSC_FALLBACK" ]] && [[ -x "$TSC_FALLBACK" ]]; then
return 0
fi
log "Installing shared TypeScript compiler fallback..."
mkdir -p "$TSC_FALLBACK_DIR"
(cd "$TSC_FALLBACK_DIR" && npm install typescript@4.9.5 2>/dev/null) || true
TSC_FALLBACK="$TSC_FALLBACK_DIR/node_modules/.bin/tsc"
if [[ -x "$TSC_FALLBACK" ]]; then
log "Fallback tsc ready: $TSC_FALLBACK"
return 0
fi
err "Could not install fallback tsc"
return 1
}
# Record system info and derive system ID + run filename
log "Recording system info..."
SYSTEM_INFO_JSON="$(get_system_info)"
echo "$SYSTEM_INFO_JSON"
SYSTEM_ID="$(echo "$SYSTEM_INFO_JSON" | python3 -c "import json,sys; print(json.load(sys.stdin)['system_id'])")"
RUN_STAMP="$(date -u +%Y-%m-%dT%H-%M-%SZ)"
RUN_FILE="$RUNS_DIR/${RUN_STAMP}_${SYSTEM_ID}.json"
LATEST_FILE="$LATEST_DIR/${SYSTEM_ID}.json"
log "System ID: $SYSTEM_ID"
log "Run file: $RUN_FILE"
# Initialize the run file (system info + empty results array)
python3 -c "
import json, sys
system_info = json.loads(sys.argv[1])
run_data = {'system': system_info, 'versions': []}
print(json.dumps(run_data, indent=2))
" "$SYSTEM_INFO_JSON" > "$RUN_FILE"
# ----- Main Loop -----
total=${#VERSIONS[@]}
idx=0
for tag in "${VERSIONS[@]}"; do
idx=$((idx + 1))
ver="$(strip_v "$tag")"
log "===== [$idx/$total] Benchmarking $tag ====="
WORKTREE="$WORKTREE_BASE/$tag"
# Verify tag exists
if ! git -C "$REPO_ROOT" rev-parse "$tag" &>/dev/null; then
err "Tag $tag not found, skipping"
continue
fi
# Select Node version
node_ver="$(pick_node_version "$ver")"
log "Using Node $node_ver for $tag"
use_node "$node_ver"
log "Active Node: $(node -v)"
# Create worktree
if [[ -d "$WORKTREE" ]]; then
log "Cleaning existing worktree $WORKTREE"
git -C "$REPO_ROOT" worktree remove --force "$WORKTREE" 2>/dev/null || rm -rf "$WORKTREE"
fi
log "Creating worktree for $tag..."
git -C "$REPO_ROOT" worktree add --detach "$WORKTREE" "$tag" 2>/dev/null
# Install dependencies
log "Installing dependencies..."
pushd "$WORKTREE" > /dev/null
LESS_DIR=""
BENCH_TARGET=""
if is_monorepo "$tag"; then
# Monorepo era (v4.x)
LESS_DIR="$WORKTREE/packages/less"
BENCH_TARGET="$LESS_DIR/benchmark"
# v4.3+ uses workspace: protocol requiring pnpm; earlier v4.x uses npm
if grep -q '"workspace:' "$LESS_DIR/package.json" 2>/dev/null || \
grep -q '"workspace:' "$WORKTREE/package.json" 2>/dev/null; then
log "Detected workspace: protocol, using pnpm..."
if command -v pnpm &>/dev/null; then
(cd "$WORKTREE" && pnpm install --ignore-scripts 2>/dev/null) || true
else
err "pnpm not available but needed for $tag workspace: deps"
# Fallback: install just typescript in packages/less
(cd "$LESS_DIR" && npm install typescript --no-save 2>/dev/null) || true
fi
else
# npm-based install for older v4.x / v3.12+
npm install --ignore-scripts --legacy-peer-deps 2>/dev/null || true
pushd "$LESS_DIR" > /dev/null
npm install --ignore-scripts --legacy-peer-deps 2>/dev/null || {
# npm install often fails on monorepo versions due to unpublished workspace
# packages (e.g. @less/test-import-module). Install runtime deps separately.
log "npm install failed, installing runtime deps separately..."
runtime_deps=$(python3 -c "
import json
with open('package.json') as f:
d = json.load(f)
deps = d.get('dependencies', {})
# Print package@range pairs
for name, ver in deps.items():
if not name.startswith('@less/'):
print(name + '@' + ver.lstrip('^~'))
" 2>/dev/null)
if [[ -n "$runtime_deps" ]]; then
deps_temp="$WORKTREE_BASE/.deps-temp"
mkdir -p "$deps_temp"
(cd "$deps_temp" && npm install $runtime_deps 2>/dev/null) || true
mkdir -p node_modules
# Copy all installed packages (including transitive deps) into node_modules
if [[ -d "$deps_temp/node_modules" ]]; then
cp -r "$deps_temp"/node_modules/* node_modules/ 2>/dev/null || true
# Also copy @scoped packages
for scope_dir in "$deps_temp"/node_modules/@*/; do
if [[ -d "$scope_dir" ]]; then
scope_name="$(basename "$scope_dir")"
mkdir -p "node_modules/$scope_name"
cp -r "$scope_dir"*/ "node_modules/$scope_name/" 2>/dev/null || true
fi
done
fi
fi
}
popd > /dev/null
fi
# Build TypeScript
pushd "$LESS_DIR" > /dev/null
log "Building TypeScript..."
if [[ -f "tsconfig.build.json" ]] || [[ -f "tsconfig.json" ]]; then
# Find tsc: check local, root, system, then shared fallback
TSC=""
for tsc_path in \
"./node_modules/.bin/tsc" \
"$WORKTREE/node_modules/.bin/tsc"; do
if [[ -x "$tsc_path" ]]; then
TSC="$tsc_path"
break
fi
done
if [[ -z "$TSC" ]]; then
# Try installing locally first
npm install typescript --no-save 2>/dev/null || true
if [[ -x "./node_modules/.bin/tsc" ]]; then
TSC="./node_modules/.bin/tsc"
else
# Use shared fallback tsc
ensure_tsc_fallback && TSC="$TSC_FALLBACK"
fi
fi
if [[ -n "$TSC" ]] && [[ -x "$TSC" ]]; then
TSCONFIG="tsconfig.build.json"
[[ -f "$TSCONFIG" ]] || TSCONFIG="tsconfig.json"
$TSC -p "$TSCONFIG" 2>/dev/null || {
log "Retrying tsc with --skipLibCheck..."
$TSC --skipLibCheck -p "$TSCONFIG" 2>/dev/null || {
err "Build failed completely for $tag, skipping"
popd > /dev/null
popd > /dev/null
git -C "$REPO_ROOT" worktree remove --force "$WORKTREE" 2>/dev/null || true
continue
}
}
else
err "No tsc available for $tag, skipping"
popd > /dev/null
popd > /dev/null
git -C "$REPO_ROOT" worktree remove --force "$WORKTREE" 2>/dev/null || true
continue
fi
fi
popd > /dev/null
else
# Pre-monorepo (v2.x, v3.x) - lib/ is already in git
LESS_DIR="$WORKTREE"
BENCH_TARGET="$WORKTREE/benchmark"
npm install --ignore-scripts --legacy-peer-deps 2>/dev/null || true
fi
popd > /dev/null
# Copy benchmark files and runner into the worktree
mkdir -p "$BENCH_TARGET"
cp "$BENCHMARK_DIR/benchmark-runner.js" "$BENCH_TARGET/"
cp "$BENCHMARK_DIR/benchmark.less" "$BENCH_TARGET/"
cp "$BENCHMARK_DIR/benchmark-import-target.less" "$BENCH_TARGET/"
cp "$BENCHMARK_DIR/benchmark-import-reference-target.less" "$BENCH_TARGET/"
cp "$BENCHMARK_DIR/benchmark-v3.less" "$BENCH_TARGET/" 2>/dev/null || true
cp "$BENCHMARK_DIR/benchmark-v37.less" "$BENCH_TARGET/" 2>/dev/null || true
cp "$BENCHMARK_DIR/benchmark-v39.less" "$BENCH_TARGET/" 2>/dev/null || true
# Run benchmarks for applicable files
CURRENT_NODE="$(node -v)"
CURRENT_DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
# Initialize tag JSON via python for safety
tag_json=$(python3 -c "
import json
print(json.dumps({
'tag': '$tag',
'version': '$ver',
'node_version': '$CURRENT_NODE',
'date': '$CURRENT_DATE',
'benchmarks': {}
}))
")
bench_count=${#BENCH_FILE_NAMES[@]}
for (( bi=0; bi= $min_ver)"
continue
fi
bench_path="$BENCH_TARGET/$bench_file"
if [[ ! -f "$bench_path" ]]; then
log " Skipping $bench_file (file not found)"
continue
fi
log " Running $bench_file ($RUNS runs, $WARMUP warmup)..."
# Run from the Less package directory so require() finds the compiler
# Save result to temp file to avoid shell quoting issues
result_file=$(mktemp)
# Pass --math=always for consistent cross-version results
# (v4+ defaults to parens-division which changes evaluation behavior)
(cd "$LESS_DIR" && node "$BENCH_TARGET/benchmark-runner.js" "$bench_path" "$RUNS" "$WARMUP" --math=always > "$result_file" 2>&1) || true
# Use python to safely merge results
tag_json=$(python3 -c "
import sys, json
tag_data = json.loads(sys.stdin.read())
bench_file = sys.argv[1]
result_file = sys.argv[2]
try:
with open(result_file) as f:
result_str = f.read().strip()
result_data = json.loads(result_str)
tag_data['benchmarks'][bench_file] = result_data
print(json.dumps(tag_data))
except (json.JSONDecodeError, Exception) as e:
tag_data['benchmarks'][bench_file] = {'error': str(e)[:500]}
print(json.dumps(tag_data))
" "$bench_file" "$result_file" <<< "$tag_json")
if python3 -c "import json; json.load(open('$result_file'))" 2>/dev/null; then
log " Done $bench_file"
else
err " $bench_file failed: $(head -5 "$result_file")"
fi
rm -f "$result_file"
done
# Append version results to run file
python3 -c "
import json, sys
tag_data = json.loads(sys.stdin.read())
run_file = sys.argv[1]
with open(run_file) as f:
run_data = json.load(f)
run_data['versions'].append(tag_data)
with open(run_file, 'w') as f:
json.dump(run_data, f, indent=2)
" "$RUN_FILE" <<< "$tag_json"
log "Results appended to $RUN_FILE"
# Clean up worktree
log "Cleaning up worktree..."
git -C "$REPO_ROOT" worktree remove --force "$WORKTREE" 2>/dev/null || rm -rf "$WORKTREE"
log "===== Done $tag ====="
echo ""
done
# Restore original Node version
restore_node
# Copy to latest
cp "$RUN_FILE" "$LATEST_FILE"
log "Latest results: $LATEST_FILE"
# Generate summary
log "Generating summary..."
python3 - "$RUN_FILE" << 'PYEOF'
import json, sys
with open(sys.argv[1]) as f:
run_data = json.load(f)
system = run_data.get('system', {})
print("\n" + "=" * 80)
print("LESS HISTORICAL BENCHMARK SUMMARY")
print(f"System: {system.get('cpu_model', '?')} | {system.get('arch', '?')} | {system.get('total_memory_gb', '?')} GB")
print(f"Date: {system.get('date', '?')}")
print("=" * 80)
print(f"\n{'Version':<12} {'Node':<12} {'File':<25} {'Avg (ms)':<12} {'Median':<12} {'Min':<10} {'Max':<10} {'+-pct':<8} {'KB/s':<8}")
print("-" * 110)
for entry in run_data.get('versions', []):
tag = entry.get('tag', '?')
node = entry.get('node_version', '?')
for bench_name, bench_data in entry.get('benchmarks', {}).items():
if 'error' in bench_data:
print(f"{tag:<12} {node:<12} {bench_name:<25} {'ERROR':>10}")
continue
render = bench_data.get('render')
if not render:
print(f"{tag:<12} {node:<12} {bench_name:<25} {'NO DATA':>10}")
continue
print(f"{tag:<12} {node:<12} {bench_name:<25} {render['avg']:>10.1f} {render['median']:>10.1f} {render['min']:>8.1f} {render['max']:>8.1f} {render['variance_pct']:>6.1f}% {render.get('throughput_kbs', 0):>6}")
print("\n" + "=" * 80)
PYEOF
log "All benchmarks complete! Results in $RESULTS_DIR/"
log " - This run: $RUN_FILE"
log " - Latest: $LATEST_FILE"
log " - All runs: $RUNS_DIR/"
================================================
FILE: packages/less/bin/lessc
================================================
#!/usr/bin/env node
/* eslint indent: [2, 2, {"SwitchCase": 1}] */
import path from 'path';
import os from 'os';
import { createRequire } from 'module';
import fs from '../lib/less-node/fs.js';
import * as utils from '../lib/less/utils.js';
import * as Constants from '../lib/less/constants.js';
import less from '../lib/less-node/index.js';
const require = createRequire(import.meta.url);
var errno;
try {
errno = require('errno');
} catch (err) {
errno = null;
}
var pluginManager = new less.PluginManager(less);
var fileManager = new less.FileManager();
var plugins = [];
var queuePlugins = [];
var args = process.argv.slice(1);
var silent = false;
var quiet = false;
var verbose = false;
var options = less.options;
options.plugins = plugins;
options.reUsePluginManager = true;
var sourceMapOptions = {};
var continueProcessing = true;
var checkArgFunc = function checkArgFunc(arg, option) {
if (!option) {
console.error(''.concat(arg, ' option requires a parameter'));
continueProcessing = false;
process.exitCode = 1;
return false;
}
return true;
};
var checkBooleanArg = function checkBooleanArg(arg) {
var onOff = /^((on|t|true|y|yes)|(off|f|false|n|no))$/i.exec(arg);
if (!onOff) {
console.error(' unable to parse '.concat(arg, ' as a boolean. use one of on/t/true/y/yes/off/f/false/n/no'));
continueProcessing = false;
process.exitCode = 1;
return false;
}
return Boolean(onOff[2]);
};
var parseVariableOption = function parseVariableOption(option, variables) {
var parts = option.split('=', 2);
variables[parts[0]] = parts[1];
};
var sourceMapFileInline = false;
var pendingDeprecations = [];
function printUsage() {
less.lesscHelper.printUsage();
pluginManager.Loader.printUsage(plugins);
continueProcessing = false;
}
function render() {
if (!continueProcessing) {
return;
}
var input = args[1];
if (input && input != '-') {
input = path.resolve(process.cwd(), input);
}
var output = args[2];
var outputbase = args[2];
if (output) {
output = path.resolve(process.cwd(), output);
}
if (options.disablePluginRule && queuePlugins.length > 0) {
console.error('--plugin and --disable-plugin-rule may not be used at the same time');
process.exitCode = 1;
return;
}
if (options.sourceMap) {
// Validate conflicting options
if (sourceMapOptions.sourceMapURL && sourceMapOptions.disableSourcemapAnnotation) {
console.error('You cannot provide flag --source-map-url with --source-map-no-annotation.');
console.error('Please remove one of those flags.');
process.exitcode = 1;
return;
}
// Handle explicit sourceMapFullFilename (from --source-map=filename)
// Normalization of other options (sourceMapBasepath, sourceMapRootpath, etc.)
// is handled automatically in parse-tree.js
if (sourceMapOptions.sourceMapFullFilename && !sourceMapFileInline) {
var mapFilename = path.resolve(process.cwd(), sourceMapOptions.sourceMapFullFilename);
var mapDir = path.dirname(mapFilename);
if (output) {
var outputDir = path.dirname(output);
// Set sourceMapOutputFilename relative to map directory
sourceMapOptions.sourceMapOutputFilename = path.join(
path.relative(mapDir, outputDir),
path.basename(output)
);
// Set sourceMapFilename relative to output directory (for sourceMappingURL comment)
sourceMapOptions.sourceMapFilename = path.join(
path.relative(outputDir, mapDir),
path.basename(sourceMapOptions.sourceMapFullFilename)
);
} else {
// No output filename, just use basename
sourceMapOptions.sourceMapOutputFilename = path.basename(output || 'output.css');
sourceMapOptions.sourceMapFilename = path.basename(sourceMapOptions.sourceMapFullFilename);
}
} else if (!sourceMapOptions.sourceMapFullFilename && output && !sourceMapFileInline) {
// No explicit sourcemap filename, derive from output
sourceMapOptions.sourceMapOutputFilename = path.basename(output);
sourceMapOptions.sourceMapFullFilename = ''.concat(output, '.map');
} else if (!output && !sourceMapFileInline) {
console.error('the sourcemap option only has an optional filename if the css filename is given');
console.error('consider adding --source-map-map-inline which embeds the sourcemap into the css');
process.exitCode = 1;
return;
}
}
if (!input) {
console.error('lessc: no input files');
console.error('');
printUsage();
process.exitCode = 1;
return;
}
var mkdirp;
var ensureDirectory = function ensureDirectory(filepath) {
var dir = path.dirname(filepath);
var cmd;
var existsSync = fs.existsSync || path.existsSync;
if (!existsSync(dir)) {
if (mkdirp === undefined) {
try {
mkdirp = require('make-dir');
} catch (e) {
mkdirp = null;
}
}
cmd = mkdirp && mkdirp.sync || fs.mkdirSync;
cmd(dir);
}
};
if (options.depends) {
if (!outputbase) {
console.error('option --depends requires an output path to be specified');
process.exitCode = 1;
return;
}
process.stdout.write(''.concat(outputbase, ': '));
}
if (!sourceMapFileInline) {
var writeSourceMap = function writeSourceMap() {
var output = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var onDone = arguments.length > 1 ? arguments[1] : undefined;
var filename = sourceMapOptions.sourceMapFullFilename;
ensureDirectory(filename);
// To fix https://github.com/less/less.js/issues/3646
output = output.toString();
fs.writeFile(filename, output, 'utf8', function (err) {
if (err) {
var description = 'Error: ';
if (errno && errno.errno[err.errno]) {
description += errno.errno[err.errno].description;
} else {
description += ''.concat(err.code, ' ').concat(err.message);
}
console.error('lessc: failed to create file '.concat(filename));
console.error(description);
process.exitCode = 1;
} else {
less.logger.info('lessc: wrote '.concat(filename));
}
onDone();
});
};
}
var writeSourceMapIfNeeded = function writeSourceMapIfNeeded(output, onDone) {
if (options.sourceMap && !sourceMapFileInline) {
writeSourceMap(output, onDone);
} else {
onDone();
}
};
var writeOutput = function writeOutput(output, result, onSuccess) {
if (options.depends) {
onSuccess();
} else if (output) {
ensureDirectory(output);
fs.writeFile(output, result.css, {
encoding: 'utf8'
}, function (err) {
if (err) {
var description = 'Error: ';
if (errno && errno.errno[err.errno]) {
description += errno.errno[err.errno].description;
} else {
description += ''.concat(err.code, ' ').concat(err.message);
}
console.error('lessc: failed to create file '.concat(output));
console.error(description);
process.exitCode = 1;
} else {
less.logger.info('lessc: wrote '.concat(output));
onSuccess();
}
});
} else if (!options.depends) {
process.stdout.write(result.css);
onSuccess();
}
};
var logDependencies = function logDependencies(options, result) {
if (options.depends) {
var depends = '';
for (var i = 0; i < result.imports.length; i++) {
depends += ''.concat(result.imports[i], ' ');
}
console.log(depends);
}
};
var parseLessFile = function parseLessFile(e, data) {
if (e) {
console.error('lessc: '.concat(e.message));
process.exitCode = 1;
return;
}
data = data.replace(/^\uFEFF/, '');
options.paths = [path.dirname(input)].concat(options.paths);
options.filename = input;
if (options.lint) {
options.sourceMap = false;
}
sourceMapOptions.sourceMapFileInline = sourceMapFileInline;
if (options.sourceMap) {
options.sourceMap = sourceMapOptions;
}
less.logger.addListener({
info: function info(msg) {
if (verbose) {
console.log(msg);
}
},
warn: function warn(msg) {
// do not show warning if the silent option is used
if (!silent && !quiet) {
console.warn(msg);
}
},
error: function error(msg) {
if (!silent) {
console.error(msg);
}
}
});
less.render(data, options).then(function (result) {
if (!options.lint) {
writeOutput(output, result, function () {
writeSourceMapIfNeeded(result.map, function () {
logDependencies(options, result);
});
});
}
}, function (err) {
if (!options.silent) {
console.error(err.toString({
stylize: options.color && less.lesscHelper.stylize
}));
}
process.exitCode = 1;
});
};
if (input != '-') {
fs.readFile(input, 'utf8', parseLessFile);
} else {
process.stdin.resume();
process.stdin.setEncoding('utf8');
var buffer = '';
process.stdin.on('data', function (data) {
buffer += data;
});
process.stdin.on('end', function () {
parseLessFile(false, buffer);
});
}
}
function processPluginQueue() {
var x = 0;
function pluginError(name) {
console.error('Unable to load plugin '.concat(name, ' please make sure that it is installed under or at the same level as less'));
process.exitCode = 1;
}
function pluginFinished(plugin) {
x++;
plugins.push(plugin);
if (x === queuePlugins.length) {
render();
}
}
queuePlugins.forEach(function (queue) {
var context = utils.clone(options);
pluginManager.Loader.loadPlugin(queue.name, process.cwd(), context, less.environment, fileManager).then(function (data) {
pluginFinished({
fileContent: data.contents,
filename: data.filename,
options: queue.options
});
}).catch(function () {
pluginError(queue.name);
});
});
} // self executing function so we can return
(function () {
args = args.filter(function (arg) {
var match;
match = arg.match(/^-I(.+)$/);
if (match) {
options.paths.push(match[1]);
return false;
}
match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=(.*))?$/i);
if (match) {
arg = match[1];
} else {
return arg;
}
switch (arg) {
case 'v':
case 'version':
console.log('lessc '.concat(less.version.join('.'), ' (Less Compiler) [JavaScript]'));
continueProcessing = false;
break;
case 'verbose':
options.verbose = verbose = true;
break;
case 's':
case 'silent':
options.silent = silent = true;
break;
case 'quiet':
options.quiet = quiet = true;
break;
case 'quiet-deprecations':
options.quietDeprecations = true;
break;
case 'l':
case 'lint':
options.lint = true;
break;
case 'strict-imports':
options.strictImports = true;
break;
case 'h':
case 'help':
printUsage();
break;
case 'x':
case 'compress':
options.compress = true;
break;
case 'insecure':
options.insecure = true;
break;
case 'M':
case 'depends':
options.depends = true;
break;
case 'max-line-len':
if (checkArgFunc(arg, match[2])) {
options.maxLineLen = parseInt(match[2], 10);
if (options.maxLineLen <= 0) {
options.maxLineLen = -1;
}
}
break;
case 'no-color':
options.color = false;
break;
case 'js':
options.javascriptEnabled = true;
pendingDeprecations.push('Warning: Inline JavaScript (--js) is deprecated and will be removed in Less 5.x. Use Less functions or custom plugins instead. (js-eval)');
break;
case 'no-js':
// eslint-disable-next-line max-len
console.error('The "--no-js" argument is deprecated, as inline JavaScript is disabled by default. Use "--js" to enable inline JavaScript (not recommended).');
break;
case 'include-path':
if (checkArgFunc(arg, match[2])) {
// ; supported on windows.
// : supported on windows and linux, excluding a drive letter like C:\ so C:\file:D:\file parses to 2
options.paths = match[2].split(os.type().match(/Windows/) ? /:(?!\\)|;/ : ':').map(function (p) {
if (p) {
return path.resolve(process.cwd(), p);
}
});
}
break;
case 'line-numbers':
if (checkArgFunc(arg, match[2])) {
options.dumpLineNumbers = match[2];
pendingDeprecations.push('Warning: The --line-numbers option is deprecated and will be removed in Less 5.x. Use source maps instead (--source-map). (dump-line-numbers)');
}
break;
case 'source-map':
options.sourceMap = true;
if (match[2]) {
sourceMapOptions.sourceMapFullFilename = match[2];
}
break;
case 'source-map-rootpath':
if (checkArgFunc(arg, match[2])) {
sourceMapOptions.sourceMapRootpath = match[2];
}
break;
case 'source-map-basepath':
if (checkArgFunc(arg, match[2])) {
sourceMapOptions.sourceMapBasepath = match[2];
}
break;
case 'source-map-inline':
case 'source-map-map-inline':
sourceMapFileInline = true;
options.sourceMap = true;
break;
case 'source-map-include-source':
case 'source-map-less-inline':
sourceMapOptions.outputSourceFiles = true;
break;
case 'source-map-url':
if (checkArgFunc(arg, match[2])) {
sourceMapOptions.sourceMapURL = match[2];
}
break;
case 'source-map-no-annotation':
sourceMapOptions.disableSourcemapAnnotation = true;
break;
case 'rp':
case 'rootpath':
if (checkArgFunc(arg, match[2])) {
options.rootpath = match[2].replace(/\\/g, '/');
}
break;
case 'ie-compat':
pendingDeprecations.push('Warning: The --ie-compat option is deprecated, as it has no effect on compilation.');
break;
case 'relative-urls':
pendingDeprecations.push('Warning: The --relative-urls option has been deprecated. Use --rewrite-urls=all.');
options.rewriteUrls = Constants.RewriteUrls.ALL;
break;
case 'ru':
case 'rewrite-urls':
var m = match[2];
if (m) {
if (m === 'local') {
options.rewriteUrls = Constants.RewriteUrls.LOCAL;
} else if (m === 'off') {
options.rewriteUrls = Constants.RewriteUrls.OFF;
} else if (m === 'all') {
options.rewriteUrls = Constants.RewriteUrls.ALL;
} else {
console.error('Unknown rewrite-urls argument '.concat(m));
continueProcessing = false;
process.exitCode = 1;
}
} else {
options.rewriteUrls = Constants.RewriteUrls.ALL;
}
break;
case 'sm':
case 'strict-math':
pendingDeprecations.push('Warning: The --strict-math option has been deprecated. Use --math=strict.');
if (checkArgFunc(arg, match[2])) {
if (checkBooleanArg(match[2])) {
options.math = Constants.Math.PARENS;
}
}
break;
case 'm':
case 'math': {
let m = match[2];
if (checkArgFunc(arg, m)) {
if (m === 'always') {
pendingDeprecations.push('Warning: --math=always is deprecated and will be removed in Less 5.x. Use --math=parens-division (default) or --math=parens. (math-always)');
options.math = Constants.Math.ALWAYS;
} else if (m === 'parens-division') {
options.math = Constants.Math.PARENS_DIVISION;
} else if (m === 'parens' || m === 'strict') {
options.math = Constants.Math.PARENS;
} else if (m === 'strict-legacy') {
pendingDeprecations.push('Warning: --math=strict-legacy has been removed. Defaulting to --math=strict.');
options.math = Constants.Math.PARENS;
}
}
break;
}
case 'su':
case 'strict-units':
if (checkArgFunc(arg, match[2])) {
options.strictUnits = checkBooleanArg(match[2]);
}
break;
case 'global-var':
if (checkArgFunc(arg, match[2])) {
if (!options.globalVars) {
options.globalVars = {};
}
parseVariableOption(match[2], options.globalVars);
}
break;
case 'modify-var':
if (checkArgFunc(arg, match[2])) {
if (!options.modifyVars) {
options.modifyVars = {};
}
parseVariableOption(match[2], options.modifyVars);
}
break;
case 'url-args':
if (checkArgFunc(arg, match[2])) {
options.urlArgs = match[2];
}
break;
case 'plugin':
var splitupArg = match[2].match(/^([^=]+)(=(.*))?/);
var name = splitupArg[1];
var pluginOptions = splitupArg[3];
queuePlugins.push({
name: name,
options: pluginOptions
});
break;
case 'disable-plugin-rule':
options.disablePluginRule = true;
break;
default:
queuePlugins.push({
name: arg,
options: match[2],
default: true
});
break;
}
});
// Flush queued deprecation warnings (respects --silent, --quiet, --quiet-deprecations)
if (!silent && !quiet && !options.quietDeprecations) {
pendingDeprecations.forEach(function (msg) {
console.warn(msg);
});
}
if (queuePlugins.length > 0) {
processPluginQueue();
} else {
render();
}
})();
================================================
FILE: packages/less/bower.json
================================================
{
"name": "less",
"main": "dist/less.js",
"ignore": [
"**/.*",
"benchmark",
"bin",
"lib",
"src",
"build",
"test",
"*.md",
"LICENSE",
"Gruntfile.js",
"*.json",
"*.yml",
".gitattributes",
".npmignore",
".eslintignore",
"tsconfig.json"
]
}
================================================
FILE: packages/less/build/banner.js
================================================
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const pkg = require('./../package.json');
export default
`/**
* Less - ${ pkg.description } v${ pkg.version }
* http://lesscss.org
*
* Copyright (c) 2009-${new Date().getFullYear()}, ${ pkg.author.name } <${ pkg.author.email }>
* Licensed under the ${ pkg.license } License.
*
* @license ${ pkg.license }
*/
`;
================================================
FILE: packages/less/build/rollup.js
================================================
import { rollup } from 'rollup';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { nodeResolve as resolve } from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import banner from './banner.js';
import path from 'path';
import { fileURLToPath } from 'url';
import { createRequire } from 'module';
import minimist from 'minimist';
const require = createRequire(import.meta.url);
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const rootPath = path.join(__dirname, '..');
const pkg = require(path.join(rootPath, 'package.json'));
const args = minimist(process.argv.slice(2));
let outDir = args.dist ? './dist' : './tmp';
/** Virtual 'module' for CJS bundle - provides createRequire that returns CJS require */
function moduleShim() {
return {
name: 'module-shim',
resolveId(id) {
if (id === 'module') return '\0module';
return null;
},
load(id) {
if (id === '\0module') {
return `export function createRequire() { return require; }`;
}
return null;
}
};
}
/** Inline package.json version - avoid runtime require of ../../package.json from wrong path */
function inlinePackageVersion() {
const version = JSON.stringify(pkg.version);
return {
name: 'inline-package-version',
transform(code, id) {
if (id.replace(/\\/g, '/').includes('less-node/index.js')) {
return {
code: code.replace(
/const\s*\{\s*version\s*\}\s*=\s*require\s*\(\s*['"]\.\.\/\.\.\/package\.json['"]\s*\)/,
`const version = ${version}`
),
map: null
};
}
return null;
}
};
}
async function buildLessNodeCjs() {
const outFile = path.join(rootPath, outDir, 'less-node.cjs');
console.log(`Writing ${outDir}/less-node.cjs...`);
const bundle = await rollup({
input: './lib/less-node/index.js',
plugins: [
moduleShim(),
inlinePackageVersion(),
resolve(),
commonjs(),
json()
]
});
await bundle.write({
file: outFile,
format: 'cjs',
exports: 'default',
banner
});
}
async function buildBrowser() {
let bundle = await rollup({
input: './lib/less-browser/bootstrap.js',
output: [
{
file: 'less.js',
format: 'umd'
},
{
file: 'less.min.js',
format: 'umd'
}
],
plugins: [
resolve(),
commonjs(),
json(),
terser({
compress: true,
include: [/^.+\.min\.js$/],
output: {
comments: function(node, comment) {
if (comment.type == 'comment2') {
// preserve banner
return /@license/i.test(comment.value);
}
}
}
})
]
});
if (!args.out || args.out.indexOf('less.js') > -1) {
const file = args.out || `${outDir}/less.js`;
console.log(`Writing ${file}...`);
await bundle.write({
file: path.join(rootPath, file),
format: 'umd',
name: 'less',
banner
});
}
if (!args.out || args.out.indexOf('less.min.js') > -1) {
const file = args.out || `${outDir}/less.min.js`;
console.log(`Writing ${file}...`);
await bundle.write({
file: path.join(rootPath, file),
format: 'umd',
name: 'less',
sourcemap: true,
banner
});
}
}
async function build() {
await buildLessNodeCjs();
await buildBrowser();
}
build();
================================================
FILE: packages/less/index.cjs
================================================
// CJS entry — requires the pre-built CJS bundle
module.exports = require('./dist/less-node.cjs');
================================================
FILE: packages/less/lib/less/constants.js
================================================
export const Math = {
ALWAYS: 0,
PARENS_DIVISION: 1,
PARENS: 2
// removed - STRICT_LEGACY: 3
};
export const RewriteUrls = {
OFF: 0,
LOCAL: 1,
ALL: 2
};
================================================
FILE: packages/less/lib/less/contexts.js
================================================
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])) {
destination[propertiesToCopy[i]] = original[propertiesToCopy[i]];
}
}
};
/*
parse is used whilst parsing
*/
const parseCopyProperties = [
// options
'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', // 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', // 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) {
copyFromOriginal(options, this, parseCopyProperties);
if (typeof this.paths === 'string') { this.paths = [this.paths]; }
};
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) {
copyFromOriginal(options, this, evalCopyProperties);
if (typeof this.paths === 'string') { this.paths = [this.paths]; }
this.frames = frames || [];
this.importantScope = this.importantScope || [];
};
contexts.Eval.prototype.enterCalc = function () {
if (!this.calcStack) {
this.calcStack = [];
}
this.calcStack.push(true);
this.inCalc = true;
};
contexts.Eval.prototype.exitCalc = function () {
this.calcStack.pop();
if (!this.calcStack.length) {
this.inCalc = false;
}
};
contexts.Eval.prototype.inParenthesis = function () {
if (!this.parensStack) {
this.parensStack = [];
}
this.parensStack.push(true);
};
contexts.Eval.prototype.outOfParenthesis = function () {
this.parensStack.pop();
};
contexts.Eval.prototype.inCalc = false;
contexts.Eval.prototype.mathOn = true;
contexts.Eval.prototype.isMathOn = function (op) {
if (!this.mathOn) {
return false;
}
if (op === '/' && this.math !== Constants.Math.ALWAYS && (!this.parensStack || !this.parensStack.length)) {
return false;
}
if (this.math > Constants.Math.PARENS_DIVISION) {
return this.parensStack && this.parensStack.length;
}
return true;
};
contexts.Eval.prototype.pathRequiresRewrite = function (path) {
const isRelative = this.rewriteUrls === Constants.RewriteUrls.LOCAL ? isPathLocalRelative : isPathRelative;
return isRelative(path);
};
contexts.Eval.prototype.rewritePath = function (path, rootpath) {
let newPath;
rootpath = rootpath || '';
newPath = this.normalizePath(rootpath + path);
// If a path was explicit relative and the rootpath was not an absolute path
// we must ensure that the new path is also explicit relative.
if (isPathLocalRelative(path) &&
isPathRelative(rootpath) &&
isPathLocalRelative(newPath) === false) {
newPath = `./${newPath}`;
}
return newPath;
};
contexts.Eval.prototype.normalizePath = function (path) {
const segments = path.split('/').reverse();
let segment;
path = [];
while (segments.length !== 0) {
segment = segments.pop();
switch ( segment ) {
case '.':
break;
case '..':
if ((path.length === 0) || (path[path.length - 1] === '..')) {
path.push( segment );
} else {
path.pop();
}
break;
default:
path.push(segment);
break;
}
}
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 ?
================================================
FILE: packages/less/lib/less/data/colors.js
================================================
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'
};
================================================
FILE: packages/less/lib/less/data/index.js
================================================
import colors from './colors.js';
import unitConversions from './unit-conversions.js';
export default { colors, unitConversions };
================================================
FILE: packages/less/lib/less/data/unit-conversions.js
================================================
export default {
length: {
'm': 1,
'cm': 0.01,
'mm': 0.001,
'in': 0.0254,
'px': 0.0254 / 96,
'pt': 0.0254 / 72,
'pc': 0.0254 / 72 * 12
},
duration: {
's': 1,
'ms': 0.001
},
angle: {
'rad': 1 / (2 * Math.PI),
'deg': 1 / 360,
'grad': 1 / 400,
'turn': 1
}
};
================================================
FILE: packages/less/lib/less/default-options.js
================================================
// Export a new default each time
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
* 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
* 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:
* - @import at root level: Always processed
* - @import inside @-rules (@media, @supports, etc.): Processed (these are not selector blocks)
* - @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
* 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
* URL is always relative to the base imported file */
rewriteUrls: false,
/* How to process math
* 0 always - eagerly try to solve all operations
* 1 parens-division - require parens for division "/"
* 2 parens | strict - require parens for all operations
* 3 strict-legacy - legacy strict behavior (super-strict)
*/
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
* 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: ''
}
}
================================================
FILE: packages/less/lib/less/deprecation.js
================================================
/**
* 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} */
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 };
================================================
FILE: packages/less/lib/less/environment/abstract-file-manager.js
================================================
class AbstractFileManager {
getPath(filename) {
let j = filename.lastIndexOf('?');
if (j > 0) {
filename = filename.slice(0, j);
}
j = filename.lastIndexOf('/');
if (j < 0) {
j = filename.lastIndexOf('\\');
}
if (j < 0) {
return '';
}
return filename.slice(0, j + 1);
}
tryAppendExtension(path, ext) {
return /(\.[a-z]*$)|([?;].*)$/.test(path) ? path : path + ext;
}
tryAppendLessExtension(path) {
return this.tryAppendExtension(path, '.less');
}
supportsSync() {
return false;
}
alwaysMakePathsAbsolute() {
return false;
}
isPathAbsolute(filename) {
return (/^(?:[a-z-]+:|\/|\\|#)/i).test(filename);
}
// TODO: pull out / replace?
join(basePath, laterPath) {
if (!basePath) {
return laterPath;
}
return basePath + laterPath;
}
pathDiff(url, baseUrl) {
// diff between two paths to create a relative path
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) {
return '';
}
max = Math.max(baseUrlParts.directories.length, urlParts.directories.length);
for (i = 0; i < max; i++) {
if (baseUrlParts.directories[i] !== urlParts.directories[i]) { break; }
}
baseUrlDirectories = baseUrlParts.directories.slice(i);
urlDirectories = urlParts.directories.slice(i);
for (i = 0; i < baseUrlDirectories.length - 1; i++) {
diff += '../';
}
for (i = 0; i < urlDirectories.length - 1; 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} baseUrl
*/
extractUrlParts(url, baseUrl) {
// urlParts[1] = protocol://hostname/ OR /
// urlParts[2] = / if path relative to host base
// urlParts[3] = directories
// urlParts[4] = filename
// urlParts[5] = parameters
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 - '${url}'`);
}
// Stylesheets in IE don't always return the full path
if (baseUrl && (!urlParts[1] || urlParts[2])) {
baseUrlParts = baseUrl.match(urlPartsRegex);
if (!baseUrlParts) {
throw new Error(`Could not parse page url - '${baseUrl}'`);
}
urlParts[1] = urlParts[1] || baseUrlParts[1] || '';
if (!urlParts[2]) {
urlParts[3] = baseUrlParts[3] + urlParts[3];
}
}
if (urlParts[3]) {
rawDirectories = urlParts[3].replace(/\\/g, '/').split('/');
// collapse '..' and skip '.'
for (i = 0; i < rawDirectories.length; i++) {
if (rawDirectories[i] === '..') {
directories.pop();
}
else if (rawDirectories[i] !== '.') {
directories.push(rawDirectories[i]);
}
}
}
returner.hostPart = urlParts[1];
returner.directories = directories;
returner.rawPath = (urlParts[1] || '') + rawDirectories.join('/');
returner.path = (urlParts[1] || '') + directories.join('/');
returner.filename = urlParts[4];
returner.fileUrl = returner.path + (urlParts[4] || '');
returner.url = returner.fileUrl + (urlParts[5] || '');
return returner;
}
}
export default AbstractFileManager;
================================================
FILE: packages/less/lib/less/environment/abstract-plugin-loader.js
================================================
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() {
return null;
}
}
evalPlugin(contents, context, imports, pluginOptions, fileInfo) {
let loader, registry, pluginObj, localModule, pluginManager, filename, result;
pluginManager = context.pluginManager;
if (fileInfo) {
if (typeof fileInfo === 'string') {
filename = fileInfo;
}
else {
filename = fileInfo.filename;
}
}
const shortname = (new this.less.FileManager()).extractUrlParts(filename).filename;
if (filename) {
pluginObj = pluginManager.get(filename);
if (pluginObj) {
result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions);
if (result) {
return result;
}
try {
if (pluginObj.use) {
pluginObj.use.call(this.context, pluginObj);
}
}
catch (e) {
e.message = e.message || 'Error during @plugin call';
return new LessError(e, imports, filename);
}
return pluginObj;
}
}
localModule = {
exports: {},
pluginManager,
fileInfo
};
registry = functionRegistry.create();
const registerPlugin = function(obj) {
pluginObj = obj;
};
try {
loader = new Function('module', 'require', 'registerPlugin', 'functions', 'tree', 'less', 'fileInfo', contents);
loader(localModule, this.require(filename), registerPlugin, registry, this.less.tree, this.less, fileInfo);
}
catch (e) {
return new LessError(e, imports, filename);
}
if (!pluginObj) {
pluginObj = localModule.exports;
}
pluginObj = this.validatePlugin(pluginObj, filename, shortname);
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) {
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
result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions);
if (result) {
return result;
}
// Run every @plugin call
try {
if (pluginObj.use) {
pluginObj.use.call(this.context, pluginObj);
}
}
catch (e) {
e.message = e.message || 'Error during @plugin call';
return new LessError(e, imports, filename);
}
}
else {
return new LessError({ message: 'Not a valid plugin' }, imports, filename);
}
return pluginObj;
}
trySetOptions(plugin, filename, name, options) {
if (options && !plugin.setOptions) {
return new LessError({
message: `Options have been provided but the plugin ${name} does not support any options.`
});
}
try {
plugin.setOptions && plugin.setOptions(options);
}
catch (e) {
return new LessError(e);
}
}
validatePlugin(plugin, filename, name) {
if (plugin) {
// support plugins being a function
// so that the plugin can be more usable programmatically
if (typeof plugin === 'function') {
plugin = new plugin();
}
if (plugin.minVersion) {
if (this.compareVersion(plugin.minVersion, this.less.version) < 0) {
return new LessError({
message: `Plugin ${name} requires version ${this.versionToString(plugin.minVersion)}`
});
}
}
return plugin;
}
return null;
}
compareVersion(aVersion, bVersion) {
if (typeof aVersion === 'string') {
aVersion = aVersion.match(/^(\d+)\.?(\d+)?\.?(\d+)?/);
aVersion.shift();
}
for (let i = 0; i < aVersion.length; i++) {
if (aVersion[i] !== bVersion[i]) {
return parseInt(aVersion[i]) > parseInt(bVersion[i]) ? -1 : 1;
}
}
return 0;
}
versionToString(version) {
let versionString = '';
for (let i = 0; i < version.length; i++) {
versionString += (versionString ? '.' : '') + version[i];
}
return versionString;
}
printUsage(plugins) {
for (let i = 0; i < plugins.length; i++) {
const plugin = plugins[i];
if (plugin.printUsage) {
plugin.printUsage();
}
}
}
}
export default AbstractPluginLoader;
================================================
FILE: packages/less/lib/less/environment/environment-api.ts
================================================
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
}
================================================
FILE: packages/less/lib/less/environment/environment.js
================================================
/**
* @todo Document why this abstraction exists, and the relationship between
* environment, file managers, and plugin manager
*/
import logger from '../logger.js';
class Environment {
constructor(externalEnvironment, fileManagers) {
this.fileManagers = fileManagers || [];
externalEnvironment = externalEnvironment || {};
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}`);
}
}
}
getFileManager(filename, currentDirectory, options, environment, isSync) {
if (!filename) {
logger.warn('getFileManager called with no filename.. Please report this issue. continuing.');
}
if (currentDirectory === undefined) {
logger.warn('getFileManager called with null directory.. Please report this issue. continuing.');
}
let fileManagers = this.fileManagers;
if (options.pluginManager) {
fileManagers = [].concat(fileManagers).concat(options.pluginManager.getFileManagers());
}
for (let i = fileManagers.length - 1; i >= 0 ; i--) {
const fileManager = fileManagers[i];
if (fileManager[isSync ? 'supportsSync' : 'supports'](filename, currentDirectory, options, environment)) {
return fileManager;
}
}
return null;
}
addFileManager(fileManager) {
this.fileManagers.push(fileManager);
}
clearFileManagers() {
this.fileManagers = [];
}
}
export default Environment;
================================================
FILE: packages/less/lib/less/environment/file-manager-api.ts
================================================
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,
environment: Environment
): boolean
/**
* If file manager supports async file retrieval for this file type
*/
supports(
filename: string,
currentDirectory: string,
options: Record,
environment: Environment
): boolean
/**
* Loads a file asynchronously.
*/
loadFile(
filename: string,
currentDirectory: string,
options: Record,
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,
environment: Environment
): { error?: unknown, filename: string, contents: string }
}
================================================
FILE: packages/less/lib/less/functions/boolean.js
================================================
import Anonymous from '../tree/anonymous.js';
import Keyword from '../tree/keyword.js';
function boolean(condition) {
return condition ? Keyword.True : Keyword.False;
}
/**
* Functions with evalArgs set to false are sent context
* as the first argument.
*/
function If(context, condition, trueValue, falseValue) {
return condition.eval(context) ? trueValue.eval(context)
: (falseValue ? falseValue.eval(context) : new Anonymous);
}
If.evalArgs = false;
function isdefined(context, variable) {
try {
variable.eval(context);
return Keyword.True;
} catch (e) {
return Keyword.False;
}
}
isdefined.evalArgs = false;
export default { isdefined, boolean, 'if': If };
================================================
FILE: packages/less/lib/less/functions/color-blending.js
================================================
import Color from '../tree/color.js';
// Color Blending
// ref: http://www.w3.org/TR/compositing-1
function colorBlend(mode, color1, color2) {
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 (let i = 0; i < 3; i++) {
cb = color1.rgb[i] / 255;
cs = color2.rgb[i] / 255;
cr = mode(cb, cs);
if (ar) {
cr = (as * cs + ab * (cb -
as * (cb + cs - cr))) / ar;
}
r[i] = cr * 255;
}
return new Color(r, ar);
}
const colorBlendModeFunctions = {
multiply: function(cb, cs) {
return cb * cs;
},
screen: function(cb, cs) {
return cb + cs - cb * cs;
},
overlay: function(cb, cs) {
cb *= 2;
return (cb <= 1) ?
colorBlendModeFunctions.multiply(cb, cs) :
colorBlendModeFunctions.screen(cb - 1, cs);
},
softlight: function(cb, cs) {
let d = 1;
let e = cb;
if (cs > 0.5) {
e = 1;
d = (cb > 0.25) ? Math.sqrt(cb)
: ((16 * cb - 12) * cb + 4) * cb;
}
return cb - (1 - 2 * cs) * e * (d - cb);
},
hardlight: function(cb, cs) {
return colorBlendModeFunctions.overlay(cs, cb);
},
difference: function(cb, cs) {
return Math.abs(cb - cs);
},
exclusion: function(cb, cs) {
return cb + cs - 2 * cb * cs;
},
// non-w3c functions:
average: function(cb, cs) {
return (cb + cs) / 2;
},
negation: function(cb, cs) {
return 1 - Math.abs(cb + cs - 1);
}
};
for (const f in colorBlendModeFunctions) {
// eslint-disable-next-line no-prototype-builtins
if (colorBlendModeFunctions.hasOwnProperty(f)) {
colorBlend[f] = colorBlend.bind(null, colorBlendModeFunctions[f]);
}
}
export default colorBlend;
================================================
FILE: packages/less/lib/less/functions/color.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 Expression from '../tree/expression.js';
import Operation from '../tree/operation.js';
let colorFunctions;
function clamp(val) {
return Math.min(1, Math.max(0, val));
}
function hsla(origColor, hsl) {
const color = colorFunctions.hsla(hsl.h, hsl.s, hsl.l, hsl.a);
if (color) {
if (origColor.value &&
/^(rgb|hsl)/.test(origColor.value)) {
color.value = origColor.value;
} else {
color.value = 'rgb';
}
return color;
}
}
function toHSL(color) {
if (color.toHSL) {
return color.toHSL();
} else {
throw new Error('Argument cannot be evaluated to a color');
}
}
function toHSV(color) {
if (color.toHSV) {
return color.toHSV();
} else {
throw new Error('Argument cannot be evaluated to a color');
}
}
function number(n) {
if (n instanceof Dimension) {
return parseFloat(n.unit.is('%') ? n.value / 100 : n.value);
} else if (typeof n === 'number') {
return n;
} else {
throw {
type: 'Argument',
message: 'color functions take numbers as parameters'
};
}
}
function scaled(n, size) {
if (n instanceof Dimension && n.unit.is('%')) {
return parseFloat(n.value * size / 100);
} else {
return number(n);
}
}
colorFunctions = {
rgb: function (r, g, b) {
let a = 1
/**
* Comma-less syntax
* e.g. rgb(0 128 255 / 50%)
*/
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) {
const op = b
b = op.operands[0]
a = op.operands[1]
}
}
const color = colorFunctions.rgba(r, g, b, a);
if (color) {
color.value = 'rgb';
return color;
}
},
rgba: function (r, g, b, a) {
try {
if (r instanceof Color) {
if (g) {
a = number(g);
} else {
a = r.alpha;
}
return new Color(r.rgb, a, 'rgba');
}
const rgb = [r, g, b].map(c => scaled(c, 255));
a = number(a);
return new Color(rgb, a, 'rgba');
}
catch (e) {}
},
hsl: function (h, s, l) {
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]
}
}
const color = colorFunctions.hsla(h, s, l, a);
if (color) {
color.value = 'hsl';
return color;
}
},
hsla: function (h, s, l, a) {
let m1;
let m2;
function hue(h) {
h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
if (h * 6 < 1) {
return m1 + (m2 - m1) * h * 6;
}
else if (h * 2 < 1) {
return m2;
}
else if (h * 3 < 2) {
return m1 + (m2 - m1) * (2 / 3 - h) * 6;
}
else {
return m1;
}
}
try {
if (h instanceof Color) {
if (s) {
a = number(s);
} else {
a = h.alpha;
}
return new Color(h.rgb, a, 'hsla');
}
h = (number(h) % 360) / 360;
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;
const rgb = [
hue(h + 1 / 3) * 255,
hue(h) * 255,
hue(h - 1 / 3) * 255
];
a = number(a);
return new Color(rgb, a, 'hsla');
}
catch (e) {}
},
hsv: function(h, s, v) {
return colorFunctions.hsva(h, s, v, 1.0);
},
hsva: function(h, s, v, a) {
h = ((number(h) % 360) / 360) * 360;
s = number(s);v = number(v);a = number(a);
let i;
let f;
i = Math.floor((h / 60) % 6);
f = (h / 60) - i;
const vs = [v,
v * (1 - s),
v * (1 - f * s),
v * (1 - (1 - f) * s)];
const perm = [[0, 3, 1],
[2, 0, 1],
[1, 0, 3],
[1, 2, 0],
[3, 1, 0],
[0, 1, 2]];
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(toHSL(color).h);
},
saturation: function (color) {
return new Dimension(toHSL(color).s * 100, '%');
},
lightness: function (color) {
return new Dimension(toHSL(color).l * 100, '%');
},
hsvhue: function(color) {
return new Dimension(toHSV(color).h);
},
hsvsaturation: function (color) {
return new Dimension(toHSV(color).s * 100, '%');
},
hsvvalue: function (color) {
return new Dimension(toHSV(color).v * 100, '%');
},
red: function (color) {
return new Dimension(color.rgb[0]);
},
green: function (color) {
return new Dimension(color.rgb[1]);
},
blue: function (color) {
return new Dimension(color.rgb[2]);
},
alpha: function (color) {
return new Dimension(toHSL(color).a);
},
luma: function (color) {
return new Dimension(color.luma() * color.alpha * 100, '%');
},
luminance: function (color) {
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, '%');
},
saturate: function (color, amount, method) {
// filter: saturate(3.2);
// should be kept as is, so check for color
if (!color.rgb) {
return null;
}
const hsl = toHSL(color);
if (typeof method !== 'undefined' && method.value === 'relative') {
hsl.s += hsl.s * amount.value / 100;
}
else {
hsl.s += amount.value / 100;
}
hsl.s = clamp(hsl.s);
return hsla(color, hsl);
},
desaturate: function (color, amount, method) {
const hsl = toHSL(color);
if (typeof method !== 'undefined' && method.value === 'relative') {
hsl.s -= hsl.s * amount.value / 100;
}
else {
hsl.s -= amount.value / 100;
}
hsl.s = clamp(hsl.s);
return hsla(color, hsl);
},
lighten: function (color, amount, method) {
const hsl = toHSL(color);
if (typeof method !== 'undefined' && method.value === 'relative') {
hsl.l += hsl.l * amount.value / 100;
}
else {
hsl.l += amount.value / 100;
}
hsl.l = clamp(hsl.l);
return hsla(color, hsl);
},
darken: function (color, amount, method) {
const hsl = toHSL(color);
if (typeof method !== 'undefined' && method.value === 'relative') {
hsl.l -= hsl.l * amount.value / 100;
}
else {
hsl.l -= amount.value / 100;
}
hsl.l = clamp(hsl.l);
return hsla(color, hsl);
},
fadein: function (color, amount, method) {
const hsl = toHSL(color);
if (typeof method !== 'undefined' && method.value === 'relative') {
hsl.a += hsl.a * amount.value / 100;
}
else {
hsl.a += amount.value / 100;
}
hsl.a = clamp(hsl.a);
return hsla(color, hsl);
},
fadeout: function (color, amount, method) {
const hsl = toHSL(color);
if (typeof method !== 'undefined' && method.value === 'relative') {
hsl.a -= hsl.a * amount.value / 100;
}
else {
hsl.a -= amount.value / 100;
}
hsl.a = clamp(hsl.a);
return hsla(color, hsl);
},
fade: function (color, amount) {
const hsl = toHSL(color);
hsl.a = amount.value / 100;
hsl.a = clamp(hsl.a);
return hsla(color, hsl);
},
spin: function (color, amount) {
const hsl = toHSL(color);
const hue = (hsl.h + amount.value) % 360;
hsl.h = hue < 0 ? 360 + hue : hue;
return hsla(color, hsl);
},
//
// Copyright (c) 2006-2009 Hampton Catlin, Natalie Weizenbaum, and Chris Eppstein
// http://sass-lang.com
//
mix: function (color1, color2, weight) {
if (!weight) {
weight = new Dimension(50);
}
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];
const alpha = color1.alpha * p + color2.alpha * (1 - p);
return new Color(rgb, alpha);
},
greyscale: function (color) {
return colorFunctions.desaturate(color, new Dimension(100));
},
contrast: function (color, dark, light, threshold) {
// filter: contrast(3.2);
// should be kept as is, so check for color
if (!color.rgb) {
return null;
}
if (typeof light === 'undefined') {
light = colorFunctions.rgba(255, 255, 255, 1.0);
}
if (typeof dark === 'undefined') {
dark = colorFunctions.rgba(0, 0, 0, 1.0);
}
// Figure out which is actually light and dark:
if (dark.luma() > light.luma()) {
const t = light;
light = dark;
dark = t;
}
if (typeof threshold === 'undefined') {
threshold = 0.43;
} else {
threshold = number(threshold);
}
if (color.luma() < threshold) {
return light;
} else {
return dark;
}
},
// Changes made in 2.7.0 - Reverted in 3.0.0
// contrast: function (color, color1, color2, threshold) {
// // Return which of `color1` and `color2` has the greatest contrast with `color`
// // according to the standard WCAG contrast ratio calculation.
// // http://www.w3.org/TR/WCAG20/#contrast-ratiodef
// // The threshold param is no longer used, in line with SASS.
// // filter: contrast(3.2);
// // should be kept as is, so check for color
// if (!color.rgb) {
// return null;
// }
// if (typeof color1 === 'undefined') {
// color1 = colorFunctions.rgba(0, 0, 0, 1.0);
// }
// if (typeof color2 === 'undefined') {
// color2 = colorFunctions.rgba(255, 255, 255, 1.0);
// }
// var contrast1, contrast2;
// var luma = color.luma();
// var luma1 = color1.luma();
// var luma2 = color2.luma();
// // Calculate contrast ratios for each color
// if (luma > luma1) {
// contrast1 = (luma + 0.05) / (luma1 + 0.05);
// } else {
// contrast1 = (luma1 + 0.05) / (luma + 0.05);
// }
// if (luma > luma2) {
// contrast2 = (luma + 0.05) / (luma2 + 0.05);
// } else {
// contrast2 = (luma2 + 0.05) / (luma + 0.05);
// }
// if (contrast1 > contrast2) {
// return color1;
// } else {
// return color2;
// }
// },
argb: function (color) {
return new Anonymous(color.toARGB());
},
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))) {
const val = c.value.slice(1);
return new Color(val, undefined, `#${val}`);
}
if ((c instanceof Color) || (c = Color.fromKeyword(c.value))) {
c.value = undefined;
return c;
}
throw {
type: 'Argument',
message: 'argument must be a color keyword or 3|4|6|8 digit hex e.g. #FFF'
};
},
tint: function(color, amount) {
return colorFunctions.mix(colorFunctions.rgb(255, 255, 255), color, amount);
},
shade: function(color, amount) {
return colorFunctions.mix(colorFunctions.rgb(0, 0, 0), color, amount);
}
};
export default colorFunctions;
================================================
FILE: packages/less/lib/less/functions/data-uri.js
================================================
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;
}
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);
}};
};
================================================
FILE: packages/less/lib/less/functions/default.js
================================================
import Keyword from '../tree/keyword.js';
import * as utils from '../utils.js';
const defaultFunc = {
eval: function () {
const v = this.value_;
const e = this.error_;
if (e) {
throw e;
}
if (!utils.isNullOrUndefined(v)) {
return v ? Keyword.True : Keyword.False;
}
},
value: function (v) {
this.value_ = v;
},
error: function (e) {
this.error_ = e;
},
reset: function () {
this.value_ = this.error_ = null;
}
};
export default defaultFunc;
================================================
FILE: packages/less/lib/less/functions/function-caller.js
================================================
import Expression from '../tree/expression.js';
class functionCaller {
constructor(name, context, index, currentFileInfo) {
this.name = name.toLowerCase();
this.index = index;
this.context = context;
this.currentFileInfo = currentFileInfo;
this.func = context.frames[0].functionRegistry.get(this.name);
}
isValid() {
return Boolean(this.func);
}
call(args) {
if (!(Array.isArray(args))) {
args = [args];
}
const evalArgs = this.func.evalArgs;
if (evalArgs !== false) {
args = args.map(a => a.eval(this.context));
}
const commentFilter = item => !(item.type === 'Comment');
// This code is terrible and should be replaced as per this issue...
// https://github.com/less/less.js/issues/2477
args = args
.filter(commentFilter)
.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 item;
});
if (evalArgs === false) {
return this.func(this.context, ...args);
}
return this.func(...args);
}
}
export default functionCaller;
================================================
FILE: packages/less/lib/less/functions/function-registry.js
================================================
function makeRegistry( base ) {
return {
_data: {},
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
if (this._data.hasOwnProperty(name)) {
// TODO warn
}
this._data[name] = func;
},
addMultiple: function(functions) {
Object.keys(functions).forEach(
name => {
this.add(name, functions[name]);
});
},
get: function(name) {
return this._data[name] || ( base && base.get( name ));
},
getLocalFunctions: function() {
return this._data;
},
inherit: function() {
return makeRegistry( this );
},
create: function(base) {
return makeRegistry(base);
}
};
}
export default makeRegistry( null );
================================================
FILE: packages/less/lib/less/functions/index.js
================================================
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
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;
};
================================================
FILE: packages/less/lib/less/functions/list.js
================================================
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
const items = Array.isArray(node.value) ?
node.value : Array(node);
return items;
};
export default {
_SELF: function(n) {
return n;
},
'~': function(...expr) {
if (expr.length === 1) {
return expr[0];
}
return new Value(expr);
},
extract: function(values, index) {
// (1-based index)
index = index.value - 1;
return getItemsFromNode(values)[index];
},
length: function(values) {
return new Dimension(getItemsFromNode(values).length);
},
/**
* Creates a Less list of incremental values.
* 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]
*/
range: function(start, end, step) {
let from;
let to;
let stepValue = 1;
const list = [];
if (end) {
to = end;
from = start.value;
if (step) {
stepValue = step.value;
}
}
else {
from = 1;
to = start;
}
for (let i = from; i <= to.value; i += stepValue) {
list.push(new Dimension(i, to.unit));
}
return new Expression(list);
},
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 Quote)) {
if (Array.isArray(list.value)) {
iterator = list.value.map(tryEval);
} else {
iterator = [tryEval(list.value)];
}
} else if (list.ruleset) {
iterator = tryEval(list.ruleset).rules;
} else if (list.rules) {
iterator = list.rules.map(tryEval);
} else if (Array.isArray(list)) {
iterator = list.map(tryEval);
} else {
iterator = [tryEval(list)];
}
let valueName = '@value';
let keyName = '@key';
let indexName = '@index';
if (rs.params) {
valueName = rs.params[0] && rs.params[0].name;
keyName = rs.params[1] && rs.params[1].name;
indexName = rs.params[2] && rs.params[2].name;
rs = rs.rules;
} else {
rs = rs.ruleset;
}
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(i + 1);
value = item;
}
if (item instanceof Comment) {
continue;
}
newRules = rs.rules.slice(0);
if (valueName) {
newRules.push(new Declaration(valueName,
value,
false, false, this.index, this.currentFileInfo));
}
if (indexName) {
newRules.push(new Declaration(indexName,
new Dimension(i + 1),
false, false, this.index, this.currentFileInfo));
}
if (keyName) {
newRules.push(new Declaration(keyName,
key,
false, false, this.index, this.currentFileInfo));
}
rules.push(new Ruleset([ new(Selector)([ new Element('', '&') ]) ],
newRules,
rs.strictImports,
rs.visibilityInfo()
));
}
return new Ruleset([ new(Selector)([ new Element('', '&') ]) ],
rules,
rs.strictImports,
rs.visibilityInfo()
).eval(this.context);
}
};
================================================
FILE: packages/less/lib/less/functions/math-helper.js
================================================
import Dimension from '../tree/dimension.js';
const MathHelper = (fn, unit, n) => {
if (!(n instanceof Dimension)) {
throw { type: 'Argument', message: 'argument must be a number' };
}
if (unit === null) {
unit = n.unit;
} else {
n = n.unify();
}
return new Dimension(fn(parseFloat(n.value)), unit);
};
export default MathHelper;
================================================
FILE: packages/less/lib/less/functions/math.js
================================================
import mathHelper from './math-helper.js';
const mathFunctions = {
// name, unit
ceil: null,
floor: null,
sqrt: null,
abs: null,
tan: '',
sin: '',
cos: '',
atan: 'rad',
asin: 'rad',
acos: 'rad'
};
for (const f in mathFunctions) {
// eslint-disable-next-line no-prototype-builtins
if (mathFunctions.hasOwnProperty(f)) {
mathFunctions[f] = mathHelper.bind(null, Math[f], mathFunctions[f]);
}
}
mathFunctions.round = (n, f) => {
const fraction = typeof f === 'undefined' ? 0 : f.value;
return mathHelper(num => num.toFixed(fraction), null, n);
};
export default mathFunctions;
================================================
FILE: packages/less/lib/less/functions/number.js
================================================
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);
switch (args.length) {
case 0: throw { type: 'Argument', message: 'one or more arguments required' };
}
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)) {
if (Array.isArray(args[i].value)) {
Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value));
continue;
} else {
throw { type: 'Argument', message: 'incompatible types' };
}
}
currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new Dimension(current.value, unitClone).unify() : current.unify();
unit = currentUnified.unit.toString() === '' && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString();
unitStatic = unit !== '' && unitStatic === undefined || unit !== '' && order[0].unify().unit.toString() === '' ? unit : unitStatic;
unitClone = unit !== '' && unitClone === undefined ? current.unit.toString() : unitClone;
j = values[''] !== undefined && unit !== '' && unit === unitStatic ? values[''] : values[unit];
if (j === undefined) {
if (unitStatic !== undefined && unit !== unitStatic) {
throw { type: 'Argument', message: 'incompatible types' };
}
values[unit] = order.length;
order.push(current);
continue;
}
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) {
order[j] = current;
}
}
if (order.length == 1) {
return order[0];
}
args = order.map(a => { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');
return new Anonymous(`${isMin ? 'min' : 'max'}(${args})`);
};
export default {
min: function(...args) {
try {
return minMax.call(this, true, args);
} catch (e) {}
},
max: function(...args) {
try {
return minMax.call(this, false, args);
} catch (e) {}
},
convert: function (val, unit) {
return val.convertTo(unit.value);
},
pi: function () {
return new Dimension(Math.PI);
},
mod: function(a, b) {
return new Dimension(a.value % b.value, a.unit);
},
pow: function(x, y) {
if (typeof x === 'number' && typeof y === 'number') {
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(Math.pow(x.value, y.value), x.unit);
},
percentage: function (n) {
const result = mathHelper(num => num * 100, '%', n);
return result;
}
};
================================================
FILE: packages/less/lib/less/functions/string.js
================================================
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('"', str instanceof JavaScript ? str.evaluated : str.value, true);
},
escape: function (str) {
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) {
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(string.quote || '', result, string.escaped);
},
'%': function (string /* arg, arg, ... */) {
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, 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;
});
}
result = result.replace(/%%/g, '%');
return new Quoted(string.quote || '', result, string.escaped);
}
};
================================================
FILE: packages/less/lib/less/functions/style.js
================================================
import Variable from '../tree/variable.js';
import Anonymous from '../tree/anonymous.js';
/** @param {*[]} args */
const styleExpression = function (args) {
args = Array.prototype.slice.call(args);
if (args.length === 0) {
throw { type: 'Argument', message: 'one or more arguments required' };
}
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})`);
};
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.
}
},
};
================================================
FILE: packages/less/lib/less/functions/svg.js
================================================
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();
}
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 = `<${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;
}
if (!(color instanceof Color) || (!((i === 0 || i + 1 === stops.length) && position === undefined) && !(position instanceof Dimension))) {
throwArgumentDescriptor();
}
positionValue = position ? position.toCSS(renderEnv) : i === 0 ? '0%' : '100%';
alpha = color.alpha;
returner += ` `;
}
returner += `${gradientType}Gradient> `;
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);
}};
};
================================================
FILE: packages/less/lib/less/functions/types.js
================================================
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) {
throw { type: 'Argument', message: 'missing the required second argument to isunit.' };
}
unit = typeof unit.value === 'string' ? unit.value : unit;
if (typeof unit !== 'string') {
throw { type: 'Argument', message: 'Second argument to isunit should be a unit or a string.' };
}
return (n instanceof Dimension) && n.unit.is(unit) ? Keyword.True : Keyword.False;
};
export default {
isruleset: function (n) {
return isa(n, DetachedRuleset);
},
iscolor: function (n) {
return isa(n, Color);
},
isnumber: function (n) {
return isa(n, Dimension);
},
isstring: function (n) {
return isa(n, Quoted);
},
iskeyword: function (n) {
return isa(n, Keyword);
},
isurl: function (n) {
return isa(n, URL);
},
ispixel: function (n) {
return isunit(n, 'px');
},
ispercentage: function (n) {
return isunit(n, '%');
},
isem: function (n) {
return isunit(n, 'em');
},
isunit,
unit: function (val, unit) {
if (!(val instanceof Dimension)) {
throw { type: 'Argument',
message: `the first argument to unit must be a number${val instanceof Operation ? '. Have you forgotten parenthesis?' : ''}` };
}
if (unit) {
if (unit instanceof Keyword) {
unit = unit.value;
} else {
unit = unit.toCSS();
}
} else {
unit = '';
}
return new Dimension(val.value, unit);
},
'get-unit': function (n) {
return new Anonymous(n.unit);
}
};
================================================
FILE: packages/less/lib/less/import-manager.js
================================================
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 = {
// 'rewriteUrls' - option - whether to adjust URL's to be relative
// 'filename' - full resolved filename of current file
// 'rootpath' - path to append to normal URLs for this node
// 'currentDirectory' - path to the current file, absolute
// 'rootFilename' - filename of the base file
// 'entryPath' - absolute path to the entry file
// 'reference' - whether the file should not be output and only output parts that are referenced
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.contentsIgnoredChars = {}; // map - filename to lines at the beginning of each file to ignore
this.mime = context.mime;
this.error = null;
this.context = context;
// Deprecated? Unused outside of here, could be useful.
this.queue = []; // Files which haven't been imported yet
this.files = {}; // Holds the imported parse trees.
}
/**
* Add an import to be imported
* @param path - the raw path
* @param tryAppendExtension - whether to try appending a file extension (.less or .js if the path has no extension)
* @param currentFileInfo - the current file info (used for instance to work out relative paths)
* @param importOptions - import options
* @param callback - callback for when it is imported
*/
push(path, tryAppendExtension, currentFileInfo, importOptions, callback) {
const importManager = this, pluginLoader = this.context.pluginManager.Loader;
this.queue.push(path);
const fileParsedFunc = function (e, root, fullPath) {
importManager.queue.splice(importManager.queue.indexOf(path), 1); // Remove the path from the queue
const importedEqualsRoot = fullPath === importManager.rootFilename;
if (importOptions.optional && e) {
callback(null, {rules:[]}, false, null);
logger.info(`The file ${fullPath} was skipped because it was not found and the import was marked optional.`);
}
else {
// Inline imports aren't cached here.
// If we start to cache them, please make sure they won't conflict with non-inline imports of the
// same name as they used to do before this comment and the condition below have been added.
if (!importManager.files[fullPath] && !importOptions.inline) {
importManager.files[fullPath] = { root, options: importOptions };
}
if (e && !importManager.error) { importManager.error = e; }
callback(e, root, importedEqualsRoot, fullPath);
}
};
const newFileInfo = {
rewriteUrls: this.context.rewriteUrls,
entryPath: currentFileInfo.entryPath,
rootpath: currentFileInfo.rootpath,
rootFilename: currentFileInfo.rootFilename
};
const fileManager = environment.getFileManager(path, currentFileInfo.currentDirectory, this.context, environment);
if (!fileManager) {
fileParsedFunc({ message: `Could not find a file-manager for ${path}` });
return;
}
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
// is in a (sub|sup) directory
//
// Examples:
// - If path of imported file is 'module/nav/nav.less' and rootpath is 'less/',
// then rootpath should become 'less/module/nav/'
// - If path of imported file is '../mixins.less' and rootpath is 'less/',
// then rootpath should become 'less/../'
newFileInfo.currentDirectory = fileManager.getPath(resolvedFilename);
if (newFileInfo.rewriteUrls) {
newFileInfo.rootpath = fileManager.join(
(importManager.context.rootpath || ''),
fileManager.pathDiff(newFileInfo.currentDirectory, newFileInfo.entryPath));
if (!fileManager.isPathAbsolute(newFileInfo.rootpath) && fileManager.alwaysMakePathsAbsolute()) {
newFileInfo.rootpath = fileManager.join(newFileInfo.entryPath, newFileInfo.rootpath);
}
}
newFileInfo.filename = resolvedFilename;
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 LessError) {
fileParsedFunc(plugin, null, resolvedFilename);
}
else {
fileParsedFunc(null, plugin, resolvedFilename);
}
} else if (importOptions.inline) {
fileParsedFunc(null, contents, resolvedFilename);
} else {
// import (multiple) parse trees apparently get altered and can't be cached.
// TODO: investigate why this is
if (importManager.files[resolvedFilename]
&& !importManager.files[resolvedFilename].options.multiple
&& !importOptions.multiple) {
fileParsedFunc(null, importManager.files[resolvedFilename].root, resolvedFilename);
}
else {
new Parser(newEnv, importManager, newFileInfo).parse(contents, function (e, root) {
fileParsedFunc(e, root, resolvedFilename);
});
}
}
};
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 {
promise = pluginLoader.loadPlugin(path, currentFileInfo.currentDirectory, context, environment, fileManager);
}
}
else {
if (context.syncImport) {
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);
}
});
}
}
if (loadedFile) {
if (!loadedFile.filename) {
fileParsedFunc(loadedFile);
} else {
loadFileCallback(loadedFile);
}
} else if (promise) {
promise.then(loadFileCallback, fileParsedFunc);
}
}
}
return ImportManager;
}
================================================
FILE: packages/less/lib/less/index.js
================================================
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,
tree,
Environment,
AbstractFileManager,
AbstractPluginLoader,
environment,
visitors,
Parser,
functions: functions(environment),
contexts,
SourceMapOutput: sourceMapOutput,
SourceMapBuilder: sourceMapBuilder,
ParseTree: parseTree,
ImportManager: importManager,
render,
parse,
LessError,
transformTree,
utils,
PluginManager,
logger
};
// Create a public API
const ctor = function(t) {
return function(...args) {
return new t(...args);
};
};
let t;
const api = Object.create(initial);
for (const n in initial.tree) {
/* eslint guard-for-in: 0 */
t = initial.tree[n];
if (typeof t === 'function') {
api[n.toLowerCase()] = ctor(t);
}
else {
api[n] = Object.create(null);
for (const o in t) {
/* eslint guard-for-in: 0 */
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.
*/
initial.parse = initial.parse.bind(api);
initial.render = initial.render.bind(api);
return api;
}
================================================
FILE: packages/less/lib/less/less-error.js
================================================
import * as utils from './utils.js';
const anonymousFunc = /(|Function):(\d+):(\d+)/;
/**
* This is a centralized class of any error that could be thrown internally (mostly by the parser).
* Besides standard .message it keeps some additional data like a path to the file where the error
* occurred along with line and column numbers.
*
* @class
* @extends Error
* @type {module.LessError}
*
* @prop {string} type
* @prop {string} filename
* @prop {number} index
* @prop {number} line
* @prop {number} column
* @prop {number} callLine
* @prop {number} callExtract
* @prop {string[]} extract
*
* @param {Object} e - An error object to wrap around or just a descriptive object
* @param {Object} fileContentMap - An object with file contents in 'contents' property (like importManager) @todo - move to fileManager?
* @param {string} [currentFilename]
*/
const LessError = function(e, fileContentMap, currentFilename) {
Error.call(this);
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) {
const input = fileContentMap.contents[filename];
const loc = utils.getLocation(e.index, input);
var line = loc.line;
const col = loc.column;
const callLine = e.call && utils.getLocation(e.call, input).line;
const lines = input ? input.split('\n') : '';
this.filename = filename;
this.index = e.index;
this.line = typeof line === 'number' ? line + 1 : null;
this.column = col;
if (!this.line && this.stack) {
const found = this.stack.match(anonymousFunc);
/**
* We have to figure out how this environment stringifies anonymous functions
* so we can correctly map plugin errors.
*
* Note, in Node 8, the output of anonymous funcs varied based on parameters
* being present or not, so we inject dummy params.
*/
const func = new Function('a', 'throw new Error()');
let lineAdjust = 0;
try {
func();
} catch (e) {
const match = e.stack.match(anonymousFunc);
lineAdjust = 1 - parseInt(match[2]);
}
if (found) {
if (found[2]) {
this.line = parseInt(found[2]) + lineAdjust;
}
if (found[3]) {
this.column = parseInt(found[3]);
}
}
}
this.callLine = callLine + 1;
this.callExtract = lines[callLine];
this.extract = [
lines[this.line - 2],
lines[this.line - 1],
lines[this.line]
];
}
};
if (typeof Object.create === 'undefined') {
const F = function () {};
F.prototype = Error.prototype;
LessError.prototype = new F();
} else {
LessError.prototype = Object.create(Error.prototype);
}
LessError.prototype.constructor = LessError;
/**
* An overridden version of the default Object.prototype.toString
* which uses additional information to create a helpful message.
*
* @param {Object} options
* @returns {string}
*/
LessError.prototype.toString = function(options) {
options = options || {};
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) {
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(`${this.line - 1} ${extract[0]}`, 'grey'));
}
if (typeof extract[1] === 'string') {
let errorTxt = `${this.line} `;
if (extract[1]) {
errorTxt += extract[1].slice(0, this.column) +
stylize(stylize(stylize(extract[1].slice(this.column, this.column + 1), 'bold') +
extract[1].slice(this.column + 1), 'red'), 'inverse');
}
error.push(errorTxt);
}
if (!isWarning && typeof extract[2] === 'string') {
error.push(stylize(`${this.line + 1} ${extract[2]}`, 'grey'));
}
error = `${error.join('\n') + stylize('', 'reset')}\n`;
}
message += stylize(`${type}: ${this.message}`, color);
if (this.filename) {
message += stylize(' in ', color) + this.filename;
}
if (this.line) {
message += stylize(` on line ${this.line}, column ${this.column + 1}:`, 'grey');
}
message += `\n${error}`;
if (this.callLine) {
message += `${stylize('from ', color) + (this.filename || '')}/n`;
message += `${stylize(this.callLine, 'grey')} ${this.callExtract}/n`;
}
return message;
};
export default LessError;
================================================
FILE: packages/less/lib/less/logger.js
================================================
export default {
error: function(msg) {
this._fireEvent('error', msg);
},
warn: function(msg) {
this._fireEvent('warn', msg);
},
info: function(msg) {
this._fireEvent('info', msg);
},
debug: function(msg) {
this._fireEvent('debug', msg);
},
addListener: function(listener) {
this._listeners.push(listener);
},
removeListener: function(listener) {
for (let i = 0; i < this._listeners.length; i++) {
if (this._listeners[i] === listener) {
this._listeners.splice(i, 1);
return;
}
}
},
_fireEvent: function(type, msg) {
for (let i = 0; i < this._listeners.length; i++) {
const logFunction = this._listeners[i][type];
if (logFunction) {
logFunction(msg);
}
}
},
_listeners: []
};
================================================
FILE: packages/less/lib/less/parse-tree.js
================================================
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;
}
toCSS(options) {
let evaldRoot;
const result = {};
let sourceMapBuilder;
try {
evaldRoot = transformTree(this.root, options);
} catch (e) {
throw new LessError(e, this.imports);
}
try {
const compress = Boolean(options.compress);
if (compress) {
logger.warn('The compress option has been deprecated. ' +
'We recommend you use a dedicated css minifier, for instance see less-plugin-clean-css.');
}
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};
if (options.sourceMap) {
// Normalize sourceMap option: if it's just true, convert to object
if (options.sourceMap === true) {
options.sourceMap = {};
}
const sourceMapOpts = options.sourceMap;
// Set sourceMapInputFilename if not set and filename is available
if (!sourceMapOpts.sourceMapInputFilename && options.filename) {
sourceMapOpts.sourceMapInputFilename = options.filename;
}
// Default sourceMapBasepath to the input file's directory if not set
// This matches the behavior documented and implemented in bin/lessc
if (sourceMapOpts.sourceMapBasepath === undefined && options.filename) {
// Get directory from filename using string manipulation (works cross-platform)
const lastSlash = Math.max(options.filename.lastIndexOf('/'), options.filename.lastIndexOf('\\'));
if (lastSlash >= 0) {
sourceMapOpts.sourceMapBasepath = options.filename.substring(0, lastSlash);
} else {
// No directory separator found, use current directory
sourceMapOpts.sourceMapBasepath = '.';
}
}
// Handle sourceMapFullFilename (CLI-specific: --source-map=filename)
// This is converted to sourceMapFilename and sourceMapOutputFilename
if (sourceMapOpts.sourceMapFullFilename && !sourceMapOpts.sourceMapFileInline) {
// This case is handled by lessc before calling render
// We just need to ensure sourceMapFilename is set if sourceMapFullFilename is provided
if (!sourceMapOpts.sourceMapFilename && !sourceMapOpts.sourceMapURL) {
// Extract just the basename for the sourceMappingURL comment
const mapBase = sourceMapOpts.sourceMapFullFilename.split(/[/\\]/).pop();
sourceMapOpts.sourceMapFilename = mapBase;
}
} else if (!sourceMapOpts.sourceMapFilename && !sourceMapOpts.sourceMapURL) {
// If sourceMapFilename is not set and sourceMapURL is not set,
// derive it from the output filename (if available) or input filename
if (sourceMapOpts.sourceMapOutputFilename) {
// Use output filename + .map
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';
}
}
// Default sourceMapOutputFilename if not set
if (!sourceMapOpts.sourceMapOutputFilename) {
if (options.filename) {
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 {
result.css = evaldRoot.toCSS(toCSSOptions);
}
} catch (e) {
throw new LessError(e, this.imports);
}
if (options.pluginManager) {
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 });
}
}
if (options.sourceMap) {
result.map = sourceMapBuilder.getExternalSourceMap();
}
result.imports = [];
for (const file in this.imports.files) {
if (Object.prototype.hasOwnProperty.call(this.imports.files, file) && file !== this.imports.rootFilename) {
result.imports.push(file);
}
}
return result;
}
}
return ParseTree;
}
================================================
FILE: packages/less/lib/less/parse.js
================================================
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') {
callback = options;
options = utils.copyOptions(this.options, {});
}
else {
options = utils.copyOptions(this.options, options || {});
}
if (!callback) {
const self = this;
return new Promise(function (resolve, reject) {
parse.call(self, input, options, function(err, output) {
if (err) {
reject(err);
} else {
resolve(output);
}
});
});
} 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 {
const filename = options.filename || 'input';
const entryPath = filename.replace(/[^/\\]*$/, '');
rootFileInfo = {
filename,
rewriteUrls: context.rewriteUrls,
rootpath: context.rootpath || '',
currentDirectory: entryPath,
entryPath,
rootFilename: filename
};
// add in a missing trailing slash
if (rootFileInfo.rootpath && rootFileInfo.rootpath.slice(-1) !== '/') {
rootFileInfo.rootpath += '/';
}
}
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) {
let evalResult, contents;
if (plugin.fileContent) {
contents = plugin.fileContent.replace(/^\uFEFF/, '');
evalResult = pluginManager.Loader.evalPlugin(contents, context, imports, plugin.options, plugin.filename);
if (evalResult instanceof LessError) {
return callback(evalResult);
}
}
else {
pluginManager.addPlugin(plugin);
}
});
}
new Parser(context, imports, rootFileInfo)
.parse(input, function (e, root) {
if (e) { return callback(e); }
callback(null, root, imports, options);
}, options);
}
};
return parse;
}
================================================
FILE: packages/less/lib/less/parser/parser-input.js
================================================
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) {
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};
let nextNewLine = inp.indexOf('\n', parserInput.i + 2);
if (nextNewLine < 0) {
nextNewLine = endIndex;
}
parserInput.i = nextNewLine;
comment.text = inp.slice(comment.index, parserInput.i);
parserInput.commentStore.push(comment);
continue;
} else if (nextChar === '*') {
const nextStarSlash = inp.indexOf('*/', parserInput.i + 2);
if (nextStarSlash >= 0) {
comment = {
index: parserInput.i,
text: inp.slice(parserInput.i, nextStarSlash + 2),
isLineComment: false
};
parserInput.i += comment.text.length - 1;
parserInput.commentStore.push(comment);
continue;
}
}
break;
}
if ((c !== CHARCODE_SPACE) && (c !== CHARCODE_LF) && (c !== CHARCODE_TAB) && (c !== CHARCODE_CR)) {
break;
}
}
current = current.slice(length + parserInput.i - mem + curr);
currentPos = parserInput.i;
if (!current.length) {
if (j < chunks.length - 1) {
current = chunks[++j];
skipWhitespace(0); // skip space at the beginning of a chunk
return true; // things changed
}
parserInput.finished = true;
}
return oldi !== parserInput.i || oldj !== j;
}
parserInput.save = () => {
currentPos = parserInput.i;
saveStack.push( { current, i: parserInput.i, j });
};
parserInput.restore = possibleErrorMessage => {
if (parserInput.i > furthest || (parserInput.i === furthest && possibleErrorMessage && !furthestPossibleErrorMessage)) {
furthest = parserInput.i;
furthestPossibleErrorMessage = possibleErrorMessage;
}
const state = saveStack.pop();
current = state.current;
currentPos = parserInput.i = state.i;
j = state.j;
};
parserInput.forget = () => {
saveStack.pop();
};
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 = tok => {
if (parserInput.i > currentPos) {
current = current.slice(parserInput.i - currentPos);
currentPos = parserInput.i;
}
const m = tok.exec(current);
if (!m) {
return null;
}
skipWhitespace(m[0].length);
if (typeof m === 'string') {
return m;
}
return m.length === 1 ? m[0] : m;
};
parserInput.$char = tok => {
if (input.charAt(parserInput.i) !== tok) {
return null;
}
skipWhitespace(1);
return tok;
};
parserInput.$peekChar = tok => {
if (input.charAt(parserInput.i) !== tok) {
return null;
}
return tok;
};
parserInput.$str = tok => {
const tokLength = tok.length;
// https://jsperf.com/string-startswith/21
for (let i = 0; i < tokLength; i++) {
if (input.charAt(parserInput.i + i) !== tok.charAt(i)) {
return null;
}
}
skipWhitespace(tokLength);
return tok;
};
parserInput.$quoted = loc => {
const pos = loc || parserInput.i;
const startChar = input.charAt(pos);
if (startChar !== '\'' && startChar !== '"') {
return;
}
const length = input.length;
const currentPosition = pos;
for (let i = 1; i + currentPosition < length; i++) {
const nextChar = input.charAt(i + currentPosition);
switch (nextChar) {
case '\\':
i++;
continue;
case '\r':
case '\n':
break;
case startChar: {
const str = input.slice(currentPosition, currentPosition + i + 1);
if (!loc && loc !== 0) {
skipWhitespace(i + 1);
return str
}
return [startChar, str];
}
default:
}
}
return null;
};
/**
* Permissive parsing. Ignores everything except matching {} [] () and quotes
* until matching token (outside of blocks)
*/
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 = char => char === tok
} else {
testChar = char => tok.test(char)
}
do {
let nextChar = input.charAt(i);
if (blockDepth === 0 && testChar(nextChar)) {
returnVal = input.slice(lastPos, i);
if (returnVal) {
parseGroups.push(returnVal);
}
else {
parseGroups.push(' ');
}
returnVal = parseGroups;
skipWhitespace(i - startPos);
loop = false
} else {
if (inComment) {
if (nextChar === '*' &&
input.charAt(i + 1) === '/') {
i++;
blockDepth--;
inComment = false;
}
i++;
continue;
}
switch (nextChar) {
case '\\':
i++;
nextChar = input.charAt(i);
parseGroups.push(input.slice(lastPos, i + 1));
lastPos = i + 1;
break;
case '/':
if (input.charAt(i + 1) === '*') {
i++;
inComment = true;
blockDepth++;
}
break;
case '\'':
case '"':
quote = parserInput.$quoted(i);
if (quote) {
parseGroups.push(input.slice(lastPos, i), quote);
i += quote[1].length - 1;
lastPos = i + 1;
}
else {
skipWhitespace(i - startPos);
returnVal = nextChar;
loop = false;
}
break;
case '{':
blockStack.push('}');
blockDepth++;
break;
case '(':
blockStack.push(')');
blockDepth++;
break;
case '[':
blockStack.push(']');
blockDepth++;
break;
case '}':
case ')':
case ']': {
const expected = blockStack.pop();
if (nextChar === expected) {
blockDepth--;
} else {
// move the parser to the error and return expected
skipWhitespace(i - startPos);
returnVal = expected;
loop = false;
}
}
}
i++;
if (i > length) {
loop = false;
}
}
} 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 = tok => {
if (typeof tok === 'string') {
// https://jsperf.com/string-startswith/21
for (let i = 0; i < tok.length; i++) {
if (input.charAt(parserInput.i + i) !== tok.charAt(i)) {
return false;
}
}
return true;
} else {
return tok.test(current);
}
};
// Specialization of peek()
// TODO remove or change some currentChar calls to peekChar
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 = (str) => {
input = str;
parserInput.i = j = currentPos = furthest = 0;
chunks = [str];
current = chunks[0];
skipWhitespace(0);
};
parserInput.end = () => {
let message;
const isFinished = parserInput.i >= input.length;
if (parserInput.i < furthest) {
message = furthestPossibleErrorMessage;
parserInput.i = furthest;
}
return {
isFinished,
furthest: parserInput.i,
furthestPossibleErrorMessage: message,
furthestReachedEnd: parserInput.i >= input.length - 1,
furthestChar: input[parserInput.i]
};
};
return parserInput;
};
================================================
FILE: packages/less/lib/less/parser/parser.js
================================================
import LessError from '../less-error.js';
import tree from '../tree/index.js';
import visitors from '../visitors/index.js';
import getParserInput from './parser-input.js';
import * as utils from '../utils.js';
import functionRegistry from '../functions/function-registry.js';
import { ContainerSyntaxOptions, MediaSyntaxOptions } from '../tree/atrule-syntax.js';
import logger from '../logger.js';
import { DeprecationHandler } from '../deprecation.js';
import Selector from '../tree/selector.js';
import Anonymous from '../tree/anonymous.js';
//
// less.js - parser
//
// A relatively straight-forward predictive parser.
// There is no tokenization/lexing stage, the input is parsed
// in one sweep.
//
// To make the parser fast enough to run in the browser, several
// optimization had to be made:
//
// - Matching and slicing on a huge input is often cause of slowdowns.
// The solution is to chunkify the input into smaller strings.
// The chunks are stored in the `chunks` var,
// `j` holds the current chunk index, and `currentPos` holds
// the index of the current chunk in relation to `input`.
// This gives us an almost 4x speed-up.
//
// - In many cases, we don't need to match individual tokens;
// for example, if a value doesn't hold any variables, operations
// or dynamic references, the parser can effectively 'skip' it,
// treating it as a literal.
// An example would be '1px solid #000' - which evaluates to itself,
// we don't need to know what the individual components are.
// The drawback, of course is that you don't get the benefits of
// syntax-checking on the CSS. This gives us a 50% speed-up in the parser,
// and a smaller speed-up in the code-gen.
//
//
// Token matching is done with the `$` function, which either takes
// a terminal string or regexp, or a non-terminal function to call.
// It also takes care of moving all the indices forwards.
//
const Parser = function Parser(context, imports, fileInfo, currentIndex) {
currentIndex = currentIndex || 0;
let parsers;
const parserInput = getParserInput();
function error(msg, type) {
throw new LessError(
{
index: parserInput.i,
filename: fileInfo.filename,
type: type || 'Syntax',
message: msg
},
imports
);
}
const deprecationHandler = new DeprecationHandler();
/**
* @param {string} msg
* @param {number} index
* @param {string} type
* @param {string} [deprecationId] - stable deprecation ID for repetition limiting
*/
function warn(msg, index, type, deprecationId) {
if (context.quiet) { return; }
if (deprecationId && context.quietDeprecations) { return; }
if (deprecationId && !deprecationHandler.shouldWarn(deprecationId)) { return; }
logger.warn(
(new LessError(
{
index: index ?? parserInput.i,
filename: fileInfo.filename,
type: type ? `${type.toUpperCase()} WARNING` : 'WARNING',
message: msg
},
imports
)).toString()
);
}
function expect(arg, msg) {
// some older browsers return typeof 'function' for RegExp
const result = (arg instanceof Function) ? arg.call(parsers) : parserInput.$re(arg);
if (result) {
return result;
}
error(msg || (typeof arg === 'string'
? `expected '${arg}' got '${parserInput.currentChar()}'`
: 'unexpected token'));
}
// Specialization of expect()
function expectChar(arg, msg) {
if (parserInput.$char(arg)) {
return arg;
}
error(msg || `expected '${arg}' got '${parserInput.currentChar()}'`);
}
function getDebugInfo(index) {
const filename = fileInfo.filename;
return {
lineNumber: utils.getLocation(index, parserInput.getInput()).line + 1,
fileName: filename
};
}
/**
* Used after initial parsing to create nodes on the fly
*
* @param {String} str - string to parse
* @param {Array} parseList - array of parsers to run input through e.g. ["value", "important"]
* @param {Number} currentIndex - start number to begin indexing
* @param {Object} fileInfo - fileInfo to attach to created nodes
*/
function parseNode(str, parseList, callback) {
let result;
const returnNodes = [];
const parser = parserInput;
try {
parser.start(str);
for (let x = 0, p; (p = parseList[x]); x++) {
result = parsers[p]();
returnNodes.push(result || null);
}
const endInfo = parser.end();
if (endInfo.isFinished) {
callback(null, returnNodes);
}
else {
callback(true, null);
}
} catch (e) {
throw new LessError({
index: e.index + currentIndex,
message: e.message
}, imports, fileInfo.filename);
}
}
//
// The Parser
//
return {
parserInput,
imports,
fileInfo,
parseNode,
//
// Parse an input string into an abstract syntax tree,
// @param str A string containing 'less' markup
// @param callback call `callback` when done.
// @param [additionalData] An optional map which can contains vars - a map (key, value) of variables to apply
//
parse: function (str, callback, additionalData) {
let root;
let err = null;
let globalVars;
let modifyVars;
let ignored;
let preText = '';
// Optionally disable @plugin parsing
if (additionalData && additionalData.disablePluginRule) {
parsers.plugin = function() {
var dir = parserInput.$re(/^@plugin?\s+/);
if (dir) {
error('@plugin statements are not allowed when disablePluginRule is set to true');
}
}
}
globalVars = (additionalData && additionalData.globalVars) ? `${Parser.serializeVars(additionalData.globalVars)}\n` : '';
modifyVars = (additionalData && additionalData.modifyVars) ? `\n${Parser.serializeVars(additionalData.modifyVars)}` : '';
if (context.pluginManager) {
const preProcessors = context.pluginManager.getPreProcessors();
for (let i = 0; i < preProcessors.length; i++) {
str = preProcessors[i].process(str, { context, imports, fileInfo });
}
}
if (globalVars || (additionalData && additionalData.banner)) {
preText = ((additionalData && additionalData.banner) ? additionalData.banner : '') + globalVars;
ignored = imports.contentsIgnoredChars;
ignored[fileInfo.filename] = ignored[fileInfo.filename] || 0;
ignored[fileInfo.filename] += preText.length;
}
str = str.replace(/\r\n?/g, '\n');
// Remove potential UTF Byte Order Mark
str = preText + str.replace(/^\uFEFF/, '') + modifyVars;
imports.contents[fileInfo.filename] = str;
// Start with the primary rule.
// The whole syntax tree is held under a Ruleset node,
// with the `root` property set to true, so no `{}` are
// output. The callback is called when the input is parsed.
try {
parserInput.start(str);
tree.Node.prototype.parse = this;
root = new tree.Ruleset(null, this.parsers.primary());
tree.Node.prototype.rootNode = root;
root.root = true;
root.firstRoot = true;
root.functionRegistry = functionRegistry.inherit();
} catch (e) {
return callback(new LessError(e, imports, fileInfo.filename));
}
// If `i` is smaller than the `input.length - 1`,
// it means the parser wasn't able to parse the whole
// string, so we've got a parsing error.
//
// We try to extract a \n delimited string,
// showing the line where the parse error occurred.
// We split it up into two parts (the part which parsed,
// and the part which didn't), so we can color them differently.
const endInfo = parserInput.end();
if (!endInfo.isFinished) {
let message = endInfo.furthestPossibleErrorMessage;
if (!message) {
message = 'Unrecognised input';
if (endInfo.furthestChar === '}') {
message += '. Possibly missing opening \'{\'';
} else if (endInfo.furthestChar === ')') {
message += '. Possibly missing opening \'(\'';
} else if (endInfo.furthestReachedEnd) {
message += '. Possibly missing something';
}
}
err = new LessError({
type: 'Parse',
message,
index: endInfo.furthest,
filename: fileInfo.filename
}, imports);
}
const finish = e => {
e = err || e || imports.error;
if (e) {
if (!(e instanceof LessError)) {
e = new LessError(e, imports, fileInfo.filename);
}
return callback(e);
}
else {
return callback(null, root);
}
};
if (context.processImports !== false) {
new visitors.ImportVisitor(imports, finish)
.run(root);
} else {
return finish();
}
},
//
// Here in, the parsing rules/functions
//
// The basic structure of the syntax tree generated is as follows:
//
// Ruleset -> Declaration -> Value -> Expression -> Entity
//
// Here's some Less code:
//
// .class {
// color: #fff;
// border: 1px solid #000;
// width: @w + 4px;
// > .child {...}
// }
//
// And here's what the parse tree might look like:
//
// Ruleset (Selector '.class', [
// Declaration ("color", Value ([Expression [Color #fff]]))
// Declaration ("border", Value ([Expression [Dimension 1px][Keyword "solid"][Color #000]]))
// Declaration ("width", Value ([Expression [Operation " + " [Variable "@w"][Dimension 4px]]]))
// Ruleset (Selector [Element '>', '.child'], [...])
// ])
//
// In general, most rules will try to parse a token with the `$re()` function, and if the return
// value is truly, will return a new node, of the relevant type. Sometimes, we need to check
// first, before parsing, that's when we use `peek()`.
//
parsers: parsers = {
//
// The `primary` rule is the *entry* and *exit* point of the parser.
// The rules here can appear at any level of the parse tree.
//
// The recursive nature of the grammar is an interplay between the `block`
// rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule,
// as represented by this simplified grammar:
//
// primary → (ruleset | declaration)+
// ruleset → selector+ block
// block → '{' primary '}'
//
// Only at one point is the primary rule not called from the
// block rule: at the root level.
//
primary: function () {
const mixin = this.mixin;
let root = [];
let node;
while (true) {
while (true) {
node = this.comment();
if (!node) { break; }
root.push(node);
}
// always process comments before deciding if finished
if (parserInput.finished) {
break;
}
if (parserInput.peek('}')) {
break;
}
node = this.extendRule();
if (node) {
root = root.concat(node);
continue;
}
node = mixin.definition() || this.declaration() || mixin.call(false, false) ||
this.ruleset() || this.variableCall() || this.entities.call() || this.atrule();
if (node) {
root.push(node);
} else {
let foundSemiColon = false;
while (parserInput.$char(';')) {
foundSemiColon = true;
}
if (!foundSemiColon) {
break;
}
}
}
return root;
},
// comments are collected by the main parsing mechanism and then assigned to nodes
// where the current structure allows it
comment: function () {
if (parserInput.commentStore.length) {
const comment = parserInput.commentStore.shift();
return new(tree.Comment)(comment.text, comment.isLineComment, comment.index + currentIndex, fileInfo);
}
},
//
// Entities are tokens which can be found inside an Expression
//
entities: {
mixinLookup: function() {
return parsers.mixin.call(true, true);
},
//
// A string, which supports escaping " and '
//
// "milky way" 'he\'s the one!'
//
quoted: function (forceEscaped) {
let str;
const index = parserInput.i;
let isEscaped = false;
parserInput.save();
if (parserInput.$char('~')) {
isEscaped = true;
} else if (forceEscaped) {
parserInput.restore();
return;
}
str = parserInput.$quoted();
if (!str) {
parserInput.restore();
return;
}
parserInput.forget();
return new(tree.Quoted)(str.charAt(0), str.slice(1, -1), isEscaped, index + currentIndex, fileInfo);
},
//
// A catch-all word, such as:
//
// black border-collapse
//
keyword: function () {
const k = parserInput.$char('%') || parserInput.$re(/^\[?(?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+\]?/);
if (k) {
return tree.Color.fromKeyword(k) || new(tree.Keyword)(k);
}
},
//
// A function call
//
// rgb(255, 0, 255)
//
// The arguments are parsed with the `entities.arguments` parser.
//
call: function () {
let name;
let args;
let func;
const index = parserInput.i;
// http://jsperf.com/case-insensitive-regex-vs-strtolower-then-regex/18
if (parserInput.peek(/^url\(/i)) {
return;
}
parserInput.save();
name = parserInput.$re(/^([\w-]+|%|~|progid:[\w.]+)\(/);
if (!name) {
parserInput.forget();
return;
}
name = name[1];
func = this.customFuncCall(name);
if (func) {
args = func.parse();
if (args && func.stop) {
parserInput.forget();
return args;
}
}
args = this.arguments(args);
if (!parserInput.$char(')')) {
parserInput.restore('Could not parse call arguments or missing \')\'');
return;
}
parserInput.forget();
return new(tree.Call)(name, args, index + currentIndex, fileInfo);
},
declarationCall: function () {
let validCall;
let args;
const index = parserInput.i;
parserInput.save();
validCall = parserInput.$re(/^[\w]+\(/);
if (!validCall) {
parserInput.forget();
return;
}
validCall = validCall.substring(0, validCall.length - 1);
// CSS at-rule keywords should never be parsed as declaration calls
if (/^(and|or|not|only|layer)$/i.test(validCall)) {
parserInput.restore();
return;
}
let rule = this.ruleProperty();
let value;
if (rule) {
value = this.value();
}
if (rule && value) {
args = [new (tree.Declaration)(rule, value, null, null, parserInput.i + currentIndex, fileInfo, true)];
}
if (!parserInput.$char(')')) {
parserInput.restore('Could not parse call arguments or missing \')\'');
return;
}
parserInput.forget();
return new(tree.Call)(validCall, args, index + currentIndex, fileInfo);
},
//
// Parsing rules for functions with non-standard args, e.g.:
//
// boolean(not(2 > 1))
//
// This is a quick prototype, to be modified/improved when
// more custom-parsed funcs come (e.g. `selector(...)`)
//
customFuncCall: function (name) {
/* Ideally the table is to be moved out of here for faster perf.,
but it's quite tricky since it relies on all these `parsers`
and `expect` available only here */
return {
alpha: f(parsers.ieAlpha, true),
boolean: f(condition),
'if': f(condition)
}[name.toLowerCase()];
function f(parse, stop) {
return {
parse, // parsing function
stop // when true - stop after parse() and return its result,
// otherwise continue for plain args
};
}
function condition() {
return [expect(parsers.condition, 'expected condition')];
}
},
arguments: function (prevArgs) {
let argsComma = prevArgs || [];
const argsSemiColon = [];
let isSemiColonSeparated;
let value;
parserInput.save();
while (true) {
if (prevArgs) {
prevArgs = false;
} else {
value = parsers.detachedRuleset() || this.assignment() || parsers.expression();
if (!value) {
break;
}
if (value.value && value.value.length == 1) {
value = value.value[0];
}
argsComma.push(value);
}
if (parserInput.$char(',')) {
continue;
}
if (parserInput.$char(';') || isSemiColonSeparated) {
isSemiColonSeparated = true;
value = (argsComma.length < 1) ? argsComma[0]
: new tree.Value(argsComma);
argsSemiColon.push(value);
argsComma = [];
}
}
parserInput.forget();
return isSemiColonSeparated ? argsSemiColon : argsComma;
},
literal: function () {
return this.dimension() ||
this.color() ||
this.quoted() ||
this.unicodeDescriptor();
},
// Assignments are argument entities for calls.
// They are present in ie filter properties as shown below.
//
// filter: progid:DXImageTransform.Microsoft.Alpha( *opacity=50* )
//
assignment: function () {
let key;
let value;
parserInput.save();
key = parserInput.$re(/^\w+(?=\s?=)/i);
if (!key) {
parserInput.restore();
return;
}
if (!parserInput.$char('=')) {
parserInput.restore();
return;
}
value = parsers.entity();
if (value) {
parserInput.forget();
return new(tree.Assignment)(key, value);
} else {
parserInput.restore();
}
},
//
// Parse url() tokens
//
// We use a specific rule for urls, because they don't really behave like
// standard function calls. The difference is that the argument doesn't have
// to be enclosed within a string, so it can't be parsed as an Expression.
//
url: function () {
let value;
const index = parserInput.i;
parserInput.autoCommentAbsorb = false;
if (!parserInput.$str('url(')) {
parserInput.autoCommentAbsorb = true;
return;
}
value = this.quoted() || this.variable() || this.property() ||
parserInput.$re(/^(?:(?:\\[()'"])|[^()'"])+/) || '';
parserInput.autoCommentAbsorb = true;
expectChar(')');
return new(tree.URL)((value.value !== undefined ||
value instanceof tree.Variable ||
value instanceof tree.Property) ?
value : new(tree.Anonymous)(value, index), index + currentIndex, fileInfo);
},
//
// A Variable entity, such as `@fink`, in
//
// width: @fink + 2px
//
// We use a different parser for variable definitions,
// see `parsers.variable`.
//
variable: function () {
let ch;
let name;
const index = parserInput.i;
parserInput.save();
if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^@@?[\w-]+/))) {
ch = parserInput.currentChar();
if ((ch === '(' && !parserInput.prevChar().match(/^\s/))
|| (ch === '[' && !parserInput.prevChar().match(/^\s/))) {
// this may be a VariableCall lookup
const result = parsers.variableCall(name);
if (result) {
parserInput.forget();
return result;
}
}
parserInput.forget();
return new(tree.Variable)(name, index + currentIndex, fileInfo);
}
parserInput.restore();
},
// A variable entity using the protective {} e.g. @{var}
variableCurly: function () {
let curly;
const index = parserInput.i;
if (parserInput.currentChar() === '@' && (curly = parserInput.$re(/^@\{([\w-]+)\}/))) {
return new(tree.Variable)(`@${curly[1]}`, index + currentIndex, fileInfo);
}
},
//
// A Property accessor, such as `$color`, in
//
// background-color: $color
//
property: function () {
let name;
const index = parserInput.i;
if (parserInput.currentChar() === '$' && (name = parserInput.$re(/^\$[\w-]+/))) {
return new(tree.Property)(name, index + currentIndex, fileInfo);
}
},
//
// A Hexadecimal color
//
// #4F3C2F
//
// `rgb` and `hsl` colors are parsed through the `entities.call` parser.
//
color: function () {
let rgb;
parserInput.save();
if (parserInput.currentChar() === '#' && (rgb = parserInput.$re(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})([\w.#[])?/))) {
if (!rgb[2]) {
parserInput.forget();
return new(tree.Color)(rgb[1], undefined, rgb[0]);
}
}
parserInput.restore();
},
colorKeyword: function () {
parserInput.save();
const autoCommentAbsorb = parserInput.autoCommentAbsorb;
parserInput.autoCommentAbsorb = false;
const k = parserInput.$re(/^[_A-Za-z-][_A-Za-z0-9-]+/);
parserInput.autoCommentAbsorb = autoCommentAbsorb;
if (!k) {
parserInput.forget();
return;
}
parserInput.restore();
const color = tree.Color.fromKeyword(k);
if (color) {
parserInput.$str(k);
return color;
}
},
//
// A Dimension, that is, a number and a unit
//
// 0.5em 95%
//
dimension: function () {
if (parserInput.peekNotNumeric()) {
return;
}
const value = parserInput.$re(/^([+-]?\d*\.?\d+)(%|[a-z_]+)?/i);
if (value) {
return new(tree.Dimension)(value[1], value[2]);
}
},
//
// A unicode descriptor, as is used in unicode-range
//
// U+0?? or U+00A1-00A9
//
unicodeDescriptor: function () {
let ud;
ud = parserInput.$re(/^U\+[0-9a-fA-F?]+(-[0-9a-fA-F?]+)?/);
if (ud) {
return new(tree.UnicodeDescriptor)(ud[0]);
}
},
//
// JavaScript code to be evaluated
//
// `window.location.href`
//
javascript: function () {
let js;
const index = parserInput.i;
parserInput.save();
const escape = parserInput.$char('~');
const jsQuote = parserInput.$char('`');
if (!jsQuote) {
parserInput.restore();
return;
}
js = parserInput.$re(/^[^`]*`/);
if (js) {
warn('Inline JavaScript evaluation (backtick expressions) is deprecated and will be removed in Less 5.x. Use Less functions or custom plugins instead.', index, 'DEPRECATED', 'js-eval');
parserInput.forget();
return new(tree.JavaScript)(js.slice(0, -1), Boolean(escape), index + currentIndex, fileInfo);
}
parserInput.restore('invalid javascript definition');
}
},
//
// The variable part of a variable definition. Used in the `rule` parser
//
// @fink:
//
variable: function () {
let name;
if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^(@[\w-]+)\s*:/))) { return name[1]; }
},
//
// Call a variable value to retrieve a detached ruleset
// or a value from a detached ruleset's rules.
//
// @fink();
// @fink;
// color: @fink[@color];
//
variableCall: function (parsedName) {
let lookups;
const i = parserInput.i;
const inValue = !!parsedName;
let name = parsedName;
parserInput.save();
if (name || (parserInput.currentChar() === '@'
&& (name = parserInput.$re(/^(@[\w-]+)(\(\s*\))?/)))) {
lookups = this.mixin.ruleLookups();
if (!lookups && ((inValue && parserInput.$str('()') !== '()') || (name[2] !== '()'))) {
parserInput.restore('Missing \'[...]\' lookup in variable call');
return;
}
if (!inValue) {
name = name[1];
}
const call = new tree.VariableCall(name, i, fileInfo);
if (!inValue && parsers.end()) {
parserInput.forget();
return call;
}
else {
parserInput.forget();
return new tree.NamespaceValue(call, lookups, i, fileInfo);
}
}
parserInput.restore();
},
//
// extend syntax - used to extend selectors
//
extend: function(isRule) {
let elements;
let e;
const index = parserInput.i;
let option;
let extendList;
let extend;
if (!parserInput.$str(isRule ? '&:extend(' : ':extend(')) {
return;
}
do {
option = null;
elements = null;
let first = true;
while (!(option = parserInput.$re(/^(!?all)(?=\s*(\)|,))/))) {
e = this.element();
if (!e) {
break;
}
/**
* @note - This will not catch selectors in pseudos like :is() and :where() because
* they don't currently parse their contents as selectors.
*/
if (!first && e.combinator.value) {
warn('Targeting complex selectors can have unexpected behavior, and this behavior may change in the future.', index)
}
first = false;
if (elements) {
elements.push(e);
} else {
elements = [ e ];
}
}
option = option && option[1];
if (!elements) {
error('Missing target selector for :extend().');
}
extend = new(tree.Extend)(new(tree.Selector)(elements), option, index + currentIndex, fileInfo);
if (extendList) {
extendList.push(extend);
} else {
extendList = [ extend ];
}
} while (parserInput.$char(','));
expect(/^\)/);
if (isRule) {
expect(/^;/);
}
return extendList;
},
//
// extendRule - used in a rule to extend all the parent selectors
//
extendRule: function() {
return this.extend(true);
},
//
// Mixins
//
mixin: {
//
// A Mixin call, with an optional argument list
//
// #mixins > .square(#fff);
// #mixins.square(#fff);
// .rounded(4px, black);
// .button;
//
// We can lookup / return a value using the lookup syntax:
//
// color: #mixin.square(#fff)[@color];
//
// The `while` loop is there because mixins can be
// namespaced, but we only support the child and descendant
// selector for now.
//
call: function (inValue, getLookup) {
const s = parserInput.currentChar();
let important = false;
let lookups;
const index = parserInput.i;
let elements;
let args;
let hasParens;
let parensIndex;
let parensWS = false;
if (s !== '.' && s !== '#') { return; }
parserInput.save(); // stop us absorbing part of an invalid selector
elements = this.elements();
if (elements) {
parensIndex = parserInput.i;
parensWS = parserInput.isWhitespace(-1);
if (parserInput.$char('(')) {
args = this.args(true).args;
expectChar(')');
hasParens = true;
if (parensWS) {
warn('Whitespace between a mixin name and parentheses for a mixin call is deprecated', parensIndex, 'DEPRECATED', 'mixin-call-whitespace');
}
}
if (getLookup !== false) {
lookups = this.ruleLookups();
}
if (getLookup === true && !lookups) {
parserInput.restore();
return;
}
if (inValue && !lookups && !hasParens) {
// This isn't a valid in-value mixin call
parserInput.restore();
return;
}
if (!inValue && parsers.important()) {
important = true;
}
if (inValue || parsers.end()) {
parserInput.forget();
const mixin = new(tree.mixin.Call)(elements, args, index + currentIndex, fileInfo, !lookups && important);
if (lookups) {
return new tree.NamespaceValue(mixin, lookups);
}
else {
if (!hasParens) {
warn('Calling a mixin without parentheses is deprecated', parensIndex, 'DEPRECATED', 'mixin-call-no-parens');
}
return mixin;
}
}
}
parserInput.restore();
},
/**
* Matching elements for mixins
* (Start with . or # and can have > )
*/
elements: function() {
let elements;
let e;
let c;
let elem;
let elemIndex;
const re = /^[#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/;
while (true) {
elemIndex = parserInput.i;
e = parserInput.$re(re);
if (!e) {
break;
}
elem = new(tree.Element)(c, e, false, elemIndex + currentIndex, fileInfo);
if (elements) {
elements.push(elem);
} else {
elements = [ elem ];
}
c = parserInput.$char('>');
}
return elements;
},
args: function (isCall) {
const entities = parsers.entities;
const returner = { args:null, variadic: false };
let expressions = [];
const argsSemiColon = [];
const argsComma = [];
let isSemiColonSeparated;
let expressionContainsNamed;
let name;
let nameLoop;
let value;
let arg;
let expand;
let hasSep = true;
parserInput.save();
while (true) {
if (isCall) {
arg = parsers.detachedRuleset() || parsers.expression();
} else {
parserInput.commentStore.length = 0;
if (parserInput.$str('...')) {
returner.variadic = true;
if (parserInput.$char(';') && !isSemiColonSeparated) {
isSemiColonSeparated = true;
}
(isSemiColonSeparated ? argsSemiColon : argsComma)
.push({ variadic: true });
break;
}
arg = entities.variable() || entities.property() || entities.literal() || entities.keyword() || this.call(true);
}
if (!arg || !hasSep) {
break;
}
nameLoop = null;
if (arg.throwAwayComments) {
arg.throwAwayComments();
}
value = arg;
let val = null;
if (isCall) {
// Variable
if (arg.value && arg.value.length == 1) {
val = arg.value[0];
}
} else {
val = arg;
}
if (val && (val instanceof tree.Variable || val instanceof tree.Property)) {
if (parserInput.$char(':')) {
if (expressions.length > 0) {
if (isSemiColonSeparated) {
error('Cannot mix ; and , as delimiter types');
}
expressionContainsNamed = true;
}
value = parsers.detachedRuleset() || parsers.expression();
if (!value) {
if (isCall) {
error('could not understand value for named argument');
} else {
parserInput.restore();
returner.args = [];
return returner;
}
}
nameLoop = (name = val.name);
} else if (parserInput.$str('...')) {
if (!isCall) {
returner.variadic = true;
if (parserInput.$char(';') && !isSemiColonSeparated) {
isSemiColonSeparated = true;
}
(isSemiColonSeparated ? argsSemiColon : argsComma)
.push({ name: arg.name, variadic: true });
break;
} else {
expand = true;
}
} else if (!isCall) {
name = nameLoop = val.name;
value = null;
}
}
if (value) {
expressions.push(value);
}
argsComma.push({ name:nameLoop, value, expand });
if (parserInput.$char(',')) {
hasSep = true;
continue;
}
hasSep = parserInput.$char(';') === ';';
if (hasSep || isSemiColonSeparated) {
if (expressionContainsNamed) {
error('Cannot mix ; and , as delimiter types');
}
isSemiColonSeparated = true;
if (expressions.length > 1) {
value = new(tree.Value)(expressions);
}
argsSemiColon.push({ name, value, expand });
name = null;
expressions = [];
expressionContainsNamed = false;
}
}
parserInput.forget();
returner.args = isSemiColonSeparated ? argsSemiColon : argsComma;
return returner;
},
//
// A Mixin definition, with a list of parameters
//
// .rounded (@radius: 2px, @color) {
// ...
// }
//
// Until we have a finer grained state-machine, we have to
// do a look-ahead, to make sure we don't have a mixin call.
// See the `rule` function for more information.
//
// We start by matching `.rounded (`, and then proceed on to
// the argument list, which has optional default values.
// We store the parameters in `params`, with a `value` key,
// if there is a value, such as in the case of `@radius`.
//
// Once we've got our params list, and a closing `)`, we parse
// the `{...}` block.
//
definition: function () {
let name;
let params = [];
let match;
let ruleset;
let cond;
let variadic = false;
if ((parserInput.currentChar() !== '.' && parserInput.currentChar() !== '#') ||
parserInput.peek(/^[^{]*\}/)) {
return;
}
parserInput.save();
match = parserInput.$re(/^([#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/);
if (match) {
name = match[1];
const argInfo = this.args(false);
params = argInfo.args;
variadic = argInfo.variadic;
// .mixincall("@{a}");
// looks a bit like a mixin definition..
// also
// .mixincall(@a: {rule: set;});
// so we have to be nice and restore
if (!parserInput.$char(')')) {
parserInput.restore('Missing closing \')\'');
return;
}
parserInput.commentStore.length = 0;
if (parserInput.$str('when')) { // Guard
cond = expect(parsers.conditions, 'expected condition');
}
ruleset = parsers.block();
if (ruleset) {
parserInput.forget();
return new(tree.mixin.Definition)(name, params, ruleset, cond, variadic);
} else {
parserInput.restore();
}
} else {
parserInput.restore();
}
},
ruleLookups: function() {
let rule;
const lookups = [];
if (parserInput.currentChar() !== '[') {
return;
}
while (true) {
parserInput.save();
rule = this.lookupValue();
if (!rule && rule !== '') {
parserInput.restore();
break;
}
lookups.push(rule);
parserInput.forget();
}
if (lookups.length > 0) {
return lookups;
}
},
lookupValue: function() {
parserInput.save();
if (!parserInput.$char('[')) {
parserInput.restore();
return;
}
const name = parserInput.$re(/^(?:[@$]{0,2})[_a-zA-Z0-9-]*/);
if (!parserInput.$char(']')) {
parserInput.restore();
return;
}
if (name || name === '') {
parserInput.forget();
return name;
}
parserInput.restore();
}
},
//
// Entities are the smallest recognized token,
// and can be found inside a rule's value.
//
entity: function () {
const entities = this.entities;
return this.comment() || entities.literal() || entities.variable() || entities.url() ||
entities.property() || entities.call() || entities.keyword() || this.mixin.call(true) ||
entities.javascript();
},
//
// A Declaration terminator. Note that we use `peek()` to check for '}',
// because the `block` rule will be expecting it, but we still need to make sure
// it's there, if ';' was omitted.
//
end: function () {
return parserInput.$char(';') || parserInput.peek('}');
},
//
// IE's alpha function
//
// alpha(opacity=88)
//
ieAlpha: function () {
let value;
// http://jsperf.com/case-insensitive-regex-vs-strtolower-then-regex/18
if (!parserInput.$re(/^opacity=/i)) { return; }
value = parserInput.$re(/^\d+/);
if (!value) {
value = expect(parsers.entities.variable, 'Could not parse alpha');
value = `@{${value.name.slice(1)}}`;
}
expectChar(')');
return new tree.Quoted('', `alpha(opacity=${value})`);
},
/**
* A Selector Element
*
* div
* + h1
* #socks
* input[type="text"]
*
* Elements are the building blocks for Selectors,
* they are made out of a `Combinator` (see combinator rule),
* and an element name, such as a tag a class, or `*`.
*/
element: function () {
let e;
let c;
let v;
const index = parserInput.i;
c = this.combinator();
/** This selector parser is quite simplistic and will pass a number of invalid selectors. */
e = parserInput.$re(/^(?:\d+\.\d+|\d+)%/) ||
// eslint-disable-next-line no-control-regex
parserInput.$re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) ||
parserInput.$char('*') || parserInput.$char('&') || this.attribute() ||
parserInput.$re(/^\([^&()@]+\)/) || parserInput.$re(/^[.#:](?=@)/) ||
this.entities.variableCurly();
if (!e) {
parserInput.save();
if (parserInput.$char('(')) {
if ((v = this.selector(false))) {
let selectors = [];
while (parserInput.$char(',')) {
selectors.push(v);
selectors.push(new Anonymous(','));
v = this.selector(false);
}
selectors.push(v);
if (parserInput.$char(')')) {
if (selectors.length > 1) {
e = new (tree.Paren)(new Selector(selectors));
} else {
e = new(tree.Paren)(v);
}
parserInput.forget();
} else {
parserInput.restore('Missing closing \')\'');
}
} else {
parserInput.restore('Missing closing \')\'');
}
} else {
parserInput.forget();
}
}
if (e) { return new(tree.Element)(c, e, e instanceof tree.Variable, index + currentIndex, fileInfo); }
},
//
// Combinators combine elements together, in a Selector.
//
// Because our parser isn't white-space sensitive, special care
// has to be taken, when parsing the descendant combinator, ` `,
// as it's an empty space. We have to check the previous character
// in the input, to see if it's a ` ` character. More info on how
// we deal with this in *combinator.js*.
//
combinator: function () {
let c = parserInput.currentChar();
if (c === '/') {
parserInput.save();
const slashedCombinator = parserInput.$re(/^\/[a-z]+\//i);
if (slashedCombinator) {
parserInput.forget();
return new(tree.Combinator)(slashedCombinator);
}
parserInput.restore();
}
if (c === '>' || c === '+' || c === '~' || c === '|' || c === '^') {
parserInput.i++;
if (c === '^' && parserInput.currentChar() === '^') {
c = '^^';
parserInput.i++;
}
while (parserInput.isWhitespace()) { parserInput.i++; }
return new(tree.Combinator)(c);
} else if (parserInput.isWhitespace(-1)) {
return new(tree.Combinator)(' ');
} else {
return new(tree.Combinator)(null);
}
},
//
// A CSS Selector
// with less extensions e.g. the ability to extend and guard
//
// .class > div + h1
// li a:hover
//
// Selectors are made out of one or more Elements, see above.
//
selector: function (isLess) {
const index = parserInput.i;
let elements;
let extendList;
let c;
let e;
let allExtends;
let when;
let condition;
isLess = isLess !== false;
while ((isLess && (extendList = this.extend())) || (isLess && (when = parserInput.$str('when'))) || (e = this.element())) {
if (when) {
condition = expect(this.conditions, 'expected condition');
} else if (condition) {
error('CSS guard can only be used at the end of selector');
} else if (extendList) {
if (allExtends) {
allExtends = allExtends.concat(extendList);
} else {
allExtends = extendList;
}
} else {
if (allExtends) { error('Extend can only be used at the end of selector'); }
c = parserInput.currentChar();
if (Array.isArray(e)){
e.forEach(ele => elements.push(ele));
} if (elements) {
elements.push(e);
} else {
elements = [ e ];
}
e = null;
}
if (c === '{' || c === '}' || c === ';' || c === ',' || c === ')') {
break;
}
}
if (elements) { return new(tree.Selector)(elements, allExtends, condition, index + currentIndex, fileInfo); }
if (allExtends) { error('Extend must be used to extend a selector, it cannot be used on its own'); }
},
selectors: function () {
let s;
let selectors;
while (true) {
s = this.selector();
if (!s) {
break;
}
if (selectors) {
selectors.push(s);
} else {
selectors = [ s ];
}
parserInput.commentStore.length = 0;
if (s.condition && selectors.length > 1) {
error('Guards are only currently allowed on a single selector.');
}
if (!parserInput.$char(',')) { break; }
if (s.condition) {
error('Guards are only currently allowed on a single selector.');
}
parserInput.commentStore.length = 0;
}
return selectors;
},
attribute: function () {
if (!parserInput.$char('[')) { return; }
const entities = this.entities;
let key;
let val;
let op;
//
// case-insensitive flag
// e.g. [attr operator value i]
//
let cif;
if (!(key = entities.variableCurly())) {
key = expect(/^(?:[_A-Za-z0-9-*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/);
}
op = parserInput.$re(/^[|~*$^]?=/);
if (op) {
val = entities.quoted() || parserInput.$re(/^[0-9]+%/) || parserInput.$re(/^[\w-]+/) || entities.variableCurly();
if (val) {
cif = parserInput.$re(/^[iIsS]/);
}
}
expectChar(']');
return new(tree.Attribute)(key, op, val, cif);
},
//
// The `block` rule is used by `ruleset` and `mixin.definition`.
// It's a wrapper around the `primary` rule, with added `{}`.
//
block: function () {
let content;
if (parserInput.$char('{') && (content = this.primary()) && parserInput.$char('}')) {
return content;
}
},
blockRuleset: function() {
let block = this.block();
if (block) {
return new tree.Ruleset(null, block);
}
},
detachedRuleset: function() {
let argInfo;
let params;
let variadic;
parserInput.save();
if (parserInput.$re(/^[.#]\(/)) {
/**
* DR args currently only implemented for each() function, and not
* yet settable as `@dr: #(@arg) {}`
* This should be done when DRs are merged with mixins.
* See: https://github.com/less/less-meta/issues/16
*/
argInfo = this.mixin.args(false);
params = argInfo.args;
variadic = argInfo.variadic;
if (!parserInput.$char(')')) {
parserInput.restore();
return;
}
}
const blockRuleset = this.blockRuleset();
if (blockRuleset) {
parserInput.forget();
if (params) {
return new tree.mixin.Definition(null, params, blockRuleset, null, variadic);
}
return new tree.DetachedRuleset(blockRuleset);
}
parserInput.restore();
},
//
// div, .class, body > p {...}
//
ruleset: function () {
let selectors;
let rules;
let debugInfo;
parserInput.save();
if (context.dumpLineNumbers) {
debugInfo = getDebugInfo(parserInput.i);
}
selectors = this.selectors();
if (selectors && (rules = this.block())) {
parserInput.forget();
const ruleset = new(tree.Ruleset)(selectors, rules, context.strictImports);
if (context.dumpLineNumbers) {
ruleset.debugInfo = debugInfo;
}
return ruleset;
} else {
parserInput.restore();
}
},
declaration: function () {
let name;
let value;
const index = parserInput.i;
let hasDR;
const c = parserInput.currentChar();
let important;
let merge;
let isVariable;
if (c === '.' || c === '#' || c === '&' || c === ':') { return; }
parserInput.save();
name = this.variable() || this.ruleProperty();
if (name) {
isVariable = typeof name === 'string';
if (isVariable) {
value = this.detachedRuleset();
if (value) {
hasDR = true;
}
}
parserInput.commentStore.length = 0;
if (!value) {
// a name returned by this.ruleProperty() is always an array of the form:
// [string-1, ..., string-n, ""] or [string-1, ..., string-n, "+"]
// where each item is a tree.Keyword or tree.Variable
merge = !isVariable && name.length > 1 && name.pop().value;
// Custom property values get permissive parsing
if (name[0].value && name[0].value.slice(0, 2) === '--') {
if (parserInput.$char(';')) {
value = new Anonymous('');
} else {
value = this.permissiveValue(/[;}]/, true);
}
}
// Try to store values as anonymous
// If we need the value later we'll re-parse it in ruleset.parseValue
else {
value = this.anonymousValue();
}
if (value) {
parserInput.forget();
// anonymous values absorb the end ';' which is required for them to work
return new(tree.Declaration)(name, value, false, merge, index + currentIndex, fileInfo);
}
if (!value) {
value = this.value();
}
if (value) {
important = this.important();
} else if (isVariable) {
/**
* As a last resort, try permissiveValue
*
* @todo - This has created some knock-on problems of not
* flagging incorrect syntax or detecting user intent.
*/
value = this.permissiveValue();
}
}
if (value && (this.end() || hasDR)) {
parserInput.forget();
return new(tree.Declaration)(name, value, important, merge, index + currentIndex, fileInfo);
}
else {
parserInput.restore();
}
} else {
parserInput.restore();
}
},
anonymousValue: function () {
const index = parserInput.i;
const match = parserInput.$re(/^([^.#@$+/'"*`(;{}-]*);/);
if (match) {
return new(tree.Anonymous)(match[1], index + currentIndex);
}
},
/**
* Used for custom properties, at-rules, and variables (as fallback)
* Parses almost anything inside of {} [] () "" blocks
* until it reaches outer-most tokens.
*
* First, it will try to parse comments and entities to reach
* the end. This is mostly like the Expression parser except no
* math is allowed.
*
* @param {RexExp} untilTokens - Characters to stop parsing at
*/
permissiveValue: function (untilTokens) {
let i;
let e;
let done;
let value;
const tok = untilTokens || ';';
const index = parserInput.i;
const result = [];
function testCurrentChar() {
const char = parserInput.currentChar();
if (typeof tok === 'string') {
return char === tok;
} else {
return tok.test(char);
}
}
if (testCurrentChar()) {
return;
}
value = [];
do {
e = this.comment();
if (e) {
value.push(e);
continue;
}
e = this.entity();
if (e) {
value.push(e);
}
if (parserInput.peek(',')) {
value.push(new (tree.Anonymous)(',', parserInput.i));
parserInput.$char(',');
}
} while (e);
done = testCurrentChar();
if (value.length > 0) {
value = new(tree.Expression)(value);
if (done) {
return value;
}
else {
result.push(value);
}
// Preserve space before $parseUntil as it will not
if (parserInput.prevChar() === ' ') {
result.push(new tree.Anonymous(' ', index));
}
}
parserInput.save();
value = parserInput.$parseUntil(tok);
if (value) {
if (typeof value === 'string') {
error(`Expected '${value}'`, 'Parse');
}
if (value.length === 1 && value[0] === ' ') {
parserInput.forget();
return new tree.Anonymous('', index);
}
/** @type {string} */
let item;
for (i = 0; i < value.length; i++) {
item = value[i];
if (Array.isArray(item)) {
// Treat actual quotes as normal quoted values
result.push(new tree.Quoted(item[0], item[1], true, index, fileInfo));
}
else {
if (i === value.length - 1) {
item = item.trim();
}
// Treat like quoted values, but replace vars like unquoted expressions
const quote = new tree.Quoted('\'', item, true, index, fileInfo);
const variableRegex = /@([\w-]+)/g;
const propRegex = /\$([\w-]+)/g;
if (variableRegex.test(item)) {
warn('@[ident] in unknown values will not be evaluated as variables in the future. Use @{[ident]}', index, 'DEPRECATED', 'variable-in-unknown-value');
}
if (propRegex.test(item)) {
warn('$[ident] in unknown values will not be evaluated as property references in the future. Use ${[ident]}', index, 'DEPRECATED', 'property-in-unknown-value');
}
quote.variableRegex = /@([\w-]+)|@{([\w-]+)}/g;
quote.propRegex = /\$([\w-]+)|\${([\w-]+)}/g;
result.push(quote);
}
}
parserInput.forget();
return new tree.Expression(result, true);
}
parserInput.restore();
},
//
// An @import atrule
//
// @import "lib";
//
// Depending on our environment, importing is done differently:
// In the browser, it's an XHR request, in Node, it would be a
// file-system operation. The function used for importing is
// stored in `import`, which we pass to the Import constructor.
//
'import': function () {
let path;
let features;
const index = parserInput.i;
const dir = parserInput.$re(/^@import\s+/);
if (dir) {
const options = (dir ? this.importOptions() : null) || {};
if ((path = this.entities.quoted() || this.entities.url())) {
features = this.mediaFeatures({});
if (!parserInput.$char(';')) {
parserInput.i = index;
error('missing semi-colon or unrecognised media features on import');
}
features = features && new(tree.Value)(features);
return new(tree.Import)(path, features, options, index + currentIndex, fileInfo);
}
else {
parserInput.i = index;
error('malformed import statement');
}
}
},
importOptions: function() {
let o;
const options = {};
let optionName;
let value;
// list of options, surrounded by parens
if (!parserInput.$char('(')) { return null; }
do {
o = this.importOption();
if (o) {
optionName = o;
value = true;
switch (optionName) {
case 'css':
optionName = 'less';
value = false;
break;
case 'once':
optionName = 'multiple';
value = false;
break;
}
options[optionName] = value;
if (!parserInput.$char(',')) { break; }
}
} while (o);
expectChar(')');
return options;
},
importOption: function() {
const opt = parserInput.$re(/^(less|css|multiple|once|inline|reference|optional)/);
if (opt) {
return opt[1];
}
},
mediaFeature: function (syntaxOptions) {
const entities = this.entities;
const nodes = [];
let e;
let p;
let rangeP;
let spacing = false;
parserInput.save();
do {
parserInput.save();
if (parserInput.$re(/^[0-9a-z-]*\s+\(/)) {
spacing = true;
}
parserInput.restore();
e = entities.declarationCall.bind(this)() || entities.keyword() || entities.variable() || entities.mixinLookup()
if (e) {
nodes.push(e);
if (e.type === 'Variable' ||
(e.type === 'Keyword' && /^(and|or|not|only)$/i.test(e.value))) {
spacing = true;
}
} else if (parserInput.$char('(')) {
let closed = false;
p = this.property();
parserInput.save();
if (!p && syntaxOptions.queryInParens && parserInput.$re(/^[0-9a-z-]*\s*([<>]=|<=|>=|[<>]|=)/)) {
parserInput.restore();
p = this.condition();
parserInput.save();
rangeP = this.atomicCondition(null, p.rvalue);
if (!rangeP) {
parserInput.restore();
}
} else {
parserInput.restore();
parserInput.save();
e = this.value();
if (e && parserInput.$char(')')) {
closed = true;
parserInput.forget();
} else {
parserInput.restore();
e = this.mediaFeature(syntaxOptions);
}
}
if (!closed && parserInput.$char(')')) {
closed = true;
}
if (closed) {
if (p && !e) {
nodes.push(new (tree.Paren)(new (tree.QueryInParens)(p.op, p.lvalue, p.rvalue, rangeP ? rangeP.op : null, rangeP ? rangeP.rvalue : null, p._index)));
e = p;
} else if (p && e) {
nodes.push(new (tree.Paren)(new (tree.Declaration)(p, e, null, null, parserInput.i + currentIndex, fileInfo, true)));
if (!spacing) {
nodes[nodes.length - 1].noSpacing = true;
}
spacing = false;
} else if (e) {
nodes.push(new(tree.Paren)(e));
spacing = false;
} else {
error('badly formed media feature definition');
}
} else {
error('Missing closing \')\'', 'Parse');
}
}
} while (e);
parserInput.forget();
if (nodes.length > 0) {
return new(tree.Expression)(nodes);
}
},
mediaFeatures: function (syntaxOptions) {
const entities = this.entities;
const features = [];
let e;
do {
e = this.mediaFeature(syntaxOptions);
if (e) {
features.push(e);
if (!parserInput.$char(',')) { break; }
else if (!features[features.length - 1].noSpacing) {
features[features.length - 1].noSpacing = false;
}
} else {
e = entities.variable() || entities.mixinLookup();
if (e) {
features.push(e);
if (!parserInput.$char(',')) { break; }
else if (!features[features.length - 1].noSpacing) {
features[features.length - 1].noSpacing = false;
}
}
}
} while (e);
return features.length > 0 ? features : null;
},
prepareAndGetNestableAtRule: function (treeType, index, debugInfo, syntaxOptions) {
const features = this.mediaFeatures(syntaxOptions);
const rules = this.block();
if (!rules) {
error('media definitions require block statements after any features');
}
parserInput.forget();
const atRule = new (treeType)(rules, features, index + currentIndex, fileInfo);
if (context.dumpLineNumbers) {
atRule.debugInfo = debugInfo;
}
return atRule;
},
nestableAtRule: function () {
let debugInfo;
const index = parserInput.i;
if (context.dumpLineNumbers) {
debugInfo = getDebugInfo(index);
}
parserInput.save();
if (parserInput.$peekChar('@')) {
if (parserInput.$str('@media')) {
return this.prepareAndGetNestableAtRule(tree.Media, index, debugInfo, MediaSyntaxOptions);
}
if (parserInput.$str('@container')) {
return this.prepareAndGetNestableAtRule(tree.Container, index, debugInfo, ContainerSyntaxOptions);
}
}
parserInput.restore();
},
//
// A @plugin directive, used to import plugins dynamically.
//
// @plugin (args) "lib";
//
plugin: function () {
let path;
let args;
let options;
const index = parserInput.i;
const dir = parserInput.$re(/^@plugin\s+/);
if (dir) {
warn('The @plugin directive is deprecated and will be replaced in Less 5.x. Use --plugin CLI option or the programmatic plugin API instead.', index, 'DEPRECATED', 'at-plugin');
args = this.pluginArgs();
if (args) {
options = {
pluginArgs: args,
isPlugin: true
};
}
else {
options = { isPlugin: true };
}
if ((path = this.entities.quoted() || this.entities.url())) {
if (!parserInput.$char(';')) {
parserInput.i = index;
error('missing semi-colon on @plugin');
}
return new(tree.Import)(path, null, options, index + currentIndex, fileInfo);
}
else {
parserInput.i = index;
error('malformed @plugin statement');
}
}
},
pluginArgs: function() {
// list of options, surrounded by parens
parserInput.save();
if (!parserInput.$char('(')) {
parserInput.restore();
return null;
}
const args = parserInput.$re(/^\s*([^);]+)\)\s*/);
if (args[1]) {
parserInput.forget();
return args[1].trim();
}
else {
parserInput.restore();
return null;
}
},
atruleUnknown: function (value, name, hasBlock) {
value = this.permissiveValue(/^[{;]/);
hasBlock = (parserInput.currentChar() === '{');
if (!value) {
if (!hasBlock && parserInput.currentChar() !== ';') {
error(''.concat(name, ' rule is missing block or ending semi-colon'));
}
}
else if (!value.value) {
value = null;
}
return [value, hasBlock];
},
atruleBlock: function (rules, value, isRooted, isKeywordList) {
rules = this.blockRuleset();
parserInput.save();
if (!rules && !isRooted) {
value = this.entity();
rules = this.blockRuleset();
}
if (!rules && !isRooted) {
parserInput.restore();
var e = [];
value = this.entity();
while (parserInput.$char(',')) {
e.push(value);
value = this.entity();
}
if (value && e.length > 0) {
e.push(value);
value = e;
isKeywordList = true;
}
else {
rules = this.blockRuleset();
}
}
else {
parserInput.forget();
}
return [rules, value, isKeywordList];
},
//
// A CSS AtRule
//
// @charset "utf-8";
//
atrule: function () {
const index = parserInput.i;
let name;
let value;
let rules;
let nonVendorSpecificName;
let hasIdentifier;
let hasExpression;
let hasUnknown;
let hasBlock = true;
let isRooted = true;
let isKeywordList = false;
if (parserInput.currentChar() !== '@') { return; }
value = this['import']() || this.plugin() || this.nestableAtRule();
if (value) {
return value;
}
parserInput.save();
name = parserInput.$re(/^@[a-z-]+/);
if (!name) { return; }
nonVendorSpecificName = name;
if (name.charAt(1) == '-' && name.indexOf('-', 2) > 0) {
nonVendorSpecificName = `@${name.slice(name.indexOf('-', 2) + 1)}`;
}
switch (nonVendorSpecificName) {
case '@charset':
hasIdentifier = true;
hasBlock = false;
break;
case '@namespace':
hasExpression = true;
hasBlock = false;
break;
case '@keyframes':
case '@counter-style':
hasIdentifier = true;
break;
case '@document':
case '@supports':
hasUnknown = true;
isRooted = false;
break;
case '@starting-style':
isRooted = false;
break;
case '@layer':
isRooted = false;
break;
default:
hasUnknown = true;
break;
}
parserInput.commentStore.length = 0;
if (hasIdentifier) {
value = this.entity();
if (!value) {
error(`expected ${name} identifier`);
}
} else if (hasExpression) {
value = this.expression();
if (!value) {
error(`expected ${name} expression`);
}
} else if (hasUnknown) {
const unknownPackage = this.atruleUnknown(value, name, hasBlock);
value = unknownPackage[0];
hasBlock = unknownPackage[1];
}
if (hasBlock) {
let blockPackage = this.atruleBlock(rules, value, isRooted, isKeywordList);
rules = blockPackage[0];
value = blockPackage[1];
isKeywordList = blockPackage[2];
if (!rules && !hasUnknown) {
parserInput.restore();
name = parserInput.$re(/^@[a-z-]+/);
const unknownPackage = this.atruleUnknown(value, name, hasBlock);
value = unknownPackage[0];
hasBlock = unknownPackage[1];
if (hasBlock) {
blockPackage = this.atruleBlock(rules, value, isRooted, isKeywordList);
rules = blockPackage[0];
value = blockPackage[1];
isKeywordList = blockPackage[2];
}
}
}
if (rules || isKeywordList || (!hasBlock && value && parserInput.$char(';'))) {
parserInput.forget();
return new(tree.AtRule)(name, value, rules, index + currentIndex, fileInfo,
context.dumpLineNumbers ? getDebugInfo(index) : null,
isRooted
);
}
parserInput.restore('at-rule options not recognised');
},
//
// A Value is a comma-delimited list of Expressions
//
// font-family: Baskerville, Georgia, serif;
//
// In a Rule, a Value represents everything after the `:`,
// and before the `;`.
//
value: function () {
let e;
const expressions = [];
const index = parserInput.i;
do {
e = this.expression();
if (e) {
expressions.push(e);
if (!parserInput.$char(',')) { break; }
}
} while (e);
if (expressions.length > 0) {
return new(tree.Value)(expressions, index + currentIndex);
}
},
important: function () {
if (parserInput.currentChar() === '!') {
return parserInput.$re(/^! *important/);
}
},
sub: function () {
let a;
let e;
parserInput.save();
if (parserInput.$char('(')) {
a = this.addition();
if (a && parserInput.$char(')')) {
parserInput.forget();
e = new(tree.Expression)([a]);
e.parens = true;
return e;
}
parserInput.restore('Expected \')\'');
return;
}
parserInput.restore();
},
colorOperand: function () {
parserInput.save();
// hsl or rgb or lch operand
const match = parserInput.$re(/^[lchrgbs]\s+/);
if (match) {
parserInput.forget();
return new tree.Keyword(match[0]);
}
parserInput.restore();
},
multiplication: function () {
let m;
let a;
let op;
let operation;
let isSpaced;
m = this.operand();
if (m) {
isSpaced = parserInput.isWhitespace(-1);
while (true) {
if (parserInput.peek(/^\/[*/]/)) {
break;
}
parserInput.save();
op = parserInput.$char('/') || parserInput.$char('*');
if (!op) {
let index = parserInput.i;
op = parserInput.$str('./');
if (op) {
warn('./ operator is deprecated', index, 'DEPRECATED', 'dot-slash-operator');
}
}
if (!op) { parserInput.forget(); break; }
a = this.operand();
if (!a) { parserInput.restore(); break; }
parserInput.forget();
m.parensInOp = true;
a.parensInOp = true;
operation = new(tree.Operation)(op, [operation || m, a], isSpaced);
isSpaced = parserInput.isWhitespace(-1);
}
return operation || m;
}
},
addition: function () {
let m;
let a;
let op;
let operation;
let isSpaced;
m = this.multiplication();
if (m) {
isSpaced = parserInput.isWhitespace(-1);
while (true) {
op = parserInput.$re(/^[-+]\s+/) || (!isSpaced && (parserInput.$char('+') || parserInput.$char('-')));
if (!op) {
break;
}
a = this.multiplication();
if (!a) {
break;
}
m.parensInOp = true;
a.parensInOp = true;
operation = new(tree.Operation)(op, [operation || m, a], isSpaced);
isSpaced = parserInput.isWhitespace(-1);
}
return operation || m;
}
},
conditions: function () {
let a;
let b;
const index = parserInput.i;
let condition;
a = this.condition(true);
if (a) {
while (true) {
if (!parserInput.peek(/^,\s*(not\s*)?\(/) || !parserInput.$char(',')) {
break;
}
b = this.condition(true);
if (!b) {
break;
}
condition = new(tree.Condition)('or', condition || a, b, index + currentIndex);
}
return condition || a;
}
},
condition: function (needsParens) {
let result;
let logical;
let next;
function or() {
return parserInput.$str('or');
}
result = this.conditionAnd(needsParens);
if (!result) {
return ;
}
logical = or();
if (logical) {
next = this.condition(needsParens);
if (next) {
result = new(tree.Condition)(logical, result, next);
} else {
return ;
}
}
return result;
},
conditionAnd: function (needsParens) {
let result;
let logical;
let next;
const self = this;
function insideCondition() {
const cond = self.negatedCondition(needsParens) || self.parenthesisCondition(needsParens);
if (!cond && !needsParens) {
return self.atomicCondition(needsParens);
}
return cond;
}
function and() {
return parserInput.$str('and');
}
result = insideCondition();
if (!result) {
return ;
}
logical = and();
if (logical) {
next = this.conditionAnd(needsParens);
if (next) {
result = new(tree.Condition)(logical, result, next);
} else {
return ;
}
}
return result;
},
negatedCondition: function (needsParens) {
if (parserInput.$str('not')) {
const result = this.parenthesisCondition(needsParens);
if (result) {
result.negate = !result.negate;
return result;
}
// Allow simple bare values (keyword/variable) without parens,
// e.g., `not false` or `not @var`.
// Complex conditions (comparisons, function calls) require parentheses.
const entities = this.entities;
const index = parserInput.i;
const a = entities.keyword() || entities.variable() || entities.quoted() || entities.mixinLookup();
if (a) {
return new(tree.Condition)('=', a, new(tree.Keyword)('true'), index + currentIndex, true);
}
}
},
parenthesisCondition: function (needsParens) {
function tryConditionFollowedByParenthesis(me) {
let body;
parserInput.save();
body = me.condition(needsParens);
if (!body) {
parserInput.restore();
return ;
}
if (!parserInput.$char(')')) {
parserInput.restore();
return ;
}
parserInput.forget();
return body;
}
let body;
parserInput.save();
if (!parserInput.$str('(')) {
parserInput.restore();
return ;
}
body = tryConditionFollowedByParenthesis(this);
if (body) {
parserInput.forget();
return body;
}
body = this.atomicCondition(needsParens);
if (!body) {
parserInput.restore();
return ;
}
if (!parserInput.$char(')')) {
parserInput.restore(`expected ')' got '${parserInput.currentChar()}'`);
return ;
}
parserInput.forget();
return body;
},
atomicCondition: function (needsParens, preparsedCond) {
const entities = this.entities;
const index = parserInput.i;
let a;
let b;
let c;
let op;
const cond = (function() {
return this.addition() || entities.keyword() || entities.quoted() || entities.mixinLookup();
}).bind(this)
if (preparsedCond) {
a = preparsedCond;
} else {
a = cond();
}
if (a) {
if (parserInput.$char('>')) {
if (parserInput.$char('=')) {
op = '>=';
} else {
op = '>';
}
} else
if (parserInput.$char('<')) {
if (parserInput.$char('=')) {
op = '<=';
} else {
op = '<';
}
} else
if (parserInput.$char('=')) {
if (parserInput.$char('>')) {
op = '=>';
} else if (parserInput.$char('<')) {
op = '=<';
} else {
op = '=';
}
}
if (op) {
b = cond();
if (b) {
c = new(tree.Condition)(op, a, b, index + currentIndex, false);
} else {
error('expected expression');
}
} else if (!preparsedCond) {
c = new(tree.Condition)('=', a, new(tree.Keyword)('true'), index + currentIndex, false);
}
return c;
}
},
//
// An operand is anything that can be part of an operation,
// such as a Color, or a Variable
//
operand: function () {
const entities = this.entities;
let negate;
if (parserInput.peek(/^-[@$(]/)) {
negate = parserInput.$char('-');
}
let o = this.sub() || entities.dimension() ||
entities.color() || entities.variable() ||
entities.property() || entities.call() ||
entities.quoted(true) || entities.colorKeyword() ||
this.colorOperand() || entities.mixinLookup();
if (negate) {
o.parensInOp = true;
o = new(tree.Negative)(o);
}
return o;
},
//
// Expressions either represent mathematical operations,
// or white-space delimited Entities.
//
// 1px solid black
// @var * 2
//
expression: function () {
const entities = [];
let e;
let delim;
const index = parserInput.i;
do {
e = this.comment();
if (e && !e.isLineComment) {
entities.push(e);
continue;
}
e = this.addition() || this.entity();
if (e instanceof tree.Comment) {
e = null;
}
if (e) {
entities.push(e);
// operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here
if (!parserInput.peek(/^\/[/*]/)) {
delim = parserInput.$char('/');
if (delim) {
entities.push(new(tree.Anonymous)(delim, index + currentIndex));
}
}
}
} while (e);
if (entities.length > 0) {
return new(tree.Expression)(entities);
}
},
property: function () {
const name = parserInput.$re(/^(\*?-?[_a-zA-Z0-9-]+)\s*:/);
if (name) {
return name[1];
}
},
ruleProperty: function () {
let name = [];
const index = [];
let s;
let k;
parserInput.save();
const simpleProperty = parserInput.$re(/^([_a-zA-Z0-9-]+)\s*:/);
if (simpleProperty) {
name = [new(tree.Keyword)(simpleProperty[1])];
parserInput.forget();
return name;
}
function match(re) {
const i = parserInput.i;
const chunk = parserInput.$re(re);
if (chunk) {
index.push(i);
return name.push(chunk[1]);
}
}
match(/^(\*?)/);
while (true) {
if (!match(/^((?:[\w-]+)|(?:[@$]\{[\w-]+\}))/)) {
break;
}
}
if ((name.length > 1) && match(/^((?:\+_|\+)?)\s*:/)) {
parserInput.forget();
// at last, we have the complete match now. move forward,
// convert name particles to tree objects and return:
if (name[0] === '') {
name.shift();
index.shift();
}
for (k = 0; k < name.length; k++) {
s = name[k];
name[k] = (s.charAt(0) !== '@' && s.charAt(0) !== '$') ?
new(tree.Keyword)(s) :
(s.charAt(0) === '@' ?
new(tree.Variable)(`@${s.slice(2, -1)}`, index[k] + currentIndex, fileInfo) :
new(tree.Property)(`$${s.slice(2, -1)}`, index[k] + currentIndex, fileInfo));
}
return name;
}
parserInput.restore();
}
}
};
};
Parser.serializeVars = vars => {
let s = '';
for (const name in vars) {
if (Object.hasOwnProperty.call(vars, name)) {
const value = vars[name];
s += `${((name[0] === '@') ? '' : '@') + name}: ${value}${(String(value).slice(-1) === ';') ? '' : ';'}`;
}
}
return s;
};
export default Parser;
================================================
FILE: packages/less/lib/less/plugin-manager.js
================================================
/**
* Plugin Manager
*/
class PluginManager {
constructor(less) {
this.less = less;
this.visitors = [];
this.preProcessors = [];
this.postProcessors = [];
this.installedPlugins = [];
this.fileManagers = [];
this.iterator = -1;
this.pluginCache = {};
this.Loader = new less.PluginLoader(less);
}
/**
* Adds all the plugins in the array
* @param {Array} plugins
*/
addPlugins(plugins) {
if (plugins) {
for (let i = 0; i < plugins.length; i++) {
this.addPlugin(plugins[i]);
}
}
}
/**
*
* @param plugin
* @param {String} filename
*/
addPlugin(plugin, filename, functionRegistry) {
this.installedPlugins.push(plugin);
if (filename) {
this.pluginCache[filename] = plugin;
}
if (plugin.install) {
plugin.install(this.less, this, functionRegistry || this.less.functions.functionRegistry);
}
}
/**
*
* @param filename
*/
get(filename) {
return this.pluginCache[filename];
}
/**
* Adds a visitor. The visitor object has options on itself to determine
* when it should run.
* @param visitor
*/
addVisitor(visitor) {
this.visitors.push(visitor);
}
/**
* Adds a pre processor object
* @param {object} preProcessor
* @param {number} priority - guidelines 1 = before import, 1000 = import, 2000 = after import
*/
addPreProcessor(preProcessor, priority) {
let indexToInsertAt;
for (indexToInsertAt = 0; indexToInsertAt < this.preProcessors.length; indexToInsertAt++) {
if (this.preProcessors[indexToInsertAt].priority >= priority) {
break;
}
}
this.preProcessors.splice(indexToInsertAt, 0, {preProcessor, priority});
}
/**
* Adds a post processor object
* @param {object} postProcessor
* @param {number} priority - guidelines 1 = before compression, 1000 = compression, 2000 = after compression
*/
addPostProcessor(postProcessor, priority) {
let indexToInsertAt;
for (indexToInsertAt = 0; indexToInsertAt < this.postProcessors.length; indexToInsertAt++) {
if (this.postProcessors[indexToInsertAt].priority >= priority) {
break;
}
}
this.postProcessors.splice(indexToInsertAt, 0, {postProcessor, priority});
}
/**
*
* @param manager
*/
addFileManager(manager) {
this.fileManagers.push(manager);
}
/**
*
* @returns {Array}
* @private
*/
getPreProcessors() {
const preProcessors = [];
for (let i = 0; i < this.preProcessors.length; i++) {
preProcessors.push(this.preProcessors[i].preProcessor);
}
return preProcessors;
}
/**
*
* @returns {Array}
* @private
*/
getPostProcessors() {
const postProcessors = [];
for (let i = 0; i < this.postProcessors.length; i++) {
postProcessors.push(this.postProcessors[i].postProcessor);
}
return postProcessors;
}
/**
*
* @returns {Array}
* @private
*/
getVisitors() {
return this.visitors;
}
visitor() {
const self = this;
return {
first: function() {
self.iterator = -1;
return self.visitors[self.iterator];
},
get: function() {
self.iterator += 1;
return self.visitors[self.iterator];
}
};
}
/**
*
* @returns {Array}
* @private
*/
getFileManagers() {
return this.fileManagers;
}
}
let pm;
const PluginManagerFactory = function(less, newFactory) {
if (newFactory || !pm) {
pm = new PluginManager(less);
}
return pm;
};
//
export default PluginManagerFactory;
================================================
FILE: packages/less/lib/less/render.js
================================================
import * as utils from './utils.js';
export default function(environment, ParseTree) {
const render = function (input, options, callback) {
if (typeof options === 'function') {
callback = options;
options = utils.copyOptions(this.options, {});
}
else {
options = utils.copyOptions(this.options, options || {});
}
if (!callback) {
const self = this;
return new Promise(function (resolve, reject) {
render.call(self, input, options, function(err, output) {
if (err) {
reject(err);
} else {
resolve(output);
}
});
});
} else {
this.parse(input, options, function(err, root, imports, options) {
if (err) { return callback(err); }
let result;
try {
const parseTree = new ParseTree(root, imports);
result = parseTree.toCSS(options);
}
catch (err) { return callback(err); }
callback(null, result);
});
}
};
return render;
}
================================================
FILE: packages/less/lib/less/source-map-builder.js
================================================
export default function (SourceMapOutput, environment) {
class SourceMapBuilder {
constructor(options) {
this.options = 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;
this.sourceMapURL = sourceMapOutput.sourceMapURL;
if (this.options.sourceMapInputFilename) {
this.sourceMapInputFilename = sourceMapOutput.normalizeFilename(this.options.sourceMapInputFilename);
}
if (this.options.sourceMapBasepath !== undefined && this.sourceMapURL !== undefined) {
this.sourceMapURL = sourceMapOutput.removeBasepath(this.sourceMapURL);
}
return css + this.getCSSAppendage();
}
getCSSAppendage() {
let sourceMapURL = this.sourceMapURL;
if (this.options.sourceMapFileInline) {
if (this.sourceMap === undefined) {
return '';
}
sourceMapURL = `data:application/json;base64,${environment.encodeBase64(this.sourceMap)}`;
}
if (this.options.disableSourcemapAnnotation) {
return '';
}
if (sourceMapURL) {
return `/*# sourceMappingURL=${sourceMapURL} */`;
}
return '';
}
getExternalSourceMap() {
return this.sourceMap;
}
setExternalSourceMap(sourceMap) {
this.sourceMap = sourceMap;
}
isInline() {
return this.options.sourceMapFileInline;
}
getSourceMapURL() {
return this.sourceMapURL;
}
getOutputFilename() {
return this.options.sourceMapOutputFilename;
}
getInputFilename() {
return this.sourceMapInputFilename;
}
}
return SourceMapBuilder;
}
================================================
FILE: packages/less/lib/less/source-map-output.js
================================================
export default function (environment) {
class SourceMapOutput {
constructor(options) {
this._css = [];
this._rootNode = options.rootNode;
this._contentsMap = options.contentsMap;
this._contentsIgnoredCharsMap = options.contentsIgnoredCharsMap;
if (options.sourceMapFilename) {
this._sourceMapFilename = options.sourceMapFilename.replace(/\\/g, '/');
}
this._outputFilename = options.outputFilename ? options.outputFilename.replace(/\\/g, '/') : options.outputFilename;
this.sourceMapURL = options.sourceMapURL;
if (options.sourceMapBasepath) {
this._sourceMapBasepath = options.sourceMapBasepath.replace(/\\/g, '/');
}
if (options.sourceMapRootpath) {
this._sourceMapRootpath = options.sourceMapRootpath.replace(/\\/g, '/');
if (this._sourceMapRootpath.charAt(this._sourceMapRootpath.length - 1) !== '/') {
this._sourceMapRootpath += '/';
}
} else {
this._sourceMapRootpath = '';
}
this._outputSourceFiles = options.outputSourceFiles;
this._sourceMapGeneratorConstructor = environment.getSourceMapGenerator();
this._lineNumber = 0;
this._column = 0;
}
removeBasepath(path) {
if (this._sourceMapBasepath && path.indexOf(this._sourceMapBasepath) === 0) {
path = path.substring(this._sourceMapBasepath.length);
if (path.charAt(0) === '\\' || path.charAt(0) === '/') {
path = path.substring(1);
}
}
return path;
}
normalizeFilename(filename) {
filename = filename.replace(/\\/g, '/');
filename = this.removeBasepath(filename);
return (this._sourceMapRootpath || '') + filename;
}
add(chunk, fileInfo, index, mapLines) {
// ignore adding empty strings
if (!chunk) {
return;
}
let lines, sourceLines, columns, sourceColumns, i;
if (fileInfo && fileInfo.filename) {
let inputSource = this._contentsMap[fileInfo.filename];
// remove vars/banner added to the top of the file
if (this._contentsIgnoredCharsMap[fileInfo.filename]) {
// adjust the index
index -= this._contentsIgnoredCharsMap[fileInfo.filename];
if (index < 0) { index = 0; }
// adjust the source
inputSource = inputSource.slice(this._contentsIgnoredCharsMap[fileInfo.filename]);
}
/**
* ignore empty content, or failsafe
* if contents map is incorrect
*/
if (inputSource === undefined) {
this._css.push(chunk);
return;
}
inputSource = inputSource.substring(0, index);
sourceLines = inputSource.split('\n');
sourceColumns = sourceLines[sourceLines.length - 1];
}
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 {
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)});
}
}
}
if (lines.length === 1) {
this._column += columns.length;
} else {
this._lineNumber += lines.length - 1;
this._column = columns.length;
}
this._css.push(chunk);
}
isEmpty() {
return this._css.length === 0;
}
toCSS(context) {
this._sourceMapGenerator = new this._sourceMapGeneratorConstructor({ file: this._outputFilename, sourceRoot: null });
if (this._outputSourceFiles) {
for (const filename in this._contentsMap) {
// eslint-disable-next-line no-prototype-builtins
if (this._contentsMap.hasOwnProperty(filename)) {
let source = this._contentsMap[filename];
if (this._contentsIgnoredCharsMap[filename]) {
source = source.slice(this._contentsIgnoredCharsMap[filename]);
}
this._sourceMapGenerator.setSourceContent(this.normalizeFilename(filename), source);
}
}
}
this._rootNode.genCSS(context, this);
if (this._css.length > 0) {
let sourceMapURL;
const sourceMapContent = JSON.stringify(this._sourceMapGenerator.toJSON());
if (this.sourceMapURL) {
sourceMapURL = this.sourceMapURL;
} else if (this._sourceMapFilename) {
sourceMapURL = this._sourceMapFilename;
}
this.sourceMapURL = sourceMapURL;
this.sourceMap = sourceMapContent;
}
return this._css.join('');
}
}
return SourceMapOutput;
}
================================================
FILE: packages/less/lib/less/transform-tree.js
================================================
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, compress?: boolean, pluginManager?: *, frames?: *[] }} options
* @returns {import('./tree/node.js').default}
*/
export default function(root, options) {
options = options || {};
let evaldRoot;
let variables = options.variables;
const evalEnv = new contexts.Eval(options);
//
// Allows setting variables with a hash, so:
//
// `{ color: new tree.Color('#f01') }` will become:
//
// new tree.Declaration('@color',
// new tree.Value([
// new tree.Expression([
// new tree.Color('#f01')
// ])
// ])
// )
//
if (typeof variables === 'object' && !Array.isArray(variables)) {
variables = Object.keys(variables).map(function (k) {
let value = variables[k];
if (!(value instanceof tree.Value)) {
if (!(value instanceof tree.Expression)) {
value = new tree.Expression([value]);
}
value = new tree.Value([value]);
}
return new tree.Declaration(`@${k}`, value, false, null, 0);
});
evalEnv.frames = [new tree.Ruleset(null, variables)];
}
const visitors = [
new visitor.JoinSelectorVisitor(),
new visitor.MarkVisibleSelectorsVisitor(true),
new visitor.ExtendVisitor(),
new visitor.ToCSSVisitor({compress: Boolean(options.compress)})
];
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
*/
if (options.pluginManager) {
visitorIterator = options.pluginManager.visitor();
for (let i = 0; i < 2; i++) {
visitorIterator.first();
while ((v = visitorIterator.get())) {
if (v.isPreEvalVisitor) {
if (i === 0 || preEvalVisitors.indexOf(v) === -1) {
preEvalVisitors.push(v);
v.run(root);
}
}
else {
if (i === 0 || visitors.indexOf(v) === -1) {
if (v.isPreVisitor) {
visitors.unshift(v);
}
else {
visitors.push(v);
}
}
}
}
}
}
evaldRoot = root.eval(evalEnv);
for (let i = 0; i < visitors.length; i++) {
visitors[i].run(evaldRoot);
}
// Run any remaining visitors added after eval pass
if (options.pluginManager) {
visitorIterator.first();
while ((v = visitorIterator.get())) {
if (visitors.indexOf(v) === -1 && preEvalVisitors.indexOf(v) === -1) {
v.run(evaldRoot);
}
}
}
return evaldRoot;
}
================================================
FILE: packages/less/lib/less/tree/anonymous.js
================================================
// @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;
}
/**
* @param {EvalContext} context
* @param {CSSOutput} output
*/
genCSS(context, output) {
this.nodeVisible = Boolean(this.value);
if (this.nodeVisible) {
output.add(/** @type {string} */ (this.value), this._fileInfo, this._index, this.mapLines);
}
}
}
export default Anonymous;
================================================
FILE: packages/less/lib/less/tree/assignment.js
================================================
// @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;
}
/**
* @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)));
}
}
}
export default Assignment;
================================================
FILE: packages/less/lib/less/tree/atrule-syntax.js
================================================
// @ts-check
export const MediaSyntaxOptions = {
queryInParens: true
};
export const ContainerSyntaxOptions = {
queryInParens: true
};
================================================
FILE: packages/less/lib/less/tree/atrule.js
================================================
// @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();
}
}
if (!this.simpleBlock) {
for (i = 0; i < this.rules.length; i++) {
/** @type {RulesetLikeNode} */ (this.rules[i]).allowImports = true;
}
}
if (this.declarations) {
this.setParent(this.declarations, /** @type {Node} */ (/** @type {unknown} */ (this)));
}
if (this.rules) {
this.setParent(this.rules, /** @type {Node} */ (/** @type {unknown} */ (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;
}
/**
* @param {Node[]} rules
* @param {boolean} [mergeable]
* @returns {boolean}
*/
declarationsBlock(rules, mergeable = false) {
if (!mergeable) {
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;
}
}
/**
* @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;
}
}
/** @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) {
this.declarations = visitor.visitArray(declarations);
}
if (value) {
this.value = visitor.visit(/** @type {Node} */ (value));
}
}
/** @override @returns {boolean} */
isRulesetLike() {
return /** @type {boolean} */ (/** @type {unknown} */ (this.rules || !this.isCharset()));
}
isCharset() {
return '@charset' === this.name;
}
/**
* @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(' ');
/** @type {Node} */ (value).genCSS(context, output);
}
if (this.simpleBlock) {
this.outputRuleset(context, output, /** @type {Node[]} */ (this.declarations));
} else if (rules) {
this.outputRuleset(context, output, rules);
} else {
output.add(';');
}
}
/**
* @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
// backpup media bubbling information
mediaPathBackup = context.mediaPath;
mediaBlocksBackup = context.mediaBlocks;
// deleted media bubbling information
context.mediaPath = [];
context.mediaBlocks = [];
if (value) {
value = /** @type {Node} */ (value).eval(context);
}
if (rules) {
rules = this.evalRoot(context, rules);
}
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) {
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) {
/** @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 /** @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)];
}
/** @type {Selector[]} */
let precedingSelectors = [];
if (context.frames.length > 0) {
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
) {
if (frame && !frame.root && frame.selectors && frame.selectors.length > 0) {
precedingSelectors = precedingSelectors.concat(frame.selectors);
}
}
if (precedingSelectors.length > 0) {
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 {
ampersandCount++;
}
}
}
}
const mixedAmpersands = ampersandCount > 0 && noAmpersandCount > 0 && !noAmpersands;
if (
(this.isRooted && ampersandCount > 0 && noAmpersandCount === 0 && noAmpersands)
|| !mixedAmpersands
) {
/** @type {RulesetLikeNode} */ (rules[0]).root = true;
}
return rules;
}
/** @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.prototype.variable.call(this.rules[0], name);
}
}
find() {
if (this.rules) {
// assuming that there is only one rule at this point - that is how parser constructs the rule
return Ruleset.prototype.find.apply(this.rules[0], arguments);
}
}
rulesets() {
if (this.rules) {
// assuming that there is only one rule at this point - that is how parser constructs the rule
return Ruleset.prototype.rulesets.apply(this.rules[0]);
}
}
/**
* @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
if (context.compress) {
output.add('{');
for (i = 0; i < ruleCnt; i++) {
rules[i].genCSS(context, output);
}
output.add('}');
context.tabLevel--;
return;
}
// Non-compressed
const tabSetStr = `\n${Array(context.tabLevel).join(' ')}`, tabRuleStr = `${tabSetStr} `;
if (!ruleCnt) {
output.add(` {${tabSetStr}}`);
} else {
output.add(` {${tabRuleStr}`);
rules[0].genCSS(context, output);
for (i = 1; i < ruleCnt; i++) {
output.add(tabRuleStr);
rules[i].genCSS(context, output);
}
output.add(`${tabSetStr}}`);
}
context.tabLevel--;
}
}
// 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;
================================================
FILE: packages/less/lib/less/tree/attribute.js
================================================
// @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));
}
/**
* @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 += (/** @type {Node} */ (this.value).toCSS ? /** @type {Node} */ (this.value).toCSS(context) : /** @type {string} */ (this.value));
}
if (this.cif) {
value = value + ' ' + this.cif;
}
return `[${value}]`;
}
}
export default Attribute;
================================================
FILE: packages/less/lib/less/tree/call.js
================================================
// @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.
//
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);
}
}
//
// When evaluating a function call,
// we either find the function in the functionRegistry,
// in which case we call it, passing the evaluated arguments,
// if this returns null or we cannot find the function, we
// simply print it out as it appeared originally [2].
//
// The reason why we evaluate the arguments, is in the case where
// we try to pass a variable to a function, like: `saturate(@color)`.
// The function should receive the value, not the variable.
//
/**
* @param {EvalContext} context
* @returns {Node}
*/
eval(context) {
/**
* Turn off math for calc(), and switch back on for evaluating nested functions
*/
const currentMathContext = context.mathOn;
context.mathOn = !this.calc;
if (this.calc || context.inCalc) {
context.enterCalc();
}
const exitCalc = () => {
if (this.calc || context.inCalc) {
context.exitCalc();
}
context.mathOn = currentMathContext;
};
/** @type {Node | string | boolean | null | undefined} */
let result;
const funcCaller = new FunctionCaller(this.name, context, this.getIndex(), this.fileInfo());
if (funcCaller.isValid()) {
try {
result = funcCaller.call(this.args);
exitCalc();
} catch (e) {
// eslint-disable-next-line no-prototype-builtins
if (/** @type {Record} */ (e).hasOwnProperty('line') && /** @type {Record} */ (e).hasOwnProperty('column')) {
throw e;
}
throw {
type: /** @type {Record} */ (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: /** @type {Record} */ (e).lineNumber,
column: /** @type {Record} */ (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)) {
if (!result || result === true) {
result = new Anonymous(null);
}
else {
result = new Anonymous(result.toString());
}
}
result._index = this._index;
result._fileInfo = this._fileInfo;
return result;
}
const args = this.args.map(a => a.eval(context));
exitCalc();
return new Call(this.name, args, this.getIndex(), this.fileInfo());
}
/**
* @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);
if (i + 1 < this.args.length) {
output.add(', ');
}
}
output.add(')');
}
}
export default Call;
================================================
FILE: packages/less/lib/less/tree/color.js
================================================
// @ts-check
import Node from './node.js';
import colors from '../data/colors.js';
/** @import { EvalContext, CSSOutput } from './node.js' */
//
// RGB Colors - #ff0014, #eee
//
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;
}
}
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;
}
/**
* @param {EvalContext} context
* @param {CSSOutput} output
*/
genCSS(context, output) {
output.add(this.toCSS(context));
}
/**
* @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
// converted from a named color string so we need
// to respect this and try to output named color too.
alpha = this.fround(context, this.alpha);
if (this.value) {
if (/** @type {string} */ (this.value).indexOf('rgb') === 0) {
if (alpha < 1) {
colorFunction = 'rgba';
}
} else if (/** @type {string} */ (this.value).indexOf('hsl') === 0) {
if (alpha < 1) {
colorFunction = 'hsla';
} else {
colorFunction = 'hsl';
}
} else {
return /** @type {string} */ (this.value);
}
} else {
if (alpha < 1) {
colorFunction = 'rgba';
}
}
switch (colorFunction) {
case 'rgba':
args = this.rgb.map(function (c) {
return clamp(Math.round(c), 255);
}).concat(clamp(alpha, 1));
break;
case 'hsla':
args.push(clamp(alpha, 1));
// eslint-disable-next-line no-fallthrough
case 'hsl':
color = this.toHSL();
args = [
this.fround(context, color.h),
`${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 `${colorFunction}(${args.join(`,${compress ? '' : ' '}`)})`;
}
color = this.toRGB();
if (compress) {
const splitcolor = color.split('');
// Convert color to short format
if (splitcolor[1] === splitcolor[2] && splitcolor[3] === splitcolor[4] && splitcolor[5] === splitcolor[6]) {
color = `#${splitcolor[1]}${splitcolor[3]}${splitcolor[5]}`;
}
}
return color;
}
//
// Operations have to be done per-channel, if not,
// channels will spill onto each other. Once we have
// our result, in the form of an integer triplet,
// we create a new Color node to hold the result.
//
/**
* @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() {
return toHex(this.rgb);
}
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 {
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;
}
/** @type {number} */ (h) /= 6;
}
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() {
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 {
s = d / max;
}
if (max === min) {
h = 0;
} 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;
}
/** @type {number} */ (h) /= 6;
}
return { h: /** @type {number} */ (h) * 360, s, v, a };
}
toARGB() {
return toHex([this.alpha * 255].concat(this.rgb));
}
/**
* @param {Node & { rgb?: number[], alpha?: number }} x
* @returns {0 | undefined}
*/
compare(x) {
return (x.rgb &&
x.rgb[0] === this.rgb[0] &&
x.rgb[1] === this.rgb[1] &&
x.rgb[2] === this.rgb[2] &&
x.alpha === this.alpha) ? 0 : undefined;
}
/** @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;
}
}
}
/**
* @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 `#${v.map(function (c) {
c = clamp(Math.round(c), 255);
return (c < 16 ? '0' : '') + c.toString(16);
}).join('')}`;
}
export default Color;
================================================
FILE: packages/less/lib/less/tree/combinator.js
================================================
// @ts-check
import Node from './node.js';
/** @import { EvalContext, CSSOutput } from './node.js' */
/** @type {Record} */
const _noSpaceCombinators = {
'': true,
' ': true,
'|': 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 === '';
}
}
/**
* @param {EvalContext} context
* @param {CSSOutput} output
*/
genCSS(context, output) {
const spaceOrEmpty = (context.compress || _noSpaceCombinators[/** @type {string} */ (this.value)]) ? '' : ' ';
output.add(spaceOrEmpty + this.value + spaceOrEmpty);
}
}
export default Combinator;
================================================
FILE: packages/less/lib/less/tree/comment.js
================================================
// @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(getDebugInfo(context, /** @type {DebugInfoContext} */ (this)), this.fileInfo(), this.getIndex());
}
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;
}
}
export default Comment;
================================================
FILE: packages/less/lib/less/tree/condition.js
================================================
// @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);
}
/**
* @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;
}
}
export default Condition;
================================================
FILE: packages/less/lib/less/tree/container.js
================================================
// @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);
}
/**
* @param {EvalContext} context
* @returns {Node}
*/
eval(context) {
if (this._evaluated) {
return /** @type {Node} */ (/** @type {unknown} */ (this));
}
if (!context.mediaBlocks) {
context.mediaBlocks = [];
context.mediaPath = [];
}
const media = new Container(null, [], this._index, this._fileInfo, this.visibilityInfo());
media._evaluated = true;
if (this.debugInfo) {
this.rules[0].debugInfo = this.debugInfo;
media.debugInfo = this.debugInfo;
}
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 = [/** @type {RulesetWithExtras} */ (this.rules[0].eval(context))];
context.frames.shift();
context.mediaPath.pop();
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;
================================================
FILE: packages/less/lib/less/tree/debug-info.js
================================================
// @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 {DebugInfoContext} ctx - Context object with debugInfo
* @returns {string} Debug info as CSS comment
*/
function asComment(ctx) {
return `/* line ${ctx.debugInfo.lineNumber}, ${ctx.debugInfo.fileName} */\n`;
}
/**
* @deprecated The dumpLineNumbers option is deprecated. Use sourcemaps instead.
* This function generates Sass-compatible debug info using @media -sass-debug-info syntax.
* This format had short-lived usage and is no longer recommended.
* This will be removed in a future version.
*
* @param {DebugInfoContext} ctx - Context object with debugInfo
* @returns {string} Sass-compatible debug info as @media query
*/
function asMediaQuery(ctx) {
let filenameWithProtocol = ctx.debugInfo.fileName;
if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) {
filenameWithProtocol = `file://${filenameWithProtocol}`;
}
return `@media -sass-debug-info{filename{font-family:${filenameWithProtocol.replace(/([.:/\\])/g, function (a) {
if (a == '\\') {
a = '/';
}
return `\\${a}`;
})}}line{font-family:\\00003${ctx.debugInfo.lineNumber}}}\n`;
}
/**
* Generates debug information (line numbers) for CSS output.
*
* @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)
* @returns {string} Debug info string
*
* @deprecated The dumpLineNumbers option is deprecated. Use sourcemaps instead.
* All modes ('comments', 'mediaquery', 'all') are deprecated and will be removed in a future version.
* The 'mediaquery' and 'all' modes generate Sass-compatible @media -sass-debug-info output
* which had short-lived usage and is no longer recommended.
*/
function debugInfo(context, ctx, lineSeparator) {
let result = '';
if (context.dumpLineNumbers && !context.compress) {
switch (context.dumpLineNumbers) {
case 'comments':
result = asComment(ctx);
break;
case 'mediaquery':
result = asMediaQuery(ctx);
break;
case 'all':
result = asComment(ctx) + (lineSeparator || '') + asMediaQuery(ctx);
break;
}
}
return result;
}
export default debugInfo;
================================================
FILE: packages/less/lib/less/tree/declaration.js
================================================
// @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) {
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++) {
name[i].eval(context).genCSS(context, output);
}
return value;
}
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 {
/** @type {Node} */ (this.value).genCSS(context, output);
}
catch (e) {
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);
}
/** @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 = (/** @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
if (name === 'font' && context.math === MATH.ALWAYS) {
mathBypass = true;
prevMath = context.math;
context.math = MATH.PARENS_DIVISION;
}
try {
context.importantScope.push({});
evaldValue = /** @type {Node} */ (this.value).eval(context);
if (!this.variable && evaldValue.type === 'DetachedRuleset') {
throw { message: 'Rulesets cannot be evaluated on a property.',
index: this.getIndex(), filename: this.fileInfo().filename };
}
let important = this.important;
const importantResult = context.importantScope.pop();
if (!important && importantResult && importantResult.important) {
important = importantResult.important;
}
return new Declaration(/** @type {string} */ (name),
evaldValue,
important,
this.merge,
this.getIndex(), this.fileInfo(), this.inline,
variable);
}
catch (e) {
const err = /** @type {{ index?: number, filename?: string }} */ (e);
if (typeof err.index !== 'number') {
err.index = this.getIndex();
err.filename = this.fileInfo().filename;
}
throw e;
}
finally {
if (mathBypass) {
context.math = prevMath;
}
}
}
makeImportant() {
return new Declaration(this.name,
/** @type {Node} */ (this.value),
'!important',
this.merge,
this.getIndex(), this.fileInfo(), this.inline);
}
}
export default Declaration;
================================================
FILE: packages/less/lib/less/tree/detached-ruleset.js
================================================
// @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);
}
/**
* @param {EvalContext} context
* @returns {DetachedRuleset}
*/
eval(context) {
const frames = this.frames || utils.copyArray(context.frames);
return new DetachedRuleset(this.ruleset, frames);
}
/**
* @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;
================================================
FILE: packages/less/lib/less/tree/dimension.js
================================================
// @ts-check
/* eslint-disable no-prototype-builtins */
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
//
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);
}
/**
* @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
/** @param {EvalContext} context */
eval(context) {
return this;
}
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: ${this.unit.toString()}`);
}
const value = this.fround(context, /** @type {number} */ (this.value));
let strValue = String(value);
if (value !== 0 && value < 0.000001 && value > -0.000001) {
// would be output 1e-6 etc.
strValue = value.toFixed(20).replace(/0+$/, '');
}
if (context && context.compress) {
// Zero values doesn't need a unit
if (value === 0 && this.unit.isLength()) {
output.add(strValue);
return;
}
// Float values doesn't need a leading zero
if (value > 0 && value < 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`.
/**
* @param {EvalContext} context
* @param {string} op
* @param {Dimension} other
*/
operate(context, op, other) {
/* jshint noempty:false */
let value = this._operate(context, op, /** @type {number} */ (this.value), /** @type {number} */ (other.value));
let unit = this.unit.clone();
if (op === '+' || op === '-') {
if (unit.numerator.length === 0 && unit.denominator.length === 0) {
unit = other.unit.clone();
if (this.unit.backupUnit) {
unit.backupUnit = this.unit.backupUnit;
}
} else if (other.unit.numerator.length === 0 && unit.denominator.length === 0) {
// do nothing
} 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: '${unit.toString()}' and '${other.unit.toString()}'.`);
}
value = this._operate(context, op, /** @type {number} */ (this.value), /** @type {number} */ (other.value));
}
} 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 === '/') {
unit.numerator = unit.numerator.concat(other.unit.denominator).sort();
unit.denominator = unit.denominator.concat(other.unit.numerator).sort();
unit.cancel();
}
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 {
a = this.unify();
b = other.unify();
if (a.unit.compare(b.unit) !== 0) {
return undefined;
}
}
return Node.numericCompare(/** @type {number} */ (a.value), /** @type {number} */ (b.value));
}
unify() {
return this.convertTo({ length: 'px', duration: 's', angle: 'rad' });
}
/**
* @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 unitConversions) {
if (unitConversions[/** @type {keyof typeof unitConversions} */ (i)].hasOwnProperty(conversions)) {
derivedConversions = {};
derivedConversions[i] = conversions;
}
}
conversions = derivedConversions;
}
applyUnit = function (atomicUnit, denominator) {
if (group.hasOwnProperty(atomicUnit)) {
if (denominator) {
value = value / (group[atomicUnit] / group[targetUnit]);
} else {
value = value * (group[atomicUnit] / group[targetUnit]);
}
return targetUnit;
}
return atomicUnit;
};
for (groupName in conversions) {
if (conversions.hasOwnProperty(groupName)) {
targetUnit = conversions[groupName];
group = /** @type {{ [unitName: string]: number }} */ (unitConversions[/** @type {keyof typeof unitConversions} */ (groupName)]);
unit.map(applyUnit);
}
}
unit.cancel();
return new Dimension(value, unit);
}
}
export default Dimension;
================================================
FILE: packages/less/lib/less/tree/element.js
================================================
// @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);
}
/** @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));
}
}
/** @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());
}
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());
}
/** @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)
ctx.firstSelector = true;
}
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;
}
}
}
export default Element;
================================================
FILE: packages/less/lib/less/tree/expression.js
================================================
// @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');
}
}
/** @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();
}
const value = /** @type {Node[]} */ (this.value);
if (value.length > 1) {
returnValue = new Expression(value.map(function (e) {
if (!e.eval) {
return e;
}
return e.eval(context);
}), this.noSpacing);
} else if (value.length === 1) {
const first = /** @type {Expression} */ (value[0]);
if (first.parens && !first.parensInOp && !context.inCalc) {
doubleParen = true;
}
returnValue = value[0].eval(context);
} else {
returnValue = this;
}
if (inParenthesis) {
context.outOfParenthesis();
}
if (this.parens && this.parensInOp && !mathOn && !doubleParen
&& (!(returnValue instanceof Dimension))) {
returnValue = new Paren(returnValue);
}
/** @type {Expression} */ (returnValue).noSpacing =
/** @type {Expression} */ (returnValue).noSpacing || noSpacing;
return returnValue;
}
/**
* @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(' ');
}
}
}
}
throwAwayComments() {
this.value = /** @type {Node[]} */ (this.value).filter(function(v) {
return !(v instanceof Comment);
});
}
}
export default Expression;
================================================
FILE: packages/less/lib/less/tree/extend.js
================================================
// @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);
}
/** @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
/** @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
/** @param {Selector[]} selectors */
findSelfSelectors(selectors) {
/** @type {import('./element.js').default[]} */
let selfElements = [];
let i, selectorElements;
for (i = 0; i < selectors.length; i++) {
selectorElements = selectors[i].elements;
// duplicate the logic in genCSS function inside the selector node.
// future TODO - move both logics into the selector joiner visitor
if (i > 0 && selectorElements.length && selectorElements[0].combinator.value === '') {
selectorElements[0].combinator.value = ' ';
}
selfElements = selfElements.concat(selectors[i].elements);
}
/** @type {Selector[]} */
this.selfSelectors = [new Selector(selfElements)];
this.selfSelectors[0].copyVisibilityInfo(this.visibilityInfo());
}
}
Extend.next_id = 0;
export default Extend;
================================================
FILE: packages/less/lib/less/tree/import.js
================================================
// @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]
*/
//
// CSS @import node
//
// The general strategy here is that we don't want to wait
// for the parsing to be completed, before we start importing
// the file. That's because in the context of a browser,
// most of the time will be spent waiting for the server to respond.
//
// On creation, we push the import path to our import queue, though
// `import,push`, we also pass it a callback, which it'll call once
// the file has been fetched, and parsed.
//
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));
}
/** @param {TreeVisitor} visitor */
accept(visitor) {
if (this.features) {
this.features = visitor.visit(this.features);
}
this.path = visitor.visit(this.path);
if (!this.options.isPlugin && !this.options.inline && this.root) {
this.root = /** @type {Ruleset} */ (visitor.visit(this.root));
}
}
/**
* @param {EvalContext} context
* @param {CSSOutput} output
*/
genCSS(context, output) {
if (this.css && this.path._fileInfo.reference === undefined) {
output.add('@import ', this._fileInfo, this._index);
this.path.genCSS(context, output);
if (this.features) {
output.add(' ');
this.features.genCSS(context, output);
}
output.add(';');
}
}
/** @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) {
return path.containsVariables();
}
return true;
}
/** @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 || 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
const pathValue = /** @type {string} */ (path.value);
if (fileInfo &&
pathValue &&
context.pathRequiresRewrite(pathValue)) {
path.value = context.rewritePath(pathValue, fileInfo.rootpath);
} else {
path.value = context.normalizePath(/** @type {string} */ (path.value));
}
}
return path;
}
/** @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 (Array.isArray(result)) {
result.forEach(function (node) {
node.addVisibilityBlock();
});
} else {
/** @type {Node} */ (result).addVisibilityBlock();
}
}
return result;
}
/** @param {EvalContext} context */
doEval(context) {
/** @type {Ruleset | undefined} */
let ruleset;
const features = this.features && this.features.eval(context);
if (this.options.isPlugin) {
if (this.root && this.root.eval) {
try {
this.root.eval(context);
}
catch (e) {
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
);
}
}
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) {
if (typeof this.skip === 'function') {
this.skip = this.skip();
}
if (this.skip) {
return [];
}
}
if (this.features) {
let featureValue = /** @type {Node[]} */ (this.features.value);
if (Array.isArray(featureValue) && featureValue.length >= 1) {
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.css = false;
}
}
}
}
if (this.options.inline) {
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) {
newImport.css = this.layerCss;
newImport.path._fileInfo = this._fileInfo;
}
if (!newImport.css && this.error) {
throw this.error;
}
return newImport;
} else if (this.root) {
if (this.features) {
let featureValue = /** @type {Node[]} */ (this.features.value);
if (Array.isArray(featureValue) && featureValue.length === 1) {
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(/** @type {Node[]} */ (featureValue.slice(0, 2)));
featureValue.splice(1, 1);
/** @type {Expression} */ (featureValue[0]).noSpacing = true;
return this;
}
}
}
}
ruleset = new Ruleset(null, utils.copyArray(this.root.rules));
ruleset.evalImports(context);
return this.features ? new Media(ruleset.rules, /** @type {Node[]} */ (this.features.value)) : ruleset.rules;
} else {
if (this.features) {
let featureValue = /** @type {Node[]} */ (this.features.value);
if (Array.isArray(featureValue) && featureValue.length >= 1) {
featureValue = /** @type {Node[]} */ (featureValue[0].value);
if (Array.isArray(featureValue) && featureValue.length >= 2) {
const isLayer = featureValue[0].type === 'Keyword' && featureValue[0].value === 'layer'
&& featureValue[1].type === 'Paren';
if (isLayer) {
this.css = true;
featureValue[0] = new Expression(/** @type {Node[]} */ (featureValue.slice(0, 2)));
featureValue.splice(1, 1);
/** @type {Expression} */ (featureValue[0]).noSpacing = true;
return this;
}
}
}
}
return [];
}
}
}
export default Import;
================================================
FILE: packages/less/lib/less/tree/index.js
================================================
// @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
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: MixinCall,
Definition: MixinDefinition
}
};
================================================
FILE: packages/less/lib/less/tree/javascript.js
================================================
// @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));
}
}
}
export default JavaScript;
================================================
FILE: packages/less/lib/less/tree/js-eval-node.js
================================================
// @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 }>} */
const evalContext = {};
if (!context.javascriptEnabled) {
throw { message: 'Inline JavaScript is not enabled. Is it set in your options?',
filename: this.fileInfo().filename,
index: this.getIndex() };
}
expression = expression.replace(/@\{([\w-]+)\}/g, function (_, name) {
return that.jsify(new Variable(`@${name}`, that.getIndex(), that.fileInfo()).eval(context));
});
/** @type {Function} */
let expressionFunc;
try {
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() };
}
const variables = /** @type {Node & { variables: () => Record }} */ (context.frames[0]).variables();
for (const k in variables) {
// eslint-disable-next-line no-prototype-builtins
if (variables.hasOwnProperty(k)) {
evalContext[k.slice(1)] = {
value: variables[k].value,
toJS: function () {
return this.value.eval(context).toCSS(context);
}
};
}
}
try {
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,
index: this.getIndex() };
}
return result;
}
/**
* @param {Node} obj
* @returns {string}
*/
jsify(obj) {
if (Array.isArray(obj.value) && (obj.value.length > 1)) {
return `[${obj.value.map(function (v) { return v.toCSS(/** @type {EvalContext} */ (undefined)); }).join(', ')}]`;
} else {
return obj.toCSS(/** @type {EvalContext} */ (undefined));
}
}
}
export default JsEvalNode;
================================================
FILE: packages/less/lib/less/tree/keyword.js
================================================
// @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');
export default Keyword;
================================================
FILE: packages/less/lib/less/tree/media.js
================================================
// @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);
}
/**
* @param {EvalContext} context
* @returns {Node}
*/
eval(context) {
if (!context.mediaBlocks) {
context.mediaBlocks = [];
context.mediaPath = [];
}
const media = new Media(null, [], this._index, this._fileInfo, this.visibilityInfo());
if (this.debugInfo) {
/** @type {RulesetLikeNode} */ (this.rules[0]).debugInfo = this.debugInfo;
media.debugInfo = this.debugInfo;
}
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 = [/** @type {RulesetLikeNode} */ (this.rules[0].eval(context))];
context.frames.shift();
context.mediaPath.pop();
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;
================================================
FILE: packages/less/lib/less/tree/merge-rules.js
================================================
// @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>} */
const groups = {};
/** @type {Array>} */
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);
}
});
}
================================================
FILE: packages/less/lib/less/tree/mixin-call.js
================================================
// @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 = /** @type {Selector} */ (visitor.visit(this.selector));
}
if (this.arguments.length) {
this.arguments = /** @type {MixinArg[]} */ (/** @type {unknown} */ (visitor.visitArray(/** @type {Node[]} */ (/** @type {unknown} */ (this.arguments)))));
}
}
/**
* @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) {
/** @type {number} */
let f;
/** @type {number} */
let p;
/** @type {Node & { matchCondition?: Function }} */
let namespace;
for (f = 0; f < 2; f++) {
conditionResult[f] = true;
defaultFunc.value(f);
for (p = 0; p < mixinPath.length && conditionResult[f]; p++) {
namespace = mixinPath[p];
if (namespace.matchCondition) {
conditionResult[f] = conditionResult[f] && namespace.matchCondition(null, context);
}
}
if (mixin.matchCondition) {
conditionResult[f] = conditionResult[f] && mixin.matchCondition(args, context);
}
}
if (conditionResult[0] || conditionResult[1]) {
if (conditionResult[0] != conditionResult[1]) {
return conditionResult[1] ?
defTrue : defFalse;
}
return defNone;
}
return defFalseEitherCase;
}
for (i = 0; i < this.arguments.length; i++) {
arg = this.arguments[i];
argValue = arg.value.eval(context);
if (arg.expand && Array.isArray(argValue.value)) {
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});
}
}
noArgumentsFilter = function(/** @type {MixinSearchFrame} */ rule) {return rule.matchArgs(null, context);};
for (i = 0; i < context.frames.length; i++) {
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.
// At first we evaluate each guard *twice* (with `default() == true` and `default() == false`),
// and build candidate list with corresponding flags. Then, when we know all possible matches,
// we make a final decision.
for (m = 0; m < mixins.length; m++) {
mixin = mixins[m].rule;
mixinPath = mixins[m].path;
isRecursive = false;
for (f = 0; f < context.frames.length; f++) {
if ((!(mixin instanceof MixinDefinition)) && mixin === (/** @type {Node & { originalRuleset?: Node }} */ (context.frames[f]).originalRuleset || context.frames[f])) {
isRecursive = true;
break;
}
}
if (isRecursive) {
continue;
}
if (mixin.matchArgs(args, context)) {
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;
}
}
defaultFunc.reset();
count = [0, 0, 0];
for (m = 0; m < candidates.length; m++) {
count[candidates[m].group]++;
}
if (count[defNone] > 0) {
defaultResult = defFalse;
} else {
defaultResult = defTrue;
if ((count[defTrue] + count[defFalse]) > 1) {
throw { type: 'Runtime',
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++) {
candidate = candidates[m].group;
if ((candidate === defNone) || (candidate === defaultResult)) {
try {
mixin = candidates[m].mixin;
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;
}
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 };
}
}
}
if (match) {
return /** @type {Node} */ (/** @type {unknown} */ (rules));
}
}
}
if (isOneFound) {
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 };
}
}
/** @param {Node[]} replacement */
_setVisibilityToReplacement(replacement) {
/** @type {number} */
let i;
/** @type {Node} */
let rule;
if (this.blocksVisibility()) {
for (i = 0; i < replacement.length; i++) {
rule = replacement[i];
rule.addVisibilityBlock();
}
}
}
/** @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 += `${a.name}:`;
}
if (a.value.toCSS) {
argValue += a.value.toCSS(/** @type {EvalContext} */ ({}));
} else {
argValue += '???';
}
return argValue;
}).join(', ') : ''})`;
}
}
export default MixinCall;
================================================
FILE: packages/less/lib/less/tree/mixin-definition.js
================================================
// @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 = /** @type {MixinParam[]} */ (/** @type {unknown} */ (visitor.visitArray(/** @type {Node[]} */ (/** @type {unknown} */ (this.params)))));
}
this.rules = visitor.visitArray(this.rules);
if (this.condition) {
this.condition = visitor.visit(this.condition);
}
}
/**
* @param {EvalContext} context
* @param {EvalContext} mixinEnv
* @param {MixinArg[] | null} args
* @param {Node[]} evaldArguments
* @returns {Ruleset}
*/
evalParams(context, mixinEnv, args, evaldArguments) {
/* jshint boss:true */
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.Eval(mixinEnv, /** @type {Node[]} */ ([frame]).concat(/** @type {Node[]} */ (mixinEnv.frames)));
if (args) {
args = /** @type {MixinArg[]} */ (utils.copyArray(args));
argsLength = args.length;
for (i = 0; i < argsLength; i++) {
arg = args[i];
if (name = (arg && arg.name)) {
isNamedFound = false;
for (j = 0; j < params.length; j++) {
if (!evaldArguments[j] && name === params[j].name) {
evaldArguments[j] = arg.value.eval(context);
frame.prependRule(new Declaration(name, arg.value.eval(context)));
isNamedFound = true;
break;
}
}
if (isNamedFound) {
args.splice(i, 1);
i--;
continue;
} else {
throw { type: 'Runtime', message: `Named argument for ${this.name} ${args[i].name} not found` };
}
}
}
}
argIndex = 0;
for (i = 0; i < params.length; i++) {
if (evaldArguments[i]) { continue; }
arg = args && args[argIndex];
if (name = params[i].name) {
if (params[i].variadic) {
varargs = [];
for (j = argIndex; j < argsLength; j++) {
varargs.push(/** @type {MixinArg[]} */ (args)[j].value.eval(context));
}
frame.prependRule(new Declaration(name, new Expression(varargs).eval(context)));
} else {
val = arg && arg.value;
if (val) {
// This was a mixin call, pass in a detached ruleset of it's eval'd rules
if (Array.isArray(val)) {
val = /** @type {Node} */ (/** @type {unknown} */ (new DetachedRuleset(new Ruleset(null, /** @type {Node[]} */ (val)))));
}
else {
val = val.eval(context);
}
} 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})` };
}
frame.prependRule(new Declaration(name, val));
evaldArguments[i] = val;
}
}
if (params[i].variadic && args) {
for (j = argIndex; j < argsLength; j++) {
evaldArguments[j] = args[j].value.eval(context);
}
}
argIndex++;
}
return frame;
}
/** @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 {
return r;
}
});
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));
}
/**
* @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(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 = /** @type {Ruleset} */ (ruleset.makeImportant());
}
return ruleset;
}
/**
* @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;
}
/**
* @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 {
return count;
}
}, 0);
if (!this.variadic) {
if (requiredArgsCnt < this.required) {
return false;
}
if (allArgsCnt > this.params.length) {
return false;
}
} else {
if (requiredArgsCnt < (this.required - 1)) {
return false;
}
}
// check patterns
len = Math.min(requiredArgsCnt, this.arity);
for (let i = 0; i < len; i++) {
if (!this.params[i].name && !this.params[i].variadic) {
if (/** @type {MixinArg[]} */ (args)[i].value.eval(context).toCSS(/** @type {EvalContext} */ ({})) != /** @type {Node} */ (this.params[i].value).eval(context).toCSS(/** @type {EvalContext} */ ({}))) {
return false;
}
}
}
return true;
}
}
export default Definition;
================================================
FILE: packages/less/lib/less/tree/namespace-value.js
================================================
// @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];
if (Array.isArray(rules)) {
rules = new Ruleset([new Selector()], rules);
}
const rs = /** @type {Ruleset} */ (rules);
if (name === '') {
rules = rs.lastDeclaration();
}
else if (name.charAt(0) === '@') {
if (name.charAt(1) === '@') {
name = `@${new Variable(name.slice(1)).eval(context).value}`;
}
if (rs.variables) {
rules = rs.variable(name);
}
if (!rules) {
throw { type: 'Name',
message: `variable ${name} not found`,
filename: this.fileInfo().filename,
index: this.getIndex() };
}
}
else {
if (name.substring(0, 2) === '$@') {
name = `$${new Variable(name.slice(1)).eval(context).value}`;
}
else {
name = name.charAt(0) === '$' ? name : `$${name}`;
}
if (rs.properties) {
rules = rs.property(name);
}
if (!rules) {
throw { type: 'Name',
message: `property "${name.slice(1)}" not found`,
filename: this.fileInfo().filename,
index: this.getIndex() };
}
const rulesArr = /** @type {Node[]} */ (rules);
rules = rulesArr[rulesArr.length - 1];
}
const current = /** @type {Node} */ (rules);
if (current.value) {
rules = /** @type {Node} */ (current.eval(context).value);
}
const currentNode = /** @type {Node & { ruleset?: Node }} */ (rules);
if (currentNode.ruleset) {
rules = currentNode.ruleset.eval(context);
}
}
return /** @type {Node} */ (rules);
}
}
export default NamespaceValue;
================================================
FILE: packages/less/lib/less/tree/negative.js
================================================
// @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('-');
/** @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(/** @type {Node} */ (this.value).eval(context));
}
}
export default Negative;
================================================
FILE: packages/less/lib/less/tree/nested-at-rule.js
================================================
// @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;
},
/** @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 (self.rules) {
self.rules = /** @type {Ruleset[]} */ (visitor.visitArray(self.rules));
}
},
evalFunction: function () {
/** @type {NestableAtRuleThis} */
const self = /** @type {NestableAtRuleThis} */ (/** @type {unknown} */ (this));
if (!self.features || !Array.isArray(self.features.value) || self.features.value.length < 1) {
return;
}
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' || 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);
/** @type {Node & { noSpacing?: boolean }} */ (exprValues[index]).noSpacing = true;
}
}
}
},
/** @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) {
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;
},
/** @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 !== self.type) {
const blockIndex = context.mediaBlocks.indexOf(self);
if (blockIndex > -1) {
context.mediaBlocks.splice(blockIndex, 1);
}
return self;
}
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.
//
// (a, b and c) with nested (d, e) ->
// a and d
// a and e
// b and c and d
// b and c and e
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(/** @type {Node[]} */ (path));
}));
self.setParent(self.features, self);
// Fake a tree-node that doesn't output anything.
return new Ruleset([], []);
},
/**
* @param {Node[][]} arr
* @returns {Node[][]}
*/
permute(arr) {
if (arr.length === 0) {
return [];
} 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]));
}
}
return result;
}
},
/** @param {Selector[] | undefined} selectors */
bubbleSelectors(selectors) {
/** @type {NestableAtRuleThis} */
const self = /** @type {NestableAtRuleThis} */ (/** @type {unknown} */ (this));
if (!selectors) {
return;
}
self.rules = [new Ruleset(utils.copyArray(selectors), [self.rules[0]])];
self.setParent(self.rules, self);
}
};
export default NestableAtRulePrototype;
================================================
FILE: packages/less/lib/less/tree/node.js
================================================
// @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
* from Node (since we're transpiling) is due to this issue:
*
* @see https://github.com/less/less.js/issues/3434
*/
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;
}
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) {
if (node && node instanceof Node) {
node.parent = parent;
}
}
if (Array.isArray(nodes)) {
nodes.forEach(set);
}
else {
set(nodes);
}
}
/** @returns {number} */
getIndex() {
return this._index || (this.parent && this.parent.getIndex()) || 0;
}
/** @returns {FileInfo} */
fileInfo() {
return this._fileInfo || (this.parent && this.parent.fileInfo()) || {};
}
/** @returns {boolean} */
isRulesetLike() { return false; }
/**
* @param {EvalContext} context
* @returns {string}
*/
toCSS(context) {
/** @type {string[]} */
const strs = [];
this.genCSS(context, {
add: function(chunk, fileInfo, index) {
strs.push(chunk);
},
isEmpty: function () {
return strs.length === 0;
}
});
return strs.join('');
}
/**
* @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) {
case '+': return a + b;
case '-': return a - b;
case '*': return a * b;
case '/': return a / b;
}
}
/**
* @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;
}
/**
* @param {Node & { compare?: (other: Node) => number | undefined }} a
* @param {Node & { compare?: (other: Node) => number | undefined }} b
* @returns {number | undefined}
*/
static compare(a, b) {
/* returns:
-1: a < b
0: a = b
1: a > b
and *any* other value for a != b (e.g. undefined, NaN, -2 etc.) */
if ((a.compare) &&
// for "symmetric results" force toCSS-based comparison
// of Quoted or Anonymous if either value is one of those
!(b.type === 'Quoted' || b.type === 'Anonymous')) {
return a.compare(b);
} else if (b.compare) {
return -b.compare(a);
} else if (a.type !== b.type) {
return undefined;
}
let aVal = a.value;
let bVal = b.value;
if (!Array.isArray(aVal)) {
return aVal === bVal ? 0 : undefined;
}
if (!Array.isArray(bVal)) {
return undefined;
}
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;
}
}
return 0;
}
/**
* @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) {
this.visibilityBlocks = 0;
}
return this.visibilityBlocks !== 0;
}
addVisibilityBlock() {
if (this.visibilityBlocks === undefined) {
this.visibilityBlocks = 0;
}
this.visibilityBlocks = this.visibilityBlocks + 1;
}
removeVisibilityBlock() {
if (this.visibilityBlocks === undefined) {
this.visibilityBlocks = 0;
}
this.visibilityBlocks = this.visibilityBlocks - 1;
}
ensureVisibility() {
this.nodeVisible = true;
}
ensureInvisibility() {
this.nodeVisible = false;
}
/** @returns {boolean | undefined} */
isVisible() {
return this.nodeVisible;
}
/** @returns {VisibilityInfo} */
visibilityInfo() {
return {
visibilityBlocks: this.visibilityBlocks,
nodeVisible: this.nodeVisible
};
}
/** @param {VisibilityInfo} info */
copyVisibilityInfo(info) {
if (!info) {
return;
}
this.visibilityBlocks = info.visibilityBlocks;
this.nodeVisible = info.nodeVisible;
}
}
/**
* Set by the parser at runtime on Node.prototype.
* @type {{ context: EvalContext, importManager: object, imports: object } | undefined}
*/
Node.prototype.parse = undefined;
export default Node;
================================================
FILE: packages/less/lib/less/tree/operation.js
================================================
// @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);
}
/**
* @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 && b instanceof Color) {
a = /** @type {Dimension} */ (a).toColor();
}
if (b instanceof Dimension && a instanceof Color) {
b = /** @type {Dimension} */ (b).toColor();
}
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);
}
throw { type: 'Operation',
message: 'Operation on an invalid type' };
}
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);
}
}
/**
* @param {EvalContext} context
* @param {CSSOutput} output
*/
genCSS(context, output) {
this.operands[0].genCSS(context, output);
if (this.isSpaced) {
output.add(' ');
}
output.add(this.op);
if (this.isSpaced) {
output.add(' ');
}
this.operands[1].genCSS(context, output);
}
}
export default Operation;
================================================
FILE: packages/less/lib/less/tree/paren.js
================================================
// @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('(');
/** @type {Node} */ (this.value).genCSS(context, output);
output.add(')');
}
/**
* @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;
}
}
export default Paren;
================================================
FILE: packages/less/lib/less/tree/property.js
================================================
// @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
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 ${name}`,
filename: this.fileInfo().filename,
index: this.getIndex() };
}
this.evaluating = true;
property = this.find(context.frames, function (/** @type {Node} */ frame) {
let v;
const vArr = /** @type {Ruleset} */ (frame).property(name);
if (vArr) {
for (let i = 0; i < vArr.length; i++) {
v = vArr[i];
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) {
const importantScope = context.importantScope[context.importantScope.length - 1];
importantScope.important = v.important;
}
v = v.value.eval(context);
return v;
}
});
if (property) {
this.evaluating = false;
return property;
} else {
throw { type: 'Name',
message: `Property '${name}' is undefined`,
filename: this.currentFileInfo.filename,
index: this.index };
}
}
/**
* @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; }
}
return null;
}
}
export default Property;
================================================
FILE: packages/less/lib/less/tree/query-in-parens.js
================================================
// @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);
this.mvalue = visitor.visit(this.mvalue);
if (this.rvalue) {
this.rvalue = visitor.visit(this.rvalue);
}
}
/** @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 + ' ');
this.mvalue.genCSS(context, output);
if (this.rvalue) {
output.add(' ' + this.op2 + ' ');
this.rvalue.genCSS(context, output);
}
}
}
export default QueryInParens;
================================================
FILE: packages/less/lib/less/tree/quoted.js
================================================
// @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(/** @type {string} */ (this.value));
if (!this.escaped) {
output.add(this.quote);
}
}
/** @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);
};
/**
* @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) {
let evaluatedValue = value;
do {
value = evaluatedValue.toString();
evaluatedValue = value.replace(regexp, replacementFnc);
} while (value !== evaluatedValue);
return evaluatedValue;
}
value = iterativeReplace(value, this.variableRegex, variableReplacement);
value = iterativeReplace(value, this.propRegex, propertyReplacement);
return new Quoted(this.quote + value + this.quote, value, this.escaped, this.getIndex(), this.fileInfo());
}
/**
* @param {Node} other
* @returns {number | undefined}
*/
compare(other) {
// when comparing quoted strings allow the quote to differ
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;
}
}
}
export default Quoted;
================================================
FILE: packages/less/lib/less/tree/ruleset.js
================================================
// @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} */
this._lookups = {};
/** @type {Object | null} */
this._variables = null;
/** @type {Object | 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 = /** @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));
}
if (this.rules && this.rules.length) {
this.rules = visitor.visitArray(this.rules);
}
}
/** @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);
defaultFunc.error({
type: 'Syntax',
message: 'it is currently only allowed in parametric mixin guards,'
});
for (i = 0; i < selCnt; i++) {
selector = /** @type {Selector} */ (this.selectors[i].eval(context));
for (let j = 0; j < selector.elements.length; j++) {
if (selector.elements[j].isVariable) {
hasVariable = true;
break;
}
}
selectors[i] = selector;
if (selector.evaldCondition) {
hasOnePassingSelector = true;
}
}
if (hasVariable) {
const toParseSelectors = new Array(selCnt);
for (i = 0; i < selCnt; i++) {
selector = selectors[i];
toParseSelectors[i] = selector.toCSS(context);
}
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));
}
});
}
defaultFunc.reset();
} else {
hasOnePassingSelector = true;
}
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;
ruleset.root = this.root;
ruleset.firstRoot = this.firstRoot;
ruleset.allowImports = this.allowImports;
if (this.debugInfo) {
ruleset.debugInfo = this.debugInfo;
}
if (!hasOnePassingSelector) {
/** @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
/** @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
/** @type {Selector[][] | undefined} */
let ctxSelectors = /** @type {EvalContext & { selectors?: Selector[][] }} */ (context).selectors;
if (!ctxSelectors) {
/** @type {EvalContext & { selectors?: Selector[][] }} */ (context).selectors = ctxSelectors = [];
}
ctxSelectors.unshift(this.selectors);
// Evaluate imports
if (ruleset.root || ruleset.allowImports || !ruleset.strictImports) {
ruleset.evalImports(context);
}
// Store the frames around mixin definitions,
// so they can be evaluated like closures when the time comes.
const rsRules = /** @type {Node[]} */ (ruleset.rules);
for (i = 0; (rule = rsRules[i]); i++) {
if (/** @type {RuleNode} */ (rule).evalFirst) {
rsRules[i] = rule.eval(context);
}
}
const mediaBlockCount = (context.mediaBlocks && context.mediaBlocks.length) || 0;
// Evaluate mixin calls.
for (i = 0; (rule = rsRules[i]); i++) {
if (rule.type === 'MixinCall') {
/* jshint loopfunc:true */
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(/** @type {string} */ (r.name)));
}
return true;
});
rsRules.splice.apply(rsRules, /** @type {[number, number, ...Node[]]} */ ([i, 1].concat(rules)));
i += rules.length - 1;
ruleset.resetCache();
} else if (rule.type === 'VariableCall') {
/* jshint loopfunc:true */
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
return false;
}
return true;
});
rsRules.splice.apply(rsRules, /** @type {[number, number, ...Node[]]} */ ([i, 1].concat(rules)));
i += rules.length - 1;
ruleset.resetCache();
}
}
// Evaluate everything else
for (i = 0; (rule = rsRules[i]); i++) {
if (!/** @type {RuleNode} */ (rule).evalFirst) {
rsRules[i] = rule = rule.eval ? rule.eval(context) : rule;
}
}
// Evaluate everything else
for (i = 0; (rule = rsRules[i]); i++) {
// for rulesets, check if it is a css guard and can be removed
if (rule instanceof Ruleset && rule.selectors && rule.selectors.length === 1) {
// check if it can be folded in (e.g. & where)
if (rule.selectors[0] && rule.selectors[0].isJustParentSelector()) {
rsRules.splice(i--, 1);
for (let j = 0; (subRule = rule.rules[j]); j++) {
if (subRule instanceof Node) {
subRule.copyVisibilityInfo(rule.visibilityInfo());
if (!(subRule instanceof Declaration) || !subRule.variable) {
rsRules.splice(++i, 0, subRule);
}
}
}
}
}
}
// Pop the stack
ctxFrames.shift();
ctxSelectors.shift();
if (context.mediaBlocks) {
for (i = mediaBlockCount; i < context.mediaBlocks.length; i++) {
/** @type {RuleNode} */ (context.mediaBlocks[i]).bubbleSelectors(selectors);
}
}
return ruleset;
}
/** @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 && (/** @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);
}
this.resetCache();
}
}
}
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 {
return r;
}
}), this.strictImports, this.visibilityInfo());
return result;
}
/** @param {Node[] | object[] | null} [args] */
matchArgs(args) {
return !args || args.length === 0;
}
/**
* @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) {
return false;
}
if (lastSelector.condition &&
!lastSelector.condition.eval(
new contexts.Eval(context,
context.frames))) {
return false;
}
return true;
}
resetCache() {
this._rulesets = null;
this._variables = null;
this._properties = null;
this._lookups = {};
}
variables() {
if (!this._variables) {
this._variables = !this.rules ? {} : this.rules.reduce(function (/** @type {Object} */ hash, /** @type {Node} */ r) {
if (r instanceof Declaration && r.variable === true) {
hash[/** @type {string} */ (r.name)] = r;
}
// when evaluating variables in an import statement, imports have not been eval'd
// so we need to go inside import statements.
// guard against root being a string (in the case of inlined less)
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));
}
}
}
return hash;
}, {});
}
return this._variables;
}
properties() {
if (!this._properties) {
this._properties = !this.rules ? {} : this.rules.reduce(function (/** @type {Object} */ 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[`$${name}`]) {
hash[`$${name}`] = [ r ];
}
else {
hash[`$${name}`].push(r);
}
}
return hash;
}, {});
}
return this._properties;
}
/** @param {string} name */
variable(name) {
const decl = this.variables()[name];
if (decl) {
return this.parseValue(decl);
}
}
/** @param {string} name */
property(name) {
const decl = this.properties()[name];
if (decl) {
return this.parseValue(decl);
}
}
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);
}
}
}
/** @param {Declaration | Declaration[]} toParse */
parseValue(toParse) {
const self = this;
/** @param {Declaration} decl */
function transformDeclaration(decl) {
if (decl.value instanceof Anonymous && !/** @type {Declaration & { parsed?: boolean }} */ (decl).parsed) {
if (typeof decl.value.value === 'string') {
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));
}
return decl;
}
else {
return decl;
}
}
if (!Array.isArray(toParse)) {
return transformDeclaration.call(self, toParse);
}
else {
/** @type {Declaration[]} */
const nodes = [];
for (let ti = 0; ti < toParse.length; ti++) {
nodes.push(transformDeclaration.call(self, toParse[ti]));
}
return nodes;
}
}
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 (/** @type {RuleNode} */ (rule).isRuleset) {
filtRules.push(rule);
}
}
return filtRules;
}
/** @param {Node} rule */
prependRule(rule) {
const rules = this.rules;
if (rules) {
rules.unshift(rule);
} else {
this.rules = [ rule ];
}
this.setParent(rule, this);
}
/**
* @param {Selector} selector
* @param {Ruleset | null} [self]
* @param {((rule: Node) => boolean)} [filter]
* @returns {{ rule: Node, path: Node[] }[]}
*/
find(selector, self, filter) {
self = self || this;
/** @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 (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 = /** @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);
}
Array.prototype.push.apply(rules, foundMixins);
}
} else {
rules.push({ rule, path: []});
}
break;
}
}
}
});
this._lookups[key] = rules;
return rules;
}
/**
* @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++;
}
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) {
importNodeIndex++;
}
ruleNodes.push(rule);
} else if (/** @type {RuleNode} */ (rule).isCharset && /** @type {RuleNode} */ (rule).isCharset()) {
ruleNodes.splice(charsetNodeIndex, 0, rule);
charsetNodeIndex++;
importNodeIndex++;
} else if (rule.type === 'Import') {
ruleNodes.splice(importNodeIndex, 0, rule);
importNodeIndex++;
} else {
ruleNodes.push(rule);
}
}
ruleNodes = charsetRuleNodes.concat(ruleNodes);
// If this is the root node, we don't render
// a selector, or {}.
if (!this.root) {
debugInfo = getDebugInfo(context, /** @type {{ debugInfo: { lineNumber: number, fileName: string } }} */ (/** @type {unknown} */ (this)), tabSetStr);
if (debugInfo) {
output.add(debugInfo);
output.add(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); }
/** @type {EvalContext & { firstSelector?: boolean }} */ (context).firstSelector = true;
path[0].genCSS(context, output);
/** @type {EvalContext & { firstSelector?: boolean }} */ (context).firstSelector = false;
for (j = 1; j < pathSubCnt; j++) {
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;
}
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());
}
context.lastRule = currentLastRule;
if (!context.lastRule && rule.isVisible()) {
output.add(context.compress ? '' : (`\n${tabRuleStr}`));
} else {
context.lastRule = false;
}
}
if (!this.root) {
output.add((context.compress ? '}' : `\n${tabSetStr}}`));
context.tabLevel--;
}
if (!output.isEmpty() && !context.compress && this.firstRoot) {
output.add('\n');
}
}
/**
* @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]);
}
}
/**
* @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) {
/** @type {Paren} */
let replacementParen;
/** @type {number} */
let j;
if (elementsToPak.length === 0) {
replacementParen = new Paren(elementsToPak[0]);
} else {
const insideParent = new Array(elementsToPak.length);
for (j = 0; j < elementsToPak.length; j++) {
insideParent[j] = new Element(
null,
elementsToPak[j],
originalElement.isVariable,
originalElement._index,
originalElement._fileInfo
);
}
replacementParen = new Paren(new Selector(insideParent));
}
return replacementParen;
}
/**
* @param {Paren | Selector} containedElement
* @param {Element} originalElement
* @returns {Selector}
*/
function createSelector(containedElement, originalElement) {
/** @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;
}
/**
* @param {Selector[]} beginningPath
* @param {Selector[]} addPath
* @param {Element} replacedElement
* @param {Selector} originalSelector
* @returns {Selector[]}
*/
function addReplacementIntoPath(beginningPath, addPath, replacedElement, originalSelector) {
/** @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,
// if not newJoinedSelector will be the last set of elements in the selector
if (beginningPath.length > 0) {
newSelectorPath = utils.copyArray(beginningPath);
lastSelector = newSelectorPath.pop();
newJoinedSelector = originalSelector.createDerived(utils.copyArray(lastSelector.elements));
}
else {
newJoinedSelector = originalSelector.createDerived([]);
}
if (addPath.length > 0) {
// /deep/ is a CSS4 selector - (removed, so should deprecate)
// that is valid without anything in front of it
// so if the & does not have a combinator that is "" or " " then
// and there is a combinator on the parent, then grab that.
// this also allows + a { & .b { .a & { ... though not sure why you would want to do that
let combinator = replacedElement.combinator;
const parentEl = addPath[0].elements[0];
if (combinator.emptyOrWhitespace && !parentEl.combinator.emptyOrWhitespace) {
combinator = parentEl.combinator;
}
// join the elements so far with the first part of the parent
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
if (newJoinedSelector.elements.length !== 0) {
newSelectorPath.push(newJoinedSelector);
}
// put together the parent selectors after the join (e.g. the rest of the parent)
if (addPath.length > 1) {
let restOfPath = addPath.slice(1);
restOfPath = restOfPath.map(function (/** @type {Selector} */ selector) {
return selector.createDerived(selector.elements, []);
});
newSelectorPath = newSelectorPath.concat(restOfPath);
}
return newSelectorPath;
}
/**
* @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++) {
const newSelectorPath = addReplacementIntoPath(beginningPath[j], addPaths, replacedElement, originalSelector);
result.push(newSelectorPath);
}
return result;
}
/**
* @param {Element[]} elements
* @param {Selector[][]} selectors
*/
function mergeElementsOnToSelectors(elements, selectors) {
/** @type {number} */
let i;
/** @type {Selector[]} */
let sel;
if (elements.length === 0) {
return ;
}
if (selectors.length === 0) {
selectors.push([ new Selector(elements) ]);
return;
}
for (i = 0; (sel = selectors[i]); i++) {
// if the previous thing in sel is a parent this needs to join on to it
if (sel.length > 0) {
sel[sel.length - 1] = sel[sel.length - 1].createDerived(sel[sel.length - 1].elements.concat(elements));
}
else {
sel.push(new Selector(elements));
}
}
}
/**
* @param {Selector[][]} paths
* @param {Selector[][]} context
* @param {Selector} inSelector
* @returns {boolean}
*/
function replaceParentSelector(paths, context, inSelector) {
// The paths are [[Selector]]
// The first list is a list of comma separated selectors
// The inner list is a list of inheritance separated selectors
// e.g.
// .a, .b {
// .c {
// }
// }
// == [[.a] [.c]] [[.b] [.c]]
//
/** @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) {
/** @type {Node} */
let maybeSelector;
if (!(element.value instanceof Paren)) {
return null;
}
maybeSelector = /** @type {Node} */ (element.value.value);
if (!(maybeSelector instanceof Selector)) {
return null;
}
return maybeSelector;
}
// the elements from the current selector so far
currentElements = [];
// the current list of new selectors to add to the path.
// We will build it up. We initiate it with one empty selector as we "multiply" the new selectors
// by the parents
newSelectors = [
[]
];
for (i = 0; (el = inSelector.elements[i]); i++) {
// non parent reference elements just get added
if (el.value !== '&') {
const nestedSelector = findNestedSelector(el);
if (nestedSelector !== null) {
// merge the current list of non parent selector elements
// on to the current list of selectors to add
mergeElementsOnToSelectors(currentElements, newSelectors);
/** @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 {
currentElements.push(el);
}
} 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
for (j = 0; j < newSelectors.length; j++) {
sel = newSelectors[j];
// if we don't have any parent paths, the & might be in a mixin so that it can be used
// whether there are parents or not
if (context.length === 0) {
// the combinator used on el should now be applied to the next element instead so that
// it is not lost
if (sel.length > 0) {
sel[0].elements.push(new Element(el.combinator, '', el.isVariable, el._index, el._fileInfo));
}
selectorsMultiplied.push(sel);
}
else {
// and the parent selectors
for (k = 0; k < context.length; k++) {
// We need to put the current selectors
// then join the last selector's elements on to the parents selectors
const newSelectorPath = addReplacementIntoPath(sel, context[k], el, inSelector);
// add that to our new set of selectors
selectorsMultiplied.push(newSelectorPath);
}
}
}
// our new selectors has been multiplied, so reset the state
newSelectors = selectorsMultiplied;
currentElements = [];
}
}
// 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++) {
length = newSelectors[i].length;
if (length > 0) {
paths.push(newSelectors[i]);
lastSelector = newSelectors[i][length - 1];
newSelectors[i][length - 1] = lastSelector.createDerived(lastSelector.elements, inSelector.extendList);
}
}
return hadParentSelector;
}
/**
* @param {VisibilityInfo} visibilityInfo
* @param {Selector} deriveFrom
*/
function deriveSelector(visibilityInfo, deriveFrom) {
const newSelector = deriveFrom.createDerived(deriveFrom.elements, deriveFrom.extendList, deriveFrom.evaldCondition);
newSelector.copyVisibilityInfo(visibilityInfo);
return newSelector;
}
// joinSelector code follows
/** @type {number} */
let i;
/** @type {Selector[][]} */
let newPaths;
/** @type {boolean} */
let hadParentSelector;
newPaths = [];
hadParentSelector = replaceParentSelector(newPaths, context, selector);
if (!hadParentSelector) {
if (context.length > 0) {
newPaths = [];
for (i = 0; i < context.length; i++) {
const concatenated = context[i].map(deriveSelector.bind(this, selector.visibilityInfo()));
concatenated.push(selector);
newPaths.push(concatenated);
}
}
else {
newPaths = [[selector]];
}
}
for (i = 0; i < newPaths.length; i++) {
paths.push(newPaths[i]);
}
}
}
export default Ruleset;
================================================
FILE: packages/less/lib/less/tree/selector.js
================================================
// @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 = /** @type {Element[]} */ (visitor.visitArray(this.elements));
}
if (this.extendList) {
this.extendList = visitor.visitArray(this.extendList);
}
if (this.condition) {
this.condition = visitor.visit(this.condition);
}
}
/**
* @param {Element[]} elements
* @param {Node[] | null} [extendList]
* @param {boolean | Node} [evaldCondition]
*/
createDerived(elements, extendList, evaldCondition) {
elements = this.getElements(elements);
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;
}
/**
* @param {(Element | Selector)[] | string | null | undefined} els
* @returns {Element[]}
*/
getElements(els) {
if (!els) {
return [new Element('', '&', false, this._index, this._fileInfo)];
}
if (typeof els === 'string') {
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 /** @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;
}
/**
* @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 {
for (i = 0; i < olen; i++) {
if (elements[i].value !== mixinEls[i]) {
return 0;
}
}
}
return olen; // return number of matched elements
}
/** @returns {string[]} */
mixinElements() {
if (this.mixinElements_) {
return this.mixinElements_;
}
/** @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) {
if (elements[0] === '&') {
elements.shift();
}
} else {
elements = [];
}
return (this.mixinElements_ = elements);
}
isJustParentSelector() {
return !this.mediaEmpty &&
this.elements.length === 1 &&
this.elements[0].value === '&' &&
(this.elements[0].combinator.value === ' ' || this.elements[0].combinator.value === '');
}
/** @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);
}
/**
* @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());
}
for (i = 0; i < this.elements.length; i++) {
element = this.elements[i];
element.genCSS(context, output);
}
}
getIsOutput() {
return this.evaldCondition;
}
}
export default Selector;
================================================
FILE: packages/less/lib/less/tree/unicode-descriptor.js
================================================
// @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;
================================================
FILE: packages/less/lib/less/tree/unit.js
================================================
// @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];
}
}
clone() {
return new Unit(utils.copyArray(this.numerator), utils.copyArray(this.denominator), this.backupUnit);
}
/**
* @param {EvalContext} context
* @param {CSSOutput} output
*/
genCSS(context, output) {
// Dimension checks the unit is singular and throws an error if in strict math mode.
const strictUnits = context && context.strictUnits;
if (this.numerator.length === 1) {
output.add(this.numerator[0]); // the ideal situation
} else if (!strictUnits && this.backupUnit) {
output.add(this.backupUnit);
} else if (!strictUnits && this.denominator.length) {
output.add(this.denominator[0]);
}
}
toString() {
let i, returnStr = this.numerator.join('*');
for (i = 0; i < this.denominator.length; i++) {
returnStr += `/${this.denominator[i]}`;
}
return returnStr;
}
/**
* @param {Unit} other
* @returns {0 | undefined}
*/
compare(other) {
return this.is(other.toString()) ? 0 : undefined;
}
/** @param {string} unitString */
is(unitString) {
return this.toString().toUpperCase() === unitString.toUpperCase();
}
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() {
return this.numerator.length <= 1 && this.denominator.length === 0;
}
/** @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);
}
}
/** @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) {
// eslint-disable-next-line no-prototype-builtins
if (group.hasOwnProperty(atomicUnit) && !result[groupName]) {
result[groupName] = atomicUnit;
}
return atomicUnit;
};
for (groupName in unitConversions) {
// eslint-disable-next-line no-prototype-builtins
if (unitConversions.hasOwnProperty(groupName)) {
group = /** @type {{ [unitName: string]: number }} */ (unitConversions[/** @type {keyof typeof unitConversions} */ (groupName)]);
this.map(mapUnit);
}
}
return result;
}
cancel() {
/** @type {{ [unit: string]: number }} */
const counter = {};
/** @type {string} */
let atomicUnit;
let i;
for (i = 0; i < this.numerator.length; i++) {
atomicUnit = this.numerator[i];
counter[atomicUnit] = (counter[atomicUnit] || 0) + 1;
}
for (i = 0; i < this.denominator.length; i++) {
atomicUnit = this.denominator[i];
counter[atomicUnit] = (counter[atomicUnit] || 0) - 1;
}
this.numerator = [];
this.denominator = [];
for (atomicUnit in counter) {
// eslint-disable-next-line no-prototype-builtins
if (counter.hasOwnProperty(atomicUnit)) {
const count = counter[atomicUnit];
if (count > 0) {
for (i = 0; i < count; i++) {
this.numerator.push(atomicUnit);
}
} else if (count < 0) {
for (i = 0; i < -count; i++) {
this.denominator.push(atomicUnit);
}
}
}
}
this.numerator.sort();
this.denominator.sort();
}
}
export default Unit;
================================================
FILE: packages/less/lib/less/tree/url.js
================================================
// @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 `\\${match}`; });
}
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(');
/** @type {Node} */ (this.value).genCSS(context, output);
output.add(')');
}
/** @param {EvalContext} context */
eval(context) {
const val = /** @type {Node} */ (this.value).eval(context);
let rootpath;
if (!this.isEvald) {
// Add the rootpath if the URL requires a rewrite
rootpath = this.fileInfo() && this.fileInfo().rootpath;
if (typeof rootpath === 'string' &&
typeof val.value === 'string' &&
context.pathRequiresRewrite(/** @type {string} */ (val.value))) {
if (!/** @type {import('./quoted.js').default} */ (val).quote) {
rootpath = escapePath(rootpath);
}
val.value = context.rewritePath(/** @type {string} */ (val.value), rootpath);
} else {
val.value = context.normalizePath(/** @type {string} */ (val.value));
}
// Add url args if enabled
if (context.urlArgs) {
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;
}
}
}
}
return new URL(val, this.getIndex(), this.fileInfo(), true);
}
}
export default URL;
================================================
FILE: packages/less/lib/less/tree/value.js
================================================
// @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;
}
}
/** @param {TreeVisitor} visitor */
accept(visitor) {
if (this.value) {
this.value = visitor.visitArray(/** @type {Node[]} */ (this.value));
}
}
/**
* @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);
}));
}
}
/**
* @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) ? ',' : ', ');
}
}
}
}
export default Value;
================================================
FILE: packages/less/lib/less/tree/variable-call.js
================================================
// @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(null, detachedRuleset);
}
else if (Array.isArray(detachedRuleset.value)) {
rules = new Ruleset(null, detachedRuleset.value);
}
else {
throw error;
}
detachedRuleset = new DetachedRuleset(rules);
}
const dr = /** @type {DetachedRuleset} */ (detachedRuleset);
if (dr.ruleset) {
return dr.callEval(context);
}
throw error;
}
}
export default VariableCall;
================================================
FILE: packages/less/lib/less/tree/variable.js
================================================
// @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 = `@${new Variable(name.slice(1), this.getIndex(), this.fileInfo()).eval(context).value}`;
}
if (this.evaluating) {
throw { type: 'Name',
message: `Recursive variable definition for ${name}`,
filename: this.fileInfo().filename,
index: this.getIndex() };
}
this.evaluating = true;
variable = this.find(context.frames, function (frame) {
const v = /** @type {Ruleset} */ (frame).variable(name);
if (v) {
if (v.important) {
const importantScope = context.importantScope[context.importantScope.length - 1];
importantScope.important = v.important;
}
// If in calc, wrap vars in a function call to cascade evaluate args first
if (context.inCalc) {
return (new Call('_SELF', [v.value], 0, undefined)).eval(context);
}
else {
return v.value.eval(context);
}
}
});
if (variable) {
this.evaluating = false;
return variable;
} else {
throw { type: 'Name',
message: `variable ${name} is undefined`,
filename: this.fileInfo().filename,
index: this.getIndex() };
}
}
/**
* @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; }
}
return null;
}
}
export default Variable;
================================================
FILE: packages/less/lib/less/utils.js
================================================
/* jshint proto: true */
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,
column
};
}
export function copyArray(arr) {
let i;
const length = arr.length;
const copy = new Array(length);
for (i = 0; i < length; i++) {
copy[i] = arr[i];
}
return copy;
}
export function clone(obj) {
const cloned = {};
for (const prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
cloned[prop] = obj[prop];
}
}
return cloned;
}
export function defaults(obj1, obj2) {
let newObj = obj2 || {};
if (!obj2._defaults) {
newObj = {};
const defaults = copy(obj1);
newObj._defaults = defaults;
const cloned = obj2 ? copy(obj2) : {};
Object.assign(newObj, defaults, cloned);
}
return newObj;
}
export function copyOptions(obj1, obj2) {
if (obj2 && obj2._defaults) {
return obj2;
}
const opts = defaults(obj1, obj2);
if (opts.strictMath) {
opts.math = Constants.Math.PARENS;
}
// Back compat with changed relativeUrls option
if (opts.relativeUrls) {
opts.rewriteUrls = Constants.RewriteUrls.ALL;
}
if (typeof opts.math === 'string') {
switch (opts.math.toLowerCase()) {
case 'always':
opts.math = Constants.Math.ALWAYS;
break;
case 'parens-division':
opts.math = Constants.Math.PARENS_DIVISION;
break;
case 'strict':
case 'parens':
opts.math = Constants.Math.PARENS;
break;
default:
opts.math = Constants.Math.PARENS;
}
}
if (typeof opts.rewriteUrls === 'string') {
switch (opts.rewriteUrls.toLowerCase()) {
case 'off':
opts.rewriteUrls = Constants.RewriteUrls.OFF;
break;
case 'local':
opts.rewriteUrls = Constants.RewriteUrls.LOCAL;
break;
case 'all':
opts.rewriteUrls = Constants.RewriteUrls.ALL;
break;
}
}
return opts;
}
export function merge(obj1, obj2) {
for (const prop in obj2) {
if (Object.prototype.hasOwnProperty.call(obj2, prop)) {
obj1[prop] = obj2[prop];
}
}
return obj1;
}
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 {
if (value !== undefined) {
result.push(value);
}
}
}
return result;
}
export function isNullOrUndefined(val) {
return val === null || val === undefined
}
================================================
FILE: packages/less/lib/less/visitors/extend-visitor.js
================================================
/* eslint-disable no-unused-vars */
/**
* @todo - Remove unused when JSDoc types are added for visitor methods
*/
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 */
class ExtendFinderVisitor {
constructor() {
this._visitor = new Visitor(this);
this.contexts = [];
this.allExtendsStack = [[]];
}
run(root) {
root = this._visitor.visit(root);
root.allExtends = this.allExtendsStack[0];
return root;
}
visitDeclaration(declNode, visitArgs) {
visitArgs.visitDeeper = false;
}
visitMixinDefinition(mixinDefinitionNode, visitArgs) {
visitArgs.visitDeeper = false;
}
visitRuleset(rulesetNode, visitArgs) {
if (rulesetNode.root) {
return;
}
let i;
let j;
let extend;
const allSelectorsExtendList = [];
let extendList;
// get &:extend(.a); rules which apply to all selectors in this ruleset
const rules = rulesetNode.rules, ruleCnt = rules ? rules.length : 0;
for (i = 0; i < ruleCnt; i++) {
if (rulesetNode.rules[i] instanceof tree.Extend) {
allSelectorsExtendList.push(rules[i]);
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
const paths = rulesetNode.paths;
for (i = 0; i < paths.length; i++) {
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) {
return allSelectorsExtend.clone();
});
}
for (j = 0; j < extendList.length; j++) {
this.foundExtends = true;
extend = extendList[j];
extend.findSelfSelectors(selectorPath);
extend.ruleset = rulesetNode;
if (j === 0) { extend.firstExtendOnThisSelectorPath = true; }
this.allExtendsStack[this.allExtendsStack.length - 1].push(extend);
}
}
this.contexts.push(rulesetNode.selectors);
}
visitRulesetOut(rulesetNode) {
if (!rulesetNode.root) {
this.contexts.length = this.contexts.length - 1;
}
}
visitMedia(mediaNode, visitArgs) {
mediaNode.allExtends = [];
this.allExtendsStack.push(mediaNode.allExtends);
}
visitMediaOut(mediaNode) {
this.allExtendsStack.length = this.allExtendsStack.length - 1;
}
visitAtRule(atRuleNode, visitArgs) {
atRuleNode.allExtends = [];
this.allExtendsStack.push(atRuleNode.allExtends);
}
visitAtRuleOut(atRuleNode) {
this.allExtendsStack.length = this.allExtendsStack.length - 1;
}
}
class ProcessExtendsVisitor {
constructor() {
this._visitor = new Visitor(this);
}
run(root) {
const extendFinder = new ExtendFinderVisitor();
this.extendIndices = {};
extendFinder.run(root);
if (!extendFinder.foundExtends) { return root; }
root.allExtends = root.allExtends.concat(this.doExtendChaining(root.allExtends, root.allExtends));
this.allExtendsStack = [root.allExtends];
const newRoot = this._visitor.visit(root);
this.checkExtendsForNonMatched(root.allExtends);
return newRoot;
}
checkExtendsForNonMatched(extendList) {
const indices = this.extendIndices;
extendList.filter(function(extend) {
return !extend.hasFoundMatches && extend.parent_ids.length == 1;
}).forEach(function(extend) {
let selector = '_unknown_';
try {
selector = extend.selector.toCSS({});
}
catch (_) {}
if (!indices[`${extend.index} ${selector}`]) {
indices[`${extend.index} ${selector}`] = true;
/**
* @todo Shouldn't this be an error? To alert the developer
* that they may have made an error in the selector they are
* targeting?
*/
logger.warn(`WARNING: extend '${selector}' has no matches`);
}
});
}
doExtendChaining(extendsList, extendsListTarget, iterationCount) {
//
// chaining is different from normal extension.. if we extend an extend then we are not just copying, altering
// and pasting the selector we would do normally, but we are also adding an extend with the same target selector
// this means this new extend can then go and alter other extends
//
// this method deals with all the chaining work - without it, extend is flat and doesn't work on other extend selectors
// this is also the most expensive.. and a match on one selector can cause an extension of a selector we had already
// processed if we look at each selector at a time, as is done in visitRuleset
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.
// a target extend is the one on the ruleset we are looking at copy/edit/pasting in place
// e.g. .a:extend(.b) {} and .b:extend(.c) {} then the first extend extends the second one
// and the second is the target.
// the separation into two lists allows us to process a subset of chains with a bigger set, as is the
// case when processing media queries
for (extendIndex = 0; extendIndex < extendsList.length; extendIndex++) {
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; }
// 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) {
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.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
// extends will look at the same selector path, so when extending
// we know that any others will be duplicates in terms of what is added to the css
if (targetExtend.firstExtendOnThisSelectorPath) {
newExtend.firstExtendOnThisSelectorPath = true;
targetExtend.ruleset.paths.push(newSelector);
}
});
}
}
}
if (extendsToAdd.length) {
// try to detect circular references to stop a stack overflow.
// may no longer be needed.
this.extendChainCount++;
if (iterationCount > 100) {
let selectorOne = '{unable to calculate}';
let selectorTwo = '{unable to calculate}';
try {
selectorOne = extendsToAdd[0].selfSelectors[0].toCSS();
selectorTwo = extendsToAdd[0].selector.toCSS();
}
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 {
return extendsToAdd;
}
}
visitDeclaration(ruleNode, visitArgs) {
visitArgs.visitDeeper = false;
}
visitMixinDefinition(mixinDefinitionNode, visitArgs) {
visitArgs.visitDeeper = false;
}
visitSelector(selectorNode, visitArgs) {
visitArgs.visitDeeper = false;
}
visitRuleset(rulesetNode, visitArgs) {
if (rulesetNode.root) {
return;
}
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 (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; }
const extendList = selectorPath[selectorPath.length - 1].extendList;
if (extendList && extendList.length) { continue; }
matches = this.findMatch(extend, selectorPath);
if (matches.length) {
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 = paths.concat(selectorsToAdd);
}
findMatch(extend, haystackSelectorPath) {
//
// look through the haystack selector path to try and find the needle - extend.selector
// returns an array of selector matches that can then be replaced
//
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});
}
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
// then each selector in haystackSelectorPath has a space before it added in the toCSS phase. so we need to
// work out what the resulting combinator will be
targetCombinator = haystackElement.combinator.value;
if (targetCombinator === '' && hackstackElementIndex === 0) {
targetCombinator = ' ';
}
// if we don't match, null our match to indicate failure
if (!this.isElementValuesEqual(needleElements[potentialMatch.matched].value, haystackElement.value) ||
(potentialMatch.matched > 0 && needleElements[potentialMatch.matched].combinator.value !== targetCombinator)) {
potentialMatch = null;
} else {
potentialMatch.matched++;
}
// if we are still valid and have finished, test whether we have elements after and whether these are allowed
if (potentialMatch) {
potentialMatch.finished = potentialMatch.matched === needleElements.length;
if (potentialMatch.finished &&
(!extend.allowAfter &&
(hackstackElementIndex + 1 < hackstackSelector.elements.length || haystackSelectorIndex + 1 < haystackSelectorPath.length))) {
potentialMatch = null;
}
}
// if null we remove, if not, we are still valid, so either push as a valid match or continue
if (potentialMatch) {
if (potentialMatch.finished) {
potentialMatch.length = needleElements.length;
potentialMatch.endPathIndex = haystackSelectorIndex;
potentialMatch.endPathElementIndex = hackstackElementIndex + 1; // index after end of match
potentialMatches.length = 0; // we don't allow matches to overlap, so start matching again
matches.push(potentialMatch);
}
} else {
potentialMatches.splice(i, 1);
i--;
}
}
}
}
return matches;
}
isElementValuesEqual(elementValue1, elementValue2) {
if (typeof elementValue1 === 'string' || typeof elementValue2 === 'string') {
return elementValue1 === elementValue2;
}
if (elementValue1 instanceof tree.Attribute) {
if (elementValue1.op !== elementValue2.op || elementValue1.key !== elementValue2.key) {
return false;
}
if (!elementValue1.value || !elementValue2.value) {
if (elementValue1.value || elementValue2.value) {
return false;
}
return true;
}
elementValue1 = elementValue1.value.value || elementValue1.value;
elementValue2 = elementValue2.value.value || elementValue2.value;
return elementValue1 === elementValue2;
}
elementValue1 = elementValue1.value;
elementValue2 = elementValue2.value;
if (elementValue1 instanceof tree.Selector) {
if (!(elementValue2 instanceof tree.Selector) || elementValue1.elements.length !== elementValue2.elements.length) {
return false;
}
for (let i = 0; i < elementValue1.elements.length; i++) {
if (elementValue1.elements[i].combinator.value !== elementValue2.elements[i].combinator.value) {
if (i !== 0 || (elementValue1.elements[i].combinator.value || ' ') !== (elementValue2.elements[i].combinator.value || ' ')) {
return false;
}
}
if (!this.isElementValuesEqual(elementValue1.elements[i].value, elementValue2.elements[i].value)) {
return false;
}
}
return true;
}
return false;
}
extendSelector(matches, selectorPath, replacementSelector, isVisible) {
// for a set of matches, replace each match with the replacement selector
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.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) {
path[path.length - 1].elements = path[path.length - 1]
.elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex));
currentSelectorPathElementIndex = 0;
currentSelectorPathIndex++;
}
newElements = selector.elements
.slice(currentSelectorPathElementIndex, match.index)
.concat([firstElement])
.concat(replacementSelector.elements.slice(1));
if (currentSelectorPathIndex === match.pathIndex && matchIndex > 0) {
path[path.length - 1].elements =
path[path.length - 1].elements.concat(newElements);
} else {
path = path.concat(selectorPath.slice(currentSelectorPathIndex, match.pathIndex));
path.push(new tree.Selector(
newElements
));
}
currentSelectorPathIndex = match.endPathIndex;
currentSelectorPathElementIndex = match.endPathElementIndex;
if (currentSelectorPathElementIndex >= selectorPath[currentSelectorPathIndex].elements.length) {
currentSelectorPathElementIndex = 0;
currentSelectorPathIndex++;
}
}
if (currentSelectorPathIndex < selectorPath.length && currentSelectorPathElementIndex > 0) {
path[path.length - 1].elements = path[path.length - 1]
.elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex));
currentSelectorPathIndex++;
}
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
const derived = currentValue.createDerived(currentValue.elements);
if (isVisible) {
derived.ensureVisibility();
} else {
derived.ensureInvisibility();
}
return derived;
});
return path;
}
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);
}
visitMediaOut(mediaNode) {
const lastIndex = this.allExtendsStack.length - 1;
this.allExtendsStack.length = lastIndex;
}
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);
}
visitAtRuleOut(atRuleNode) {
const lastIndex = this.allExtendsStack.length - 1;
this.allExtendsStack.length = lastIndex;
}
}
export default ProcessExtendsVisitor;
================================================
FILE: packages/less/lib/less/visitors/import-sequencer.js
================================================
class ImportSequencer {
constructor(onSequencerEmpty) {
this.imports = [];
this.variableImports = [];
this._onSequencerEmpty = onSequencerEmpty;
this._currentDepth = 0;
}
addImport(callback) {
const importSequencer = this,
importItem = {
callback,
args: null,
isReady: false
};
this.imports.push(importItem);
return function() {
importItem.args = Array.prototype.slice.call(arguments, 0);
importItem.isReady = true;
importSequencer.tryRun();
};
}
addVariableImport(callback) {
this.variableImports.push(callback);
}
tryRun() {
this._currentDepth++;
try {
while (true) {
while (this.imports.length > 0) {
const importItem = this.imports[0];
if (!importItem.isReady) {
return;
}
this.imports = this.imports.slice(1);
importItem.callback.apply(null, importItem.args);
}
if (this.variableImports.length === 0) {
break;
}
const variableImport = this.variableImports[0];
this.variableImports = this.variableImports.slice(1);
variableImport();
}
} finally {
this._currentDepth--;
}
if (this._currentDepth === 0 && this._onSequencerEmpty) {
this._onSequencerEmpty();
}
}
}
export default ImportSequencer;
================================================
FILE: packages/less/lib/less/visitors/import-visitor.js
================================================
/* eslint-disable no-unused-vars */
/**
* @todo - Remove unused when JSDoc types are added for visitor methods
*/
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.Eval();
this.importCount = 0;
this.onceFileDetectionMap = {};
this.recursionDetector = {};
this._sequencer = new ImportSequencer(this._onSequencerEmpty.bind(this));
};
ImportVisitor.prototype = {
isReplacing: false,
run: function (root) {
try {
// process the contents
this._visitor.visit(root);
}
catch (e) {
this.error = e;
}
this.isFinished = true;
this._sequencer.tryRun();
},
_onSequencerEmpty: function() {
if (!this.isFinished) {
return;
}
this._finish(this.error);
},
visitImport: function (importNode, visitArgs) {
const inlineCSS = importNode.options.inline;
if (!importNode.css || inlineCSS) {
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 {
this.processImportNode(importNode, context, importParent);
}
}
visitArgs.visitDeeper = false;
},
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; }
// attempt to eval properly and treat as css
importNode.css = true;
// if that fails, this error will be thrown
importNode.error = e;
}
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
const tryAppendLessExtension = evaldImportNode.css === undefined;
for (let i = 0; i < importParent.rules.length; i++) {
if (importParent.rules[i] === importNode) {
importParent.rules[i] = evaldImportNode;
break;
}
}
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--;
if (this.isFinished) {
this._sequencer.tryRun();
}
}
},
onImported: function (importNode, context, e, root, importedAtRoot, fullPath) {
if (e) {
if (!e.filename) {
e.index = importNode.getIndex(); e.filename = importNode.fileInfo().filename;
}
this.error = e;
}
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() {
if (fullPath in importVisitor.onceFileDetectionMap) {
return true;
}
importVisitor.onceFileDetectionMap[fullPath] = true;
return false;
};
}
}
if (!fullPath && isOptional) {
importNode.skip = true;
}
if (root) {
importNode.root = root;
importNode.importedFilename = fullPath;
if (!inlineCSS && !isPlugin && (context.importMultiple || !duplicateImport)) {
importVisitor.recursionDetector[fullPath] = true;
const oldContext = this.context;
this.context = context;
try {
this._visitor.visit(root);
} catch (e) {
this.error = e;
}
this.context = oldContext;
}
}
importVisitor.importCount--;
if (importVisitor.isFinished) {
importVisitor._sequencer.tryRun();
}
},
visitDeclaration: function (declNode, visitArgs) {
if (declNode.value.type === 'DetachedRuleset') {
this.context.frames.unshift(declNode);
} else {
visitArgs.visitDeeper = false;
}
},
visitDeclarationOut: function(declNode) {
if (declNode.value.type === 'DetachedRuleset') {
this.context.frames.shift();
}
},
visitAtRule: function (atRuleNode, visitArgs) {
if (atRuleNode.value) {
this.context.frames.unshift(atRuleNode);
} else if (atRuleNode.declarations && atRuleNode.declarations.length) {
if (atRuleNode.isRooted) {
this.context.frames.unshift(atRuleNode);
} else {
this.context.frames.unshift(atRuleNode.declarations[0]);
}
} else if (atRuleNode.rules && atRuleNode.rules.length) {
this.context.frames.unshift(atRuleNode);
}
},
visitAtRuleOut: function (atRuleNode) {
this.context.frames.shift();
},
visitMixinDefinition: function (mixinDefinitionNode, visitArgs) {
this.context.frames.unshift(mixinDefinitionNode);
},
visitMixinDefinitionOut: function (mixinDefinitionNode) {
this.context.frames.shift();
},
visitRuleset: function (rulesetNode, visitArgs) {
this.context.frames.unshift(rulesetNode);
},
visitRulesetOut: function (rulesetNode) {
this.context.frames.shift();
},
visitMedia: function (mediaNode, visitArgs) {
this.context.frames.unshift(mediaNode.rules[0]);
},
visitMediaOut: function (mediaNode) {
this.context.frames.shift();
}
};
export default ImportVisitor;
================================================
FILE: packages/less/lib/less/visitors/index.js
================================================
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
};
================================================
FILE: packages/less/lib/less/visitors/join-selector-visitor.js
================================================
/* eslint-disable no-unused-vars */
/**
* @todo - Remove unused when JSDoc types are added for visitor methods
*/
import Visitor from './visitor.js';
class JoinSelectorVisitor {
constructor() {
this.contexts = [[]];
this._visitor = new Visitor(this);
}
run(root) {
return this._visitor.visit(root);
}
visitDeclaration(declNode, visitArgs) {
visitArgs.visitDeeper = false;
}
visitMixinDefinition(mixinDefinitionNode, visitArgs) {
visitArgs.visitDeeper = false;
}
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(); });
rulesetNode.selectors = selectors.length ? selectors : (selectors = null);
if (selectors) { rulesetNode.joinSelectors(paths, context, selectors); }
}
if (!selectors) { rulesetNode.rules = null; }
rulesetNode.paths = paths;
}
}
visitRulesetOut(rulesetNode) {
this.contexts.length = 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);
}
visitAtRule(atRuleNode, visitArgs) {
const context = this.contexts[this.contexts.length - 1];
if (atRuleNode.declarations && atRuleNode.declarations.length) {
atRuleNode.declarations[0].root = (context.length === 0 || context[0].multiMedia);
}
else if (atRuleNode.rules && atRuleNode.rules.length) {
atRuleNode.rules[0].root = (atRuleNode.isRooted || context.length === 0 || null);
}
}
}
export default JoinSelectorVisitor;
================================================
FILE: packages/less/lib/less/visitors/set-tree-visibility-visitor.js
================================================
import Node from '../tree/node.js';
class SetTreeVisibilityVisitor {
/** @param {boolean} visible */
constructor(visible) {
this.visible = visible;
}
/** @param {Node} root */
run(root) {
this.visit(root);
}
/**
* @param {Node[]} nodes
* @returns {Node[]}
*/
visitArray(nodes) {
if (!nodes) {
return nodes;
}
const cnt = nodes.length;
let i;
for (i = 0; i < cnt; i++) {
this.visit(nodes[i]);
}
return nodes;
}
/**
* @param {*} node
* @returns {*}
*/
visit(node) {
if (!node) {
return node;
}
if (node.constructor === Array) {
return this.visitArray(node);
}
if (!node.blocksVisibility || node.blocksVisibility()) {
return node;
}
if (this.visible) {
node.ensureVisibility();
} else {
node.ensureInvisibility();
}
node.accept(this);
return node;
}
}
export default SetTreeVisibilityVisitor;
================================================
FILE: packages/less/lib/less/visitors/to-css-visitor.js
================================================
/* eslint-disable no-unused-vars */
/**
* @todo - Remove unused when JSDoc types are added for visitor methods
*/
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;
}
containsSilentNonBlockedChild(bodyRules) {
let rule;
if (!bodyRules) {
return false;
}
for (let r = 0; r < bodyRules.length; r++) {
rule = bodyRules[r];
if (rule.isSilent && rule.isSilent(this._context) && !rule.blocksVisibility()) {
// the atrule contains something that was referenced (likely by extend)
// therefore it needs to be shown in output too
return true;
}
}
return false;
}
keepOnlyVisibleChilds(owner) {
if (owner && owner.rules) {
owner.rules = owner.rules.filter(thing => thing.isVisible());
}
}
isEmpty(owner) {
return (owner && owner.rules)
? (owner.rules.length === 0) : true;
}
hasVisibleSelector(rulesetNode) {
return (rulesetNode && rulesetNode.paths)
? (rulesetNode.paths.length > 0) : false;
}
resolveVisibility(node) {
if (!node.blocksVisibility()) {
if (this.isEmpty(node)) {
return ;
}
return node;
}
const compiledRulesBody = node.rules[0];
this.keepOnlyVisibleChilds(compiledRulesBody);
if (this.isEmpty(compiledRulesBody)) {
return ;
}
node.ensureVisibility();
node.removeVisibilityBlock();
return node;
}
isVisibleRuleset(rulesetNode) {
if (rulesetNode.firstRoot) {
return true;
}
if (this.isEmpty(rulesetNode)) {
return false;
}
if (!rulesetNode.root && !this.hasVisibleSelector(rulesetNode)) {
return false;
}
return true;
}
}
const ToCSSVisitor = function(context) {
this._visitor = new Visitor(this);
this._context = context;
this.utils = new CSSVisitorUtils(context);
};
ToCSSVisitor.prototype = {
isReplacing: true,
run: function (root) {
return this._visitor.visit(root);
},
visitDeclaration: function (declNode, visitArgs) {
if (declNode.blocksVisibility() || declNode.variable) {
return;
}
return declNode;
},
visitMixinDefinition: function (mixinNode, visitArgs) {
// mixin definitions do not get eval'd - this means they keep state
// so we have to clear that state here so it isn't used if toCSS is called twice
mixinNode.frames = [];
},
visitExtend: function (extendNode, visitArgs) {
},
visitComment: function (commentNode, visitArgs) {
if (commentNode.blocksVisibility() || commentNode.isSilent(this._context)) {
return;
}
return commentNode;
},
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 importNode;
},
visitAtRule: function(atRuleNode, visitArgs) {
if (atRuleNode.rules && atRuleNode.rules.length) {
return this.visitAtRuleWithBody(atRuleNode, visitArgs);
} else {
return this.visitAtRuleWithoutBody(atRuleNode, visitArgs);
}
},
visitAnonymous: function(anonymousNode, visitArgs) {
if (!anonymousNode.blocksVisibility()) {
anonymousNode.accept(this._visitor);
return anonymousNode;
}
},
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) {
const bodyRules = atRuleNode.rules;
return bodyRules.length === 1 && (!bodyRules[0].paths || bodyRules[0].paths.length === 0);
}
function getBodyRules(atRuleNode) {
const nodeRules = atRuleNode.rules;
if (hasFakeRuleset(atRuleNode)) {
return nodeRules[0].rules;
}
return nodeRules;
}
// it is still true that it is only one ruleset in array
// this is last such moment
// process childs
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) {
if (atRuleNode.blocksVisibility()) {
return;
}
if (atRuleNode.name === '@charset') {
// Only output the debug info together with subsequent @charset definitions
// a comment (or @media statement) before the actual @charset atrule would
// be considered illegal css as it has to be on the first line
if (this.charset) {
if (atRuleNode.debugInfo) {
const comment = new tree.Comment(`/* ${atRuleNode.toCSS(this._context).replace(/\n/g, '')} */\n`);
comment.debugInfo = atRuleNode.debugInfo;
return this._visitor.visit(comment);
}
return;
}
this.charset = true;
}
return atRuleNode;
},
checkValidNodes: function(rules, isRoot) {
if (!rules) {
return;
}
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};
}
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: `${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
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
const nodeRules = rulesetNode.rules;
let nodeRuleCnt = nodeRules ? nodeRules.length : 0;
for (let i = 0; i < nodeRuleCnt; ) {
rule = nodeRules[i];
if (rule && rule.rules) {
// visit because we are moving them out from being a child
rulesets.push(this._visitor.visit(rule));
nodeRules.splice(i, 1);
nodeRuleCnt--;
continue;
}
i++;
}
// accept the visitor to remove rules and refactor itself
// then we can decide nogw whether we want it or not
// compile body
if (nodeRuleCnt > 0) {
rulesetNode.accept(this._visitor);
} else {
rulesetNode.rules = null;
}
visitArgs.visitDeeper = false;
} else { // if (! rulesetNode.root) {
rulesetNode.accept(this._visitor);
visitArgs.visitDeeper = false;
}
if (rulesetNode.rules) {
this._mergeRules(rulesetNode.rules);
this._removeDuplicateRules(rulesetNode.rules);
}
// now decide whether we keep the ruleset
if (this.utils.isVisibleRuleset(rulesetNode)) {
rulesetNode.ensureVisibility();
rulesets.splice(0, 0, rulesetNode);
}
if (rulesets.length === 1) {
return rulesets[0];
}
return rulesets;
},
_compileRulesetPaths: function(rulesetNode) {
if (rulesetNode.paths) {
rulesetNode.paths = rulesetNode.paths
.filter(p => {
let i;
if (p[0].elements[0].combinator.value === ' ') {
p[0].elements[0].combinator = new(tree.Combinator)('');
}
for (i = 0; i < p.length; i++) {
if (p[i].isVisible() && p[i].getIsOutput()) {
return true;
}
}
return false;
});
}
},
_removeDuplicateRules: function(rules) {
if (!rules) { return; }
// remove duplicates
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 {
let ruleList = ruleCache[rule.name];
if (!Array.isArray(ruleList)) {
const prevRuleCSS = ruleList.toCSS(this._context);
ruleList = ruleCache[rule.name] = [prevRuleCSS];
}
const ruleCSS = rule.toCSS(this._context);
if (ruleList.indexOf(ruleCSS) !== -1) {
rules.splice(i, 1);
} else {
ruleList.push(ruleCSS);
}
}
}
}
},
_mergeRules: mergeRules
};
export default ToCSSVisitor;
================================================
FILE: packages/less/lib/less/visitors/visitor.js
================================================
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
let key, child;
for (key in parent) {
/* eslint guard-for-in: 0 */
child = parent[key];
switch (typeof child) {
case 'function':
// ignore bound functions directly on tree which do not have a prototype
// or aren't nodes
if (child.prototype && child.prototype.type) {
child.prototype.typeIndex = ticker++;
}
break;
case 'object':
ticker = indexNodeTypes(child, ticker);
break;
}
}
return ticker;
}
class Visitor {
constructor(implementation) {
this._implementation = implementation;
this._visitInCache = {};
this._visitOutCache = {};
if (!_hasIndexed) {
indexNodeTypes(tree, 1);
_hasIndexed = true;
}
}
visit(node) {
if (!node) {
return node;
}
const nodeTypeIndex = node.typeIndex;
if (!nodeTypeIndex) {
// MixinCall args aren't a node type?
if (node.value && node.value.typeIndex) {
this.visit(node.value);
}
return node;
}
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${node.type}`;
func = impl[fnName] || _noop;
funcOut = impl[`${fnName}Out`] || _noop;
this._visitInCache[nodeTypeIndex] = func;
this._visitOutCache[nodeTypeIndex] = funcOut;
}
if (func !== _noop) {
const newNode = func.call(impl, node, visitArgs);
if (node && impl.isReplacing) {
node = newNode;
}
}
if (visitArgs.visitDeeper && node) {
if (node.length) {
for (let i = 0, cnt = node.length; i < cnt; i++) {
if (node[i].accept) {
node[i].accept(this);
}
}
} else if (node.accept) {
node.accept(this);
}
}
if (funcOut != _noop) {
funcOut.call(impl, node);
}
return node;
}
visitArray(nodes, nonReplacing) {
if (!nodes) {
return nodes;
}
const cnt = nodes.length;
let i;
// Non-replacing
if (nonReplacing || !this._implementation.isReplacing) {
for (i = 0; i < cnt; i++) {
this.visit(nodes[i]);
}
return nodes;
}
// Replacing
const out = [];
for (i = 0; i < cnt; i++) {
const evald = this.visit(nodes[i]);
if (evald === undefined) { continue; }
if (!evald.splice) {
out.push(evald);
} else if (evald.length) {
this.flatten(evald, out);
}
}
return out;
}
flatten(arr, out) {
if (!out) {
out = [];
}
let cnt, i, item, nestedCnt, j, nestedItem;
for (i = 0, cnt = arr.length; i < cnt; i++) {
item = arr[i];
if (item === undefined) {
continue;
}
if (!item.splice) {
out.push(item);
continue;
}
for (j = 0, nestedCnt = item.length; j < nestedCnt; j++) {
nestedItem = item[j];
if (nestedItem === undefined) {
continue;
}
if (!nestedItem.splice) {
out.push(nestedItem);
} else if (nestedItem.length) {
this.flatten(nestedItem, out);
}
}
}
return out;
}
}
export default Visitor;
================================================
FILE: packages/less/lib/less-browser/add-default-options.js
================================================
import {addDataAttr} from './utils.js';
import browser from './browser.js';
/**
* @param {Window} window
* @param {Record} options
*/
export default (window, options) => {
// use options from the current script tag data attribues
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)
//
// This is set to `false` by default, so that the body
// doesn't start loading before the stylesheets are parsed.
// Setting this to `true` can result in flickering.
//
options.async = options.async || false;
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 == 'localhost' ||
(window.location.port &&
window.location.port.length > 0) ||
options.isFileProtocol ? 'development'
: 'production');
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';
}
};
================================================
FILE: packages/less/lib/less-browser/bootstrap.js
================================================
/**
* Kicks off less and compiles any stylesheets
* used in the browser distributed version of less
* to kick-start less using the browser api
*/
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 (const key in window.less) {
if (Object.prototype.hasOwnProperty.call(window.less, key)) {
options[key] = window.less[key];
}
}
}
addDefaultOptions(window, options);
options.plugins = options.plugins || [];
if (window.LESS_PLUGINS) {
options.plugins = options.plugins.concat(window.LESS_PLUGINS);
}
const less = root(window, options);
export default less;
window.less = less;
let css;
let head;
let style;
// Always restore page visibility
function resolveOrReject(data) {
if (data.filename) {
console.warn(data);
}
if (!options.async) {
head.removeChild(style);
}
}
if (options.onReady) {
if (/!watch/.test(window.location.hash)) {
less.watch();
}
// Simulate synchronous stylesheet loading by hiding page rendering
if (!options.async) {
css = 'body { display: none !important }';
head = document.head || document.getElementsByTagName('head')[0];
style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
}
less.registerStylesheetsImmediately();
less.pageLoadFinished = less.refresh(less.env === 'development').then(resolveOrReject, resolveOrReject);
}
================================================
FILE: packages/less/lib/less-browser/browser.js
================================================
import * as utils from './utils.js';
export default {
createCSS: function (document, styles, sheet) {
// Strip the query-string
const href = sheet.href || '';
// If there is no title set, use the filename, minus the extension
const id = `less:${sheet.title || utils.extractId(href)}`;
// If this has already been inserted into the DOM, we may need to replace it
const oldStyleNode = document.getElementById(id);
let keepOldStyleNode = false;
// Create a new stylesheet node for insertion or (if necessary) replacement
const styleNode = document.createElement('style');
styleNode.setAttribute('type', 'text/css');
if (sheet.media) {
styleNode.setAttribute('media', sheet.media);
}
styleNode.id = id;
if (!styleNode.styleSheet) {
styleNode.appendChild(document.createTextNode(styles));
// If new contents match contents of oldStyleNode, don't replace oldStyleNode
keepOldStyleNode = (oldStyleNode !== null && oldStyleNode.childNodes.length > 0 && styleNode.childNodes.length > 0 &&
oldStyleNode.firstChild.nodeValue === styleNode.firstChild.nodeValue);
}
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) {
const nextEl = sheet && sheet.nextSibling || null;
if (nextEl) {
nextEl.parentNode.insertBefore(styleNode, nextEl);
} else {
head.appendChild(styleNode);
}
}
if (oldStyleNode && keepOldStyleNode === false) {
oldStyleNode.parentNode.removeChild(oldStyleNode);
}
// For IE.
// This needs to happen *after* the style element is added to the DOM, otherwise IE 7 and 8 may crash.
// See http://social.msdn.microsoft.com/Forums/en-US/7e081b65-878a-4c22-8e68-c10d39c2ed32/internet-explorer-crashes-appending-style-element-to-head
if (styleNode.styleSheet) {
try {
styleNode.styleSheet.cssText = styles;
} catch (e) {
throw new Error('Couldn\'t reassign styleSheet.cssText.');
}
}
},
currentScript: function(window) {
const document = window.document;
return document.currentScript || (() => {
const scripts = document.getElementsByTagName('script');
return scripts[scripts.length - 1];
})();
}
};
================================================
FILE: packages/less/lib/less-browser/cache.js
================================================
// Cache system is a bit outdated and could do with work
export default (window, options, logger) => {
let cache = null;
if (options.env !== 'development') {
try {
cache = (typeof window.localStorage === 'undefined') ? null : window.localStorage;
} catch (_) {}
}
return {
setCSS: function(path, lastModified, modifyVars, styles) {
if (cache) {
logger.info(`saving ${path} to cache.`);
try {
cache.setItem(path, styles);
cache.setItem(`${path}:timestamp`, lastModified);
if (modifyVars) {
cache.setItem(`${path}:vars`, JSON.stringify(modifyVars));
}
} catch (e) {
// TODO - could do with adding more robust error handling
logger.error(`failed to save "${path}" to local storage for caching.`);
}
}
},
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 &&
(new Date(webInfo.lastModified).valueOf() ===
new Date(timestamp).valueOf()) &&
JSON.stringify(modifyVars) === vars) {
// Use local copy
return css;
}
}
};
};
================================================
FILE: packages/less/lib/less-browser/error-reporting.js
================================================
import * as utils from './utils.js';
import browser from './browser.js';
export default (window, less, options) => {
function errorHTML(e, rootHref) {
const id = `less-error-message:${utils.extractId(rootHref || '')}`;
const template = '{line} {content} ';
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 = `${e.type || 'Syntax'}Error: ${e.message || 'There is an error in your .less file'}` +
` in ${filenameNoPath} `;
const errorline = (e, i, classname) => {
if (e.extract[i] !== undefined) {
errors.push(template.replace(/\{line\}/, (parseInt(e.line, 10) || 0) + (i - 1))
.replace(/\{class\}/, classname)
.replace(/\{content\}/, e.extract[i]));
}
};
if (e.line) {
errorline(e, 0, '');
errorline(e, 1, 'line');
errorline(e, 2, '');
content += `on line ${e.line}, column ${e.column + 1}:
`;
}
if (e.stack && (e.extract || options.logLevel >= 4)) {
content += ` Stack Trace${e.stack.split('\n').slice(1).join(' ')}`;
}
elem.innerHTML = content;
// CSS for error messages
browser.createCSS(window.document, [
'.less-error-message ul, .less-error-message li {',
'list-style-type: none;',
'margin-right: 15px;',
'padding: 4px 0;',
'margin: 0;',
'}',
'.less-error-message label {',
'font-size: 12px;',
'margin-right: 15px;',
'padding: 4px 0;',
'color: #cc7777;',
'}',
'.less-error-message pre {',
'color: #dd6666;',
'padding: 4px 0;',
'margin: 0;',
'display: inline-block;',
'}',
'.less-error-message pre.line {',
'color: #ff0000;',
'}',
'.less-error-message h3 {',
'font-size: 20px;',
'font-weight: bold;',
'padding: 15px 0 5px 0;',
'margin: 0;',
'}',
'.less-error-message a {',
'color: #10a',
'}',
'.less-error-message .error {',
'color: red;',
'font-weight: bold;',
'padding-bottom: 2px;',
'border-bottom: 1px dashed red;',
'}'
].join('\n'), { title: 'error-message' });
elem.style.cssText = [
'font-family: Arial, sans-serif',
'border: 1px solid #e00',
'background-color: #eee',
'border-radius: 5px',
'-webkit-border-radius: 5px',
'-moz-border-radius: 5px',
'color: #e00',
'padding: 15px',
'margin-bottom: 15px'
].join(';');
if (options.env === 'development') {
timer = setInterval(() => {
const document = window.document;
const body = document.body;
if (body) {
if (document.getElementById(id)) {
body.replaceChild(elem, document.getElementById(id));
} else {
body.insertBefore(elem, body.firstChild);
}
clearInterval(timer);
}
}, 10);
}
}
function removeErrorHTML(path) {
const node = window.document.getElementById(`less-error-message:${utils.extractId(path)}`);
if (node) {
node.parentNode.removeChild(node);
}
}
function removeErrorConsole() {
// no action
}
function removeError(path) {
if (!options.errorReporting || options.errorReporting === 'html') {
removeErrorHTML(path);
} else if (options.errorReporting === 'console') {
removeErrorConsole(path);
} else if (typeof options.errorReporting === 'function') {
options.errorReporting('remove', path);
}
}
function errorConsole(e, rootHref) {
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) {
errors.push(template.replace(/\{line\}/, (parseInt(e.line, 10) || 0) + (i - 1))
.replace(/\{class\}/, classname)
.replace(/\{content\}/, e.extract[i]));
}
};
if (e.line) {
errorline(e, 0, '');
errorline(e, 1, 'line');
errorline(e, 2, '');
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${e.stack}`;
}
less.logger.error(content);
}
function error(e, rootHref) {
if (!options.errorReporting || options.errorReporting === 'html') {
errorHTML(e, rootHref);
} else if (options.errorReporting === 'console') {
errorConsole(e, rootHref);
} else if (typeof options.errorReporting === 'function') {
options.errorReporting('add', e, rootHref);
}
}
return {
add: error,
remove: removeError
};
};
================================================
FILE: packages/less/lib/less-browser/file-manager.js
================================================
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
const FileManager = function() {}
FileManager.prototype = Object.assign(new AbstractFileManager(), {
alwaysMakePathsAbsolute() {
return true;
},
join(basePath, laterPath) {
if (!basePath) {
return laterPath;
}
return this.extractUrlParts(laterPath, basePath).path;
},
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 '${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') {
errback(xhr.status, url);
}
}
if (options.isFileProtocol && !options.fileAsync) {
if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 300)) {
callback(xhr.responseText);
} else {
errback(xhr.status, url);
}
} else if (async) {
xhr.onreadystatechange = () => {
if (xhr.readyState == 4) {
handleResponse(xhr, callback, errback);
}
};
} else {
handleResponse(xhr, callback, errback);
}
},
supports() {
return true;
},
clearFileCache() {
fileCache = {};
},
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
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 {
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}` });
}
}
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 }});
}, function doXHRError(status, url) {
reject({ type: 'File', message: `'${url}' wasn't found (${status})`, href });
});
});
}
});
export default (opts, log) => {
options = opts;
logger = log;
return FileManager;
}
================================================
FILE: packages/less/lib/less-browser/image-size.js
================================================
import functionRegistry from './../less/functions/function-registry.js';
export default () => {
function imageSize() {
throw {
type: 'Runtime',
message: 'Image size functions are not supported in browser version of less'
};
}
const imageFunctions = {
'image-size': function(filePathNode) {
imageSize(this, filePathNode);
return -1;
},
'image-width': function(filePathNode) {
imageSize(this, filePathNode);
return -1;
},
'image-height': function(filePathNode) {
imageSize(this, filePathNode);
return -1;
}
};
functionRegistry.addMultiple(imageFunctions);
};
================================================
FILE: packages/less/lib/less-browser/index.js
================================================
//
// index.js
// Should expose the additional browser functions on to the less object
//
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;
const environment = less.environment;
const FileManager = FM(options, less.logger);
const fileManager = new FileManager();
environment.addFileManager(fileManager);
less.FileManager = FileManager;
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?
if (options.functions) {
less.functions.functionRegistry.addMultiple(options.functions);
}
const typePattern = /^text\/(x-)?less$/;
function clone(obj) {
const cloned = {};
for (const prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
cloned[prop] = obj[prop];
}
}
return cloned;
}
function loadStyles(modifyVars) {
const styles = document.getElementsByTagName('style');
for (let style of styles) {
if (style.type.match(typePattern)) {
const instanceOptions = {
...clone(options),
modifyVars,
filename: document.location.href.replace(/#.*$/, '')
}
const lessText = style.innerHTML || '';
/* jshint loopfunc:true */
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 {
style.innerHTML = result.css;
}
}
});
}
}
}
function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) {
const instanceOptions = clone(options);
addDataAttr(instanceOptions, sheet);
instanceOptions.mime = sheet.type;
if (modifyVars) {
instanceOptions.modifyVars = modifyVars;
}
function loadInitialFileCallback(loadedFile) {
const data = loadedFile.contents;
const path = loadedFile.filename;
const webInfo = loadedFile.webInfo;
const newFileInfo = {
currentDirectory: fileManager.getPath(path),
filename: path,
rootFilename: path,
rewriteUrls: instanceOptions.rewriteUrls
};
newFileInfo.entryPath = newFileInfo.currentDirectory;
newFileInfo.rootpath = instanceOptions.rootpath || newFileInfo.currentDirectory;
if (webInfo) {
webInfo.remaining = remaining;
const css = cache.getCSS(path, webInfo, instanceOptions.modifyVars);
if (!reload && css) {
webInfo.local = true;
callback(null, css, data, sheet, webInfo, path);
return;
}
}
// TODO add tests around how this behaves when reloading
errors.remove(path);
instanceOptions.rootFileInfo = newFileInfo;
less.render(data, instanceOptions, (e, result) => {
if (e) {
e.href = path;
callback(e);
} else {
cache.setCSS(sheet.href, webInfo.lastModified, instanceOptions.modifyVars, result.css);
callback(null, result.css, data, sheet, webInfo, path);
}
});
}
fileManager.loadFile(sheet.href, null, instanceOptions, environment)
.then(loadedFile => {
loadInitialFileCallback(loadedFile);
}).catch(err => {
console.log(err);
callback(err);
});
}
function loadStyleSheets(callback, reload, modifyVars) {
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(() => {
if (less.watchMode) {
fileManager.clearFileCache();
/**
* @todo remove when this is typed with JSDoc
*/
// eslint-disable-next-line no-unused-vars
loadStyleSheets((e, css, _, sheet, webInfo) => {
if (e) {
errors.add(e, e.href || sheet.href);
} else if (css) {
browser.createCSS(window.document, css, sheet);
}
});
}
}, options.poll);
}
}
//
// Watch mode
//
less.watch = function () {
if (!less.watchMode ) {
less.env = 'development';
initRunningMode();
}
this.watchMode = true;
return true;
};
less.unwatch = function () {clearInterval(less.watchTimer); this.watchMode = false; return false; };
//
// Synchronously get all tags with the 'rel' attribute set to
// "stylesheet/less".
//
less.registerStylesheetsImmediately = () => {
const links = document.getElementsByTagName('link');
less.sheets = [];
for (let i = 0; i < links.length; i++) {
if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&
(links[i].type.match(typePattern)))) {
less.sheets.push(links[i]);
}
}
};
//
// Asynchronously get all tags with the 'rel' attribute set to
// "stylesheet/less", returning a Promise.
//
less.registerStylesheets = () => new Promise((resolve) => {
less.registerStylesheetsImmediately();
resolve();
});
//
// With this function, it's possible to alter variables and re-render
// CSS without reloading less-files
//
less.modifyVars = record => less.refresh(true, record, false);
less.refresh = (reload, modifyVars, clearFileCache) => {
if ((reload || clearFileCache) && clearFileCache !== false) {
fileManager.clearFileCache();
}
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();
totalMilliseconds = endTime - startTime;
less.logger.info('Less has finished and no sheets were loaded.');
resolve({
startTime,
endTime,
totalMilliseconds,
sheets: less.sheets.length
});
} else {
// Relies on less.sheets array, callback seems to be guaranteed to be called for every element of the array
loadStyleSheets((e, css, _, sheet, webInfo) => {
if (e) {
errors.add(e, e.href || sheet.href);
reject(e);
return;
}
if (webInfo.local) {
less.logger.info(`Loading ${sheet.href} from cache.`);
} else {
less.logger.info(`Rendered ${sheet.href} successfully.`);
}
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 ${totalMilliseconds}ms`);
resolve({
startTime,
endTime,
totalMilliseconds,
sheets: less.sheets.length
});
}
endTime = new Date();
}, reload, modifyVars);
}
loadStyles(modifyVars);
});
};
less.refreshStyles = loadStyles;
return less;
};
================================================
FILE: packages/less/lib/less-browser/log-listener.js
================================================
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.
// 3 - Debug, information and errors
// 2 - Information and errors
// 1 - Errors
// 0 - None
// Defaults to 2
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);
}
}
}];
}
for (let i = 0; i < options.loggers.length; i++) {
less.logger.addListener(options.loggers[i]);
}
};
================================================
FILE: packages/less/lib/less-browser/plugin-loader.js
================================================
/**
* @todo Add tests for browser `@plugin`
*/
import AbstractPluginLoader from '../less/environment/abstract-plugin-loader.js';
/**
* Browser Plugin Loader
*/
const PluginLoader = function(less) {
this.less = less;
// Should we shim this.require for browser? Probably not?
};
PluginLoader.prototype = Object.assign(new AbstractPluginLoader(), {
loadPlugin(filename, basePath, context, environment, fileManager) {
return new Promise((fulfill, reject) => {
fileManager.loadFile(filename, basePath, context, environment)
.then(fulfill).catch(reject);
});
}
});
export default PluginLoader;
================================================
FILE: packages/less/lib/less-browser/utils.js
================================================
/** @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)
}
/**
* @param {Record} 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 {
try {
options[opt] = JSON.parse(tag.dataset[opt]);
}
catch (_) {}
}
}
}
}
================================================
FILE: packages/less/lib/less-node/environment.js
================================================
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.
const buffer = (Buffer.from ? Buffer.from(str) : (new Buffer(str)));
return buffer.toString('base64');
},
mimeLookup: function (filename) {
try {
const mimeModule = require('mime');
return mimeModule ? mimeModule.lookup(filename) : "application/octet-stream";
} catch (e) {
return "application/octet-stream";
}
},
charsetLookup: function (mime) {
try {
const mimeModule = require('mime');
return mimeModule ? mimeModule.charsets.lookup(mime) : undefined;
} catch (e) {
return undefined;
}
},
getSourceMapGenerator: function getSourceMapGenerator() {
try {
const sourceMapModule = require('source-map');
return sourceMapModule ? sourceMapModule.SourceMapGenerator : SourceMapGeneratorFallback;
} catch (e) {
return SourceMapGeneratorFallback;
}
}
};
================================================
FILE: packages/less/lib/less-node/file-manager.js
================================================
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() {
return true;
},
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 || {};
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) {
getFileData(returnData, returnData);
if (callback) {
callback(result.error, result);
}
else {
return result;
}
}
else {
// promise is guaranteed to be asyncronous
// which helps as it allows the file handle
// to be closed before it continues with the next file
return new Promise(getFileData);
}
function returnData(data) {
if (!data.filename) {
result = { error: data };
}
else {
result = data;
}
}
function getFileData(fulfill, reject) {
(function tryPathIndex(i) {
function tryWithExtension() {
const extFilename = options.ext ? self.tryAppendExtension(fullFilename, options.ext) : fullFilename;
if (extFilename !== fullFilename && !explicit && paths[i] === '.') {
try {
fullFilename = require.resolve(extFilename);
isNodeModule = true;
}
catch (e) {
filenamesTried.push(npmPrefix + extFilename);
fullFilename = extFilename;
}
}
else {
fullFilename = extFilename;
}
}
if (i < paths.length) {
(function tryPrefix(j) {
if (j < prefixes.length) {
isNodeModule = false;
fullFilename = fileParts.rawPath + prefixes[j] + fileParts.filename;
if (paths[i]) {
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] === '.') {
try {
fullFilename = require.resolve(fullFilename);
isNodeModule = true;
}
catch (e) {
filenamesTried.push(npmPrefix + fullFilename);
tryWithExtension();
}
}
else {
tryWithExtension();
}
const readFileArgs = [fullFilename];
if (!options.rawBuffer) {
readFileArgs.push('utf-8');
}
if (options.syncImport) {
try {
const data = fs.readFileSync.apply(this, readFileArgs);
fulfill({ contents: data, filename: fullFilename});
}
catch (e) {
filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);
return tryPrefix(j + 1);
}
}
else {
readFileArgs.push(function(e, data) {
if (e) {
filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);
return tryPrefix(j + 1);
}
fulfill({ contents: data, filename: fullFilename});
});
fs.readFile.apply(this, readFileArgs);
}
}
else {
tryPathIndex(i + 1);
}
})(0);
} else {
reject({ type: 'File', message: `'${filename}' wasn't found. Tried - ${filenamesTried.join(',')}` });
}
}(0));
}
},
loadFileSync(filename, currentDirectory, options, environment) {
options.syncImport = true;
return this.loadFile(filename, currentDirectory, options, environment);
}
});
export default FileManager;
================================================
FILE: packages/less/lib/less-node/fs.js
================================================
/** @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;
}
export default fs;
================================================
FILE: packages/less/lib/less-node/image-size.js
================================================
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) {
let filePath = filePathNode.value;
const currentFileInfo = functionContext.currentFileInfo;
const currentDirectory = currentFileInfo.rewriteUrls ?
currentFileInfo.currentDirectory : currentFileInfo.entryPath;
const fragmentStart = filePath.indexOf('#');
if (fragmentStart !== -1) {
filePath = filePath.slice(0, fragmentStart);
}
const fileManager = environment.getFileManager(filePath, currentDirectory, functionContext.context, environment, true);
if (!fileManager) {
throw {
type: 'File',
message: `Can not set up FileManager for ${filePathNode}`
};
}
const fileSync = fileManager.loadFileSync(filePath, currentDirectory, functionContext.context, environment);
if (fileSync.error) {
throw fileSync.error;
}
const sizeOf = require('image-size');
return sizeOf ? sizeOf(fileSync.filename) : {width: 0, height: 0};
}
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) {
const size = imageSize(this, filePathNode);
return new Dimension(size.width, 'px');
},
'image-height': function(filePathNode) {
const size = imageSize(this, filePathNode);
return new Dimension(size.height, 'px');
}
};
functionRegistry.addMultiple(imageFunctions);
};
================================================
FILE: packages/less/lib/less-node/index.js
================================================
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 = createFromEnvironment;
less.lesscHelper = lesscHelper;
less.PluginLoader = PluginLoader;
less.fs = fs;
less.FileManager = FileManager;
less.UrlFileManager = UrlFileManager;
// Set up options
less.options = defaultOptions();
// provide image-size functionality
imageSize(less.environment);
export default less;
================================================
FILE: packages/less/lib/less-node/lessc-helper.js
================================================
// lessc_helper.js
//
// helper functions for lessc
const lessc_helper = {
// Stylize a string
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 `\x1b[${styles[style][0]}m${str}\x1b[${styles[style][1]}m`;
},
// Print command line options
printUsage: function() {
console.log('usage: lessc [option option=parameter ...] [destination]');
console.log('');
console.log('If source is set to `-\' (dash or hyphen-minus), input is read from stdin.');
console.log('');
console.log('options:');
console.log(' -h, --help Prints help (this message) and exit.');
console.log(' --include-path=PATHS Sets include paths. Separated by `:\'. `;\' also supported on windows.');
console.log(' -M, --depends Outputs a makefile import dependency list to stdout.');
console.log(' --no-color Disables colorized output.');
console.log(' --ie-compat Enables IE8 compatibility checks.');
console.log(' --js Enables inline JavaScript in less files');
console.log(' -l, --lint Syntax check only (lint).');
console.log(' -s, --silent Suppresses output of error messages.');
console.log(' --quiet Suppresses output of warnings.');
console.log(' --strict-imports (DEPRECATED) Ignores .less imports inside selector blocks. Has confusing behavior.');
console.log(' --insecure Allows imports from insecure https hosts.');
console.log(' -v, --version Prints version number and exit.');
console.log(' --verbose Be verbose.');
console.log(' --source-map[=FILENAME] Outputs a v3 sourcemap to the filename (or output filename.map).');
console.log(' --source-map-rootpath=X Adds this path onto the sourcemap filename and less file paths.');
console.log(' --source-map-basepath=X Sets sourcemap base path, defaults to current working directory.');
console.log(' --source-map-include-source Puts the less files into the map instead of referencing them.');
console.log(' --source-map-inline Puts the map (and any less files) as a base64 data uri into the output css file.');
console.log(' --source-map-url=URL Sets a custom URL to map file, for sourceMappingURL comment');
console.log(' in generated CSS file.');
console.log(' --source-map-no-annotation Excludes the sourceMappingURL comment from the output css file.');
console.log(' -rp, --rootpath=URL Sets rootpath for url rewriting in relative imports and urls');
console.log(' Works with or without the relative-urls option.');
console.log(' -ru=, --rewrite-urls= Rewrites URLs to make them relative to the base less file.');
console.log(' all|local|off \'all\' rewrites all URLs, \'local\' just those starting with a \'.\'');
console.log('');
console.log(' -m=, --math=');
console.log(' always Less will eagerly perform math operations always.');
console.log(' parens-division Math performed except for division (/) operator');
console.log(' parens | strict Math only performed inside parentheses');
console.log(' strict-legacy Parens required in very strict terms (legacy --strict-math)');
console.log('');
console.log(' -su=on|off Allows mixed units, e.g. 1px+1em or 1px*1px which have units');
console.log(' --strict-units=on|off that cannot be represented.');
console.log(' --global-var=\'VAR=VALUE\' Defines a variable that can be referenced by the file.');
console.log(' --modify-var=\'VAR=VALUE\' Modifies a variable already declared in the file.');
console.log(' --url-args=\'QUERYSTRING\' Adds params into url tokens (e.g. 42, cb=42 or \'a=1&b=2\')');
console.log(' --plugin=PLUGIN=OPTIONS Loads a plugin. You can also omit the --plugin= if the plugin begins');
console.log(' less-plugin. E.g. the clean css plugin is called less-plugin-clean-css');
console.log(' once installed (npm install less-plugin-clean-css), use either with');
console.log(' --plugin=less-plugin-clean-css or just --clean-css');
console.log(' specify options afterwards e.g. --plugin=less-plugin-clean-css="advanced"');
console.log(' or --clean-css="advanced"');
console.log(' --disable-plugin-rule Disallow @plugin statements');
console.log('');
console.log(' --quiet-deprecations Suppress deprecation warnings only (keeps other warnings).');
console.log('');
console.log('-------------------------- Deprecated ----------------');
console.log(' -sm=on|off Legacy parens-only math. Use --math');
console.log(' --strict-math=on|off ');
console.log('');
console.log(' --line-numbers=TYPE (DEPRECATED) Outputs filename and line numbers.');
console.log(' TYPE can be either \'comments\', \'mediaquery\', or \'all\'.');
console.log(' The entire dumpLineNumbers option is deprecated.');
console.log(' Use sourcemaps (--source-map) instead.');
console.log(' All modes will be removed in a future version.');
console.log(' Note: \'mediaquery\' and \'all\' modes generate @media -sass-debug-info');
console.log(' which had short-lived usage and is no longer recommended.');
console.log(' -x, --compress Compresses output by removing some whitespaces.');
console.log(' We recommend you use a dedicated minifer like less-plugin-clean-css');
console.log('');
console.log('Report bugs to: http://github.com/less/less.js/issues');
console.log('Home page: ');
}
};
export const { stylize, printUsage } = lessc_helper;
export default lessc_helper;
================================================
FILE: packages/less/lib/less-node/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
*/
const PluginLoader = function(less) {
this.less = less;
this.require = prefix => {
prefix = path.dirname(prefix);
return id => {
const str = id.slice(0, 2);
if (str === '..' || str === './') {
return require(path.join(prefix, id));
}
else {
return require(id);
}
};
};
};
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((fulfill, reject) => {
fileManager.loadFile(filename, basePath, context, environment).then(
data => {
try {
fulfill(data);
}
catch (e) {
console.log(e);
reject(e);
}
}
).catch(err => {
reject(err);
});
});
},
loadPluginSync(filename, basePath, context, environment, fileManager) {
context.syncImport = true;
return this.loadPlugin(filename, basePath, context, environment, fileManager);
}
});
export default PluginLoader;
================================================
FILE: packages/less/lib/less-node/url-file-manager.js
================================================
/* eslint-disable no-unused-vars */
/**
* @todo - remove top eslint rule when FileManagers have JSDoc type
* and are TS-type-checked
*/
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(filename, currentDirectory, options, environment) {
return new Promise((fulfill, reject) => {
if (request === undefined) {
try { request = require('needle'); }
catch (e) { request = null; }
}
if (!request) {
reject({ type: 'File', message: 'optional dependency \'needle\' required to import over http(s)\n' });
return;
}
let urlStr = isUrlRe.test( filename ) ? filename : url.resolve(currentDirectory, filename);
/** native-request currently has a bug */
const hackUrlStr = urlStr.indexOf('?') === -1 ? urlStr + '?' : urlStr
request.get(hackUrlStr, { follow_max: 5 }, (err, resp, body) => {
if (err || resp && resp.statusCode >= 400) {
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 '${urlStr}' caused too many redirects` });
return;
}
body = body.toString('utf8');
if (!body) {
logger.warn(`Warning: Empty body (HTTP ${resp.statusCode}) returned by "${urlStr}"`);
}
fulfill({ contents: body || '', filename: urlStr });
});
});
}
});
export default UrlFileManager;
================================================
FILE: packages/less/package.json
================================================
{
"name": "less",
"version": "4.6.3",
"description": "Leaner CSS",
"homepage": "http://lesscss.org",
"author": {
"name": "Alexis Sellier",
"email": "self@cloudhead.net"
},
"contributors": [
"The Core Less Team"
],
"bugs": {
"url": "https://github.com/less/less.js/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/less/less.js.git"
},
"master": {
"url": "https://github.com/less/less.js/blob/master/",
"raw": "https://raw.githubusercontent.com/less/less.js/master/"
},
"license": "Apache-2.0",
"type": "module",
"bin": {
"lessc": "./bin/lessc"
},
"main": "./dist/less-node.cjs",
"exports": {
".": {
"browser": "./dist/less.js",
"import": "./lib/less-node/index.js",
"require": "./dist/less-node.cjs",
"default": "./lib/less-node/index.js"
},
"./lib/*": "./lib/*",
"./dist/less-node.cjs": "./dist/less-node.cjs",
"./dist/less.js": "./dist/less.js",
"./dist/less.min.js": "./dist/less.min.js"
},
"directories": {
"test": "./test"
},
"files": [
"bin",
"lib",
"!lib/**/*.map",
"dist",
"index.cjs",
"README.md"
],
"browser": "./dist/less.js",
"engines": {
"node": ">=18"
},
"scripts": {
"quicktest": "grunt quicktest",
"test": "grunt test",
"test:node": "grunt test:node",
"test:coverage": "c8 -r lcov -r json-summary -r text-summary -r html --include=\"lib/**/*.js\" --include=\"bin/**/*.js\" --exclude=\"dist/**\" --exclude=\"**/*.test.js\" --exclude=\"**/*.spec.js\" --exclude=\"test/**\" --exclude=\"tmp/**\" --exclude=\"**/abstract-file-manager.js\" --exclude=\"**/abstract-plugin-loader.js\" grunt shell:test && node scripts/coverage-report.js && node scripts/coverage-lines.js",
"grunt": "grunt",
"lint": "eslint '**/*.{ts,js}'",
"lint:fix": "eslint '**/*.{ts,js}' --fix",
"typecheck": "tsc --noEmit",
"build": "node build/rollup.js --dist",
"prepublishOnly": "npm run typecheck && grunt dist && grunt test:node"
},
"optionalDependencies": {
"errno": "^0.1.1",
"graceful-fs": "^4.1.2",
"image-size": "~0.5.0",
"make-dir": "^5.1.0",
"mime": "^1.4.1",
"needle": "^3.1.0",
"source-map": "~0.6.0"
},
"devDependencies": {
"@less/test-data": "workspace:*",
"@less/test-import-module": "workspace:*",
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.0.0",
"@types/node": "^18",
"@typescript-eslint/eslint-plugin": "^4.28.0",
"@typescript-eslint/parser": "^4.28.0",
"benny": "^3.6.12",
"bootstrap-less-port": "0.3.0",
"c8": "^10.1.3",
"chai": "^4.2.0",
"chalk": "^4.1.2",
"cosmiconfig": "~9.0.0",
"cross-env": "^7.0.3",
"eslint": "^7.29.0",
"fs-extra": "^8.1.0",
"git-rev": "^0.2.1",
"glob": "~11.0.3",
"globby": "^10.0.1",
"grunt": "^1.5.0",
"grunt-cli": "^1.3.2",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-connect": "^1.0.2",
"grunt-eslint": "^23.0.0",
"grunt-saucelabs": "^9.0.1",
"grunt-shell": "^1.3.0",
"html-template-tag": "^3.2.0",
"jest-diff": "~30.1.2",
"jit-grunt": "^0.10.0",
"less-plugin-autoprefix": "^1.5.1",
"less-plugin-clean-css": "^1.6.0",
"minimist": "^1.2.0",
"mocha": "^6.2.1",
"mocha-teamcity-reporter": "^3.0.0",
"npm-run-all": "^4.1.5",
"performance-now": "^0.2.0",
"phin": "^2.2.3",
"playwright": "1.50.1",
"promise": "^7.1.1",
"read-glob": "^3.0.0",
"resolve": "^1.17.0",
"rollup": "^2.52.2",
"rollup-plugin-terser": "^5.1.1",
"semver": "^6.3.0",
"shx": "^0.3.2",
"time-grunt": "^1.3.0",
"typescript": "^5.7.0",
"uikit": "2.27.4",
"url": "^0.11.4",
"path-browserify": "^1.0.1",
"webpack": "^5.64.6",
"webpack-cli": "^5.1.4"
},
"keywords": [
"compile less",
"css nesting",
"css variable",
"css",
"gradients css",
"gradients css3",
"less compiler",
"less css",
"less mixins",
"less",
"less.js",
"lesscss",
"mixins",
"nested css",
"parser",
"preprocessor",
"bootstrap css",
"bootstrap less",
"style",
"styles",
"stylesheet",
"variables in css",
"css less"
],
"rawcurrent": "https://raw.github.com/less/less.js/v",
"sourcearchive": "https://github.com/less/less.js/archive/v",
"dependencies": {
"copy-anything": "^3.0.5",
"parse-node-version": "^1.0.1"
},
"gitHead": "1df9072ee9ebdadc791bf35dfb1dbc3ef9f1948f"
}
================================================
FILE: packages/less/scripts/coverage-lines.js
================================================
#!/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
*/
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
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 lib/ 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('lib/less/') && !normalized.includes('lib/less-browser/')) ||
normalized.includes('lib/less-node/') ||
normalized.includes('bin/'))) {
// Extract relative path - match lib/less/... or lib/less-node/... or bin/...
// Path format: lib/less/tree/debug-info.js or lib/less-node/file-manager.js
// Match from lib/ or bin/ to end of path
const match = normalized.match(/(lib\/[^/]+\/.+|bin\/.+)$/);
const relativePath = match ? match[1] : (normalized.includes('/lib/') || 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, 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 lib/less/, lib/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');
================================================
FILE: packages/less/scripts/coverage-report.js
================================================
#!/usr/bin/env node
/**
* Generates a per-file coverage report table for lib/ directories
*/
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
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 lib/ files (less, less-node) and bin/ files
// Note: lib/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('/lib/less/') && !normalized.includes('/lib/less-browser/')) ||
normalized.includes('/lib/less-node/') ||
normalized.includes('/bin/');
})
.map(([filePath, data]) => {
// Extract relative path from absolute path
const normalized = filePath.replace(/\\/g, '/');
// Match lib/ paths or bin/ paths
const match = normalized.match(/((?:lib\/[^/]+\/[^/]+\/|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 lib/ files found in coverage report.');
process.exit(0);
}
// Group by directory
const grouped = {
'lib/less/': [],
'lib/less-node/': [],
'bin/': []
};
srcFiles.forEach(file => {
if (file.path.startsWith('lib/less/')) {
grouped['lib/less/'].push(file);
} else if (file.path.startsWith('lib/less-node/')) {
grouped['lib/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 (lib/less/, lib/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');
================================================
FILE: packages/less/scripts/postinstall.js
================================================
#!/usr/bin/env node
import fs from 'fs';
import path from 'path';
import { execSync } from 'child_process';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
function isDevelopmentEnvironment() {
if (process.env.npm_config_user_config || process.env.npm_config_global) {
return false;
}
if (process.env.CI || process.env.GITHUB_ACTIONS || process.env.TRAVIS) {
return false;
}
const parentPackageJson = path.join(__dirname, '../../../package.json');
if (!fs.existsSync(parentPackageJson)) {
return false;
}
const currentPackageJson = path.join(__dirname, '../package.json');
if (!fs.existsSync(currentPackageJson)) {
return false;
}
return true;
}
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');
}
}
if (isDevelopmentEnvironment()) {
installPlaywrightBrowsers();
}
================================================
FILE: packages/less/test/.eslintrc.json
================================================
{
"env": {
"node": true,
"browser": true
},
"parserOptions": {
"ecmaVersion": 6
}
}
================================================
FILE: packages/less/test/README.md
================================================
Tests are generally organized in the `less/` folder by what options are set in index.js.
The main tests are located under `less/_main/`
================================================
FILE: packages/less/test/browser/common.js
================================================
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(/