tailwindcss 0.0.0-insiders.df011dc → 0.0.0-insiders.e2d5f21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +106 -1
- package/README.md +1 -1
- package/colors.js +1 -304
- package/defaultConfig.js +1 -4
- package/defaultTheme.js +1 -4
- package/lib/cli-peer-dependencies.js +4 -9
- package/lib/cli.js +646 -705
- package/lib/constants.js +15 -15
- package/lib/corePluginList.js +174 -4
- package/lib/corePlugins.js +3637 -2934
- package/lib/css/preflight.css +14 -1
- package/lib/featureFlags.js +44 -44
- package/lib/index.js +25 -24
- package/lib/lib/collapseAdjacentRules.js +33 -35
- package/lib/lib/collapseDuplicateDeclarations.js +29 -0
- package/lib/lib/detectNesting.js +34 -0
- package/lib/lib/evaluateTailwindFunctions.js +134 -155
- package/lib/lib/expandApplyAtRules.js +183 -200
- package/lib/lib/expandTailwindAtRules.js +219 -232
- package/lib/lib/generateRules.js +478 -311
- package/lib/lib/getModuleDependencies.js +36 -41
- package/lib/lib/normalizeTailwindDirectives.js +66 -58
- package/lib/lib/resolveDefaultsAtRules.js +110 -90
- package/lib/lib/setupContextUtils.js +740 -580
- package/lib/lib/setupTrackingContext.js +142 -162
- package/lib/lib/setupWatchingContext.js +235 -278
- package/lib/lib/sharedState.js +7 -17
- package/lib/lib/substituteScreenAtRules.js +22 -26
- package/lib/processTailwindFeatures.js +38 -44
- package/lib/public/colors.js +329 -0
- package/lib/public/create-plugin.js +13 -0
- package/lib/public/default-config.js +14 -0
- package/lib/public/default-theme.js +14 -0
- package/lib/public/resolve-config.js +19 -0
- package/lib/util/bigSign.js +3 -5
- package/lib/util/buildMediaQuery.js +15 -31
- package/lib/util/cloneDeep.js +14 -13
- package/lib/util/cloneNodes.js +9 -13
- package/lib/util/color.js +69 -59
- package/lib/util/configurePlugins.js +13 -14
- package/lib/util/createPlugin.js +21 -24
- package/lib/util/createUtilityPlugin.js +47 -45
- package/lib/util/dataTypes.js +231 -0
- package/lib/util/defaults.js +10 -14
- package/lib/util/escapeClassName.js +12 -14
- package/lib/util/escapeCommas.js +3 -5
- package/lib/util/flattenColorPalette.js +14 -10
- package/lib/util/formatVariantSelector.js +186 -0
- package/lib/util/getAllConfigs.js +23 -16
- package/lib/util/hashConfig.js +10 -10
- package/lib/util/isKeyframeRule.js +3 -5
- package/lib/util/isPlainObject.js +7 -10
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/log.js +39 -30
- package/lib/util/nameClass.js +23 -23
- package/lib/util/negateValue.js +14 -15
- package/lib/util/normalizeConfig.js +208 -0
- package/lib/util/normalizeScreens.js +58 -0
- package/lib/util/parseAnimationValue.js +82 -53
- package/lib/util/parseBoxShadowValue.js +77 -0
- package/lib/util/parseDependency.js +49 -60
- package/lib/util/parseObjectStyles.js +23 -20
- package/lib/util/pluginUtils.js +153 -285
- package/lib/util/prefixSelector.js +14 -16
- package/lib/util/resolveConfig.js +194 -249
- package/lib/util/resolveConfigPath.js +38 -45
- package/lib/util/responsive.js +12 -11
- package/lib/util/tap.js +4 -6
- package/lib/util/toColorValue.js +4 -5
- package/lib/util/toPath.js +4 -6
- package/lib/util/transformThemeValue.js +57 -26
- package/lib/util/withAlphaVariable.js +56 -54
- package/package.json +27 -37
- package/peers/index.js +73099 -84294
- package/plugin.js +1 -3
- package/resolveConfig.js +1 -7
- package/scripts/create-plugin-list.js +2 -2
- package/src/cli.js +27 -18
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +2124 -1968
- package/src/css/preflight.css +14 -1
- package/src/featureFlags.js +12 -6
- package/src/lib/collapseDuplicateDeclarations.js +28 -0
- package/src/lib/detectNesting.js +39 -0
- package/src/lib/evaluateTailwindFunctions.js +5 -2
- package/src/lib/expandTailwindAtRules.js +24 -32
- package/src/lib/generateRules.js +230 -20
- package/src/lib/normalizeTailwindDirectives.js +3 -2
- package/src/lib/resolveDefaultsAtRules.js +46 -30
- package/src/lib/setupContextUtils.js +275 -113
- package/src/lib/setupTrackingContext.js +9 -8
- package/src/lib/setupWatchingContext.js +12 -7
- package/src/lib/sharedState.js +1 -4
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/processTailwindFeatures.js +8 -1
- package/src/public/colors.js +300 -0
- package/src/public/create-plugin.js +2 -0
- package/src/public/default-config.js +4 -0
- package/src/public/default-theme.js +4 -0
- package/src/public/resolve-config.js +7 -0
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/createUtilityPlugin.js +2 -11
- package/src/util/dataTypes.js +246 -0
- package/src/util/formatVariantSelector.js +196 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +18 -21
- package/src/util/nameClass.js +10 -6
- package/src/util/negateValue.js +4 -2
- package/src/util/normalizeConfig.js +249 -0
- package/src/util/normalizeScreens.js +42 -0
- package/src/util/parseAnimationValue.js +7 -1
- package/src/util/parseBoxShadowValue.js +71 -0
- package/src/util/parseDependency.js +4 -0
- package/src/util/pluginUtils.js +101 -204
- package/src/util/prefixSelector.js +1 -4
- package/src/util/resolveConfig.js +12 -65
- package/src/util/transformThemeValue.js +22 -7
- package/src/util/withAlphaVariable.js +13 -8
- package/stubs/defaultConfig.stub.js +163 -97
- package/stubs/simpleConfig.stub.js +0 -1
|
@@ -1,331 +1,288 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.default = setupWatchingContext;
|
|
7
|
-
|
|
8
6
|
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
-
|
|
10
7
|
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
|
|
12
8
|
var _tmp = _interopRequireDefault(require("tmp"));
|
|
13
|
-
|
|
14
9
|
var _chokidar = _interopRequireDefault(require("chokidar"));
|
|
15
|
-
|
|
16
10
|
var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
|
17
|
-
|
|
18
11
|
var _quickLru = _interopRequireDefault(require("quick-lru"));
|
|
19
|
-
|
|
20
12
|
var _normalizePath = _interopRequireDefault(require("normalize-path"));
|
|
21
|
-
|
|
22
13
|
var _hashConfig = _interopRequireDefault(require("../util/hashConfig"));
|
|
23
|
-
|
|
24
14
|
var _log = _interopRequireDefault(require("../util/log"));
|
|
25
|
-
|
|
26
15
|
var _getModuleDependencies = _interopRequireDefault(require("../lib/getModuleDependencies"));
|
|
27
|
-
|
|
28
|
-
var _resolveConfig = _interopRequireDefault(require("../../resolveConfig"));
|
|
29
|
-
|
|
16
|
+
var _resolveConfig = _interopRequireDefault(require("../public/resolve-config"));
|
|
30
17
|
var _resolveConfigPath = _interopRequireDefault(require("../util/resolveConfigPath"));
|
|
31
|
-
|
|
32
18
|
var _setupContextUtils = require("./setupContextUtils");
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
function _interopRequireDefault(obj) {
|
|
20
|
+
return obj && obj.__esModule ? obj : {
|
|
21
|
+
default: obj
|
|
22
|
+
};
|
|
23
|
+
}
|
|
36
24
|
// This is used to trigger rebuilds. Just updating the timestamp
|
|
37
25
|
// is significantly faster than actually writing to the file (10x).
|
|
38
26
|
function touch(filename) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
27
|
+
let time = new Date();
|
|
28
|
+
try {
|
|
29
|
+
_fs.default.utimesSync(filename, time, time);
|
|
30
|
+
} catch (err) {
|
|
31
|
+
_fs.default.closeSync(_fs.default.openSync(filename, 'w'));
|
|
32
|
+
}
|
|
46
33
|
}
|
|
47
|
-
|
|
48
34
|
let watchers = new WeakMap();
|
|
49
|
-
|
|
50
35
|
function getWatcher(context) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return null;
|
|
36
|
+
if (watchers.has(context)) {
|
|
37
|
+
return watchers.get(context);
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
56
40
|
}
|
|
57
|
-
|
|
58
41
|
function setWatcher(context, watcher) {
|
|
59
|
-
|
|
42
|
+
return watchers.set(context, watcher);
|
|
60
43
|
}
|
|
61
|
-
|
|
62
44
|
let touchFiles = new WeakMap();
|
|
63
|
-
|
|
64
45
|
function getTouchFile(context) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return null;
|
|
46
|
+
if (touchFiles.has(context)) {
|
|
47
|
+
return touchFiles.get(context);
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
70
50
|
}
|
|
71
|
-
|
|
72
51
|
function setTouchFile(context, touchFile) {
|
|
73
|
-
|
|
52
|
+
return touchFiles.set(context, touchFile);
|
|
74
53
|
}
|
|
75
|
-
|
|
76
54
|
let configPaths = new WeakMap();
|
|
77
|
-
|
|
78
55
|
function getConfigPath(context, configOrPath) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return configPaths.get(context);
|
|
56
|
+
if (!configPaths.has(context)) {
|
|
57
|
+
configPaths.set(context, (0, _resolveConfigPath).default(configOrPath));
|
|
58
|
+
}
|
|
59
|
+
return configPaths.get(context);
|
|
84
60
|
}
|
|
85
|
-
|
|
86
61
|
function rebootWatcher(context, configPath, configDependencies, candidateFiles) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
setTouchFile(context, touchFile);
|
|
92
|
-
touch(touchFile);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
let watcher = getWatcher(context);
|
|
96
|
-
Promise.resolve(watcher ? watcher.close() : null).then(() => {
|
|
97
|
-
_log.default.info(['Tailwind CSS is watching for changes...', 'https://tailwindcss.com/docs/just-in-time-mode#watch-mode-and-one-off-builds']);
|
|
98
|
-
|
|
99
|
-
watcher = _chokidar.default.watch([...candidateFiles, ...configDependencies], {
|
|
100
|
-
ignoreInitial: true
|
|
101
|
-
});
|
|
102
|
-
setWatcher(context, watcher);
|
|
103
|
-
watcher.on('add', file => {
|
|
104
|
-
let changedFile = _path.default.resolve('.', file);
|
|
105
|
-
|
|
106
|
-
let content = _fs.default.readFileSync(changedFile, 'utf8');
|
|
107
|
-
|
|
108
|
-
let extension = _path.default.extname(changedFile).slice(1);
|
|
109
|
-
|
|
110
|
-
context.changedContent.push({
|
|
111
|
-
content,
|
|
112
|
-
extension
|
|
113
|
-
});
|
|
114
|
-
touch(touchFile);
|
|
115
|
-
});
|
|
116
|
-
watcher.on('change', file => {
|
|
117
|
-
// If it was a config dependency, touch the config file to trigger a new context.
|
|
118
|
-
// This is not really that clean of a solution but it's the fastest, because we
|
|
119
|
-
// can do a very quick check on each build to see if the config has changed instead
|
|
120
|
-
// of having to get all of the module dependencies and check every timestamp each
|
|
121
|
-
// time.
|
|
122
|
-
if (configDependencies.has(file)) {
|
|
123
|
-
for (let dependency of configDependencies) {
|
|
124
|
-
delete require.cache[require.resolve(dependency)];
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
touch(configPath);
|
|
128
|
-
} else {
|
|
129
|
-
let changedFile = _path.default.resolve('.', file);
|
|
130
|
-
|
|
131
|
-
let content = _fs.default.readFileSync(changedFile, 'utf8');
|
|
132
|
-
|
|
133
|
-
let extension = _path.default.extname(changedFile).slice(1);
|
|
134
|
-
|
|
135
|
-
context.changedContent.push({
|
|
136
|
-
content,
|
|
137
|
-
extension
|
|
138
|
-
});
|
|
62
|
+
let touchFile = getTouchFile(context);
|
|
63
|
+
if (touchFile === null) {
|
|
64
|
+
touchFile = _tmp.default.fileSync().name;
|
|
65
|
+
setTouchFile(context, touchFile);
|
|
139
66
|
touch(touchFile);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
watcher.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
67
|
+
}
|
|
68
|
+
let watcher = getWatcher(context);
|
|
69
|
+
Promise.resolve(watcher ? watcher.close() : null).then(()=>{
|
|
70
|
+
_log.default.info([
|
|
71
|
+
'Tailwind CSS is watching for changes...',
|
|
72
|
+
'https://tailwindcss.com/docs/just-in-time-mode#watch-mode-and-one-off-builds',
|
|
73
|
+
]);
|
|
74
|
+
watcher = _chokidar.default.watch([
|
|
75
|
+
...candidateFiles,
|
|
76
|
+
...configDependencies
|
|
77
|
+
], {
|
|
78
|
+
ignoreInitial: true,
|
|
79
|
+
awaitWriteFinish: process.platform === 'win32' ? {
|
|
80
|
+
stabilityThreshold: 50,
|
|
81
|
+
pollInterval: 10
|
|
82
|
+
} : false
|
|
83
|
+
});
|
|
84
|
+
setWatcher(context, watcher);
|
|
85
|
+
watcher.on('add', (file)=>{
|
|
86
|
+
let changedFile = _path.default.resolve('.', file);
|
|
87
|
+
let content = _fs.default.readFileSync(changedFile, 'utf8');
|
|
88
|
+
let extension = _path.default.extname(changedFile).slice(1);
|
|
89
|
+
context.changedContent.push({
|
|
90
|
+
content,
|
|
91
|
+
extension
|
|
92
|
+
});
|
|
93
|
+
touch(touchFile);
|
|
94
|
+
});
|
|
95
|
+
watcher.on('change', (file)=>{
|
|
96
|
+
// If it was a config dependency, touch the config file to trigger a new context.
|
|
97
|
+
// This is not really that clean of a solution but it's the fastest, because we
|
|
98
|
+
// can do a very quick check on each build to see if the config has changed instead
|
|
99
|
+
// of having to get all of the module dependencies and check every timestamp each
|
|
100
|
+
// time.
|
|
101
|
+
if (configDependencies.has(file)) {
|
|
102
|
+
for (let dependency of configDependencies){
|
|
103
|
+
delete require.cache[require.resolve(dependency)];
|
|
104
|
+
}
|
|
105
|
+
touch(configPath);
|
|
106
|
+
} else {
|
|
107
|
+
let changedFile = _path.default.resolve('.', file);
|
|
108
|
+
let content = _fs.default.readFileSync(changedFile, 'utf8');
|
|
109
|
+
let extension = _path.default.extname(changedFile).slice(1);
|
|
110
|
+
context.changedContent.push({
|
|
111
|
+
content,
|
|
112
|
+
extension
|
|
113
|
+
});
|
|
114
|
+
touch(touchFile);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
watcher.on('unlink', (file)=>{
|
|
118
|
+
// Touch the config file if any of the dependencies are deleted.
|
|
119
|
+
if (configDependencies.has(file)) {
|
|
120
|
+
for (let dependency of configDependencies){
|
|
121
|
+
delete require.cache[require.resolve(dependency)];
|
|
122
|
+
}
|
|
123
|
+
touch(configPath);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
151
126
|
});
|
|
152
|
-
});
|
|
153
127
|
}
|
|
154
|
-
|
|
155
128
|
let configPathCache = new _quickLru.default({
|
|
156
|
-
|
|
129
|
+
maxSize: 100
|
|
157
130
|
});
|
|
158
131
|
let configDependenciesCache = new WeakMap();
|
|
159
|
-
|
|
160
132
|
function getConfigDependencies(context) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return configDependenciesCache.get(context);
|
|
133
|
+
if (!configDependenciesCache.has(context)) {
|
|
134
|
+
configDependenciesCache.set(context, new Set());
|
|
135
|
+
}
|
|
136
|
+
return configDependenciesCache.get(context);
|
|
166
137
|
}
|
|
167
|
-
|
|
168
138
|
let candidateFilesCache = new WeakMap();
|
|
169
|
-
|
|
170
139
|
function getCandidateFiles(context, tailwindConfig) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
140
|
+
if (candidateFilesCache.has(context)) {
|
|
141
|
+
return candidateFilesCache.get(context);
|
|
142
|
+
}
|
|
143
|
+
let candidateFiles = tailwindConfig.content.files.filter((item)=>typeof item === 'string'
|
|
144
|
+
).map((contentPath)=>(0, _normalizePath).default(contentPath)
|
|
145
|
+
);
|
|
146
|
+
return candidateFilesCache.set(context, candidateFiles).get(context);
|
|
147
|
+
}
|
|
148
|
+
// Get the config object based on a path
|
|
180
149
|
function getTailwindConfig(configOrPath) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
150
|
+
let userConfigPath = (0, _resolveConfigPath).default(configOrPath);
|
|
151
|
+
if (userConfigPath !== null) {
|
|
152
|
+
let [prevConfig, prevModified = -Infinity, prevConfigHash] = configPathCache.get(userConfigPath) || [];
|
|
153
|
+
let modified = _fs.default.statSync(userConfigPath).mtimeMs;
|
|
154
|
+
// It hasn't changed (based on timestamp)
|
|
155
|
+
if (modified <= prevModified) {
|
|
156
|
+
return [
|
|
157
|
+
prevConfig,
|
|
158
|
+
userConfigPath,
|
|
159
|
+
prevConfigHash,
|
|
160
|
+
[
|
|
161
|
+
userConfigPath
|
|
162
|
+
]
|
|
163
|
+
];
|
|
164
|
+
}
|
|
165
|
+
// It has changed (based on timestamp), or first run
|
|
166
|
+
delete require.cache[userConfigPath];
|
|
167
|
+
let newConfig = (0, _resolveConfig).default(require(userConfigPath));
|
|
168
|
+
let newHash = (0, _hashConfig).default(newConfig);
|
|
169
|
+
configPathCache.set(userConfigPath, [
|
|
170
|
+
newConfig,
|
|
171
|
+
modified,
|
|
172
|
+
newHash
|
|
173
|
+
]);
|
|
174
|
+
return [
|
|
175
|
+
newConfig,
|
|
176
|
+
userConfigPath,
|
|
177
|
+
newHash,
|
|
178
|
+
[
|
|
179
|
+
userConfigPath
|
|
180
|
+
]
|
|
181
|
+
];
|
|
182
|
+
}
|
|
183
|
+
// It's a plain object, not a path
|
|
184
|
+
let newConfig = (0, _resolveConfig).default(configOrPath.config === undefined ? configOrPath : configOrPath.config);
|
|
185
|
+
return [
|
|
186
|
+
newConfig,
|
|
187
|
+
null,
|
|
188
|
+
(0, _hashConfig).default(newConfig),
|
|
189
|
+
[]
|
|
190
|
+
];
|
|
204
191
|
}
|
|
205
|
-
|
|
206
192
|
function resolvedChangedContent(context, candidateFiles) {
|
|
207
|
-
|
|
208
|
-
raw,
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
extension
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return changedContent;
|
|
193
|
+
let changedContent = context.tailwindConfig.content.files.filter((item)=>typeof item.raw === 'string'
|
|
194
|
+
).map(({ raw , extension ='html' })=>({
|
|
195
|
+
content: raw,
|
|
196
|
+
extension
|
|
197
|
+
})
|
|
198
|
+
);
|
|
199
|
+
for (let changedFile of resolveChangedFiles(context, candidateFiles)){
|
|
200
|
+
let content = _fs.default.readFileSync(changedFile, 'utf8');
|
|
201
|
+
let extension = _path.default.extname(changedFile).slice(1);
|
|
202
|
+
changedContent.push({
|
|
203
|
+
content,
|
|
204
|
+
extension
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return changedContent;
|
|
227
208
|
}
|
|
228
|
-
|
|
229
209
|
let scannedContentCache = new WeakMap();
|
|
230
|
-
|
|
231
210
|
function resolveChangedFiles(context, candidateFiles) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
211
|
+
let changedFiles = new Set();
|
|
212
|
+
// If we're not set up and watching files ourselves, we need to do
|
|
213
|
+
// the work of grabbing all of the template files for candidate
|
|
214
|
+
// detection.
|
|
215
|
+
if (!scannedContentCache.has(context)) {
|
|
216
|
+
let files = _fastGlob.default.sync(candidateFiles);
|
|
217
|
+
for (let file of files){
|
|
218
|
+
changedFiles.add(file);
|
|
219
|
+
}
|
|
220
|
+
scannedContentCache.set(context, true);
|
|
241
221
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return changedFiles;
|
|
247
|
-
} // DISABLE_TOUCH = FALSE
|
|
248
|
-
// Retrieve an existing context from cache if possible (since contexts are unique per
|
|
249
|
-
// source path), or set up a new one (including setting up watchers and registering
|
|
250
|
-
// plugins) then return it
|
|
251
|
-
|
|
252
|
-
|
|
222
|
+
return changedFiles;
|
|
223
|
+
}
|
|
253
224
|
function setupWatchingContext(configOrPath) {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
registerDependency({
|
|
317
|
-
type: 'dependency',
|
|
318
|
-
file: touchFile
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
if (tailwindDirectives.size > 0) {
|
|
323
|
-
for (let changedContent of resolvedChangedContent(context, candidateFiles)) {
|
|
324
|
-
context.changedContent.push(changedContent);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
return context;
|
|
225
|
+
return ({ tailwindDirectives , registerDependency })=>{
|
|
226
|
+
return (root, result)=>{
|
|
227
|
+
let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] = getTailwindConfig(configOrPath);
|
|
228
|
+
let contextDependencies = new Set(configDependencies);
|
|
229
|
+
// If there are no @tailwind rules, we don't consider this CSS file or it's dependencies
|
|
230
|
+
// to be dependencies of the context. Can reuse the context even if they change.
|
|
231
|
+
// We may want to think about `@layer` being part of this trigger too, but it's tough
|
|
232
|
+
// because it's impossible for a layer in one file to end up in the actual @tailwind rule
|
|
233
|
+
// in another file since independent sources are effectively isolated.
|
|
234
|
+
if (tailwindDirectives.size > 0) {
|
|
235
|
+
// Add current css file as a context dependencies.
|
|
236
|
+
contextDependencies.add(result.opts.from);
|
|
237
|
+
// Add all css @import dependencies as context dependencies.
|
|
238
|
+
for (let message of result.messages){
|
|
239
|
+
if (message.type === 'dependency') {
|
|
240
|
+
contextDependencies.add(message.file);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
let [context, isNewContext] = (0, _setupContextUtils).getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
|
|
245
|
+
let candidateFiles = getCandidateFiles(context, tailwindConfig);
|
|
246
|
+
let contextConfigDependencies = getConfigDependencies(context);
|
|
247
|
+
for (let file of configDependencies){
|
|
248
|
+
registerDependency({
|
|
249
|
+
type: 'dependency',
|
|
250
|
+
file
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
context.disposables.push((oldContext)=>{
|
|
254
|
+
let watcher = getWatcher(oldContext);
|
|
255
|
+
if (watcher !== null) {
|
|
256
|
+
watcher.close();
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
let configPath = getConfigPath(context, configOrPath);
|
|
260
|
+
if (configPath !== null) {
|
|
261
|
+
for (let dependency of (0, _getModuleDependencies).default(configPath)){
|
|
262
|
+
if (dependency.file === configPath) {
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
contextConfigDependencies.add(dependency.file);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (isNewContext) {
|
|
269
|
+
rebootWatcher(context, configPath, contextConfigDependencies, candidateFiles);
|
|
270
|
+
}
|
|
271
|
+
// Register our temp file as a dependency — we write to this file
|
|
272
|
+
// to trigger rebuilds.
|
|
273
|
+
let touchFile = getTouchFile(context);
|
|
274
|
+
if (touchFile) {
|
|
275
|
+
registerDependency({
|
|
276
|
+
type: 'dependency',
|
|
277
|
+
file: touchFile
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
if (tailwindDirectives.size > 0) {
|
|
281
|
+
for (let changedContent of resolvedChangedContent(context, candidateFiles)){
|
|
282
|
+
context.changedContent.push(changedContent);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return context;
|
|
286
|
+
};
|
|
329
287
|
};
|
|
330
|
-
|
|
331
|
-
}
|
|
288
|
+
}
|
package/lib/lib/sharedState.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
var _quickLru = _interopRequireDefault(require("quick-lru"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
5
|
+
exports.contextSourcesMap = exports.configContextMap = exports.contextMap = exports.env = void 0;
|
|
12
6
|
const env = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
TAILWIND_MODE: process.env.TAILWIND_MODE,
|
|
8
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
9
|
+
DEBUG: process.env.DEBUG !== undefined && process.env.DEBUG !== '0',
|
|
10
|
+
TAILWIND_DISABLE_TOUCH: process.env.TAILWIND_DISABLE_TOUCH !== undefined,
|
|
11
|
+
TAILWIND_TOUCH_DIR: process.env.TAILWIND_TOUCH_DIR
|
|
18
12
|
};
|
|
19
13
|
exports.env = env;
|
|
20
14
|
const contextMap = new Map();
|
|
@@ -23,7 +17,3 @@ const configContextMap = new Map();
|
|
|
23
17
|
exports.configContextMap = configContextMap;
|
|
24
18
|
const contextSourcesMap = new Map();
|
|
25
19
|
exports.contextSourcesMap = contextSourcesMap;
|
|
26
|
-
const contentMatchCache = new _quickLru.default({
|
|
27
|
-
maxSize: 25000
|
|
28
|
-
});
|
|
29
|
-
exports.contentMatchCache = contentMatchCache;
|
|
@@ -1,31 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.default = _default;
|
|
7
|
-
|
|
6
|
+
var _normalizeScreens = require("../util/normalizeScreens");
|
|
8
7
|
var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
}
|
|
8
|
+
function _interopRequireDefault(obj) {
|
|
9
|
+
return obj && obj.__esModule ? obj : {
|
|
10
|
+
default: obj
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function _default({ tailwindConfig: { theme } }) {
|
|
14
|
+
return function(css) {
|
|
15
|
+
css.walkAtRules('screen', (atRule)=>{
|
|
16
|
+
let screen = atRule.params;
|
|
17
|
+
let screens = (0, _normalizeScreens).normalizeScreens(theme.screens);
|
|
18
|
+
let screenDefinition = screens.find(({ name })=>name === screen
|
|
19
|
+
);
|
|
20
|
+
if (!screenDefinition) {
|
|
21
|
+
throw atRule.error(`No \`${screen}\` screen found.`);
|
|
22
|
+
}
|
|
23
|
+
atRule.name = 'media';
|
|
24
|
+
atRule.params = (0, _buildMediaQuery).default(screenDefinition);
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
}
|