less 2.2.2 → 2.6.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.
- checksums.yaml +7 -0
- data/Changelog.md +17 -0
- data/Gemfile +7 -3
- data/README.md +29 -13
- data/bin/lessc +3 -1
- data/less.gemspec +2 -6
- data/lib/less/defaults.rb +3 -3
- data/lib/less/java_script/rhino_context.rb +17 -27
- data/lib/less/java_script/v8_context.rb +11 -11
- data/lib/less/js/.gitattributes +10 -0
- data/lib/less/js/.gitignore +24 -0
- data/lib/less/js/.jshintrc +11 -0
- data/lib/less/js/.npmignore +1 -0
- data/lib/less/js/.travis.yml +8 -0
- data/lib/less/js/CHANGELOG.md +299 -0
- data/lib/less/js/CONTRIBUTING.md +50 -0
- data/lib/less/js/Gruntfile.js +298 -0
- data/lib/less/js/README.md +43 -12
- data/lib/less/js/benchmark/benchmark.less +194 -194
- data/lib/less/js/benchmark/less-benchmark.js +9 -10
- data/lib/less/js/bin/lessc +310 -37
- data/lib/less/js/bower.json +18 -0
- data/lib/less/js/build/README.md +51 -0
- data/lib/less/js/build/amd.js +1 -1
- data/lib/less/js/build/browser-header.js +4 -0
- data/lib/less/js/build/build.yml +162 -0
- data/lib/less/js/build/require-rhino.js +7 -2
- data/lib/less/js/build/rhino-header.js +4 -0
- data/lib/less/js/build/rhino-modules.js +131 -0
- data/lib/less/js/build/tasks/.gitkeep +1 -0
- data/lib/less/js/build.gradle +347 -0
- data/lib/less/js/dist/less-1.3.1.js +4011 -0
- data/lib/less/js/dist/less-1.3.1.min.js +9 -0
- data/lib/less/js/dist/less-1.3.2.js +4401 -0
- data/lib/less/js/dist/less-1.3.2.min.js +9 -0
- data/lib/less/js/dist/less-1.3.3.js +4413 -0
- data/lib/less/js/dist/less-1.3.3.min.js +9 -0
- data/lib/less/js/dist/less-1.4.0-beta.js +5830 -0
- data/lib/less/js/dist/less-1.4.0-beta.min.js +11 -0
- data/lib/less/js/dist/less-1.4.0.js +5830 -0
- data/lib/less/js/dist/less-1.4.0.min.js +11 -0
- data/lib/less/js/dist/less-1.4.1.js +5837 -0
- data/lib/less/js/dist/less-1.4.1.min.js +11 -0
- data/lib/less/js/dist/less-1.4.2.js +5837 -0
- data/lib/less/js/dist/less-1.4.2.min.js +11 -0
- data/lib/less/js/dist/less-1.5.0.js +6914 -0
- data/lib/less/js/dist/less-1.5.0.min.js +13 -0
- data/lib/less/js/dist/less-1.5.1.js +6941 -0
- data/lib/less/js/dist/less-1.5.1.min.js +13 -0
- data/lib/less/js/dist/less-1.6.0.js +7485 -0
- data/lib/less/js/dist/less-1.6.0.min.js +16 -0
- data/lib/less/js/dist/less-1.6.1.js +7513 -0
- data/lib/less/js/dist/less-1.6.1.min.js +16 -0
- data/lib/less/js/dist/less-1.6.2.js +7624 -0
- data/lib/less/js/dist/less-1.6.2.min.js +16 -0
- data/lib/less/js/dist/less-1.6.3.js +7627 -0
- data/lib/less/js/dist/less-1.6.3.min.js +16 -0
- data/lib/less/js/dist/less-1.7.0.js +7921 -0
- data/lib/less/js/dist/less-1.7.0.min.js +16 -0
- data/lib/less/js/dist/less-rhino-1.3.1.js +3725 -0
- data/lib/less/js/dist/less-rhino-1.3.2.js +3990 -0
- data/lib/less/js/dist/less-rhino-1.3.3.js +4002 -0
- data/lib/less/js/dist/less-rhino-1.4.0.js +4273 -0
- data/lib/less/js/dist/less-rhino-1.5.1.js +6831 -0
- data/lib/less/js/dist/less-rhino-1.6.2.js +9017 -0
- data/lib/less/js/dist/less-rhino-1.6.3.js +9020 -0
- data/lib/less/js/dist/less-rhino-1.7.0.js +9301 -0
- data/lib/less/js/dist/lessc-rhino-1.6.2.js +449 -0
- data/lib/less/js/dist/lessc-rhino-1.6.3.js +449 -0
- data/lib/less/js/dist/lessc-rhino-1.7.0.js +449 -0
- data/lib/less/js/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/lib/less/js/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/lib/less/js/gradlew +164 -0
- data/lib/less/js/gradlew.bat +90 -0
- data/lib/less/js/lib/less/browser.js +547 -250
- data/lib/less/js/lib/less/encoder.js +4 -0
- data/lib/less/js/lib/less/env.js +136 -0
- data/lib/less/js/lib/less/extend-visitor.js +416 -0
- data/lib/less/js/lib/less/functions.js +576 -36
- data/lib/less/js/lib/less/import-visitor.js +142 -0
- data/lib/less/js/lib/less/index.js +187 -83
- data/lib/less/js/lib/less/join-selector-visitor.js +44 -0
- data/lib/less/js/lib/less/lessc_helper.js +82 -0
- data/lib/less/js/lib/less/parser.js +1286 -523
- data/lib/less/js/lib/less/rhino.js +415 -29
- data/lib/less/js/lib/less/source-map-output.js +141 -0
- data/lib/less/js/lib/less/to-css-visitor.js +240 -0
- data/lib/less/js/lib/less/tree/alpha.js +17 -5
- data/lib/less/js/lib/less/tree/anonymous.js +25 -4
- data/lib/less/js/lib/less/tree/assignment.js +17 -5
- data/lib/less/js/lib/less/tree/call.js +36 -13
- data/lib/less/js/lib/less/tree/color.js +119 -31
- data/lib/less/js/lib/less/tree/comment.js +18 -4
- data/lib/less/js/lib/less/tree/condition.js +35 -28
- data/lib/less/js/lib/less/tree/detached-ruleset.js +20 -0
- data/lib/less/js/lib/less/tree/dimension.js +291 -16
- data/lib/less/js/lib/less/tree/directive.js +56 -22
- data/lib/less/js/lib/less/tree/element.js +78 -17
- data/lib/less/js/lib/less/tree/expression.js +39 -8
- data/lib/less/js/lib/less/tree/extend.js +53 -0
- data/lib/less/js/lib/less/tree/import.js +81 -36
- data/lib/less/js/lib/less/tree/javascript.js +17 -10
- data/lib/less/js/lib/less/tree/keyword.js +8 -3
- data/lib/less/js/lib/less/tree/media.js +70 -27
- data/lib/less/js/lib/less/tree/mixin.js +250 -70
- data/lib/less/js/lib/less/tree/negative.js +24 -0
- data/lib/less/js/lib/less/tree/operation.js +38 -13
- data/lib/less/js/lib/less/tree/paren.js +9 -2
- data/lib/less/js/lib/less/tree/quoted.js +29 -10
- data/lib/less/js/lib/less/tree/rule.js +77 -29
- data/lib/less/js/lib/less/tree/ruleset-call.js +16 -0
- data/lib/less/js/lib/less/tree/ruleset.js +445 -107
- data/lib/less/js/lib/less/tree/selector.js +117 -30
- data/lib/less/js/lib/less/tree/unicode-descriptor.js +15 -0
- data/lib/less/js/lib/less/tree/url.js +43 -15
- data/lib/less/js/lib/less/tree/value.js +16 -6
- data/lib/less/js/lib/less/tree/variable.js +26 -8
- data/lib/less/js/lib/less/tree.js +82 -2
- data/lib/less/js/lib/less/visitor.js +146 -0
- data/lib/less/js/lib/source-map/source-map-0.1.31.js +1933 -0
- data/lib/less/js/lib/source-map/source-map-footer.js +4 -0
- data/lib/less/js/lib/source-map/source-map-header.js +3 -0
- data/lib/less/js/package.json +86 -11
- data/lib/less/js/test/browser/common.js +201 -0
- data/lib/less/js/test/browser/css/global-vars/simple.css +3 -0
- data/lib/less/js/test/browser/css/modify-vars/simple.css +8 -0
- data/lib/less/js/test/browser/css/postProcessor/postProcessor.css +4 -0
- data/lib/less/js/test/browser/css/relative-urls/urls.css +35 -0
- data/lib/less/js/test/browser/css/rootpath/urls.css +35 -0
- data/lib/less/js/test/browser/css/rootpath-relative/urls.css +35 -0
- data/lib/less/js/test/browser/css/urls.css +53 -0
- data/lib/less/js/test/browser/es5.js +27 -0
- data/lib/less/js/test/browser/jasmine-html.js +681 -0
- data/lib/less/js/test/browser/jasmine.css +82 -0
- data/lib/less/js/test/browser/jasmine.js +2600 -0
- data/lib/less/js/test/browser/less/console-errors/test-error.less +3 -0
- data/lib/less/js/test/browser/less/console-errors/test-error.txt +2 -0
- data/lib/less/js/test/browser/less/global-vars/simple.less +3 -0
- data/lib/less/js/test/browser/less/imports/urls.less +4 -0
- data/lib/less/js/test/browser/less/imports/urls2.less +4 -0
- data/lib/less/js/test/browser/less/modify-vars/imports/simple2.less +4 -0
- data/lib/less/js/test/browser/less/modify-vars/simple.less +8 -0
- data/lib/less/js/test/browser/less/postProcessor/postProcessor.less +4 -0
- data/lib/less/js/test/browser/less/relative-urls/urls.less +33 -0
- data/lib/less/js/test/browser/less/rootpath/urls.less +33 -0
- data/lib/less/js/test/browser/less/rootpath-relative/urls.less +33 -0
- data/lib/less/js/test/browser/less/urls.less +57 -0
- data/lib/less/js/test/browser/phantom-runner.js +150 -0
- data/lib/less/js/test/browser/runner-browser-options.js +42 -0
- data/lib/less/js/test/browser/runner-browser-spec.js +12 -0
- data/lib/less/js/test/browser/runner-console-errors.js +5 -0
- data/lib/less/js/test/browser/runner-errors-options.js +5 -0
- data/lib/less/js/test/browser/runner-errors-spec.js +4 -0
- data/lib/less/js/test/browser/runner-global-vars-options.js +4 -0
- data/lib/less/js/test/browser/runner-global-vars-spec.js +3 -0
- data/lib/less/js/test/browser/runner-legacy-options.js +4 -0
- data/lib/less/js/test/browser/runner-legacy-spec.js +3 -0
- data/lib/less/js/test/browser/runner-main-options.js +15 -0
- data/lib/less/js/test/browser/runner-main-spec.js +3 -0
- data/lib/less/js/test/browser/runner-modify-vars-options.js +2 -0
- data/lib/less/js/test/browser/runner-modify-vars-spec.js +43 -0
- data/lib/less/js/test/browser/runner-no-js-errors-options.js +4 -0
- data/lib/less/js/test/browser/runner-no-js-errors-spec.js +4 -0
- data/lib/less/js/test/browser/runner-postProcessor-options.js +4 -0
- data/lib/less/js/test/browser/runner-postProcessor.js +3 -0
- data/lib/less/js/test/browser/runner-production-options.js +3 -0
- data/lib/less/js/test/browser/runner-production-spec.js +5 -0
- data/lib/less/js/test/browser/runner-relative-urls-options.js +3 -0
- data/lib/less/js/test/browser/runner-relative-urls-spec.js +3 -0
- data/lib/less/js/test/browser/runner-rootpath-options.js +3 -0
- data/lib/less/js/test/browser/runner-rootpath-relative-options.js +4 -0
- data/lib/less/js/test/browser/runner-rootpath-relative-spec.js +3 -0
- data/lib/less/js/test/browser/runner-rootpath-spec.js +3 -0
- data/lib/less/js/test/browser/test-runner-template.tmpl +47 -0
- data/lib/less/js/test/css/charsets.css +1 -0
- data/lib/less/js/test/css/colors.css +29 -0
- data/lib/less/js/test/css/comments.css +15 -2
- data/lib/less/js/test/css/compression/compression.css +3 -0
- data/lib/less/js/test/css/css-3.css +73 -2
- data/lib/less/js/test/css/css-escapes.css +4 -0
- data/lib/less/js/test/css/css-guards.css +37 -0
- data/lib/less/js/test/css/css.css +20 -14
- data/lib/less/js/test/css/debug/linenumbers-all.css +49 -0
- data/lib/less/js/test/css/debug/linenumbers-comments.css +40 -0
- data/lib/less/js/test/css/debug/linenumbers-mediaquery.css +40 -0
- data/lib/less/js/test/css/detached-rulesets.css +71 -0
- data/lib/less/js/test/css/empty.css +0 -0
- data/lib/less/js/test/css/extend-chaining.css +81 -0
- data/lib/less/js/test/css/extend-clearfix.css +19 -0
- data/lib/less/js/test/css/extend-exact.css +37 -0
- data/lib/less/js/test/css/extend-media.css +24 -0
- data/lib/less/js/test/css/extend-nest.css +57 -0
- data/lib/less/js/test/css/extend-selector.css +80 -0
- data/lib/less/js/test/css/extend.css +76 -0
- data/lib/less/js/test/css/extract-and-length.css +133 -0
- data/lib/less/js/test/css/functions.css +117 -2
- data/lib/less/js/test/css/globalVars/extended.css +12 -0
- data/lib/less/js/test/css/globalVars/simple.css +6 -0
- data/lib/less/js/test/css/ie-filters.css +7 -3
- data/lib/less/js/test/css/import-inline.css +5 -0
- data/lib/less/js/test/css/import-interpolation.css +6 -0
- data/lib/less/js/test/css/import-once.css +15 -0
- data/lib/less/js/test/css/import-reference.css +68 -0
- data/lib/less/js/test/css/import.css +23 -10
- data/lib/less/js/test/css/javascript.css +3 -2
- data/lib/less/js/test/css/legacy/legacy.css +7 -0
- data/lib/less/js/test/css/media.css +141 -1
- data/lib/less/js/test/css/merge.css +34 -0
- data/lib/less/js/test/css/mixins-args.css +41 -4
- data/lib/less/js/test/css/mixins-guards-default-func.css +129 -0
- data/lib/less/js/test/css/mixins-guards.css +24 -0
- data/lib/less/js/test/css/mixins-important.css +28 -0
- data/lib/less/js/test/css/mixins-interpolated.css +39 -0
- data/lib/less/js/test/css/mixins-named-args.css +27 -0
- data/lib/less/js/test/css/mixins-pattern.css +4 -0
- data/lib/less/js/test/css/mixins.css +70 -0
- data/lib/less/js/test/css/modifyVars/extended.css +9 -0
- data/lib/less/js/test/css/no-output.css +0 -0
- data/lib/less/js/test/css/parens.css +21 -5
- data/lib/less/js/test/css/property-name-interp.css +20 -0
- data/lib/less/js/test/css/scope.css +23 -0
- data/lib/less/js/test/css/selectors.css +84 -0
- data/lib/less/js/test/css/static-urls/urls.css +45 -0
- data/lib/less/js/test/css/strings.css +5 -2
- data/lib/less/js/test/css/url-args/urls.css +56 -0
- data/lib/less/js/test/css/urls.css +71 -0
- data/lib/less/js/test/css/variables-in-at-rules.css +18 -0
- data/lib/less/js/test/css/variables.css +22 -4
- data/lib/less/js/test/css/whitespace.css +4 -0
- data/lib/less/js/test/data/data-uri-fail.png +0 -0
- data/lib/less/js/test/data/image.jpg +1 -0
- data/lib/less/js/test/data/page.html +1 -0
- data/lib/less/js/test/index.js +45 -0
- data/lib/less/js/test/less/charsets.less +3 -0
- data/lib/less/js/test/less/colors.less +37 -4
- data/lib/less/js/test/less/comments.less +21 -3
- data/lib/less/js/test/less/compression/compression.less +36 -0
- data/lib/less/js/test/less/css-3.less +70 -6
- data/lib/less/js/test/less/css-escapes.less +6 -1
- data/lib/less/js/test/less/css-guards.less +102 -0
- data/lib/less/js/test/less/css.less +23 -15
- data/lib/less/js/test/less/debug/import/test.less +25 -0
- data/lib/less/js/test/less/debug/linenumbers.less +33 -0
- data/lib/less/js/test/less/detached-rulesets.less +103 -0
- data/lib/less/js/test/less/empty.less +0 -0
- data/lib/less/js/test/less/errors/add-mixed-units.less +3 -0
- data/lib/less/js/test/less/errors/add-mixed-units.txt +4 -0
- data/lib/less/js/test/less/errors/add-mixed-units2.less +3 -0
- data/lib/less/js/test/less/errors/add-mixed-units2.txt +4 -0
- data/lib/less/js/test/less/errors/at-rules-undefined-var.less +4 -0
- data/lib/less/js/test/less/errors/at-rules-undefined-var.txt +4 -0
- data/lib/less/js/test/less/errors/bad-variable-declaration1.less +1 -0
- data/lib/less/js/test/less/errors/bad-variable-declaration1.txt +2 -0
- data/lib/less/js/test/less/errors/color-func-invalid-color.less +3 -0
- data/lib/less/js/test/less/errors/color-func-invalid-color.txt +4 -0
- data/lib/less/js/test/less/errors/comment-in-selector.less +1 -0
- data/lib/less/js/test/less/errors/comment-in-selector.txt +2 -0
- data/lib/less/js/test/less/errors/css-guard-default-func.less +4 -0
- data/lib/less/js/test/less/errors/css-guard-default-func.txt +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-1.less +6 -0
- data/lib/less/js/test/less/errors/detached-ruleset-1.txt +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-2.less +6 -0
- data/lib/less/js/test/less/errors/detached-ruleset-2.txt +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-3.less +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-3.txt +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-4.less +5 -0
- data/lib/less/js/test/less/errors/detached-ruleset-4.txt +3 -0
- data/lib/less/js/test/less/errors/detached-ruleset-5.less +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-5.txt +3 -0
- data/lib/less/js/test/less/errors/detached-ruleset-6.less +5 -0
- data/lib/less/js/test/less/errors/detached-ruleset-6.txt +4 -0
- data/lib/less/js/test/less/errors/divide-mixed-units.less +3 -0
- data/lib/less/js/test/less/errors/divide-mixed-units.txt +4 -0
- data/lib/less/js/test/less/errors/extend-no-selector.less +3 -0
- data/lib/less/js/test/less/errors/extend-no-selector.txt +3 -0
- data/lib/less/js/test/less/errors/extend-not-at-end.less +3 -0
- data/lib/less/js/test/less/errors/extend-not-at-end.txt +3 -0
- data/lib/less/js/test/less/errors/import-missing.less +6 -0
- data/lib/less/js/test/less/errors/import-missing.txt +3 -0
- data/lib/less/js/test/less/errors/import-no-semi.less +1 -0
- data/lib/less/js/test/less/errors/import-no-semi.txt +2 -0
- data/lib/less/js/test/less/errors/import-subfolder1.less +1 -0
- data/lib/less/js/test/less/errors/import-subfolder1.txt +3 -0
- data/lib/less/js/test/less/errors/import-subfolder2.less +1 -0
- data/lib/less/js/test/less/errors/import-subfolder2.txt +4 -0
- data/lib/less/js/test/less/errors/imports/import-subfolder1.less +1 -0
- data/lib/less/js/test/less/errors/imports/import-subfolder2.less +1 -0
- data/lib/less/js/test/less/errors/imports/import-test.less +4 -0
- data/lib/less/js/test/less/errors/imports/subfolder/mixin-not-defined.less +1 -0
- data/lib/less/js/test/less/errors/imports/subfolder/parse-error-curly-bracket.less +1 -0
- data/lib/less/js/test/less/errors/javascript-error.less +3 -0
- data/lib/less/js/test/less/errors/javascript-error.txt +4 -0
- data/lib/less/js/test/less/errors/javascript-undefined-var.less +3 -0
- data/lib/less/js/test/less/errors/javascript-undefined-var.txt +4 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-1.less +6 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-1.txt +4 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-2.less +6 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-2.txt +4 -0
- data/lib/less/js/test/less/errors/mixin-not-defined.less +11 -0
- data/lib/less/js/test/less/errors/mixin-not-defined.txt +3 -0
- data/lib/less/js/test/less/errors/mixin-not-matched.less +6 -0
- data/lib/less/js/test/less/errors/mixin-not-matched.txt +3 -0
- data/lib/less/js/test/less/errors/mixin-not-matched2.less +6 -0
- data/lib/less/js/test/less/errors/mixin-not-matched2.txt +3 -0
- data/lib/less/js/test/less/errors/mixin-not-visible-in-scope-1.less +9 -0
- data/lib/less/js/test/less/errors/mixin-not-visible-in-scope-1.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-1.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-1.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-2.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-2.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-3.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-3.txt +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors.less +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors.txt +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors2.less +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors2.txt +4 -0
- data/lib/less/js/test/less/errors/multiply-mixed-units.less +7 -0
- data/lib/less/js/test/less/errors/multiply-mixed-units.txt +4 -0
- data/lib/less/js/test/less/errors/parens-error-1.less +3 -0
- data/lib/less/js/test/less/errors/parens-error-1.txt +4 -0
- data/lib/less/js/test/less/errors/parens-error-2.less +3 -0
- data/lib/less/js/test/less/errors/parens-error-2.txt +4 -0
- data/lib/less/js/test/less/errors/parens-error-3.less +3 -0
- data/lib/less/js/test/less/errors/parens-error-3.txt +4 -0
- data/lib/less/js/test/less/errors/parse-error-curly-bracket.less +4 -0
- data/lib/less/js/test/less/errors/parse-error-curly-bracket.txt +4 -0
- data/lib/less/js/test/less/errors/parse-error-extra-parens.less +5 -0
- data/lib/less/js/test/less/errors/parse-error-extra-parens.txt +3 -0
- data/lib/less/js/test/less/errors/parse-error-missing-bracket.less +2 -0
- data/lib/less/js/test/less/errors/parse-error-missing-bracket.txt +3 -0
- data/lib/less/js/test/less/errors/parse-error-missing-parens.less +5 -0
- data/lib/less/js/test/less/errors/parse-error-missing-parens.txt +3 -0
- data/lib/less/js/test/less/errors/parse-error-with-import.less +13 -0
- data/lib/less/js/test/less/errors/parse-error-with-import.txt +4 -0
- data/lib/less/js/test/less/errors/percentage-missing-space.less +3 -0
- data/lib/less/js/test/less/errors/percentage-missing-space.txt +4 -0
- data/lib/less/js/test/less/errors/property-asterisk-only-name.less +3 -0
- data/lib/less/js/test/less/errors/property-asterisk-only-name.txt +4 -0
- data/lib/less/js/test/less/errors/property-ie5-hack.less +3 -0
- data/lib/less/js/test/less/errors/property-ie5-hack.txt +4 -0
- data/lib/less/js/test/less/errors/property-in-root.less +4 -0
- data/lib/less/js/test/less/errors/property-in-root.txt +4 -0
- data/lib/less/js/test/less/errors/property-in-root2.less +1 -0
- data/lib/less/js/test/less/errors/property-in-root2.txt +4 -0
- data/lib/less/js/test/less/errors/property-in-root3.less +4 -0
- data/lib/less/js/test/less/errors/property-in-root3.txt +3 -0
- data/lib/less/js/test/less/errors/property-interp-not-defined.less +1 -0
- data/lib/less/js/test/less/errors/property-interp-not-defined.txt +2 -0
- data/lib/less/js/test/less/errors/recursive-variable.less +1 -0
- data/lib/less/js/test/less/errors/recursive-variable.txt +2 -0
- data/lib/less/js/test/less/errors/svg-gradient1.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient1.txt +4 -0
- data/lib/less/js/test/less/errors/svg-gradient2.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient2.txt +4 -0
- data/lib/less/js/test/less/errors/svg-gradient3.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient3.txt +4 -0
- data/lib/less/js/test/less/errors/unit-function.less +3 -0
- data/lib/less/js/test/less/errors/unit-function.txt +4 -0
- data/lib/less/js/test/less/extend-chaining.less +91 -0
- data/lib/less/js/test/less/extend-clearfix.less +19 -0
- data/lib/less/js/test/less/extend-exact.less +46 -0
- data/lib/less/js/test/less/extend-media.less +24 -0
- data/lib/less/js/test/less/extend-nest.less +65 -0
- data/lib/less/js/test/less/extend-selector.less +99 -0
- data/lib/less/js/test/less/extend.less +81 -0
- data/lib/less/js/test/less/extract-and-length.less +133 -0
- data/lib/less/js/test/less/functions.less +130 -6
- data/lib/less/js/test/less/globalVars/extended.json +5 -0
- data/lib/less/js/test/less/globalVars/extended.less +10 -0
- data/lib/less/js/test/less/globalVars/simple.json +3 -0
- data/lib/less/js/test/less/globalVars/simple.less +3 -0
- data/lib/less/js/test/less/ie-filters.less +7 -0
- data/lib/less/js/test/less/import/deeper/import-once-test-a.less +1 -0
- data/lib/less/js/test/less/import/import-and-relative-paths-test.less +17 -0
- data/lib/less/js/test/less/import/import-charset-test.less +1 -0
- data/lib/less/js/test/less/import/import-interpolation.less +1 -0
- data/lib/less/js/test/less/import/import-interpolation2.less +5 -0
- data/lib/less/js/test/less/import/import-once-test-c.less +6 -0
- data/lib/less/js/test/less/import/import-reference.less +51 -0
- data/lib/less/js/test/less/import/import-test-a.less +1 -0
- data/lib/less/js/test/less/import/import-test-c.less +0 -1
- data/lib/less/js/test/less/import/import-test-f.less +5 -0
- data/lib/less/js/test/less/import/imports/font.less +8 -0
- data/lib/less/js/test/less/import/imports/logo.less +5 -0
- data/lib/less/js/test/less/import/invalid-css.less +1 -0
- data/lib/less/js/test/less/import/urls.less +1 -0
- data/lib/less/js/test/less/import-inline.less +2 -0
- data/lib/less/js/test/less/import-interpolation.less +8 -0
- data/lib/less/js/test/less/import-once.less +6 -0
- data/lib/less/js/test/less/import-reference.less +21 -0
- data/lib/less/js/test/less/import.less +13 -3
- data/lib/less/js/test/less/javascript.less +5 -3
- data/lib/less/js/test/less/legacy/legacy.less +7 -0
- data/lib/less/js/test/less/media.less +158 -3
- data/lib/less/js/test/less/merge.less +78 -0
- data/lib/less/js/test/less/mixins-args.less +93 -15
- data/lib/less/js/test/less/mixins-guards-default-func.less +195 -0
- data/lib/less/js/test/less/mixins-guards.less +65 -0
- data/lib/less/js/test/less/mixins-important.less +8 -1
- data/lib/less/js/test/less/mixins-interpolated.less +69 -0
- data/lib/less/js/test/less/mixins-named-args.less +36 -0
- data/lib/less/js/test/less/mixins-nested.less +2 -2
- data/lib/less/js/test/less/mixins-pattern.less +4 -1
- data/lib/less/js/test/less/mixins.less +74 -0
- data/lib/less/js/test/less/modifyVars/extended.json +5 -0
- data/lib/less/js/test/less/modifyVars/extended.less +11 -0
- data/lib/less/js/test/less/no-js-errors/no-js-errors.less +3 -0
- data/lib/less/js/test/less/no-js-errors/no-js-errors.txt +4 -0
- data/lib/less/js/test/less/no-output.less +2 -0
- data/lib/less/js/test/less/operations.less +27 -27
- data/lib/less/js/test/less/parens.less +24 -5
- data/lib/less/js/test/less/property-name-interp.less +53 -0
- data/lib/less/js/test/less/scope.less +73 -1
- data/lib/less/js/test/less/selectors.less +101 -0
- data/lib/less/js/test/less/sourcemaps/basic.json +3 -0
- data/lib/less/js/test/less/sourcemaps/basic.less +27 -0
- data/lib/less/js/test/less/sourcemaps/imported.css +7 -0
- data/lib/less/js/test/less/static-urls/urls.less +33 -0
- data/lib/less/js/test/less/strings.less +7 -1
- data/lib/less/js/test/less/url-args/urls.less +63 -0
- data/lib/less/js/test/less/urls.less +72 -0
- data/lib/less/js/test/less/variables-in-at-rules.less +20 -0
- data/lib/less/js/test/less/variables.less +42 -13
- data/lib/less/js/test/less/whitespace.less +7 -0
- data/lib/less/js/test/less-test.js +251 -65
- data/lib/less/js/test/rhino/test-header.js +15 -0
- data/lib/less/js/test/sourcemaps/basic.json +1 -0
- data/lib/less/js/test/sourcemaps/index.html +17 -0
- data/lib/less/loader.rb +191 -27
- data/lib/less/parser.rb +47 -8
- data/lib/less/version.rb +2 -2
- data/spec/less/loader_spec.rb +45 -0
- data/spec/less/parser_spec.rb +43 -17
- data/spec/less/some/some.css +0 -0
- data/spec/less/some/some.less +4 -0
- metadata +352 -57
- data/lib/less/js/CHANGELOG +0 -41
- data/lib/less/js/Makefile +0 -75
- data/lib/less/js/build/ecma-5.js +0 -120
- data/lib/less/js/build/header.js +0 -7
- data/lib/less/js/lib/less/cssmin.js +0 -355
|
@@ -5,16 +5,24 @@ tree.functions = {
|
|
|
5
5
|
return this.rgba(r, g, b, 1.0);
|
|
6
6
|
},
|
|
7
7
|
rgba: function (r, g, b, a) {
|
|
8
|
-
var rgb = [r, g, b].map(function (c) { return
|
|
9
|
-
|
|
8
|
+
var rgb = [r, g, b].map(function (c) { return scaled(c, 255); });
|
|
9
|
+
a = number(a);
|
|
10
10
|
return new(tree.Color)(rgb, a);
|
|
11
11
|
},
|
|
12
12
|
hsl: function (h, s, l) {
|
|
13
13
|
return this.hsla(h, s, l, 1.0);
|
|
14
14
|
},
|
|
15
15
|
hsla: function (h, s, l, a) {
|
|
16
|
+
function hue(h) {
|
|
17
|
+
h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
|
|
18
|
+
if (h * 6 < 1) { return m1 + (m2 - m1) * h * 6; }
|
|
19
|
+
else if (h * 2 < 1) { return m2; }
|
|
20
|
+
else if (h * 3 < 2) { return m1 + (m2 - m1) * (2/3 - h) * 6; }
|
|
21
|
+
else { return m1; }
|
|
22
|
+
}
|
|
23
|
+
|
|
16
24
|
h = (number(h) % 360) / 360;
|
|
17
|
-
s = number(s); l = number(l); a = number(a);
|
|
25
|
+
s = clamp(number(s)); l = clamp(number(l)); a = clamp(number(a));
|
|
18
26
|
|
|
19
27
|
var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
|
|
20
28
|
var m1 = l * 2 - m2;
|
|
@@ -23,15 +31,37 @@ tree.functions = {
|
|
|
23
31
|
hue(h) * 255,
|
|
24
32
|
hue(h - 1/3) * 255,
|
|
25
33
|
a);
|
|
34
|
+
},
|
|
26
35
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
hsv: function(h, s, v) {
|
|
37
|
+
return this.hsva(h, s, v, 1.0);
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
hsva: function(h, s, v, a) {
|
|
41
|
+
h = ((number(h) % 360) / 360) * 360;
|
|
42
|
+
s = number(s); v = number(v); a = number(a);
|
|
43
|
+
|
|
44
|
+
var i, f;
|
|
45
|
+
i = Math.floor((h / 60) % 6);
|
|
46
|
+
f = (h / 60) - i;
|
|
47
|
+
|
|
48
|
+
var vs = [v,
|
|
49
|
+
v * (1 - s),
|
|
50
|
+
v * (1 - f * s),
|
|
51
|
+
v * (1 - (1 - f) * s)];
|
|
52
|
+
var perm = [[0, 3, 1],
|
|
53
|
+
[2, 0, 1],
|
|
54
|
+
[1, 0, 3],
|
|
55
|
+
[1, 2, 0],
|
|
56
|
+
[3, 1, 0],
|
|
57
|
+
[0, 1, 2]];
|
|
58
|
+
|
|
59
|
+
return this.rgba(vs[perm[i][0]] * 255,
|
|
60
|
+
vs[perm[i][1]] * 255,
|
|
61
|
+
vs[perm[i][2]] * 255,
|
|
62
|
+
a);
|
|
34
63
|
},
|
|
64
|
+
|
|
35
65
|
hue: function (color) {
|
|
36
66
|
return new(tree.Dimension)(Math.round(color.toHSL().h));
|
|
37
67
|
},
|
|
@@ -41,10 +71,44 @@ tree.functions = {
|
|
|
41
71
|
lightness: function (color) {
|
|
42
72
|
return new(tree.Dimension)(Math.round(color.toHSL().l * 100), '%');
|
|
43
73
|
},
|
|
74
|
+
hsvhue: function(color) {
|
|
75
|
+
return new(tree.Dimension)(Math.round(color.toHSV().h));
|
|
76
|
+
},
|
|
77
|
+
hsvsaturation: function (color) {
|
|
78
|
+
return new(tree.Dimension)(Math.round(color.toHSV().s * 100), '%');
|
|
79
|
+
},
|
|
80
|
+
hsvvalue: function (color) {
|
|
81
|
+
return new(tree.Dimension)(Math.round(color.toHSV().v * 100), '%');
|
|
82
|
+
},
|
|
83
|
+
red: function (color) {
|
|
84
|
+
return new(tree.Dimension)(color.rgb[0]);
|
|
85
|
+
},
|
|
86
|
+
green: function (color) {
|
|
87
|
+
return new(tree.Dimension)(color.rgb[1]);
|
|
88
|
+
},
|
|
89
|
+
blue: function (color) {
|
|
90
|
+
return new(tree.Dimension)(color.rgb[2]);
|
|
91
|
+
},
|
|
44
92
|
alpha: function (color) {
|
|
45
93
|
return new(tree.Dimension)(color.toHSL().a);
|
|
46
94
|
},
|
|
95
|
+
luma: function (color) {
|
|
96
|
+
return new(tree.Dimension)(Math.round(color.luma() * color.alpha * 100), '%');
|
|
97
|
+
},
|
|
98
|
+
luminance: function (color) {
|
|
99
|
+
var luminance =
|
|
100
|
+
(0.2126 * color.rgb[0] / 255)
|
|
101
|
+
+ (0.7152 * color.rgb[1] / 255)
|
|
102
|
+
+ (0.0722 * color.rgb[2] / 255);
|
|
103
|
+
|
|
104
|
+
return new(tree.Dimension)(Math.round(luminance * color.alpha * 100), '%');
|
|
105
|
+
},
|
|
47
106
|
saturate: function (color, amount) {
|
|
107
|
+
// filter: saturate(3.2);
|
|
108
|
+
// should be kept as is, so check for color
|
|
109
|
+
if (!color.rgb) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
48
112
|
var hsl = color.toHSL();
|
|
49
113
|
|
|
50
114
|
hsl.s += amount.value / 100;
|
|
@@ -106,6 +170,9 @@ tree.functions = {
|
|
|
106
170
|
// http://sass-lang.com
|
|
107
171
|
//
|
|
108
172
|
mix: function (color1, color2, weight) {
|
|
173
|
+
if (!weight) {
|
|
174
|
+
weight = new(tree.Dimension)(50);
|
|
175
|
+
}
|
|
109
176
|
var p = weight.value / 100.0;
|
|
110
177
|
var w = p * 2 - 1;
|
|
111
178
|
var a = color1.toHSL().a - color2.toHSL().a;
|
|
@@ -124,53 +191,168 @@ tree.functions = {
|
|
|
124
191
|
greyscale: function (color) {
|
|
125
192
|
return this.desaturate(color, new(tree.Dimension)(100));
|
|
126
193
|
},
|
|
194
|
+
contrast: function (color, dark, light, threshold) {
|
|
195
|
+
// filter: contrast(3.2);
|
|
196
|
+
// should be kept as is, so check for color
|
|
197
|
+
if (!color.rgb) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
if (typeof light === 'undefined') {
|
|
201
|
+
light = this.rgba(255, 255, 255, 1.0);
|
|
202
|
+
}
|
|
203
|
+
if (typeof dark === 'undefined') {
|
|
204
|
+
dark = this.rgba(0, 0, 0, 1.0);
|
|
205
|
+
}
|
|
206
|
+
//Figure out which is actually light and dark!
|
|
207
|
+
if (dark.luma() > light.luma()) {
|
|
208
|
+
var t = light;
|
|
209
|
+
light = dark;
|
|
210
|
+
dark = t;
|
|
211
|
+
}
|
|
212
|
+
if (typeof threshold === 'undefined') {
|
|
213
|
+
threshold = 0.43;
|
|
214
|
+
} else {
|
|
215
|
+
threshold = number(threshold);
|
|
216
|
+
}
|
|
217
|
+
if (color.luma() < threshold) {
|
|
218
|
+
return light;
|
|
219
|
+
} else {
|
|
220
|
+
return dark;
|
|
221
|
+
}
|
|
222
|
+
},
|
|
127
223
|
e: function (str) {
|
|
128
224
|
return new(tree.Anonymous)(str instanceof tree.JavaScript ? str.evaluated : str);
|
|
129
225
|
},
|
|
130
226
|
escape: function (str) {
|
|
131
227
|
return new(tree.Anonymous)(encodeURI(str.value).replace(/=/g, "%3D").replace(/:/g, "%3A").replace(/#/g, "%23").replace(/;/g, "%3B").replace(/\(/g, "%28").replace(/\)/g, "%29"));
|
|
132
228
|
},
|
|
133
|
-
|
|
229
|
+
replace: function (string, pattern, replacement, flags) {
|
|
230
|
+
var result = string.value;
|
|
231
|
+
|
|
232
|
+
result = result.replace(new RegExp(pattern.value, flags ? flags.value : ''), replacement.value);
|
|
233
|
+
return new(tree.Quoted)(string.quote || '', result, string.escaped);
|
|
234
|
+
},
|
|
235
|
+
'%': function (string /* arg, arg, ...*/) {
|
|
134
236
|
var args = Array.prototype.slice.call(arguments, 1),
|
|
135
|
-
|
|
237
|
+
result = string.value;
|
|
136
238
|
|
|
137
239
|
for (var i = 0; i < args.length; i++) {
|
|
138
|
-
|
|
240
|
+
/*jshint loopfunc:true */
|
|
241
|
+
result = result.replace(/%[sda]/i, function(token) {
|
|
139
242
|
var value = token.match(/s/i) ? args[i].value : args[i].toCSS();
|
|
140
243
|
return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value;
|
|
141
244
|
});
|
|
142
245
|
}
|
|
143
|
-
|
|
144
|
-
return new(tree.Quoted)(
|
|
246
|
+
result = result.replace(/%%/g, '%');
|
|
247
|
+
return new(tree.Quoted)(string.quote || '', result, string.escaped);
|
|
145
248
|
},
|
|
146
|
-
|
|
147
|
-
|
|
249
|
+
unit: function (val, unit) {
|
|
250
|
+
if(!(val instanceof tree.Dimension)) {
|
|
251
|
+
throw { type: "Argument", message: "the first argument to unit must be a number" + (val instanceof tree.Operation ? ". Have you forgotten parenthesis?" : "") };
|
|
252
|
+
}
|
|
253
|
+
if (unit) {
|
|
254
|
+
if (unit instanceof tree.Keyword) {
|
|
255
|
+
unit = unit.value;
|
|
256
|
+
} else {
|
|
257
|
+
unit = unit.toCSS();
|
|
258
|
+
}
|
|
259
|
+
} else {
|
|
260
|
+
unit = "";
|
|
261
|
+
}
|
|
262
|
+
return new(tree.Dimension)(val.value, unit);
|
|
148
263
|
},
|
|
149
|
-
|
|
150
|
-
return
|
|
264
|
+
convert: function (val, unit) {
|
|
265
|
+
return val.convertTo(unit.value);
|
|
151
266
|
},
|
|
152
|
-
|
|
153
|
-
|
|
267
|
+
round: function (n, f) {
|
|
268
|
+
var fraction = typeof(f) === "undefined" ? 0 : f.value;
|
|
269
|
+
return _math(function(num) { return num.toFixed(fraction); }, null, n);
|
|
154
270
|
},
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
271
|
+
pi: function () {
|
|
272
|
+
return new(tree.Dimension)(Math.PI);
|
|
273
|
+
},
|
|
274
|
+
mod: function(a, b) {
|
|
275
|
+
return new(tree.Dimension)(a.value % b.value, a.unit);
|
|
276
|
+
},
|
|
277
|
+
pow: function(x, y) {
|
|
278
|
+
if (typeof x === "number" && typeof y === "number") {
|
|
279
|
+
x = new(tree.Dimension)(x);
|
|
280
|
+
y = new(tree.Dimension)(y);
|
|
281
|
+
} else if (!(x instanceof tree.Dimension) || !(y instanceof tree.Dimension)) {
|
|
282
|
+
throw { type: "Argument", message: "arguments must be numbers" };
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return new(tree.Dimension)(Math.pow(x.value, y.value), x.unit);
|
|
286
|
+
},
|
|
287
|
+
_minmax: function (isMin, args) {
|
|
288
|
+
args = Array.prototype.slice.call(args);
|
|
289
|
+
switch(args.length) {
|
|
290
|
+
case 0: throw { type: "Argument", message: "one or more arguments required" };
|
|
291
|
+
}
|
|
292
|
+
var i, j, current, currentUnified, referenceUnified, unit, unitStatic, unitClone,
|
|
293
|
+
order = [], // elems only contains original argument values.
|
|
294
|
+
values = {}; // key is the unit.toString() for unified tree.Dimension values,
|
|
295
|
+
// value is the index into the order array.
|
|
296
|
+
for (i = 0; i < args.length; i++) {
|
|
297
|
+
current = args[i];
|
|
298
|
+
if (!(current instanceof tree.Dimension)) {
|
|
299
|
+
if(Array.isArray(args[i].value)) {
|
|
300
|
+
Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value));
|
|
301
|
+
}
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
currentUnified = current.unit.toString() === "" && unitClone !== undefined ? new(tree.Dimension)(current.value, unitClone).unify() : current.unify();
|
|
305
|
+
unit = currentUnified.unit.toString() === "" && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString();
|
|
306
|
+
unitStatic = unit !== "" && unitStatic === undefined || unit !== "" && order[0].unify().unit.toString() === "" ? unit : unitStatic;
|
|
307
|
+
unitClone = unit !== "" && unitClone === undefined ? current.unit.toString() : unitClone;
|
|
308
|
+
j = values[""] !== undefined && unit !== "" && unit === unitStatic ? values[""] : values[unit];
|
|
309
|
+
if (j === undefined) {
|
|
310
|
+
if(unitStatic !== undefined && unit !== unitStatic) {
|
|
311
|
+
throw{ type: "Argument", message: "incompatible types" };
|
|
312
|
+
}
|
|
313
|
+
values[unit] = order.length;
|
|
314
|
+
order.push(current);
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
referenceUnified = order[j].unit.toString() === "" && unitClone !== undefined ? new(tree.Dimension)(order[j].value, unitClone).unify() : order[j].unify();
|
|
318
|
+
if ( isMin && currentUnified.value < referenceUnified.value ||
|
|
319
|
+
!isMin && currentUnified.value > referenceUnified.value) {
|
|
320
|
+
order[j] = current;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (order.length == 1) {
|
|
324
|
+
return order[0];
|
|
162
325
|
}
|
|
326
|
+
args = order.map(function (a) { return a.toCSS(this.env); }).join(this.env.compress ? "," : ", ");
|
|
327
|
+
return new(tree.Anonymous)((isMin ? "min" : "max") + "(" + args + ")");
|
|
328
|
+
},
|
|
329
|
+
min: function () {
|
|
330
|
+
return this._minmax(true, arguments);
|
|
331
|
+
},
|
|
332
|
+
max: function () {
|
|
333
|
+
return this._minmax(false, arguments);
|
|
334
|
+
},
|
|
335
|
+
"get-unit": function (n) {
|
|
336
|
+
return new(tree.Anonymous)(n.unit);
|
|
163
337
|
},
|
|
164
338
|
argb: function (color) {
|
|
165
339
|
return new(tree.Anonymous)(color.toARGB());
|
|
166
|
-
|
|
167
340
|
},
|
|
168
341
|
percentage: function (n) {
|
|
169
342
|
return new(tree.Dimension)(n.value * 100, '%');
|
|
170
343
|
},
|
|
171
344
|
color: function (n) {
|
|
172
345
|
if (n instanceof tree.Quoted) {
|
|
173
|
-
|
|
346
|
+
var colorCandidate = n.value,
|
|
347
|
+
returnColor;
|
|
348
|
+
returnColor = tree.Color.fromKeyword(colorCandidate);
|
|
349
|
+
if (returnColor) {
|
|
350
|
+
return returnColor;
|
|
351
|
+
}
|
|
352
|
+
if (/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/.test(colorCandidate)) {
|
|
353
|
+
return new(tree.Color)(colorCandidate.slice(1));
|
|
354
|
+
}
|
|
355
|
+
throw { type: "Argument", message: "argument must be a color keyword or 3/6 digit hex e.g. #FFF" };
|
|
174
356
|
} else {
|
|
175
357
|
throw { type: "Argument", message: "argument must be a string" };
|
|
176
358
|
}
|
|
@@ -191,26 +373,367 @@ tree.functions = {
|
|
|
191
373
|
return this._isa(n, tree.URL);
|
|
192
374
|
},
|
|
193
375
|
ispixel: function (n) {
|
|
194
|
-
return (n
|
|
376
|
+
return this.isunit(n, 'px');
|
|
195
377
|
},
|
|
196
378
|
ispercentage: function (n) {
|
|
197
|
-
return (n
|
|
379
|
+
return this.isunit(n, '%');
|
|
198
380
|
},
|
|
199
381
|
isem: function (n) {
|
|
200
|
-
return (n
|
|
382
|
+
return this.isunit(n, 'em');
|
|
383
|
+
},
|
|
384
|
+
isunit: function (n, unit) {
|
|
385
|
+
return (n instanceof tree.Dimension) && n.unit.is(unit.value || unit) ? tree.True : tree.False;
|
|
201
386
|
},
|
|
202
387
|
_isa: function (n, Type) {
|
|
203
388
|
return (n instanceof Type) ? tree.True : tree.False;
|
|
389
|
+
},
|
|
390
|
+
tint: function(color, amount) {
|
|
391
|
+
return this.mix(this.rgb(255,255,255), color, amount);
|
|
392
|
+
},
|
|
393
|
+
shade: function(color, amount) {
|
|
394
|
+
return this.mix(this.rgb(0, 0, 0), color, amount);
|
|
395
|
+
},
|
|
396
|
+
extract: function(values, index) {
|
|
397
|
+
index = index.value - 1; // (1-based index)
|
|
398
|
+
// handle non-array values as an array of length 1
|
|
399
|
+
// return 'undefined' if index is invalid
|
|
400
|
+
return Array.isArray(values.value)
|
|
401
|
+
? values.value[index] : Array(values)[index];
|
|
402
|
+
},
|
|
403
|
+
length: function(values) {
|
|
404
|
+
var n = Array.isArray(values.value) ? values.value.length : 1;
|
|
405
|
+
return new tree.Dimension(n);
|
|
406
|
+
},
|
|
407
|
+
|
|
408
|
+
"data-uri": function(mimetypeNode, filePathNode) {
|
|
409
|
+
|
|
410
|
+
if (typeof window !== 'undefined') {
|
|
411
|
+
return new tree.URL(filePathNode || mimetypeNode, this.currentFileInfo).eval(this.env);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
var mimetype = mimetypeNode.value;
|
|
415
|
+
var filePath = (filePathNode && filePathNode.value);
|
|
416
|
+
|
|
417
|
+
var fs = require('fs'),
|
|
418
|
+
path = require('path'),
|
|
419
|
+
useBase64 = false;
|
|
420
|
+
|
|
421
|
+
if (arguments.length < 2) {
|
|
422
|
+
filePath = mimetype;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (this.env.isPathRelative(filePath)) {
|
|
426
|
+
if (this.currentFileInfo.relativeUrls) {
|
|
427
|
+
filePath = path.join(this.currentFileInfo.currentDirectory, filePath);
|
|
428
|
+
} else {
|
|
429
|
+
filePath = path.join(this.currentFileInfo.entryPath, filePath);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// detect the mimetype if not given
|
|
434
|
+
if (arguments.length < 2) {
|
|
435
|
+
var mime;
|
|
436
|
+
try {
|
|
437
|
+
mime = require('mime');
|
|
438
|
+
} catch (ex) {
|
|
439
|
+
mime = tree._mime;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
mimetype = mime.lookup(filePath);
|
|
443
|
+
|
|
444
|
+
// use base 64 unless it's an ASCII or UTF-8 format
|
|
445
|
+
var charset = mime.charsets.lookup(mimetype);
|
|
446
|
+
useBase64 = ['US-ASCII', 'UTF-8'].indexOf(charset) < 0;
|
|
447
|
+
if (useBase64) { mimetype += ';base64'; }
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
useBase64 = /;base64$/.test(mimetype);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
var buf = fs.readFileSync(filePath);
|
|
454
|
+
|
|
455
|
+
// IE8 cannot handle a data-uri larger than 32KB. If this is exceeded
|
|
456
|
+
// and the --ieCompat flag is enabled, return a normal url() instead.
|
|
457
|
+
var DATA_URI_MAX_KB = 32,
|
|
458
|
+
fileSizeInKB = parseInt((buf.length / 1024), 10);
|
|
459
|
+
if (fileSizeInKB >= DATA_URI_MAX_KB) {
|
|
460
|
+
|
|
461
|
+
if (this.env.ieCompat !== false) {
|
|
462
|
+
if (!this.env.silent) {
|
|
463
|
+
console.warn("Skipped data-uri embedding of %s because its size (%dKB) exceeds IE8-safe %dKB!", filePath, fileSizeInKB, DATA_URI_MAX_KB);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return new tree.URL(filePathNode || mimetypeNode, this.currentFileInfo).eval(this.env);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
buf = useBase64 ? buf.toString('base64')
|
|
471
|
+
: encodeURIComponent(buf);
|
|
472
|
+
|
|
473
|
+
var uri = "\"data:" + mimetype + ',' + buf + "\"";
|
|
474
|
+
return new(tree.URL)(new(tree.Anonymous)(uri));
|
|
475
|
+
},
|
|
476
|
+
|
|
477
|
+
"svg-gradient": function(direction) {
|
|
478
|
+
|
|
479
|
+
function throwArgumentDescriptor() {
|
|
480
|
+
throw { type: "Argument", message: "svg-gradient expects direction, start_color [start_position], [color position,]..., end_color [end_position]" };
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
if (arguments.length < 3) {
|
|
484
|
+
throwArgumentDescriptor();
|
|
485
|
+
}
|
|
486
|
+
var stops = Array.prototype.slice.call(arguments, 1),
|
|
487
|
+
gradientDirectionSvg,
|
|
488
|
+
gradientType = "linear",
|
|
489
|
+
rectangleDimension = 'x="0" y="0" width="1" height="1"',
|
|
490
|
+
useBase64 = true,
|
|
491
|
+
renderEnv = {compress: false},
|
|
492
|
+
returner,
|
|
493
|
+
directionValue = direction.toCSS(renderEnv),
|
|
494
|
+
i, color, position, positionValue, alpha;
|
|
495
|
+
|
|
496
|
+
switch (directionValue) {
|
|
497
|
+
case "to bottom":
|
|
498
|
+
gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"';
|
|
499
|
+
break;
|
|
500
|
+
case "to right":
|
|
501
|
+
gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="0%"';
|
|
502
|
+
break;
|
|
503
|
+
case "to bottom right":
|
|
504
|
+
gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="100%"';
|
|
505
|
+
break;
|
|
506
|
+
case "to top right":
|
|
507
|
+
gradientDirectionSvg = 'x1="0%" y1="100%" x2="100%" y2="0%"';
|
|
508
|
+
break;
|
|
509
|
+
case "ellipse":
|
|
510
|
+
case "ellipse at center":
|
|
511
|
+
gradientType = "radial";
|
|
512
|
+
gradientDirectionSvg = 'cx="50%" cy="50%" r="75%"';
|
|
513
|
+
rectangleDimension = 'x="-50" y="-50" width="101" height="101"';
|
|
514
|
+
break;
|
|
515
|
+
default:
|
|
516
|
+
throw { type: "Argument", message: "svg-gradient direction must be 'to bottom', 'to right', 'to bottom right', 'to top right' or 'ellipse at center'" };
|
|
517
|
+
}
|
|
518
|
+
returner = '<?xml version="1.0" ?>' +
|
|
519
|
+
'<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none">' +
|
|
520
|
+
'<' + gradientType + 'Gradient id="gradient" gradientUnits="userSpaceOnUse" ' + gradientDirectionSvg + '>';
|
|
521
|
+
|
|
522
|
+
for (i = 0; i < stops.length; i+= 1) {
|
|
523
|
+
if (stops[i].value) {
|
|
524
|
+
color = stops[i].value[0];
|
|
525
|
+
position = stops[i].value[1];
|
|
526
|
+
} else {
|
|
527
|
+
color = stops[i];
|
|
528
|
+
position = undefined;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
if (!(color instanceof tree.Color) || (!((i === 0 || i+1 === stops.length) && position === undefined) && !(position instanceof tree.Dimension))) {
|
|
532
|
+
throwArgumentDescriptor();
|
|
533
|
+
}
|
|
534
|
+
positionValue = position ? position.toCSS(renderEnv) : i === 0 ? "0%" : "100%";
|
|
535
|
+
alpha = color.alpha;
|
|
536
|
+
returner += '<stop offset="' + positionValue + '" stop-color="' + color.toRGB() + '"' + (alpha < 1 ? ' stop-opacity="' + alpha + '"' : '') + '/>';
|
|
537
|
+
}
|
|
538
|
+
returner += '</' + gradientType + 'Gradient>' +
|
|
539
|
+
'<rect ' + rectangleDimension + ' fill="url(#gradient)" /></svg>';
|
|
540
|
+
|
|
541
|
+
if (useBase64) {
|
|
542
|
+
try {
|
|
543
|
+
returner = require('./encoder').encodeBase64(returner); // TODO browser implementation
|
|
544
|
+
} catch(e) {
|
|
545
|
+
useBase64 = false;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
returner = "'data:image/svg+xml" + (useBase64 ? ";base64" : "") + "," + returner + "'";
|
|
550
|
+
return new(tree.URL)(new(tree.Anonymous)(returner));
|
|
204
551
|
}
|
|
205
552
|
};
|
|
206
553
|
|
|
207
|
-
|
|
208
|
-
|
|
554
|
+
// these static methods are used as a fallback when the optional 'mime' dependency is missing
|
|
555
|
+
tree._mime = {
|
|
556
|
+
// this map is intentionally incomplete
|
|
557
|
+
// if you want more, install 'mime' dep
|
|
558
|
+
_types: {
|
|
559
|
+
'.htm' : 'text/html',
|
|
560
|
+
'.html': 'text/html',
|
|
561
|
+
'.gif' : 'image/gif',
|
|
562
|
+
'.jpg' : 'image/jpeg',
|
|
563
|
+
'.jpeg': 'image/jpeg',
|
|
564
|
+
'.png' : 'image/png'
|
|
565
|
+
},
|
|
566
|
+
lookup: function (filepath) {
|
|
567
|
+
var ext = require('path').extname(filepath),
|
|
568
|
+
type = tree._mime._types[ext];
|
|
569
|
+
if (type === undefined) {
|
|
570
|
+
throw new Error('Optional dependency "mime" is required for ' + ext);
|
|
571
|
+
}
|
|
572
|
+
return type;
|
|
573
|
+
},
|
|
574
|
+
charsets: {
|
|
575
|
+
lookup: function (type) {
|
|
576
|
+
// assumes all text types are UTF-8
|
|
577
|
+
return type && (/^text\//).test(type) ? 'UTF-8' : '';
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
// Math
|
|
583
|
+
|
|
584
|
+
var mathFunctions = {
|
|
585
|
+
// name, unit
|
|
586
|
+
ceil: null,
|
|
587
|
+
floor: null,
|
|
588
|
+
sqrt: null,
|
|
589
|
+
abs: null,
|
|
590
|
+
tan: "",
|
|
591
|
+
sin: "",
|
|
592
|
+
cos: "",
|
|
593
|
+
atan: "rad",
|
|
594
|
+
asin: "rad",
|
|
595
|
+
acos: "rad"
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
function _math(fn, unit, n) {
|
|
599
|
+
if (!(n instanceof tree.Dimension)) {
|
|
600
|
+
throw { type: "Argument", message: "argument must be a number" };
|
|
601
|
+
}
|
|
602
|
+
if (unit == null) {
|
|
603
|
+
unit = n.unit;
|
|
604
|
+
} else {
|
|
605
|
+
n = n.unify();
|
|
606
|
+
}
|
|
607
|
+
return new(tree.Dimension)(fn(parseFloat(n.value)), unit);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// ~ End of Math
|
|
611
|
+
|
|
612
|
+
// Color Blending
|
|
613
|
+
// ref: http://www.w3.org/TR/compositing-1
|
|
614
|
+
|
|
615
|
+
function colorBlend(mode, color1, color2) {
|
|
616
|
+
var ab = color1.alpha, cb, // backdrop
|
|
617
|
+
as = color2.alpha, cs, // source
|
|
618
|
+
ar, cr, r = []; // result
|
|
619
|
+
|
|
620
|
+
ar = as + ab * (1 - as);
|
|
621
|
+
for (var i = 0; i < 3; i++) {
|
|
622
|
+
cb = color1.rgb[i] / 255;
|
|
623
|
+
cs = color2.rgb[i] / 255;
|
|
624
|
+
cr = mode(cb, cs);
|
|
625
|
+
if (ar) {
|
|
626
|
+
cr = (as * cs + ab * (cb
|
|
627
|
+
- as * (cb + cs - cr))) / ar;
|
|
628
|
+
}
|
|
629
|
+
r[i] = cr * 255;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
return new(tree.Color)(r, ar);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
var colorBlendMode = {
|
|
636
|
+
multiply: function(cb, cs) {
|
|
637
|
+
return cb * cs;
|
|
638
|
+
},
|
|
639
|
+
screen: function(cb, cs) {
|
|
640
|
+
return cb + cs - cb * cs;
|
|
641
|
+
},
|
|
642
|
+
overlay: function(cb, cs) {
|
|
643
|
+
cb *= 2;
|
|
644
|
+
return (cb <= 1)
|
|
645
|
+
? colorBlendMode.multiply(cb, cs)
|
|
646
|
+
: colorBlendMode.screen(cb - 1, cs);
|
|
647
|
+
},
|
|
648
|
+
softlight: function(cb, cs) {
|
|
649
|
+
var d = 1, e = cb;
|
|
650
|
+
if (cs > 0.5) {
|
|
651
|
+
e = 1;
|
|
652
|
+
d = (cb > 0.25) ? Math.sqrt(cb)
|
|
653
|
+
: ((16 * cb - 12) * cb + 4) * cb;
|
|
654
|
+
}
|
|
655
|
+
return cb - (1 - 2 * cs) * e * (d - cb);
|
|
656
|
+
},
|
|
657
|
+
hardlight: function(cb, cs) {
|
|
658
|
+
return colorBlendMode.overlay(cs, cb);
|
|
659
|
+
},
|
|
660
|
+
difference: function(cb, cs) {
|
|
661
|
+
return Math.abs(cb - cs);
|
|
662
|
+
},
|
|
663
|
+
exclusion: function(cb, cs) {
|
|
664
|
+
return cb + cs - 2 * cb * cs;
|
|
665
|
+
},
|
|
666
|
+
|
|
667
|
+
// non-w3c functions:
|
|
668
|
+
average: function(cb, cs) {
|
|
669
|
+
return (cb + cs) / 2;
|
|
670
|
+
},
|
|
671
|
+
negation: function(cb, cs) {
|
|
672
|
+
return 1 - Math.abs(cb + cs - 1);
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
// ~ End of Color Blending
|
|
677
|
+
|
|
678
|
+
tree.defaultFunc = {
|
|
679
|
+
eval: function () {
|
|
680
|
+
var v = this.value_, e = this.error_;
|
|
681
|
+
if (e) {
|
|
682
|
+
throw e;
|
|
683
|
+
}
|
|
684
|
+
if (v != null) {
|
|
685
|
+
return v ? tree.True : tree.False;
|
|
686
|
+
}
|
|
687
|
+
},
|
|
688
|
+
value: function (v) {
|
|
689
|
+
this.value_ = v;
|
|
690
|
+
},
|
|
691
|
+
error: function (e) {
|
|
692
|
+
this.error_ = e;
|
|
693
|
+
},
|
|
694
|
+
reset: function () {
|
|
695
|
+
this.value_ = this.error_ = null;
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
function initFunctions() {
|
|
700
|
+
var f, tf = tree.functions;
|
|
701
|
+
|
|
702
|
+
// math
|
|
703
|
+
for (f in mathFunctions) {
|
|
704
|
+
if (mathFunctions.hasOwnProperty(f)) {
|
|
705
|
+
tf[f] = _math.bind(null, Math[f], mathFunctions[f]);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// color blending
|
|
710
|
+
for (f in colorBlendMode) {
|
|
711
|
+
if (colorBlendMode.hasOwnProperty(f)) {
|
|
712
|
+
tf[f] = colorBlend.bind(null, colorBlendMode[f]);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
// default
|
|
717
|
+
f = tree.defaultFunc;
|
|
718
|
+
tf["default"] = f.eval.bind(f);
|
|
719
|
+
|
|
720
|
+
} initFunctions();
|
|
721
|
+
|
|
722
|
+
function hsla(color) {
|
|
723
|
+
return tree.functions.hsla(color.h, color.s, color.l, color.a);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
function scaled(n, size) {
|
|
727
|
+
if (n instanceof tree.Dimension && n.unit.is('%')) {
|
|
728
|
+
return parseFloat(n.value * size / 100);
|
|
729
|
+
} else {
|
|
730
|
+
return number(n);
|
|
731
|
+
}
|
|
209
732
|
}
|
|
210
733
|
|
|
211
734
|
function number(n) {
|
|
212
735
|
if (n instanceof tree.Dimension) {
|
|
213
|
-
return parseFloat(n.unit
|
|
736
|
+
return parseFloat(n.unit.is('%') ? n.value / 100 : n.value);
|
|
214
737
|
} else if (typeof(n) === 'number') {
|
|
215
738
|
return n;
|
|
216
739
|
} else {
|
|
@@ -225,4 +748,21 @@ function clamp(val) {
|
|
|
225
748
|
return Math.min(1, Math.max(0, val));
|
|
226
749
|
}
|
|
227
750
|
|
|
751
|
+
tree.fround = function(env, value) {
|
|
752
|
+
var p;
|
|
753
|
+
if (env && (env.numPrecision != null)) {
|
|
754
|
+
p = Math.pow(10, env.numPrecision);
|
|
755
|
+
return Math.round(value * p) / p;
|
|
756
|
+
} else {
|
|
757
|
+
return value;
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
|
|
761
|
+
tree.functionCall = function(env, currentFileInfo) {
|
|
762
|
+
this.env = env;
|
|
763
|
+
this.currentFileInfo = currentFileInfo;
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
tree.functionCall.prototype = tree.functions;
|
|
767
|
+
|
|
228
768
|
})(require('./tree'));
|