tailwindcss 0.0.0-oxide-insiders.a7fe2fe → 0.0.0-oxide-insiders.7f555c4

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 (108) hide show
  1. package/lib/cli/build/deps.js +34 -18
  2. package/lib/cli/build/index.js +45 -12
  3. package/lib/cli/build/plugin.js +273 -90
  4. package/lib/cli/build/utils.js +56 -24
  5. package/lib/cli/build/watching.js +156 -38
  6. package/lib/cli/help/index.js +61 -16
  7. package/lib/cli/index.js +121 -62
  8. package/lib/cli/init/index.js +47 -23
  9. package/lib/cli-peer-dependencies.js +23 -13
  10. package/lib/cli.js +5 -1
  11. package/lib/corePluginList.js +7 -4
  12. package/lib/corePlugins.js +855 -386
  13. package/lib/featureFlags.js +43 -18
  14. package/lib/lib/cacheInvalidation.js +78 -30
  15. package/lib/lib/collapseAdjacentRules.js +46 -23
  16. package/lib/lib/collapseDuplicateDeclarations.js +70 -27
  17. package/lib/lib/content.js +134 -41
  18. package/lib/lib/defaultExtractor.js +201 -96
  19. package/lib/lib/detectNesting.js +38 -12
  20. package/lib/lib/evaluateTailwindFunctions.js +192 -103
  21. package/lib/lib/expandApplyAtRules.js +488 -181
  22. package/lib/lib/expandTailwindAtRules.js +240 -70
  23. package/lib/lib/findAtConfigPath.js +34 -15
  24. package/lib/lib/generateRules.js +775 -353
  25. package/lib/lib/getModuleDependencies.js +67 -29
  26. package/lib/lib/load-config.js +27 -17
  27. package/lib/lib/normalizeTailwindDirectives.js +73 -27
  28. package/lib/lib/offsets.js +227 -62
  29. package/lib/lib/partitionApplyAtRules.js +53 -29
  30. package/lib/lib/regex.js +50 -28
  31. package/lib/lib/remap-bitfield.js +86 -9
  32. package/lib/lib/resolveDefaultsAtRules.js +123 -53
  33. package/lib/lib/setupContextUtils.js +1117 -584
  34. package/lib/lib/setupTrackingContext.js +149 -58
  35. package/lib/lib/sharedState.js +71 -23
  36. package/lib/lib/substituteScreenAtRules.js +19 -9
  37. package/lib/oxide/cli/build/deps.js +46 -23
  38. package/lib/oxide/cli/build/index.js +44 -12
  39. package/lib/oxide/cli/build/plugin.js +271 -89
  40. package/lib/oxide/cli/build/utils.js +55 -24
  41. package/lib/oxide/cli/build/watching.js +153 -36
  42. package/lib/oxide/cli/help/index.js +60 -16
  43. package/lib/oxide/cli/index.js +128 -67
  44. package/lib/oxide/cli/init/index.js +40 -19
  45. package/lib/oxide/cli.js +3 -2
  46. package/lib/plugin.js +58 -31
  47. package/lib/postcss-plugins/nesting/index.js +13 -7
  48. package/lib/postcss-plugins/nesting/plugin.js +65 -20
  49. package/lib/processTailwindFeatures.js +41 -10
  50. package/lib/public/colors.js +25 -16
  51. package/lib/public/create-plugin.js +11 -6
  52. package/lib/public/default-config.js +12 -6
  53. package/lib/public/default-theme.js +12 -6
  54. package/lib/public/load-config.js +9 -5
  55. package/lib/public/resolve-config.js +10 -6
  56. package/lib/util/applyImportantSelector.js +28 -17
  57. package/lib/util/bigSign.js +9 -6
  58. package/lib/util/buildMediaQuery.js +19 -10
  59. package/lib/util/cloneDeep.js +19 -9
  60. package/lib/util/cloneNodes.js +29 -14
  61. package/lib/util/color.js +87 -47
  62. package/lib/util/colorNames.js +752 -0
  63. package/lib/util/configurePlugins.js +18 -9
  64. package/lib/util/createPlugin.js +17 -8
  65. package/lib/util/createUtilityPlugin.js +30 -16
  66. package/lib/util/dataTypes.js +189 -38
  67. package/lib/util/defaults.js +21 -9
  68. package/lib/util/escapeClassName.js +15 -9
  69. package/lib/util/escapeCommas.js +9 -6
  70. package/lib/util/flattenColorPalette.js +11 -7
  71. package/lib/util/formatVariantSelector.js +209 -60
  72. package/lib/util/getAllConfigs.js +44 -35
  73. package/lib/util/hashConfig.js +12 -8
  74. package/lib/util/isKeyframeRule.js +10 -7
  75. package/lib/util/isPlainObject.js +14 -9
  76. package/lib/util/isSyntacticallyValidPropertyValue.js +45 -14
  77. package/lib/util/log.js +20 -9
  78. package/lib/util/nameClass.js +31 -10
  79. package/lib/util/negateValue.js +28 -10
  80. package/lib/util/normalizeConfig.js +242 -63
  81. package/lib/util/normalizeScreens.js +145 -70
  82. package/lib/util/parseAnimationValue.js +64 -14
  83. package/lib/util/parseBoxShadowValue.js +63 -14
  84. package/lib/util/parseDependency.js +39 -13
  85. package/lib/util/parseGlob.js +25 -8
  86. package/lib/util/parseObjectStyles.js +29 -18
  87. package/lib/util/pluginUtils.js +196 -77
  88. package/lib/util/prefixSelector.js +31 -12
  89. package/lib/util/pseudoElements.js +116 -34
  90. package/lib/util/removeAlphaVariables.js +23 -8
  91. package/lib/util/resolveConfig.js +224 -105
  92. package/lib/util/resolveConfigPath.js +45 -15
  93. package/lib/util/responsive.js +10 -6
  94. package/lib/util/splitAtTopLevelOnly.js +46 -10
  95. package/lib/util/tap.js +11 -7
  96. package/lib/util/toColorValue.js +10 -7
  97. package/lib/util/toPath.js +28 -8
  98. package/lib/util/transformThemeValue.js +49 -14
  99. package/lib/util/validateConfig.js +25 -15
  100. package/lib/util/validateFormalSyntax.js +14 -6
  101. package/lib/util/withAlphaVariable.js +54 -30
  102. package/package.json +18 -22
  103. package/peers/index.js +57849 -43101
  104. package/src/lib/expandTailwindAtRules.js +1 -1
  105. package/src/lib/setupTrackingContext.js +1 -1
  106. package/src/util/color.js +1 -1
  107. package/src/util/colorNames.js +150 -0
  108. package/src/util/pseudoElements.js +4 -4
@@ -1,88 +1,152 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
- value: !0
4
- }), Object.defineProperty(exports, "defaultExtractor", {
5
- enumerable: !0,
6
- get: ()=>defaultExtractor
3
+ value: true
7
4
  });
8
- const _featureFlags = require("../featureFlags"), _regex = function(obj, nodeInterop) {
9
- if (!nodeInterop && obj && obj.__esModule) return obj;
10
- if (null === obj || "object" != typeof obj && "function" != typeof obj) return {
11
- default: obj
12
- };
13
- var cache = _getRequireWildcardCache(nodeInterop);
14
- if (cache && cache.has(obj)) return cache.get(obj);
15
- var newObj = {}, hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
16
- for(var key in obj)if ("default" !== key && Object.prototype.hasOwnProperty.call(obj, key)) {
17
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
18
- desc && (desc.get || desc.set) ? Object.defineProperty(newObj, key, desc) : newObj[key] = obj[key];
5
+ Object.defineProperty(exports, "defaultExtractor", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return defaultExtractor;
19
9
  }
20
- return newObj.default = obj, cache && cache.set(obj, newObj), newObj;
21
- }(require("./regex"));
10
+ });
11
+ const _featureFlags = require("../featureFlags");
12
+ const _regex = /*#__PURE__*/ _interop_require_wildcard(require("./regex"));
22
13
  function _getRequireWildcardCache(nodeInterop) {
23
- if ("function" != typeof WeakMap) return null;
24
- var cacheBabelInterop = new WeakMap(), cacheNodeInterop = new WeakMap();
14
+ if (typeof WeakMap !== "function") return null;
15
+ var cacheBabelInterop = new WeakMap();
16
+ var cacheNodeInterop = new WeakMap();
25
17
  return (_getRequireWildcardCache = function(nodeInterop) {
26
18
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
27
19
  })(nodeInterop);
28
20
  }
21
+ function _interop_require_wildcard(obj, nodeInterop) {
22
+ if (!nodeInterop && obj && obj.__esModule) {
23
+ return obj;
24
+ }
25
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
26
+ return {
27
+ default: obj
28
+ };
29
+ }
30
+ var cache = _getRequireWildcardCache(nodeInterop);
31
+ if (cache && cache.has(obj)) {
32
+ return cache.get(obj);
33
+ }
34
+ var newObj = {};
35
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
36
+ for(var key in obj){
37
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
38
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
39
+ if (desc && (desc.get || desc.set)) {
40
+ Object.defineProperty(newObj, key, desc);
41
+ } else {
42
+ newObj[key] = obj[key];
43
+ }
44
+ }
45
+ }
46
+ newObj.default = obj;
47
+ if (cache) {
48
+ cache.set(obj, newObj);
49
+ }
50
+ return newObj;
51
+ }
29
52
  function defaultExtractor(context) {
30
- let patterns = Array.from(function*(context) {
31
- let separator = context.tailwindConfig.separator, variantGroupingEnabled = (0, _featureFlags.flagEnabled)(context.tailwindConfig, "variantGrouping"), prefix = "" !== context.tailwindConfig.prefix ? _regex.optional(_regex.pattern([
32
- /-?/,
33
- _regex.escape(context.tailwindConfig.prefix)
34
- ])) : "", utility = _regex.any([
35
- /\[[^\s:'"`]+:[^\s\[\]]+\]/,
36
- /\[[^\s:'"`]+:[^\s]+?\[[^\s]+\][^\s]+?\]/,
37
- _regex.pattern([
38
- /-?(?:\w+)/,
39
- _regex.optional(_regex.any([
40
- _regex.pattern([
41
- /-(?:\w+-)*\[[^\s:]+\]/,
42
- /(?![{([]])/,
43
- /(?:\/[^\s'"`\\><$]*)?/
44
- ]),
45
- _regex.pattern([
46
- /-(?:\w+-)*\[[^\s]+\]/,
47
- /(?![{([]])/,
48
- /(?:\/[^\s'"`\\$]*)?/
49
- ]),
50
- /[-\/][^\s'"`\\$={><]*/
51
- ]))
52
- ])
53
- ]);
54
- for (let variantPattern of [
55
- _regex.any([
53
+ let patterns = Array.from(buildRegExps(context));
54
+ /**
55
+ * @param {string} content
56
+ */ return (content)=>{
57
+ /** @type {(string|string)[]} */ let results = [];
58
+ for (let pattern of patterns){
59
+ var _content_match;
60
+ results = [
61
+ ...results,
62
+ ...(_content_match = content.match(pattern)) !== null && _content_match !== void 0 ? _content_match : []
63
+ ];
64
+ }
65
+ return results.filter((v)=>v !== undefined).map(clipAtBalancedParens);
66
+ };
67
+ }
68
+ function* buildRegExps(context) {
69
+ let separator = context.tailwindConfig.separator;
70
+ let variantGroupingEnabled = (0, _featureFlags.flagEnabled)(context.tailwindConfig, "variantGrouping");
71
+ let prefix = context.tailwindConfig.prefix !== "" ? _regex.optional(_regex.pattern([
72
+ /-?/,
73
+ _regex.escape(context.tailwindConfig.prefix)
74
+ ])) : "";
75
+ let utility = _regex.any([
76
+ // Arbitrary properties (without square brackets)
77
+ /\[[^\s:'"`]+:[^\s\[\]]+\]/,
78
+ // Arbitrary properties with balanced square brackets
79
+ // This is a targeted fix to continue to allow theme()
80
+ // with square brackets to work in arbitrary properties
81
+ // while fixing a problem with the regex matching too much
82
+ /\[[^\s:'"`]+:[^\s]+?\[[^\s]+\][^\s]+?\]/,
83
+ // Utilities
84
+ _regex.pattern([
85
+ // Utility Name / Group Name
86
+ /-?(?:\w+)/,
87
+ // Normal/Arbitrary values
88
+ _regex.optional(_regex.any([
56
89
  _regex.pattern([
57
- /@\[[^\s"'`]+\](\/[^\s"'`]+)?/,
58
- separator
90
+ // Arbitrary values
91
+ /-(?:\w+-)*\[[^\s:]+\]/,
92
+ // Not immediately followed by an `{[(`
93
+ /(?![{([]])/,
94
+ // optionally followed by an opacity modifier
95
+ /(?:\/[^\s'"`\\><$]*)?/
59
96
  ]),
60
97
  _regex.pattern([
61
- /([^\s"'`\[\\]+-)?\[[^\s"'`]+\]/,
62
- separator
98
+ // Arbitrary values
99
+ /-(?:\w+-)*\[[^\s]+\]/,
100
+ // Not immediately followed by an `{[(`
101
+ /(?![{([]])/,
102
+ // optionally followed by an opacity modifier
103
+ /(?:\/[^\s'"`\\$]*)?/
63
104
  ]),
64
- _regex.pattern([
65
- /[^\s"'`\[\\]+/,
66
- separator
67
- ])
105
+ // Normal values w/o quotes — may include an opacity modifier
106
+ /[-\/][^\s'"`\\$={><]*/
107
+ ]))
108
+ ])
109
+ ]);
110
+ let variantPatterns = [
111
+ // Without quotes
112
+ _regex.any([
113
+ // This is here to provide special support for the `@` variant
114
+ _regex.pattern([
115
+ /@\[[^\s"'`]+\](\/[^\s"'`]+)?/,
116
+ separator
68
117
  ]),
69
- _regex.any([
70
- _regex.pattern([
71
- /([^\s"'`\[\\]+-)?\[[^\s`]+\]/,
72
- separator
73
- ]),
74
- _regex.pattern([
75
- /[^\s`\[\\]+/,
76
- separator
77
- ])
118
+ _regex.pattern([
119
+ /([^\s"'`\[\\]+-)?\[[^\s"'`]+\]/,
120
+ separator
121
+ ]),
122
+ _regex.pattern([
123
+ /[^\s"'`\[\\]+/,
124
+ separator
78
125
  ])
79
- ])yield _regex.pattern([
126
+ ]),
127
+ // With quotes allowed
128
+ _regex.any([
129
+ _regex.pattern([
130
+ /([^\s"'`\[\\]+-)?\[[^\s`]+\]/,
131
+ separator
132
+ ]),
133
+ _regex.pattern([
134
+ /[^\s`\[\\]+/,
135
+ separator
136
+ ])
137
+ ])
138
+ ];
139
+ for (const variantPattern of variantPatterns){
140
+ yield _regex.pattern([
141
+ // Variants
80
142
  "((?=((",
81
143
  variantPattern,
82
144
  ")+))\\2)?",
145
+ // Important (optional)
83
146
  /!?/,
84
147
  prefix,
85
148
  variantGroupingEnabled ? _regex.any([
149
+ // Or any of those things but grouped separated by commas
86
150
  _regex.pattern([
87
151
  /\(/,
88
152
  utility,
@@ -92,47 +156,88 @@ function defaultExtractor(context) {
92
156
  ]),
93
157
  /\)/
94
158
  ]),
159
+ // Arbitrary properties, constrained utilities, arbitrary values, etc…
95
160
  utility
96
161
  ]) : utility
97
162
  ]);
98
- yield /[^<>"'`\s.(){}[\]#=%$]*[^<>"'`\s.(){}[\]#=%:$]/g;
99
- }(context));
100
- return (content)=>{
101
- let results = [];
102
- for (let pattern of patterns){
103
- var _content_match;
104
- results = [
105
- ...results,
106
- ...null !== (_content_match = content.match(pattern)) && void 0 !== _content_match ? _content_match : []
107
- ];
108
- }
109
- return results.filter((v)=>void 0 !== v).map(clipAtBalancedParens);
110
- };
163
+ }
164
+ // 5. Inner matches
165
+ yield /[^<>"'`\s.(){}[\]#=%$]*[^<>"'`\s.(){}[\]#=%:$]/g;
111
166
  }
112
- let SPECIALS = /([\[\]'"`])([^\[\]'"`])?/g, ALLOWED_CLASS_CHARACTERS = /[^"'`\s<>\]]+/;
113
- function clipAtBalancedParens(input) {
114
- if (!input.includes("-[")) return input;
115
- let depth = 0, openStringTypes = [], matches = input.matchAll(SPECIALS);
116
- for (let match of matches = Array.from(matches).flatMap((match)=>{
117
- let [, ...groups] = match;
167
+ // We want to capture any "special" characters
168
+ // AND the characters immediately following them (if there is one)
169
+ let SPECIALS = /([\[\]'"`])([^\[\]'"`])?/g;
170
+ let ALLOWED_CLASS_CHARACTERS = /[^"'`\s<>\]]+/;
171
+ /**
172
+ * Clips a string ensuring that parentheses, quotes, etc… are balanced
173
+ * Used for arbitrary values only
174
+ *
175
+ * We will go past the end of the balanced parens until we find a non-class character
176
+ *
177
+ * Depth matching behavior:
178
+ * w-[calc(100%-theme('spacing[some_key][1.5]'))]']
179
+ * ┬ ┬ ┬┬ ┬ ┬┬ ┬┬┬┬┬┬┬
180
+ * 1 2 3 4 34 3 210 END
181
+ * ╰────┴──────────┴────────┴────────┴┴───┴─┴┴┴
182
+ *
183
+ * @param {string} input
184
+ */ function clipAtBalancedParens(input) {
185
+ // We are care about this for arbitrary values
186
+ if (!input.includes("-[")) {
187
+ return input;
188
+ }
189
+ let depth = 0;
190
+ let openStringTypes = [];
191
+ // Find all parens, brackets, quotes, etc
192
+ // Stop when we end at a balanced pair
193
+ // This is naive and will treat mismatched parens as balanced
194
+ // This shouldn't be a problem in practice though
195
+ let matches = input.matchAll(SPECIALS);
196
+ // We can't use lookbehind assertions because we have to support Safari
197
+ // So, instead, we've emulated it using capture groups and we'll re-work the matches to accommodate
198
+ matches = Array.from(matches).flatMap((match)=>{
199
+ const [, ...groups] = match;
118
200
  return groups.map((group, idx)=>Object.assign([], match, {
119
201
  index: match.index + idx,
120
202
  0: group
121
203
  }));
122
- })){
123
- let char = match[0], inStringType = openStringTypes[openStringTypes.length - 1];
124
- if (char === inStringType ? openStringTypes.pop() : ("'" === char || '"' === char || "`" === char) && openStringTypes.push(char), !inStringType) {
125
- if ("[" === char) {
126
- depth++;
127
- continue;
128
- }
129
- if ("]" === char) {
130
- depth--;
131
- continue;
132
- }
133
- if (depth < 0) return input.substring(0, match.index - 1);
134
- if (0 === depth && !ALLOWED_CLASS_CHARACTERS.test(char)) return input.substring(0, match.index);
204
+ });
205
+ for (let match of matches){
206
+ let char = match[0];
207
+ let inStringType = openStringTypes[openStringTypes.length - 1];
208
+ if (char === inStringType) {
209
+ openStringTypes.pop();
210
+ } else if (char === "'" || char === '"' || char === "`") {
211
+ openStringTypes.push(char);
212
+ }
213
+ if (inStringType) {
214
+ continue;
215
+ } else if (char === "[") {
216
+ depth++;
217
+ continue;
218
+ } else if (char === "]") {
219
+ depth--;
220
+ continue;
221
+ }
222
+ // We've gone one character past the point where we should stop
223
+ // This means that there was an extra closing `]`
224
+ // We'll clip to just before it
225
+ if (depth < 0) {
226
+ return input.substring(0, match.index - 1);
227
+ }
228
+ // We've finished balancing the brackets but there still may be characters that can be included
229
+ // For example in the class `text-[#336699]/[.35]`
230
+ // The depth goes to `0` at the closing `]` but goes up again at the `[`
231
+ // If we're at zero and encounter a non-class character then we clip the class there
232
+ if (depth === 0 && !ALLOWED_CLASS_CHARACTERS.test(char)) {
233
+ return input.substring(0, match.index);
135
234
  }
136
235
  }
137
236
  return input;
138
- }
237
+ } // Regular utilities
238
+ // {{modifier}:}*{namespace}{-{suffix}}*{/{opacityModifier}}?
239
+ // Arbitrary values
240
+ // {{modifier}:}*{namespace}-[{arbitraryValue}]{/{opacityModifier}}?
241
+ // arbitraryValue: no whitespace, balanced quotes unless within quotes, balanced brackets unless within quotes
242
+ // Arbitrary properties
243
+ // {{modifier}:}*[{validCssPropertyName}:{arbitraryValue}]
@@ -1,19 +1,45 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ function isRoot(node) {
12
+ return node.type === "root";
13
+ }
14
+ function isAtLayer(node) {
15
+ return node.type === "atrule" && node.name === "layer";
16
+ }
2
17
  function _default(_context) {
3
18
  return (root, result)=>{
4
- let found = !1;
19
+ let found = false;
5
20
  root.walkAtRules("tailwind", (node)=>{
6
- var node1;
7
- return !found && (node.parent && !("root" === node.parent.type || "atrule" === (node1 = node.parent).type && "layer" === node1.name) ? (found = !0, node.warn(result, "Nested @tailwind rules were detected, but are not supported.\nConsider using a prefix to scope Tailwind's classes: https://tailwindcss.com/docs/configuration#prefix\nAlternatively, use the important selector strategy: https://tailwindcss.com/docs/configuration#selector-strategy"), !1) : void 0);
8
- }), root.walkRules((rule)=>{
9
- if (found) return !1;
10
- rule.walkRules((nestedRule)=>(found = !0, nestedRule.warn(result, "Nested CSS was detected, but CSS nesting has not been configured correctly.\nPlease enable a CSS nesting plugin *before* Tailwind in your configuration.\nSee how here: https://tailwindcss.com/docs/using-with-preprocessors#nesting"), !1));
21
+ if (found) return false;
22
+ if (node.parent && !(isRoot(node.parent) || isAtLayer(node.parent))) {
23
+ found = true;
24
+ node.warn(result, [
25
+ "Nested @tailwind rules were detected, but are not supported.",
26
+ "Consider using a prefix to scope Tailwind's classes: https://tailwindcss.com/docs/configuration#prefix",
27
+ "Alternatively, use the important selector strategy: https://tailwindcss.com/docs/configuration#selector-strategy"
28
+ ].join("\n"));
29
+ return false;
30
+ }
31
+ });
32
+ root.walkRules((rule)=>{
33
+ if (found) return false;
34
+ rule.walkRules((nestedRule)=>{
35
+ found = true;
36
+ nestedRule.warn(result, [
37
+ "Nested CSS was detected, but CSS nesting has not been configured correctly.",
38
+ "Please enable a CSS nesting plugin *before* Tailwind in your configuration.",
39
+ "See how here: https://tailwindcss.com/docs/using-with-preprocessors#nesting"
40
+ ].join("\n"));
41
+ return false;
42
+ });
11
43
  });
12
44
  };
13
45
  }
14
- Object.defineProperty(exports, "__esModule", {
15
- value: !0
16
- }), Object.defineProperty(exports, "default", {
17
- enumerable: !0,
18
- get: ()=>_default
19
- });