tailwindcss 0.0.0-insiders.ee945bb → 0.0.0-insiders.ef2ebb2
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/colors.d.ts +3 -0
- package/defaultConfig.d.ts +3 -0
- package/defaultTheme.d.ts +4 -0
- package/index.css +5 -0
- package/lib/cli/build/index.js +57 -0
- package/lib/cli/build/plugin.js +433 -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 -751
- package/lib/corePluginList.js +13 -3
- package/lib/corePlugins.js +2323 -1720
- 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 +454 -206
- 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 +687 -301
- 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 +166 -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 +70 -53
- 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 +59 -53
- package/plugin.d.ts +11 -0
- package/resolveConfig.d.ts +12 -0
- package/scripts/generate-types.js +105 -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 +476 -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 -825
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +614 -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 +427 -127
- 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 +591 -156
- package/src/lib/setupTrackingContext.js +44 -58
- package/src/lib/sharedState.js +13 -4
- package/src/plugin.js +141 -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 +39 -20
- 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} +218 -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 +369 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +298 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/generated/default-theme.d.ts +372 -0
- package/types/index.d.ts +7 -0
- package/CHANGELOG.md +0 -2090
- package/lib/cli-peer-dependencies.js +0 -15
- package/lib/constants.js +0 -37
- package/peers/index.js +0 -75077
- 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
|
@@ -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,13 +179,16 @@ 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
|
-
function getClasses(selector) {
|
|
109
|
-
let parser = (0,
|
|
186
|
+
function getClasses(selector, mutate) {
|
|
187
|
+
let parser = (0, _postcssselectorparser.default)((selectors)=>{
|
|
110
188
|
let allClasses = [];
|
|
189
|
+
if (mutate) {
|
|
190
|
+
mutate(selectors);
|
|
191
|
+
}
|
|
111
192
|
selectors.walkClasses((classNode)=>{
|
|
112
193
|
allClasses.push(classNode.value);
|
|
113
194
|
});
|
|
@@ -120,9 +201,20 @@ function extractCandidates(node, state = {
|
|
|
120
201
|
}, depth = 0) {
|
|
121
202
|
let classes = [];
|
|
122
203
|
// Handle normal rules
|
|
123
|
-
if (node.type ===
|
|
204
|
+
if (node.type === "rule") {
|
|
205
|
+
// Ignore everything inside a :not(...). This allows you to write code like
|
|
206
|
+
// `div:not(.foo)`. If `.foo` is never found in your code, then we used to
|
|
207
|
+
// not generated it. But now we will ignore everything inside a `:not`, so
|
|
208
|
+
// that it still gets generated.
|
|
209
|
+
function ignoreNot(selectors) {
|
|
210
|
+
selectors.walkPseudos((pseudo)=>{
|
|
211
|
+
if (pseudo.value === ":not") {
|
|
212
|
+
pseudo.remove();
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
124
216
|
for (let selector of node.selectors){
|
|
125
|
-
let classCandidates = getClasses(selector);
|
|
217
|
+
let classCandidates = getClasses(selector, ignoreNot);
|
|
126
218
|
// At least one of the selectors contains non-"on-demandable" candidates.
|
|
127
219
|
if (classCandidates.length === 0) {
|
|
128
220
|
state.containsNonOnDemandable = true;
|
|
@@ -131,10 +223,9 @@ function extractCandidates(node, state = {
|
|
|
131
223
|
classes.push(classCandidate);
|
|
132
224
|
}
|
|
133
225
|
}
|
|
134
|
-
} else if (node.type ===
|
|
226
|
+
} else if (node.type === "atrule") {
|
|
135
227
|
node.walkRules((rule)=>{
|
|
136
|
-
for (let classCandidate of rule.selectors.flatMap((selector)=>getClasses(selector
|
|
137
|
-
)){
|
|
228
|
+
for (let classCandidate of rule.selectors.flatMap((selector)=>getClasses(selector))){
|
|
138
229
|
classes.push(classCandidate);
|
|
139
230
|
}
|
|
140
231
|
});
|
|
@@ -153,7 +244,7 @@ function withIdentifiers(styles) {
|
|
|
153
244
|
let [containsNonOnDemandableSelectors, candidates] = extractCandidates(node);
|
|
154
245
|
// If this isn't "on-demandable", assign it a universal candidate to always include it.
|
|
155
246
|
if (containsNonOnDemandableSelectors) {
|
|
156
|
-
candidates.unshift(
|
|
247
|
+
candidates.unshift(_sharedState.NOT_ON_DEMAND);
|
|
157
248
|
}
|
|
158
249
|
// However, it could be that it also contains "on-demandable" candidates.
|
|
159
250
|
// E.g.: `span, .foo {}`, in that case it should still be possible to use
|
|
@@ -169,76 +260,70 @@ function withIdentifiers(styles) {
|
|
|
169
260
|
});
|
|
170
261
|
});
|
|
171
262
|
}
|
|
172
|
-
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 }) {
|
|
173
291
|
function getConfigValue(path, defaultValue) {
|
|
174
|
-
return path ? (0, _dlv
|
|
292
|
+
return path ? (0, _dlv.default)(tailwindConfig, path, defaultValue) : tailwindConfig;
|
|
175
293
|
}
|
|
176
294
|
function applyConfiguredPrefix(selector) {
|
|
177
|
-
return (0, _prefixSelector
|
|
295
|
+
return (0, _prefixSelector.default)(tailwindConfig.prefix, selector);
|
|
178
296
|
}
|
|
179
297
|
function prefixIdentifier(identifier, options) {
|
|
180
|
-
if (identifier ===
|
|
181
|
-
return
|
|
298
|
+
if (identifier === _sharedState.NOT_ON_DEMAND) {
|
|
299
|
+
return _sharedState.NOT_ON_DEMAND;
|
|
182
300
|
}
|
|
183
301
|
if (!options.respectPrefix) {
|
|
184
302
|
return identifier;
|
|
185
303
|
}
|
|
186
304
|
return context.tailwindConfig.prefix + identifier;
|
|
187
305
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
});
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
variantFunction = variantFunction.replace(/\n+/g, '').replace(/\s{1,}/g, ' ').trim();
|
|
202
|
-
let fns = parseVariantFormatString(variantFunction).map((str)=>{
|
|
203
|
-
if (!str.startsWith('@')) {
|
|
204
|
-
return ({ format })=>format(str)
|
|
205
|
-
;
|
|
206
|
-
}
|
|
207
|
-
let [, name, params] = /@(.*?) (.*)/g.exec(str);
|
|
208
|
-
return ({ wrap })=>wrap(_postcss.default.atRule({
|
|
209
|
-
name,
|
|
210
|
-
params
|
|
211
|
-
}))
|
|
212
|
-
;
|
|
213
|
-
}).reverse();
|
|
214
|
-
return (api)=>{
|
|
215
|
-
for (let fn of fns){
|
|
216
|
-
fn(api);
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
});
|
|
220
|
-
insertInto(variantList, variantName, options);
|
|
221
|
-
variantMap.set(variantName, variantFunctions);
|
|
222
|
-
},
|
|
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 = {
|
|
223
316
|
postcss: _postcss.default,
|
|
224
317
|
prefix: applyConfiguredPrefix,
|
|
225
318
|
e: _escapeClassName.default,
|
|
226
319
|
config: getConfigValue,
|
|
227
|
-
theme
|
|
228
|
-
const [pathRoot, ...subPaths] = (0, _toPath).toPath(path);
|
|
229
|
-
const value = getConfigValue([
|
|
230
|
-
'theme',
|
|
231
|
-
pathRoot,
|
|
232
|
-
...subPaths
|
|
233
|
-
], defaultValue);
|
|
234
|
-
return (0, _transformThemeValue).default(pathRoot)(value);
|
|
235
|
-
},
|
|
320
|
+
theme: resolveThemeValue,
|
|
236
321
|
corePlugins: (path)=>{
|
|
237
322
|
if (Array.isArray(tailwindConfig.corePlugins)) {
|
|
238
323
|
return tailwindConfig.corePlugins.includes(path);
|
|
239
324
|
}
|
|
240
325
|
return getConfigValue([
|
|
241
|
-
|
|
326
|
+
"corePlugins",
|
|
242
327
|
path
|
|
243
328
|
], true);
|
|
244
329
|
},
|
|
@@ -249,14 +334,14 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
249
334
|
addBase (base) {
|
|
250
335
|
for (let [identifier, rule] of withIdentifiers(base)){
|
|
251
336
|
let prefixedIdentifier = prefixIdentifier(identifier, {});
|
|
252
|
-
let offset = offsets.base
|
|
337
|
+
let offset = offsets.create("base");
|
|
253
338
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
254
339
|
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
255
340
|
}
|
|
256
341
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
257
342
|
{
|
|
258
343
|
sort: offset,
|
|
259
|
-
layer:
|
|
344
|
+
layer: "base"
|
|
260
345
|
},
|
|
261
346
|
rule
|
|
262
347
|
]);
|
|
@@ -276,8 +361,8 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
276
361
|
}
|
|
277
362
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
278
363
|
{
|
|
279
|
-
sort: offsets.
|
|
280
|
-
layer:
|
|
364
|
+
sort: offsets.create("defaults"),
|
|
365
|
+
layer: "defaults"
|
|
281
366
|
},
|
|
282
367
|
rule
|
|
283
368
|
]);
|
|
@@ -285,6 +370,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
285
370
|
},
|
|
286
371
|
addComponents (components, options) {
|
|
287
372
|
let defaultOptions = {
|
|
373
|
+
preserveSource: false,
|
|
288
374
|
respectPrefix: true,
|
|
289
375
|
respectImportant: false
|
|
290
376
|
};
|
|
@@ -297,8 +383,8 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
297
383
|
}
|
|
298
384
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
299
385
|
{
|
|
300
|
-
sort: offsets.components
|
|
301
|
-
layer:
|
|
386
|
+
sort: offsets.create("components"),
|
|
387
|
+
layer: "components",
|
|
302
388
|
options
|
|
303
389
|
},
|
|
304
390
|
rule
|
|
@@ -307,6 +393,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
307
393
|
},
|
|
308
394
|
addUtilities (utilities, options) {
|
|
309
395
|
let defaultOptions = {
|
|
396
|
+
preserveSource: false,
|
|
310
397
|
respectPrefix: true,
|
|
311
398
|
respectImportant: true
|
|
312
399
|
};
|
|
@@ -319,8 +406,8 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
319
406
|
}
|
|
320
407
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
321
408
|
{
|
|
322
|
-
sort: offsets.utilities
|
|
323
|
-
layer:
|
|
409
|
+
sort: offsets.create("utilities"),
|
|
410
|
+
layer: "utilities",
|
|
324
411
|
options
|
|
325
412
|
},
|
|
326
413
|
rule
|
|
@@ -330,13 +417,14 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
330
417
|
matchUtilities: function(utilities, options) {
|
|
331
418
|
let defaultOptions = {
|
|
332
419
|
respectPrefix: true,
|
|
333
|
-
respectImportant: true
|
|
420
|
+
respectImportant: true,
|
|
421
|
+
modifiers: false
|
|
334
422
|
};
|
|
335
|
-
options = {
|
|
423
|
+
options = normalizeOptionTypes({
|
|
336
424
|
...defaultOptions,
|
|
337
425
|
...options
|
|
338
|
-
};
|
|
339
|
-
let offset = offsets.utilities
|
|
426
|
+
});
|
|
427
|
+
let offset = offsets.create("utilities");
|
|
340
428
|
for(let identifier in utilities){
|
|
341
429
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
342
430
|
let rule = utilities[identifier];
|
|
@@ -345,28 +433,42 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
345
433
|
options
|
|
346
434
|
]);
|
|
347
435
|
function wrapped(modifier, { isOnlyPlugin }) {
|
|
348
|
-
let
|
|
349
|
-
type = [].concat(type);
|
|
350
|
-
let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options, tailwindConfig);
|
|
436
|
+
let [value, coercedType, utilityModifier] = (0, _pluginUtils.coerceValue)(options.types, modifier, options, tailwindConfig);
|
|
351
437
|
if (value === undefined) {
|
|
352
438
|
return [];
|
|
353
439
|
}
|
|
354
|
-
if (!
|
|
355
|
-
|
|
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
|
+
}
|
|
356
449
|
}
|
|
357
|
-
if (!(0,
|
|
450
|
+
if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
|
|
358
451
|
return [];
|
|
359
452
|
}
|
|
360
|
-
let
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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
|
+
}));
|
|
364
466
|
return ruleSets;
|
|
365
467
|
}
|
|
366
468
|
let withOffsets = [
|
|
367
469
|
{
|
|
368
470
|
sort: offset,
|
|
369
|
-
layer:
|
|
471
|
+
layer: "utilities",
|
|
370
472
|
options
|
|
371
473
|
},
|
|
372
474
|
wrapped
|
|
@@ -380,13 +482,14 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
380
482
|
matchComponents: function(components, options) {
|
|
381
483
|
let defaultOptions = {
|
|
382
484
|
respectPrefix: true,
|
|
383
|
-
respectImportant: false
|
|
485
|
+
respectImportant: false,
|
|
486
|
+
modifiers: false
|
|
384
487
|
};
|
|
385
|
-
options = {
|
|
488
|
+
options = normalizeOptionTypes({
|
|
386
489
|
...defaultOptions,
|
|
387
490
|
...options
|
|
388
|
-
};
|
|
389
|
-
let offset = offsets.components
|
|
491
|
+
});
|
|
492
|
+
let offset = offsets.create("components");
|
|
390
493
|
for(let identifier in components){
|
|
391
494
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
392
495
|
let rule = components[identifier];
|
|
@@ -395,35 +498,42 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
395
498
|
options
|
|
396
499
|
]);
|
|
397
500
|
function wrapped(modifier, { isOnlyPlugin }) {
|
|
398
|
-
let
|
|
399
|
-
type = [].concat(type);
|
|
400
|
-
let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options, tailwindConfig);
|
|
501
|
+
let [value, coercedType, utilityModifier] = (0, _pluginUtils.coerceValue)(options.types, modifier, options, tailwindConfig);
|
|
401
502
|
if (value === undefined) {
|
|
402
503
|
return [];
|
|
403
504
|
}
|
|
404
|
-
if (!
|
|
505
|
+
if (!options.types.some(({ type })=>type === coercedType)) {
|
|
405
506
|
if (isOnlyPlugin) {
|
|
406
507
|
_log.default.warn([
|
|
407
508
|
`Unnecessary typehint \`${coercedType}\` in \`${identifier}-${modifier}\`.`,
|
|
408
|
-
`You can safely update it to \`${identifier}-${modifier.replace(coercedType +
|
|
509
|
+
`You can safely update it to \`${identifier}-${modifier.replace(coercedType + ":", "")}\`.`
|
|
409
510
|
]);
|
|
410
511
|
} else {
|
|
411
512
|
return [];
|
|
412
513
|
}
|
|
413
514
|
}
|
|
414
|
-
if (!(0,
|
|
515
|
+
if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
|
|
415
516
|
return [];
|
|
416
517
|
}
|
|
417
|
-
let
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
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
|
+
}));
|
|
421
531
|
return ruleSets;
|
|
422
532
|
}
|
|
423
533
|
let withOffsets = [
|
|
424
534
|
{
|
|
425
535
|
sort: offset,
|
|
426
|
-
layer:
|
|
536
|
+
layer: "components",
|
|
427
537
|
options
|
|
428
538
|
},
|
|
429
539
|
wrapped
|
|
@@ -433,8 +543,85 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
433
543
|
}
|
|
434
544
|
context.candidateRuleMap.get(prefixedIdentifier).push(withOffsets);
|
|
435
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
|
+
});
|
|
436
622
|
}
|
|
437
623
|
};
|
|
624
|
+
return api;
|
|
438
625
|
}
|
|
439
626
|
let fileModifiedMapCache = new WeakMap();
|
|
440
627
|
function getFileModifiedMap(context) {
|
|
@@ -445,30 +632,34 @@ function getFileModifiedMap(context) {
|
|
|
445
632
|
}
|
|
446
633
|
function trackModified(files, fileModifiedMap) {
|
|
447
634
|
let changed = false;
|
|
635
|
+
let mtimesToCommit = new Map();
|
|
448
636
|
for (let file of files){
|
|
449
|
-
var
|
|
637
|
+
var _fs_statSync;
|
|
450
638
|
if (!file) continue;
|
|
451
639
|
let parsed = _url.default.parse(file);
|
|
452
|
-
let pathname = parsed.hash ? parsed.href.replace(parsed.hash,
|
|
453
|
-
pathname = parsed.search ? pathname.replace(parsed.search,
|
|
454
|
-
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), {
|
|
455
643
|
throwIfNoEntry: false
|
|
456
|
-
})) === null ||
|
|
644
|
+
})) === null || _fs_statSync === void 0 ? void 0 : _fs_statSync.mtimeMs;
|
|
457
645
|
if (!newModified) {
|
|
458
646
|
continue;
|
|
459
647
|
}
|
|
460
648
|
if (!fileModifiedMap.has(file) || newModified > fileModifiedMap.get(file)) {
|
|
461
649
|
changed = true;
|
|
462
650
|
}
|
|
463
|
-
|
|
651
|
+
mtimesToCommit.set(file, newModified);
|
|
464
652
|
}
|
|
465
|
-
return
|
|
653
|
+
return [
|
|
654
|
+
changed,
|
|
655
|
+
mtimesToCommit
|
|
656
|
+
];
|
|
466
657
|
}
|
|
467
658
|
function extractVariantAtRules(node) {
|
|
468
659
|
node.walkAtRules((atRule)=>{
|
|
469
660
|
if ([
|
|
470
|
-
|
|
471
|
-
|
|
661
|
+
"responsive",
|
|
662
|
+
"variants"
|
|
472
663
|
].includes(atRule.name)) {
|
|
473
664
|
extractVariantAtRules(atRule);
|
|
474
665
|
atRule.before(atRule.nodes);
|
|
@@ -479,18 +670,18 @@ function extractVariantAtRules(node) {
|
|
|
479
670
|
function collectLayerPlugins(root) {
|
|
480
671
|
let layerPlugins = [];
|
|
481
672
|
root.each((node)=>{
|
|
482
|
-
if (node.type ===
|
|
483
|
-
|
|
484
|
-
|
|
673
|
+
if (node.type === "atrule" && [
|
|
674
|
+
"responsive",
|
|
675
|
+
"variants"
|
|
485
676
|
].includes(node.name)) {
|
|
486
|
-
node.name =
|
|
487
|
-
node.params =
|
|
677
|
+
node.name = "layer";
|
|
678
|
+
node.params = "utilities";
|
|
488
679
|
}
|
|
489
680
|
});
|
|
490
681
|
// Walk @layer rules and treat them like plugins
|
|
491
|
-
root.walkAtRules(
|
|
682
|
+
root.walkAtRules("layer", (layerRule)=>{
|
|
492
683
|
extractVariantAtRules(layerRule);
|
|
493
|
-
if (layerRule.params ===
|
|
684
|
+
if (layerRule.params === "base") {
|
|
494
685
|
for (let node of layerRule.nodes){
|
|
495
686
|
layerPlugins.push(function({ addBase }) {
|
|
496
687
|
addBase(node, {
|
|
@@ -499,20 +690,22 @@ function collectLayerPlugins(root) {
|
|
|
499
690
|
});
|
|
500
691
|
}
|
|
501
692
|
layerRule.remove();
|
|
502
|
-
} else if (layerRule.params ===
|
|
693
|
+
} else if (layerRule.params === "components") {
|
|
503
694
|
for (let node of layerRule.nodes){
|
|
504
695
|
layerPlugins.push(function({ addComponents }) {
|
|
505
696
|
addComponents(node, {
|
|
506
|
-
respectPrefix: false
|
|
697
|
+
respectPrefix: false,
|
|
698
|
+
preserveSource: true
|
|
507
699
|
});
|
|
508
700
|
});
|
|
509
701
|
}
|
|
510
702
|
layerRule.remove();
|
|
511
|
-
} else if (layerRule.params ===
|
|
703
|
+
} else if (layerRule.params === "utilities") {
|
|
512
704
|
for (let node of layerRule.nodes){
|
|
513
705
|
layerPlugins.push(function({ addUtilities }) {
|
|
514
706
|
addUtilities(node, {
|
|
515
|
-
respectPrefix: false
|
|
707
|
+
respectPrefix: false,
|
|
708
|
+
preserveSource: true
|
|
516
709
|
});
|
|
517
710
|
});
|
|
518
711
|
}
|
|
@@ -522,10 +715,7 @@ function collectLayerPlugins(root) {
|
|
|
522
715
|
return layerPlugins;
|
|
523
716
|
}
|
|
524
717
|
function resolvePlugins(context, root) {
|
|
525
|
-
let corePluginList = Object.entries({
|
|
526
|
-
..._corePlugins.variantPlugins,
|
|
527
|
-
..._corePlugins.corePlugins
|
|
528
|
-
}).map(([name, plugin])=>{
|
|
718
|
+
let corePluginList = Object.entries(_corePlugins.corePlugins).map(([name, plugin])=>{
|
|
529
719
|
if (!context.tailwindConfig.corePlugins.includes(name)) {
|
|
530
720
|
return null;
|
|
531
721
|
}
|
|
@@ -535,22 +725,27 @@ function resolvePlugins(context, root) {
|
|
|
535
725
|
if (plugin.__isOptionsFunction) {
|
|
536
726
|
plugin = plugin();
|
|
537
727
|
}
|
|
538
|
-
return typeof plugin ===
|
|
728
|
+
return typeof plugin === "function" ? plugin : plugin.handler;
|
|
539
729
|
});
|
|
540
730
|
let layerPlugins = collectLayerPlugins(root);
|
|
541
731
|
// TODO: This is a workaround for backwards compatibility, since custom variants
|
|
542
732
|
// were historically sorted before screen/stackable variants.
|
|
543
733
|
let beforeVariants = [
|
|
544
|
-
_corePlugins.variantPlugins[
|
|
545
|
-
_corePlugins.variantPlugins[
|
|
734
|
+
_corePlugins.variantPlugins["pseudoElementVariants"],
|
|
735
|
+
_corePlugins.variantPlugins["pseudoClassVariants"],
|
|
736
|
+
_corePlugins.variantPlugins["hasVariants"],
|
|
737
|
+
_corePlugins.variantPlugins["ariaVariants"],
|
|
738
|
+
_corePlugins.variantPlugins["dataVariants"]
|
|
546
739
|
];
|
|
547
740
|
let afterVariants = [
|
|
548
|
-
_corePlugins.variantPlugins[
|
|
549
|
-
_corePlugins.variantPlugins[
|
|
550
|
-
_corePlugins.variantPlugins[
|
|
551
|
-
_corePlugins.variantPlugins[
|
|
552
|
-
_corePlugins.variantPlugins[
|
|
553
|
-
_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"]
|
|
554
749
|
];
|
|
555
750
|
return [
|
|
556
751
|
...corePluginList,
|
|
@@ -563,13 +758,9 @@ function resolvePlugins(context, root) {
|
|
|
563
758
|
function registerPlugins(plugins, context) {
|
|
564
759
|
let variantList = [];
|
|
565
760
|
let variantMap = new Map();
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
components: 0n,
|
|
570
|
-
utilities: 0n,
|
|
571
|
-
user: 0n
|
|
572
|
-
};
|
|
761
|
+
context.variantMap = variantMap;
|
|
762
|
+
let offsets = new _offsets.Offsets();
|
|
763
|
+
context.offsets = offsets;
|
|
573
764
|
let classList = new Set();
|
|
574
765
|
let pluginApi = buildPluginApi(context.tailwindConfig, context, {
|
|
575
766
|
variantList,
|
|
@@ -586,89 +777,53 @@ function registerPlugins(plugins, context) {
|
|
|
586
777
|
plugin === null || plugin === void 0 ? void 0 : plugin(pluginApi);
|
|
587
778
|
}
|
|
588
779
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
)([
|
|
592
|
-
offsets.base,
|
|
593
|
-
offsets.defaults,
|
|
594
|
-
offsets.components,
|
|
595
|
-
offsets.utilities,
|
|
596
|
-
offsets.user,
|
|
597
|
-
]);
|
|
598
|
-
let reservedBits = BigInt(highestOffset.toString(2).length);
|
|
599
|
-
// A number one less than the top range of the highest offset area
|
|
600
|
-
// so arbitrary properties are always sorted at the end.
|
|
601
|
-
context.arbitraryPropertiesSort = (1n << reservedBits << 0n) - 1n;
|
|
602
|
-
context.layerOrder = {
|
|
603
|
-
defaults: 1n << reservedBits << 0n,
|
|
604
|
-
base: 1n << reservedBits << 1n,
|
|
605
|
-
components: 1n << reservedBits << 2n,
|
|
606
|
-
utilities: 1n << reservedBits << 3n,
|
|
607
|
-
user: 1n << reservedBits << 4n
|
|
608
|
-
};
|
|
609
|
-
reservedBits += 5n;
|
|
610
|
-
let offset = 0;
|
|
611
|
-
context.variantOrder = new Map(variantList.map((variant, i)=>{
|
|
612
|
-
let variantFunctions = variantMap.get(variant).length;
|
|
613
|
-
let bits = 1n << BigInt(i + offset) << reservedBits;
|
|
614
|
-
offset += variantFunctions - 1;
|
|
615
|
-
return [
|
|
616
|
-
variant,
|
|
617
|
-
bits
|
|
618
|
-
];
|
|
619
|
-
}).sort(([, a], [, z])=>(0, _bigSign).default(a - z)
|
|
620
|
-
));
|
|
621
|
-
context.minimumScreen = [
|
|
622
|
-
...context.variantOrder.values()
|
|
623
|
-
].shift();
|
|
780
|
+
// Make sure to record bit masks for every variant
|
|
781
|
+
offsets.recordVariants(variantList, (variant)=>variantMap.get(variant).length);
|
|
624
782
|
// Build variantMap
|
|
625
|
-
for (let [variantName,
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
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),
|
|
629
786
|
variantFunction
|
|
630
|
-
]
|
|
631
|
-
));
|
|
787
|
+
]));
|
|
632
788
|
}
|
|
633
|
-
var
|
|
634
|
-
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);
|
|
635
791
|
if (safelist.length > 0) {
|
|
636
792
|
let checks = [];
|
|
637
|
-
for (let
|
|
638
|
-
if (typeof
|
|
793
|
+
for (let value of safelist){
|
|
794
|
+
if (typeof value === "string") {
|
|
639
795
|
context.changedContent.push({
|
|
640
|
-
content:
|
|
641
|
-
extension:
|
|
796
|
+
content: value,
|
|
797
|
+
extension: "html"
|
|
642
798
|
});
|
|
643
799
|
continue;
|
|
644
800
|
}
|
|
645
|
-
if (
|
|
646
|
-
_log.default.warn(
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
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"
|
|
650
806
|
]);
|
|
651
807
|
continue;
|
|
652
808
|
}
|
|
653
|
-
checks.push(
|
|
809
|
+
checks.push(value);
|
|
654
810
|
}
|
|
655
811
|
if (checks.length > 0) {
|
|
656
812
|
let patternMatchingCount = new Map();
|
|
657
813
|
let prefixLength = context.tailwindConfig.prefix.length;
|
|
814
|
+
let checkImportantUtils = checks.some((check)=>check.pattern.source.includes("!"));
|
|
658
815
|
for (let util of classList){
|
|
659
816
|
let utils = Array.isArray(util) ? (()=>{
|
|
660
817
|
let [utilName, options] = util;
|
|
661
|
-
var
|
|
662
|
-
let values = Object.keys((
|
|
663
|
-
let classes = values.map((value)=>(0, _nameClass
|
|
664
|
-
);
|
|
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));
|
|
665
821
|
if (options === null || options === void 0 ? void 0 : options.supportsNegativeValues) {
|
|
666
822
|
// This is the normal negated version
|
|
667
823
|
// e.g. `-inset-1` or `-tw-inset-1`
|
|
668
824
|
classes = [
|
|
669
825
|
...classes,
|
|
670
|
-
...classes.map((cls)=>
|
|
671
|
-
)
|
|
826
|
+
...classes.map((cls)=>"-" + cls)
|
|
672
827
|
];
|
|
673
828
|
// This is the negated version *after* the prefix
|
|
674
829
|
// e.g. `tw--inset-1`
|
|
@@ -676,15 +831,26 @@ function registerPlugins(plugins, context) {
|
|
|
676
831
|
// So we add the negative after the prefix
|
|
677
832
|
classes = [
|
|
678
833
|
...classes,
|
|
679
|
-
...classes.map((cls)=>cls.slice(0, prefixLength) +
|
|
680
|
-
|
|
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)
|
|
681
847
|
];
|
|
682
848
|
}
|
|
683
849
|
return classes;
|
|
684
850
|
})() : [
|
|
685
851
|
util
|
|
686
852
|
];
|
|
687
|
-
for (let
|
|
853
|
+
for (let util of utils){
|
|
688
854
|
for (let { pattern , variants =[] } of checks){
|
|
689
855
|
// RegExp with the /g flag are stateful, so let's reset the last
|
|
690
856
|
// index pointer to reset the state.
|
|
@@ -692,16 +858,16 @@ function registerPlugins(plugins, context) {
|
|
|
692
858
|
if (!patternMatchingCount.has(pattern)) {
|
|
693
859
|
patternMatchingCount.set(pattern, 0);
|
|
694
860
|
}
|
|
695
|
-
if (!pattern.test(
|
|
861
|
+
if (!pattern.test(util)) continue;
|
|
696
862
|
patternMatchingCount.set(pattern, patternMatchingCount.get(pattern) + 1);
|
|
697
863
|
context.changedContent.push({
|
|
698
|
-
content:
|
|
699
|
-
extension:
|
|
864
|
+
content: util,
|
|
865
|
+
extension: "html"
|
|
700
866
|
});
|
|
701
867
|
for (let variant of variants){
|
|
702
868
|
context.changedContent.push({
|
|
703
|
-
content: variant + context.tailwindConfig.separator +
|
|
704
|
-
extension:
|
|
869
|
+
content: variant + context.tailwindConfig.separator + util,
|
|
870
|
+
extension: "html"
|
|
705
871
|
});
|
|
706
872
|
}
|
|
707
873
|
}
|
|
@@ -711,34 +877,54 @@ function registerPlugins(plugins, context) {
|
|
|
711
877
|
if (count !== 0) continue;
|
|
712
878
|
_log.default.warn([
|
|
713
879
|
`The safelist pattern \`${regex}\` doesn't match any Tailwind CSS classes.`,
|
|
714
|
-
|
|
715
|
-
|
|
880
|
+
"Fix this pattern or remove it from your `safelist` configuration.",
|
|
881
|
+
"https://tailwindcss.com/docs/content-configuration#safelisting-classes"
|
|
716
882
|
]);
|
|
717
883
|
}
|
|
718
884
|
}
|
|
719
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";
|
|
720
888
|
// A list of utilities that are used by certain Tailwind CSS utilities but
|
|
721
889
|
// that don't exist on their own. This will result in them "not existing" and
|
|
722
890
|
// sorting could be weird since you still require them in order to make the
|
|
723
|
-
// host
|
|
724
|
-
let parasiteUtilities =
|
|
725
|
-
prefix(context,
|
|
726
|
-
prefix(context,
|
|
727
|
-
|
|
891
|
+
// host utilities work properly. (Thanks Biology)
|
|
892
|
+
let parasiteUtilities = [
|
|
893
|
+
prefix(context, darkClassName),
|
|
894
|
+
prefix(context, "group"),
|
|
895
|
+
prefix(context, "peer")
|
|
896
|
+
];
|
|
728
897
|
context.getClassOrder = function getClassOrder(classes) {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
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++);
|
|
733
918
|
}
|
|
734
919
|
return classes.map((className)=>{
|
|
735
|
-
var
|
|
736
|
-
let order = (
|
|
737
|
-
|
|
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) {
|
|
738
924
|
// This will make sure that it is at the very beginning of the
|
|
739
925
|
// `components` layer which technically means 'before any
|
|
740
926
|
// components'.
|
|
741
|
-
order =
|
|
927
|
+
order = BigInt(parasiteIndex);
|
|
742
928
|
}
|
|
743
929
|
return [
|
|
744
930
|
className,
|
|
@@ -748,17 +934,40 @@ function registerPlugins(plugins, context) {
|
|
|
748
934
|
};
|
|
749
935
|
// Generate a list of strings for autocompletion purposes, e.g.
|
|
750
936
|
// ['uppercase', 'lowercase', ...]
|
|
751
|
-
context.getClassList = function getClassList() {
|
|
937
|
+
context.getClassList = function getClassList(options = {}) {
|
|
752
938
|
let output = [];
|
|
753
939
|
for (let util of classList){
|
|
754
940
|
if (Array.isArray(util)) {
|
|
755
|
-
|
|
941
|
+
var _utilOptions_types;
|
|
942
|
+
let [utilName, utilOptions] = util;
|
|
756
943
|
let negativeClasses = [];
|
|
757
|
-
var
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
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);
|
|
762
971
|
}
|
|
763
972
|
}
|
|
764
973
|
output.push(...negativeClasses);
|
|
@@ -768,32 +977,204 @@ function registerPlugins(plugins, context) {
|
|
|
768
977
|
}
|
|
769
978
|
return output;
|
|
770
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);
|
|
771
1146
|
}
|
|
772
1147
|
function createContext(tailwindConfig, changedContent = [], root = _postcss.default.root()) {
|
|
1148
|
+
var _tailwindConfig_blocklist;
|
|
773
1149
|
let context = {
|
|
774
1150
|
disposables: [],
|
|
775
1151
|
ruleCache: new Set(),
|
|
1152
|
+
candidateRuleCache: new Map(),
|
|
776
1153
|
classCache: new Map(),
|
|
777
1154
|
applyClassCache: new Map(),
|
|
778
|
-
|
|
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 : []),
|
|
779
1157
|
postCssNodeCache: new Map(),
|
|
780
1158
|
candidateRuleMap: new Map(),
|
|
781
1159
|
tailwindConfig,
|
|
782
1160
|
changedContent: changedContent,
|
|
783
1161
|
variantMap: new Map(),
|
|
784
|
-
stylesheetCache: null
|
|
1162
|
+
stylesheetCache: null,
|
|
1163
|
+
variantOptions: new Map(),
|
|
1164
|
+
markInvalidUtilityCandidate: (candidate)=>markInvalidUtilityCandidate(context, candidate),
|
|
1165
|
+
markInvalidUtilityNode: (node)=>markInvalidUtilityNode(context, node)
|
|
785
1166
|
};
|
|
786
1167
|
let resolvedPlugins = resolvePlugins(context, root);
|
|
787
1168
|
registerPlugins(resolvedPlugins, context);
|
|
788
1169
|
return context;
|
|
789
1170
|
}
|
|
790
|
-
let contextMap =
|
|
791
|
-
let configContextMap =
|
|
792
|
-
let contextSourcesMap =
|
|
1171
|
+
let contextMap = _sharedState.contextMap;
|
|
1172
|
+
let configContextMap = _sharedState.configContextMap;
|
|
1173
|
+
let contextSourcesMap = _sharedState.contextSourcesMap;
|
|
793
1174
|
function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies) {
|
|
794
1175
|
let sourcePath = result.opts.from;
|
|
795
1176
|
let isConfigFile = userConfigPath !== null;
|
|
796
|
-
|
|
1177
|
+
_sharedState.env.DEBUG && console.log("Source path:", sourcePath);
|
|
797
1178
|
let existingContext;
|
|
798
1179
|
if (isConfigFile && contextMap.has(sourcePath)) {
|
|
799
1180
|
existingContext = contextMap.get(sourcePath);
|
|
@@ -803,17 +1184,18 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
803
1184
|
contextMap.set(sourcePath, context);
|
|
804
1185
|
existingContext = context;
|
|
805
1186
|
}
|
|
806
|
-
let cssDidChange = (0,
|
|
1187
|
+
let cssDidChange = (0, _cacheInvalidation.hasContentChanged)(sourcePath, root);
|
|
807
1188
|
// If there's already a context in the cache and we don't need to
|
|
808
1189
|
// reset the context, return the cached context.
|
|
809
1190
|
if (existingContext) {
|
|
810
|
-
let contextDependenciesChanged = trackModified([
|
|
1191
|
+
let [contextDependenciesChanged, mtimesToCommit] = trackModified([
|
|
811
1192
|
...contextDependencies
|
|
812
1193
|
], getFileModifiedMap(existingContext));
|
|
813
1194
|
if (!contextDependenciesChanged && !cssDidChange) {
|
|
814
1195
|
return [
|
|
815
1196
|
existingContext,
|
|
816
|
-
false
|
|
1197
|
+
false,
|
|
1198
|
+
mtimesToCommit
|
|
817
1199
|
];
|
|
818
1200
|
}
|
|
819
1201
|
}
|
|
@@ -839,9 +1221,12 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
839
1221
|
}
|
|
840
1222
|
}
|
|
841
1223
|
}
|
|
842
|
-
|
|
1224
|
+
_sharedState.env.DEBUG && console.log("Setting up new context...");
|
|
843
1225
|
let context = createContext(tailwindConfig, [], root);
|
|
844
|
-
|
|
1226
|
+
Object.assign(context, {
|
|
1227
|
+
userConfigPath
|
|
1228
|
+
});
|
|
1229
|
+
let [, mtimesToCommit] = trackModified([
|
|
845
1230
|
...contextDependencies
|
|
846
1231
|
], getFileModifiedMap(context));
|
|
847
1232
|
// ---
|
|
@@ -854,6 +1239,7 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
854
1239
|
contextSourcesMap.get(context).add(sourcePath);
|
|
855
1240
|
return [
|
|
856
1241
|
context,
|
|
857
|
-
true
|
|
1242
|
+
true,
|
|
1243
|
+
mtimesToCommit
|
|
858
1244
|
];
|
|
859
1245
|
}
|