tailwindcss 0.0.0-insiders.ea10bb9 → 0.0.0-insiders.ea3d9cd
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.
- package/README.md +1 -1
- package/index.css +5 -0
- package/lib/cli/build/index.js +23 -10
- package/lib/cli/build/plugin.js +136 -117
- package/lib/cli/build/utils.js +18 -8
- package/lib/cli/build/watching.js +16 -12
- package/lib/cli/help/index.js +6 -4
- package/lib/cli/index.js +223 -10
- package/lib/cli/init/index.js +29 -12
- package/lib/cli.js +1 -227
- package/lib/corePluginList.js +8 -1
- package/lib/corePlugins.js +374 -77
- package/lib/css/preflight.css +9 -1
- package/lib/featureFlags.js +30 -17
- package/lib/index.js +1 -47
- package/lib/lib/cacheInvalidation.js +7 -5
- package/lib/lib/collapseAdjacentRules.js +5 -3
- package/lib/lib/collapseDuplicateDeclarations.js +12 -10
- package/lib/lib/content.js +61 -31
- package/lib/lib/defaultExtractor.js +15 -8
- package/lib/lib/detectNesting.js +10 -2
- package/lib/lib/evaluateTailwindFunctions.js +24 -20
- package/lib/lib/expandApplyAtRules.js +43 -35
- package/lib/lib/expandTailwindAtRules.js +89 -22
- package/lib/lib/findAtConfigPath.js +9 -7
- package/lib/lib/generateRules.js +160 -98
- package/lib/lib/getModuleDependencies.js +85 -37
- package/lib/lib/handleImportAtRules.js +50 -0
- package/lib/lib/load-config.js +42 -0
- package/lib/lib/normalizeTailwindDirectives.js +5 -18
- package/lib/lib/offsets.js +93 -4
- package/lib/lib/partitionApplyAtRules.js +3 -1
- package/lib/lib/regex.js +21 -7
- package/lib/lib/remap-bitfield.js +89 -0
- package/lib/lib/resolveDefaultsAtRules.js +28 -24
- package/lib/lib/setupContextUtils.js +191 -142
- package/lib/lib/setupTrackingContext.js +50 -26
- package/lib/lib/sharedState.js +28 -9
- package/lib/lib/substituteScreenAtRules.js +5 -3
- package/lib/plugin.js +116 -0
- package/lib/postcss-plugins/nesting/index.js +3 -1
- package/lib/postcss-plugins/nesting/plugin.js +10 -8
- package/lib/processTailwindFeatures.js +14 -12
- package/lib/public/colors.js +49 -25
- package/lib/public/create-plugin.js +5 -3
- package/lib/public/default-config.js +6 -4
- package/lib/public/default-theme.js +6 -4
- package/lib/public/load-config.js +12 -0
- package/lib/public/resolve-config.js +6 -4
- package/lib/util/applyImportantSelector.js +36 -0
- package/lib/util/bigSign.js +3 -1
- package/lib/util/buildMediaQuery.js +3 -1
- package/lib/util/cloneDeep.js +3 -1
- package/lib/util/cloneNodes.js +5 -3
- package/lib/util/color.js +30 -12
- package/lib/util/colorNames.js +752 -0
- package/lib/util/configurePlugins.js +3 -1
- package/lib/util/createPlugin.js +3 -1
- package/lib/util/createUtilityPlugin.js +7 -5
- package/lib/util/dataTypes.js +88 -23
- package/lib/util/defaults.js +9 -7
- package/lib/util/escapeClassName.js +10 -8
- package/lib/util/escapeCommas.js +3 -1
- package/lib/util/flattenColorPalette.js +3 -1
- package/lib/util/formatVariantSelector.js +138 -160
- package/lib/util/getAllConfigs.js +8 -6
- package/lib/util/hashConfig.js +6 -4
- package/lib/util/isKeyframeRule.js +3 -1
- package/lib/util/isPlainObject.js +3 -1
- package/lib/util/isSyntacticallyValidPropertyValue.js +3 -1
- package/lib/util/log.js +25 -4
- package/lib/util/nameClass.js +12 -6
- package/lib/util/negateValue.js +4 -2
- package/lib/util/normalizeConfig.js +63 -36
- package/lib/util/normalizeScreens.js +12 -4
- package/lib/util/parseAnimationValue.js +3 -1
- package/lib/util/parseBoxShadowValue.js +6 -2
- package/lib/util/parseDependency.js +3 -1
- package/lib/util/parseGlob.js +6 -4
- package/lib/util/parseObjectStyles.js +9 -7
- package/lib/util/pluginUtils.js +53 -55
- package/lib/util/prefixSelector.js +27 -11
- package/lib/util/pseudoElements.js +209 -0
- package/lib/util/removeAlphaVariables.js +3 -1
- package/lib/util/resolveConfig.js +17 -15
- package/lib/util/resolveConfigPath.js +26 -10
- package/lib/util/responsive.js +6 -4
- package/lib/util/splitAtTopLevelOnly.js +10 -2
- package/lib/util/tap.js +3 -1
- package/lib/util/toColorValue.js +3 -1
- package/lib/util/toPath.js +3 -1
- package/lib/util/transformThemeValue.js +6 -4
- package/lib/util/validateConfig.js +27 -3
- package/lib/util/validateFormalSyntax.js +3 -1
- package/lib/util/withAlphaVariable.js +6 -2
- package/lib/value-parser/LICENSE +22 -0
- package/lib/value-parser/README.md +3 -0
- package/lib/value-parser/index.d.js +2 -0
- package/lib/value-parser/index.js +22 -0
- package/lib/value-parser/parse.js +259 -0
- package/lib/value-parser/stringify.js +38 -0
- package/lib/value-parser/unit.js +86 -0
- package/lib/value-parser/walk.js +16 -0
- package/loadConfig.d.ts +4 -0
- package/loadConfig.js +2 -0
- package/package.json +46 -45
- package/resolveConfig.d.ts +11 -2
- package/src/cli/build/index.js +17 -9
- package/src/cli/build/plugin.js +96 -73
- package/src/cli/build/watching.js +4 -2
- package/src/cli/index.js +217 -3
- package/src/cli/init/index.js +37 -8
- package/src/cli.js +1 -221
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +237 -34
- package/src/css/preflight.css +9 -1
- package/src/featureFlags.js +7 -3
- package/src/index.js +1 -47
- package/src/lib/content.js +45 -18
- package/src/lib/defaultExtractor.js +9 -3
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/evaluateTailwindFunctions.js +4 -1
- package/src/lib/expandApplyAtRules.js +8 -1
- package/src/lib/expandTailwindAtRules.js +73 -12
- package/src/lib/generateRules.js +127 -49
- package/src/lib/getModuleDependencies.js +70 -30
- package/src/lib/handleImportAtRules.js +34 -0
- package/src/lib/load-config.ts +31 -0
- package/src/lib/normalizeTailwindDirectives.js +0 -27
- package/src/lib/offsets.js +104 -1
- package/src/lib/remap-bitfield.js +82 -0
- package/src/lib/setupContextUtils.js +109 -69
- package/src/lib/setupTrackingContext.js +37 -14
- package/src/lib/sharedState.js +11 -4
- package/src/plugin.js +124 -0
- package/src/public/colors.js +22 -0
- package/src/public/default-config.js +1 -1
- package/src/public/default-theme.js +2 -2
- package/src/public/load-config.js +2 -0
- package/src/util/applyImportantSelector.js +27 -0
- package/src/util/color.js +18 -3
- package/src/util/colorNames.js +150 -0
- package/src/util/dataTypes.js +49 -9
- package/src/util/formatVariantSelector.js +160 -163
- package/src/util/getAllConfigs.js +2 -2
- package/src/util/log.js +24 -0
- package/src/util/negateValue.js +1 -1
- package/src/util/normalizeConfig.js +39 -11
- package/src/util/pluginUtils.js +16 -35
- package/src/util/prefixSelector.js +28 -10
- package/src/util/pseudoElements.js +167 -0
- package/src/util/resolveConfigPath.js +12 -1
- package/src/util/splitAtTopLevelOnly.js +8 -1
- package/src/util/validateConfig.js +23 -0
- package/src/value-parser/LICENSE +22 -0
- package/src/value-parser/README.md +3 -0
- package/src/value-parser/index.d.ts +177 -0
- package/src/value-parser/index.js +28 -0
- package/src/value-parser/parse.js +303 -0
- package/src/value-parser/stringify.js +41 -0
- package/src/value-parser/unit.js +118 -0
- package/src/value-parser/walk.js +18 -0
- package/stubs/.gitignore +1 -0
- package/stubs/.prettierrc.json +6 -0
- package/stubs/{defaultConfig.stub.js → config.full.js} +197 -147
- package/stubs/{simpleConfig.stub.js → config.simple.js} +1 -2
- package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -1
- package/stubs/postcss.config.js +5 -0
- package/stubs/tailwind.config.cjs +2 -0
- package/stubs/tailwind.config.js +2 -0
- package/stubs/tailwind.config.ts +3 -0
- package/types/config.d.ts +17 -10
- package/types/generated/colors.d.ts +22 -0
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +110 -80
- package/CHANGELOG.md +0 -2336
- package/lib/cli/build/deps.js +0 -54
- package/lib/cli/shared.js +0 -12
- package/lib/cli-peer-dependencies.js +0 -28
- package/lib/constants.js +0 -44
- package/peers/index.js +0 -79512
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/cli/build/deps.js +0 -56
- package/src/cli/shared.js +0 -5
- package/src/cli-peer-dependencies.js +0 -15
- package/src/constants.js +0 -17
package/lib/lib/generateRules.js
CHANGED
|
@@ -9,26 +9,33 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
getClassNameFromSelector: ()
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
getClassNameFromSelector: function() {
|
|
13
|
+
return getClassNameFromSelector;
|
|
14
|
+
},
|
|
15
|
+
resolveMatches: function() {
|
|
16
|
+
return resolveMatches;
|
|
17
|
+
},
|
|
18
|
+
generateRules: function() {
|
|
19
|
+
return generateRules;
|
|
20
|
+
}
|
|
15
21
|
});
|
|
16
|
-
const _postcss = /*#__PURE__*/
|
|
17
|
-
const
|
|
18
|
-
const _parseObjectStyles = /*#__PURE__*/
|
|
19
|
-
const _isPlainObject = /*#__PURE__*/
|
|
20
|
-
const _prefixSelector = /*#__PURE__*/
|
|
22
|
+
const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
|
|
23
|
+
const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser"));
|
|
24
|
+
const _parseObjectStyles = /*#__PURE__*/ _interop_require_default(require("../util/parseObjectStyles"));
|
|
25
|
+
const _isPlainObject = /*#__PURE__*/ _interop_require_default(require("../util/isPlainObject"));
|
|
26
|
+
const _prefixSelector = /*#__PURE__*/ _interop_require_default(require("../util/prefixSelector"));
|
|
21
27
|
const _pluginUtils = require("../util/pluginUtils");
|
|
22
|
-
const _log = /*#__PURE__*/
|
|
23
|
-
const _sharedState = /*#__PURE__*/
|
|
28
|
+
const _log = /*#__PURE__*/ _interop_require_default(require("../util/log"));
|
|
29
|
+
const _sharedState = /*#__PURE__*/ _interop_require_wildcard(require("./sharedState"));
|
|
24
30
|
const _formatVariantSelector = require("../util/formatVariantSelector");
|
|
25
31
|
const _nameClass = require("../util/nameClass");
|
|
26
32
|
const _dataTypes = require("../util/dataTypes");
|
|
27
33
|
const _setupContextUtils = require("./setupContextUtils");
|
|
28
|
-
const _isSyntacticallyValidPropertyValue = /*#__PURE__*/
|
|
29
|
-
const
|
|
34
|
+
const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interop_require_default(require("../util/isSyntacticallyValidPropertyValue"));
|
|
35
|
+
const _splitAtTopLevelOnly = require("../util/splitAtTopLevelOnly.js");
|
|
30
36
|
const _featureFlags = require("../featureFlags");
|
|
31
|
-
|
|
37
|
+
const _applyImportantSelector = require("../util/applyImportantSelector");
|
|
38
|
+
function _interop_require_default(obj) {
|
|
32
39
|
return obj && obj.__esModule ? obj : {
|
|
33
40
|
default: obj
|
|
34
41
|
};
|
|
@@ -41,7 +48,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
41
48
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
42
49
|
})(nodeInterop);
|
|
43
50
|
}
|
|
44
|
-
function
|
|
51
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
45
52
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
46
53
|
return obj;
|
|
47
54
|
}
|
|
@@ -72,7 +79,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
72
79
|
}
|
|
73
80
|
return newObj;
|
|
74
81
|
}
|
|
75
|
-
let classNameParser = (0,
|
|
82
|
+
let classNameParser = (0, _postcssselectorparser.default)((selectors)=>{
|
|
76
83
|
return selectors.first.filter(({ type })=>type === "class").pop().value;
|
|
77
84
|
});
|
|
78
85
|
function getClassNameFromSelector(selector) {
|
|
@@ -162,12 +169,12 @@ function applyImportant(matches, classCandidate) {
|
|
|
162
169
|
]
|
|
163
170
|
});
|
|
164
171
|
container.walkRules((r)=>{
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
172
|
+
let ast = (0, _postcssselectorparser.default)().astSync(r.selector);
|
|
173
|
+
// Remove extraneous selectors that do not include the base candidate
|
|
174
|
+
ast.each((sel)=>(0, _formatVariantSelector.eliminateIrrelevantSelectors)(sel, classCandidate));
|
|
175
|
+
// Update all instances of the base candidate to include the important marker
|
|
176
|
+
(0, _pluginUtils.updateAllClasses)(ast, (className)=>className === classCandidate ? `!${className}` : className);
|
|
177
|
+
r.selector = ast.toString();
|
|
171
178
|
r.walkDecls((d)=>d.important = true);
|
|
172
179
|
});
|
|
173
180
|
result.push([
|
|
@@ -198,13 +205,16 @@ function applyVariant(variant, matches, context) {
|
|
|
198
205
|
};
|
|
199
206
|
// Retrieve "modifier"
|
|
200
207
|
{
|
|
201
|
-
let
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
+
let [baseVariant, ...modifiers] = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(variant, "/");
|
|
209
|
+
// This is a hack to support variants with `/` in them, like `ar-1/10/20:text-red-500`
|
|
210
|
+
// In this case 1/10 is a value but /20 is a modifier
|
|
211
|
+
if (modifiers.length > 1) {
|
|
212
|
+
baseVariant = baseVariant + "/" + modifiers.slice(0, -1).join("/");
|
|
213
|
+
modifiers = modifiers.slice(-1);
|
|
214
|
+
}
|
|
215
|
+
if (modifiers.length && !context.variantMap.has(variant)) {
|
|
216
|
+
variant = baseVariant;
|
|
217
|
+
args.modifier = modifiers[0];
|
|
208
218
|
}
|
|
209
219
|
}
|
|
210
220
|
// Retrieve "arbitrary value"
|
|
@@ -216,33 +226,37 @@ function applyVariant(variant, matches, context) {
|
|
|
216
226
|
// But we don't want:
|
|
217
227
|
// @-[200px] (`-` is incorrect)
|
|
218
228
|
// group[:hover] (`-` is missing)
|
|
219
|
-
let
|
|
220
|
-
if (
|
|
221
|
-
let [, char,
|
|
229
|
+
let match = /(.)(-?)\[(.*)\]/g.exec(variant);
|
|
230
|
+
if (match) {
|
|
231
|
+
let [, char, separator, value] = match;
|
|
222
232
|
// @-[200px] case
|
|
223
|
-
if (char === "@" &&
|
|
233
|
+
if (char === "@" && separator === "-") return [];
|
|
224
234
|
// group[:hover] case
|
|
225
|
-
if (char !== "@" &&
|
|
226
|
-
variant = variant.replace(`${
|
|
235
|
+
if (char !== "@" && separator === "") return [];
|
|
236
|
+
variant = variant.replace(`${separator}[${value}]`, "");
|
|
227
237
|
args.value = value;
|
|
228
238
|
}
|
|
229
239
|
}
|
|
230
240
|
// Register arbitrary variants
|
|
231
241
|
if (isArbitraryValue(variant) && !context.variantMap.has(variant)) {
|
|
242
|
+
let sort = context.offsets.recordVariant(variant);
|
|
232
243
|
let selector = (0, _dataTypes.normalize)(variant.slice(1, -1));
|
|
233
|
-
|
|
244
|
+
let selectors = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(selector, ",");
|
|
245
|
+
// We do not support multiple selectors for arbitrary variants
|
|
246
|
+
if (selectors.length > 1) {
|
|
234
247
|
return [];
|
|
235
248
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
sort,
|
|
241
|
-
|
|
242
|
-
]
|
|
243
|
-
|
|
249
|
+
if (!selectors.every(_setupContextUtils.isValidVariantFormatString)) {
|
|
250
|
+
return [];
|
|
251
|
+
}
|
|
252
|
+
let records = selectors.map((sel, idx)=>[
|
|
253
|
+
context.offsets.applyParallelOffset(sort, idx),
|
|
254
|
+
(0, _setupContextUtils.parseVariant)(sel.trim())
|
|
255
|
+
]);
|
|
256
|
+
context.variantMap.set(variant, records);
|
|
244
257
|
}
|
|
245
258
|
if (context.variantMap.has(variant)) {
|
|
259
|
+
let isArbitraryVariant = isArbitraryValue(variant);
|
|
246
260
|
let variantFunctionTuples = context.variantMap.get(variant).slice();
|
|
247
261
|
let result = [];
|
|
248
262
|
for (let [meta, rule] of matches){
|
|
@@ -299,21 +313,24 @@ function applyVariant(variant, matches, context) {
|
|
|
299
313
|
clone.append(wrapper);
|
|
300
314
|
},
|
|
301
315
|
format (selectorFormat) {
|
|
302
|
-
collectedFormats.push(
|
|
316
|
+
collectedFormats.push({
|
|
317
|
+
format: selectorFormat,
|
|
318
|
+
isArbitraryVariant
|
|
319
|
+
});
|
|
303
320
|
},
|
|
304
321
|
args
|
|
305
322
|
});
|
|
306
323
|
// It can happen that a list of format strings is returned from within the function. In that
|
|
307
324
|
// case, we have to process them as well. We can use the existing `variantSort`.
|
|
308
325
|
if (Array.isArray(ruleWithVariant)) {
|
|
309
|
-
for (let [idx,
|
|
326
|
+
for (let [idx, variantFunction] of ruleWithVariant.entries()){
|
|
310
327
|
// This is a little bit scary since we are pushing to an array of items that we are
|
|
311
328
|
// currently looping over. However, you can also think of it like a processing queue
|
|
312
329
|
// where you keep handling jobs until everything is done and each job can queue more
|
|
313
330
|
// jobs if needed.
|
|
314
331
|
variantFunctionTuples.push([
|
|
315
332
|
context.offsets.applyParallelOffset(variantSort, idx),
|
|
316
|
-
|
|
333
|
+
variantFunction,
|
|
317
334
|
// If the clone has been modified we have to pass that back
|
|
318
335
|
// though so each rule can use the modified container
|
|
319
336
|
clone.clone()
|
|
@@ -322,7 +339,10 @@ function applyVariant(variant, matches, context) {
|
|
|
322
339
|
continue;
|
|
323
340
|
}
|
|
324
341
|
if (typeof ruleWithVariant === "string") {
|
|
325
|
-
collectedFormats.push(
|
|
342
|
+
collectedFormats.push({
|
|
343
|
+
format: ruleWithVariant,
|
|
344
|
+
isArbitraryVariant
|
|
345
|
+
});
|
|
326
346
|
}
|
|
327
347
|
if (ruleWithVariant === null) {
|
|
328
348
|
continue;
|
|
@@ -342,7 +362,7 @@ function applyVariant(variant, matches, context) {
|
|
|
342
362
|
// as well. E.g.: `${variant}${separator}${className}`.
|
|
343
363
|
// However, plugin authors probably also prepend or append certain
|
|
344
364
|
// classes, pseudos, ids, ...
|
|
345
|
-
let rebuiltBase = (0,
|
|
365
|
+
let rebuiltBase = (0, _postcssselectorparser.default)((selectors)=>{
|
|
346
366
|
selectors.walkClasses((classNode)=>{
|
|
347
367
|
classNode.value = `${variant}${context.tailwindConfig.separator}${classNode.value}`;
|
|
348
368
|
});
|
|
@@ -358,7 +378,10 @@ function applyVariant(variant, matches, context) {
|
|
|
358
378
|
// modified (by plugin): .foo .foo\\:markdown > p
|
|
359
379
|
// rebuiltBase (internal): .foo\\:markdown > p
|
|
360
380
|
// format: .foo &
|
|
361
|
-
collectedFormats.push(
|
|
381
|
+
collectedFormats.push({
|
|
382
|
+
format: modified.replace(rebuiltBase, "&"),
|
|
383
|
+
isArbitraryVariant
|
|
384
|
+
});
|
|
362
385
|
rule.selector = before;
|
|
363
386
|
});
|
|
364
387
|
}
|
|
@@ -370,13 +393,12 @@ function applyVariant(variant, matches, context) {
|
|
|
370
393
|
...clone.nodes[0].raws.tailwind,
|
|
371
394
|
parentLayer: meta.layer
|
|
372
395
|
};
|
|
373
|
-
var
|
|
396
|
+
var _meta_collectedFormats;
|
|
374
397
|
let withOffset = [
|
|
375
398
|
{
|
|
376
399
|
...meta,
|
|
377
400
|
sort: context.offsets.applyVariantOffset(meta.sort, variantSort, Object.assign(args, context.variantOptions.get(variant))),
|
|
378
|
-
collectedFormats: ((
|
|
379
|
-
isArbitraryVariant: isArbitraryValue(variant)
|
|
401
|
+
collectedFormats: ((_meta_collectedFormats = meta.collectedFormats) !== null && _meta_collectedFormats !== void 0 ? _meta_collectedFormats : []).concat(collectedFormats)
|
|
380
402
|
},
|
|
381
403
|
clone.nodes[0]
|
|
382
404
|
];
|
|
@@ -434,7 +456,7 @@ function isValidPropName(name) {
|
|
|
434
456
|
function isParsableNode(node) {
|
|
435
457
|
let isParsable = true;
|
|
436
458
|
node.walkDecls((decl)=>{
|
|
437
|
-
if (!isParsableCssValue(decl.
|
|
459
|
+
if (!isParsableCssValue(decl.prop, decl.value)) {
|
|
438
460
|
isParsable = false;
|
|
439
461
|
return false;
|
|
440
462
|
}
|
|
@@ -456,8 +478,8 @@ function isParsableCssValue(property, value) {
|
|
|
456
478
|
}
|
|
457
479
|
}
|
|
458
480
|
function extractArbitraryProperty(classCandidate, context) {
|
|
459
|
-
var
|
|
460
|
-
let [, property, value] = (
|
|
481
|
+
var _classCandidate_match;
|
|
482
|
+
let [, property, value] = (_classCandidate_match = classCandidate.match(/^\[([a-zA-Z0-9-_]+):(\S+)\]$/)) !== null && _classCandidate_match !== void 0 ? _classCandidate_match : [];
|
|
461
483
|
if (value === undefined) {
|
|
462
484
|
return null;
|
|
463
485
|
}
|
|
@@ -531,16 +553,16 @@ function splitWithSeparator(input, separator) {
|
|
|
531
553
|
_sharedState.NOT_ON_DEMAND
|
|
532
554
|
];
|
|
533
555
|
}
|
|
534
|
-
return (0,
|
|
556
|
+
return (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(input, separator);
|
|
535
557
|
}
|
|
536
558
|
function* recordCandidates(matches, classCandidate) {
|
|
537
559
|
for (const match of matches){
|
|
538
|
-
var
|
|
539
|
-
var
|
|
560
|
+
var _match__options;
|
|
561
|
+
var _match__options_preserveSource;
|
|
540
562
|
match[1].raws.tailwind = {
|
|
541
563
|
...match[1].raws.tailwind,
|
|
542
564
|
classCandidate,
|
|
543
|
-
preserveSource: (
|
|
565
|
+
preserveSource: (_match__options_preserveSource = (_match__options = match[0].options) === null || _match__options === void 0 ? void 0 : _match__options.preserveSource) !== null && _match__options_preserveSource !== void 0 ? _match__options_preserveSource : false
|
|
544
566
|
};
|
|
545
567
|
yield match;
|
|
546
568
|
}
|
|
@@ -556,7 +578,7 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
556
578
|
if ((0, _featureFlags.flagEnabled)(context.tailwindConfig, "variantGrouping")) {
|
|
557
579
|
if (classCandidate.startsWith("(") && classCandidate.endsWith(")")) {
|
|
558
580
|
let base = variants.slice().reverse().join(separator);
|
|
559
|
-
for (let part of (0,
|
|
581
|
+
for (let part of (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(classCandidate.slice(1, -1), ",")){
|
|
560
582
|
yield* resolveMatches(base + separator + part, context, original);
|
|
561
583
|
}
|
|
562
584
|
}
|
|
@@ -598,25 +620,25 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
598
620
|
}
|
|
599
621
|
}
|
|
600
622
|
} else if (modifier === "DEFAULT" || modifier === "-DEFAULT") {
|
|
601
|
-
let
|
|
602
|
-
let [
|
|
603
|
-
for (let
|
|
623
|
+
let ruleSet = plugin;
|
|
624
|
+
let [rules, options] = parseRules(ruleSet, context.postCssNodeCache);
|
|
625
|
+
for (let rule of rules){
|
|
604
626
|
matchesPerPlugin.push([
|
|
605
627
|
{
|
|
606
628
|
...sort,
|
|
607
629
|
options: {
|
|
608
630
|
...sort.options,
|
|
609
|
-
...
|
|
631
|
+
...options
|
|
610
632
|
}
|
|
611
633
|
},
|
|
612
|
-
|
|
634
|
+
rule
|
|
613
635
|
]);
|
|
614
636
|
}
|
|
615
637
|
}
|
|
616
638
|
if (matchesPerPlugin.length > 0) {
|
|
617
|
-
var
|
|
618
|
-
var
|
|
619
|
-
let matchingTypes = Array.from((0, _pluginUtils.getMatchingTypes)((
|
|
639
|
+
var _sort_options;
|
|
640
|
+
var _sort_options_types, _sort_options1;
|
|
641
|
+
let matchingTypes = Array.from((0, _pluginUtils.getMatchingTypes)((_sort_options_types = (_sort_options = sort.options) === null || _sort_options === void 0 ? void 0 : _sort_options.types) !== null && _sort_options_types !== void 0 ? _sort_options_types : [], modifier, (_sort_options1 = sort.options) !== null && _sort_options1 !== void 0 ? _sort_options1 : {}, context.tailwindConfig)).map(([_, type])=>type);
|
|
620
642
|
if (matchingTypes.length > 0) {
|
|
621
643
|
typesByMatches.set(matchesPerPlugin, matchingTypes);
|
|
622
644
|
}
|
|
@@ -656,18 +678,18 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
656
678
|
});
|
|
657
679
|
});
|
|
658
680
|
}
|
|
659
|
-
var
|
|
681
|
+
var _findFallback;
|
|
660
682
|
// Try to find a fallback plugin, because we already know that multiple plugins matched for
|
|
661
683
|
// the given arbitrary value.
|
|
662
|
-
let fallback = (
|
|
684
|
+
let fallback = (_findFallback = findFallback(withoutAny)) !== null && _findFallback !== void 0 ? _findFallback : findFallback(withAny);
|
|
663
685
|
if (fallback) {
|
|
664
686
|
matches = [
|
|
665
687
|
fallback
|
|
666
688
|
];
|
|
667
689
|
} else {
|
|
668
|
-
var
|
|
690
|
+
var _typesByMatches_get;
|
|
669
691
|
let typesPerPlugin = matches.map((match)=>new Set([
|
|
670
|
-
...(
|
|
692
|
+
...(_typesByMatches_get = typesByMatches.get(match)) !== null && _typesByMatches_get !== void 0 ? _typesByMatches_get : []
|
|
671
693
|
]));
|
|
672
694
|
// Remove duplicates, so that we can detect proper unique types for each plugin.
|
|
673
695
|
for (let pluginTypes of typesPerPlugin){
|
|
@@ -685,11 +707,11 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
685
707
|
}
|
|
686
708
|
let messages = [];
|
|
687
709
|
for (let [idx, group] of typesPerPlugin.entries()){
|
|
688
|
-
for (let
|
|
689
|
-
let
|
|
710
|
+
for (let type of group){
|
|
711
|
+
let rules = matches[idx].map(([, rule])=>rule).flat().map((rule)=>rule.toString().split("\n").slice(1, -1) // Remove selector and closing '}'
|
|
690
712
|
.map((line)=>line.trim()).map((x)=>` ${x}`) // Re-indent
|
|
691
713
|
.join("\n")).join("\n\n");
|
|
692
|
-
messages.push(` Use \`${candidate.replace("[", `[${
|
|
714
|
+
messages.push(` Use \`${candidate.replace("[", `[${type}:`)}\` for \`${rules.trim()}\``);
|
|
693
715
|
break;
|
|
694
716
|
}
|
|
695
717
|
}
|
|
@@ -718,31 +740,71 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
718
740
|
candidate
|
|
719
741
|
};
|
|
720
742
|
// Apply final format selector
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
var ref1;
|
|
732
|
-
rule.selector = (0, _formatVariantSelector.finalizeSelector)(finalFormat, {
|
|
733
|
-
selector: rule.selector,
|
|
734
|
-
candidate: original,
|
|
735
|
-
base: candidate.split(new RegExp(`\\${(ref1 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref1 !== void 0 ? ref1 : ":"}(?![^[]*\\])`)).pop(),
|
|
736
|
-
isArbitraryVariant: match[0].isArbitraryVariant,
|
|
737
|
-
context
|
|
738
|
-
});
|
|
739
|
-
});
|
|
740
|
-
match[1] = container.nodes[0];
|
|
743
|
+
match = applyFinalFormat(match, {
|
|
744
|
+
context,
|
|
745
|
+
candidate,
|
|
746
|
+
original
|
|
747
|
+
});
|
|
748
|
+
// Skip rules with invalid selectors
|
|
749
|
+
// This will cause the candidate to be added to the "not class"
|
|
750
|
+
// cache skipping it entirely for future builds
|
|
751
|
+
if (match === null) {
|
|
752
|
+
continue;
|
|
741
753
|
}
|
|
742
754
|
yield match;
|
|
743
755
|
}
|
|
744
756
|
}
|
|
745
757
|
}
|
|
758
|
+
function applyFinalFormat(match, { context , candidate , original }) {
|
|
759
|
+
if (!match[0].collectedFormats) {
|
|
760
|
+
return match;
|
|
761
|
+
}
|
|
762
|
+
let isValid = true;
|
|
763
|
+
let finalFormat;
|
|
764
|
+
try {
|
|
765
|
+
finalFormat = (0, _formatVariantSelector.formatVariantSelector)(match[0].collectedFormats, {
|
|
766
|
+
context,
|
|
767
|
+
candidate
|
|
768
|
+
});
|
|
769
|
+
} catch {
|
|
770
|
+
// The format selector we produced is invalid
|
|
771
|
+
// This could be because:
|
|
772
|
+
// - A bug exists
|
|
773
|
+
// - A plugin introduced an invalid variant selector (ex: `addVariant('foo', '&;foo')`)
|
|
774
|
+
// - The user used an invalid arbitrary variant (ex: `[&;foo]:underline`)
|
|
775
|
+
// Either way the build will fail because of this
|
|
776
|
+
// We would rather that the build pass "silently" given that this could
|
|
777
|
+
// happen because of picking up invalid things when scanning content
|
|
778
|
+
// So we'll throw out the candidate instead
|
|
779
|
+
return null;
|
|
780
|
+
}
|
|
781
|
+
let container = _postcss.default.root({
|
|
782
|
+
nodes: [
|
|
783
|
+
match[1].clone()
|
|
784
|
+
]
|
|
785
|
+
});
|
|
786
|
+
container.walkRules((rule)=>{
|
|
787
|
+
if (inKeyframes(rule)) {
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
try {
|
|
791
|
+
rule.selector = (0, _formatVariantSelector.finalizeSelector)(rule.selector, finalFormat, {
|
|
792
|
+
candidate: original,
|
|
793
|
+
context
|
|
794
|
+
});
|
|
795
|
+
} catch {
|
|
796
|
+
// If this selector is invalid we also want to skip it
|
|
797
|
+
// But it's likely that being invalid here means there's a bug in a plugin rather than too loosely matching content
|
|
798
|
+
isValid = false;
|
|
799
|
+
return false;
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
if (!isValid) {
|
|
803
|
+
return null;
|
|
804
|
+
}
|
|
805
|
+
match[1] = container.nodes[0];
|
|
806
|
+
return match;
|
|
807
|
+
}
|
|
746
808
|
function inKeyframes(rule) {
|
|
747
809
|
return rule.parent && rule.parent.type === "atrule" && rule.parent.name === "keyframes";
|
|
748
810
|
}
|
|
@@ -765,7 +827,7 @@ function getImportantStrategy(important) {
|
|
|
765
827
|
return;
|
|
766
828
|
}
|
|
767
829
|
rule.selectors = rule.selectors.map((selector)=>{
|
|
768
|
-
return
|
|
830
|
+
return (0, _applyImportantSelector.applyImportantSelector)(selector, important);
|
|
769
831
|
});
|
|
770
832
|
};
|
|
771
833
|
}
|
|
@@ -787,8 +849,8 @@ function generateRules(candidates, context) {
|
|
|
787
849
|
continue;
|
|
788
850
|
}
|
|
789
851
|
context.classCache.set(candidate, matches);
|
|
790
|
-
var
|
|
791
|
-
let rules = (
|
|
852
|
+
var _context_candidateRuleCache_get;
|
|
853
|
+
let rules = (_context_candidateRuleCache_get = context.candidateRuleCache.get(candidate)) !== null && _context_candidateRuleCache_get !== void 0 ? _context_candidateRuleCache_get : new Set();
|
|
792
854
|
context.candidateRuleCache.set(candidate, rules);
|
|
793
855
|
for (const match of matches){
|
|
794
856
|
let [{ sort , options }, rule] = match;
|
|
@@ -4,48 +4,96 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return getModuleDependencies;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _fs = /*#__PURE__*/
|
|
10
|
-
const _path = /*#__PURE__*/
|
|
11
|
-
|
|
12
|
-
const _detective = /*#__PURE__*/ _interopRequireDefault(require("detective"));
|
|
13
|
-
function _interopRequireDefault(obj) {
|
|
11
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
14
|
return obj && obj.__esModule ? obj : {
|
|
15
15
|
default: obj
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
let jsExtensions = [
|
|
19
|
+
".js",
|
|
20
|
+
".cjs",
|
|
21
|
+
".mjs"
|
|
22
|
+
];
|
|
23
|
+
// Given the current file `a.ts`, we want to make sure that when importing `b` that we resolve
|
|
24
|
+
// `b.ts` before `b.js`
|
|
25
|
+
//
|
|
26
|
+
// E.g.:
|
|
27
|
+
//
|
|
28
|
+
// a.ts
|
|
29
|
+
// b // .ts
|
|
30
|
+
// c // .ts
|
|
31
|
+
// a.js
|
|
32
|
+
// b // .js or .ts
|
|
33
|
+
let jsResolutionOrder = [
|
|
34
|
+
"",
|
|
35
|
+
".js",
|
|
36
|
+
".cjs",
|
|
37
|
+
".mjs",
|
|
38
|
+
".ts",
|
|
39
|
+
".cts",
|
|
40
|
+
".mts",
|
|
41
|
+
".jsx",
|
|
42
|
+
".tsx"
|
|
43
|
+
];
|
|
44
|
+
let tsResolutionOrder = [
|
|
45
|
+
"",
|
|
46
|
+
".ts",
|
|
47
|
+
".cts",
|
|
48
|
+
".mts",
|
|
49
|
+
".tsx",
|
|
50
|
+
".js",
|
|
51
|
+
".cjs",
|
|
52
|
+
".mjs",
|
|
53
|
+
".jsx"
|
|
54
|
+
];
|
|
55
|
+
function resolveWithExtension(file, extensions) {
|
|
56
|
+
// Try to find `./a.ts`, `./a.ts`, ... from `./a`
|
|
57
|
+
for (let ext of extensions){
|
|
58
|
+
let full = `${file}${ext}`;
|
|
59
|
+
if (_fs.default.existsSync(full) && _fs.default.statSync(full).isFile()) {
|
|
60
|
+
return full;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Try to find `./a/index.js` from `./a`
|
|
64
|
+
for (let ext of extensions){
|
|
65
|
+
let full = `${file}/index${ext}`;
|
|
66
|
+
if (_fs.default.existsSync(full)) {
|
|
67
|
+
return full;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
25
71
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
72
|
+
function* _getModuleDependencies(filename, base, seen, ext = _path.default.extname(filename)) {
|
|
73
|
+
// Try to find the file
|
|
74
|
+
let absoluteFile = resolveWithExtension(_path.default.resolve(base, filename), jsExtensions.includes(ext) ? jsResolutionOrder : tsResolutionOrder);
|
|
75
|
+
if (absoluteFile === null) return; // File doesn't exist
|
|
76
|
+
// Prevent infinite loops when there are circular dependencies
|
|
77
|
+
if (seen.has(absoluteFile)) return; // Already seen
|
|
78
|
+
seen.add(absoluteFile);
|
|
79
|
+
// Mark the file as a dependency
|
|
80
|
+
yield absoluteFile;
|
|
81
|
+
// Resolve new base for new imports/requires
|
|
82
|
+
base = _path.default.dirname(absoluteFile);
|
|
83
|
+
ext = _path.default.extname(absoluteFile);
|
|
84
|
+
let contents = _fs.default.readFileSync(absoluteFile, "utf-8");
|
|
85
|
+
// Find imports/requires
|
|
86
|
+
for (let match of [
|
|
87
|
+
...contents.matchAll(/import[\s\S]*?['"](.{3,}?)['"]/gi),
|
|
88
|
+
...contents.matchAll(/import[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi),
|
|
89
|
+
...contents.matchAll(/require\(['"`](.+)['"`]\)/gi)
|
|
90
|
+
]){
|
|
91
|
+
// Bail out if it's not a relative file
|
|
92
|
+
if (!match[1].startsWith(".")) continue;
|
|
93
|
+
yield* _getModuleDependencies(match[1], base, seen, ext);
|
|
49
94
|
}
|
|
50
|
-
|
|
95
|
+
}
|
|
96
|
+
function getModuleDependencies(absoluteFilePath) {
|
|
97
|
+
if (absoluteFilePath === null) return new Set();
|
|
98
|
+
return new Set(_getModuleDependencies(absoluteFilePath, _path.default.dirname(absoluteFilePath), new Set()));
|
|
51
99
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "handleImportAtRules", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return handleImportAtRules;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
|
|
12
|
+
const _postcssimport = /*#__PURE__*/ _interop_require_default(require("postcss-import"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const TAILWIND = Symbol();
|
|
19
|
+
function handleImportAtRules() {
|
|
20
|
+
let RESTORE_ATRULE_COMMENT = "__TAILWIND_RESTORE__";
|
|
21
|
+
let atRulesToRestore = [
|
|
22
|
+
"tailwind",
|
|
23
|
+
"config"
|
|
24
|
+
];
|
|
25
|
+
return [
|
|
26
|
+
(root)=>{
|
|
27
|
+
root.walkAtRules((rule)=>{
|
|
28
|
+
if (!atRulesToRestore.includes(rule.name)) return rule;
|
|
29
|
+
rule.after(_postcss.default.comment({
|
|
30
|
+
text: RESTORE_ATRULE_COMMENT,
|
|
31
|
+
raws: {
|
|
32
|
+
[TAILWIND]: {
|
|
33
|
+
rule
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
rule.remove();
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
(0, _postcssimport.default)(),
|
|
41
|
+
(root)=>{
|
|
42
|
+
root.walkComments((rule)=>{
|
|
43
|
+
if (rule.text === RESTORE_ATRULE_COMMENT) {
|
|
44
|
+
rule.after(rule.raws[TAILWIND].rule);
|
|
45
|
+
rule.remove();
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
];
|
|
50
|
+
}
|