tailwindcss 0.0.0-insiders.ea80db2 → 0.0.0-insiders.eae2b7a
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 +13 -9
- package/defaultTheme.d.ts +2 -1
- package/index.css +5 -0
- package/lib/cli/build/index.js +57 -0
- package/lib/cli/build/plugin.js +427 -0
- package/lib/cli/build/utils.js +88 -0
- package/lib/cli/build/watching.js +182 -0
- package/lib/cli/help/index.js +73 -0
- package/lib/cli/index.js +231 -0
- package/lib/cli/init/index.js +63 -0
- package/lib/cli.js +1 -759
- package/lib/corePluginList.js +12 -3
- package/lib/corePlugins.js +2308 -1739
- package/lib/css/preflight.css +13 -5
- package/lib/featureFlags.js +50 -25
- package/lib/index.js +1 -40
- package/lib/lib/cacheInvalidation.js +48 -25
- package/lib/lib/collapseAdjacentRules.js +17 -10
- package/lib/lib/collapseDuplicateDeclarations.js +13 -8
- package/lib/lib/content.js +207 -0
- package/lib/lib/defaultExtractor.js +232 -33
- package/lib/lib/detectNesting.js +21 -10
- package/lib/lib/evaluateTailwindFunctions.js +117 -50
- package/lib/lib/expandApplyAtRules.js +316 -215
- package/lib/lib/expandTailwindAtRules.js +167 -115
- package/lib/lib/findAtConfigPath.js +46 -0
- package/lib/lib/generateRules.js +444 -211
- package/lib/lib/getModuleDependencies.js +88 -37
- package/lib/lib/handleImportAtRules.js +50 -0
- package/lib/lib/load-config.js +42 -0
- package/lib/lib/normalizeTailwindDirectives.js +29 -39
- package/lib/lib/offsets.js +306 -0
- package/lib/lib/partitionApplyAtRules.js +13 -8
- package/lib/lib/regex.js +74 -0
- package/lib/lib/remap-bitfield.js +89 -0
- package/lib/lib/resolveDefaultsAtRules.js +96 -74
- package/lib/lib/setupContextUtils.js +672 -300
- package/lib/lib/setupTrackingContext.js +63 -68
- package/lib/lib/sharedState.js +44 -17
- package/lib/lib/substituteScreenAtRules.js +14 -10
- package/lib/plugin.js +160 -0
- package/lib/postcss-plugins/nesting/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +10 -6
- package/lib/postcss-plugins/nesting/plugin.js +24 -20
- package/lib/processTailwindFeatures.js +34 -29
- package/lib/public/colors.js +272 -246
- package/lib/public/create-plugin.js +9 -5
- package/lib/public/default-config.js +10 -6
- package/lib/public/default-theme.js +10 -6
- package/lib/public/load-config.js +12 -0
- package/lib/public/resolve-config.js +11 -6
- package/lib/util/applyImportantSelector.js +36 -0
- package/lib/util/bigSign.js +6 -1
- package/lib/util/buildMediaQuery.js +13 -6
- package/lib/util/cloneDeep.js +9 -6
- package/lib/util/cloneNodes.js +12 -3
- package/lib/util/color.js +66 -50
- package/lib/util/colorNames.js +752 -0
- package/lib/util/configurePlugins.js +7 -2
- package/lib/util/createPlugin.js +8 -5
- package/lib/util/createUtilityPlugin.js +13 -9
- package/lib/util/dataTypes.js +182 -111
- package/lib/util/defaults.js +12 -7
- package/lib/util/escapeClassName.js +13 -8
- package/lib/util/escapeCommas.js +7 -2
- package/lib/util/flattenColorPalette.js +11 -10
- package/lib/util/formatVariantSelector.js +228 -151
- package/lib/util/getAllConfigs.js +33 -12
- package/lib/util/hashConfig.js +9 -4
- package/lib/util/isKeyframeRule.js +7 -2
- package/lib/util/isPlainObject.js +7 -2
- package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +25 -15
- package/lib/util/log.js +40 -13
- package/lib/util/nameClass.js +27 -10
- package/lib/util/negateValue.js +25 -8
- package/lib/util/normalizeConfig.js +155 -87
- package/lib/util/normalizeScreens.js +127 -8
- package/lib/util/parseAnimationValue.js +44 -40
- package/lib/util/parseBoxShadowValue.js +33 -62
- package/lib/util/parseDependency.js +39 -55
- package/lib/util/parseGlob.js +36 -0
- package/lib/util/parseObjectStyles.js +15 -10
- package/lib/util/pluginUtils.js +154 -59
- package/lib/util/prefixSelector.js +29 -10
- package/lib/util/pseudoElements.js +209 -0
- package/lib/util/removeAlphaVariables.js +31 -0
- package/lib/util/resolveConfig.js +96 -95
- package/lib/util/resolveConfigPath.js +29 -10
- package/lib/util/responsive.js +11 -6
- package/lib/util/splitAtTopLevelOnly.js +51 -0
- package/lib/util/tap.js +6 -1
- package/lib/util/toColorValue.js +7 -2
- package/lib/util/toPath.js +22 -4
- package/lib/util/transformThemeValue.js +40 -26
- package/lib/util/validateConfig.js +48 -0
- package/lib/util/validateFormalSyntax.js +26 -0
- package/lib/util/withAlphaVariable.js +27 -15
- 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 +54 -52
- package/plugin.d.ts +10 -5
- package/resolveConfig.d.ts +12 -0
- package/scripts/generate-types.js +53 -0
- package/scripts/release-channel.js +18 -0
- package/scripts/release-notes.js +21 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli/build/index.js +53 -0
- package/src/cli/build/plugin.js +465 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +229 -0
- package/src/cli/help/index.js +70 -0
- package/src/cli/index.js +217 -0
- package/src/cli/init/index.js +79 -0
- package/src/cli.js +1 -836
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +576 -106
- package/src/css/preflight.css +13 -5
- package/src/featureFlags.js +17 -3
- package/src/index.js +1 -42
- package/src/lib/collapseAdjacentRules.js +5 -1
- package/src/lib/content.js +240 -0
- package/src/lib/defaultExtractor.js +202 -35
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/evaluateTailwindFunctions.js +82 -8
- package/src/lib/expandApplyAtRules.js +322 -189
- package/src/lib/expandTailwindAtRules.js +82 -59
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +413 -132
- 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 +373 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/remap-bitfield.js +82 -0
- package/src/lib/resolveDefaultsAtRules.js +53 -36
- package/src/lib/setupContextUtils.js +570 -151
- package/src/lib/setupTrackingContext.js +44 -58
- package/src/lib/sharedState.js +13 -4
- package/src/plugin.js +128 -0
- package/src/postcss-plugins/nesting/README.md +2 -2
- 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/buildMediaQuery.js +5 -3
- package/src/util/cloneNodes.js +5 -1
- package/src/util/color.js +34 -17
- package/src/util/colorNames.js +150 -0
- package/src/util/dataTypes.js +67 -23
- package/src/util/formatVariantSelector.js +264 -144
- package/src/util/getAllConfigs.js +21 -2
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/log.js +25 -1
- package/src/util/nameClass.js +4 -0
- package/src/util/negateValue.js +11 -3
- package/src/util/normalizeConfig.js +78 -20
- package/src/util/normalizeScreens.js +99 -4
- package/src/util/parseBoxShadowValue.js +3 -50
- package/src/util/parseDependency.js +37 -42
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +118 -23
- package/src/util/prefixSelector.js +28 -10
- package/src/util/pseudoElements.js +167 -0
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +70 -62
- package/src/util/resolveConfigPath.js +12 -1
- package/src/util/splitAtTopLevelOnly.js +52 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +13 -3
- package/src/util/validateConfig.js +36 -0
- package/src/util/validateFormalSyntax.js +34 -0
- package/src/util/withAlphaVariable.js +1 -1
- 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} +215 -165
- package/stubs/{simpleConfig.stub.js → config.simple.js} +1 -1
- 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 +102 -56
- package/types/generated/colors.d.ts +22 -0
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +372 -0
- package/types/index.d.ts +7 -1
- package/CHANGELOG.md +0 -2099
- package/lib/cli-peer-dependencies.js +0 -15
- package/lib/constants.js +0 -37
- package/peers/index.js +0 -75156
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/cli-peer-dependencies.js +0 -9
- package/src/constants.js +0 -17
- package/types.d.ts +0 -1
|
@@ -2,83 +2,161 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
isValidVariantFormatString: function() {
|
|
13
|
+
return isValidVariantFormatString;
|
|
14
|
+
},
|
|
15
|
+
parseVariant: function() {
|
|
16
|
+
return parseVariant;
|
|
17
|
+
},
|
|
18
|
+
getFileModifiedMap: function() {
|
|
19
|
+
return getFileModifiedMap;
|
|
20
|
+
},
|
|
21
|
+
createContext: function() {
|
|
22
|
+
return createContext;
|
|
23
|
+
},
|
|
24
|
+
getContext: function() {
|
|
25
|
+
return getContext;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
29
|
+
const _url = /*#__PURE__*/ _interop_require_default(require("url"));
|
|
30
|
+
const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
|
|
31
|
+
const _dlv = /*#__PURE__*/ _interop_require_default(require("dlv"));
|
|
32
|
+
const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser"));
|
|
33
|
+
const _transformThemeValue = /*#__PURE__*/ _interop_require_default(require("../util/transformThemeValue"));
|
|
34
|
+
const _parseObjectStyles = /*#__PURE__*/ _interop_require_default(require("../util/parseObjectStyles"));
|
|
35
|
+
const _prefixSelector = /*#__PURE__*/ _interop_require_default(require("../util/prefixSelector"));
|
|
36
|
+
const _isPlainObject = /*#__PURE__*/ _interop_require_default(require("../util/isPlainObject"));
|
|
37
|
+
const _escapeClassName = /*#__PURE__*/ _interop_require_default(require("../util/escapeClassName"));
|
|
38
|
+
const _nameClass = /*#__PURE__*/ _interop_require_wildcard(require("../util/nameClass"));
|
|
39
|
+
const _pluginUtils = require("../util/pluginUtils");
|
|
40
|
+
const _corePlugins = require("../corePlugins");
|
|
41
|
+
const _sharedState = /*#__PURE__*/ _interop_require_wildcard(require("./sharedState"));
|
|
42
|
+
const _toPath = require("../util/toPath");
|
|
43
|
+
const _log = /*#__PURE__*/ _interop_require_default(require("../util/log"));
|
|
44
|
+
const _negateValue = /*#__PURE__*/ _interop_require_default(require("../util/negateValue"));
|
|
45
|
+
const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interop_require_default(require("../util/isSyntacticallyValidPropertyValue"));
|
|
46
|
+
const _generateRules = require("./generateRules");
|
|
47
|
+
const _cacheInvalidation = require("./cacheInvalidation.js");
|
|
48
|
+
const _offsets = require("./offsets.js");
|
|
49
|
+
const _formatVariantSelector = require("../util/formatVariantSelector");
|
|
50
|
+
function _interop_require_default(obj) {
|
|
30
51
|
return obj && obj.__esModule ? obj : {
|
|
31
52
|
default: obj
|
|
32
53
|
};
|
|
33
54
|
}
|
|
34
|
-
function
|
|
35
|
-
if (
|
|
55
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
56
|
+
if (typeof WeakMap !== "function") return null;
|
|
57
|
+
var cacheBabelInterop = new WeakMap();
|
|
58
|
+
var cacheNodeInterop = new WeakMap();
|
|
59
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
60
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
61
|
+
})(nodeInterop);
|
|
62
|
+
}
|
|
63
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
64
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
36
65
|
return obj;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
66
|
+
}
|
|
67
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
68
|
+
return {
|
|
69
|
+
default: obj
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
73
|
+
if (cache && cache.has(obj)) {
|
|
74
|
+
return cache.get(obj);
|
|
75
|
+
}
|
|
76
|
+
var newObj = {};
|
|
77
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
78
|
+
for(var key in obj){
|
|
79
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
80
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
81
|
+
if (desc && (desc.get || desc.set)) {
|
|
82
|
+
Object.defineProperty(newObj, key, desc);
|
|
83
|
+
} else {
|
|
84
|
+
newObj[key] = obj[key];
|
|
49
85
|
}
|
|
50
86
|
}
|
|
51
|
-
newObj.default = obj;
|
|
52
|
-
return newObj;
|
|
53
87
|
}
|
|
88
|
+
newObj.default = obj;
|
|
89
|
+
if (cache) {
|
|
90
|
+
cache.set(obj, newObj);
|
|
91
|
+
}
|
|
92
|
+
return newObj;
|
|
54
93
|
}
|
|
94
|
+
const VARIANT_TYPES = {
|
|
95
|
+
AddVariant: Symbol.for("ADD_VARIANT"),
|
|
96
|
+
MatchVariant: Symbol.for("MATCH_VARIANT")
|
|
97
|
+
};
|
|
98
|
+
const VARIANT_INFO = {
|
|
99
|
+
Base: 1 << 0,
|
|
100
|
+
Dynamic: 1 << 1
|
|
101
|
+
};
|
|
55
102
|
function prefix(context, selector) {
|
|
56
|
-
let
|
|
57
|
-
return typeof
|
|
103
|
+
let prefix = context.tailwindConfig.prefix;
|
|
104
|
+
return typeof prefix === "function" ? prefix(selector) : prefix + selector;
|
|
58
105
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
106
|
+
function normalizeOptionTypes({ type ="any" , ...options }) {
|
|
107
|
+
let types = [].concat(type);
|
|
108
|
+
return {
|
|
109
|
+
...options,
|
|
110
|
+
types: types.map((type)=>{
|
|
111
|
+
if (Array.isArray(type)) {
|
|
112
|
+
return {
|
|
113
|
+
type: type[0],
|
|
114
|
+
...type[1]
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
type,
|
|
119
|
+
preferOnConflict: false
|
|
120
|
+
};
|
|
121
|
+
})
|
|
122
|
+
};
|
|
68
123
|
}
|
|
69
|
-
function
|
|
70
|
-
let
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
124
|
+
function parseVariantFormatString(input) {
|
|
125
|
+
/** @type {string[]} */ let parts = [];
|
|
126
|
+
// When parsing whitespace around special characters are insignificant
|
|
127
|
+
// However, _inside_ of a variant they could be
|
|
128
|
+
// Because the selector could look like this
|
|
129
|
+
// @media { &[data-name="foo bar"] }
|
|
130
|
+
// This is why we do not skip whitespace
|
|
131
|
+
let current = "";
|
|
132
|
+
let depth = 0;
|
|
133
|
+
for(let idx = 0; idx < input.length; idx++){
|
|
134
|
+
let char = input[idx];
|
|
135
|
+
if (char === "\\") {
|
|
136
|
+
// Escaped characters are not special
|
|
137
|
+
current += "\\" + input[++idx];
|
|
138
|
+
} else if (char === "{") {
|
|
139
|
+
// Nested rule: start
|
|
140
|
+
++depth;
|
|
141
|
+
parts.push(current.trim());
|
|
142
|
+
current = "";
|
|
143
|
+
} else if (char === "}") {
|
|
144
|
+
// Nested rule: end
|
|
145
|
+
if (--depth < 0) {
|
|
146
|
+
throw new Error(`Your { and } are unbalanced.`);
|
|
78
147
|
}
|
|
148
|
+
parts.push(current.trim());
|
|
149
|
+
current = "";
|
|
150
|
+
} else {
|
|
151
|
+
// Normal character
|
|
152
|
+
current += char;
|
|
79
153
|
}
|
|
80
154
|
}
|
|
81
|
-
|
|
155
|
+
if (current.length > 0) {
|
|
156
|
+
parts.push(current.trim());
|
|
157
|
+
}
|
|
158
|
+
parts = parts.filter((part)=>part !== "");
|
|
159
|
+
return parts;
|
|
82
160
|
}
|
|
83
161
|
function insertInto(list, value, { before =[] } = {}) {
|
|
84
162
|
before = [].concat(before);
|
|
@@ -101,12 +179,12 @@ function parseStyles(styles) {
|
|
|
101
179
|
]);
|
|
102
180
|
}
|
|
103
181
|
return styles.flatMap((style)=>{
|
|
104
|
-
let isNode = !Array.isArray(style) && !(0, _isPlainObject
|
|
105
|
-
return isNode ? style : (0, _parseObjectStyles
|
|
182
|
+
let isNode = !Array.isArray(style) && !(0, _isPlainObject.default)(style);
|
|
183
|
+
return isNode ? style : (0, _parseObjectStyles.default)(style);
|
|
106
184
|
});
|
|
107
185
|
}
|
|
108
186
|
function getClasses(selector, mutate) {
|
|
109
|
-
let parser = (0,
|
|
187
|
+
let parser = (0, _postcssselectorparser.default)((selectors)=>{
|
|
110
188
|
let allClasses = [];
|
|
111
189
|
if (mutate) {
|
|
112
190
|
mutate(selectors);
|
|
@@ -123,14 +201,14 @@ function extractCandidates(node, state = {
|
|
|
123
201
|
}, depth = 0) {
|
|
124
202
|
let classes = [];
|
|
125
203
|
// Handle normal rules
|
|
126
|
-
if (node.type ===
|
|
204
|
+
if (node.type === "rule") {
|
|
127
205
|
// Ignore everything inside a :not(...). This allows you to write code like
|
|
128
206
|
// `div:not(.foo)`. If `.foo` is never found in your code, then we used to
|
|
129
207
|
// not generated it. But now we will ignore everything inside a `:not`, so
|
|
130
208
|
// that it still gets generated.
|
|
131
209
|
function ignoreNot(selectors) {
|
|
132
210
|
selectors.walkPseudos((pseudo)=>{
|
|
133
|
-
if (pseudo.value ===
|
|
211
|
+
if (pseudo.value === ":not") {
|
|
134
212
|
pseudo.remove();
|
|
135
213
|
}
|
|
136
214
|
});
|
|
@@ -145,10 +223,9 @@ function extractCandidates(node, state = {
|
|
|
145
223
|
classes.push(classCandidate);
|
|
146
224
|
}
|
|
147
225
|
}
|
|
148
|
-
} else if (node.type ===
|
|
226
|
+
} else if (node.type === "atrule") {
|
|
149
227
|
node.walkRules((rule)=>{
|
|
150
|
-
for (let classCandidate of rule.selectors.flatMap((selector)=>getClasses(selector)
|
|
151
|
-
)){
|
|
228
|
+
for (let classCandidate of rule.selectors.flatMap((selector)=>getClasses(selector))){
|
|
152
229
|
classes.push(classCandidate);
|
|
153
230
|
}
|
|
154
231
|
});
|
|
@@ -167,7 +244,7 @@ function withIdentifiers(styles) {
|
|
|
167
244
|
let [containsNonOnDemandableSelectors, candidates] = extractCandidates(node);
|
|
168
245
|
// If this isn't "on-demandable", assign it a universal candidate to always include it.
|
|
169
246
|
if (containsNonOnDemandableSelectors) {
|
|
170
|
-
candidates.unshift(
|
|
247
|
+
candidates.unshift(_sharedState.NOT_ON_DEMAND);
|
|
171
248
|
}
|
|
172
249
|
// However, it could be that it also contains "on-demandable" candidates.
|
|
173
250
|
// E.g.: `span, .foo {}`, in that case it should still be possible to use
|
|
@@ -183,76 +260,70 @@ function withIdentifiers(styles) {
|
|
|
183
260
|
});
|
|
184
261
|
});
|
|
185
262
|
}
|
|
186
|
-
function
|
|
263
|
+
function isValidVariantFormatString(format) {
|
|
264
|
+
return format.startsWith("@") || format.includes("&");
|
|
265
|
+
}
|
|
266
|
+
function parseVariant(variant) {
|
|
267
|
+
variant = variant.replace(/\n+/g, "").replace(/\s{1,}/g, " ").trim();
|
|
268
|
+
let fns = parseVariantFormatString(variant).map((str)=>{
|
|
269
|
+
if (!str.startsWith("@")) {
|
|
270
|
+
return ({ format })=>format(str);
|
|
271
|
+
}
|
|
272
|
+
let [, name, params] = /@(.*?)( .+|[({].*)/g.exec(str);
|
|
273
|
+
return ({ wrap })=>wrap(_postcss.default.atRule({
|
|
274
|
+
name,
|
|
275
|
+
params: params.trim()
|
|
276
|
+
}));
|
|
277
|
+
}).reverse();
|
|
278
|
+
return (api)=>{
|
|
279
|
+
for (let fn of fns){
|
|
280
|
+
fn(api);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
*
|
|
286
|
+
* @param {any} tailwindConfig
|
|
287
|
+
* @param {any} context
|
|
288
|
+
* @param {object} param2
|
|
289
|
+
* @param {Offsets} param2.offsets
|
|
290
|
+
*/ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , offsets , classList }) {
|
|
187
291
|
function getConfigValue(path, defaultValue) {
|
|
188
|
-
return path ? (0, _dlv
|
|
292
|
+
return path ? (0, _dlv.default)(tailwindConfig, path, defaultValue) : tailwindConfig;
|
|
189
293
|
}
|
|
190
294
|
function applyConfiguredPrefix(selector) {
|
|
191
|
-
return (0, _prefixSelector
|
|
295
|
+
return (0, _prefixSelector.default)(tailwindConfig.prefix, selector);
|
|
192
296
|
}
|
|
193
297
|
function prefixIdentifier(identifier, options) {
|
|
194
|
-
if (identifier ===
|
|
195
|
-
return
|
|
298
|
+
if (identifier === _sharedState.NOT_ON_DEMAND) {
|
|
299
|
+
return _sharedState.NOT_ON_DEMAND;
|
|
196
300
|
}
|
|
197
301
|
if (!options.respectPrefix) {
|
|
198
302
|
return identifier;
|
|
199
303
|
}
|
|
200
304
|
return context.tailwindConfig.prefix + identifier;
|
|
201
305
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
});
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
variantFunction = variantFunction.replace(/\n+/g, '').replace(/\s{1,}/g, ' ').trim();
|
|
216
|
-
let fns = parseVariantFormatString(variantFunction).map((str)=>{
|
|
217
|
-
if (!str.startsWith('@')) {
|
|
218
|
-
return ({ format })=>format(str)
|
|
219
|
-
;
|
|
220
|
-
}
|
|
221
|
-
let [, name, params] = /@(.*?) (.*)/g.exec(str);
|
|
222
|
-
return ({ wrap })=>wrap(_postcss.default.atRule({
|
|
223
|
-
name,
|
|
224
|
-
params
|
|
225
|
-
}))
|
|
226
|
-
;
|
|
227
|
-
}).reverse();
|
|
228
|
-
return (api)=>{
|
|
229
|
-
for (let fn of fns){
|
|
230
|
-
fn(api);
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
});
|
|
234
|
-
insertInto(variantList, variantName, options);
|
|
235
|
-
variantMap.set(variantName, variantFunctions);
|
|
236
|
-
},
|
|
306
|
+
function resolveThemeValue(path, defaultValue, opts = {}) {
|
|
307
|
+
let parts = (0, _toPath.toPath)(path);
|
|
308
|
+
let value = getConfigValue([
|
|
309
|
+
"theme",
|
|
310
|
+
...parts
|
|
311
|
+
], defaultValue);
|
|
312
|
+
return (0, _transformThemeValue.default)(parts[0])(value, opts);
|
|
313
|
+
}
|
|
314
|
+
let variantIdentifier = 0;
|
|
315
|
+
let api = {
|
|
237
316
|
postcss: _postcss.default,
|
|
238
317
|
prefix: applyConfiguredPrefix,
|
|
239
318
|
e: _escapeClassName.default,
|
|
240
319
|
config: getConfigValue,
|
|
241
|
-
theme
|
|
242
|
-
const [pathRoot, ...subPaths] = (0, _toPath).toPath(path);
|
|
243
|
-
const value = getConfigValue([
|
|
244
|
-
'theme',
|
|
245
|
-
pathRoot,
|
|
246
|
-
...subPaths
|
|
247
|
-
], defaultValue);
|
|
248
|
-
return (0, _transformThemeValue).default(pathRoot)(value);
|
|
249
|
-
},
|
|
320
|
+
theme: resolveThemeValue,
|
|
250
321
|
corePlugins: (path)=>{
|
|
251
322
|
if (Array.isArray(tailwindConfig.corePlugins)) {
|
|
252
323
|
return tailwindConfig.corePlugins.includes(path);
|
|
253
324
|
}
|
|
254
325
|
return getConfigValue([
|
|
255
|
-
|
|
326
|
+
"corePlugins",
|
|
256
327
|
path
|
|
257
328
|
], true);
|
|
258
329
|
},
|
|
@@ -263,14 +334,14 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
263
334
|
addBase (base) {
|
|
264
335
|
for (let [identifier, rule] of withIdentifiers(base)){
|
|
265
336
|
let prefixedIdentifier = prefixIdentifier(identifier, {});
|
|
266
|
-
let offset = offsets.base
|
|
337
|
+
let offset = offsets.create("base");
|
|
267
338
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
268
339
|
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
269
340
|
}
|
|
270
341
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
271
342
|
{
|
|
272
343
|
sort: offset,
|
|
273
|
-
layer:
|
|
344
|
+
layer: "base"
|
|
274
345
|
},
|
|
275
346
|
rule
|
|
276
347
|
]);
|
|
@@ -290,8 +361,8 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
290
361
|
}
|
|
291
362
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
292
363
|
{
|
|
293
|
-
sort: offsets.
|
|
294
|
-
layer:
|
|
364
|
+
sort: offsets.create("defaults"),
|
|
365
|
+
layer: "defaults"
|
|
295
366
|
},
|
|
296
367
|
rule
|
|
297
368
|
]);
|
|
@@ -299,6 +370,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
299
370
|
},
|
|
300
371
|
addComponents (components, options) {
|
|
301
372
|
let defaultOptions = {
|
|
373
|
+
preserveSource: false,
|
|
302
374
|
respectPrefix: true,
|
|
303
375
|
respectImportant: false
|
|
304
376
|
};
|
|
@@ -311,8 +383,8 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
311
383
|
}
|
|
312
384
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
313
385
|
{
|
|
314
|
-
sort: offsets.components
|
|
315
|
-
layer:
|
|
386
|
+
sort: offsets.create("components"),
|
|
387
|
+
layer: "components",
|
|
316
388
|
options
|
|
317
389
|
},
|
|
318
390
|
rule
|
|
@@ -321,6 +393,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
321
393
|
},
|
|
322
394
|
addUtilities (utilities, options) {
|
|
323
395
|
let defaultOptions = {
|
|
396
|
+
preserveSource: false,
|
|
324
397
|
respectPrefix: true,
|
|
325
398
|
respectImportant: true
|
|
326
399
|
};
|
|
@@ -333,8 +406,8 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
333
406
|
}
|
|
334
407
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
335
408
|
{
|
|
336
|
-
sort: offsets.utilities
|
|
337
|
-
layer:
|
|
409
|
+
sort: offsets.create("utilities"),
|
|
410
|
+
layer: "utilities",
|
|
338
411
|
options
|
|
339
412
|
},
|
|
340
413
|
rule
|
|
@@ -344,13 +417,14 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
344
417
|
matchUtilities: function(utilities, options) {
|
|
345
418
|
let defaultOptions = {
|
|
346
419
|
respectPrefix: true,
|
|
347
|
-
respectImportant: true
|
|
420
|
+
respectImportant: true,
|
|
421
|
+
modifiers: false
|
|
348
422
|
};
|
|
349
|
-
options = {
|
|
423
|
+
options = normalizeOptionTypes({
|
|
350
424
|
...defaultOptions,
|
|
351
425
|
...options
|
|
352
|
-
};
|
|
353
|
-
let offset = offsets.utilities
|
|
426
|
+
});
|
|
427
|
+
let offset = offsets.create("utilities");
|
|
354
428
|
for(let identifier in utilities){
|
|
355
429
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
356
430
|
let rule = utilities[identifier];
|
|
@@ -359,28 +433,42 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
359
433
|
options
|
|
360
434
|
]);
|
|
361
435
|
function wrapped(modifier, { isOnlyPlugin }) {
|
|
362
|
-
let
|
|
363
|
-
type = [].concat(type);
|
|
364
|
-
let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options, tailwindConfig);
|
|
436
|
+
let [value, coercedType, utilityModifier] = (0, _pluginUtils.coerceValue)(options.types, modifier, options, tailwindConfig);
|
|
365
437
|
if (value === undefined) {
|
|
366
438
|
return [];
|
|
367
439
|
}
|
|
368
|
-
if (!
|
|
369
|
-
|
|
440
|
+
if (!options.types.some(({ type })=>type === coercedType)) {
|
|
441
|
+
if (isOnlyPlugin) {
|
|
442
|
+
_log.default.warn([
|
|
443
|
+
`Unnecessary typehint \`${coercedType}\` in \`${identifier}-${modifier}\`.`,
|
|
444
|
+
`You can safely update it to \`${identifier}-${modifier.replace(coercedType + ":", "")}\`.`
|
|
445
|
+
]);
|
|
446
|
+
} else {
|
|
447
|
+
return [];
|
|
448
|
+
}
|
|
370
449
|
}
|
|
371
|
-
if (!(0,
|
|
450
|
+
if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
|
|
372
451
|
return [];
|
|
373
452
|
}
|
|
374
|
-
let
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
453
|
+
let extras = {
|
|
454
|
+
get modifier () {
|
|
455
|
+
if (!options.modifiers) {
|
|
456
|
+
_log.default.warn(`modifier-used-without-options-for-${identifier}`, [
|
|
457
|
+
"Your plugin must set `modifiers: true` in its options to support modifiers."
|
|
458
|
+
]);
|
|
459
|
+
}
|
|
460
|
+
return utilityModifier;
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
let ruleSets = [].concat(rule(value, extras)).filter(Boolean).map((declaration)=>({
|
|
464
|
+
[(0, _nameClass.default)(identifier, modifier)]: declaration
|
|
465
|
+
}));
|
|
378
466
|
return ruleSets;
|
|
379
467
|
}
|
|
380
468
|
let withOffsets = [
|
|
381
469
|
{
|
|
382
470
|
sort: offset,
|
|
383
|
-
layer:
|
|
471
|
+
layer: "utilities",
|
|
384
472
|
options
|
|
385
473
|
},
|
|
386
474
|
wrapped
|
|
@@ -394,13 +482,14 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
394
482
|
matchComponents: function(components, options) {
|
|
395
483
|
let defaultOptions = {
|
|
396
484
|
respectPrefix: true,
|
|
397
|
-
respectImportant: false
|
|
485
|
+
respectImportant: false,
|
|
486
|
+
modifiers: false
|
|
398
487
|
};
|
|
399
|
-
options = {
|
|
488
|
+
options = normalizeOptionTypes({
|
|
400
489
|
...defaultOptions,
|
|
401
490
|
...options
|
|
402
|
-
};
|
|
403
|
-
let offset = offsets.components
|
|
491
|
+
});
|
|
492
|
+
let offset = offsets.create("components");
|
|
404
493
|
for(let identifier in components){
|
|
405
494
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
406
495
|
let rule = components[identifier];
|
|
@@ -409,35 +498,42 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
409
498
|
options
|
|
410
499
|
]);
|
|
411
500
|
function wrapped(modifier, { isOnlyPlugin }) {
|
|
412
|
-
let
|
|
413
|
-
type = [].concat(type);
|
|
414
|
-
let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options, tailwindConfig);
|
|
501
|
+
let [value, coercedType, utilityModifier] = (0, _pluginUtils.coerceValue)(options.types, modifier, options, tailwindConfig);
|
|
415
502
|
if (value === undefined) {
|
|
416
503
|
return [];
|
|
417
504
|
}
|
|
418
|
-
if (!
|
|
505
|
+
if (!options.types.some(({ type })=>type === coercedType)) {
|
|
419
506
|
if (isOnlyPlugin) {
|
|
420
507
|
_log.default.warn([
|
|
421
508
|
`Unnecessary typehint \`${coercedType}\` in \`${identifier}-${modifier}\`.`,
|
|
422
|
-
`You can safely update it to \`${identifier}-${modifier.replace(coercedType +
|
|
509
|
+
`You can safely update it to \`${identifier}-${modifier.replace(coercedType + ":", "")}\`.`
|
|
423
510
|
]);
|
|
424
511
|
} else {
|
|
425
512
|
return [];
|
|
426
513
|
}
|
|
427
514
|
}
|
|
428
|
-
if (!(0,
|
|
515
|
+
if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
|
|
429
516
|
return [];
|
|
430
517
|
}
|
|
431
|
-
let
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
518
|
+
let extras = {
|
|
519
|
+
get modifier () {
|
|
520
|
+
if (!options.modifiers) {
|
|
521
|
+
_log.default.warn(`modifier-used-without-options-for-${identifier}`, [
|
|
522
|
+
"Your plugin must set `modifiers: true` in its options to support modifiers."
|
|
523
|
+
]);
|
|
524
|
+
}
|
|
525
|
+
return utilityModifier;
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
let ruleSets = [].concat(rule(value, extras)).filter(Boolean).map((declaration)=>({
|
|
529
|
+
[(0, _nameClass.default)(identifier, modifier)]: declaration
|
|
530
|
+
}));
|
|
435
531
|
return ruleSets;
|
|
436
532
|
}
|
|
437
533
|
let withOffsets = [
|
|
438
534
|
{
|
|
439
535
|
sort: offset,
|
|
440
|
-
layer:
|
|
536
|
+
layer: "components",
|
|
441
537
|
options
|
|
442
538
|
},
|
|
443
539
|
wrapped
|
|
@@ -447,8 +543,85 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
447
543
|
}
|
|
448
544
|
context.candidateRuleMap.get(prefixedIdentifier).push(withOffsets);
|
|
449
545
|
}
|
|
546
|
+
},
|
|
547
|
+
addVariant (variantName, variantFunctions, options = {}) {
|
|
548
|
+
variantFunctions = [].concat(variantFunctions).map((variantFunction)=>{
|
|
549
|
+
if (typeof variantFunction !== "string") {
|
|
550
|
+
// Safelist public API functions
|
|
551
|
+
return (api = {})=>{
|
|
552
|
+
let { args , modifySelectors , container , separator , wrap , format } = api;
|
|
553
|
+
let result = variantFunction(Object.assign({
|
|
554
|
+
modifySelectors,
|
|
555
|
+
container,
|
|
556
|
+
separator
|
|
557
|
+
}, options.type === VARIANT_TYPES.MatchVariant && {
|
|
558
|
+
args,
|
|
559
|
+
wrap,
|
|
560
|
+
format
|
|
561
|
+
}));
|
|
562
|
+
if (typeof result === "string" && !isValidVariantFormatString(result)) {
|
|
563
|
+
throw new Error(`Your custom variant \`${variantName}\` has an invalid format string. Make sure it's an at-rule or contains a \`&\` placeholder.`);
|
|
564
|
+
}
|
|
565
|
+
if (Array.isArray(result)) {
|
|
566
|
+
return result.filter((variant)=>typeof variant === "string").map((variant)=>parseVariant(variant));
|
|
567
|
+
}
|
|
568
|
+
// result may be undefined with legacy variants that use APIs like `modifySelectors`
|
|
569
|
+
// result may also be a postcss node if someone was returning the result from `modifySelectors`
|
|
570
|
+
return result && typeof result === "string" && parseVariant(result)(api);
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
if (!isValidVariantFormatString(variantFunction)) {
|
|
574
|
+
throw new Error(`Your custom variant \`${variantName}\` has an invalid format string. Make sure it's an at-rule or contains a \`&\` placeholder.`);
|
|
575
|
+
}
|
|
576
|
+
return parseVariant(variantFunction);
|
|
577
|
+
});
|
|
578
|
+
insertInto(variantList, variantName, options);
|
|
579
|
+
variantMap.set(variantName, variantFunctions);
|
|
580
|
+
context.variantOptions.set(variantName, options);
|
|
581
|
+
},
|
|
582
|
+
matchVariant (variant, variantFn, options) {
|
|
583
|
+
var _options_id;
|
|
584
|
+
// A unique identifier that "groups" these variants together.
|
|
585
|
+
// This is for internal use only which is why it is not present in the types
|
|
586
|
+
let id = (_options_id = options === null || options === void 0 ? void 0 : options.id) !== null && _options_id !== void 0 ? _options_id : ++variantIdentifier;
|
|
587
|
+
let isSpecial = variant === "@";
|
|
588
|
+
var _options_values;
|
|
589
|
+
for (let [key, value] of Object.entries((_options_values = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values !== void 0 ? _options_values : {})){
|
|
590
|
+
if (key === "DEFAULT") continue;
|
|
591
|
+
api.addVariant(isSpecial ? `${variant}${key}` : `${variant}-${key}`, ({ args , container })=>{
|
|
592
|
+
return variantFn(value, {
|
|
593
|
+
modifier: args === null || args === void 0 ? void 0 : args.modifier,
|
|
594
|
+
container
|
|
595
|
+
});
|
|
596
|
+
}, {
|
|
597
|
+
...options,
|
|
598
|
+
value,
|
|
599
|
+
id,
|
|
600
|
+
type: VARIANT_TYPES.MatchVariant,
|
|
601
|
+
variantInfo: VARIANT_INFO.Base
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
var _options_values1;
|
|
605
|
+
let hasDefault = "DEFAULT" in ((_options_values1 = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values1 !== void 0 ? _options_values1 : {});
|
|
606
|
+
api.addVariant(variant, ({ args , container })=>{
|
|
607
|
+
if ((args === null || args === void 0 ? void 0 : args.value) === _sharedState.NONE && !hasDefault) {
|
|
608
|
+
return null;
|
|
609
|
+
}
|
|
610
|
+
var // (JetBrains) plugins.
|
|
611
|
+
_args_value;
|
|
612
|
+
return variantFn((args === null || args === void 0 ? void 0 : args.value) === _sharedState.NONE ? options.values.DEFAULT : (_args_value = args === null || args === void 0 ? void 0 : args.value) !== null && _args_value !== void 0 ? _args_value : typeof args === "string" ? args : "", {
|
|
613
|
+
modifier: args === null || args === void 0 ? void 0 : args.modifier,
|
|
614
|
+
container
|
|
615
|
+
});
|
|
616
|
+
}, {
|
|
617
|
+
...options,
|
|
618
|
+
id,
|
|
619
|
+
type: VARIANT_TYPES.MatchVariant,
|
|
620
|
+
variantInfo: VARIANT_INFO.Dynamic
|
|
621
|
+
});
|
|
450
622
|
}
|
|
451
623
|
};
|
|
624
|
+
return api;
|
|
452
625
|
}
|
|
453
626
|
let fileModifiedMapCache = new WeakMap();
|
|
454
627
|
function getFileModifiedMap(context) {
|
|
@@ -459,30 +632,34 @@ function getFileModifiedMap(context) {
|
|
|
459
632
|
}
|
|
460
633
|
function trackModified(files, fileModifiedMap) {
|
|
461
634
|
let changed = false;
|
|
635
|
+
let mtimesToCommit = new Map();
|
|
462
636
|
for (let file of files){
|
|
463
|
-
var
|
|
637
|
+
var _fs_statSync;
|
|
464
638
|
if (!file) continue;
|
|
465
639
|
let parsed = _url.default.parse(file);
|
|
466
|
-
let pathname = parsed.hash ? parsed.href.replace(parsed.hash,
|
|
467
|
-
pathname = parsed.search ? pathname.replace(parsed.search,
|
|
468
|
-
let newModified = (
|
|
640
|
+
let pathname = parsed.hash ? parsed.href.replace(parsed.hash, "") : parsed.href;
|
|
641
|
+
pathname = parsed.search ? pathname.replace(parsed.search, "") : pathname;
|
|
642
|
+
let newModified = (_fs_statSync = _fs.default.statSync(decodeURIComponent(pathname), {
|
|
469
643
|
throwIfNoEntry: false
|
|
470
|
-
})) === null ||
|
|
644
|
+
})) === null || _fs_statSync === void 0 ? void 0 : _fs_statSync.mtimeMs;
|
|
471
645
|
if (!newModified) {
|
|
472
646
|
continue;
|
|
473
647
|
}
|
|
474
648
|
if (!fileModifiedMap.has(file) || newModified > fileModifiedMap.get(file)) {
|
|
475
649
|
changed = true;
|
|
476
650
|
}
|
|
477
|
-
|
|
651
|
+
mtimesToCommit.set(file, newModified);
|
|
478
652
|
}
|
|
479
|
-
return
|
|
653
|
+
return [
|
|
654
|
+
changed,
|
|
655
|
+
mtimesToCommit
|
|
656
|
+
];
|
|
480
657
|
}
|
|
481
658
|
function extractVariantAtRules(node) {
|
|
482
659
|
node.walkAtRules((atRule)=>{
|
|
483
660
|
if ([
|
|
484
|
-
|
|
485
|
-
|
|
661
|
+
"responsive",
|
|
662
|
+
"variants"
|
|
486
663
|
].includes(atRule.name)) {
|
|
487
664
|
extractVariantAtRules(atRule);
|
|
488
665
|
atRule.before(atRule.nodes);
|
|
@@ -493,18 +670,18 @@ function extractVariantAtRules(node) {
|
|
|
493
670
|
function collectLayerPlugins(root) {
|
|
494
671
|
let layerPlugins = [];
|
|
495
672
|
root.each((node)=>{
|
|
496
|
-
if (node.type ===
|
|
497
|
-
|
|
498
|
-
|
|
673
|
+
if (node.type === "atrule" && [
|
|
674
|
+
"responsive",
|
|
675
|
+
"variants"
|
|
499
676
|
].includes(node.name)) {
|
|
500
|
-
node.name =
|
|
501
|
-
node.params =
|
|
677
|
+
node.name = "layer";
|
|
678
|
+
node.params = "utilities";
|
|
502
679
|
}
|
|
503
680
|
});
|
|
504
681
|
// Walk @layer rules and treat them like plugins
|
|
505
|
-
root.walkAtRules(
|
|
682
|
+
root.walkAtRules("layer", (layerRule)=>{
|
|
506
683
|
extractVariantAtRules(layerRule);
|
|
507
|
-
if (layerRule.params ===
|
|
684
|
+
if (layerRule.params === "base") {
|
|
508
685
|
for (let node of layerRule.nodes){
|
|
509
686
|
layerPlugins.push(function({ addBase }) {
|
|
510
687
|
addBase(node, {
|
|
@@ -513,20 +690,22 @@ function collectLayerPlugins(root) {
|
|
|
513
690
|
});
|
|
514
691
|
}
|
|
515
692
|
layerRule.remove();
|
|
516
|
-
} else if (layerRule.params ===
|
|
693
|
+
} else if (layerRule.params === "components") {
|
|
517
694
|
for (let node of layerRule.nodes){
|
|
518
695
|
layerPlugins.push(function({ addComponents }) {
|
|
519
696
|
addComponents(node, {
|
|
520
|
-
respectPrefix: false
|
|
697
|
+
respectPrefix: false,
|
|
698
|
+
preserveSource: true
|
|
521
699
|
});
|
|
522
700
|
});
|
|
523
701
|
}
|
|
524
702
|
layerRule.remove();
|
|
525
|
-
} else if (layerRule.params ===
|
|
703
|
+
} else if (layerRule.params === "utilities") {
|
|
526
704
|
for (let node of layerRule.nodes){
|
|
527
705
|
layerPlugins.push(function({ addUtilities }) {
|
|
528
706
|
addUtilities(node, {
|
|
529
|
-
respectPrefix: false
|
|
707
|
+
respectPrefix: false,
|
|
708
|
+
preserveSource: true
|
|
530
709
|
});
|
|
531
710
|
});
|
|
532
711
|
}
|
|
@@ -536,10 +715,7 @@ function collectLayerPlugins(root) {
|
|
|
536
715
|
return layerPlugins;
|
|
537
716
|
}
|
|
538
717
|
function resolvePlugins(context, root) {
|
|
539
|
-
let corePluginList = Object.entries({
|
|
540
|
-
..._corePlugins.variantPlugins,
|
|
541
|
-
..._corePlugins.corePlugins
|
|
542
|
-
}).map(([name, plugin])=>{
|
|
718
|
+
let corePluginList = Object.entries(_corePlugins.corePlugins).map(([name, plugin])=>{
|
|
543
719
|
if (!context.tailwindConfig.corePlugins.includes(name)) {
|
|
544
720
|
return null;
|
|
545
721
|
}
|
|
@@ -549,22 +725,27 @@ function resolvePlugins(context, root) {
|
|
|
549
725
|
if (plugin.__isOptionsFunction) {
|
|
550
726
|
plugin = plugin();
|
|
551
727
|
}
|
|
552
|
-
return typeof plugin ===
|
|
728
|
+
return typeof plugin === "function" ? plugin : plugin.handler;
|
|
553
729
|
});
|
|
554
730
|
let layerPlugins = collectLayerPlugins(root);
|
|
555
731
|
// TODO: This is a workaround for backwards compatibility, since custom variants
|
|
556
732
|
// were historically sorted before screen/stackable variants.
|
|
557
733
|
let beforeVariants = [
|
|
558
|
-
_corePlugins.variantPlugins[
|
|
559
|
-
_corePlugins.variantPlugins[
|
|
734
|
+
_corePlugins.variantPlugins["pseudoElementVariants"],
|
|
735
|
+
_corePlugins.variantPlugins["pseudoClassVariants"],
|
|
736
|
+
_corePlugins.variantPlugins["hasVariants"],
|
|
737
|
+
_corePlugins.variantPlugins["ariaVariants"],
|
|
738
|
+
_corePlugins.variantPlugins["dataVariants"]
|
|
560
739
|
];
|
|
561
740
|
let afterVariants = [
|
|
562
|
-
_corePlugins.variantPlugins[
|
|
563
|
-
_corePlugins.variantPlugins[
|
|
564
|
-
_corePlugins.variantPlugins[
|
|
565
|
-
_corePlugins.variantPlugins[
|
|
566
|
-
_corePlugins.variantPlugins[
|
|
567
|
-
_corePlugins.variantPlugins[
|
|
741
|
+
_corePlugins.variantPlugins["supportsVariants"],
|
|
742
|
+
_corePlugins.variantPlugins["directionVariants"],
|
|
743
|
+
_corePlugins.variantPlugins["reducedMotionVariants"],
|
|
744
|
+
_corePlugins.variantPlugins["prefersContrastVariants"],
|
|
745
|
+
_corePlugins.variantPlugins["darkVariants"],
|
|
746
|
+
_corePlugins.variantPlugins["printVariant"],
|
|
747
|
+
_corePlugins.variantPlugins["screenVariants"],
|
|
748
|
+
_corePlugins.variantPlugins["orientationVariants"]
|
|
568
749
|
];
|
|
569
750
|
return [
|
|
570
751
|
...corePluginList,
|
|
@@ -577,13 +758,9 @@ function resolvePlugins(context, root) {
|
|
|
577
758
|
function registerPlugins(plugins, context) {
|
|
578
759
|
let variantList = [];
|
|
579
760
|
let variantMap = new Map();
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
components: 0n,
|
|
584
|
-
utilities: 0n,
|
|
585
|
-
user: 0n
|
|
586
|
-
};
|
|
761
|
+
context.variantMap = variantMap;
|
|
762
|
+
let offsets = new _offsets.Offsets();
|
|
763
|
+
context.offsets = offsets;
|
|
587
764
|
let classList = new Set();
|
|
588
765
|
let pluginApi = buildPluginApi(context.tailwindConfig, context, {
|
|
589
766
|
variantList,
|
|
@@ -600,89 +777,53 @@ function registerPlugins(plugins, context) {
|
|
|
600
777
|
plugin === null || plugin === void 0 ? void 0 : plugin(pluginApi);
|
|
601
778
|
}
|
|
602
779
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
)([
|
|
606
|
-
offsets.base,
|
|
607
|
-
offsets.defaults,
|
|
608
|
-
offsets.components,
|
|
609
|
-
offsets.utilities,
|
|
610
|
-
offsets.user,
|
|
611
|
-
]);
|
|
612
|
-
let reservedBits = BigInt(highestOffset.toString(2).length);
|
|
613
|
-
// A number one less than the top range of the highest offset area
|
|
614
|
-
// so arbitrary properties are always sorted at the end.
|
|
615
|
-
context.arbitraryPropertiesSort = (1n << reservedBits << 0n) - 1n;
|
|
616
|
-
context.layerOrder = {
|
|
617
|
-
defaults: 1n << reservedBits << 0n,
|
|
618
|
-
base: 1n << reservedBits << 1n,
|
|
619
|
-
components: 1n << reservedBits << 2n,
|
|
620
|
-
utilities: 1n << reservedBits << 3n,
|
|
621
|
-
user: 1n << reservedBits << 4n
|
|
622
|
-
};
|
|
623
|
-
reservedBits += 5n;
|
|
624
|
-
let offset = 0;
|
|
625
|
-
context.variantOrder = new Map(variantList.map((variant, i)=>{
|
|
626
|
-
let variantFunctions = variantMap.get(variant).length;
|
|
627
|
-
let bits = 1n << BigInt(i + offset) << reservedBits;
|
|
628
|
-
offset += variantFunctions - 1;
|
|
629
|
-
return [
|
|
630
|
-
variant,
|
|
631
|
-
bits
|
|
632
|
-
];
|
|
633
|
-
}).sort(([, a], [, z])=>(0, _bigSign).default(a - z)
|
|
634
|
-
));
|
|
635
|
-
context.minimumScreen = [
|
|
636
|
-
...context.variantOrder.values()
|
|
637
|
-
].shift();
|
|
780
|
+
// Make sure to record bit masks for every variant
|
|
781
|
+
offsets.recordVariants(variantList, (variant)=>variantMap.get(variant).length);
|
|
638
782
|
// Build variantMap
|
|
639
|
-
for (let [variantName,
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
sort << BigInt(idx),
|
|
783
|
+
for (let [variantName, variantFunctions] of variantMap.entries()){
|
|
784
|
+
context.variantMap.set(variantName, variantFunctions.map((variantFunction, idx)=>[
|
|
785
|
+
offsets.forVariant(variantName, idx),
|
|
643
786
|
variantFunction
|
|
644
|
-
]
|
|
645
|
-
));
|
|
787
|
+
]));
|
|
646
788
|
}
|
|
647
|
-
var
|
|
648
|
-
let safelist = ((
|
|
789
|
+
var _context_tailwindConfig_safelist;
|
|
790
|
+
let safelist = ((_context_tailwindConfig_safelist = context.tailwindConfig.safelist) !== null && _context_tailwindConfig_safelist !== void 0 ? _context_tailwindConfig_safelist : []).filter(Boolean);
|
|
649
791
|
if (safelist.length > 0) {
|
|
650
792
|
let checks = [];
|
|
651
|
-
for (let
|
|
652
|
-
if (typeof
|
|
793
|
+
for (let value of safelist){
|
|
794
|
+
if (typeof value === "string") {
|
|
653
795
|
context.changedContent.push({
|
|
654
|
-
content:
|
|
655
|
-
extension:
|
|
796
|
+
content: value,
|
|
797
|
+
extension: "html"
|
|
656
798
|
});
|
|
657
799
|
continue;
|
|
658
800
|
}
|
|
659
|
-
if (
|
|
660
|
-
_log.default.warn(
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
801
|
+
if (value instanceof RegExp) {
|
|
802
|
+
_log.default.warn("root-regex", [
|
|
803
|
+
"Regular expressions in `safelist` work differently in Tailwind CSS v3.0.",
|
|
804
|
+
"Update your `safelist` configuration to eliminate this warning.",
|
|
805
|
+
"https://tailwindcss.com/docs/content-configuration#safelisting-classes"
|
|
664
806
|
]);
|
|
665
807
|
continue;
|
|
666
808
|
}
|
|
667
|
-
checks.push(
|
|
809
|
+
checks.push(value);
|
|
668
810
|
}
|
|
669
811
|
if (checks.length > 0) {
|
|
670
812
|
let patternMatchingCount = new Map();
|
|
671
813
|
let prefixLength = context.tailwindConfig.prefix.length;
|
|
814
|
+
let checkImportantUtils = checks.some((check)=>check.pattern.source.includes("!"));
|
|
672
815
|
for (let util of classList){
|
|
673
816
|
let utils = Array.isArray(util) ? (()=>{
|
|
674
817
|
let [utilName, options] = util;
|
|
675
|
-
var
|
|
676
|
-
let values = Object.keys((
|
|
677
|
-
let classes = values.map((value)=>(0, _nameClass
|
|
678
|
-
);
|
|
818
|
+
var _options_values;
|
|
819
|
+
let values = Object.keys((_options_values = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values !== void 0 ? _options_values : {});
|
|
820
|
+
let classes = values.map((value)=>(0, _nameClass.formatClass)(utilName, value));
|
|
679
821
|
if (options === null || options === void 0 ? void 0 : options.supportsNegativeValues) {
|
|
680
822
|
// This is the normal negated version
|
|
681
823
|
// e.g. `-inset-1` or `-tw-inset-1`
|
|
682
824
|
classes = [
|
|
683
825
|
...classes,
|
|
684
|
-
...classes.map((cls)=>
|
|
685
|
-
)
|
|
826
|
+
...classes.map((cls)=>"-" + cls)
|
|
686
827
|
];
|
|
687
828
|
// This is the negated version *after* the prefix
|
|
688
829
|
// e.g. `tw--inset-1`
|
|
@@ -690,15 +831,26 @@ function registerPlugins(plugins, context) {
|
|
|
690
831
|
// So we add the negative after the prefix
|
|
691
832
|
classes = [
|
|
692
833
|
...classes,
|
|
693
|
-
...classes.map((cls)=>cls.slice(0, prefixLength) +
|
|
694
|
-
|
|
834
|
+
...classes.map((cls)=>cls.slice(0, prefixLength) + "-" + cls.slice(prefixLength))
|
|
835
|
+
];
|
|
836
|
+
}
|
|
837
|
+
if (options.types.some(({ type })=>type === "color")) {
|
|
838
|
+
classes = [
|
|
839
|
+
...classes,
|
|
840
|
+
...classes.flatMap((cls)=>Object.keys(context.tailwindConfig.theme.opacity).map((opacity)=>`${cls}/${opacity}`))
|
|
841
|
+
];
|
|
842
|
+
}
|
|
843
|
+
if (checkImportantUtils && (options === null || options === void 0 ? void 0 : options.respectImportant)) {
|
|
844
|
+
classes = [
|
|
845
|
+
...classes,
|
|
846
|
+
...classes.map((cls)=>"!" + cls)
|
|
695
847
|
];
|
|
696
848
|
}
|
|
697
849
|
return classes;
|
|
698
850
|
})() : [
|
|
699
851
|
util
|
|
700
852
|
];
|
|
701
|
-
for (let
|
|
853
|
+
for (let util of utils){
|
|
702
854
|
for (let { pattern , variants =[] } of checks){
|
|
703
855
|
// RegExp with the /g flag are stateful, so let's reset the last
|
|
704
856
|
// index pointer to reset the state.
|
|
@@ -706,16 +858,16 @@ function registerPlugins(plugins, context) {
|
|
|
706
858
|
if (!patternMatchingCount.has(pattern)) {
|
|
707
859
|
patternMatchingCount.set(pattern, 0);
|
|
708
860
|
}
|
|
709
|
-
if (!pattern.test(
|
|
861
|
+
if (!pattern.test(util)) continue;
|
|
710
862
|
patternMatchingCount.set(pattern, patternMatchingCount.get(pattern) + 1);
|
|
711
863
|
context.changedContent.push({
|
|
712
|
-
content:
|
|
713
|
-
extension:
|
|
864
|
+
content: util,
|
|
865
|
+
extension: "html"
|
|
714
866
|
});
|
|
715
867
|
for (let variant of variants){
|
|
716
868
|
context.changedContent.push({
|
|
717
|
-
content: variant + context.tailwindConfig.separator +
|
|
718
|
-
extension:
|
|
869
|
+
content: variant + context.tailwindConfig.separator + util,
|
|
870
|
+
extension: "html"
|
|
719
871
|
});
|
|
720
872
|
}
|
|
721
873
|
}
|
|
@@ -725,34 +877,54 @@ function registerPlugins(plugins, context) {
|
|
|
725
877
|
if (count !== 0) continue;
|
|
726
878
|
_log.default.warn([
|
|
727
879
|
`The safelist pattern \`${regex}\` doesn't match any Tailwind CSS classes.`,
|
|
728
|
-
|
|
729
|
-
|
|
880
|
+
"Fix this pattern or remove it from your `safelist` configuration.",
|
|
881
|
+
"https://tailwindcss.com/docs/content-configuration#safelisting-classes"
|
|
730
882
|
]);
|
|
731
883
|
}
|
|
732
884
|
}
|
|
733
885
|
}
|
|
886
|
+
var _context_tailwindConfig_darkMode, _concat_;
|
|
887
|
+
let darkClassName = (_concat_ = [].concat((_context_tailwindConfig_darkMode = context.tailwindConfig.darkMode) !== null && _context_tailwindConfig_darkMode !== void 0 ? _context_tailwindConfig_darkMode : "media")[1]) !== null && _concat_ !== void 0 ? _concat_ : "dark";
|
|
734
888
|
// A list of utilities that are used by certain Tailwind CSS utilities but
|
|
735
889
|
// that don't exist on their own. This will result in them "not existing" and
|
|
736
890
|
// sorting could be weird since you still require them in order to make the
|
|
737
|
-
// host
|
|
738
|
-
let parasiteUtilities =
|
|
739
|
-
prefix(context,
|
|
740
|
-
prefix(context,
|
|
741
|
-
|
|
891
|
+
// host utilities work properly. (Thanks Biology)
|
|
892
|
+
let parasiteUtilities = [
|
|
893
|
+
prefix(context, darkClassName),
|
|
894
|
+
prefix(context, "group"),
|
|
895
|
+
prefix(context, "peer")
|
|
896
|
+
];
|
|
742
897
|
context.getClassOrder = function getClassOrder(classes) {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
898
|
+
// Sort classes so they're ordered in a deterministic manner
|
|
899
|
+
let sorted = [
|
|
900
|
+
...classes
|
|
901
|
+
].sort((a, z)=>{
|
|
902
|
+
if (a === z) return 0;
|
|
903
|
+
if (a < z) return -1;
|
|
904
|
+
return 1;
|
|
905
|
+
});
|
|
906
|
+
// Non-util classes won't be generated, so we default them to null
|
|
907
|
+
let sortedClassNames = new Map(sorted.map((className)=>[
|
|
908
|
+
className,
|
|
909
|
+
null
|
|
910
|
+
]));
|
|
911
|
+
// Sort all classes in order
|
|
912
|
+
// Non-tailwind classes won't be generated and will be left as `null`
|
|
913
|
+
let rules = (0, _generateRules.generateRules)(new Set(sorted), context);
|
|
914
|
+
rules = context.offsets.sort(rules);
|
|
915
|
+
let idx = BigInt(parasiteUtilities.length);
|
|
916
|
+
for (const [, rule] of rules){
|
|
917
|
+
sortedClassNames.set(rule.raws.tailwind.candidate, idx++);
|
|
747
918
|
}
|
|
748
919
|
return classes.map((className)=>{
|
|
749
|
-
var
|
|
750
|
-
let order = (
|
|
751
|
-
|
|
920
|
+
var _sortedClassNames_get;
|
|
921
|
+
let order = (_sortedClassNames_get = sortedClassNames.get(className)) !== null && _sortedClassNames_get !== void 0 ? _sortedClassNames_get : null;
|
|
922
|
+
let parasiteIndex = parasiteUtilities.indexOf(className);
|
|
923
|
+
if (order === null && parasiteIndex !== -1) {
|
|
752
924
|
// This will make sure that it is at the very beginning of the
|
|
753
925
|
// `components` layer which technically means 'before any
|
|
754
926
|
// components'.
|
|
755
|
-
order =
|
|
927
|
+
order = BigInt(parasiteIndex);
|
|
756
928
|
}
|
|
757
929
|
return [
|
|
758
930
|
className,
|
|
@@ -762,17 +934,40 @@ function registerPlugins(plugins, context) {
|
|
|
762
934
|
};
|
|
763
935
|
// Generate a list of strings for autocompletion purposes, e.g.
|
|
764
936
|
// ['uppercase', 'lowercase', ...]
|
|
765
|
-
context.getClassList = function getClassList() {
|
|
937
|
+
context.getClassList = function getClassList(options = {}) {
|
|
766
938
|
let output = [];
|
|
767
939
|
for (let util of classList){
|
|
768
940
|
if (Array.isArray(util)) {
|
|
769
|
-
|
|
941
|
+
var _utilOptions_types;
|
|
942
|
+
let [utilName, utilOptions] = util;
|
|
770
943
|
let negativeClasses = [];
|
|
771
|
-
var
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
944
|
+
var _utilOptions_modifiers;
|
|
945
|
+
let modifiers = Object.keys((_utilOptions_modifiers = utilOptions === null || utilOptions === void 0 ? void 0 : utilOptions.modifiers) !== null && _utilOptions_modifiers !== void 0 ? _utilOptions_modifiers : {});
|
|
946
|
+
if (utilOptions === null || utilOptions === void 0 ? void 0 : (_utilOptions_types = utilOptions.types) === null || _utilOptions_types === void 0 ? void 0 : _utilOptions_types.some(({ type })=>type === "color")) {
|
|
947
|
+
var _context_tailwindConfig_theme_opacity;
|
|
948
|
+
modifiers.push(...Object.keys((_context_tailwindConfig_theme_opacity = context.tailwindConfig.theme.opacity) !== null && _context_tailwindConfig_theme_opacity !== void 0 ? _context_tailwindConfig_theme_opacity : {}));
|
|
949
|
+
}
|
|
950
|
+
let metadata = {
|
|
951
|
+
modifiers
|
|
952
|
+
};
|
|
953
|
+
let includeMetadata = options.includeMetadata && modifiers.length > 0;
|
|
954
|
+
var _utilOptions_values;
|
|
955
|
+
for (let [key, value] of Object.entries((_utilOptions_values = utilOptions === null || utilOptions === void 0 ? void 0 : utilOptions.values) !== null && _utilOptions_values !== void 0 ? _utilOptions_values : {})){
|
|
956
|
+
// Ignore undefined and null values
|
|
957
|
+
if (value == null) {
|
|
958
|
+
continue;
|
|
959
|
+
}
|
|
960
|
+
let cls = (0, _nameClass.formatClass)(utilName, key);
|
|
961
|
+
output.push(includeMetadata ? [
|
|
962
|
+
cls,
|
|
963
|
+
metadata
|
|
964
|
+
] : cls);
|
|
965
|
+
if ((utilOptions === null || utilOptions === void 0 ? void 0 : utilOptions.supportsNegativeValues) && (0, _negateValue.default)(value)) {
|
|
966
|
+
let cls = (0, _nameClass.formatClass)(utilName, `-${key}`);
|
|
967
|
+
negativeClasses.push(includeMetadata ? [
|
|
968
|
+
cls,
|
|
969
|
+
metadata
|
|
970
|
+
] : cls);
|
|
776
971
|
}
|
|
777
972
|
}
|
|
778
973
|
output.push(...negativeClasses);
|
|
@@ -782,32 +977,204 @@ function registerPlugins(plugins, context) {
|
|
|
782
977
|
}
|
|
783
978
|
return output;
|
|
784
979
|
};
|
|
980
|
+
// Generate a list of available variants with meta information of the type of variant.
|
|
981
|
+
context.getVariants = function getVariants() {
|
|
982
|
+
let result = [];
|
|
983
|
+
for (let [name, options] of context.variantOptions.entries()){
|
|
984
|
+
if (options.variantInfo === VARIANT_INFO.Base) continue;
|
|
985
|
+
var _options_values;
|
|
986
|
+
result.push({
|
|
987
|
+
name,
|
|
988
|
+
isArbitrary: options.type === Symbol.for("MATCH_VARIANT"),
|
|
989
|
+
values: Object.keys((_options_values = options.values) !== null && _options_values !== void 0 ? _options_values : {}),
|
|
990
|
+
hasDash: name !== "@",
|
|
991
|
+
selectors ({ modifier , value } = {}) {
|
|
992
|
+
let candidate = "__TAILWIND_PLACEHOLDER__";
|
|
993
|
+
let rule = _postcss.default.rule({
|
|
994
|
+
selector: `.${candidate}`
|
|
995
|
+
});
|
|
996
|
+
let container = _postcss.default.root({
|
|
997
|
+
nodes: [
|
|
998
|
+
rule.clone()
|
|
999
|
+
]
|
|
1000
|
+
});
|
|
1001
|
+
let before = container.toString();
|
|
1002
|
+
var _context_variantMap_get;
|
|
1003
|
+
let fns = ((_context_variantMap_get = context.variantMap.get(name)) !== null && _context_variantMap_get !== void 0 ? _context_variantMap_get : []).flatMap(([_, fn])=>fn);
|
|
1004
|
+
let formatStrings = [];
|
|
1005
|
+
for (let fn of fns){
|
|
1006
|
+
var _options_values;
|
|
1007
|
+
let localFormatStrings = [];
|
|
1008
|
+
var _options_values_value;
|
|
1009
|
+
let api = {
|
|
1010
|
+
args: {
|
|
1011
|
+
modifier,
|
|
1012
|
+
value: (_options_values_value = (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[value]) !== null && _options_values_value !== void 0 ? _options_values_value : value
|
|
1013
|
+
},
|
|
1014
|
+
separator: context.tailwindConfig.separator,
|
|
1015
|
+
modifySelectors (modifierFunction) {
|
|
1016
|
+
// Run the modifierFunction over each rule
|
|
1017
|
+
container.each((rule)=>{
|
|
1018
|
+
if (rule.type !== "rule") {
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
rule.selectors = rule.selectors.map((selector)=>{
|
|
1022
|
+
return modifierFunction({
|
|
1023
|
+
get className () {
|
|
1024
|
+
return (0, _generateRules.getClassNameFromSelector)(selector);
|
|
1025
|
+
},
|
|
1026
|
+
selector
|
|
1027
|
+
});
|
|
1028
|
+
});
|
|
1029
|
+
});
|
|
1030
|
+
return container;
|
|
1031
|
+
},
|
|
1032
|
+
format (str) {
|
|
1033
|
+
localFormatStrings.push(str);
|
|
1034
|
+
},
|
|
1035
|
+
wrap (wrapper) {
|
|
1036
|
+
localFormatStrings.push(`@${wrapper.name} ${wrapper.params} { & }`);
|
|
1037
|
+
},
|
|
1038
|
+
container
|
|
1039
|
+
};
|
|
1040
|
+
let ruleWithVariant = fn(api);
|
|
1041
|
+
if (localFormatStrings.length > 0) {
|
|
1042
|
+
formatStrings.push(localFormatStrings);
|
|
1043
|
+
}
|
|
1044
|
+
if (Array.isArray(ruleWithVariant)) {
|
|
1045
|
+
for (let variantFunction of ruleWithVariant){
|
|
1046
|
+
localFormatStrings = [];
|
|
1047
|
+
variantFunction(api);
|
|
1048
|
+
formatStrings.push(localFormatStrings);
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
// Reverse engineer the result of the `container`
|
|
1053
|
+
let manualFormatStrings = [];
|
|
1054
|
+
let after = container.toString();
|
|
1055
|
+
if (before !== after) {
|
|
1056
|
+
// Figure out all selectors
|
|
1057
|
+
container.walkRules((rule)=>{
|
|
1058
|
+
let modified = rule.selector;
|
|
1059
|
+
// Rebuild the base selector, this is what plugin authors would do
|
|
1060
|
+
// as well. E.g.: `${variant}${separator}${className}`.
|
|
1061
|
+
// However, plugin authors probably also prepend or append certain
|
|
1062
|
+
// classes, pseudos, ids, ...
|
|
1063
|
+
let rebuiltBase = (0, _postcssselectorparser.default)((selectors)=>{
|
|
1064
|
+
selectors.walkClasses((classNode)=>{
|
|
1065
|
+
classNode.value = `${name}${context.tailwindConfig.separator}${classNode.value}`;
|
|
1066
|
+
});
|
|
1067
|
+
}).processSync(modified);
|
|
1068
|
+
// Now that we know the original selector, the new selector, and
|
|
1069
|
+
// the rebuild part in between, we can replace the part that plugin
|
|
1070
|
+
// authors need to rebuild with `&`, and eventually store it in the
|
|
1071
|
+
// collectedFormats. Similar to what `format('...')` would do.
|
|
1072
|
+
//
|
|
1073
|
+
// E.g.:
|
|
1074
|
+
// variant: foo
|
|
1075
|
+
// selector: .markdown > p
|
|
1076
|
+
// modified (by plugin): .foo .foo\\:markdown > p
|
|
1077
|
+
// rebuiltBase (internal): .foo\\:markdown > p
|
|
1078
|
+
// format: .foo &
|
|
1079
|
+
manualFormatStrings.push(modified.replace(rebuiltBase, "&").replace(candidate, "&"));
|
|
1080
|
+
});
|
|
1081
|
+
// Figure out all atrules
|
|
1082
|
+
container.walkAtRules((atrule)=>{
|
|
1083
|
+
manualFormatStrings.push(`@${atrule.name} (${atrule.params}) { & }`);
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
var _options_values1;
|
|
1087
|
+
let isArbitraryVariant = !(value in ((_options_values1 = options.values) !== null && _options_values1 !== void 0 ? _options_values1 : {}));
|
|
1088
|
+
formatStrings = formatStrings.map((format)=>format.map((str)=>({
|
|
1089
|
+
format: str,
|
|
1090
|
+
isArbitraryVariant
|
|
1091
|
+
})));
|
|
1092
|
+
manualFormatStrings = manualFormatStrings.map((format)=>({
|
|
1093
|
+
format,
|
|
1094
|
+
isArbitraryVariant
|
|
1095
|
+
}));
|
|
1096
|
+
let opts = {
|
|
1097
|
+
candidate,
|
|
1098
|
+
context
|
|
1099
|
+
};
|
|
1100
|
+
let result = formatStrings.map((formats)=>(0, _formatVariantSelector.finalizeSelector)(`.${candidate}`, (0, _formatVariantSelector.formatVariantSelector)(formats, opts), opts).replace(`.${candidate}`, "&").replace("{ & }", "").trim());
|
|
1101
|
+
if (manualFormatStrings.length > 0) {
|
|
1102
|
+
result.push((0, _formatVariantSelector.formatVariantSelector)(manualFormatStrings, opts).toString().replace(`.${candidate}`, "&"));
|
|
1103
|
+
}
|
|
1104
|
+
return result;
|
|
1105
|
+
}
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
return result;
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
/**
|
|
1112
|
+
* Mark as class as retroactively invalid
|
|
1113
|
+
*
|
|
1114
|
+
*
|
|
1115
|
+
* @param {string} candidate
|
|
1116
|
+
*/ function markInvalidUtilityCandidate(context, candidate) {
|
|
1117
|
+
if (!context.classCache.has(candidate)) {
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
// Mark this as not being a real utility
|
|
1121
|
+
context.notClassCache.add(candidate);
|
|
1122
|
+
// Remove it from any candidate-specific caches
|
|
1123
|
+
context.classCache.delete(candidate);
|
|
1124
|
+
context.applyClassCache.delete(candidate);
|
|
1125
|
+
context.candidateRuleMap.delete(candidate);
|
|
1126
|
+
context.candidateRuleCache.delete(candidate);
|
|
1127
|
+
// Ensure the stylesheet gets rebuilt
|
|
1128
|
+
context.stylesheetCache = null;
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Mark as class as retroactively invalid
|
|
1132
|
+
*
|
|
1133
|
+
* @param {import('postcss').Node} node
|
|
1134
|
+
*/ function markInvalidUtilityNode(context, node) {
|
|
1135
|
+
let candidate = node.raws.tailwind.candidate;
|
|
1136
|
+
if (!candidate) {
|
|
1137
|
+
return;
|
|
1138
|
+
}
|
|
1139
|
+
for (const entry of context.ruleCache){
|
|
1140
|
+
if (entry[1].raws.tailwind.candidate === candidate) {
|
|
1141
|
+
context.ruleCache.delete(entry);
|
|
1142
|
+
// context.postCssNodeCache.delete(node)
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
markInvalidUtilityCandidate(context, candidate);
|
|
785
1146
|
}
|
|
786
1147
|
function createContext(tailwindConfig, changedContent = [], root = _postcss.default.root()) {
|
|
1148
|
+
var _tailwindConfig_blocklist;
|
|
787
1149
|
let context = {
|
|
788
1150
|
disposables: [],
|
|
789
1151
|
ruleCache: new Set(),
|
|
1152
|
+
candidateRuleCache: new Map(),
|
|
790
1153
|
classCache: new Map(),
|
|
791
1154
|
applyClassCache: new Map(),
|
|
792
|
-
|
|
1155
|
+
// Seed the not class cache with the blocklist (which is only strings)
|
|
1156
|
+
notClassCache: new Set((_tailwindConfig_blocklist = tailwindConfig.blocklist) !== null && _tailwindConfig_blocklist !== void 0 ? _tailwindConfig_blocklist : []),
|
|
793
1157
|
postCssNodeCache: new Map(),
|
|
794
1158
|
candidateRuleMap: new Map(),
|
|
795
1159
|
tailwindConfig,
|
|
796
1160
|
changedContent: changedContent,
|
|
797
1161
|
variantMap: new Map(),
|
|
798
|
-
stylesheetCache: null
|
|
1162
|
+
stylesheetCache: null,
|
|
1163
|
+
variantOptions: new Map(),
|
|
1164
|
+
markInvalidUtilityCandidate: (candidate)=>markInvalidUtilityCandidate(context, candidate),
|
|
1165
|
+
markInvalidUtilityNode: (node)=>markInvalidUtilityNode(context, node)
|
|
799
1166
|
};
|
|
800
1167
|
let resolvedPlugins = resolvePlugins(context, root);
|
|
801
1168
|
registerPlugins(resolvedPlugins, context);
|
|
802
1169
|
return context;
|
|
803
1170
|
}
|
|
804
|
-
let contextMap =
|
|
805
|
-
let configContextMap =
|
|
806
|
-
let contextSourcesMap =
|
|
1171
|
+
let contextMap = _sharedState.contextMap;
|
|
1172
|
+
let configContextMap = _sharedState.configContextMap;
|
|
1173
|
+
let contextSourcesMap = _sharedState.contextSourcesMap;
|
|
807
1174
|
function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies) {
|
|
808
1175
|
let sourcePath = result.opts.from;
|
|
809
1176
|
let isConfigFile = userConfigPath !== null;
|
|
810
|
-
|
|
1177
|
+
_sharedState.env.DEBUG && console.log("Source path:", sourcePath);
|
|
811
1178
|
let existingContext;
|
|
812
1179
|
if (isConfigFile && contextMap.has(sourcePath)) {
|
|
813
1180
|
existingContext = contextMap.get(sourcePath);
|
|
@@ -817,17 +1184,18 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
817
1184
|
contextMap.set(sourcePath, context);
|
|
818
1185
|
existingContext = context;
|
|
819
1186
|
}
|
|
820
|
-
let cssDidChange = (0,
|
|
1187
|
+
let cssDidChange = (0, _cacheInvalidation.hasContentChanged)(sourcePath, root);
|
|
821
1188
|
// If there's already a context in the cache and we don't need to
|
|
822
1189
|
// reset the context, return the cached context.
|
|
823
1190
|
if (existingContext) {
|
|
824
|
-
let contextDependenciesChanged = trackModified([
|
|
1191
|
+
let [contextDependenciesChanged, mtimesToCommit] = trackModified([
|
|
825
1192
|
...contextDependencies
|
|
826
1193
|
], getFileModifiedMap(existingContext));
|
|
827
1194
|
if (!contextDependenciesChanged && !cssDidChange) {
|
|
828
1195
|
return [
|
|
829
1196
|
existingContext,
|
|
830
|
-
false
|
|
1197
|
+
false,
|
|
1198
|
+
mtimesToCommit
|
|
831
1199
|
];
|
|
832
1200
|
}
|
|
833
1201
|
}
|
|
@@ -853,9 +1221,12 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
853
1221
|
}
|
|
854
1222
|
}
|
|
855
1223
|
}
|
|
856
|
-
|
|
1224
|
+
_sharedState.env.DEBUG && console.log("Setting up new context...");
|
|
857
1225
|
let context = createContext(tailwindConfig, [], root);
|
|
858
|
-
|
|
1226
|
+
Object.assign(context, {
|
|
1227
|
+
userConfigPath
|
|
1228
|
+
});
|
|
1229
|
+
let [, mtimesToCommit] = trackModified([
|
|
859
1230
|
...contextDependencies
|
|
860
1231
|
], getFileModifiedMap(context));
|
|
861
1232
|
// ---
|
|
@@ -868,6 +1239,7 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
868
1239
|
contextSourcesMap.get(context).add(sourcePath);
|
|
869
1240
|
return [
|
|
870
1241
|
context,
|
|
871
|
-
true
|
|
1242
|
+
true,
|
|
1243
|
+
mtimesToCommit
|
|
872
1244
|
];
|
|
873
1245
|
}
|