less 2.3.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/workspace.xml +277 -237
- package/.jscsrc +36 -1
- package/.travis.yml +1 -0
- package/CHANGELOG.md +14 -0
- package/Gruntfile.js +1 -1
- package/appveyor.yml +5 -0
- package/bin/lessc +8 -5
- package/bower.json +1 -1
- package/dist/less.js +909 -814
- package/dist/less.min.js +6 -6
- package/lib/less/contexts.js +2 -2
- package/lib/less/environment/abstract-file-manager.js +6 -6
- package/lib/less/environment/environment.js +2 -2
- package/lib/less/functions/color.js +13 -5
- package/lib/less/functions/math.js +1 -1
- package/lib/less/functions/number.js +2 -2
- package/lib/less/functions/types.js +18 -8
- package/lib/less/import-manager.js +5 -5
- package/lib/less/index.js +1 -1
- package/lib/less/less-error.js +1 -1
- package/lib/less/logger.js +2 -2
- package/lib/less/parse-tree.js +45 -45
- package/lib/less/parse.js +5 -2
- package/lib/less/parser/parser-input.js +3 -3
- package/lib/less/parser/parser.js +52 -18
- package/lib/less/plugin-manager.js +30 -3
- package/lib/less/render.js +5 -2
- package/lib/less/source-map-builder.js +4 -0
- package/lib/less/source-map-output.js +3 -3
- package/lib/less/transform-tree.js +4 -4
- package/lib/less/tree/anonymous.js +1 -1
- package/lib/less/tree/call.js +1 -1
- package/lib/less/tree/color.js +2 -2
- package/lib/less/tree/condition.js +8 -4
- package/lib/less/tree/dimension.js +4 -4
- package/lib/less/tree/element.js +1 -1
- package/lib/less/tree/expression.js +1 -1
- package/lib/less/tree/extend.js +3 -3
- package/lib/less/tree/javascript.js +2 -2
- package/lib/less/tree/media.js +20 -20
- package/lib/less/tree/mixin-call.js +2 -2
- package/lib/less/tree/mixin-definition.js +29 -8
- package/lib/less/tree/quoted.js +3 -3
- package/lib/less/tree/rule.js +1 -1
- package/lib/less/tree/ruleset.js +35 -28
- package/lib/less/tree/selector.js +1 -1
- package/lib/less/tree/unit.js +2 -0
- package/lib/less/tree/value.js +1 -1
- package/lib/less/visitors/extend-visitor.js +15 -14
- package/lib/less/visitors/import-sequencer.js +2 -2
- package/lib/less/visitors/import-visitor.js +2 -2
- package/lib/less/visitors/to-css-visitor.js +5 -5
- package/lib/less-browser/cache.js +2 -2
- package/lib/less-browser/file-manager.js +96 -96
- package/lib/less-browser/index.js +205 -205
- package/lib/less-browser/log-listener.js +2 -2
- package/lib/less-browser/utils.js +6 -6
- package/lib/less-node/file-manager.js +9 -4
- package/lib/less-node/index.js +3 -3
- package/lib/less-node/plugin-loader.js +3 -3
- package/lib/less-node/url-file-manager.js +5 -2
- package/lib/less-rhino/index.js +13 -9
- package/lib/source-map/source-map-0.1.31.js +1 -1
- package/package.json +1 -1
- package/test/browser/css/relative-urls/urls.css +1 -0
- package/test/browser/less/relative-urls/urls.less +1 -0
- package/test/browser/runner-browser-options.js +23 -23
- package/test/browser/runner-errors-spec.js +1 -1
- package/test/browser/runner-global-vars-spec.js +1 -1
- package/test/browser/runner-main-options.js +5 -5
- package/test/browser/runner-main-spec.js +1 -1
- package/test/copy-bom.js +35 -35
- package/test/css/functions.css +8 -0
- package/test/css/import-interpolation.css +1 -0
- package/test/css/mixins-important.css +6 -0
- package/test/css/selectors.css +5 -0
- package/test/css/static-urls/urls.css +1 -0
- package/test/css/urls.css +1 -0
- package/test/index.js +2 -1
- package/test/less/functions.less +13 -0
- package/test/less/import/imports/logo.less +1 -0
- package/test/less/mixins-important.less +17 -1
- package/test/less/selectors.less +10 -0
- package/test/less/sourcemaps-empty/empty.less +0 -0
- package/test/less/sourcemaps-empty/var-defs.less +1 -0
- package/test/less/urls.less +1 -1
- package/test/less-test.js +49 -27
- package/test/modify-vars.js +13 -13
- package/test/browser/less.js +0 -29
- package/test/less-bom/charsets.less +0 -3
- package/test/less-bom/colors.less +0 -98
- package/test/less-bom/comments.less +0 -102
- package/test/less-bom/comments2.less +0 -20
- package/test/less-bom/compression/compression.less +0 -36
- package/test/less-bom/css-3.less +0 -154
- package/test/less-bom/css-escapes.less +0 -33
- package/test/less-bom/css-guards.less +0 -103
- package/test/less-bom/css.less +0 -108
- package/test/less-bom/debug/import/test.less +0 -25
- package/test/less-bom/debug/linenumbers.less +0 -33
- package/test/less-bom/detached-rulesets.less +0 -103
- package/test/less-bom/empty.less +0 -1
- package/test/less-bom/errors/add-mixed-units.less +0 -3
- package/test/less-bom/errors/add-mixed-units.txt +0 -4
- package/test/less-bom/errors/add-mixed-units2.less +0 -3
- package/test/less-bom/errors/add-mixed-units2.txt +0 -4
- package/test/less-bom/errors/at-rules-undefined-var.less +0 -4
- package/test/less-bom/errors/at-rules-undefined-var.txt +0 -4
- package/test/less-bom/errors/bad-variable-declaration1.less +0 -1
- package/test/less-bom/errors/bad-variable-declaration1.txt +0 -2
- package/test/less-bom/errors/color-func-invalid-color.less +0 -3
- package/test/less-bom/errors/color-func-invalid-color.txt +0 -4
- package/test/less-bom/errors/color-invalid-hex-code.less +0 -3
- package/test/less-bom/errors/color-invalid-hex-code.txt +0 -4
- package/test/less-bom/errors/color-invalid-hex-code2.less +0 -3
- package/test/less-bom/errors/color-invalid-hex-code2.txt +0 -4
- package/test/less-bom/errors/css-guard-default-func.less +0 -4
- package/test/less-bom/errors/css-guard-default-func.txt +0 -4
- package/test/less-bom/errors/detached-ruleset-1.less +0 -6
- package/test/less-bom/errors/detached-ruleset-1.txt +0 -4
- package/test/less-bom/errors/detached-ruleset-2.less +0 -6
- package/test/less-bom/errors/detached-ruleset-2.txt +0 -4
- package/test/less-bom/errors/detached-ruleset-3.less +0 -4
- package/test/less-bom/errors/detached-ruleset-3.txt +0 -4
- package/test/less-bom/errors/detached-ruleset-4.less +0 -5
- package/test/less-bom/errors/detached-ruleset-4.txt +0 -4
- package/test/less-bom/errors/detached-ruleset-5.less +0 -4
- package/test/less-bom/errors/detached-ruleset-5.txt +0 -3
- package/test/less-bom/errors/detached-ruleset-6.less +0 -5
- package/test/less-bom/errors/detached-ruleset-6.txt +0 -4
- package/test/less-bom/errors/divide-mixed-units.less +0 -3
- package/test/less-bom/errors/divide-mixed-units.txt +0 -4
- package/test/less-bom/errors/extend-no-selector.less +0 -3
- package/test/less-bom/errors/extend-no-selector.txt +0 -3
- package/test/less-bom/errors/extend-not-at-end.less +0 -3
- package/test/less-bom/errors/extend-not-at-end.txt +0 -3
- package/test/less-bom/errors/import-malformed.less +0 -1
- package/test/less-bom/errors/import-malformed.txt +0 -3
- package/test/less-bom/errors/import-missing.less +0 -6
- package/test/less-bom/errors/import-missing.txt +0 -3
- package/test/less-bom/errors/import-no-semi.less +0 -1
- package/test/less-bom/errors/import-no-semi.txt +0 -2
- package/test/less-bom/errors/import-subfolder1.less +0 -1
- package/test/less-bom/errors/import-subfolder1.txt +0 -3
- package/test/less-bom/errors/import-subfolder2.less +0 -1
- package/test/less-bom/errors/import-subfolder2.txt +0 -4
- package/test/less-bom/errors/imports/import-subfolder1.less +0 -1
- package/test/less-bom/errors/imports/import-subfolder2.less +0 -1
- package/test/less-bom/errors/imports/import-test.less +0 -4
- package/test/less-bom/errors/imports/subfolder/mixin-not-defined.less +0 -1
- package/test/less-bom/errors/imports/subfolder/parse-error-curly-bracket.less +0 -1
- package/test/less-bom/errors/javascript-error.less +0 -3
- package/test/less-bom/errors/javascript-error.txt +0 -4
- package/test/less-bom/errors/javascript-undefined-var.less +0 -3
- package/test/less-bom/errors/javascript-undefined-var.txt +0 -4
- package/test/less-bom/errors/mixed-mixin-definition-args-1.less +0 -6
- package/test/less-bom/errors/mixed-mixin-definition-args-1.txt +0 -4
- package/test/less-bom/errors/mixed-mixin-definition-args-2.less +0 -6
- package/test/less-bom/errors/mixed-mixin-definition-args-2.txt +0 -4
- package/test/less-bom/errors/mixin-not-defined.less +0 -11
- package/test/less-bom/errors/mixin-not-defined.txt +0 -3
- package/test/less-bom/errors/mixin-not-matched.less +0 -6
- package/test/less-bom/errors/mixin-not-matched.txt +0 -3
- package/test/less-bom/errors/mixin-not-matched2.less +0 -6
- package/test/less-bom/errors/mixin-not-matched2.txt +0 -3
- package/test/less-bom/errors/mixin-not-visible-in-scope-1.less +0 -9
- package/test/less-bom/errors/mixin-not-visible-in-scope-1.txt +0 -4
- package/test/less-bom/errors/mixins-guards-default-func-1.less +0 -9
- package/test/less-bom/errors/mixins-guards-default-func-1.txt +0 -4
- package/test/less-bom/errors/mixins-guards-default-func-2.less +0 -9
- package/test/less-bom/errors/mixins-guards-default-func-2.txt +0 -4
- package/test/less-bom/errors/mixins-guards-default-func-3.less +0 -9
- package/test/less-bom/errors/mixins-guards-default-func-3.txt +0 -4
- package/test/less-bom/errors/multiple-guards-on-css-selectors.less +0 -4
- package/test/less-bom/errors/multiple-guards-on-css-selectors.txt +0 -4
- package/test/less-bom/errors/multiple-guards-on-css-selectors2.less +0 -4
- package/test/less-bom/errors/multiple-guards-on-css-selectors2.txt +0 -4
- package/test/less-bom/errors/multiply-mixed-units.less +0 -7
- package/test/less-bom/errors/multiply-mixed-units.txt +0 -4
- package/test/less-bom/errors/parens-error-1.less +0 -3
- package/test/less-bom/errors/parens-error-1.txt +0 -4
- package/test/less-bom/errors/parens-error-2.less +0 -3
- package/test/less-bom/errors/parens-error-2.txt +0 -4
- package/test/less-bom/errors/parens-error-3.less +0 -3
- package/test/less-bom/errors/parens-error-3.txt +0 -4
- package/test/less-bom/errors/parse-error-curly-bracket.less +0 -4
- package/test/less-bom/errors/parse-error-curly-bracket.txt +0 -4
- package/test/less-bom/errors/parse-error-extra-parens.less +0 -5
- package/test/less-bom/errors/parse-error-extra-parens.txt +0 -3
- package/test/less-bom/errors/parse-error-missing-bracket.less +0 -2
- package/test/less-bom/errors/parse-error-missing-bracket.txt +0 -3
- package/test/less-bom/errors/parse-error-missing-parens.less +0 -5
- package/test/less-bom/errors/parse-error-missing-parens.txt +0 -3
- package/test/less-bom/errors/parse-error-with-import.less +0 -13
- package/test/less-bom/errors/parse-error-with-import.txt +0 -4
- package/test/less-bom/errors/percentage-missing-space.less +0 -3
- package/test/less-bom/errors/percentage-missing-space.txt +0 -4
- package/test/less-bom/errors/property-asterisk-only-name.less +0 -3
- package/test/less-bom/errors/property-asterisk-only-name.txt +0 -4
- package/test/less-bom/errors/property-ie5-hack.less +0 -3
- package/test/less-bom/errors/property-ie5-hack.txt +0 -3
- package/test/less-bom/errors/property-in-root.less +0 -4
- package/test/less-bom/errors/property-in-root.txt +0 -4
- package/test/less-bom/errors/property-in-root2.less +0 -1
- package/test/less-bom/errors/property-in-root2.txt +0 -4
- package/test/less-bom/errors/property-in-root3.less +0 -4
- package/test/less-bom/errors/property-in-root3.txt +0 -3
- package/test/less-bom/errors/property-interp-not-defined.less +0 -1
- package/test/less-bom/errors/property-interp-not-defined.txt +0 -2
- package/test/less-bom/errors/recursive-variable.less +0 -1
- package/test/less-bom/errors/recursive-variable.txt +0 -2
- package/test/less-bom/errors/single-character.less +0 -1
- package/test/less-bom/errors/single-character.txt +0 -2
- package/test/less-bom/errors/svg-gradient1.less +0 -3
- package/test/less-bom/errors/svg-gradient1.txt +0 -4
- package/test/less-bom/errors/svg-gradient2.less +0 -3
- package/test/less-bom/errors/svg-gradient2.txt +0 -4
- package/test/less-bom/errors/svg-gradient3.less +0 -3
- package/test/less-bom/errors/svg-gradient3.txt +0 -4
- package/test/less-bom/errors/unit-function.less +0 -3
- package/test/less-bom/errors/unit-function.txt +0 -4
- package/test/less-bom/extend-chaining.less +0 -91
- package/test/less-bom/extend-clearfix.less +0 -19
- package/test/less-bom/extend-exact.less +0 -46
- package/test/less-bom/extend-media.less +0 -24
- package/test/less-bom/extend-nest.less +0 -65
- package/test/less-bom/extend-selector.less +0 -99
- package/test/less-bom/extend.less +0 -81
- package/test/less-bom/extract-and-length.less +0 -133
- package/test/less-bom/functions.less +0 -201
- package/test/less-bom/globalVars/extended.json +0 -5
- package/test/less-bom/globalVars/extended.less +0 -10
- package/test/less-bom/globalVars/simple.json +0 -3
- package/test/less-bom/globalVars/simple.less +0 -3
- package/test/less-bom/ie-filters.less +0 -15
- package/test/less-bom/import/deeper/deeper-2/url-import-2.less +0 -3
- package/test/less-bom/import/deeper/deeper-2/url-import.less +0 -1
- package/test/less-bom/import/deeper/import-once-test-a.less +0 -1
- package/test/less-bom/import/deeper/url-import.less +0 -1
- package/test/less-bom/import/import-and-relative-paths-test.less +0 -17
- package/test/less-bom/import/import-charset-test.less +0 -1
- package/test/less-bom/import/import-interpolation.less +0 -2
- package/test/less-bom/import/import-interpolation2.less +0 -5
- package/test/less-bom/import/import-once-test-c.less +0 -6
- package/test/less-bom/import/import-reference.less +0 -89
- package/test/less-bom/import/import-test-a.less +0 -4
- package/test/less-bom/import/import-test-b.less +0 -8
- package/test/less-bom/import/import-test-c.less +0 -6
- package/test/less-bom/import/import-test-d.css +0 -1
- package/test/less-bom/import/import-test-e.less +0 -2
- package/test/less-bom/import/import-test-f.less +0 -5
- package/test/less-bom/import/imports/font.less +0 -8
- package/test/less-bom/import/imports/logo.less +0 -5
- package/test/less-bom/import/interpolation-vars.less +0 -6
- package/test/less-bom/import/invalid-css.less +0 -1
- package/test/less-bom/import/urls.less +0 -1
- package/test/less-bom/import-inline.less +0 -3
- package/test/less-bom/import-interpolation.less +0 -8
- package/test/less-bom/import-once.less +0 -6
- package/test/less-bom/import-reference.less +0 -23
- package/test/less-bom/import.less +0 -30
- package/test/less-bom/include-path/include-path.less +0 -6
- package/test/less-bom/javascript.less +0 -38
- package/test/less-bom/lazy-eval.less +0 -6
- package/test/less-bom/legacy/legacy.less +0 -7
- package/test/less-bom/media.less +0 -234
- package/test/less-bom/merge.less +0 -78
- package/test/less-bom/mixins-args.less +0 -215
- package/test/less-bom/mixins-closure.less +0 -26
- package/test/less-bom/mixins-guards-default-func.less +0 -195
- package/test/less-bom/mixins-guards.less +0 -271
- package/test/less-bom/mixins-important.less +0 -37
- package/test/less-bom/mixins-interpolated.less +0 -75
- package/test/less-bom/mixins-named-args.less +0 -36
- package/test/less-bom/mixins-nested.less +0 -22
- package/test/less-bom/mixins-pattern.less +0 -102
- package/test/less-bom/mixins.less +0 -145
- package/test/less-bom/modifyVars/extended.json +0 -5
- package/test/less-bom/modifyVars/extended.less +0 -11
- package/test/less-bom/nested-gradient-with-svg-gradient/mixin-consumer.less +0 -5
- package/test/less-bom/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +0 -15
- package/test/less-bom/no-js-errors/no-js-errors.less +0 -3
- package/test/less-bom/no-js-errors/no-js-errors.txt +0 -4
- package/test/less-bom/no-output.less +0 -2
- package/test/less-bom/operations.less +0 -62
- package/test/less-bom/parens.less +0 -45
- package/test/less-bom/property-name-interp.less +0 -56
- package/test/less-bom/rulesets.less +0 -30
- package/test/less-bom/scope.less +0 -104
- package/test/less-bom/selectors.less +0 -174
- package/test/less-bom/sourcemaps/basic.json +0 -3
- package/test/less-bom/sourcemaps/basic.less +0 -27
- package/test/less-bom/sourcemaps/imported.css +0 -7
- package/test/less-bom/static-urls/urls.less +0 -33
- package/test/less-bom/strict-units/strict-units.less +0 -4
- package/test/less-bom/strings.less +0 -73
- package/test/less-bom/url-args/urls.less +0 -63
- package/test/less-bom/urls.less +0 -94
- package/test/less-bom/variables-in-at-rules.less +0 -20
- package/test/less-bom/variables.less +0 -119
- package/test/less-bom/whitespace.less +0 -44
|
@@ -6,251 +6,251 @@ var addDataAttr = require("./utils").addDataAttr,
|
|
|
6
6
|
browser = require("./browser");
|
|
7
7
|
|
|
8
8
|
module.exports = function(window, options) {
|
|
9
|
-
var document = window.document;
|
|
10
|
-
var less = require('../less')();
|
|
11
|
-
module.exports = less;
|
|
12
|
-
less.options = options;
|
|
13
|
-
var environment = less.environment,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
environment.addFileManager(fileManager);
|
|
17
|
-
less.FileManager = FileManager;
|
|
18
|
-
|
|
19
|
-
require("./log-listener")(less, options);
|
|
20
|
-
var errors = require("./error-reporting")(window, less, options);
|
|
21
|
-
var cache = less.cache = options.cache || require("./cache")(window, options, less.logger);
|
|
22
|
-
|
|
23
|
-
//Setup user functions
|
|
24
|
-
if (options.functions) {
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var typePattern = /^text\/(x-)?less$/;
|
|
29
|
-
|
|
30
|
-
function postProcessCSS(styles) {
|
|
31
|
-
if (options.postProcessor && typeof options.postProcessor === 'function') {
|
|
32
|
-
styles = options.postProcessor.call(styles, styles) || styles;
|
|
9
|
+
var document = window.document;
|
|
10
|
+
var less = require('../less')();
|
|
11
|
+
//module.exports = less;
|
|
12
|
+
less.options = options;
|
|
13
|
+
var environment = less.environment,
|
|
14
|
+
FileManager = require("./file-manager")(options, less.logger),
|
|
15
|
+
fileManager = new FileManager();
|
|
16
|
+
environment.addFileManager(fileManager);
|
|
17
|
+
less.FileManager = FileManager;
|
|
18
|
+
|
|
19
|
+
require("./log-listener")(less, options);
|
|
20
|
+
var errors = require("./error-reporting")(window, less, options);
|
|
21
|
+
var cache = less.cache = options.cache || require("./cache")(window, options, less.logger);
|
|
22
|
+
|
|
23
|
+
//Setup user functions
|
|
24
|
+
if (options.functions) {
|
|
25
|
+
less.functions.functionRegistry.addMultiple(options.functions);
|
|
33
26
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (obj.hasOwnProperty(prop)) {
|
|
41
|
-
cloned[prop] = obj[prop];
|
|
27
|
+
|
|
28
|
+
var typePattern = /^text\/(x-)?less$/;
|
|
29
|
+
|
|
30
|
+
function postProcessCSS(styles) {
|
|
31
|
+
if (options.postProcessor && typeof options.postProcessor === 'function') {
|
|
32
|
+
styles = options.postProcessor.call(styles, styles) || styles;
|
|
42
33
|
}
|
|
34
|
+
return styles;
|
|
43
35
|
}
|
|
44
|
-
return cloned;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// only really needed for phantom
|
|
48
|
-
function bind(func, thisArg) {
|
|
49
|
-
var curryArgs = Array.prototype.slice.call(arguments, 2);
|
|
50
|
-
return function() {
|
|
51
|
-
var args = curryArgs.concat(Array.prototype.slice.call(arguments, 0));
|
|
52
|
-
return func.apply(thisArg, args);
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
36
|
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
|
|
37
|
+
function clone(obj) {
|
|
38
|
+
var cloned = {};
|
|
39
|
+
for (var prop in obj) {
|
|
40
|
+
if (obj.hasOwnProperty(prop)) {
|
|
41
|
+
cloned[prop] = obj[prop];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return cloned;
|
|
45
|
+
}
|
|
59
46
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
47
|
+
// only really needed for phantom
|
|
48
|
+
function bind(func, thisArg) {
|
|
49
|
+
var curryArgs = Array.prototype.slice.call(arguments, 2);
|
|
50
|
+
return function() {
|
|
51
|
+
var args = curryArgs.concat(Array.prototype.slice.call(arguments, 0));
|
|
52
|
+
return func.apply(thisArg, args);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
67
55
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
56
|
+
function loadStyles(modifyVars) {
|
|
57
|
+
var styles = document.getElementsByTagName('style'),
|
|
58
|
+
style;
|
|
59
|
+
|
|
60
|
+
for (var i = 0; i < styles.length; i++) {
|
|
61
|
+
style = styles[i];
|
|
62
|
+
if (style.type.match(typePattern)) {
|
|
63
|
+
var instanceOptions = clone(options);
|
|
64
|
+
instanceOptions.modifyVars = modifyVars;
|
|
65
|
+
var lessText = style.innerHTML || '';
|
|
66
|
+
instanceOptions.filename = document.location.href.replace(/#.*$/, '');
|
|
67
|
+
|
|
68
|
+
/*jshint loopfunc:true */
|
|
69
|
+
// use closure to store current style
|
|
70
|
+
less.render(lessText, instanceOptions,
|
|
71
|
+
bind(function(style, e, result) {
|
|
72
|
+
if (e) {
|
|
73
|
+
errors.add(e, "inline");
|
|
78
74
|
} else {
|
|
79
|
-
style.
|
|
75
|
+
style.type = 'text/css';
|
|
76
|
+
if (style.styleSheet) {
|
|
77
|
+
style.styleSheet.cssText = result.css;
|
|
78
|
+
} else {
|
|
79
|
+
style.innerHTML = result.css;
|
|
80
|
+
}
|
|
80
81
|
}
|
|
81
|
-
}
|
|
82
|
-
|
|
82
|
+
}, null, style));
|
|
83
|
+
}
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
|
-
}
|
|
86
86
|
|
|
87
|
-
function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) {
|
|
87
|
+
function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) {
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
var instanceOptions = clone(options);
|
|
90
|
+
addDataAttr(instanceOptions, sheet);
|
|
91
|
+
instanceOptions.mime = sheet.type;
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
if (modifyVars) {
|
|
94
|
+
instanceOptions.modifyVars = modifyVars;
|
|
95
|
+
}
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
function loadInitialFileCallback(loadedFile) {
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
var data = loadedFile.contents,
|
|
100
|
+
path = loadedFile.filename,
|
|
101
|
+
webInfo = loadedFile.webInfo;
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
var newFileInfo = {
|
|
104
|
+
currentDirectory: fileManager.getPath(path),
|
|
105
|
+
filename: path,
|
|
106
|
+
rootFilename: path,
|
|
107
|
+
relativeUrls: instanceOptions.relativeUrls};
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
newFileInfo.entryPath = newFileInfo.currentDirectory;
|
|
110
|
+
newFileInfo.rootpath = instanceOptions.rootpath || newFileInfo.currentDirectory;
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
if (webInfo) {
|
|
113
|
+
webInfo.remaining = remaining;
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
if (!instanceOptions.modifyVars) {
|
|
116
|
+
var css = cache.getCSS(path, webInfo);
|
|
117
|
+
if (!reload && css) {
|
|
118
|
+
webInfo.local = true;
|
|
119
|
+
callback(null, css, data, sheet, webInfo, path);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
|
-
}
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
//TODO add tests around how this behaves when reloading
|
|
126
|
+
errors.remove(path);
|
|
127
|
+
|
|
128
|
+
instanceOptions.rootFileInfo = newFileInfo;
|
|
129
|
+
less.render(data, instanceOptions, function(e, result) {
|
|
130
|
+
if (e) {
|
|
131
|
+
e.href = path;
|
|
132
|
+
callback(e);
|
|
133
|
+
} else {
|
|
134
|
+
result.css = postProcessCSS(result.css);
|
|
135
|
+
if (!instanceOptions.modifyVars) {
|
|
136
|
+
cache.setCSS(sheet.href, webInfo.lastModified, result.css);
|
|
137
|
+
}
|
|
138
|
+
callback(null, result.css, data, sheet, webInfo, path);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
127
142
|
|
|
128
|
-
|
|
129
|
-
less.render(data, instanceOptions, function(e, result) {
|
|
143
|
+
fileManager.loadFile(sheet.href, null, instanceOptions, environment, function(e, loadedFile) {
|
|
130
144
|
if (e) {
|
|
131
|
-
e.href = path;
|
|
132
145
|
callback(e);
|
|
133
|
-
|
|
134
|
-
result.css = postProcessCSS(result.css);
|
|
135
|
-
if (!instanceOptions.modifyVars) {
|
|
136
|
-
cache.setCSS(sheet.href, webInfo.lastModified, result.css);
|
|
137
|
-
}
|
|
138
|
-
callback(null, result.css, data, sheet, webInfo, path);
|
|
146
|
+
return;
|
|
139
147
|
}
|
|
148
|
+
loadInitialFileCallback(loadedFile);
|
|
140
149
|
});
|
|
141
150
|
}
|
|
142
151
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
callback(
|
|
146
|
-
return;
|
|
152
|
+
function loadStyleSheets(callback, reload, modifyVars) {
|
|
153
|
+
for (var i = 0; i < less.sheets.length; i++) {
|
|
154
|
+
loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1), modifyVars);
|
|
147
155
|
}
|
|
148
|
-
loadInitialFileCallback(loadedFile);
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function loadStyleSheets(callback, reload, modifyVars) {
|
|
153
|
-
for (var i = 0; i < less.sheets.length; i++) {
|
|
154
|
-
loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1), modifyVars);
|
|
155
156
|
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function initRunningMode(){
|
|
159
|
-
if (less.env === 'development') {
|
|
160
|
-
less.watchTimer = setInterval(function () {
|
|
161
|
-
if (less.watchMode) {
|
|
162
|
-
fileManager.clearFileCache();
|
|
163
|
-
loadStyleSheets(function (e, css, _, sheet, webInfo) {
|
|
164
|
-
if (e) {
|
|
165
|
-
errors.add(e, e.href || sheet.href);
|
|
166
|
-
} else if (css) {
|
|
167
|
-
browser.createCSS(window.document, css, sheet);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}, options.poll);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
157
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
less.
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
158
|
+
function initRunningMode() {
|
|
159
|
+
if (less.env === 'development') {
|
|
160
|
+
less.watchTimer = setInterval(function () {
|
|
161
|
+
if (less.watchMode) {
|
|
162
|
+
fileManager.clearFileCache();
|
|
163
|
+
loadStyleSheets(function (e, css, _, sheet, webInfo) {
|
|
164
|
+
if (e) {
|
|
165
|
+
errors.add(e, e.href || sheet.href);
|
|
166
|
+
} else if (css) {
|
|
167
|
+
browser.createCSS(window.document, css, sheet);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}, options.poll);
|
|
172
|
+
}
|
|
182
173
|
}
|
|
183
|
-
this.watchMode = true;
|
|
184
|
-
return true;
|
|
185
|
-
};
|
|
186
174
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
//
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
less.
|
|
193
|
-
|
|
194
|
-
var links = document.getElementsByTagName('link');
|
|
195
|
-
less.sheets = [];
|
|
196
|
-
|
|
197
|
-
for (var i = 0; i < links.length; i++) {
|
|
198
|
-
if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&
|
|
199
|
-
(links[i].type.match(typePattern)))) {
|
|
200
|
-
less.sheets.push(links[i]);
|
|
201
|
-
}
|
|
175
|
+
//
|
|
176
|
+
// Watch mode
|
|
177
|
+
//
|
|
178
|
+
less.watch = function () {
|
|
179
|
+
if (!less.watchMode ) {
|
|
180
|
+
less.env = 'development';
|
|
181
|
+
initRunningMode();
|
|
202
182
|
}
|
|
183
|
+
this.watchMode = true;
|
|
184
|
+
return true;
|
|
185
|
+
};
|
|
203
186
|
|
|
204
|
-
|
|
205
|
-
});
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
//
|
|
209
|
-
// With this function, it's possible to alter variables and re-render
|
|
210
|
-
// CSS without reloading less-files
|
|
211
|
-
//
|
|
212
|
-
less.modifyVars = function(record) {
|
|
213
|
-
return less.refresh(true, record, false);
|
|
214
|
-
};
|
|
187
|
+
less.unwatch = function () {clearInterval(less.watchTimer); this.watchMode = false; return false; };
|
|
215
188
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
189
|
+
//
|
|
190
|
+
// Get all <link> tags with the 'rel' attribute set to "stylesheet/less"
|
|
191
|
+
//
|
|
192
|
+
less.registerStylesheets = function() {
|
|
193
|
+
return new Promise(function(resolve, reject) {
|
|
194
|
+
var links = document.getElementsByTagName('link');
|
|
195
|
+
less.sheets = [];
|
|
223
196
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
if (webInfo.local) {
|
|
231
|
-
less.logger.info("loading " + sheet.href + " from cache.");
|
|
232
|
-
} else {
|
|
233
|
-
less.logger.info("rendered " + sheet.href + " successfully.");
|
|
234
|
-
}
|
|
235
|
-
browser.createCSS(window.document, css, sheet);
|
|
236
|
-
less.logger.info("css for " + sheet.href + " generated in " + (new Date() - endTime) + 'ms');
|
|
237
|
-
if (webInfo.remaining === 0) {
|
|
238
|
-
totalMilliseconds = new Date() - startTime;
|
|
239
|
-
less.logger.info("less has finished. css generated in " + totalMilliseconds + 'ms');
|
|
240
|
-
resolve({
|
|
241
|
-
startTime: startTime,
|
|
242
|
-
endTime: endTime,
|
|
243
|
-
totalMilliseconds: totalMilliseconds,
|
|
244
|
-
sheets: less.sheets.length
|
|
245
|
-
});
|
|
197
|
+
for (var i = 0; i < links.length; i++) {
|
|
198
|
+
if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&
|
|
199
|
+
(links[i].type.match(typePattern)))) {
|
|
200
|
+
less.sheets.push(links[i]);
|
|
201
|
+
}
|
|
246
202
|
}
|
|
247
|
-
endTime = new Date();
|
|
248
|
-
}, reload, modifyVars);
|
|
249
203
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
};
|
|
204
|
+
resolve();
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
//
|
|
209
|
+
// With this function, it's possible to alter variables and re-render
|
|
210
|
+
// CSS without reloading less-files
|
|
211
|
+
//
|
|
212
|
+
less.modifyVars = function(record) {
|
|
213
|
+
return less.refresh(true, record, false);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
less.refresh = function (reload, modifyVars, clearFileCache) {
|
|
217
|
+
if ((reload || clearFileCache) && clearFileCache !== false) {
|
|
218
|
+
fileManager.clearFileCache();
|
|
219
|
+
}
|
|
220
|
+
return new Promise(function (resolve, reject) {
|
|
221
|
+
var startTime, endTime, totalMilliseconds;
|
|
222
|
+
startTime = endTime = new Date();
|
|
223
|
+
|
|
224
|
+
loadStyleSheets(function (e, css, _, sheet, webInfo) {
|
|
225
|
+
if (e) {
|
|
226
|
+
errors.add(e, e.href || sheet.href);
|
|
227
|
+
reject(e);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (webInfo.local) {
|
|
231
|
+
less.logger.info("loading " + sheet.href + " from cache.");
|
|
232
|
+
} else {
|
|
233
|
+
less.logger.info("rendered " + sheet.href + " successfully.");
|
|
234
|
+
}
|
|
235
|
+
browser.createCSS(window.document, css, sheet);
|
|
236
|
+
less.logger.info("css for " + sheet.href + " generated in " + (new Date() - endTime) + 'ms');
|
|
237
|
+
if (webInfo.remaining === 0) {
|
|
238
|
+
totalMilliseconds = new Date() - startTime;
|
|
239
|
+
less.logger.info("less has finished. css generated in " + totalMilliseconds + 'ms');
|
|
240
|
+
resolve({
|
|
241
|
+
startTime: startTime,
|
|
242
|
+
endTime: endTime,
|
|
243
|
+
totalMilliseconds: totalMilliseconds,
|
|
244
|
+
sheets: less.sheets.length
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
endTime = new Date();
|
|
248
|
+
}, reload, modifyVars);
|
|
249
|
+
|
|
250
|
+
loadStyles(modifyVars);
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
253
|
|
|
254
|
-
less.refreshStyles = loadStyles;
|
|
254
|
+
less.refreshStyles = loadStyles;
|
|
255
255
|
return less;
|
|
256
256
|
};
|
|
@@ -11,7 +11,7 @@ module.exports = function(less, options) {
|
|
|
11
11
|
// 1 - Errors
|
|
12
12
|
// 0 - None
|
|
13
13
|
// Defaults to 2
|
|
14
|
-
options.logLevel = typeof
|
|
14
|
+
options.logLevel = typeof options.logLevel !== 'undefined' ? options.logLevel : (options.env === 'development' ? logLevel_info : logLevel_error);
|
|
15
15
|
|
|
16
16
|
if (!options.loggers) {
|
|
17
17
|
options.loggers = [{
|
|
@@ -37,7 +37,7 @@ module.exports = function(less, options) {
|
|
|
37
37
|
}
|
|
38
38
|
}];
|
|
39
39
|
}
|
|
40
|
-
for(var i = 0; i < options.loggers.length; i++) {
|
|
40
|
+
for (var i = 0; i < options.loggers.length; i++) {
|
|
41
41
|
less.logger.addListener(options.loggers[i]);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
extractId: function(href) {
|
|
3
|
-
return href.replace(/^[a-z-]+:\/+?[^\/]+/, ''
|
|
4
|
-
.replace(/[\?\&]livereload=\w+/, ''
|
|
5
|
-
.replace(/^\//,
|
|
6
|
-
.replace(/\.[a-zA-Z]+$/,
|
|
7
|
-
.replace(/[^\.\w-]+/g,
|
|
8
|
-
.replace(/\./g,
|
|
3
|
+
return href.replace(/^[a-z-]+:\/+?[^\/]+/, '') // Remove protocol & domain
|
|
4
|
+
.replace(/[\?\&]livereload=\w+/, '') // Remove LiveReload cachebuster
|
|
5
|
+
.replace(/^\//, '') // Remove root /
|
|
6
|
+
.replace(/\.[a-zA-Z]+$/, '') // Remove simple extension
|
|
7
|
+
.replace(/[^\.\w-]+/g, '-') // Replace illegal characters
|
|
8
|
+
.replace(/\./g, ':'); // Replace dots with colons(for valid id)
|
|
9
9
|
},
|
|
10
10
|
addDataAttr: function(options, tag) {
|
|
11
11
|
for (var opt in tag.dataset) {
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
var path = require('path'),
|
|
2
2
|
fs = require('./fs'),
|
|
3
|
-
PromiseConstructor
|
|
3
|
+
PromiseConstructor,
|
|
4
4
|
AbstractFileManager = require("../less/environment/abstract-file-manager.js");
|
|
5
5
|
|
|
6
|
+
try {
|
|
7
|
+
PromiseConstructor = typeof Promise === 'undefined' ? require('promise') : Promise;
|
|
8
|
+
} catch(e) {
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
var FileManager = function() {
|
|
7
12
|
};
|
|
8
13
|
|
|
@@ -23,7 +28,7 @@ FileManager.prototype.loadFile = function(filename, currentDirectory, options, e
|
|
|
23
28
|
|
|
24
29
|
options = options || {};
|
|
25
30
|
|
|
26
|
-
if (options.syncImport) {
|
|
31
|
+
if (options.syncImport || !PromiseConstructor) {
|
|
27
32
|
data = this.loadFileSync(filename, currentDirectory, options, environment, 'utf-8');
|
|
28
33
|
callback(data.error, data);
|
|
29
34
|
return;
|
|
@@ -79,7 +84,7 @@ FileManager.prototype.loadFileSync = function(filename, currentDirectory, option
|
|
|
79
84
|
try {
|
|
80
85
|
fullFilename = filename;
|
|
81
86
|
if (paths[i]) {
|
|
82
|
-
|
|
87
|
+
fullFilename = path.join(paths[i], fullFilename);
|
|
83
88
|
}
|
|
84
89
|
filenamesTried.push(fullFilename);
|
|
85
90
|
fs.statSync(fullFilename);
|
|
@@ -95,7 +100,7 @@ FileManager.prototype.loadFileSync = function(filename, currentDirectory, option
|
|
|
95
100
|
} else {
|
|
96
101
|
data = fs.readFileSync(fullFilename, encoding);
|
|
97
102
|
result = { contents: data, filename: fullFilename};
|
|
98
|
-
|
|
103
|
+
}
|
|
99
104
|
|
|
100
105
|
return result;
|
|
101
106
|
};
|
package/lib/less-node/index.js
CHANGED
|
@@ -27,11 +27,11 @@ less.formatError = function(ctx, options) {
|
|
|
27
27
|
return ctx.stack || ctx.message;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
if (typeof
|
|
30
|
+
if (typeof extract[0] === 'string') {
|
|
31
31
|
error.push(stylize((ctx.line - 1) + ' ' + extract[0], 'grey'));
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
if (typeof
|
|
34
|
+
if (typeof extract[1] === 'string') {
|
|
35
35
|
var errorTxt = ctx.line + ' ';
|
|
36
36
|
if (extract[1]) {
|
|
37
37
|
errorTxt += extract[1].slice(0, ctx.column) +
|
|
@@ -41,7 +41,7 @@ less.formatError = function(ctx, options) {
|
|
|
41
41
|
error.push(errorTxt);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
if (typeof
|
|
44
|
+
if (typeof extract[2] === 'string') {
|
|
45
45
|
error.push(stylize((ctx.line + 1) + ' ' + extract[2], 'grey'));
|
|
46
46
|
}
|
|
47
47
|
error = error.join('\n') + stylize('', 'reset') + '\n';
|
|
@@ -38,7 +38,7 @@ PluginLoader.prototype.tryLoadPlugin = function(name, argument) {
|
|
|
38
38
|
return null;
|
|
39
39
|
};
|
|
40
40
|
PluginLoader.prototype.compareVersion = function(aVersion, bVersion) {
|
|
41
|
-
for(var i = 0; i < aVersion.length; i++) {
|
|
41
|
+
for (var i = 0; i < aVersion.length; i++) {
|
|
42
42
|
if (aVersion[i] !== bVersion[i]) {
|
|
43
43
|
return parseInt(aVersion[i]) > parseInt(bVersion[i]) ? -1 : 1;
|
|
44
44
|
}
|
|
@@ -47,7 +47,7 @@ PluginLoader.prototype.compareVersion = function(aVersion, bVersion) {
|
|
|
47
47
|
};
|
|
48
48
|
PluginLoader.prototype.versionToString = function(version) {
|
|
49
49
|
var versionString = "";
|
|
50
|
-
for(var i = 0; i < version.length; i++) {
|
|
50
|
+
for (var i = 0; i < version.length; i++) {
|
|
51
51
|
versionString += (versionString ? "." : "") + version[i];
|
|
52
52
|
}
|
|
53
53
|
return versionString;
|
|
@@ -81,7 +81,7 @@ PluginLoader.prototype.tryRequirePlugin = function(name) {
|
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
83
|
PluginLoader.prototype.printUsage = function(plugins) {
|
|
84
|
-
for(var i = 0; i < plugins.length; i++) {
|
|
84
|
+
for (var i = 0; i < plugins.length; i++) {
|
|
85
85
|
var plugin = plugins[i];
|
|
86
86
|
if (plugin.printUsage) {
|
|
87
87
|
plugin.printUsage();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var isUrlRe = /^(?:https?:)?\/\//i,
|
|
2
2
|
url = require('url'),
|
|
3
3
|
request,
|
|
4
|
-
PromiseConstructor
|
|
4
|
+
PromiseConstructor,
|
|
5
5
|
AbstractFileManager = require("../less/environment/abstract-file-manager.js"),
|
|
6
6
|
logger = require("../less/logger");
|
|
7
7
|
|
|
@@ -15,6 +15,9 @@ UrlFileManager.prototype.supports = function(filename, currentDirectory, options
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
UrlFileManager.prototype.loadFile = function(filename, currentDirectory, options, environment) {
|
|
18
|
+
if (!PromiseConstructor) {
|
|
19
|
+
PromiseConstructor = typeof Promise === 'undefined' ? require('promise') : Promise;
|
|
20
|
+
}
|
|
18
21
|
return new PromiseConstructor(function(fulfill, reject) {
|
|
19
22
|
if (request === undefined) {
|
|
20
23
|
try { request = require('request'); }
|
|
@@ -43,7 +46,7 @@ UrlFileManager.prototype.loadFile = function(filename, currentDirectory, options
|
|
|
43
46
|
return;
|
|
44
47
|
}
|
|
45
48
|
if (!body) {
|
|
46
|
-
logger.warn('Warning: Empty body (HTTP '+ res.statusCode + ') returned by "' + urlStr + '"');
|
|
49
|
+
logger.warn('Warning: Empty body (HTTP ' + res.statusCode + ') returned by "' + urlStr + '"');
|
|
47
50
|
}
|
|
48
51
|
fulfill({ contents: body, filename: urlStr });
|
|
49
52
|
});
|