less 4.9.0 → 5.0.0-alpha.1

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 (131) hide show
  1. package/README.md +19 -5
  2. package/bin/lessc +190 -630
  3. package/dist/less-node.cjs +399 -14570
  4. package/index.cjs +5 -2
  5. package/lib/index.js +164 -0
  6. package/lib/lessc-helper.js +52 -0
  7. package/lib/logger.js +76 -0
  8. package/lib/options.d.ts +46 -0
  9. package/lib/options.js +145 -0
  10. package/lib/types.js +20 -0
  11. package/lib/version.js +19 -0
  12. package/package.json +34 -40
  13. package/dist/less.cjs +0 -15215
  14. package/dist/less.js +0 -15215
  15. package/dist/less.min.js +0 -11
  16. package/dist/less.min.js.map +0 -1
  17. package/lib/less/constants.js +0 -13
  18. package/lib/less/contexts.js +0 -165
  19. package/lib/less/data/colors.js +0 -150
  20. package/lib/less/data/index.js +0 -4
  21. package/lib/less/data/unit-conversions.js +0 -21
  22. package/lib/less/default-options.js +0 -89
  23. package/lib/less/deprecation.js +0 -82
  24. package/lib/less/environment/abstract-file-manager.js +0 -140
  25. package/lib/less/environment/abstract-plugin-loader.js +0 -185
  26. package/lib/less/environment/environment-api.ts +0 -21
  27. package/lib/less/environment/environment.js +0 -59
  28. package/lib/less/environment/file-manager-api.ts +0 -77
  29. package/lib/less/functions/boolean.js +0 -29
  30. package/lib/less/functions/color-blending.js +0 -85
  31. package/lib/less/functions/color.js +0 -452
  32. package/lib/less/functions/data-uri.js +0 -74
  33. package/lib/less/functions/default.js +0 -26
  34. package/lib/less/functions/function-caller.js +0 -55
  35. package/lib/less/functions/function-registry.js +0 -36
  36. package/lib/less/functions/index.js +0 -35
  37. package/lib/less/functions/list.js +0 -158
  38. package/lib/less/functions/math-helper.js +0 -22
  39. package/lib/less/functions/math.js +0 -30
  40. package/lib/less/functions/number.js +0 -95
  41. package/lib/less/functions/string.js +0 -39
  42. package/lib/less/functions/style.js +0 -29
  43. package/lib/less/functions/svg.js +0 -87
  44. package/lib/less/functions/types.js +0 -70
  45. package/lib/less/import-manager.js +0 -183
  46. package/lib/less/index.js +0 -95
  47. package/lib/less/less-error.js +0 -166
  48. package/lib/less/logger.js +0 -34
  49. package/lib/less/parse-tree.js +0 -124
  50. package/lib/less/parse.js +0 -87
  51. package/lib/less/parser/lookup-pattern.js +0 -26
  52. package/lib/less/parser/parser-input.js +0 -400
  53. package/lib/less/parser/parser.js +0 -2998
  54. package/lib/less/plugin-manager.js +0 -168
  55. package/lib/less/render.js +0 -41
  56. package/lib/less/source-map-builder.js +0 -82
  57. package/lib/less/source-map-output.js +0 -151
  58. package/lib/less/transform-tree.js +0 -102
  59. package/lib/less/tree/anonymous.js +0 -61
  60. package/lib/less/tree/assignment.js +0 -48
  61. package/lib/less/tree/atrule-syntax.js +0 -8
  62. package/lib/less/tree/atrule.js +0 -340
  63. package/lib/less/tree/attribute.js +0 -63
  64. package/lib/less/tree/call.js +0 -132
  65. package/lib/less/tree/color.js +0 -285
  66. package/lib/less/tree/combinator.js +0 -38
  67. package/lib/less/tree/comment.js +0 -48
  68. package/lib/less/tree/condition.js +0 -65
  69. package/lib/less/tree/container.js +0 -104
  70. package/lib/less/tree/debug-info.js +0 -80
  71. package/lib/less/tree/declaration.js +0 -139
  72. package/lib/less/tree/detached-ruleset.js +0 -45
  73. package/lib/less/tree/dimension.js +0 -215
  74. package/lib/less/tree/element.js +0 -93
  75. package/lib/less/tree/expression.js +0 -100
  76. package/lib/less/tree/extend.js +0 -88
  77. package/lib/less/tree/import.js +0 -299
  78. package/lib/less/tree/index.js +0 -56
  79. package/lib/less/tree/interpolated-variable.js +0 -106
  80. package/lib/less/tree/javascript.js +0 -45
  81. package/lib/less/tree/js-eval-node.js +0 -80
  82. package/lib/less/tree/keyword.js +0 -28
  83. package/lib/less/tree/media.js +0 -90
  84. package/lib/less/tree/merge-rules.js +0 -47
  85. package/lib/less/tree/mixin-call.js +0 -283
  86. package/lib/less/tree/mixin-definition.js +0 -319
  87. package/lib/less/tree/namespace-value.js +0 -95
  88. package/lib/less/tree/negative.js +0 -37
  89. package/lib/less/tree/nested-at-rule.js +0 -239
  90. package/lib/less/tree/node.js +0 -310
  91. package/lib/less/tree/operation.js +0 -81
  92. package/lib/less/tree/paren.js +0 -41
  93. package/lib/less/tree/property.js +0 -96
  94. package/lib/less/tree/query-in-parens.js +0 -64
  95. package/lib/less/tree/quoted.js +0 -131
  96. package/lib/less/tree/ruleset.js +0 -1068
  97. package/lib/less/tree/selector.js +0 -201
  98. package/lib/less/tree/unicode-descriptor.js +0 -14
  99. package/lib/less/tree/unit.js +0 -170
  100. package/lib/less/tree/url.js +0 -83
  101. package/lib/less/tree/value.js +0 -60
  102. package/lib/less/tree/variable-call.js +0 -60
  103. package/lib/less/tree/variable.js +0 -85
  104. package/lib/less/utils.js +0 -126
  105. package/lib/less/visitors/extend-visitor.js +0 -505
  106. package/lib/less/visitors/import-sequencer.js +0 -56
  107. package/lib/less/visitors/import-visitor.js +0 -203
  108. package/lib/less/visitors/index.js +0 -15
  109. package/lib/less/visitors/join-selector-visitor.js +0 -65
  110. package/lib/less/visitors/set-tree-visibility-visitor.js +0 -57
  111. package/lib/less/visitors/to-css-visitor.js +0 -332
  112. package/lib/less/visitors/visitor.js +0 -165
  113. package/lib/less-browser/add-default-options.js +0 -53
  114. package/lib/less-browser/bootstrap.js +0 -67
  115. package/lib/less-browser/browser.js +0 -65
  116. package/lib/less-browser/cache.js +0 -43
  117. package/lib/less-browser/error-reporting.js +0 -170
  118. package/lib/less-browser/file-manager.js +0 -112
  119. package/lib/less-browser/image-size.js +0 -28
  120. package/lib/less-browser/index.js +0 -284
  121. package/lib/less-browser/log-listener.js +0 -42
  122. package/lib/less-browser/plugin-loader.js +0 -24
  123. package/lib/less-browser/utils.js +0 -30
  124. package/lib/less-node/environment.js +0 -43
  125. package/lib/less-node/file-manager.js +0 -156
  126. package/lib/less-node/fs.js +0 -14
  127. package/lib/less-node/image-size.js +0 -78
  128. package/lib/less-node/index.js +0 -31
  129. package/lib/less-node/lessc-helper.js +0 -95
  130. package/lib/less-node/plugin-loader.js +0 -62
  131. package/lib/less-node/url-file-manager.js +0 -60
@@ -1,131 +0,0 @@
1
- // @ts-check
2
- /** @import { EvalContext, CSSOutput, FileInfo } from './node.js' */
3
- import Node from './node.js';
4
- import {
5
- VARIABLE_INTERPOLATION,
6
- PROPERTY_INTERPOLATION,
7
- resolveInterpolatedVariable,
8
- resolveInterpolatedProperty
9
- } from './interpolated-variable.js';
10
-
11
- class Quoted extends Node {
12
- get type() { return 'Quoted'; }
13
-
14
- /**
15
- * @param {string} str
16
- * @param {string} [content]
17
- * @param {boolean} [escaped]
18
- * @param {number} [index]
19
- * @param {FileInfo} [currentFileInfo]
20
- */
21
- constructor(str, content, escaped, index, currentFileInfo) {
22
- super();
23
- /** @type {boolean} */
24
- this.escaped = (escaped === undefined) ? true : escaped;
25
- /** @type {string} */
26
- this.value = content || '';
27
- /** @type {string} */
28
- this.quote = str.charAt(0);
29
- this._index = index;
30
- this._fileInfo = currentFileInfo;
31
- /** @type {RegExp} */
32
- this.variableRegex = new RegExp(VARIABLE_INTERPOLATION.source, 'g');
33
- /** @type {RegExp} */
34
- this.propRegex = new RegExp(PROPERTY_INTERPOLATION.source, 'g');
35
- /** @type {boolean | undefined} */
36
- this.allowRoot = escaped;
37
- }
38
-
39
- /**
40
- * @param {EvalContext} context
41
- * @param {CSSOutput} output
42
- */
43
- genCSS(context, output) {
44
- if (!this.escaped) {
45
- output.add(this.quote, this.fileInfo(), this.getIndex());
46
- }
47
- output.add(/** @type {string} */ (this.value));
48
- if (!this.escaped) {
49
- output.add(this.quote);
50
- }
51
- }
52
-
53
- /** @returns {RegExpMatchArray | null} */
54
- containsVariables() {
55
- return /** @type {string} */ (this.value).match(this.variableRegex);
56
- }
57
-
58
- /** @param {EvalContext} context */
59
- eval(context) {
60
- const that = this;
61
- let value = /** @type {string} */ (this.value);
62
- /**
63
- * @param {string} _
64
- * @param {string} name1
65
- * @param {string} name2
66
- * @returns {string}
67
- */
68
- const variableReplacement = function (_, name1, name2) {
69
- const v = resolveInterpolatedVariable(
70
- name1 ?? name2, that.getIndex(), that.fileInfo()
71
- ).eval(context);
72
- return (v instanceof Quoted) ? /** @type {string} */ (v.value) : v.toCSS(context);
73
- };
74
- /**
75
- * @param {string} _
76
- * @param {string} name1
77
- * @param {string} name2
78
- * @returns {string}
79
- */
80
- const propertyReplacement = function (_, name1, name2) {
81
- const v = resolveInterpolatedProperty(
82
- name1 ?? name2, that.getIndex(), that.fileInfo()
83
- ).eval(context);
84
- return (v instanceof Quoted) ? /** @type {string} */ (v.value) : v.toCSS(context);
85
- };
86
- /**
87
- * @param {string} value
88
- * @param {RegExp} regexp
89
- * @param {(substring: string, ...args: string[]) => string} replacementFnc
90
- * @returns {string}
91
- */
92
- function iterativeReplace(value, regexp, replacementFnc) {
93
- let evaluatedValue = value;
94
- do {
95
- value = evaluatedValue.toString();
96
- evaluatedValue = value.replace(regexp, replacementFnc);
97
- } while (value !== evaluatedValue);
98
- return evaluatedValue;
99
- }
100
- value = iterativeReplace(value, this.variableRegex, variableReplacement);
101
- value = iterativeReplace(value, this.propRegex, propertyReplacement);
102
- const result = new Quoted(
103
- this.quote + value + this.quote, value, this.escaped, this.getIndex(), this.fileInfo()
104
- );
105
- // Carry the quote across rather than re-deriving it from the rebuilt string.
106
- // For a real quote character the two agree, but an unquoted body (empty quote)
107
- // is not round-trippable that way — it would pick up the first character of the
108
- // substituted value and read as quoted, which suppresses rootpath escaping in
109
- // `URL.eval`.
110
- result.quote = this.quote;
111
- return result;
112
- }
113
-
114
- /**
115
- * @param {Node} other
116
- * @returns {number | undefined}
117
- */
118
- compare(other) {
119
- // when comparing quoted strings allow the quote to differ
120
- if (other.type === 'Quoted' && !this.escaped && !/** @type {Quoted} */ (other).escaped) {
121
- return Node.numericCompare(
122
- /** @type {string} */ (this.value),
123
- /** @type {string} */ (other.value)
124
- );
125
- } else {
126
- return other.toCSS && this.toCSS(/** @type {EvalContext} */ ({})) === other.toCSS(/** @type {EvalContext} */ ({})) ? 0 : undefined;
127
- }
128
- }
129
- }
130
-
131
- export default Quoted;