less 3.10.0-beta.2 → 3.10.3

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.
Files changed (124) hide show
  1. package/.DS_Store +0 -0
  2. package/bin/lessc +6652 -5505
  3. package/dist/less.cjs.js +6593 -5448
  4. package/dist/less.js +10 -6
  5. package/dist/less.min.js +2 -2
  6. package/dist/less.min.js.map +1 -1
  7. package/lib/less/constants.js +13 -0
  8. package/lib/less/contexts.js +164 -0
  9. package/lib/less/data/colors.js +150 -0
  10. package/lib/less/data/index.js +4 -0
  11. package/lib/less/data/unit-conversions.js +21 -0
  12. package/lib/less/default-options.js +68 -0
  13. package/lib/less/environment/abstract-file-manager.js +127 -0
  14. package/lib/less/environment/abstract-plugin-loader.js +187 -0
  15. package/lib/less/environment/environment-api.js +25 -0
  16. package/lib/less/environment/environment.js +59 -0
  17. package/lib/less/environment/file-manager-api.js +103 -0
  18. package/lib/less/functions/boolean.js +13 -0
  19. package/lib/less/functions/color-blending.js +84 -0
  20. package/lib/less/functions/color.js +417 -0
  21. package/lib/less/functions/data-uri.js +74 -0
  22. package/lib/less/functions/default.js +25 -0
  23. package/lib/less/functions/function-caller.js +49 -0
  24. package/lib/less/functions/function-registry.js +35 -0
  25. package/lib/less/functions/index.js +33 -0
  26. package/lib/less/functions/list.js +143 -0
  27. package/lib/less/functions/math-helper.js +15 -0
  28. package/lib/less/functions/math.js +28 -0
  29. package/lib/less/functions/number.js +89 -0
  30. package/lib/less/functions/string.js +36 -0
  31. package/lib/less/functions/svg.js +87 -0
  32. package/lib/less/functions/types.js +70 -0
  33. package/lib/less/import-manager.js +169 -0
  34. package/lib/less/index.js +92 -0
  35. package/lib/less/less-error.js +140 -0
  36. package/lib/less/logger.js +34 -0
  37. package/lib/less/parse-tree.js +66 -0
  38. package/lib/less/parse.js +89 -0
  39. package/lib/less/parser/chunker.js +122 -0
  40. package/lib/less/parser/parser-input.js +390 -0
  41. package/lib/less/parser/parser.js +2418 -0
  42. package/lib/less/plugin-manager.js +168 -0
  43. package/lib/less/render.js +42 -0
  44. package/lib/less/source-map-builder.js +77 -0
  45. package/lib/less/source-map-output.js +149 -0
  46. package/lib/less/transform-tree.js +96 -0
  47. package/lib/less/tree/anonymous.js +37 -0
  48. package/lib/less/tree/assignment.js +33 -0
  49. package/lib/less/tree/atrule.js +165 -0
  50. package/lib/less/tree/attribute.js +34 -0
  51. package/lib/less/tree/call.js +105 -0
  52. package/lib/less/tree/color.js +246 -0
  53. package/lib/less/tree/combinator.js +29 -0
  54. package/lib/less/tree/comment.js +29 -0
  55. package/lib/less/tree/condition.js +43 -0
  56. package/lib/less/tree/debug-info.js +34 -0
  57. package/lib/less/tree/declaration.js +115 -0
  58. package/lib/less/tree/detached-ruleset.js +30 -0
  59. package/lib/less/tree/dimension.js +179 -0
  60. package/lib/less/tree/element.js +73 -0
  61. package/lib/less/tree/expression.js +74 -0
  62. package/lib/less/tree/extend.js +66 -0
  63. package/lib/less/tree/import.js +184 -0
  64. package/lib/less/tree/index.js +54 -0
  65. package/lib/less/tree/javascript.js +33 -0
  66. package/lib/less/tree/js-eval-node.js +58 -0
  67. package/lib/less/tree/keyword.js +21 -0
  68. package/lib/less/tree/media.js +154 -0
  69. package/lib/less/tree/mixin-call.js +215 -0
  70. package/lib/less/tree/mixin-definition.js +229 -0
  71. package/lib/less/tree/namespace-value.js +87 -0
  72. package/lib/less/tree/negative.js +26 -0
  73. package/lib/less/tree/node.js +178 -0
  74. package/lib/less/tree/operation.js +62 -0
  75. package/lib/less/tree/paren.js +22 -0
  76. package/lib/less/tree/property.js +77 -0
  77. package/lib/less/tree/quoted.js +70 -0
  78. package/lib/less/tree/ruleset.js +867 -0
  79. package/lib/less/tree/selector.js +146 -0
  80. package/lib/less/tree/unicode-descriptor.js +13 -0
  81. package/lib/less/tree/unit.js +141 -0
  82. package/lib/less/tree/url.js +65 -0
  83. package/lib/less/tree/value.js +44 -0
  84. package/lib/less/tree/variable-call.js +46 -0
  85. package/lib/less/tree/variable.js +67 -0
  86. package/lib/less/utils.js +122 -0
  87. package/lib/less/visitors/extend-visitor.js +505 -0
  88. package/lib/less/visitors/import-sequencer.js +58 -0
  89. package/lib/less/visitors/import-visitor.js +189 -0
  90. package/lib/less/visitors/index.js +15 -0
  91. package/lib/less/visitors/join-selector-visitor.js +57 -0
  92. package/lib/less/visitors/set-tree-visibility-visitor.js +45 -0
  93. package/lib/less/visitors/to-css-visitor.js +363 -0
  94. package/lib/less/visitors/visitor.js +163 -0
  95. package/lib/less-browser/add-default-options.js +49 -0
  96. package/lib/less-browser/bootstrap.js +69 -0
  97. package/lib/less-browser/browser.js +65 -0
  98. package/lib/less-browser/cache.js +43 -0
  99. package/lib/less-browser/error-reporting.js +170 -0
  100. package/lib/less-browser/file-manager.js +113 -0
  101. package/lib/less-browser/image-size.js +28 -0
  102. package/lib/less-browser/index.js +285 -0
  103. package/lib/less-browser/log-listener.js +42 -0
  104. package/lib/less-browser/plugin-loader.js +26 -0
  105. package/lib/less-browser/utils.js +24 -0
  106. package/lib/less-node/environment.js +16 -0
  107. package/lib/less-node/file-manager.js +177 -0
  108. package/lib/less-node/fs.js +10 -0
  109. package/lib/less-node/image-size.js +58 -0
  110. package/lib/less-node/index.js +27 -0
  111. package/lib/less-node/lessc-helper.js +89 -0
  112. package/lib/less-node/plugin-loader.js +53 -0
  113. package/lib/less-node/url-file-manager.js +49 -0
  114. package/lib/lessc.js +557 -0
  115. package/lib/source-map/source-map-0.1.31.js +1933 -0
  116. package/lib/source-map/source-map-footer.js +4 -0
  117. package/lib/source-map/source-map-header.js +3 -0
  118. package/package.json +1 -1
  119. package/test/.DS_Store +0 -0
  120. package/test/browser/less.min.js +11 -0
  121. package/test/browser/less.min.js.map +1 -0
  122. package/test/css/css-escapes.css +1 -0
  123. package/test/less/css-escapes.less +3 -1
  124. package/.git/index +0 -0
@@ -0,0 +1,27 @@
1
+ import environment from './environment';
2
+ import FileManager from './file-manager';
3
+ import UrlFileManager from './url-file-manager';
4
+ import createFromEnvironment from '../less';
5
+ import lesscHelper from './lessc-helper';
6
+ import PluginLoader from './plugin-loader';
7
+ import fs from './fs';
8
+ import defaultOptions from '../less/default-options';
9
+ import imageSize from './image-size';
10
+
11
+ const less = createFromEnvironment(environment, [new FileManager(), new UrlFileManager()]);
12
+
13
+ // allow people to create less with their own environment
14
+ less.createFromEnvironment = createFromEnvironment;
15
+ less.lesscHelper = lesscHelper;
16
+ less.PluginLoader = PluginLoader;
17
+ less.fs = fs;
18
+ less.FileManager = FileManager;
19
+ less.UrlFileManager = UrlFileManager;
20
+
21
+ // Set up options
22
+ less.options = defaultOptions();
23
+
24
+ // provide image-size functionality
25
+ imageSize(less.environment);
26
+
27
+ export default less;
@@ -0,0 +1,89 @@
1
+ // lessc_helper.js
2
+ //
3
+ // helper functions for lessc
4
+ const lessc_helper = {
5
+
6
+ // Stylize a string
7
+ stylize : function(str, style) {
8
+ const styles = {
9
+ 'reset' : [0, 0],
10
+ 'bold' : [1, 22],
11
+ 'inverse' : [7, 27],
12
+ 'underline' : [4, 24],
13
+ 'yellow' : [33, 39],
14
+ 'green' : [32, 39],
15
+ 'red' : [31, 39],
16
+ 'grey' : [90, 39]
17
+ };
18
+ return `\x1b[${styles[style][0]}m${str}\x1b[${styles[style][1]}m`;
19
+ },
20
+
21
+ // Print command line options
22
+ printUsage: function() {
23
+ console.log('usage: lessc [option option=parameter ...] <source> [destination]');
24
+ console.log('');
25
+ console.log('If source is set to `-\' (dash or hyphen-minus), input is read from stdin.');
26
+ console.log('');
27
+ console.log('options:');
28
+ console.log(' -h, --help Prints help (this message) and exit.');
29
+ console.log(' --include-path=PATHS Sets include paths. Separated by `:\'. `;\' also supported on windows.');
30
+ console.log(' -M, --depends Outputs a makefile import dependency list to stdout.');
31
+ console.log(' --no-color Disables colorized output.');
32
+ console.log(' --ie-compat Enables IE8 compatibility checks.');
33
+ console.log(' --js Enables inline JavaScript in less files');
34
+ console.log(' -l, --lint Syntax check only (lint).');
35
+ console.log(' -s, --silent Suppresses output of error messages.');
36
+ console.log(' --strict-imports Forces evaluation of imports.');
37
+ console.log(' --insecure Allows imports from insecure https hosts.');
38
+ console.log(' -v, --version Prints version number and exit.');
39
+ console.log(' --verbose Be verbose.');
40
+ console.log(' --source-map[=FILENAME] Outputs a v3 sourcemap to the filename (or output filename.map).');
41
+ console.log(' --source-map-rootpath=X Adds this path onto the sourcemap filename and less file paths.');
42
+ console.log(' --source-map-basepath=X Sets sourcemap base path, defaults to current working directory.');
43
+ console.log(' --source-map-include-source Puts the less files into the map instead of referencing them.');
44
+ console.log(' --source-map-inline Puts the map (and any less files) as a base64 data uri into the output css file.');
45
+ console.log(' --source-map-url=URL Sets a custom URL to map file, for sourceMappingURL comment');
46
+ console.log(' in generated CSS file.');
47
+ console.log(' -rp, --rootpath=URL Sets rootpath for url rewriting in relative imports and urls');
48
+ console.log(' Works with or without the relative-urls option.');
49
+ console.log(' -ru=, --rewrite-urls= Rewrites URLs to make them relative to the base less file.');
50
+ console.log(' all|local|off \'all\' rewrites all URLs, \'local\' just those starting with a \'.\'');
51
+ console.log('');
52
+ console.log(' -m=, --math=');
53
+ console.log(' always Less will eagerly perform math operations always.');
54
+ console.log(' parens-division Math performed except for division (/) operator');
55
+ console.log(' parens | strict Math only performed inside parentheses');
56
+ console.log(' strict-legacy Parens required in very strict terms (legacy --strict-math)');
57
+ console.log('');
58
+ console.log(' -su=on|off Allows mixed units, e.g. 1px+1em or 1px*1px which have units');
59
+ console.log(' --strict-units=on|off that cannot be represented.');
60
+ console.log(' --global-var=\'VAR=VALUE\' Defines a variable that can be referenced by the file.');
61
+ console.log(' --modify-var=\'VAR=VALUE\' Modifies a variable already declared in the file.');
62
+ console.log(' --url-args=\'QUERYSTRING\' Adds params into url tokens (e.g. 42, cb=42 or \'a=1&b=2\')');
63
+ console.log(' --plugin=PLUGIN=OPTIONS Loads a plugin. You can also omit the --plugin= if the plugin begins');
64
+ console.log(' less-plugin. E.g. the clean css plugin is called less-plugin-clean-css');
65
+ console.log(' once installed (npm install less-plugin-clean-css), use either with');
66
+ console.log(' --plugin=less-plugin-clean-css or just --clean-css');
67
+ console.log(' specify options afterwards e.g. --plugin=less-plugin-clean-css="advanced"');
68
+ console.log(' or --clean-css="advanced"');
69
+ console.log('');
70
+ console.log('-------------------------- Deprecated ----------------');
71
+ console.log(' -sm=on|off Legacy parens-only math. Use --math');
72
+ console.log(' --strict-math=on|off ');
73
+ console.log('');
74
+ console.log(' --line-numbers=TYPE Outputs filename and line numbers.');
75
+ console.log(' TYPE can be either \'comments\', which will output');
76
+ console.log(' the debug info within comments, \'mediaquery\'');
77
+ console.log(' that will output the information within a fake');
78
+ console.log(' media query which is compatible with the SASS');
79
+ console.log(' format, and \'all\' which will do both.');
80
+ console.log(' -x, --compress Compresses output by removing some whitespaces.');
81
+ console.log(' We recommend you use a dedicated minifer like less-plugin-clean-css');
82
+ console.log('');
83
+ console.log('Report bugs to: http://github.com/less/less.js/issues');
84
+ console.log('Home page: <http://lesscss.org/>');
85
+ }
86
+ };
87
+
88
+ // Exports helper functions
89
+ for (const h in lessc_helper) { if (lessc_helper.hasOwnProperty(h)) { exports[h] = lessc_helper[h]; }}
@@ -0,0 +1,53 @@
1
+ import path from 'path';
2
+ import AbstractPluginLoader from '../less/environment/abstract-plugin-loader.js';
3
+
4
+ /**
5
+ * Node Plugin Loader
6
+ */
7
+ class PluginLoader extends AbstractPluginLoader {
8
+ constructor(less) {
9
+ super();
10
+
11
+ this.less = less;
12
+ this.require = prefix => {
13
+ prefix = path.dirname(prefix);
14
+ return id => {
15
+ const str = id.substr(0, 2);
16
+ if (str === '..' || str === './') {
17
+ return require(path.join(prefix, id));
18
+ }
19
+ else {
20
+ return require(id);
21
+ }
22
+ };
23
+ };
24
+ }
25
+
26
+ loadPlugin(filename, basePath, context, environment, fileManager) {
27
+ const prefix = filename.slice(0, 1);
28
+ const explicit = prefix === '.' || prefix === '/' || filename.slice(-3).toLowerCase() === '.js';
29
+ if (!explicit) {
30
+ context.prefixes = ['less-plugin-', ''];
31
+ }
32
+
33
+ return new Promise((fulfill, reject) => {
34
+ fileManager.loadFile(filename, basePath, context, environment).then(
35
+ data => {
36
+ try {
37
+ fulfill(data);
38
+ }
39
+ catch (e) {
40
+ console.log(e);
41
+ reject(e);
42
+ }
43
+ }
44
+ ).catch(err => {
45
+ reject(err);
46
+ });
47
+ });
48
+
49
+ }
50
+ }
51
+
52
+ export default PluginLoader;
53
+
@@ -0,0 +1,49 @@
1
+ const isUrlRe = /^(?:https?:)?\/\//i;
2
+ import url from 'url';
3
+ let request;
4
+ import AbstractFileManager from '../less/environment/abstract-file-manager.js';
5
+ import logger from '../less/logger';
6
+
7
+ class UrlFileManager extends AbstractFileManager {
8
+ supports(filename, currentDirectory, options, environment) {
9
+ return isUrlRe.test( filename ) || isUrlRe.test(currentDirectory);
10
+ }
11
+
12
+ loadFile(filename, currentDirectory, options, environment) {
13
+ return new Promise((fulfill, reject) => {
14
+ if (request === undefined) {
15
+ try { request = require('request'); }
16
+ catch (e) { request = null; }
17
+ }
18
+ if (!request) {
19
+ reject({ type: 'File', message: 'optional dependency \'request\' required to import over http(s)\n' });
20
+ return;
21
+ }
22
+
23
+ let urlStr = isUrlRe.test( filename ) ? filename : url.resolve(currentDirectory, filename);
24
+ const urlObj = url.parse(urlStr);
25
+
26
+ if (!urlObj.protocol) {
27
+ urlObj.protocol = 'http';
28
+ urlStr = urlObj.format();
29
+ }
30
+
31
+ request.get({uri: urlStr, strictSSL: !options.insecure }, (error, res, body) => {
32
+ if (error) {
33
+ reject({ type: 'File', message: `resource '${urlStr}' gave this Error:\n ${error}\n` });
34
+ return;
35
+ }
36
+ if (res && res.statusCode === 404) {
37
+ reject({ type: 'File', message: `resource '${urlStr}' was not found\n` });
38
+ return;
39
+ }
40
+ if (!body) {
41
+ logger.warn(`Warning: Empty body (HTTP ${res.statusCode}) returned by "${urlStr}"`);
42
+ }
43
+ fulfill({ contents: body, filename: urlStr });
44
+ });
45
+ });
46
+ }
47
+ }
48
+
49
+ export default UrlFileManager;