less 4.9.1 → 5.0.0-alpha.10

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 (134) hide show
  1. package/README.md +23 -5
  2. package/V5-STATUS.md +71 -0
  3. package/bin/lessc +302 -626
  4. package/dist/less-browser-dev.js +2550 -0
  5. package/dist/less-node.cjs +480 -14561
  6. package/index.cjs +5 -2
  7. package/lib/browser-dev.js +86 -0
  8. package/lib/index.js +164 -0
  9. package/lib/lessc-helper.js +64 -0
  10. package/lib/logger.js +76 -0
  11. package/lib/options.d.ts +82 -0
  12. package/lib/options.js +227 -0
  13. package/lib/types.js +20 -0
  14. package/lib/version.js +19 -0
  15. package/package.json +36 -40
  16. package/dist/less.cjs +0 -15218
  17. package/dist/less.js +0 -15218
  18. package/dist/less.min.js +0 -11
  19. package/dist/less.min.js.map +0 -1
  20. package/lib/less/constants.js +0 -13
  21. package/lib/less/contexts.js +0 -165
  22. package/lib/less/data/colors.js +0 -150
  23. package/lib/less/data/index.js +0 -4
  24. package/lib/less/data/unit-conversions.js +0 -21
  25. package/lib/less/default-options.js +0 -89
  26. package/lib/less/deprecation.js +0 -82
  27. package/lib/less/environment/abstract-file-manager.js +0 -140
  28. package/lib/less/environment/abstract-plugin-loader.js +0 -185
  29. package/lib/less/environment/environment-api.ts +0 -21
  30. package/lib/less/environment/environment.js +0 -59
  31. package/lib/less/environment/file-manager-api.ts +0 -77
  32. package/lib/less/functions/boolean.js +0 -29
  33. package/lib/less/functions/color-blending.js +0 -85
  34. package/lib/less/functions/color.js +0 -452
  35. package/lib/less/functions/data-uri.js +0 -74
  36. package/lib/less/functions/default.js +0 -26
  37. package/lib/less/functions/function-caller.js +0 -55
  38. package/lib/less/functions/function-registry.js +0 -36
  39. package/lib/less/functions/index.js +0 -35
  40. package/lib/less/functions/list.js +0 -158
  41. package/lib/less/functions/math-helper.js +0 -22
  42. package/lib/less/functions/math.js +0 -30
  43. package/lib/less/functions/number.js +0 -95
  44. package/lib/less/functions/string.js +0 -39
  45. package/lib/less/functions/style.js +0 -29
  46. package/lib/less/functions/svg.js +0 -87
  47. package/lib/less/functions/types.js +0 -70
  48. package/lib/less/import-manager.js +0 -183
  49. package/lib/less/index.js +0 -95
  50. package/lib/less/less-error.js +0 -166
  51. package/lib/less/logger.js +0 -34
  52. package/lib/less/parse-tree.js +0 -124
  53. package/lib/less/parse.js +0 -87
  54. package/lib/less/parser/lookup-pattern.js +0 -26
  55. package/lib/less/parser/parser-input.js +0 -400
  56. package/lib/less/parser/parser.js +0 -2998
  57. package/lib/less/plugin-manager.js +0 -168
  58. package/lib/less/render.js +0 -41
  59. package/lib/less/source-map-builder.js +0 -82
  60. package/lib/less/source-map-output.js +0 -151
  61. package/lib/less/transform-tree.js +0 -102
  62. package/lib/less/tree/anonymous.js +0 -61
  63. package/lib/less/tree/assignment.js +0 -48
  64. package/lib/less/tree/atrule-syntax.js +0 -8
  65. package/lib/less/tree/atrule.js +0 -340
  66. package/lib/less/tree/attribute.js +0 -63
  67. package/lib/less/tree/call.js +0 -132
  68. package/lib/less/tree/color.js +0 -285
  69. package/lib/less/tree/combinator.js +0 -38
  70. package/lib/less/tree/comment.js +0 -48
  71. package/lib/less/tree/condition.js +0 -65
  72. package/lib/less/tree/container.js +0 -104
  73. package/lib/less/tree/debug-info.js +0 -80
  74. package/lib/less/tree/declaration.js +0 -142
  75. package/lib/less/tree/detached-ruleset.js +0 -45
  76. package/lib/less/tree/dimension.js +0 -215
  77. package/lib/less/tree/element.js +0 -93
  78. package/lib/less/tree/expression.js +0 -100
  79. package/lib/less/tree/extend.js +0 -88
  80. package/lib/less/tree/import.js +0 -299
  81. package/lib/less/tree/index.js +0 -56
  82. package/lib/less/tree/interpolated-variable.js +0 -106
  83. package/lib/less/tree/javascript.js +0 -45
  84. package/lib/less/tree/js-eval-node.js +0 -80
  85. package/lib/less/tree/keyword.js +0 -28
  86. package/lib/less/tree/media.js +0 -90
  87. package/lib/less/tree/merge-rules.js +0 -47
  88. package/lib/less/tree/mixin-call.js +0 -283
  89. package/lib/less/tree/mixin-definition.js +0 -319
  90. package/lib/less/tree/namespace-value.js +0 -95
  91. package/lib/less/tree/negative.js +0 -37
  92. package/lib/less/tree/nested-at-rule.js +0 -239
  93. package/lib/less/tree/node.js +0 -310
  94. package/lib/less/tree/operation.js +0 -81
  95. package/lib/less/tree/paren.js +0 -41
  96. package/lib/less/tree/property.js +0 -96
  97. package/lib/less/tree/query-in-parens.js +0 -64
  98. package/lib/less/tree/quoted.js +0 -131
  99. package/lib/less/tree/ruleset.js +0 -1068
  100. package/lib/less/tree/selector.js +0 -201
  101. package/lib/less/tree/unicode-descriptor.js +0 -14
  102. package/lib/less/tree/unit.js +0 -170
  103. package/lib/less/tree/url.js +0 -83
  104. package/lib/less/tree/value.js +0 -60
  105. package/lib/less/tree/variable-call.js +0 -60
  106. package/lib/less/tree/variable.js +0 -85
  107. package/lib/less/utils.js +0 -126
  108. package/lib/less/visitors/extend-visitor.js +0 -505
  109. package/lib/less/visitors/import-sequencer.js +0 -56
  110. package/lib/less/visitors/import-visitor.js +0 -203
  111. package/lib/less/visitors/index.js +0 -15
  112. package/lib/less/visitors/join-selector-visitor.js +0 -65
  113. package/lib/less/visitors/set-tree-visibility-visitor.js +0 -57
  114. package/lib/less/visitors/to-css-visitor.js +0 -332
  115. package/lib/less/visitors/visitor.js +0 -165
  116. package/lib/less-browser/add-default-options.js +0 -53
  117. package/lib/less-browser/bootstrap.js +0 -67
  118. package/lib/less-browser/browser.js +0 -65
  119. package/lib/less-browser/cache.js +0 -43
  120. package/lib/less-browser/error-reporting.js +0 -170
  121. package/lib/less-browser/file-manager.js +0 -112
  122. package/lib/less-browser/image-size.js +0 -28
  123. package/lib/less-browser/index.js +0 -284
  124. package/lib/less-browser/log-listener.js +0 -42
  125. package/lib/less-browser/plugin-loader.js +0 -24
  126. package/lib/less-browser/utils.js +0 -30
  127. package/lib/less-node/environment.js +0 -43
  128. package/lib/less-node/file-manager.js +0 -156
  129. package/lib/less-node/fs.js +0 -14
  130. package/lib/less-node/image-size.js +0 -78
  131. package/lib/less-node/index.js +0 -31
  132. package/lib/less-node/lessc-helper.js +0 -95
  133. package/lib/less-node/plugin-loader.js +0 -62
  134. 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;