tailwindcss 3.3.2 → 3.3.4

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 (65) hide show
  1. package/CHANGELOG.md +50 -1
  2. package/lib/cli/build/plugin.js +2 -2
  3. package/lib/cli/build/watching.js +1 -1
  4. package/lib/corePlugins.js +11 -7
  5. package/lib/css/preflight.css +9 -0
  6. package/lib/lib/defaultExtractor.js +16 -22
  7. package/lib/lib/evaluateTailwindFunctions.js +5 -3
  8. package/lib/lib/expandApplyAtRules.js +6 -0
  9. package/lib/lib/expandTailwindAtRules.js +20 -6
  10. package/lib/lib/generateRules.js +34 -24
  11. package/lib/lib/setupContextUtils.js +53 -33
  12. package/lib/lib/setupTrackingContext.js +2 -1
  13. package/lib/oxide/cli/build/plugin.js +2 -2
  14. package/lib/plugin.js +3 -3
  15. package/lib/processTailwindFeatures.js +2 -2
  16. package/lib/util/color.js +1 -1
  17. package/lib/util/dataTypes.js +100 -16
  18. package/lib/util/formatVariantSelector.js +10 -3
  19. package/lib/util/isPlainObject.js +1 -1
  20. package/lib/util/prefixSelector.js +1 -1
  21. package/lib/util/pseudoElements.js +18 -34
  22. package/lib/value-parser/LICENSE +22 -0
  23. package/lib/value-parser/README.md +3 -0
  24. package/lib/value-parser/index.d.js +2 -0
  25. package/lib/value-parser/index.js +22 -0
  26. package/lib/value-parser/parse.js +259 -0
  27. package/lib/value-parser/stringify.js +38 -0
  28. package/lib/value-parser/unit.js +86 -0
  29. package/lib/value-parser/walk.js +16 -0
  30. package/nesting/index.d.ts +4 -0
  31. package/package.json +5 -6
  32. package/peers/index.js +701 -617
  33. package/src/cli/build/plugin.js +2 -2
  34. package/src/cli/build/watching.js +1 -1
  35. package/src/corePlugins.js +13 -7
  36. package/src/css/preflight.css +9 -0
  37. package/src/featureFlags.js +0 -1
  38. package/src/lib/defaultExtractor.js +12 -13
  39. package/src/lib/evaluateTailwindFunctions.js +4 -1
  40. package/src/lib/expandApplyAtRules.js +7 -0
  41. package/src/lib/expandTailwindAtRules.js +20 -6
  42. package/src/lib/generateRules.js +34 -25
  43. package/src/lib/setupContextUtils.js +50 -35
  44. package/src/lib/setupTrackingContext.js +1 -3
  45. package/src/oxide/cli/build/plugin.ts +2 -2
  46. package/src/plugin.js +3 -3
  47. package/src/processTailwindFeatures.js +3 -2
  48. package/src/util/color.js +1 -1
  49. package/src/util/dataTypes.js +101 -18
  50. package/src/util/formatVariantSelector.js +11 -3
  51. package/src/util/isPlainObject.js +1 -1
  52. package/src/util/prefixSelector.js +1 -0
  53. package/src/util/pseudoElements.js +14 -17
  54. package/src/value-parser/LICENSE +22 -0
  55. package/src/value-parser/README.md +3 -0
  56. package/src/value-parser/index.d.ts +177 -0
  57. package/src/value-parser/index.js +28 -0
  58. package/src/value-parser/parse.js +303 -0
  59. package/src/value-parser/stringify.js +41 -0
  60. package/src/value-parser/unit.js +118 -0
  61. package/src/value-parser/walk.js +18 -0
  62. package/stubs/config.full.js +1 -0
  63. package/types/config.d.ts +6 -6
  64. package/types/generated/default-theme.d.ts +1 -0
  65. package/types/index.d.ts +7 -3
@@ -244,9 +244,9 @@ async function createProcessor(args, cliConfigPath) {
244
244
  let tailwindPlugin = ()=>{
245
245
  return {
246
246
  postcssPlugin: "tailwindcss",
247
- Once (root, { result }) {
247
+ async Once (root, { result }) {
248
248
  _sharedState.env.DEBUG && console.time("Compiling CSS");
249
- (0, _processTailwindFeatures.default)(({ createContext })=>{
249
+ await (0, _processTailwindFeatures.default)(({ createContext })=>{
250
250
  console.error();
251
251
  console.error("Rebuilding...");
252
252
  return ()=>{
package/lib/plugin.js CHANGED
@@ -20,7 +20,7 @@ module.exports = function tailwindcss(configOrPath) {
20
20
  console.time("JIT TOTAL");
21
21
  return root;
22
22
  },
23
- function(root, result) {
23
+ async function(root, result) {
24
24
  var _findAtConfigPath1;
25
25
  // Use the path for the `@config` directive if it exists, otherwise use the
26
26
  // path for the file being processed
@@ -30,12 +30,12 @@ module.exports = function tailwindcss(configOrPath) {
30
30
  let roots = root.nodes.filter((node)=>node.type === "root");
31
31
  for (const root of roots){
32
32
  if (root.type === "root") {
33
- (0, _processTailwindFeatures.default)(context)(root, result);
33
+ await (0, _processTailwindFeatures.default)(context)(root, result);
34
34
  }
35
35
  }
36
36
  return;
37
37
  }
38
- (0, _processTailwindFeatures.default)(context)(root, result);
38
+ await (0, _processTailwindFeatures.default)(context)(root, result);
39
39
  },
40
40
  false && function lightningCssPlugin(_root, result) {
41
41
  let postcss = require("postcss");
@@ -26,7 +26,7 @@ function _interop_require_default(obj) {
26
26
  };
27
27
  }
28
28
  function processTailwindFeatures(setupContext) {
29
- return function(root, result) {
29
+ return async function(root, result) {
30
30
  let { tailwindDirectives , applyDirectives } = (0, _normalizeTailwindDirectives.default)(root);
31
31
  (0, _detectNesting.default)()(root, result);
32
32
  // Partition apply rules that are found in the css
@@ -50,7 +50,7 @@ function processTailwindFeatures(setupContext) {
50
50
  throw new Error("The '-' character cannot be used as a custom separator in JIT mode due to parsing ambiguity. Please use another character like '_' instead.");
51
51
  }
52
52
  (0, _featureFlags.issueFlagNotices)(context.tailwindConfig);
53
- (0, _expandTailwindAtRules.default)(context)(root, result);
53
+ await (0, _expandTailwindAtRules.default)(context)(root, result);
54
54
  // Partition apply rules that are generated by
55
55
  // addComponents, addUtilities and so on.
56
56
  (0, _partitionApplyAtRules.default)()(root, result);
package/lib/util/color.js CHANGED
@@ -27,7 +27,7 @@ let SHORT_HEX = /^#([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i;
27
27
  let VALUE = /(?:\d+|\d*\.\d+)%?/;
28
28
  let SEP = /(?:\s*,\s*|\s+)/;
29
29
  let ALPHA_SEP = /\s*[,/]\s*/;
30
- let CUSTOM_PROPERTY = /var\(--(?:[^ )]*?)\)/;
30
+ let CUSTOM_PROPERTY = /var\(--(?:[^ )]*?)(?:,(?:[^ )]*?|var\(--[^ )]*?\)))?\)/;
31
31
  let RGB = new RegExp(`^(rgba?)\\(\\s*(${VALUE.source}|${CUSTOM_PROPERTY.source})(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${ALPHA_SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?\\s*\\)$`);
32
32
  let HSL = new RegExp(`^(hsla?)\\(\\s*((?:${VALUE.source})(?:deg|rad|grad|turn)?|${CUSTOM_PROPERTY.source})(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${ALPHA_SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?\\s*\\)$`);
33
33
  function parseColor(value, { loose =false } = {}) {
@@ -68,10 +68,30 @@ let cssFunctions = [
68
68
  function isCSSFunction(value) {
69
69
  return cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.*\\)`).test(value));
70
70
  }
71
- const placeholder = "--tw-placeholder";
72
- const placeholderRe = new RegExp(placeholder, "g");
73
- function normalize(value, isRoot = true) {
74
- if (value.startsWith("--")) {
71
+ // These properties accept a `<dashed-ident>` as one of the values. This means that you can use them
72
+ // as: `timeline-scope: --tl;`
73
+ //
74
+ // Without the `var(--tl)`, in these cases we don't want to normalize the value, and you should add
75
+ // the `var()` yourself.
76
+ //
77
+ // More info:
78
+ // - https://drafts.csswg.org/scroll-animations/#propdef-timeline-scope
79
+ // - https://developer.mozilla.org/en-US/docs/Web/CSS/timeline-scope#dashed-ident
80
+ //
81
+ const AUTO_VAR_INJECTION_EXCEPTIONS = new Set([
82
+ // Concrete properties
83
+ "scroll-timeline-name",
84
+ "timeline-scope",
85
+ "view-timeline-name",
86
+ "font-palette",
87
+ // Shorthand properties
88
+ "scroll-timeline",
89
+ "animation-timeline",
90
+ "view-timeline"
91
+ ]);
92
+ function normalize(value, context = null, isRoot = true) {
93
+ let isVarException = context && AUTO_VAR_INJECTION_EXCEPTIONS.has(context.property);
94
+ if (value.startsWith("--") && !isVarException) {
75
95
  return `var(${value})`;
76
96
  }
77
97
  // Keep raw strings if it starts with `url(`
@@ -80,7 +100,7 @@ function normalize(value, isRoot = true) {
80
100
  if (/^url\(.*?\)$/.test(part)) {
81
101
  return part;
82
102
  }
83
- return normalize(part, false);
103
+ return normalize(part, context, false);
84
104
  }).join("");
85
105
  }
86
106
  // Convert `_` to ` `, except for escaped underscores `\_`
@@ -89,17 +109,80 @@ function normalize(value, isRoot = true) {
89
109
  if (isRoot) {
90
110
  value = value.trim();
91
111
  }
92
- // Add spaces around operators inside math functions like calc() that do not follow an operator
93
- // or '('.
94
- value = value.replace(/(calc|min|max|clamp)\(.+\)/g, (match)=>{
95
- let vars = [];
96
- return match.replace(/var\((--.+?)[,)]/g, (match, g1)=>{
97
- vars.push(g1);
98
- return match.replace(g1, placeholder);
99
- }).replace(/(-?\d*\.?\d(?!\b-\d.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ").replace(placeholderRe, ()=>vars.shift());
100
- });
112
+ value = normalizeMathOperatorSpacing(value);
101
113
  return value;
102
114
  }
115
+ /**
116
+ * Add spaces around operators inside math functions
117
+ * like calc() that do not follow an operator or '('.
118
+ *
119
+ * @param {string} value
120
+ * @returns {string}
121
+ */ function normalizeMathOperatorSpacing(value) {
122
+ let preventFormattingInFunctions = [
123
+ "theme"
124
+ ];
125
+ return value.replace(/(calc|min|max|clamp)\(.+\)/g, (match)=>{
126
+ let result = "";
127
+ function lastChar() {
128
+ let char = result.trimEnd();
129
+ return char[char.length - 1];
130
+ }
131
+ for(let i = 0; i < match.length; i++){
132
+ function peek(word) {
133
+ return word.split("").every((char, j)=>match[i + j] === char);
134
+ }
135
+ function consumeUntil(chars) {
136
+ let minIndex = Infinity;
137
+ for (let char of chars){
138
+ let index = match.indexOf(char, i);
139
+ if (index !== -1 && index < minIndex) {
140
+ minIndex = index;
141
+ }
142
+ }
143
+ let result = match.slice(i, minIndex);
144
+ i += result.length - 1;
145
+ return result;
146
+ }
147
+ let char = match[i];
148
+ // Handle `var(--variable)`
149
+ if (peek("var")) {
150
+ // When we consume until `)`, then we are dealing with this scenario:
151
+ // `var(--example)`
152
+ //
153
+ // When we consume until `,`, then we are dealing with this scenario:
154
+ // `var(--example, 1rem)`
155
+ //
156
+ // In this case we do want to "format", the default value as well
157
+ result += consumeUntil([
158
+ ")",
159
+ ","
160
+ ]);
161
+ } else if (preventFormattingInFunctions.some((fn)=>peek(fn))) {
162
+ result += consumeUntil([
163
+ ")"
164
+ ]);
165
+ } else if ([
166
+ "+",
167
+ "-",
168
+ "*",
169
+ "/"
170
+ ].includes(char) && ![
171
+ "(",
172
+ "+",
173
+ "-",
174
+ "*",
175
+ "/"
176
+ ].includes(lastChar())) {
177
+ result += ` ${char} `;
178
+ } else {
179
+ result += char;
180
+ }
181
+ }
182
+ // Simplify multiple spaces
183
+ return result.replace(/\s+/g, " ");
184
+ });
185
+ }
103
186
  function url(value) {
104
187
  return value.startsWith("url(");
105
188
  }
@@ -199,11 +282,12 @@ function image(value) {
199
282
  return images > 0;
200
283
  }
201
284
  let gradientTypes = new Set([
285
+ "conic-gradient",
202
286
  "linear-gradient",
203
287
  "radial-gradient",
288
+ "repeating-conic-gradient",
204
289
  "repeating-linear-gradient",
205
- "repeating-radial-gradient",
206
- "conic-gradient"
290
+ "repeating-radial-gradient"
207
291
  ]);
208
292
  function gradient(value) {
209
293
  value = normalize(value);
@@ -27,12 +27,13 @@ const _unesc = /*#__PURE__*/ _interop_require_default(require("postcss-selector-
27
27
  const _escapeClassName = /*#__PURE__*/ _interop_require_default(require("../util/escapeClassName"));
28
28
  const _prefixSelector = /*#__PURE__*/ _interop_require_default(require("../util/prefixSelector"));
29
29
  const _pseudoElements = require("./pseudoElements");
30
+ const _splitAtTopLevelOnly = require("./splitAtTopLevelOnly");
30
31
  function _interop_require_default(obj) {
31
32
  return obj && obj.__esModule ? obj : {
32
33
  default: obj
33
34
  };
34
35
  }
35
- /** @typedef {import('postcss-selector-parser').Root} Root */ /** @typedef {import('postcss-selector-parser').Selector} Selector */ /** @typedef {import('postcss-selector-parser').Pseudo} Pseudo */ /** @typedef {import('postcss-selector-parser').Node} Node */ /** @typedef {{format: string, isArbitraryVariant: boolean}[]} RawFormats */ /** @typedef {import('postcss-selector-parser').Root} ParsedFormats */ /** @typedef {RawFormats | ParsedFormats} AcceptedFormats */ let MERGE = ":merge";
36
+ /** @typedef {import('postcss-selector-parser').Root} Root */ /** @typedef {import('postcss-selector-parser').Selector} Selector */ /** @typedef {import('postcss-selector-parser').Pseudo} Pseudo */ /** @typedef {import('postcss-selector-parser').Node} Node */ /** @typedef {{format: string, respectPrefix: boolean}[]} RawFormats */ /** @typedef {import('postcss-selector-parser').Root} ParsedFormats */ /** @typedef {RawFormats | ParsedFormats} AcceptedFormats */ let MERGE = ":merge";
36
37
  function formatVariantSelector(formats, { context , candidate }) {
37
38
  var _context_tailwindConfig_prefix;
38
39
  let prefix = (_context_tailwindConfig_prefix = context === null || context === void 0 ? void 0 : context.tailwindConfig.prefix) !== null && _context_tailwindConfig_prefix !== void 0 ? _context_tailwindConfig_prefix : "";
@@ -41,7 +42,7 @@ function formatVariantSelector(formats, { context , candidate }) {
41
42
  let ast = (0, _postcssselectorparser.default)().astSync(format.format);
42
43
  return {
43
44
  ...format,
44
- ast: format.isArbitraryVariant ? ast : (0, _prefixSelector.default)(prefix, ast)
45
+ ast: format.respectPrefix ? (0, _prefixSelector.default)(prefix, ast) : ast
45
46
  };
46
47
  });
47
48
  // We start with the candidate selector
@@ -138,7 +139,7 @@ function finalizeSelector(current, formats, { context , candidate , base }) {
138
139
  // │ │ │ ╰── We will not split here
139
140
  // ╰──┴─────┴─────────────── We will split here
140
141
  //
141
- base = base !== null && base !== void 0 ? base : candidate.split(new RegExp(`\\${separator}(?![^[]*\\])`)).pop();
142
+ base = base !== null && base !== void 0 ? base : (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(candidate, separator).pop();
142
143
  // Parse the selector into an AST
143
144
  let selector = (0, _postcssselectorparser.default)().astSync(current);
144
145
  // Normalize escaped classes, e.g.:
@@ -159,6 +160,12 @@ function finalizeSelector(current, formats, { context , candidate , base }) {
159
160
  });
160
161
  // Remove extraneous selectors that do not include the base candidate
161
162
  selector.each((sel)=>eliminateIrrelevantSelectors(sel, base));
163
+ // If ffter eliminating irrelevant selectors, we end up with nothing
164
+ // Then the whole "rule" this is associated with does not need to exist
165
+ // We use `null` as a marker value for that case
166
+ if (selector.length === 0) {
167
+ return null;
168
+ }
162
169
  // If there are no formats that means there were no variants added to the candidate
163
170
  // so we can just return the selector as-is
164
171
  let formatAst = Array.isArray(formats) ? formatVariantSelector(formats, {
@@ -13,5 +13,5 @@ function isPlainObject(value) {
13
13
  return false;
14
14
  }
15
15
  const prototype = Object.getPrototypeOf(value);
16
- return prototype === null || prototype === Object.prototype;
16
+ return prototype === null || Object.getPrototypeOf(prototype) === null;
17
17
  }
@@ -29,7 +29,7 @@ function _default(prefix, selector, prependNegative = false) {
29
29
  if (prefix === "") {
30
30
  return selector;
31
31
  }
32
- let ast = typeof selector === "string" ? (0, _postcssselectorparser.default)().astSync(selector) : selector;
32
+ /** @type {import('postcss-selector-parser').Root} */ let ast = typeof selector === "string" ? (0, _postcssselectorparser.default)().astSync(selector) : selector;
33
33
  ast.walkClasses((classSelector)=>{
34
34
  let baseClass = classSelector.value;
35
35
  let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith("-");
@@ -11,7 +11,7 @@
11
11
  // **Jumpable**
12
12
  // Any terminal element may "jump" over combinators when moving to the end of the selector
13
13
  //
14
- // This is a backwards-compat quirk of :before and :after variants.
14
+ // This is a backwards-compat quirk of pseudo element variants from earlier versions of Tailwind CSS.
15
15
  /** @typedef {'terminal' | 'actionable' | 'jumpable'} PseudoProperty */ /** @type {Record<string, PseudoProperty[]>} */ "use strict";
16
16
  Object.defineProperty(exports, "__esModule", {
17
17
  value: true
@@ -23,12 +23,14 @@ Object.defineProperty(exports, "movePseudos", {
23
23
  }
24
24
  });
25
25
  let elementProperties = {
26
+ // Pseudo elements from the spec
26
27
  "::after": [
27
28
  "terminal",
28
29
  "jumpable"
29
30
  ],
30
31
  "::backdrop": [
31
- "terminal"
32
+ "terminal",
33
+ "jumpable"
32
34
  ],
33
35
  "::before": [
34
36
  "terminal",
@@ -52,17 +54,20 @@ let elementProperties = {
52
54
  "terminal"
53
55
  ],
54
56
  "::marker": [
55
- "terminal"
57
+ "terminal",
58
+ "jumpable"
56
59
  ],
57
60
  "::part": [
58
61
  "terminal",
59
62
  "actionable"
60
63
  ],
61
64
  "::placeholder": [
62
- "terminal"
65
+ "terminal",
66
+ "jumpable"
63
67
  ],
64
68
  "::selection": [
65
- "terminal"
69
+ "terminal",
70
+ "jumpable"
66
71
  ],
67
72
  "::slotted": [
68
73
  "terminal"
@@ -73,42 +78,20 @@ let elementProperties = {
73
78
  "::target-text": [
74
79
  "terminal"
75
80
  ],
76
- // other
81
+ // Pseudo elements from the spec with special rules
77
82
  "::file-selector-button": [
78
83
  "terminal",
79
84
  "actionable"
80
85
  ],
81
- "::-webkit-progress-bar": [
82
- "terminal",
86
+ // Library-specific pseudo elements used by component libraries
87
+ // These are Shadow DOM-like
88
+ "::deep": [
83
89
  "actionable"
84
90
  ],
85
- // Webkit scroll bar pseudo elements can be combined with user-action pseudo classes
86
- "::-webkit-scrollbar": [
87
- "terminal",
91
+ "::v-deep": [
88
92
  "actionable"
89
93
  ],
90
- "::-webkit-scrollbar-button": [
91
- "terminal",
92
- "actionable"
93
- ],
94
- "::-webkit-scrollbar-thumb": [
95
- "terminal",
96
- "actionable"
97
- ],
98
- "::-webkit-scrollbar-track": [
99
- "terminal",
100
- "actionable"
101
- ],
102
- "::-webkit-scrollbar-track-piece": [
103
- "terminal",
104
- "actionable"
105
- ],
106
- "::-webkit-scrollbar-corner": [
107
- "terminal",
108
- "actionable"
109
- ],
110
- "::-webkit-resizer": [
111
- "terminal",
94
+ "::ng-deep": [
112
95
  "actionable"
113
96
  ],
114
97
  // Note: As a rule, double colons (::) should be used instead of a single colon
@@ -133,8 +116,9 @@ let elementProperties = {
133
116
  ],
134
117
  // The default value is used when the pseudo-element is not recognized
135
118
  // Because it's not recognized, we don't know if it's terminal or not
136
- // So we assume it can't be moved AND can have user-action pseudo classes attached to it
119
+ // So we assume it can be moved AND can have user-action pseudo classes attached to it
137
120
  __default__: [
121
+ "terminal",
138
122
  "actionable"
139
123
  ]
140
124
  };
@@ -0,0 +1,22 @@
1
+ Copyright (c) Bogdan Chadkin <trysound@yandex.ru>
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ # postcss-value-parser (forked + inlined)
2
+
3
+ This is a customized version of of [PostCSS Value Parser](https://github.com/TrySound/postcss-value-parser) to fix some bugs around parsing CSS functions.
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ module.exports = postcssValueParser;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var parse = require("./parse");
3
+ var walk = require("./walk");
4
+ var stringify = require("./stringify");
5
+ function ValueParser(value) {
6
+ if (this instanceof ValueParser) {
7
+ this.nodes = parse(value);
8
+ return this;
9
+ }
10
+ return new ValueParser(value);
11
+ }
12
+ ValueParser.prototype.toString = function() {
13
+ return Array.isArray(this.nodes) ? stringify(this.nodes) : "";
14
+ };
15
+ ValueParser.prototype.walk = function(cb, bubble) {
16
+ walk(this.nodes, cb, bubble);
17
+ return this;
18
+ };
19
+ ValueParser.unit = require("./unit");
20
+ ValueParser.walk = walk;
21
+ ValueParser.stringify = stringify;
22
+ module.exports = ValueParser;