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