tailwindcss 0.0.0-insiders.df011dc → 0.0.0-insiders.e2d5f21
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 +106 -1
- package/README.md +1 -1
- package/colors.js +1 -304
- package/defaultConfig.js +1 -4
- package/defaultTheme.js +1 -4
- package/lib/cli-peer-dependencies.js +4 -9
- package/lib/cli.js +646 -705
- package/lib/constants.js +15 -15
- package/lib/corePluginList.js +174 -4
- package/lib/corePlugins.js +3637 -2934
- package/lib/css/preflight.css +14 -1
- package/lib/featureFlags.js +44 -44
- package/lib/index.js +25 -24
- package/lib/lib/collapseAdjacentRules.js +33 -35
- package/lib/lib/collapseDuplicateDeclarations.js +29 -0
- package/lib/lib/detectNesting.js +34 -0
- package/lib/lib/evaluateTailwindFunctions.js +134 -155
- package/lib/lib/expandApplyAtRules.js +183 -200
- package/lib/lib/expandTailwindAtRules.js +219 -232
- package/lib/lib/generateRules.js +478 -311
- package/lib/lib/getModuleDependencies.js +36 -41
- package/lib/lib/normalizeTailwindDirectives.js +66 -58
- package/lib/lib/resolveDefaultsAtRules.js +110 -90
- package/lib/lib/setupContextUtils.js +740 -580
- package/lib/lib/setupTrackingContext.js +142 -162
- package/lib/lib/setupWatchingContext.js +235 -278
- package/lib/lib/sharedState.js +7 -17
- package/lib/lib/substituteScreenAtRules.js +22 -26
- package/lib/processTailwindFeatures.js +38 -44
- package/lib/public/colors.js +329 -0
- package/lib/public/create-plugin.js +13 -0
- package/lib/public/default-config.js +14 -0
- package/lib/public/default-theme.js +14 -0
- package/lib/public/resolve-config.js +19 -0
- package/lib/util/bigSign.js +3 -5
- package/lib/util/buildMediaQuery.js +15 -31
- package/lib/util/cloneDeep.js +14 -13
- package/lib/util/cloneNodes.js +9 -13
- package/lib/util/color.js +69 -59
- package/lib/util/configurePlugins.js +13 -14
- package/lib/util/createPlugin.js +21 -24
- package/lib/util/createUtilityPlugin.js +47 -45
- package/lib/util/dataTypes.js +231 -0
- package/lib/util/defaults.js +10 -14
- package/lib/util/escapeClassName.js +12 -14
- package/lib/util/escapeCommas.js +3 -5
- package/lib/util/flattenColorPalette.js +14 -10
- package/lib/util/formatVariantSelector.js +186 -0
- package/lib/util/getAllConfigs.js +23 -16
- package/lib/util/hashConfig.js +10 -10
- package/lib/util/isKeyframeRule.js +3 -5
- package/lib/util/isPlainObject.js +7 -10
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/log.js +39 -30
- package/lib/util/nameClass.js +23 -23
- package/lib/util/negateValue.js +14 -15
- package/lib/util/normalizeConfig.js +208 -0
- package/lib/util/normalizeScreens.js +58 -0
- package/lib/util/parseAnimationValue.js +82 -53
- package/lib/util/parseBoxShadowValue.js +77 -0
- package/lib/util/parseDependency.js +49 -60
- package/lib/util/parseObjectStyles.js +23 -20
- package/lib/util/pluginUtils.js +153 -285
- package/lib/util/prefixSelector.js +14 -16
- package/lib/util/resolveConfig.js +194 -249
- package/lib/util/resolveConfigPath.js +38 -45
- package/lib/util/responsive.js +12 -11
- package/lib/util/tap.js +4 -6
- package/lib/util/toColorValue.js +4 -5
- package/lib/util/toPath.js +4 -6
- package/lib/util/transformThemeValue.js +57 -26
- package/lib/util/withAlphaVariable.js +56 -54
- package/package.json +27 -37
- package/peers/index.js +73099 -84294
- package/plugin.js +1 -3
- package/resolveConfig.js +1 -7
- package/scripts/create-plugin-list.js +2 -2
- package/src/cli.js +27 -18
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +2124 -1968
- package/src/css/preflight.css +14 -1
- package/src/featureFlags.js +12 -6
- package/src/lib/collapseDuplicateDeclarations.js +28 -0
- package/src/lib/detectNesting.js +39 -0
- package/src/lib/evaluateTailwindFunctions.js +5 -2
- package/src/lib/expandTailwindAtRules.js +24 -32
- package/src/lib/generateRules.js +230 -20
- package/src/lib/normalizeTailwindDirectives.js +3 -2
- package/src/lib/resolveDefaultsAtRules.js +46 -30
- package/src/lib/setupContextUtils.js +275 -113
- package/src/lib/setupTrackingContext.js +9 -8
- package/src/lib/setupWatchingContext.js +12 -7
- package/src/lib/sharedState.js +1 -4
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/processTailwindFeatures.js +8 -1
- package/src/public/colors.js +300 -0
- package/src/public/create-plugin.js +2 -0
- package/src/public/default-config.js +4 -0
- package/src/public/default-theme.js +4 -0
- package/src/public/resolve-config.js +7 -0
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/createUtilityPlugin.js +2 -11
- package/src/util/dataTypes.js +246 -0
- package/src/util/formatVariantSelector.js +196 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +18 -21
- package/src/util/nameClass.js +10 -6
- package/src/util/negateValue.js +4 -2
- package/src/util/normalizeConfig.js +249 -0
- package/src/util/normalizeScreens.js +42 -0
- package/src/util/parseAnimationValue.js +7 -1
- package/src/util/parseBoxShadowValue.js +71 -0
- package/src/util/parseDependency.js +4 -0
- package/src/util/pluginUtils.js +101 -204
- package/src/util/prefixSelector.js +1 -4
- package/src/util/resolveConfig.js +12 -65
- package/src/util/transformThemeValue.js +22 -7
- package/src/util/withAlphaVariable.js +13 -8
- package/stubs/defaultConfig.stub.js +163 -97
- package/stubs/simpleConfig.stub.js +0 -1
|
@@ -1,643 +1,803 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.getFileModifiedMap = getFileModifiedMap;
|
|
7
6
|
exports.createContext = createContext;
|
|
8
7
|
exports.getContext = getContext;
|
|
9
|
-
|
|
10
8
|
var _fs = _interopRequireDefault(require("fs"));
|
|
11
|
-
|
|
12
9
|
var _url = _interopRequireDefault(require("url"));
|
|
13
|
-
|
|
14
10
|
var _postcss = _interopRequireDefault(require("postcss"));
|
|
15
|
-
|
|
16
11
|
var _dlv = _interopRequireDefault(require("dlv"));
|
|
17
|
-
|
|
18
12
|
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
|
|
19
|
-
|
|
20
13
|
var _transformThemeValue = _interopRequireDefault(require("../util/transformThemeValue"));
|
|
21
|
-
|
|
22
14
|
var _parseObjectStyles = _interopRequireDefault(require("../util/parseObjectStyles"));
|
|
23
|
-
|
|
24
15
|
var _prefixSelector = _interopRequireDefault(require("../util/prefixSelector"));
|
|
25
|
-
|
|
26
16
|
var _isPlainObject = _interopRequireDefault(require("../util/isPlainObject"));
|
|
27
|
-
|
|
28
17
|
var _escapeClassName = _interopRequireDefault(require("../util/escapeClassName"));
|
|
29
|
-
|
|
30
|
-
var _nameClass = _interopRequireDefault(require("../util/nameClass"));
|
|
31
|
-
|
|
18
|
+
var _nameClass = _interopRequireWildcard(require("../util/nameClass"));
|
|
32
19
|
var _pluginUtils = require("../util/pluginUtils");
|
|
33
|
-
|
|
34
20
|
var _bigSign = _interopRequireDefault(require("../util/bigSign"));
|
|
35
|
-
|
|
36
|
-
var corePlugins = _interopRequireWildcard(require("../corePlugins"));
|
|
37
|
-
|
|
21
|
+
var _corePlugins = require("../corePlugins");
|
|
38
22
|
var sharedState = _interopRequireWildcard(require("./sharedState"));
|
|
39
|
-
|
|
40
23
|
var _toPath = require("../util/toPath");
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
24
|
+
var _log = _interopRequireDefault(require("../util/log"));
|
|
25
|
+
var _negateValue = _interopRequireDefault(require("../util/negateValue"));
|
|
26
|
+
var _isValidArbitraryValue = _interopRequireDefault(require("../util/isValidArbitraryValue"));
|
|
27
|
+
function _interopRequireDefault(obj) {
|
|
28
|
+
return obj && obj.__esModule ? obj : {
|
|
29
|
+
default: obj
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function _interopRequireWildcard(obj) {
|
|
33
|
+
if (obj && obj.__esModule) {
|
|
34
|
+
return obj;
|
|
35
|
+
} else {
|
|
36
|
+
var newObj = {
|
|
37
|
+
};
|
|
38
|
+
if (obj != null) {
|
|
39
|
+
for(var key in obj){
|
|
40
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
41
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
|
42
|
+
};
|
|
43
|
+
if (desc.get || desc.set) {
|
|
44
|
+
Object.defineProperty(newObj, key, desc);
|
|
45
|
+
} else {
|
|
46
|
+
newObj[key] = obj[key];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
newObj.default = obj;
|
|
52
|
+
return newObj;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function parseVariantFormatString(input) {
|
|
56
|
+
if (input.includes('{')) {
|
|
57
|
+
if (!isBalanced(input)) throw new Error(`Your { and } are unbalanced.`);
|
|
58
|
+
return input.split(/{(.*)}/gim).flatMap((line)=>parseVariantFormatString(line)
|
|
59
|
+
).filter(Boolean);
|
|
60
|
+
}
|
|
61
|
+
return [
|
|
62
|
+
input.trim()
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
function isBalanced(input) {
|
|
66
|
+
let count = 0;
|
|
67
|
+
for (let char of input){
|
|
68
|
+
if (char === '{') {
|
|
69
|
+
count++;
|
|
70
|
+
} else if (char === '}') {
|
|
71
|
+
if (--count < 0) {
|
|
72
|
+
return false // unbalanced
|
|
73
|
+
;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return count === 0;
|
|
78
|
+
}
|
|
79
|
+
function insertInto(list, value, { before =[] } = {
|
|
80
|
+
}) {
|
|
81
|
+
before = [].concat(before);
|
|
82
|
+
if (before.length <= 0) {
|
|
83
|
+
list.push(value);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
let idx = list.length - 1;
|
|
87
|
+
for (let other of before){
|
|
88
|
+
let iidx = list.indexOf(other);
|
|
89
|
+
if (iidx === -1) continue;
|
|
90
|
+
idx = Math.min(idx, iidx);
|
|
91
|
+
}
|
|
92
|
+
list.splice(idx, 0, value);
|
|
67
93
|
}
|
|
68
|
-
|
|
69
94
|
function parseStyles(styles) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
95
|
+
if (!Array.isArray(styles)) {
|
|
96
|
+
return parseStyles([
|
|
97
|
+
styles
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
return styles.flatMap((style)=>{
|
|
101
|
+
let isNode = !Array.isArray(style) && !(0, _isPlainObject).default(style);
|
|
102
|
+
return isNode ? style : (0, _parseObjectStyles).default(style);
|
|
103
|
+
});
|
|
78
104
|
}
|
|
79
|
-
|
|
80
105
|
function getClasses(selector) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
106
|
+
let parser = (0, _postcssSelectorParser).default((selectors)=>{
|
|
107
|
+
let allClasses = [];
|
|
108
|
+
selectors.walkClasses((classNode)=>{
|
|
109
|
+
allClasses.push(classNode.value);
|
|
110
|
+
});
|
|
111
|
+
return allClasses;
|
|
85
112
|
});
|
|
86
|
-
return
|
|
87
|
-
});
|
|
88
|
-
return parser.transformSync(selector);
|
|
113
|
+
return parser.transformSync(selector);
|
|
89
114
|
}
|
|
90
|
-
|
|
91
115
|
function extractCandidates(node) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
116
|
+
let classes = [];
|
|
117
|
+
if (node.type === 'rule') {
|
|
118
|
+
for (let selector of node.selectors){
|
|
119
|
+
let classCandidates = getClasses(selector);
|
|
120
|
+
// At least one of the selectors contains non-"on-demandable" candidates.
|
|
121
|
+
if (classCandidates.length === 0) return [];
|
|
122
|
+
classes = [
|
|
123
|
+
...classes,
|
|
124
|
+
...classCandidates
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
return classes;
|
|
128
|
+
}
|
|
129
|
+
if (node.type === 'atrule') {
|
|
130
|
+
node.walkRules((rule)=>{
|
|
131
|
+
classes = [
|
|
132
|
+
...classes,
|
|
133
|
+
...rule.selectors.flatMap((selector)=>getClasses(selector)
|
|
134
|
+
)
|
|
135
|
+
];
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return classes;
|
|
101
139
|
}
|
|
102
|
-
|
|
103
140
|
function withIdentifiers(styles) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
141
|
+
return parseStyles(styles).flatMap((node)=>{
|
|
142
|
+
let nodeMap = new Map();
|
|
143
|
+
let candidates = extractCandidates(node);
|
|
144
|
+
// If this isn't "on-demandable", assign it a universal candidate.
|
|
145
|
+
if (candidates.length === 0) {
|
|
146
|
+
return [
|
|
147
|
+
[
|
|
148
|
+
'*',
|
|
149
|
+
node
|
|
150
|
+
]
|
|
151
|
+
];
|
|
152
|
+
}
|
|
153
|
+
return candidates.map((c)=>{
|
|
154
|
+
if (!nodeMap.has(node)) {
|
|
155
|
+
nodeMap.set(node, node);
|
|
156
|
+
}
|
|
157
|
+
return [
|
|
158
|
+
c,
|
|
159
|
+
nodeMap.get(node)
|
|
160
|
+
];
|
|
161
|
+
});
|
|
118
162
|
});
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
let matchingBrackets = new Map([['{', '}'], ['[', ']'], ['(', ')']]);
|
|
123
|
-
let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v]) => [v, k]));
|
|
124
|
-
let quotes = new Set(['"', "'", '`']); // Arbitrary values must contain balanced brackets (), [] and {}. Escaped
|
|
125
|
-
// values don't count, and brackets inside quotes also don't count.
|
|
126
|
-
//
|
|
127
|
-
// E.g.: w-[this-is]w-[weird-and-invalid]
|
|
128
|
-
// E.g.: w-[this-is\\]w-\\[weird-but-valid]
|
|
129
|
-
// E.g.: content-['this-is-also-valid]-weirdly-enough']
|
|
130
|
-
|
|
131
|
-
function isValidArbitraryValue(value) {
|
|
132
|
-
let stack = [];
|
|
133
|
-
let inQuotes = false;
|
|
134
|
-
|
|
135
|
-
for (let i = 0; i < value.length; i++) {
|
|
136
|
-
let char = value[i]; // Non-escaped quotes allow us to "allow" anything in between
|
|
137
|
-
|
|
138
|
-
if (quotes.has(char) && value[i - 1] !== '\\') {
|
|
139
|
-
inQuotes = !inQuotes;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (inQuotes) continue;
|
|
143
|
-
if (value[i - 1] === '\\') continue; // Escaped
|
|
144
|
-
|
|
145
|
-
if (matchingBrackets.has(char)) {
|
|
146
|
-
stack.push(char);
|
|
147
|
-
} else if (inverseMatchingBrackets.has(char)) {
|
|
148
|
-
let inverse = inverseMatchingBrackets.get(char); // Nothing to pop from, therefore it is unbalanced
|
|
149
|
-
|
|
150
|
-
if (stack.length <= 0) {
|
|
151
|
-
return false;
|
|
152
|
-
} // Popped value must match the inverse value, otherwise it is unbalanced
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (stack.pop() !== inverse) {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
} // If there is still something on the stack, it is also unbalanced
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (stack.length > 0) {
|
|
163
|
-
return false;
|
|
164
|
-
} // All good, totally balanced!
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return true;
|
|
168
163
|
}
|
|
169
|
-
|
|
170
|
-
function
|
|
171
|
-
|
|
172
|
-
variantMap,
|
|
173
|
-
offsets
|
|
174
|
-
}) {
|
|
175
|
-
function getConfigValue(path, defaultValue) {
|
|
176
|
-
return path ? (0, _dlv.default)(tailwindConfig, path, defaultValue) : tailwindConfig;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function applyConfiguredPrefix(selector) {
|
|
180
|
-
return (0, _prefixSelector.default)(tailwindConfig.prefix, selector);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function prefixIdentifier(identifier, options) {
|
|
184
|
-
if (identifier === '*') {
|
|
185
|
-
return '*';
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (!options.respectPrefix) {
|
|
189
|
-
return identifier;
|
|
164
|
+
function buildPluginApi(tailwindConfig, context, { variantList , variantMap , offsets , classList }) {
|
|
165
|
+
function getConfigValue(path, defaultValue) {
|
|
166
|
+
return path ? (0, _dlv).default(tailwindConfig, path, defaultValue) : tailwindConfig;
|
|
190
167
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return (0, _prefixSelector.default)(context.tailwindConfig.prefix, `.${identifier}`).substr(1);
|
|
168
|
+
function applyConfiguredPrefix(selector) {
|
|
169
|
+
return (0, _prefixSelector).default(tailwindConfig.prefix, selector);
|
|
194
170
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return {
|
|
200
|
-
addVariant(variantName, variantFunctions, options = {}) {
|
|
201
|
-
variantFunctions = [].concat(variantFunctions);
|
|
202
|
-
insertInto(variantList, variantName, options);
|
|
203
|
-
variantMap.set(variantName, variantFunctions);
|
|
204
|
-
},
|
|
205
|
-
|
|
206
|
-
postcss: _postcss.default,
|
|
207
|
-
prefix: applyConfiguredPrefix,
|
|
208
|
-
e: _escapeClassName.default,
|
|
209
|
-
config: getConfigValue,
|
|
210
|
-
|
|
211
|
-
theme(path, defaultValue) {
|
|
212
|
-
const [pathRoot, ...subPaths] = (0, _toPath.toPath)(path);
|
|
213
|
-
const value = getConfigValue(['theme', pathRoot, ...subPaths], defaultValue);
|
|
214
|
-
return (0, _transformThemeValue.default)(pathRoot)(value);
|
|
215
|
-
},
|
|
216
|
-
|
|
217
|
-
corePlugins: path => {
|
|
218
|
-
if (Array.isArray(tailwindConfig.corePlugins)) {
|
|
219
|
-
return tailwindConfig.corePlugins.includes(path);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return getConfigValue(['corePlugins', path], true);
|
|
223
|
-
},
|
|
224
|
-
variants: () => {
|
|
225
|
-
// Preserved for backwards compatibility but not used in v3.0+
|
|
226
|
-
return [];
|
|
227
|
-
},
|
|
228
|
-
|
|
229
|
-
addUserCss(userCss) {
|
|
230
|
-
for (let [identifier, rule] of withIdentifiers(userCss)) {
|
|
231
|
-
let offset = offsets.user++;
|
|
232
|
-
|
|
233
|
-
if (!context.candidateRuleMap.has(identifier)) {
|
|
234
|
-
context.candidateRuleMap.set(identifier, []);
|
|
171
|
+
function prefixIdentifier(identifier, options) {
|
|
172
|
+
if (identifier === '*') {
|
|
173
|
+
return '*';
|
|
235
174
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
sort: offset,
|
|
239
|
-
layer: 'user'
|
|
240
|
-
}, rule]);
|
|
241
|
-
}
|
|
242
|
-
},
|
|
243
|
-
|
|
244
|
-
addBase(base) {
|
|
245
|
-
for (let [identifier, rule] of withIdentifiers(base)) {
|
|
246
|
-
let prefixedIdentifier = prefixIdentifier(identifier, {});
|
|
247
|
-
let offset = offsets.base++;
|
|
248
|
-
|
|
249
|
-
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
250
|
-
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
175
|
+
if (!options.respectPrefix) {
|
|
176
|
+
return identifier;
|
|
251
177
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
matchUtilities: function (utilities, options) {
|
|
315
|
-
let defaultOptions = {
|
|
316
|
-
variants: [],
|
|
317
|
-
respectPrefix: true,
|
|
318
|
-
respectImportant: true,
|
|
319
|
-
respectVariants: true
|
|
320
|
-
};
|
|
321
|
-
options = { ...defaultOptions,
|
|
322
|
-
...options
|
|
323
|
-
};
|
|
324
|
-
let offset = offsets.utilities++;
|
|
325
|
-
|
|
326
|
-
for (let identifier in utilities) {
|
|
327
|
-
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
328
|
-
let rule = utilities[identifier];
|
|
329
|
-
|
|
330
|
-
function wrapped(modifier) {
|
|
331
|
-
let {
|
|
332
|
-
type = 'any'
|
|
333
|
-
} = options;
|
|
334
|
-
type = [].concat(type);
|
|
335
|
-
let [value, coercedType] = (0, _pluginUtils.coerceValue)(type, modifier, options.values, tailwindConfig);
|
|
336
|
-
|
|
337
|
-
if (!type.includes(coercedType) || value === undefined) {
|
|
338
|
-
return [];
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
if (!isValidArbitraryValue(value)) {
|
|
178
|
+
return context.tailwindConfig.prefix + identifier;
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
addVariant (variantName, variantFunctions, options = {
|
|
182
|
+
}) {
|
|
183
|
+
variantFunctions = [].concat(variantFunctions).map((variantFunction)=>{
|
|
184
|
+
if (typeof variantFunction !== 'string') {
|
|
185
|
+
// Safelist public API functions
|
|
186
|
+
return ({ modifySelectors , container , separator })=>{
|
|
187
|
+
return variantFunction({
|
|
188
|
+
modifySelectors,
|
|
189
|
+
container,
|
|
190
|
+
separator
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
variantFunction = variantFunction.replace(/\n+/g, '').replace(/\s{1,}/g, ' ').trim();
|
|
195
|
+
let fns = parseVariantFormatString(variantFunction).map((str)=>{
|
|
196
|
+
if (!str.startsWith('@')) {
|
|
197
|
+
return ({ format })=>format(str)
|
|
198
|
+
;
|
|
199
|
+
}
|
|
200
|
+
let [, name, params] = /@(.*?) (.*)/g.exec(str);
|
|
201
|
+
return ({ wrap })=>wrap(_postcss.default.atRule({
|
|
202
|
+
name,
|
|
203
|
+
params
|
|
204
|
+
}))
|
|
205
|
+
;
|
|
206
|
+
}).reverse();
|
|
207
|
+
return (api)=>{
|
|
208
|
+
for (let fn of fns){
|
|
209
|
+
fn(api);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
});
|
|
213
|
+
insertInto(variantList, variantName, options);
|
|
214
|
+
variantMap.set(variantName, variantFunctions);
|
|
215
|
+
},
|
|
216
|
+
postcss: _postcss.default,
|
|
217
|
+
prefix: applyConfiguredPrefix,
|
|
218
|
+
e: _escapeClassName.default,
|
|
219
|
+
config: getConfigValue,
|
|
220
|
+
theme (path, defaultValue) {
|
|
221
|
+
const [pathRoot, ...subPaths] = (0, _toPath).toPath(path);
|
|
222
|
+
const value = getConfigValue([
|
|
223
|
+
'theme',
|
|
224
|
+
pathRoot,
|
|
225
|
+
...subPaths
|
|
226
|
+
], defaultValue);
|
|
227
|
+
return (0, _transformThemeValue).default(pathRoot)(value);
|
|
228
|
+
},
|
|
229
|
+
corePlugins: (path)=>{
|
|
230
|
+
if (Array.isArray(tailwindConfig.corePlugins)) {
|
|
231
|
+
return tailwindConfig.corePlugins.includes(path);
|
|
232
|
+
}
|
|
233
|
+
return getConfigValue([
|
|
234
|
+
'corePlugins',
|
|
235
|
+
path
|
|
236
|
+
], true);
|
|
237
|
+
},
|
|
238
|
+
variants: ()=>{
|
|
239
|
+
// Preserved for backwards compatibility but not used in v3.0+
|
|
342
240
|
return [];
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
241
|
+
},
|
|
242
|
+
addUserCss (userCss) {
|
|
243
|
+
for (let [identifier, rule] of withIdentifiers(userCss)){
|
|
244
|
+
let offset = offsets.user++;
|
|
245
|
+
if (!context.candidateRuleMap.has(identifier)) {
|
|
246
|
+
context.candidateRuleMap.set(identifier, []);
|
|
247
|
+
}
|
|
248
|
+
context.candidateRuleMap.get(identifier).push([
|
|
249
|
+
{
|
|
250
|
+
sort: offset,
|
|
251
|
+
layer: 'user'
|
|
252
|
+
},
|
|
253
|
+
rule
|
|
254
|
+
]);
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
addBase (base) {
|
|
258
|
+
for (let [identifier, rule] of withIdentifiers(base)){
|
|
259
|
+
let prefixedIdentifier = prefixIdentifier(identifier, {
|
|
260
|
+
});
|
|
261
|
+
let offset = offsets.base++;
|
|
262
|
+
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
263
|
+
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
264
|
+
}
|
|
265
|
+
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
266
|
+
{
|
|
267
|
+
sort: offset,
|
|
268
|
+
layer: 'base'
|
|
269
|
+
},
|
|
270
|
+
rule
|
|
271
|
+
]);
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
addComponents (components, options) {
|
|
275
|
+
let defaultOptions = {
|
|
276
|
+
respectPrefix: true,
|
|
277
|
+
respectImportant: false
|
|
278
|
+
};
|
|
279
|
+
options = Object.assign({
|
|
280
|
+
}, defaultOptions, Array.isArray(options) ? {
|
|
281
|
+
} : options);
|
|
282
|
+
for (let [identifier, rule] of withIdentifiers(components)){
|
|
283
|
+
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
284
|
+
let offset = offsets.components++;
|
|
285
|
+
classList.add(prefixedIdentifier);
|
|
286
|
+
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
287
|
+
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
288
|
+
}
|
|
289
|
+
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
290
|
+
{
|
|
291
|
+
sort: offset,
|
|
292
|
+
layer: 'components',
|
|
293
|
+
options
|
|
294
|
+
},
|
|
295
|
+
rule
|
|
296
|
+
]);
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
addUtilities (utilities, options) {
|
|
300
|
+
let defaultOptions = {
|
|
301
|
+
respectPrefix: true,
|
|
302
|
+
respectImportant: true
|
|
303
|
+
};
|
|
304
|
+
options = Object.assign({
|
|
305
|
+
}, defaultOptions, Array.isArray(options) ? {
|
|
306
|
+
} : options);
|
|
307
|
+
for (let [identifier, rule] of withIdentifiers(utilities)){
|
|
308
|
+
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
309
|
+
let offset = offsets.utilities++;
|
|
310
|
+
classList.add(prefixedIdentifier);
|
|
311
|
+
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
312
|
+
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
313
|
+
}
|
|
314
|
+
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
315
|
+
{
|
|
316
|
+
sort: offset,
|
|
317
|
+
layer: 'utilities',
|
|
318
|
+
options
|
|
319
|
+
},
|
|
320
|
+
rule
|
|
321
|
+
]);
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
matchUtilities: function(utilities, options) {
|
|
325
|
+
let defaultOptions = {
|
|
326
|
+
respectPrefix: true,
|
|
327
|
+
respectImportant: true
|
|
328
|
+
};
|
|
329
|
+
options = {
|
|
330
|
+
...defaultOptions,
|
|
331
|
+
...options
|
|
332
|
+
};
|
|
333
|
+
let offset = offsets.utilities++;
|
|
334
|
+
for(let identifier in utilities){
|
|
335
|
+
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
336
|
+
let rule = utilities[identifier];
|
|
337
|
+
classList.add([
|
|
338
|
+
prefixedIdentifier,
|
|
339
|
+
options
|
|
340
|
+
]);
|
|
341
|
+
function wrapped(modifier, { isOnlyPlugin }) {
|
|
342
|
+
let { type ='any' } = options;
|
|
343
|
+
type = [].concat(type);
|
|
344
|
+
let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options, tailwindConfig);
|
|
345
|
+
if (value === undefined) {
|
|
346
|
+
return [];
|
|
347
|
+
}
|
|
348
|
+
if (!type.includes(coercedType) && !isOnlyPlugin) {
|
|
349
|
+
return [];
|
|
350
|
+
}
|
|
351
|
+
if (!(0, _isValidArbitraryValue).default(value)) {
|
|
352
|
+
return [];
|
|
353
|
+
}
|
|
354
|
+
let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
|
|
355
|
+
[(0, _nameClass).default(identifier, modifier)]: declaration
|
|
356
|
+
})
|
|
357
|
+
);
|
|
358
|
+
return ruleSets;
|
|
359
|
+
}
|
|
360
|
+
let withOffsets = [
|
|
361
|
+
{
|
|
362
|
+
sort: offset,
|
|
363
|
+
layer: 'utilities',
|
|
364
|
+
options
|
|
365
|
+
},
|
|
366
|
+
wrapped
|
|
367
|
+
];
|
|
368
|
+
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
369
|
+
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
370
|
+
}
|
|
371
|
+
context.candidateRuleMap.get(prefixedIdentifier).push(withOffsets);
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
matchComponents: function(components, options) {
|
|
375
|
+
let defaultOptions = {
|
|
376
|
+
respectPrefix: true,
|
|
377
|
+
respectImportant: false
|
|
378
|
+
};
|
|
379
|
+
options = {
|
|
380
|
+
...defaultOptions,
|
|
381
|
+
...options
|
|
382
|
+
};
|
|
383
|
+
let offset = offsets.components++;
|
|
384
|
+
for(let identifier in components){
|
|
385
|
+
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
386
|
+
let rule = components[identifier];
|
|
387
|
+
classList.add([
|
|
388
|
+
prefixedIdentifier,
|
|
389
|
+
options
|
|
390
|
+
]);
|
|
391
|
+
function wrapped(modifier, { isOnlyPlugin }) {
|
|
392
|
+
let { type ='any' } = options;
|
|
393
|
+
type = [].concat(type);
|
|
394
|
+
let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options, tailwindConfig);
|
|
395
|
+
if (value === undefined) {
|
|
396
|
+
return [];
|
|
397
|
+
}
|
|
398
|
+
if (!type.includes(coercedType)) {
|
|
399
|
+
if (isOnlyPlugin) {
|
|
400
|
+
_log.default.warn([
|
|
401
|
+
`Unnecessary typehint \`${coercedType}\` in \`${identifier}-${modifier}\`.`,
|
|
402
|
+
`You can safely update it to \`${identifier}-${modifier.replace(coercedType + ':', '')}\`.`,
|
|
403
|
+
]);
|
|
404
|
+
} else {
|
|
405
|
+
return [];
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (!(0, _isValidArbitraryValue).default(value)) {
|
|
409
|
+
return [];
|
|
410
|
+
}
|
|
411
|
+
let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
|
|
412
|
+
[(0, _nameClass).default(identifier, modifier)]: declaration
|
|
413
|
+
})
|
|
414
|
+
);
|
|
415
|
+
return ruleSets;
|
|
416
|
+
}
|
|
417
|
+
let withOffsets = [
|
|
418
|
+
{
|
|
419
|
+
sort: offset,
|
|
420
|
+
layer: 'components',
|
|
421
|
+
options
|
|
422
|
+
},
|
|
423
|
+
wrapped
|
|
424
|
+
];
|
|
425
|
+
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
426
|
+
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
427
|
+
}
|
|
428
|
+
context.candidateRuleMap.get(prefixedIdentifier).push(withOffsets);
|
|
349
429
|
}
|
|
350
|
-
|
|
351
|
-
})).filter(Boolean).map(declaration => ({
|
|
352
|
-
[(0, _nameClass.default)(identifier, modifier)]: declaration
|
|
353
|
-
}));
|
|
354
|
-
return [...includedRules, ...ruleSets];
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
let withOffsets = [{
|
|
358
|
-
sort: offset,
|
|
359
|
-
layer: 'utilities',
|
|
360
|
-
options
|
|
361
|
-
}, wrapped];
|
|
362
|
-
|
|
363
|
-
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
364
|
-
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
365
430
|
}
|
|
366
|
-
|
|
367
|
-
context.candidateRuleMap.get(prefixedIdentifier).push(withOffsets);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
};
|
|
431
|
+
};
|
|
371
432
|
}
|
|
372
|
-
|
|
373
433
|
let fileModifiedMapCache = new WeakMap();
|
|
374
|
-
|
|
375
434
|
function getFileModifiedMap(context) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
return fileModifiedMapCache.get(context);
|
|
435
|
+
if (!fileModifiedMapCache.has(context)) {
|
|
436
|
+
fileModifiedMapCache.set(context, new Map());
|
|
437
|
+
}
|
|
438
|
+
return fileModifiedMapCache.get(context);
|
|
381
439
|
}
|
|
382
|
-
|
|
383
440
|
function trackModified(files, fileModifiedMap) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
if (!fileModifiedMap.has(file) || newModified > fileModifiedMap.get(file)) {
|
|
397
|
-
changed = true;
|
|
441
|
+
let changed = false;
|
|
442
|
+
for (let file of files){
|
|
443
|
+
if (!file) continue;
|
|
444
|
+
let parsed = _url.default.parse(file);
|
|
445
|
+
let pathname = parsed.hash ? parsed.href.replace(parsed.hash, '') : parsed.href;
|
|
446
|
+
pathname = parsed.search ? pathname.replace(parsed.search, '') : pathname;
|
|
447
|
+
let newModified = _fs.default.statSync(decodeURIComponent(pathname)).mtimeMs;
|
|
448
|
+
if (!fileModifiedMap.has(file) || newModified > fileModifiedMap.get(file)) {
|
|
449
|
+
changed = true;
|
|
450
|
+
}
|
|
451
|
+
fileModifiedMap.set(file, newModified);
|
|
398
452
|
}
|
|
399
|
-
|
|
400
|
-
fileModifiedMap.set(file, newModified);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
return changed;
|
|
453
|
+
return changed;
|
|
404
454
|
}
|
|
405
|
-
|
|
406
455
|
function extractVariantAtRules(node) {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
456
|
+
node.walkAtRules((atRule)=>{
|
|
457
|
+
if ([
|
|
458
|
+
'responsive',
|
|
459
|
+
'variants'
|
|
460
|
+
].includes(atRule.name)) {
|
|
461
|
+
extractVariantAtRules(atRule);
|
|
462
|
+
atRule.before(atRule.nodes);
|
|
463
|
+
atRule.remove();
|
|
464
|
+
}
|
|
465
|
+
});
|
|
414
466
|
}
|
|
415
|
-
|
|
416
467
|
function collectLayerPlugins(root) {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
})
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
468
|
+
let layerPlugins = [];
|
|
469
|
+
root.each((node)=>{
|
|
470
|
+
if (node.type === 'atrule' && [
|
|
471
|
+
'responsive',
|
|
472
|
+
'variants'
|
|
473
|
+
].includes(node.name)) {
|
|
474
|
+
node.name = 'layer';
|
|
475
|
+
node.params = 'utilities';
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
// Walk @layer rules and treat them like plugins
|
|
479
|
+
root.walkAtRules('layer', (layerRule)=>{
|
|
480
|
+
extractVariantAtRules(layerRule);
|
|
481
|
+
if (layerRule.params === 'base') {
|
|
482
|
+
for (let node of layerRule.nodes){
|
|
483
|
+
layerPlugins.push(function({ addBase }) {
|
|
484
|
+
addBase(node, {
|
|
485
|
+
respectPrefix: false
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
layerRule.remove();
|
|
490
|
+
} else if (layerRule.params === 'components') {
|
|
491
|
+
for (let node of layerRule.nodes){
|
|
492
|
+
layerPlugins.push(function({ addComponents }) {
|
|
493
|
+
addComponents(node, {
|
|
494
|
+
respectPrefix: false
|
|
495
|
+
});
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
layerRule.remove();
|
|
499
|
+
} else if (layerRule.params === 'utilities') {
|
|
500
|
+
for (let node of layerRule.nodes){
|
|
501
|
+
layerPlugins.push(function({ addUtilities }) {
|
|
502
|
+
addUtilities(node, {
|
|
503
|
+
respectPrefix: false
|
|
504
|
+
});
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
layerRule.remove();
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
root.walkRules((rule)=>{
|
|
511
|
+
// At this point it is safe to include all the left-over css from the
|
|
512
|
+
// user's css file. This is because the `@tailwind` and `@layer` directives
|
|
513
|
+
// will already be handled and will be removed from the css tree.
|
|
514
|
+
layerPlugins.push(function({ addUserCss }) {
|
|
515
|
+
addUserCss(rule, {
|
|
516
|
+
respectPrefix: false
|
|
517
|
+
});
|
|
460
518
|
});
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
layerRule.remove();
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
root.walkRules(rule => {
|
|
467
|
-
// At this point it is safe to include all the left-over css from the
|
|
468
|
-
// user's css file. This is because the `@tailwind` and `@layer` directives
|
|
469
|
-
// will already be handled and will be removed from the css tree.
|
|
470
|
-
layerPlugins.push(function ({
|
|
471
|
-
addUserCss
|
|
472
|
-
}) {
|
|
473
|
-
addUserCss(rule, {
|
|
474
|
-
respectPrefix: false
|
|
475
|
-
});
|
|
476
519
|
});
|
|
477
|
-
|
|
478
|
-
return layerPlugins;
|
|
520
|
+
return layerPlugins;
|
|
479
521
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
522
|
+
function resolvePlugins(context, root) {
|
|
523
|
+
let corePluginList = Object.entries({
|
|
524
|
+
..._corePlugins.variantPlugins,
|
|
525
|
+
..._corePlugins.corePlugins
|
|
526
|
+
}).map(([name, plugin])=>{
|
|
527
|
+
if (!context.tailwindConfig.corePlugins.includes(name)) {
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
530
|
+
return plugin;
|
|
531
|
+
}).filter(Boolean);
|
|
532
|
+
let userPlugins = context.tailwindConfig.plugins.map((plugin)=>{
|
|
533
|
+
if (plugin.__isOptionsFunction) {
|
|
534
|
+
plugin = plugin();
|
|
535
|
+
}
|
|
536
|
+
return typeof plugin === 'function' ? plugin : plugin.handler;
|
|
537
|
+
});
|
|
538
|
+
let layerPlugins = collectLayerPlugins(root);
|
|
539
|
+
// TODO: This is a workaround for backwards compatibility, since custom variants
|
|
540
|
+
// were historically sorted before screen/stackable variants.
|
|
541
|
+
let beforeVariants = [
|
|
542
|
+
_corePlugins.variantPlugins['pseudoElementVariants'],
|
|
543
|
+
_corePlugins.variantPlugins['pseudoClassVariants'],
|
|
544
|
+
];
|
|
545
|
+
let afterVariants = [
|
|
546
|
+
_corePlugins.variantPlugins['directionVariants'],
|
|
547
|
+
_corePlugins.variantPlugins['reducedMotionVariants'],
|
|
548
|
+
_corePlugins.variantPlugins['darkVariants'],
|
|
549
|
+
_corePlugins.variantPlugins['printVariant'],
|
|
550
|
+
_corePlugins.variantPlugins['screenVariants'],
|
|
551
|
+
_corePlugins.variantPlugins['orientationVariants'],
|
|
552
|
+
];
|
|
553
|
+
return [
|
|
554
|
+
...corePluginList,
|
|
555
|
+
...beforeVariants,
|
|
556
|
+
...userPlugins,
|
|
557
|
+
...afterVariants,
|
|
558
|
+
...layerPlugins
|
|
559
|
+
];
|
|
502
560
|
}
|
|
503
|
-
|
|
504
561
|
function registerPlugins(plugins, context) {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
562
|
+
let variantList = [];
|
|
563
|
+
let variantMap = new Map();
|
|
564
|
+
let offsets = {
|
|
565
|
+
base: 0n,
|
|
566
|
+
components: 0n,
|
|
567
|
+
utilities: 0n,
|
|
568
|
+
user: 0n
|
|
569
|
+
};
|
|
570
|
+
let classList = new Set();
|
|
571
|
+
let pluginApi = buildPluginApi(context.tailwindConfig, context, {
|
|
572
|
+
variantList,
|
|
573
|
+
variantMap,
|
|
574
|
+
offsets,
|
|
575
|
+
classList
|
|
576
|
+
});
|
|
577
|
+
for (let plugin of plugins){
|
|
578
|
+
if (Array.isArray(plugin)) {
|
|
579
|
+
for (let pluginItem of plugin){
|
|
580
|
+
pluginItem(pluginApi);
|
|
581
|
+
}
|
|
582
|
+
} else {
|
|
583
|
+
plugin === null || plugin === void 0 ? void 0 : plugin(pluginApi);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
let highestOffset = ((args)=>args.reduce((m, e)=>e > m ? e : m
|
|
587
|
+
)
|
|
588
|
+
)([
|
|
589
|
+
offsets.base,
|
|
590
|
+
offsets.components,
|
|
591
|
+
offsets.utilities,
|
|
592
|
+
offsets.user,
|
|
593
|
+
]);
|
|
594
|
+
let reservedBits = BigInt(highestOffset.toString(2).length);
|
|
595
|
+
// A number one less than the top range of the highest offset area
|
|
596
|
+
// so arbitrary properties are always sorted at the end.
|
|
597
|
+
context.arbitraryPropertiesSort = (1n << reservedBits << 0n) - 1n;
|
|
598
|
+
context.layerOrder = {
|
|
599
|
+
base: 1n << reservedBits << 0n,
|
|
600
|
+
components: 1n << reservedBits << 1n,
|
|
601
|
+
utilities: 1n << reservedBits << 2n,
|
|
602
|
+
user: 1n << reservedBits << 3n
|
|
603
|
+
};
|
|
604
|
+
reservedBits += 4n;
|
|
605
|
+
let offset = 0;
|
|
606
|
+
context.variantOrder = new Map(variantList.map((variant, i)=>{
|
|
607
|
+
let variantFunctions = variantMap.get(variant).length;
|
|
608
|
+
let bits = 1n << BigInt(i + offset) << reservedBits;
|
|
609
|
+
offset += variantFunctions - 1;
|
|
610
|
+
return [
|
|
611
|
+
variant,
|
|
612
|
+
bits
|
|
613
|
+
];
|
|
614
|
+
}).sort(([, a], [, z])=>(0, _bigSign).default(a - z)
|
|
615
|
+
));
|
|
616
|
+
context.minimumScreen = [
|
|
617
|
+
...context.variantOrder.values()
|
|
618
|
+
].shift();
|
|
619
|
+
// Build variantMap
|
|
620
|
+
for (let [variantName, variantFunctions1] of variantMap.entries()){
|
|
621
|
+
let sort = context.variantOrder.get(variantName);
|
|
622
|
+
context.variantMap.set(variantName, variantFunctions1.map((variantFunction, idx)=>[
|
|
623
|
+
sort << BigInt(idx),
|
|
624
|
+
variantFunction
|
|
625
|
+
]
|
|
626
|
+
));
|
|
627
|
+
}
|
|
628
|
+
var _safelist;
|
|
629
|
+
let safelist = ((_safelist = context.tailwindConfig.safelist) !== null && _safelist !== void 0 ? _safelist : []).filter(Boolean);
|
|
630
|
+
if (safelist.length > 0) {
|
|
631
|
+
let checks = [];
|
|
632
|
+
for (let value1 of safelist){
|
|
633
|
+
if (typeof value1 === 'string') {
|
|
634
|
+
context.changedContent.push({
|
|
635
|
+
content: value1,
|
|
636
|
+
extension: 'html'
|
|
637
|
+
});
|
|
638
|
+
continue;
|
|
639
|
+
}
|
|
640
|
+
if (value1 instanceof RegExp) {
|
|
641
|
+
_log.default.warn('root-regex', [
|
|
642
|
+
'Regular expressions in `safelist` work differently in Tailwind CSS v3.0.',
|
|
643
|
+
'Update your `safelist` configuration to eliminate this warning.'
|
|
644
|
+
]);
|
|
645
|
+
continue;
|
|
646
|
+
}
|
|
647
|
+
checks.push(value1);
|
|
648
|
+
}
|
|
649
|
+
if (checks.length > 0) {
|
|
650
|
+
let patternMatchingCount = new Map();
|
|
651
|
+
for (let util of classList){
|
|
652
|
+
let utils = Array.isArray(util) ? (()=>{
|
|
653
|
+
let [utilName, options] = util;
|
|
654
|
+
var ref;
|
|
655
|
+
return Object.keys((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {
|
|
656
|
+
}).map((value)=>(0, _nameClass).formatClass(utilName, value)
|
|
657
|
+
);
|
|
658
|
+
})() : [
|
|
659
|
+
util
|
|
660
|
+
];
|
|
661
|
+
for (let util1 of utils){
|
|
662
|
+
for (let { pattern , variants =[] } of checks){
|
|
663
|
+
// RegExp with the /g flag are stateful, so let's reset the last
|
|
664
|
+
// index pointer to reset the state.
|
|
665
|
+
pattern.lastIndex = 0;
|
|
666
|
+
if (!patternMatchingCount.has(pattern)) {
|
|
667
|
+
patternMatchingCount.set(pattern, 0);
|
|
668
|
+
}
|
|
669
|
+
if (!pattern.test(util1)) continue;
|
|
670
|
+
patternMatchingCount.set(pattern, patternMatchingCount.get(pattern) + 1);
|
|
671
|
+
context.changedContent.push({
|
|
672
|
+
content: util1,
|
|
673
|
+
extension: 'html'
|
|
674
|
+
});
|
|
675
|
+
for (let variant of variants){
|
|
676
|
+
context.changedContent.push({
|
|
677
|
+
content: variant + context.tailwindConfig.separator + util1,
|
|
678
|
+
extension: 'html'
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
for (let [regex, count] of patternMatchingCount.entries()){
|
|
685
|
+
if (count !== 0) continue;
|
|
686
|
+
_log.default.warn([
|
|
687
|
+
`The safelist pattern \`${regex}\` doesn't match any Tailwind CSS classes.`,
|
|
688
|
+
'Fix this pattern or remove it from your `safelist` configuration.',
|
|
689
|
+
]);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
526
692
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
context.variantMap.set(variantName, variantFunctions.map((variantFunction, idx) => [sort << BigInt(idx), variantFunction]));
|
|
551
|
-
}
|
|
693
|
+
// Generate a list of strings for autocompletion purposes, e.g.
|
|
694
|
+
// ['uppercase', 'lowercase', ...]
|
|
695
|
+
context.getClassList = function() {
|
|
696
|
+
let output = [];
|
|
697
|
+
for (let util of classList){
|
|
698
|
+
if (Array.isArray(util)) {
|
|
699
|
+
let [utilName, options] = util;
|
|
700
|
+
let negativeClasses = [];
|
|
701
|
+
var ref;
|
|
702
|
+
for (let [key, value] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {
|
|
703
|
+
})){
|
|
704
|
+
output.push((0, _nameClass).formatClass(utilName, key));
|
|
705
|
+
if ((options === null || options === void 0 ? void 0 : options.supportsNegativeValues) && (0, _negateValue).default(value)) {
|
|
706
|
+
negativeClasses.push((0, _nameClass).formatClass(utilName, `-${key}`));
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
output.push(...negativeClasses);
|
|
710
|
+
} else {
|
|
711
|
+
output.push(util);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
return output;
|
|
715
|
+
};
|
|
552
716
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
return context;
|
|
717
|
+
function createContext(tailwindConfig, changedContent = [], root = _postcss.default.root()) {
|
|
718
|
+
let context = {
|
|
719
|
+
disposables: [],
|
|
720
|
+
ruleCache: new Set(),
|
|
721
|
+
classCache: new Map(),
|
|
722
|
+
applyClassCache: new Map(),
|
|
723
|
+
notClassCache: new Set(),
|
|
724
|
+
postCssNodeCache: new Map(),
|
|
725
|
+
candidateRuleMap: new Map(),
|
|
726
|
+
tailwindConfig,
|
|
727
|
+
changedContent: changedContent,
|
|
728
|
+
variantMap: new Map(),
|
|
729
|
+
stylesheetCache: null
|
|
730
|
+
};
|
|
731
|
+
let resolvedPlugins = resolvePlugins(context, root);
|
|
732
|
+
registerPlugins(resolvedPlugins, context);
|
|
733
|
+
return context;
|
|
571
734
|
}
|
|
572
|
-
|
|
573
735
|
let contextMap = sharedState.contextMap;
|
|
574
736
|
let configContextMap = sharedState.configContextMap;
|
|
575
737
|
let contextSourcesMap = sharedState.contextSourcesMap;
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
contextMap.set(sourcePath, context);
|
|
589
|
-
existingContext = context;
|
|
590
|
-
} // If there's already a context in the cache and we don't need to
|
|
591
|
-
// reset the context, return the cached context.
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
if (existingContext) {
|
|
595
|
-
let contextDependenciesChanged = trackModified([...contextDependencies], getFileModifiedMap(existingContext));
|
|
596
|
-
|
|
597
|
-
if (!contextDependenciesChanged) {
|
|
598
|
-
return [existingContext, false];
|
|
738
|
+
function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies) {
|
|
739
|
+
let sourcePath = result.opts.from;
|
|
740
|
+
let isConfigFile = userConfigPath !== null;
|
|
741
|
+
sharedState.env.DEBUG && console.log('Source path:', sourcePath);
|
|
742
|
+
let existingContext;
|
|
743
|
+
if (isConfigFile && contextMap.has(sourcePath)) {
|
|
744
|
+
existingContext = contextMap.get(sourcePath);
|
|
745
|
+
} else if (configContextMap.has(tailwindConfigHash)) {
|
|
746
|
+
let context = configContextMap.get(tailwindConfigHash);
|
|
747
|
+
contextSourcesMap.get(context).add(sourcePath);
|
|
748
|
+
contextMap.set(sourcePath, context);
|
|
749
|
+
existingContext = context;
|
|
599
750
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
contextSourcesMap.get(oldContext).delete(sourcePath);
|
|
612
|
-
|
|
613
|
-
if (contextSourcesMap.get(oldContext).size === 0) {
|
|
614
|
-
contextSourcesMap.delete(oldContext);
|
|
615
|
-
|
|
616
|
-
for (let [tailwindConfigHash, context] of configContextMap) {
|
|
617
|
-
if (context === oldContext) {
|
|
618
|
-
configContextMap.delete(tailwindConfigHash);
|
|
619
|
-
}
|
|
751
|
+
// If there's already a context in the cache and we don't need to
|
|
752
|
+
// reset the context, return the cached context.
|
|
753
|
+
if (existingContext) {
|
|
754
|
+
let contextDependenciesChanged = trackModified([
|
|
755
|
+
...contextDependencies
|
|
756
|
+
], getFileModifiedMap(existingContext));
|
|
757
|
+
if (!contextDependenciesChanged) {
|
|
758
|
+
return [
|
|
759
|
+
existingContext,
|
|
760
|
+
false
|
|
761
|
+
];
|
|
620
762
|
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
763
|
+
}
|
|
764
|
+
// If this source is in the context map, get the old context.
|
|
765
|
+
// Remove this source from the context sources for the old context,
|
|
766
|
+
// and clean up that context if no one else is using it. This can be
|
|
767
|
+
// called by many processes in rapid succession, so we check for presence
|
|
768
|
+
// first because the first process to run this code will wipe it out first.
|
|
769
|
+
if (contextMap.has(sourcePath)) {
|
|
770
|
+
let oldContext = contextMap.get(sourcePath);
|
|
771
|
+
if (contextSourcesMap.has(oldContext)) {
|
|
772
|
+
contextSourcesMap.get(oldContext).delete(sourcePath);
|
|
773
|
+
if (contextSourcesMap.get(oldContext).size === 0) {
|
|
774
|
+
contextSourcesMap.delete(oldContext);
|
|
775
|
+
for (let [tailwindConfigHash, context] of configContextMap){
|
|
776
|
+
if (context === oldContext) {
|
|
777
|
+
configContextMap.delete(tailwindConfigHash);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
for (let disposable of oldContext.disposables.splice(0)){
|
|
781
|
+
disposable(oldContext);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
624
784
|
}
|
|
625
|
-
}
|
|
626
785
|
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
786
|
+
sharedState.env.DEBUG && console.log('Setting up new context...');
|
|
787
|
+
let context = createContext(tailwindConfig, [], root);
|
|
788
|
+
trackModified([
|
|
789
|
+
...contextDependencies
|
|
790
|
+
], getFileModifiedMap(context));
|
|
791
|
+
// ---
|
|
792
|
+
// Update all context tracking state
|
|
793
|
+
configContextMap.set(tailwindConfigHash, context);
|
|
794
|
+
contextMap.set(sourcePath, context);
|
|
795
|
+
if (!contextSourcesMap.has(context)) {
|
|
796
|
+
contextSourcesMap.set(context, new Set());
|
|
797
|
+
}
|
|
798
|
+
contextSourcesMap.get(context).add(sourcePath);
|
|
799
|
+
return [
|
|
800
|
+
context,
|
|
801
|
+
true
|
|
802
|
+
];
|
|
803
|
+
}
|