tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.cb6e45a
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 +526 -2
- package/LICENSE +1 -2
- package/README.md +13 -6
- package/colors.d.ts +3 -0
- package/colors.js +2 -1
- package/defaultConfig.d.ts +3 -0
- package/defaultConfig.js +2 -1
- package/defaultTheme.d.ts +4 -0
- package/defaultTheme.js +2 -1
- package/lib/cli/build/deps.js +54 -0
- package/lib/cli/build/index.js +44 -0
- package/lib/cli/build/plugin.js +335 -0
- package/lib/cli/build/utils.js +78 -0
- package/lib/cli/build/watching.js +113 -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 +12 -0
- package/lib/cli-peer-dependencies.js +20 -7
- package/lib/cli.js +91 -569
- package/lib/constants.js +27 -20
- package/lib/corePluginList.js +16 -4
- package/lib/corePlugins.js +2247 -1873
- package/lib/css/preflight.css +20 -9
- package/lib/featureFlags.js +37 -23
- package/lib/index.js +28 -12
- package/lib/lib/cacheInvalidation.js +90 -0
- package/lib/lib/collapseAdjacentRules.js +27 -9
- package/lib/lib/collapseDuplicateDeclarations.js +83 -0
- package/lib/lib/content.js +167 -0
- package/lib/lib/defaultExtractor.js +236 -0
- package/lib/lib/detectNesting.js +21 -3
- package/lib/lib/evaluateTailwindFunctions.js +117 -50
- package/lib/lib/expandApplyAtRules.js +439 -160
- package/lib/lib/expandTailwindAtRules.js +141 -151
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +572 -105
- package/lib/lib/getModuleDependencies.js +11 -8
- package/lib/lib/normalizeTailwindDirectives.js +45 -33
- 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 +114 -81
- package/lib/lib/setupContextUtils.js +777 -385
- package/lib/lib/setupTrackingContext.js +43 -71
- package/lib/lib/sharedState.js +49 -18
- package/lib/lib/substituteScreenAtRules.js +13 -8
- 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 +36 -21
- package/lib/public/colors.js +250 -252
- package/lib/public/create-plugin.js +6 -4
- package/lib/public/default-config.js +7 -5
- package/lib/public/default-theme.js +7 -5
- package/lib/public/resolve-config.js +8 -5
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +18 -24
- package/lib/util/cloneDeep.js +7 -6
- package/lib/util/cloneNodes.js +21 -3
- package/lib/util/color.js +54 -40
- package/lib/util/configurePlugins.js +5 -2
- package/lib/util/createPlugin.js +6 -6
- package/lib/util/createUtilityPlugin.js +11 -13
- package/lib/util/dataTypes.js +137 -100
- package/lib/util/defaults.js +10 -1
- package/lib/util/escapeClassName.js +7 -4
- package/lib/util/escapeCommas.js +5 -2
- package/lib/util/flattenColorPalette.js +9 -12
- package/lib/util/formatVariantSelector.js +285 -0
- package/lib/util/getAllConfigs.js +27 -8
- package/lib/util/hashConfig.js +6 -3
- package/lib/util/isKeyframeRule.js +5 -2
- package/lib/util/isPlainObject.js +5 -2
- package/lib/util/isValidArbitraryValue.js +72 -0
- package/lib/util/log.js +44 -22
- package/lib/util/nameClass.js +20 -8
- package/lib/util/negateValue.js +23 -6
- package/lib/util/normalizeConfig.js +267 -0
- package/lib/util/normalizeScreens.js +170 -0
- package/lib/util/parseAnimationValue.js +42 -40
- package/lib/util/parseBoxShadowValue.js +84 -0
- package/lib/util/parseDependency.js +38 -56
- package/lib/util/parseGlob.js +34 -0
- package/lib/util/parseObjectStyles.js +11 -8
- package/lib/util/pluginUtils.js +171 -189
- package/lib/util/prefixSelector.js +10 -10
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +92 -126
- package/lib/util/resolveConfigPath.js +11 -9
- package/lib/util/responsive.js +8 -5
- package/lib/util/splitAtTopLevelOnly.js +43 -0
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +5 -3
- package/lib/util/toPath.js +24 -3
- package/lib/util/transformThemeValue.js +49 -31
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/validateFormalSyntax.js +24 -0
- package/lib/util/withAlphaVariable.js +23 -15
- package/nesting/index.js +2 -12
- package/package.json +48 -46
- package/peers/index.js +14817 -12471
- package/plugin.d.ts +11 -0
- package/plugin.js +2 -1
- package/resolveConfig.d.ts +3 -0
- package/resolveConfig.js +2 -1
- 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 +45 -0
- package/src/cli/build/plugin.js +397 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +134 -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 +5 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +26 -565
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +905 -615
- package/src/css/preflight.css +20 -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 +205 -0
- package/src/lib/defaultExtractor.js +211 -0
- package/src/lib/detectNesting.js +22 -3
- package/src/lib/evaluateTailwindFunctions.js +84 -10
- package/src/lib/expandApplyAtRules.js +488 -153
- package/src/lib/expandTailwindAtRules.js +94 -106
- package/src/lib/findAtConfigPath.js +50 -0
- package/src/lib/generateRules.js +589 -67
- 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 +98 -60
- package/src/lib/setupContextUtils.js +737 -246
- package/src/lib/setupTrackingContext.js +16 -54
- package/src/lib/sharedState.js +44 -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 +17 -2
- package/src/public/colors.js +4 -9
- 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 -2
- package/src/util/dataTypes.js +57 -21
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +319 -0
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +23 -22
- package/src/util/nameClass.js +6 -2
- package/src/util/negateValue.js +14 -4
- package/src/util/normalizeConfig.js +282 -0
- package/src/util/normalizeScreens.js +140 -0
- package/src/util/parseBoxShadowValue.js +72 -0
- package/src/util/parseDependency.js +37 -42
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +144 -152
- package/src/util/prefixSelector.js +7 -8
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +82 -81
- 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 +1 -1
- package/stubs/defaultConfig.stub.js +173 -93
- package/stubs/simpleConfig.stub.js +1 -1
- package/types/config.d.ts +361 -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 -284
- package/nesting/plugin.js +0 -41
- package/src/lib/setupWatchingContext.js +0 -306
package/lib/css/preflight.css
CHANGED
|
@@ -9,7 +9,12 @@
|
|
|
9
9
|
box-sizing: border-box; /* 1 */
|
|
10
10
|
border-width: 0; /* 2 */
|
|
11
11
|
border-style: solid; /* 2 */
|
|
12
|
-
border-color: currentColor; /* 2 */
|
|
12
|
+
border-color: theme('borderColor.DEFAULT', currentColor); /* 2 */
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
::before,
|
|
16
|
+
::after {
|
|
17
|
+
--tw-content: '';
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
/*
|
|
@@ -53,7 +58,7 @@ hr {
|
|
|
53
58
|
Add the correct text decoration in Chrome, Edge, and Safari.
|
|
54
59
|
*/
|
|
55
60
|
|
|
56
|
-
abbr[title] {
|
|
61
|
+
abbr:where([title]) {
|
|
57
62
|
text-decoration: underline dotted;
|
|
58
63
|
}
|
|
59
64
|
|
|
@@ -139,7 +144,7 @@ sup {
|
|
|
139
144
|
table {
|
|
140
145
|
text-indent: 0; /* 1 */
|
|
141
146
|
border-color: inherit; /* 2 */
|
|
142
|
-
border-collapse: collapse;
|
|
147
|
+
border-collapse: collapse; /* 3 */
|
|
143
148
|
}
|
|
144
149
|
|
|
145
150
|
/*
|
|
@@ -155,6 +160,7 @@ select,
|
|
|
155
160
|
textarea {
|
|
156
161
|
font-family: inherit; /* 1 */
|
|
157
162
|
font-size: 100%; /* 1 */
|
|
163
|
+
font-weight: inherit; /* 1 */
|
|
158
164
|
line-height: inherit; /* 1 */
|
|
159
165
|
color: inherit; /* 1 */
|
|
160
166
|
margin: 0; /* 2 */
|
|
@@ -283,7 +289,8 @@ legend {
|
|
|
283
289
|
}
|
|
284
290
|
|
|
285
291
|
ol,
|
|
286
|
-
ul
|
|
292
|
+
ul,
|
|
293
|
+
menu {
|
|
287
294
|
list-style: none;
|
|
288
295
|
margin: 0;
|
|
289
296
|
padding: 0;
|
|
@@ -304,7 +311,7 @@ textarea {
|
|
|
304
311
|
|
|
305
312
|
input::placeholder,
|
|
306
313
|
textarea::placeholder {
|
|
307
|
-
opacity: 1;
|
|
314
|
+
opacity: 1; /* 1 */
|
|
308
315
|
color: theme('colors.gray.400', #9ca3af); /* 2 */
|
|
309
316
|
}
|
|
310
317
|
|
|
@@ -317,6 +324,13 @@ button,
|
|
|
317
324
|
cursor: pointer;
|
|
318
325
|
}
|
|
319
326
|
|
|
327
|
+
/*
|
|
328
|
+
Make sure disabled buttons don't get the pointer cursor.
|
|
329
|
+
*/
|
|
330
|
+
:disabled {
|
|
331
|
+
cursor: default;
|
|
332
|
+
}
|
|
333
|
+
|
|
320
334
|
/*
|
|
321
335
|
1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
|
|
322
336
|
2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
|
|
@@ -345,10 +359,7 @@ video {
|
|
|
345
359
|
height: auto;
|
|
346
360
|
}
|
|
347
361
|
|
|
348
|
-
/*
|
|
349
|
-
Ensure the default browser behavior of the `hidden` attribute.
|
|
350
|
-
*/
|
|
351
|
-
|
|
362
|
+
/* Make elements with the HTML hidden attribute stay hidden by default */
|
|
352
363
|
[hidden] {
|
|
353
364
|
display: none;
|
|
354
365
|
}
|
package/lib/featureFlags.js
CHANGED
|
@@ -2,56 +2,70 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
flagEnabled: ()=>flagEnabled,
|
|
13
|
+
issueFlagNotices: ()=>issueFlagNotices,
|
|
14
|
+
default: ()=>_default
|
|
15
|
+
});
|
|
16
|
+
const _picocolors = /*#__PURE__*/ _interopRequireDefault(require("picocolors"));
|
|
17
|
+
const _log = /*#__PURE__*/ _interopRequireDefault(require("./util/log"));
|
|
10
18
|
function _interopRequireDefault(obj) {
|
|
11
19
|
return obj && obj.__esModule ? obj : {
|
|
12
20
|
default: obj
|
|
13
21
|
};
|
|
14
22
|
}
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
let defaults = {
|
|
24
|
+
optimizeUniversalDefaults: false,
|
|
25
|
+
generalizedModifiers: true
|
|
26
|
+
};
|
|
27
|
+
let featureFlags = {
|
|
28
|
+
future: [
|
|
29
|
+
"hoverOnlyWhenSupported",
|
|
30
|
+
"respectDefaultRingColorOpacity",
|
|
31
|
+
"disableColorOpacityUtilitiesByDefault",
|
|
32
|
+
"relativeContentPathsByDefault"
|
|
33
|
+
],
|
|
17
34
|
experimental: [
|
|
18
|
-
|
|
35
|
+
"optimizeUniversalDefaults",
|
|
36
|
+
"generalizedModifiers"
|
|
19
37
|
]
|
|
20
38
|
};
|
|
21
39
|
function flagEnabled(config, flag) {
|
|
22
40
|
if (featureFlags.future.includes(flag)) {
|
|
23
41
|
var ref;
|
|
24
|
-
var ref1;
|
|
25
|
-
return config.future ===
|
|
42
|
+
var ref1, ref2;
|
|
43
|
+
return config.future === "all" || ((ref2 = (ref1 = config === null || config === void 0 ? void 0 : (ref = config.future) === null || ref === void 0 ? void 0 : ref[flag]) !== null && ref1 !== void 0 ? ref1 : defaults[flag]) !== null && ref2 !== void 0 ? ref2 : false);
|
|
26
44
|
}
|
|
27
45
|
if (featureFlags.experimental.includes(flag)) {
|
|
28
|
-
var
|
|
29
|
-
var ref5;
|
|
30
|
-
return config.experimental ===
|
|
46
|
+
var ref3;
|
|
47
|
+
var ref4, ref5;
|
|
48
|
+
return config.experimental === "all" || ((ref5 = (ref4 = config === null || config === void 0 ? void 0 : (ref3 = config.experimental) === null || ref3 === void 0 ? void 0 : ref3[flag]) !== null && ref4 !== void 0 ? ref4 : defaults[flag]) !== null && ref5 !== void 0 ? ref5 : false);
|
|
31
49
|
}
|
|
32
50
|
return false;
|
|
33
51
|
}
|
|
34
52
|
function experimentalFlagsEnabled(config) {
|
|
35
|
-
if (config.experimental ===
|
|
53
|
+
if (config.experimental === "all") {
|
|
36
54
|
return featureFlags.experimental;
|
|
37
55
|
}
|
|
38
56
|
var ref;
|
|
39
|
-
return Object.keys((ref = config === null || config === void 0 ? void 0 : config.experimental) !== null && ref !== void 0 ? ref : {
|
|
40
|
-
}).filter((flag)=>featureFlags.experimental.includes(flag) && config.experimental[flag]
|
|
41
|
-
);
|
|
57
|
+
return Object.keys((ref = config === null || config === void 0 ? void 0 : config.experimental) !== null && ref !== void 0 ? ref : {}).filter((flag)=>featureFlags.experimental.includes(flag) && config.experimental[flag]);
|
|
42
58
|
}
|
|
43
59
|
function issueFlagNotices(config) {
|
|
44
60
|
if (process.env.JEST_WORKER_ID !== undefined) {
|
|
45
61
|
return;
|
|
46
62
|
}
|
|
47
63
|
if (experimentalFlagsEnabled(config).length > 0) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
_log.default.warn([
|
|
64
|
+
let changes = experimentalFlagsEnabled(config).map((s)=>_picocolors.default.yellow(s)).join(", ");
|
|
65
|
+
_log.default.warn("experimental-flags-enabled", [
|
|
51
66
|
`You have enabled experimental features: ${changes}`,
|
|
52
|
-
|
|
67
|
+
"Experimental features in Tailwind CSS are not covered by semver, may introduce breaking changes, and can change at any time."
|
|
53
68
|
]);
|
|
54
69
|
}
|
|
55
70
|
}
|
|
56
|
-
|
|
57
|
-
exports.default = _default;
|
|
71
|
+
const _default = featureFlags;
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
const _setupTrackingContext = /*#__PURE__*/ _interopRequireDefault(require("./lib/setupTrackingContext"));
|
|
6
|
+
const _processTailwindFeatures = /*#__PURE__*/ _interopRequireDefault(require("./processTailwindFeatures"));
|
|
7
|
+
const _sharedState = require("./lib/sharedState");
|
|
8
|
+
const _findAtConfigPath = require("./lib/findAtConfigPath");
|
|
6
9
|
function _interopRequireDefault(obj) {
|
|
7
10
|
return obj && obj.__esModule ? obj : {
|
|
8
11
|
default: obj
|
|
@@ -10,22 +13,35 @@ function _interopRequireDefault(obj) {
|
|
|
10
13
|
}
|
|
11
14
|
module.exports = function tailwindcss(configOrPath) {
|
|
12
15
|
return {
|
|
13
|
-
postcssPlugin:
|
|
16
|
+
postcssPlugin: "tailwindcss",
|
|
14
17
|
plugins: [
|
|
15
18
|
_sharedState.env.DEBUG && function(root) {
|
|
16
|
-
console.log(
|
|
17
|
-
console.time(
|
|
19
|
+
console.log("\n");
|
|
20
|
+
console.time("JIT TOTAL");
|
|
18
21
|
return root;
|
|
19
22
|
},
|
|
20
23
|
function(root, result) {
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
var ref;
|
|
25
|
+
// Use the path for the `@config` directive if it exists, otherwise use the
|
|
26
|
+
// path for the file being processed
|
|
27
|
+
configOrPath = (ref = (0, _findAtConfigPath.findAtConfigPath)(root, result)) !== null && ref !== void 0 ? ref : configOrPath;
|
|
28
|
+
let context = (0, _setupTrackingContext.default)(configOrPath);
|
|
29
|
+
if (root.type === "document") {
|
|
30
|
+
let roots = root.nodes.filter((node)=>node.type === "root");
|
|
31
|
+
for (const root1 of roots){
|
|
32
|
+
if (root1.type === "root") {
|
|
33
|
+
(0, _processTailwindFeatures.default)(context)(root1, result);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
(0, _processTailwindFeatures.default)(context)(root, result);
|
|
23
39
|
},
|
|
24
40
|
_sharedState.env.DEBUG && function(root) {
|
|
25
|
-
console.timeEnd(
|
|
26
|
-
console.log(
|
|
41
|
+
console.timeEnd("JIT TOTAL");
|
|
42
|
+
console.log("\n");
|
|
27
43
|
return root;
|
|
28
|
-
}
|
|
44
|
+
}
|
|
29
45
|
].filter(Boolean)
|
|
30
46
|
};
|
|
31
47
|
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "hasContentChanged", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>hasContentChanged
|
|
8
|
+
});
|
|
9
|
+
const _crypto = /*#__PURE__*/ _interopRequireDefault(require("crypto"));
|
|
10
|
+
const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
|
|
11
|
+
function _interopRequireDefault(obj) {
|
|
12
|
+
return obj && obj.__esModule ? obj : {
|
|
13
|
+
default: obj
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
17
|
+
if (typeof WeakMap !== "function") return null;
|
|
18
|
+
var cacheBabelInterop = new WeakMap();
|
|
19
|
+
var cacheNodeInterop = new WeakMap();
|
|
20
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
21
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
22
|
+
})(nodeInterop);
|
|
23
|
+
}
|
|
24
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
25
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
26
|
+
return obj;
|
|
27
|
+
}
|
|
28
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
29
|
+
return {
|
|
30
|
+
default: obj
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
34
|
+
if (cache && cache.has(obj)) {
|
|
35
|
+
return cache.get(obj);
|
|
36
|
+
}
|
|
37
|
+
var newObj = {};
|
|
38
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
39
|
+
for(var key in obj){
|
|
40
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
41
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
42
|
+
if (desc && (desc.get || desc.set)) {
|
|
43
|
+
Object.defineProperty(newObj, key, desc);
|
|
44
|
+
} else {
|
|
45
|
+
newObj[key] = obj[key];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
newObj.default = obj;
|
|
50
|
+
if (cache) {
|
|
51
|
+
cache.set(obj, newObj);
|
|
52
|
+
}
|
|
53
|
+
return newObj;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Calculate the hash of a string.
|
|
57
|
+
*
|
|
58
|
+
* This doesn't need to be cryptographically secure or
|
|
59
|
+
* anything like that since it's used only to detect
|
|
60
|
+
* when the CSS changes to invalidate the context.
|
|
61
|
+
*
|
|
62
|
+
* This is wrapped in a try/catch because it's really dependent
|
|
63
|
+
* on how Node itself is build and the environment and OpenSSL
|
|
64
|
+
* version / build that is installed on the user's machine.
|
|
65
|
+
*
|
|
66
|
+
* Based on the environment this can just outright fail.
|
|
67
|
+
*
|
|
68
|
+
* See https://github.com/nodejs/node/issues/40455
|
|
69
|
+
*
|
|
70
|
+
* @param {string} str
|
|
71
|
+
*/ function getHash(str) {
|
|
72
|
+
try {
|
|
73
|
+
return _crypto.default.createHash("md5").update(str, "utf-8").digest("binary");
|
|
74
|
+
} catch (err) {
|
|
75
|
+
return "";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function hasContentChanged(sourcePath, root) {
|
|
79
|
+
let css = root.toString();
|
|
80
|
+
// We only care about files with @tailwind directives
|
|
81
|
+
// Other files use an existing context
|
|
82
|
+
if (!css.includes("@tailwind")) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
let existingHash = _sharedState.sourceHashMap.get(sourcePath);
|
|
86
|
+
let rootHash = getHash(css);
|
|
87
|
+
let didChange = existingHash !== rootHash;
|
|
88
|
+
_sharedState.sourceHashMap.set(sourcePath, rootHash);
|
|
89
|
+
return didChange;
|
|
90
|
+
}
|
|
@@ -2,19 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>collapseAdjacentRules
|
|
8
|
+
});
|
|
6
9
|
let comparisonMap = {
|
|
7
10
|
atrule: [
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
"name",
|
|
12
|
+
"params"
|
|
10
13
|
],
|
|
11
14
|
rule: [
|
|
12
|
-
|
|
15
|
+
"selector"
|
|
13
16
|
]
|
|
14
17
|
};
|
|
15
18
|
let types = new Set(Object.keys(comparisonMap));
|
|
16
19
|
function collapseAdjacentRules() {
|
|
17
|
-
|
|
20
|
+
function collapseRulesIn(root) {
|
|
18
21
|
let currentRule = null;
|
|
19
22
|
root.each((node)=>{
|
|
20
23
|
if (!types.has(node.type)) {
|
|
@@ -27,15 +30,30 @@ function collapseAdjacentRules() {
|
|
|
27
30
|
}
|
|
28
31
|
let properties = comparisonMap[node.type];
|
|
29
32
|
var _property, _property1;
|
|
30
|
-
if (node.type ===
|
|
33
|
+
if (node.type === "atrule" && node.name === "font-face") {
|
|
31
34
|
currentRule = node;
|
|
32
|
-
} else if (properties.every((property)=>((_property = node[property]) !== null && _property !== void 0 ? _property :
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
} else if (properties.every((property)=>((_property = node[property]) !== null && _property !== void 0 ? _property : "").replace(/\s+/g, " ") === ((_property1 = currentRule[property]) !== null && _property1 !== void 0 ? _property1 : "").replace(/\s+/g, " "))) {
|
|
36
|
+
// An AtRule may not have children (for example if we encounter duplicate @import url(…) rules)
|
|
37
|
+
if (node.nodes) {
|
|
38
|
+
currentRule.append(node.nodes);
|
|
39
|
+
}
|
|
35
40
|
node.remove();
|
|
36
41
|
} else {
|
|
37
42
|
currentRule = node;
|
|
38
43
|
}
|
|
39
44
|
});
|
|
45
|
+
// After we've collapsed adjacent rules & at-rules, we need to collapse
|
|
46
|
+
// adjacent rules & at-rules that are children of at-rules.
|
|
47
|
+
// We do not care about nesting rules because Tailwind CSS
|
|
48
|
+
// explicitly does not handle rule nesting on its own as
|
|
49
|
+
// the user is expected to use a nesting plugin
|
|
50
|
+
root.each((node)=>{
|
|
51
|
+
if (node.type === "atrule") {
|
|
52
|
+
collapseRulesIn(node);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return (root)=>{
|
|
57
|
+
collapseRulesIn(root);
|
|
40
58
|
};
|
|
41
59
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>collapseDuplicateDeclarations
|
|
8
|
+
});
|
|
9
|
+
function collapseDuplicateDeclarations() {
|
|
10
|
+
return (root)=>{
|
|
11
|
+
root.walkRules((node)=>{
|
|
12
|
+
let seen = new Map();
|
|
13
|
+
let droppable = new Set([]);
|
|
14
|
+
let byProperty = new Map();
|
|
15
|
+
node.walkDecls((decl)=>{
|
|
16
|
+
// This could happen if we have nested selectors. In that case the
|
|
17
|
+
// parent will loop over all its declarations but also the declarations
|
|
18
|
+
// of nested rules. With this we ensure that we are shallowly checking
|
|
19
|
+
// declarations.
|
|
20
|
+
if (decl.parent !== node) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (seen.has(decl.prop)) {
|
|
24
|
+
// Exact same value as what we have seen so far
|
|
25
|
+
if (seen.get(decl.prop).value === decl.value) {
|
|
26
|
+
// Keep the last one, drop the one we've seen so far
|
|
27
|
+
droppable.add(seen.get(decl.prop));
|
|
28
|
+
// Override the existing one with the new value. This is necessary
|
|
29
|
+
// so that if we happen to have more than one declaration with the
|
|
30
|
+
// same value, that we keep removing the previous one. Otherwise we
|
|
31
|
+
// will only remove the *first* one.
|
|
32
|
+
seen.set(decl.prop, decl);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
// Not the same value, so we need to check if we can merge it so
|
|
36
|
+
// let's collect it first.
|
|
37
|
+
if (!byProperty.has(decl.prop)) {
|
|
38
|
+
byProperty.set(decl.prop, new Set());
|
|
39
|
+
}
|
|
40
|
+
byProperty.get(decl.prop).add(seen.get(decl.prop));
|
|
41
|
+
byProperty.get(decl.prop).add(decl);
|
|
42
|
+
}
|
|
43
|
+
seen.set(decl.prop, decl);
|
|
44
|
+
});
|
|
45
|
+
// Drop all the duplicate declarations with the exact same value we've
|
|
46
|
+
// already seen so far.
|
|
47
|
+
for (let decl of droppable){
|
|
48
|
+
decl.remove();
|
|
49
|
+
}
|
|
50
|
+
// Analyze the declarations based on its unit, drop all the declarations
|
|
51
|
+
// with the same unit but the last one in the list.
|
|
52
|
+
for (let declarations of byProperty.values()){
|
|
53
|
+
let byUnit = new Map();
|
|
54
|
+
for (let decl1 of declarations){
|
|
55
|
+
let unit = resolveUnit(decl1.value);
|
|
56
|
+
if (unit === null) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (!byUnit.has(unit)) {
|
|
60
|
+
byUnit.set(unit, new Set());
|
|
61
|
+
}
|
|
62
|
+
byUnit.get(unit).add(decl1);
|
|
63
|
+
}
|
|
64
|
+
for (let declarations1 of byUnit.values()){
|
|
65
|
+
// Get all but the last one
|
|
66
|
+
let removableDeclarations = Array.from(declarations1).slice(0, -1);
|
|
67
|
+
for (let decl2 of removableDeclarations){
|
|
68
|
+
decl2.remove();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
let UNITLESS_NUMBER = Symbol("unitless-number");
|
|
76
|
+
function resolveUnit(input) {
|
|
77
|
+
let result = /^-?\d*.?\d+([\w%]+)?$/g.exec(input);
|
|
78
|
+
if (result) {
|
|
79
|
+
var ref;
|
|
80
|
+
return (ref = result[1]) !== null && ref !== void 0 ? ref : UNITLESS_NUMBER;
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
function _export(target, all) {
|
|
7
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
parseCandidateFiles: ()=>parseCandidateFiles,
|
|
14
|
+
resolvedChangedContent: ()=>resolvedChangedContent
|
|
15
|
+
});
|
|
16
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
17
|
+
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
18
|
+
const _isGlob = /*#__PURE__*/ _interopRequireDefault(require("is-glob"));
|
|
19
|
+
const _fastGlob = /*#__PURE__*/ _interopRequireDefault(require("fast-glob"));
|
|
20
|
+
const _normalizePath = /*#__PURE__*/ _interopRequireDefault(require("normalize-path"));
|
|
21
|
+
const _parseGlob = require("../util/parseGlob");
|
|
22
|
+
const _sharedState = require("./sharedState");
|
|
23
|
+
function _interopRequireDefault(obj) {
|
|
24
|
+
return obj && obj.__esModule ? obj : {
|
|
25
|
+
default: obj
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function parseCandidateFiles(context, tailwindConfig) {
|
|
29
|
+
let files = tailwindConfig.content.files;
|
|
30
|
+
// Normalize the file globs
|
|
31
|
+
files = files.filter((filePath)=>typeof filePath === "string");
|
|
32
|
+
files = files.map(_normalizePath.default);
|
|
33
|
+
// Split into included and excluded globs
|
|
34
|
+
let tasks = _fastGlob.default.generateTasks(files);
|
|
35
|
+
/** @type {ContentPath[]} */ let included = [];
|
|
36
|
+
/** @type {ContentPath[]} */ let excluded = [];
|
|
37
|
+
for (const task of tasks){
|
|
38
|
+
included.push(...task.positive.map((filePath)=>parseFilePath(filePath, false)));
|
|
39
|
+
excluded.push(...task.negative.map((filePath)=>parseFilePath(filePath, true)));
|
|
40
|
+
}
|
|
41
|
+
let paths = [
|
|
42
|
+
...included,
|
|
43
|
+
...excluded
|
|
44
|
+
];
|
|
45
|
+
// Resolve paths relative to the config file or cwd
|
|
46
|
+
paths = resolveRelativePaths(context, paths);
|
|
47
|
+
// Resolve symlinks if possible
|
|
48
|
+
paths = paths.flatMap(resolvePathSymlinks);
|
|
49
|
+
// Update cached patterns
|
|
50
|
+
paths = paths.map(resolveGlobPattern);
|
|
51
|
+
return paths;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @param {string} filePath
|
|
56
|
+
* @param {boolean} ignore
|
|
57
|
+
* @returns {ContentPath}
|
|
58
|
+
*/ function parseFilePath(filePath, ignore) {
|
|
59
|
+
let contentPath = {
|
|
60
|
+
original: filePath,
|
|
61
|
+
base: filePath,
|
|
62
|
+
ignore,
|
|
63
|
+
pattern: filePath,
|
|
64
|
+
glob: null
|
|
65
|
+
};
|
|
66
|
+
if ((0, _isGlob.default)(filePath)) {
|
|
67
|
+
Object.assign(contentPath, (0, _parseGlob.parseGlob)(filePath));
|
|
68
|
+
}
|
|
69
|
+
return contentPath;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* @param {ContentPath} contentPath
|
|
74
|
+
* @returns {ContentPath}
|
|
75
|
+
*/ function resolveGlobPattern(contentPath) {
|
|
76
|
+
contentPath.pattern = contentPath.glob ? `${contentPath.base}/${contentPath.glob}` : contentPath.base;
|
|
77
|
+
contentPath.pattern = contentPath.ignore ? `!${contentPath.pattern}` : contentPath.pattern;
|
|
78
|
+
// This is required for Windows support to properly pick up Glob paths.
|
|
79
|
+
// Afaik, this technically shouldn't be needed but there's probably
|
|
80
|
+
// some internal, direct path matching with a normalized path in
|
|
81
|
+
// a package which can't handle mixed directory separators
|
|
82
|
+
contentPath.pattern = (0, _normalizePath.default)(contentPath.pattern);
|
|
83
|
+
return contentPath;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Resolve each path relative to the config file (when possible) if the experimental flag is enabled
|
|
87
|
+
* Otherwise, resolve relative to the current working directory
|
|
88
|
+
*
|
|
89
|
+
* @param {any} context
|
|
90
|
+
* @param {ContentPath[]} contentPaths
|
|
91
|
+
* @returns {ContentPath[]}
|
|
92
|
+
*/ function resolveRelativePaths(context, contentPaths) {
|
|
93
|
+
let resolveFrom = [];
|
|
94
|
+
// Resolve base paths relative to the config file (when possible) if the experimental flag is enabled
|
|
95
|
+
if (context.userConfigPath && context.tailwindConfig.content.relative) {
|
|
96
|
+
resolveFrom = [
|
|
97
|
+
_path.default.dirname(context.userConfigPath)
|
|
98
|
+
];
|
|
99
|
+
}
|
|
100
|
+
return contentPaths.map((contentPath)=>{
|
|
101
|
+
contentPath.base = _path.default.resolve(...resolveFrom, contentPath.base);
|
|
102
|
+
return contentPath;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Resolve the symlink for the base directory / file in each path
|
|
107
|
+
* These are added as additional dependencies to watch for changes because
|
|
108
|
+
* some tools (like webpack) will only watch the actual file or directory
|
|
109
|
+
* but not the symlink itself even in projects that use monorepos.
|
|
110
|
+
*
|
|
111
|
+
* @param {ContentPath} contentPath
|
|
112
|
+
* @returns {ContentPath[]}
|
|
113
|
+
*/ function resolvePathSymlinks(contentPath) {
|
|
114
|
+
let paths = [
|
|
115
|
+
contentPath
|
|
116
|
+
];
|
|
117
|
+
try {
|
|
118
|
+
let resolvedPath = _fs.default.realpathSync(contentPath.base);
|
|
119
|
+
if (resolvedPath !== contentPath.base) {
|
|
120
|
+
paths.push({
|
|
121
|
+
...contentPath,
|
|
122
|
+
base: resolvedPath
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
} catch {
|
|
126
|
+
// TODO: log this?
|
|
127
|
+
}
|
|
128
|
+
return paths;
|
|
129
|
+
}
|
|
130
|
+
function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
131
|
+
let changedContent = context.tailwindConfig.content.files.filter((item)=>typeof item.raw === "string").map(({ raw , extension ="html" })=>({
|
|
132
|
+
content: raw,
|
|
133
|
+
extension
|
|
134
|
+
}));
|
|
135
|
+
for (let changedFile of resolveChangedFiles(candidateFiles, fileModifiedMap)){
|
|
136
|
+
let content = _fs.default.readFileSync(changedFile, "utf8");
|
|
137
|
+
let extension = _path.default.extname(changedFile).slice(1);
|
|
138
|
+
changedContent.push({
|
|
139
|
+
content,
|
|
140
|
+
extension
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return changedContent;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
*
|
|
147
|
+
* @param {ContentPath[]} candidateFiles
|
|
148
|
+
* @param {Map<string, number>} fileModifiedMap
|
|
149
|
+
* @returns {Set<string>}
|
|
150
|
+
*/ function resolveChangedFiles(candidateFiles, fileModifiedMap) {
|
|
151
|
+
let paths = candidateFiles.map((contentPath)=>contentPath.pattern);
|
|
152
|
+
let changedFiles = new Set();
|
|
153
|
+
_sharedState.env.DEBUG && console.time("Finding changed files");
|
|
154
|
+
let files = _fastGlob.default.sync(paths, {
|
|
155
|
+
absolute: true
|
|
156
|
+
});
|
|
157
|
+
for (let file of files){
|
|
158
|
+
let prevModified = fileModifiedMap.has(file) ? fileModifiedMap.get(file) : -Infinity;
|
|
159
|
+
let modified = _fs.default.statSync(file).mtimeMs;
|
|
160
|
+
if (modified > prevModified) {
|
|
161
|
+
changedFiles.add(file);
|
|
162
|
+
fileModifiedMap.set(file, modified);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
_sharedState.env.DEBUG && console.timeEnd("Finding changed files");
|
|
166
|
+
return changedFiles;
|
|
167
|
+
}
|