tailwindcss 0.0.0-insiders.bbafc8e → 0.0.0-insiders.bbf2b1b
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/CHANGELOG.md +163 -8
- package/README.md +6 -3
- package/colors.d.ts +3 -0
- package/defaultConfig.d.ts +3 -0
- package/defaultTheme.d.ts +4 -0
- package/lib/cli-peer-dependencies.js +20 -7
- package/lib/cli.js +314 -247
- package/lib/constants.js +27 -20
- package/lib/corePluginList.js +6 -3
- package/lib/corePlugins.js +1719 -1628
- package/lib/css/preflight.css +1 -8
- package/lib/featureFlags.js +27 -18
- package/lib/index.js +17 -15
- package/lib/lib/cacheInvalidation.js +45 -24
- package/lib/lib/collapseAdjacentRules.js +14 -9
- package/lib/lib/collapseDuplicateDeclarations.js +12 -9
- package/lib/lib/defaultExtractor.js +220 -33
- package/lib/lib/detectNesting.js +13 -10
- package/lib/lib/evaluateTailwindFunctions.js +101 -54
- package/lib/lib/expandApplyAtRules.js +254 -209
- package/lib/lib/expandTailwindAtRules.js +86 -69
- package/lib/lib/generateRules.js +244 -145
- package/lib/lib/getModuleDependencies.js +11 -8
- package/lib/lib/normalizeTailwindDirectives.js +35 -32
- package/lib/lib/partitionApplyAtRules.js +11 -8
- package/lib/lib/regex.js +60 -0
- package/lib/lib/resolveDefaultsAtRules.js +89 -71
- package/lib/lib/setupContextUtils.js +290 -205
- package/lib/lib/setupTrackingContext.js +44 -37
- package/lib/lib/sharedState.js +22 -16
- package/lib/lib/substituteScreenAtRules.js +11 -9
- package/lib/postcss-plugins/nesting/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +8 -6
- package/lib/postcss-plugins/nesting/plugin.js +18 -16
- package/lib/processTailwindFeatures.js +31 -28
- package/lib/public/colors.js +247 -245
- package/lib/public/create-plugin.js +6 -4
- package/lib/public/default-config.js +7 -5
- package/lib/public/default-theme.js +7 -5
- package/lib/public/resolve-config.js +8 -5
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +7 -5
- package/lib/util/cloneDeep.js +7 -6
- package/lib/util/cloneNodes.js +10 -3
- package/lib/util/color.js +53 -54
- package/lib/util/configurePlugins.js +4 -1
- package/lib/util/createPlugin.js +6 -5
- package/lib/util/createUtilityPlugin.js +9 -7
- package/lib/util/dataTypes.js +110 -100
- package/lib/util/defaults.js +4 -1
- package/lib/util/escapeClassName.js +7 -4
- package/lib/util/escapeCommas.js +5 -2
- package/lib/util/flattenColorPalette.js +9 -10
- package/lib/util/formatVariantSelector.js +100 -85
- package/lib/util/getAllConfigs.js +17 -8
- package/lib/util/hashConfig.js +6 -3
- package/lib/util/isKeyframeRule.js +5 -2
- package/lib/util/isPlainObject.js +5 -2
- package/lib/util/isValidArbitraryValue.js +21 -13
- package/lib/util/log.js +18 -12
- package/lib/util/nameClass.js +17 -9
- package/lib/util/negateValue.js +8 -6
- package/lib/util/normalizeConfig.js +84 -71
- package/lib/util/normalizeScreens.js +22 -8
- package/lib/util/parseAnimationValue.js +42 -40
- package/lib/util/parseBoxShadowValue.js +29 -62
- package/lib/util/parseDependency.js +18 -15
- package/lib/util/parseObjectStyles.js +10 -7
- package/lib/util/pluginUtils.js +47 -31
- package/lib/util/prefixSelector.js +7 -4
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +88 -84
- package/lib/util/resolveConfigPath.js +10 -7
- package/lib/util/responsive.js +8 -5
- package/lib/util/splitAtTopLevelOnly.js +93 -0
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +5 -2
- package/lib/util/toPath.js +20 -4
- package/lib/util/transformThemeValue.js +30 -25
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/withAlphaVariable.js +23 -15
- package/package.json +32 -27
- package/peers/index.js +8612 -4245
- package/plugin.d.ts +11 -0
- package/resolveConfig.d.ts +3 -0
- package/scripts/generate-types.js +105 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +125 -25
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +145 -49
- package/src/css/preflight.css +1 -8
- package/src/featureFlags.js +2 -2
- package/src/lib/collapseAdjacentRules.js +5 -1
- package/src/lib/defaultExtractor.js +193 -35
- package/src/lib/evaluateTailwindFunctions.js +56 -6
- package/src/lib/expandApplyAtRules.js +252 -187
- package/src/lib/expandTailwindAtRules.js +4 -4
- package/src/lib/generateRules.js +156 -59
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +53 -36
- package/src/lib/setupContextUtils.js +142 -46
- package/src/lib/setupTrackingContext.js +5 -1
- package/src/postcss-plugins/nesting/README.md +2 -2
- package/src/util/cloneNodes.js +5 -1
- package/src/util/color.js +25 -21
- package/src/util/dataTypes.js +13 -7
- package/src/util/formatVariantSelector.js +82 -63
- package/src/util/getAllConfigs.js +8 -0
- package/src/util/log.js +1 -1
- package/src/util/normalizeConfig.js +0 -8
- package/src/util/parseBoxShadowValue.js +3 -50
- package/src/util/pluginUtils.js +13 -1
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +66 -52
- package/src/util/splitAtTopLevelOnly.js +71 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +4 -2
- package/src/util/validateConfig.js +13 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +5 -1
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +327 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/generated/default-theme.d.ts +331 -0
- package/types/index.d.ts +7 -0
|
@@ -2,52 +2,72 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>expandTailwindAtRules
|
|
8
|
+
});
|
|
9
|
+
const _quickLru = /*#__PURE__*/ _interopRequireDefault(require("quick-lru"));
|
|
10
|
+
const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
|
|
11
|
+
const _generateRules = require("./generateRules");
|
|
12
|
+
const _bigSign = /*#__PURE__*/ _interopRequireDefault(require("../util/bigSign"));
|
|
13
|
+
const _log = /*#__PURE__*/ _interopRequireDefault(require("../util/log"));
|
|
14
|
+
const _cloneNodes = /*#__PURE__*/ _interopRequireDefault(require("../util/cloneNodes"));
|
|
15
|
+
const _defaultExtractor = require("./defaultExtractor");
|
|
13
16
|
function _interopRequireDefault(obj) {
|
|
14
17
|
return obj && obj.__esModule ? obj : {
|
|
15
18
|
default: obj
|
|
16
19
|
};
|
|
17
20
|
}
|
|
18
|
-
function
|
|
19
|
-
if (
|
|
21
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
22
|
+
if (typeof WeakMap !== "function") return null;
|
|
23
|
+
var cacheBabelInterop = new WeakMap();
|
|
24
|
+
var cacheNodeInterop = new WeakMap();
|
|
25
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
26
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
27
|
+
})(nodeInterop);
|
|
28
|
+
}
|
|
29
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
30
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
20
31
|
return obj;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
}
|
|
33
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
34
|
+
return {
|
|
35
|
+
default: obj
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
39
|
+
if (cache && cache.has(obj)) {
|
|
40
|
+
return cache.get(obj);
|
|
41
|
+
}
|
|
42
|
+
var newObj = {};
|
|
43
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
44
|
+
for(var key in obj){
|
|
45
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
46
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
47
|
+
if (desc && (desc.get || desc.set)) {
|
|
48
|
+
Object.defineProperty(newObj, key, desc);
|
|
49
|
+
} else {
|
|
50
|
+
newObj[key] = obj[key];
|
|
33
51
|
}
|
|
34
52
|
}
|
|
35
|
-
newObj.default = obj;
|
|
36
|
-
return newObj;
|
|
37
53
|
}
|
|
54
|
+
newObj.default = obj;
|
|
55
|
+
if (cache) {
|
|
56
|
+
cache.set(obj, newObj);
|
|
57
|
+
}
|
|
58
|
+
return newObj;
|
|
38
59
|
}
|
|
39
|
-
let env =
|
|
60
|
+
let env = _sharedState.env;
|
|
40
61
|
const builtInExtractors = {
|
|
41
62
|
DEFAULT: _defaultExtractor.defaultExtractor
|
|
42
63
|
};
|
|
43
64
|
const builtInTransformers = {
|
|
44
|
-
DEFAULT: (content)=>content
|
|
45
|
-
,
|
|
46
|
-
svelte: (content)=>content.replace(/(?:^|\s)class:/g, ' ')
|
|
65
|
+
DEFAULT: (content)=>content,
|
|
66
|
+
svelte: (content)=>content.replace(/(?:^|\s)class:/g, " ")
|
|
47
67
|
};
|
|
48
|
-
function getExtractor(
|
|
49
|
-
let extractors = tailwindConfig.content.extract;
|
|
50
|
-
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT;
|
|
68
|
+
function getExtractor(context, fileExtension) {
|
|
69
|
+
let extractors = context.tailwindConfig.content.extract;
|
|
70
|
+
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT(context);
|
|
51
71
|
}
|
|
52
72
|
function getTransformer(tailwindConfig, fileExtension) {
|
|
53
73
|
let transformers = tailwindConfig.content.transform;
|
|
@@ -63,7 +83,7 @@ function getClassCandidates(content, extractor, candidates, seen) {
|
|
|
63
83
|
maxSize: 25000
|
|
64
84
|
}));
|
|
65
85
|
}
|
|
66
|
-
for (let line of content.split(
|
|
86
|
+
for (let line of content.split("\n")){
|
|
67
87
|
line = line.trim();
|
|
68
88
|
if (seen.has(line)) {
|
|
69
89
|
continue;
|
|
@@ -74,19 +94,17 @@ function getClassCandidates(content, extractor, candidates, seen) {
|
|
|
74
94
|
candidates.add(match);
|
|
75
95
|
}
|
|
76
96
|
} else {
|
|
77
|
-
let extractorMatches = extractor(line).filter((s)=>s !==
|
|
78
|
-
);
|
|
97
|
+
let extractorMatches = extractor(line).filter((s)=>s !== "!*");
|
|
79
98
|
let lineMatchesSet = new Set(extractorMatches);
|
|
80
|
-
for (let
|
|
81
|
-
candidates.add(
|
|
99
|
+
for (let match1 of lineMatchesSet){
|
|
100
|
+
candidates.add(match1);
|
|
82
101
|
}
|
|
83
102
|
extractorCache.get(extractor).set(line, lineMatchesSet);
|
|
84
103
|
}
|
|
85
104
|
}
|
|
86
105
|
}
|
|
87
106
|
function buildStylesheet(rules, context) {
|
|
88
|
-
let sortedRules = rules.sort(([a], [z])=>(0, _bigSign
|
|
89
|
-
);
|
|
107
|
+
let sortedRules = rules.sort(([a], [z])=>(0, _bigSign.default)(a - z));
|
|
90
108
|
let returnValue = {
|
|
91
109
|
base: new Set(),
|
|
92
110
|
defaults: new Set(),
|
|
@@ -144,37 +162,36 @@ function expandTailwindAtRules(context) {
|
|
|
144
162
|
// a lot of work and bail early. Also we don't have to register our touch
|
|
145
163
|
// file as a dependency since the output of this CSS does not depend on
|
|
146
164
|
// the source of any templates. Think Vue <style> blocks for example.
|
|
147
|
-
if (rule.name ===
|
|
165
|
+
if (rule.name === "tailwind") {
|
|
148
166
|
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
149
167
|
layerNodes[rule.params] = rule;
|
|
150
168
|
}
|
|
151
169
|
}
|
|
152
170
|
});
|
|
153
|
-
if (Object.values(layerNodes).every((n)=>n === null
|
|
154
|
-
)) {
|
|
171
|
+
if (Object.values(layerNodes).every((n)=>n === null)) {
|
|
155
172
|
return root;
|
|
156
173
|
}
|
|
157
174
|
// ---
|
|
158
175
|
// Find potential rules in changed files
|
|
159
176
|
let candidates = new Set([
|
|
160
|
-
|
|
177
|
+
_sharedState.NOT_ON_DEMAND
|
|
161
178
|
]);
|
|
162
179
|
let seen = new Set();
|
|
163
|
-
env.DEBUG && console.time(
|
|
180
|
+
env.DEBUG && console.time("Reading changed files");
|
|
164
181
|
for (let { content , extension } of context.changedContent){
|
|
165
182
|
let transformer = getTransformer(context.tailwindConfig, extension);
|
|
166
|
-
let extractor = getExtractor(context
|
|
183
|
+
let extractor = getExtractor(context, extension);
|
|
167
184
|
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
168
185
|
}
|
|
169
|
-
env.DEBUG && console.timeEnd(
|
|
186
|
+
env.DEBUG && console.timeEnd("Reading changed files");
|
|
170
187
|
// ---
|
|
171
188
|
// Generate the actual CSS
|
|
172
189
|
let classCacheCount = context.classCache.size;
|
|
173
|
-
env.DEBUG && console.time(
|
|
174
|
-
let rules = (0, _generateRules
|
|
175
|
-
env.DEBUG && console.timeEnd(
|
|
190
|
+
env.DEBUG && console.time("Generate rules");
|
|
191
|
+
let rules = (0, _generateRules.generateRules)(candidates, context);
|
|
192
|
+
env.DEBUG && console.timeEnd("Generate rules");
|
|
176
193
|
// We only ever add to the classCache, so if it didn't grow, there is nothing new.
|
|
177
|
-
env.DEBUG && console.time(
|
|
194
|
+
env.DEBUG && console.time("Build stylesheet");
|
|
178
195
|
if (context.stylesheetCache === null || context.classCache.size !== classCacheCount) {
|
|
179
196
|
for (let rule of rules){
|
|
180
197
|
context.ruleCache.add(rule);
|
|
@@ -183,32 +200,32 @@ function expandTailwindAtRules(context) {
|
|
|
183
200
|
...context.ruleCache
|
|
184
201
|
], context);
|
|
185
202
|
}
|
|
186
|
-
env.DEBUG && console.timeEnd(
|
|
203
|
+
env.DEBUG && console.timeEnd("Build stylesheet");
|
|
187
204
|
let { defaults: defaultNodes , base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes , } = context.stylesheetCache;
|
|
188
205
|
// ---
|
|
189
206
|
// Replace any Tailwind directives with generated CSS
|
|
190
207
|
if (layerNodes.base) {
|
|
191
|
-
layerNodes.base.before((0, _cloneNodes
|
|
208
|
+
layerNodes.base.before((0, _cloneNodes.default)([
|
|
192
209
|
...baseNodes,
|
|
193
210
|
...defaultNodes
|
|
194
211
|
], layerNodes.base.source, {
|
|
195
|
-
layer:
|
|
212
|
+
layer: "base"
|
|
196
213
|
}));
|
|
197
214
|
layerNodes.base.remove();
|
|
198
215
|
}
|
|
199
216
|
if (layerNodes.components) {
|
|
200
|
-
layerNodes.components.before((0, _cloneNodes
|
|
217
|
+
layerNodes.components.before((0, _cloneNodes.default)([
|
|
201
218
|
...componentNodes
|
|
202
219
|
], layerNodes.components.source, {
|
|
203
|
-
layer:
|
|
220
|
+
layer: "components"
|
|
204
221
|
}));
|
|
205
222
|
layerNodes.components.remove();
|
|
206
223
|
}
|
|
207
224
|
if (layerNodes.utilities) {
|
|
208
|
-
layerNodes.utilities.before((0, _cloneNodes
|
|
225
|
+
layerNodes.utilities.before((0, _cloneNodes.default)([
|
|
209
226
|
...utilityNodes
|
|
210
227
|
], layerNodes.utilities.source, {
|
|
211
|
-
layer:
|
|
228
|
+
layer: "utilities"
|
|
212
229
|
}));
|
|
213
230
|
layerNodes.utilities.remove();
|
|
214
231
|
}
|
|
@@ -216,44 +233,44 @@ function expandTailwindAtRules(context) {
|
|
|
216
233
|
const variantNodes = Array.from(screenNodes).filter((node)=>{
|
|
217
234
|
var ref;
|
|
218
235
|
const parentLayer = (ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer;
|
|
219
|
-
if (parentLayer ===
|
|
236
|
+
if (parentLayer === "components") {
|
|
220
237
|
return layerNodes.components !== null;
|
|
221
238
|
}
|
|
222
|
-
if (parentLayer ===
|
|
239
|
+
if (parentLayer === "utilities") {
|
|
223
240
|
return layerNodes.utilities !== null;
|
|
224
241
|
}
|
|
225
242
|
return true;
|
|
226
243
|
});
|
|
227
244
|
if (layerNodes.variants) {
|
|
228
|
-
layerNodes.variants.before((0, _cloneNodes
|
|
229
|
-
layer:
|
|
245
|
+
layerNodes.variants.before((0, _cloneNodes.default)(variantNodes, layerNodes.variants.source, {
|
|
246
|
+
layer: "variants"
|
|
230
247
|
}));
|
|
231
248
|
layerNodes.variants.remove();
|
|
232
249
|
} else if (variantNodes.length > 0) {
|
|
233
|
-
root.append((0, _cloneNodes
|
|
234
|
-
layer:
|
|
250
|
+
root.append((0, _cloneNodes.default)(variantNodes, root.source, {
|
|
251
|
+
layer: "variants"
|
|
235
252
|
}));
|
|
236
253
|
}
|
|
237
254
|
// If we've got a utility layer and no utilities are generated there's likely something wrong
|
|
238
255
|
const hasUtilityVariants = variantNodes.some((node)=>{
|
|
239
256
|
var ref;
|
|
240
|
-
return ((ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer) ===
|
|
257
|
+
return ((ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer) === "utilities";
|
|
241
258
|
});
|
|
242
259
|
if (layerNodes.utilities && utilityNodes.size === 0 && !hasUtilityVariants) {
|
|
243
|
-
_log.default.warn(
|
|
244
|
-
|
|
245
|
-
|
|
260
|
+
_log.default.warn("content-problems", [
|
|
261
|
+
"No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.",
|
|
262
|
+
"https://tailwindcss.com/docs/content-configuration",
|
|
246
263
|
]);
|
|
247
264
|
}
|
|
248
265
|
// ---
|
|
249
266
|
if (env.DEBUG) {
|
|
250
|
-
console.log(
|
|
251
|
-
console.log(
|
|
267
|
+
console.log("Potential classes: ", candidates.size);
|
|
268
|
+
console.log("Active contexts: ", _sharedState.contextSourcesMap.size);
|
|
252
269
|
}
|
|
253
270
|
// Clear the cache for the changed files
|
|
254
271
|
context.changedContent = [];
|
|
255
272
|
// Cleanup any leftover @layer atrules
|
|
256
|
-
root.walkAtRules(
|
|
273
|
+
root.walkAtRules("layer", (rule)=>{
|
|
257
274
|
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
258
275
|
rule.remove();
|
|
259
276
|
}
|