tailwindcss 0.0.0-insiders.fda68f7 → 0.0.0-oxide.6bf5e56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +603 -2
- package/LICENSE +1 -2
- package/README.md +14 -6
- package/colors.d.ts +3 -0
- package/colors.js +2 -304
- package/defaultConfig.d.ts +3 -0
- package/defaultConfig.js +2 -4
- package/defaultTheme.d.ts +4 -0
- package/defaultTheme.js +2 -4
- package/lib/cli/build/deps.js +54 -0
- package/lib/cli/build/index.js +48 -0
- package/lib/cli/build/plugin.js +367 -0
- package/lib/cli/build/utils.js +78 -0
- package/lib/cli/build/watching.js +178 -0
- package/lib/cli/help/index.js +71 -0
- package/lib/cli/index.js +18 -0
- package/lib/cli/init/index.js +46 -0
- package/lib/cli/shared.js +13 -0
- package/lib/cli-peer-dependencies.js +22 -14
- package/lib/cli.js +217 -743
- package/lib/constants.js +41 -34
- package/lib/corePluginList.js +178 -5
- package/lib/corePlugins.js +3879 -2941
- package/lib/css/preflight.css +22 -9
- package/lib/featureFlags.js +61 -50
- package/lib/index.js +45 -28
- package/lib/lib/cacheInvalidation.js +90 -0
- package/lib/lib/collapseAdjacentRules.js +52 -36
- package/lib/lib/collapseDuplicateDeclarations.js +83 -0
- package/lib/lib/content.js +176 -0
- package/lib/lib/defaultExtractor.js +236 -0
- package/lib/lib/detectNesting.js +37 -0
- package/lib/lib/evaluateTailwindFunctions.js +203 -161
- package/lib/lib/expandApplyAtRules.js +502 -221
- package/lib/lib/expandTailwindAtRules.js +258 -243
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +775 -320
- package/lib/lib/getModuleDependencies.js +44 -46
- package/lib/lib/normalizeTailwindDirectives.js +79 -60
- package/lib/lib/offsets.js +217 -0
- package/lib/lib/partitionApplyAtRules.js +56 -0
- package/lib/lib/regex.js +60 -0
- package/lib/lib/resolveDefaultsAtRules.js +150 -94
- package/lib/lib/setupContextUtils.js +1146 -599
- package/lib/lib/setupTrackingContext.js +129 -177
- package/lib/lib/sharedState.js +53 -21
- package/lib/lib/substituteScreenAtRules.js +26 -28
- package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +19 -0
- package/lib/postcss-plugins/nesting/plugin.js +87 -0
- package/lib/processTailwindFeatures.js +58 -53
- package/lib/public/colors.js +331 -0
- package/lib/public/create-plugin.js +15 -0
- package/lib/public/default-config.js +16 -0
- package/lib/public/default-theme.js +16 -0
- package/lib/public/resolve-config.js +22 -0
- package/lib/util/bigSign.js +7 -6
- package/lib/util/buildMediaQuery.js +21 -32
- package/lib/util/cloneDeep.js +16 -14
- package/lib/util/cloneNodes.js +29 -15
- package/lib/util/color.js +90 -66
- package/lib/util/configurePlugins.js +17 -15
- package/lib/util/createPlugin.js +23 -26
- package/lib/util/createUtilityPlugin.js +46 -46
- package/lib/util/dataTypes.js +242 -0
- package/lib/util/defaults.js +20 -15
- package/lib/util/escapeClassName.js +18 -17
- package/lib/util/escapeCommas.js +7 -6
- package/lib/util/flattenColorPalette.js +13 -12
- package/lib/util/formatVariantSelector.js +285 -0
- package/lib/util/getAllConfigs.js +44 -18
- package/lib/util/hashConfig.js +15 -12
- package/lib/util/isKeyframeRule.js +7 -6
- package/lib/util/isPlainObject.js +11 -11
- package/lib/util/isSyntacticallyValidPropertyValue.js +72 -0
- package/lib/util/log.js +52 -33
- package/lib/util/nameClass.js +37 -26
- package/lib/util/negateValue.js +31 -17
- package/lib/util/normalizeConfig.js +281 -0
- package/lib/util/normalizeScreens.js +170 -0
- package/lib/util/parseAnimationValue.js +85 -54
- package/lib/util/parseBoxShadowValue.js +84 -0
- package/lib/util/parseDependency.js +41 -70
- package/lib/util/parseGlob.js +34 -0
- package/lib/util/parseObjectStyles.js +30 -24
- package/lib/util/pluginUtils.js +252 -287
- package/lib/util/prefixSelector.js +20 -20
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +221 -256
- package/lib/util/resolveConfigPath.js +43 -48
- package/lib/util/responsive.js +18 -14
- package/lib/util/splitAtTopLevelOnly.js +43 -0
- package/lib/util/tap.js +8 -7
- package/lib/util/toColorValue.js +7 -6
- package/lib/util/toPath.js +27 -8
- package/lib/util/transformThemeValue.js +67 -28
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/validateFormalSyntax.js +24 -0
- package/lib/util/withAlphaVariable.js +67 -57
- package/nesting/index.js +2 -12
- package/package.json +60 -65
- package/peers/index.js +76445 -84221
- package/plugin.d.ts +11 -0
- package/plugin.js +1 -2
- package/resolveConfig.d.ts +12 -0
- package/resolveConfig.js +2 -7
- package/scripts/create-plugin-list.js +2 -2
- 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/deps.js +56 -0
- package/src/cli/build/index.js +49 -0
- package/src/cli/build/plugin.js +439 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +227 -0
- package/src/cli/help/index.js +70 -0
- package/src/cli/index.js +3 -0
- package/src/cli/init/index.js +50 -0
- package/src/cli/shared.js +6 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +50 -575
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +2405 -1948
- package/src/css/preflight.css +22 -9
- package/src/featureFlags.js +26 -10
- package/src/index.js +19 -6
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/collapseDuplicateDeclarations.js +93 -0
- package/src/lib/content.js +212 -0
- package/src/lib/defaultExtractor.js +211 -0
- package/src/lib/detectNesting.js +39 -0
- package/src/lib/evaluateTailwindFunctions.js +84 -10
- package/src/lib/expandApplyAtRules.js +508 -153
- package/src/lib/expandTailwindAtRules.js +130 -104
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +596 -70
- package/src/lib/normalizeTailwindDirectives.js +10 -3
- package/src/lib/offsets.js +270 -0
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +105 -47
- package/src/lib/setupContextUtils.js +828 -196
- package/src/lib/setupTrackingContext.js +19 -54
- package/src/lib/sharedState.js +45 -7
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/postcss-plugins/nesting/README.md +42 -0
- package/src/postcss-plugins/nesting/index.js +13 -0
- package/src/postcss-plugins/nesting/plugin.js +80 -0
- package/src/processTailwindFeatures.js +19 -2
- package/src/public/colors.js +300 -0
- package/src/public/create-plugin.js +2 -0
- package/src/public/default-config.js +4 -0
- package/src/public/default-theme.js +4 -0
- package/src/public/resolve-config.js +7 -0
- package/src/util/buildMediaQuery.js +14 -16
- package/src/util/cloneNodes.js +19 -2
- package/src/util/color.js +31 -14
- package/src/util/createUtilityPlugin.js +2 -11
- package/src/util/dataTypes.js +256 -0
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +319 -0
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/isSyntacticallyValidPropertyValue.js +61 -0
- package/src/util/log.js +23 -22
- package/src/util/nameClass.js +14 -6
- package/src/util/negateValue.js +15 -5
- package/src/util/normalizeConfig.js +300 -0
- package/src/util/normalizeScreens.js +140 -0
- package/src/util/parseAnimationValue.js +7 -1
- package/src/util/parseBoxShadowValue.js +72 -0
- package/src/util/parseDependency.js +37 -38
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +216 -197
- package/src/util/prefixSelector.js +7 -8
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +86 -91
- package/src/util/splitAtTopLevelOnly.js +45 -0
- package/src/util/toPath.js +23 -1
- package/src/util/transformThemeValue.js +33 -8
- package/src/util/validateConfig.js +13 -0
- package/src/util/validateFormalSyntax.js +34 -0
- package/src/util/withAlphaVariable.js +14 -9
- package/stubs/defaultConfig.stub.js +186 -117
- package/stubs/simpleConfig.stub.js +1 -1
- package/types/config.d.ts +362 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/generated/default-theme.d.ts +342 -0
- package/types/index.d.ts +7 -0
- package/lib/lib/setupWatchingContext.js +0 -331
- package/nesting/plugin.js +0 -41
- package/src/lib/setupWatchingContext.js +0 -306
|
@@ -1,190 +1,142 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var _parseDependency = _interopRequireDefault(require("../util/parseDependency"));
|
|
31
|
-
|
|
32
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
|
-
|
|
5
|
+
Object.defineProperty(exports, // DISABLE_TOUCH = TRUE
|
|
6
|
+
// Retrieve an existing context from cache if possible (since contexts are unique per
|
|
7
|
+
// source path), or set up a new one (including setting up watchers and registering
|
|
8
|
+
// plugins) then return it
|
|
9
|
+
"default", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: ()=>setupTrackingContext
|
|
12
|
+
});
|
|
13
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
14
|
+
const _quickLru = /*#__PURE__*/ _interopRequireDefault(require("quick-lru"));
|
|
15
|
+
const _hashConfig = /*#__PURE__*/ _interopRequireDefault(require("../util/hashConfig"));
|
|
16
|
+
const _getModuleDependencies = /*#__PURE__*/ _interopRequireDefault(require("../lib/getModuleDependencies"));
|
|
17
|
+
const _resolveConfig = /*#__PURE__*/ _interopRequireDefault(require("../public/resolve-config"));
|
|
18
|
+
const _resolveConfigPath = /*#__PURE__*/ _interopRequireDefault(require("../util/resolveConfigPath"));
|
|
19
|
+
const _setupContextUtils = require("./setupContextUtils");
|
|
20
|
+
const _parseDependency = /*#__PURE__*/ _interopRequireDefault(require("../util/parseDependency"));
|
|
21
|
+
const _validateConfigJs = require("../util/validateConfig.js");
|
|
22
|
+
const _contentJs = require("./content.js");
|
|
23
|
+
function _interopRequireDefault(obj) {
|
|
24
|
+
return obj && obj.__esModule ? obj : {
|
|
25
|
+
default: obj
|
|
26
|
+
};
|
|
27
|
+
}
|
|
34
28
|
let configPathCache = new _quickLru.default({
|
|
35
|
-
|
|
29
|
+
maxSize: 100
|
|
36
30
|
});
|
|
37
31
|
let candidateFilesCache = new WeakMap();
|
|
38
|
-
|
|
39
32
|
function getCandidateFiles(context, tailwindConfig) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
let candidateFiles = tailwindConfig.content.content.filter(item => typeof item === 'string').map(contentPath => (0, _normalizePath.default)(_path.default.resolve(contentPath)));
|
|
45
|
-
return candidateFilesCache.set(context, candidateFiles).get(context);
|
|
46
|
-
} // Get the config object based on a path
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
function getTailwindConfig(configOrPath) {
|
|
50
|
-
let userConfigPath = (0, _resolveConfigPath.default)(configOrPath);
|
|
51
|
-
|
|
52
|
-
if (userConfigPath !== null) {
|
|
53
|
-
let [prevConfig, prevConfigHash, prevDeps, prevModified] = configPathCache.get(userConfigPath) || [];
|
|
54
|
-
let newDeps = (0, _getModuleDependencies.default)(userConfigPath).map(dep => dep.file);
|
|
55
|
-
let modified = false;
|
|
56
|
-
let newModified = new Map();
|
|
57
|
-
|
|
58
|
-
for (let file of newDeps) {
|
|
59
|
-
let time = _fs.default.statSync(file).mtimeMs;
|
|
60
|
-
|
|
61
|
-
newModified.set(file, time);
|
|
62
|
-
|
|
63
|
-
if (!prevModified || !prevModified.has(file) || time > prevModified.get(file)) {
|
|
64
|
-
modified = true;
|
|
65
|
-
}
|
|
66
|
-
} // It hasn't changed (based on timestamps)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (!modified) {
|
|
70
|
-
return [prevConfig, userConfigPath, prevConfigHash, prevDeps];
|
|
71
|
-
} // It has changed (based on timestamps), or first run
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
for (let file of newDeps) {
|
|
75
|
-
delete require.cache[file];
|
|
33
|
+
if (candidateFilesCache.has(context)) {
|
|
34
|
+
return candidateFilesCache.get(context);
|
|
76
35
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
let newHash = (0, _hashConfig.default)(newConfig);
|
|
80
|
-
configPathCache.set(userConfigPath, [newConfig, newHash, newDeps, newModified]);
|
|
81
|
-
return [newConfig, userConfigPath, newHash, newDeps];
|
|
82
|
-
} // It's a plain object, not a path
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
let newConfig = (0, _resolveConfig.default)(configOrPath.config === undefined ? configOrPath : configOrPath.config);
|
|
86
|
-
return [newConfig, null, (0, _hashConfig.default)(newConfig), []];
|
|
36
|
+
let candidateFiles = (0, _contentJs.parseCandidateFiles)(context, tailwindConfig);
|
|
37
|
+
return candidateFilesCache.set(context, candidateFiles).get(context);
|
|
87
38
|
}
|
|
88
|
-
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
changedContent.push({
|
|
104
|
-
content,
|
|
105
|
-
extension
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return changedContent;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function resolveChangedFiles(candidateFiles, fileModifiedMap) {
|
|
113
|
-
let changedFiles = new Set();
|
|
114
|
-
_sharedState.env.DEBUG && console.time('Finding changed files');
|
|
115
|
-
|
|
116
|
-
let files = _fastGlob.default.sync(candidateFiles);
|
|
117
|
-
|
|
118
|
-
for (let file of files) {
|
|
119
|
-
let prevModified = fileModifiedMap.has(file) ? fileModifiedMap.get(file) : -Infinity;
|
|
120
|
-
|
|
121
|
-
let modified = _fs.default.statSync(file).mtimeMs;
|
|
122
|
-
|
|
123
|
-
if (modified > prevModified) {
|
|
124
|
-
changedFiles.add(file);
|
|
125
|
-
fileModifiedMap.set(file, modified);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
_sharedState.env.DEBUG && console.timeEnd('Finding changed files');
|
|
130
|
-
return changedFiles;
|
|
131
|
-
} // DISABLE_TOUCH = TRUE
|
|
132
|
-
// Retrieve an existing context from cache if possible (since contexts are unique per
|
|
133
|
-
// source path), or set up a new one (including setting up watchers and registering
|
|
134
|
-
// plugins) then return it
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
function setupTrackingContext(configOrPath) {
|
|
138
|
-
return ({
|
|
139
|
-
tailwindDirectives,
|
|
140
|
-
registerDependency
|
|
141
|
-
}) => {
|
|
142
|
-
return (root, result) => {
|
|
143
|
-
let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] = getTailwindConfig(configOrPath);
|
|
144
|
-
let contextDependencies = new Set(configDependencies); // If there are no @tailwind rules, we don't consider this CSS file or it's dependencies
|
|
145
|
-
// to be dependencies of the context. Can reuse the context even if they change.
|
|
146
|
-
// We may want to think about `@layer` being part of this trigger too, but it's tough
|
|
147
|
-
// because it's impossible for a layer in one file to end up in the actual @tailwind rule
|
|
148
|
-
// in another file since independent sources are effectively isolated.
|
|
149
|
-
|
|
150
|
-
if (tailwindDirectives.size > 0) {
|
|
151
|
-
// Add current css file as a context dependencies.
|
|
152
|
-
contextDependencies.add(result.opts.from); // Add all css @import dependencies as context dependencies.
|
|
153
|
-
|
|
154
|
-
for (let message of result.messages) {
|
|
155
|
-
if (message.type === 'dependency') {
|
|
156
|
-
contextDependencies.add(message.file);
|
|
157
|
-
}
|
|
39
|
+
// Get the config object based on a path
|
|
40
|
+
function getTailwindConfig(configOrPath) {
|
|
41
|
+
let userConfigPath = (0, _resolveConfigPath.default)(configOrPath);
|
|
42
|
+
if (userConfigPath !== null) {
|
|
43
|
+
let [prevConfig, prevConfigHash, prevDeps, prevModified] = configPathCache.get(userConfigPath) || [];
|
|
44
|
+
let newDeps = (0, _getModuleDependencies.default)(userConfigPath).map((dep)=>dep.file);
|
|
45
|
+
let modified = false;
|
|
46
|
+
let newModified = new Map();
|
|
47
|
+
for (let file of newDeps){
|
|
48
|
+
let time = _fs.default.statSync(file).mtimeMs;
|
|
49
|
+
newModified.set(file, time);
|
|
50
|
+
if (!prevModified || !prevModified.has(file) || time > prevModified.get(file)) {
|
|
51
|
+
modified = true;
|
|
52
|
+
}
|
|
158
53
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (tailwindDirectives.size > 0) {
|
|
169
|
-
let fileModifiedMap = (0, _setupContextUtils.getFileModifiedMap)(context); // Add template paths as postcss dependencies.
|
|
170
|
-
|
|
171
|
-
for (let fileOrGlob of candidateFiles) {
|
|
172
|
-
registerDependency((0, _parseDependency.default)(fileOrGlob));
|
|
54
|
+
// It hasn't changed (based on timestamps)
|
|
55
|
+
if (!modified) {
|
|
56
|
+
return [
|
|
57
|
+
prevConfig,
|
|
58
|
+
userConfigPath,
|
|
59
|
+
prevConfigHash,
|
|
60
|
+
prevDeps
|
|
61
|
+
];
|
|
173
62
|
}
|
|
174
|
-
|
|
175
|
-
for (let
|
|
176
|
-
|
|
63
|
+
// It has changed (based on timestamps), or first run
|
|
64
|
+
for (let file1 of newDeps){
|
|
65
|
+
delete require.cache[file1];
|
|
177
66
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
67
|
+
let newConfig = (0, _resolveConfig.default)(require(userConfigPath));
|
|
68
|
+
newConfig = (0, _validateConfigJs.validateConfig)(newConfig);
|
|
69
|
+
let newHash = (0, _hashConfig.default)(newConfig);
|
|
70
|
+
configPathCache.set(userConfigPath, [
|
|
71
|
+
newConfig,
|
|
72
|
+
newHash,
|
|
73
|
+
newDeps,
|
|
74
|
+
newModified
|
|
75
|
+
]);
|
|
76
|
+
return [
|
|
77
|
+
newConfig,
|
|
78
|
+
userConfigPath,
|
|
79
|
+
newHash,
|
|
80
|
+
newDeps
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
// It's a plain object, not a path
|
|
84
|
+
let newConfig1 = (0, _resolveConfig.default)(configOrPath.config === undefined ? configOrPath : configOrPath.config);
|
|
85
|
+
newConfig1 = (0, _validateConfigJs.validateConfig)(newConfig1);
|
|
86
|
+
return [
|
|
87
|
+
newConfig1,
|
|
88
|
+
null,
|
|
89
|
+
(0, _hashConfig.default)(newConfig1),
|
|
90
|
+
[]
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
function setupTrackingContext(configOrPath) {
|
|
94
|
+
return ({ tailwindDirectives , registerDependency })=>{
|
|
95
|
+
return (root, result)=>{
|
|
96
|
+
let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] = getTailwindConfig(configOrPath);
|
|
97
|
+
let contextDependencies = new Set(configDependencies);
|
|
98
|
+
// If there are no @tailwind or @apply rules, we don't consider this CSS
|
|
99
|
+
// file or its dependencies to be dependencies of the context. Can reuse
|
|
100
|
+
// the context even if they change. We may want to think about `@layer`
|
|
101
|
+
// being part of this trigger too, but it's tough because it's impossible
|
|
102
|
+
// for a layer in one file to end up in the actual @tailwind rule in
|
|
103
|
+
// another file since independent sources are effectively isolated.
|
|
104
|
+
if (tailwindDirectives.size > 0) {
|
|
105
|
+
// Add current css file as a context dependencies.
|
|
106
|
+
contextDependencies.add(result.opts.from);
|
|
107
|
+
// Add all css @import dependencies as context dependencies.
|
|
108
|
+
for (let message of result.messages){
|
|
109
|
+
if (message.type === "dependency") {
|
|
110
|
+
contextDependencies.add(message.file);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
let [context] = (0, _setupContextUtils.getContext)(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
|
|
115
|
+
let candidateFiles = getCandidateFiles(context, tailwindConfig);
|
|
116
|
+
// If there are no @tailwind or @apply rules, we don't consider this CSS file or it's
|
|
117
|
+
// dependencies to be dependencies of the context. Can reuse the context even if they change.
|
|
118
|
+
// We may want to think about `@layer` being part of this trigger too, but it's tough
|
|
119
|
+
// because it's impossible for a layer in one file to end up in the actual @tailwind rule
|
|
120
|
+
// in another file since independent sources are effectively isolated.
|
|
121
|
+
if (tailwindDirectives.size > 0) {
|
|
122
|
+
let fileModifiedMap = (0, _setupContextUtils.getFileModifiedMap)(context);
|
|
123
|
+
// Add template paths as postcss dependencies.
|
|
124
|
+
for (let contentPath of candidateFiles){
|
|
125
|
+
for (let dependency of (0, _parseDependency.default)(contentPath)){
|
|
126
|
+
registerDependency(dependency);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
for (let changedContent of (0, _contentJs.resolvedChangedContent)(context, candidateFiles, fileModifiedMap)){
|
|
130
|
+
context.changedContent.push(changedContent);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
for (let file of configDependencies){
|
|
134
|
+
registerDependency({
|
|
135
|
+
type: "dependency",
|
|
136
|
+
file
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return context;
|
|
140
|
+
};
|
|
188
141
|
};
|
|
189
|
-
|
|
190
|
-
}
|
|
142
|
+
}
|
package/lib/lib/sharedState.js
CHANGED
|
@@ -1,29 +1,61 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
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
|
+
env: ()=>env,
|
|
13
|
+
contextMap: ()=>contextMap,
|
|
14
|
+
configContextMap: ()=>configContextMap,
|
|
15
|
+
contextSourcesMap: ()=>contextSourcesMap,
|
|
16
|
+
sourceHashMap: ()=>sourceHashMap,
|
|
17
|
+
NOT_ON_DEMAND: ()=>NOT_ON_DEMAND,
|
|
18
|
+
NONE: ()=>NONE,
|
|
19
|
+
resolveDebug: ()=>resolveDebug
|
|
5
20
|
});
|
|
6
|
-
exports.contentMatchCache = exports.contextSourcesMap = exports.configContextMap = exports.contextMap = exports.env = void 0;
|
|
7
|
-
|
|
8
|
-
var _quickLru = _interopRequireDefault(require("quick-lru"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
21
|
const env = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
TAILWIND_DISABLE_TOUCH: process.env.TAILWIND_DISABLE_TOUCH !== undefined,
|
|
17
|
-
TAILWIND_TOUCH_DIR: process.env.TAILWIND_TOUCH_DIR
|
|
22
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
23
|
+
DEBUG: resolveDebug(process.env.DEBUG),
|
|
24
|
+
OXIDE: process.env.OXIDE
|
|
18
25
|
};
|
|
19
|
-
exports.env = env;
|
|
20
26
|
const contextMap = new Map();
|
|
21
|
-
exports.contextMap = contextMap;
|
|
22
27
|
const configContextMap = new Map();
|
|
23
|
-
exports.configContextMap = configContextMap;
|
|
24
28
|
const contextSourcesMap = new Map();
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
const sourceHashMap = new Map();
|
|
30
|
+
const NOT_ON_DEMAND = new String("*");
|
|
31
|
+
const NONE = Symbol("__NONE__");
|
|
32
|
+
function resolveDebug(debug) {
|
|
33
|
+
if (debug === undefined) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
// Environment variables are strings, so convert to boolean
|
|
37
|
+
if (debug === "true" || debug === "1") {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (debug === "false" || debug === "0") {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
// Keep the debug convention into account:
|
|
44
|
+
// DEBUG=* -> This enables all debug modes
|
|
45
|
+
// DEBUG=projectA,projectB,projectC -> This enables debug for projectA, projectB and projectC
|
|
46
|
+
// DEBUG=projectA:* -> This enables all debug modes for projectA (if you have sub-types)
|
|
47
|
+
// DEBUG=projectA,-projectB -> This enables debug for projectA and explicitly disables it for projectB
|
|
48
|
+
if (debug === "*") {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
let debuggers = debug.split(",").map((d)=>d.split(":")[0]);
|
|
52
|
+
// Ignoring tailwindcss
|
|
53
|
+
if (debuggers.includes("-tailwindcss")) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
// Including tailwindcss
|
|
57
|
+
if (debuggers.includes("tailwindcss")) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
css
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
}
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>_default
|
|
8
|
+
});
|
|
9
|
+
const _normalizeScreens = require("../util/normalizeScreens");
|
|
10
|
+
const _buildMediaQuery = /*#__PURE__*/ _interopRequireDefault(require("../util/buildMediaQuery"));
|
|
11
|
+
function _interopRequireDefault(obj) {
|
|
12
|
+
return obj && obj.__esModule ? obj : {
|
|
13
|
+
default: obj
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function _default({ tailwindConfig: { theme } }) {
|
|
17
|
+
return function(css) {
|
|
18
|
+
css.walkAtRules("screen", (atRule)=>{
|
|
19
|
+
let screen = atRule.params;
|
|
20
|
+
let screens = (0, _normalizeScreens.normalizeScreens)(theme.screens);
|
|
21
|
+
let screenDefinition = screens.find(({ name })=>name === screen);
|
|
22
|
+
if (!screenDefinition) {
|
|
23
|
+
throw atRule.error(`No \`${screen}\` screen found.`);
|
|
24
|
+
}
|
|
25
|
+
atRule.name = "media";
|
|
26
|
+
atRule.params = (0, _buildMediaQuery.default)(screenDefinition);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# tailwindcss/nesting
|
|
2
2
|
|
|
3
|
-
This is a PostCSS plugin that wraps [postcss-nested](https://github.com/postcss/postcss-nested) or [postcss-nesting](https://github.com/
|
|
3
|
+
This is a PostCSS plugin that wraps [postcss-nested](https://github.com/postcss/postcss-nested) or [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting) and acts as a compatibility layer to make sure your nesting plugin of choice properly understands Tailwind's custom syntax like `@apply` and `@screen`.
|
|
4
4
|
|
|
5
5
|
Add it to your PostCSS configuration, somewhere before Tailwind itself:
|
|
6
6
|
|
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
|
18
18
|
|
|
19
19
|
By default, it uses the [postcss-nested](https://github.com/postcss/postcss-nested) plugin under the hood, which uses a Sass-like syntax and is the plugin that powers nesting support in the [Tailwind CSS plugin API](https://tailwindcss.com/docs/plugins#css-in-js-syntax).
|
|
20
20
|
|
|
21
|
-
If you'd rather use [postcss-nesting](https://github.com/
|
|
21
|
+
If you'd rather use [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting) (which is based on the work-in-progress [CSS Nesting](https://drafts.csswg.org/css-nesting-1/) specification), first install the plugin alongside:
|
|
22
22
|
|
|
23
23
|
```shell
|
|
24
24
|
npm install postcss-nesting
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>_default
|
|
8
|
+
});
|
|
9
|
+
const _plugin = require("./plugin");
|
|
10
|
+
const _default = Object.assign(function(opts) {
|
|
11
|
+
return {
|
|
12
|
+
postcssPlugin: "tailwindcss/nesting",
|
|
13
|
+
Once (root, { result }) {
|
|
14
|
+
return (0, _plugin.nesting)(opts)(root, result);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}, {
|
|
18
|
+
postcss: true
|
|
19
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "nesting", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>nesting
|
|
8
|
+
});
|
|
9
|
+
const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
|
|
10
|
+
const _postcssNested = /*#__PURE__*/ _interopRequireDefault(require("postcss-nested"));
|
|
11
|
+
function _interopRequireDefault(obj) {
|
|
12
|
+
return obj && obj.__esModule ? obj : {
|
|
13
|
+
default: obj
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function nesting(opts = _postcssNested.default) {
|
|
17
|
+
return (root, result)=>{
|
|
18
|
+
root.walkAtRules("screen", (rule)=>{
|
|
19
|
+
rule.name = "media";
|
|
20
|
+
rule.params = `screen(${rule.params})`;
|
|
21
|
+
});
|
|
22
|
+
root.walkAtRules("apply", (rule)=>{
|
|
23
|
+
rule.before(_postcss.default.decl({
|
|
24
|
+
prop: "__apply",
|
|
25
|
+
value: rule.params,
|
|
26
|
+
source: rule.source
|
|
27
|
+
}));
|
|
28
|
+
rule.remove();
|
|
29
|
+
});
|
|
30
|
+
let plugin = (()=>{
|
|
31
|
+
var ref;
|
|
32
|
+
if (typeof opts === "function" || typeof opts === "object" && (opts === null || opts === void 0 ? void 0 : (ref = opts.hasOwnProperty) === null || ref === void 0 ? void 0 : ref.call(opts, "postcssPlugin"))) {
|
|
33
|
+
return opts;
|
|
34
|
+
}
|
|
35
|
+
if (typeof opts === "string") {
|
|
36
|
+
return require(opts);
|
|
37
|
+
}
|
|
38
|
+
if (Object.keys(opts).length <= 0) {
|
|
39
|
+
return _postcssNested.default;
|
|
40
|
+
}
|
|
41
|
+
throw new Error("tailwindcss/nesting should be loaded with a nesting plugin.");
|
|
42
|
+
})();
|
|
43
|
+
(0, _postcss.default)([
|
|
44
|
+
plugin
|
|
45
|
+
]).process(root, result.opts).sync();
|
|
46
|
+
root.walkDecls("__apply", (decl)=>{
|
|
47
|
+
decl.before(_postcss.default.atRule({
|
|
48
|
+
name: "apply",
|
|
49
|
+
params: decl.value,
|
|
50
|
+
source: decl.source
|
|
51
|
+
}));
|
|
52
|
+
decl.remove();
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Use a private PostCSS API to remove the "clean" flag from the entire AST.
|
|
56
|
+
* This is done because running process() on the AST will set the "clean"
|
|
57
|
+
* flag on all nodes, which we don't want.
|
|
58
|
+
*
|
|
59
|
+
* This causes downstream plugins using the visitor API to be skipped.
|
|
60
|
+
*
|
|
61
|
+
* This is guarded because the PostCSS API is not public
|
|
62
|
+
* and may change in future versions of PostCSS.
|
|
63
|
+
*
|
|
64
|
+
* See https://github.com/postcss/postcss/issues/1712 for more details
|
|
65
|
+
*
|
|
66
|
+
* @param {import('postcss').Node} node
|
|
67
|
+
*/ function markDirty(node) {
|
|
68
|
+
if (!("markDirty" in node)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// Traverse the tree down to the leaf nodes
|
|
72
|
+
if (node.nodes) {
|
|
73
|
+
node.nodes.forEach((n)=>markDirty(n));
|
|
74
|
+
}
|
|
75
|
+
// If it's a leaf node mark it as dirty
|
|
76
|
+
// We do this here because marking a node as dirty
|
|
77
|
+
// will walk up the tree and mark all parents as dirty
|
|
78
|
+
// resulting in a lot of unnecessary work if we did this
|
|
79
|
+
// for every single node
|
|
80
|
+
if (!node.nodes) {
|
|
81
|
+
node.markDirty();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
markDirty(root);
|
|
85
|
+
return root;
|
|
86
|
+
};
|
|
87
|
+
}
|