tailwindcss 0.0.0-insiders.bbafc8e → 0.0.0-insiders.bbf2b1b
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 +163 -8
- package/README.md +6 -3
- package/colors.d.ts +3 -0
- package/defaultConfig.d.ts +3 -0
- package/defaultTheme.d.ts +4 -0
- package/lib/cli-peer-dependencies.js +20 -7
- package/lib/cli.js +314 -247
- package/lib/constants.js +27 -20
- package/lib/corePluginList.js +6 -3
- package/lib/corePlugins.js +1719 -1628
- package/lib/css/preflight.css +1 -8
- package/lib/featureFlags.js +27 -18
- package/lib/index.js +17 -15
- package/lib/lib/cacheInvalidation.js +45 -24
- package/lib/lib/collapseAdjacentRules.js +14 -9
- package/lib/lib/collapseDuplicateDeclarations.js +12 -9
- package/lib/lib/defaultExtractor.js +220 -33
- package/lib/lib/detectNesting.js +13 -10
- package/lib/lib/evaluateTailwindFunctions.js +101 -54
- package/lib/lib/expandApplyAtRules.js +254 -209
- package/lib/lib/expandTailwindAtRules.js +86 -69
- package/lib/lib/generateRules.js +244 -145
- package/lib/lib/getModuleDependencies.js +11 -8
- package/lib/lib/normalizeTailwindDirectives.js +35 -32
- package/lib/lib/partitionApplyAtRules.js +11 -8
- package/lib/lib/regex.js +60 -0
- package/lib/lib/resolveDefaultsAtRules.js +89 -71
- package/lib/lib/setupContextUtils.js +290 -205
- package/lib/lib/setupTrackingContext.js +44 -37
- package/lib/lib/sharedState.js +22 -16
- package/lib/lib/substituteScreenAtRules.js +11 -9
- package/lib/postcss-plugins/nesting/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +8 -6
- package/lib/postcss-plugins/nesting/plugin.js +18 -16
- package/lib/processTailwindFeatures.js +31 -28
- package/lib/public/colors.js +247 -245
- 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 +7 -5
- package/lib/util/cloneDeep.js +7 -6
- package/lib/util/cloneNodes.js +10 -3
- package/lib/util/color.js +53 -54
- package/lib/util/configurePlugins.js +4 -1
- package/lib/util/createPlugin.js +6 -5
- package/lib/util/createUtilityPlugin.js +9 -7
- package/lib/util/dataTypes.js +110 -100
- package/lib/util/defaults.js +4 -1
- package/lib/util/escapeClassName.js +7 -4
- package/lib/util/escapeCommas.js +5 -2
- package/lib/util/flattenColorPalette.js +9 -10
- package/lib/util/formatVariantSelector.js +100 -85
- package/lib/util/getAllConfigs.js +17 -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 +21 -13
- package/lib/util/log.js +18 -12
- package/lib/util/nameClass.js +17 -9
- package/lib/util/negateValue.js +8 -6
- package/lib/util/normalizeConfig.js +84 -71
- package/lib/util/normalizeScreens.js +22 -8
- package/lib/util/parseAnimationValue.js +42 -40
- package/lib/util/parseBoxShadowValue.js +29 -62
- package/lib/util/parseDependency.js +18 -15
- package/lib/util/parseObjectStyles.js +10 -7
- package/lib/util/pluginUtils.js +47 -31
- package/lib/util/prefixSelector.js +7 -4
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +88 -84
- package/lib/util/resolveConfigPath.js +10 -7
- package/lib/util/responsive.js +8 -5
- package/lib/util/splitAtTopLevelOnly.js +93 -0
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +5 -2
- package/lib/util/toPath.js +20 -4
- package/lib/util/transformThemeValue.js +30 -25
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/withAlphaVariable.js +23 -15
- package/package.json +32 -27
- package/peers/index.js +8612 -4245
- package/plugin.d.ts +11 -0
- package/resolveConfig.d.ts +3 -0
- package/scripts/generate-types.js +105 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +125 -25
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +145 -49
- package/src/css/preflight.css +1 -8
- package/src/featureFlags.js +2 -2
- package/src/lib/collapseAdjacentRules.js +5 -1
- package/src/lib/defaultExtractor.js +193 -35
- package/src/lib/evaluateTailwindFunctions.js +56 -6
- package/src/lib/expandApplyAtRules.js +252 -187
- package/src/lib/expandTailwindAtRules.js +4 -4
- package/src/lib/generateRules.js +156 -59
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +53 -36
- package/src/lib/setupContextUtils.js +142 -46
- package/src/lib/setupTrackingContext.js +5 -1
- package/src/postcss-plugins/nesting/README.md +2 -2
- package/src/util/cloneNodes.js +5 -1
- package/src/util/color.js +25 -21
- package/src/util/dataTypes.js +13 -7
- package/src/util/formatVariantSelector.js +82 -63
- package/src/util/getAllConfigs.js +8 -0
- package/src/util/log.js +1 -1
- package/src/util/normalizeConfig.js +0 -8
- package/src/util/parseBoxShadowValue.js +3 -50
- package/src/util/pluginUtils.js +13 -1
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +66 -52
- package/src/util/splitAtTopLevelOnly.js +71 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +4 -2
- package/src/util/validateConfig.js +13 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +5 -1
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +327 -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 +331 -0
- package/types/index.d.ts +7 -0
package/lib/css/preflight.css
CHANGED
|
@@ -160,6 +160,7 @@ select,
|
|
|
160
160
|
textarea {
|
|
161
161
|
font-family: inherit; /* 1 */
|
|
162
162
|
font-size: 100%; /* 1 */
|
|
163
|
+
font-weight: inherit; /* 1 */
|
|
163
164
|
line-height: inherit; /* 1 */
|
|
164
165
|
color: inherit; /* 1 */
|
|
165
166
|
margin: 0; /* 2 */
|
|
@@ -357,11 +358,3 @@ video {
|
|
|
357
358
|
max-width: 100%;
|
|
358
359
|
height: auto;
|
|
359
360
|
}
|
|
360
|
-
|
|
361
|
-
/*
|
|
362
|
-
Ensure the default browser behavior of the `hidden` attribute.
|
|
363
|
-
*/
|
|
364
|
-
|
|
365
|
-
[hidden] {
|
|
366
|
-
display: none;
|
|
367
|
-
}
|
package/lib/featureFlags.js
CHANGED
|
@@ -2,11 +2,19 @@
|
|
|
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
|
|
@@ -16,44 +24,45 @@ let defaults = {
|
|
|
16
24
|
optimizeUniversalDefaults: false
|
|
17
25
|
};
|
|
18
26
|
let featureFlags = {
|
|
19
|
-
future: [
|
|
27
|
+
future: [
|
|
28
|
+
"hoverOnlyWhenSupported",
|
|
29
|
+
"respectDefaultRingColorOpacity"
|
|
30
|
+
],
|
|
20
31
|
experimental: [
|
|
21
|
-
|
|
32
|
+
"optimizeUniversalDefaults",
|
|
33
|
+
"matchVariant" /* , 'variantGrouping' */
|
|
22
34
|
]
|
|
23
35
|
};
|
|
24
36
|
function flagEnabled(config, flag) {
|
|
25
37
|
if (featureFlags.future.includes(flag)) {
|
|
26
38
|
var ref;
|
|
27
39
|
var ref1, ref2;
|
|
28
|
-
return config.future ===
|
|
40
|
+
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);
|
|
29
41
|
}
|
|
30
42
|
if (featureFlags.experimental.includes(flag)) {
|
|
31
43
|
var ref3;
|
|
32
44
|
var ref4, ref5;
|
|
33
|
-
return config.experimental ===
|
|
45
|
+
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);
|
|
34
46
|
}
|
|
35
47
|
return false;
|
|
36
48
|
}
|
|
37
49
|
function experimentalFlagsEnabled(config) {
|
|
38
|
-
if (config.experimental ===
|
|
50
|
+
if (config.experimental === "all") {
|
|
39
51
|
return featureFlags.experimental;
|
|
40
52
|
}
|
|
41
53
|
var ref;
|
|
42
|
-
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]
|
|
43
|
-
);
|
|
54
|
+
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]);
|
|
44
55
|
}
|
|
45
56
|
function issueFlagNotices(config) {
|
|
46
57
|
if (process.env.JEST_WORKER_ID !== undefined) {
|
|
47
58
|
return;
|
|
48
59
|
}
|
|
49
60
|
if (experimentalFlagsEnabled(config).length > 0) {
|
|
50
|
-
let changes = experimentalFlagsEnabled(config).map((s)=>_picocolors.default.yellow(s)
|
|
51
|
-
|
|
52
|
-
_log.default.warn('experimental-flags-enabled', [
|
|
61
|
+
let changes = experimentalFlagsEnabled(config).map((s)=>_picocolors.default.yellow(s)).join(", ");
|
|
62
|
+
_log.default.warn("experimental-flags-enabled", [
|
|
53
63
|
`You have enabled experimental features: ${changes}`,
|
|
54
|
-
|
|
64
|
+
"Experimental features in Tailwind CSS are not covered by semver, may introduce breaking changes, and can change at any time.",
|
|
55
65
|
]);
|
|
56
66
|
}
|
|
57
67
|
}
|
|
58
|
-
|
|
59
|
-
exports.default = _default;
|
|
68
|
+
const _default = featureFlags;
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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");
|
|
5
8
|
function _interopRequireDefault(obj) {
|
|
6
9
|
return obj && obj.__esModule ? obj : {
|
|
7
10
|
default: obj
|
|
@@ -9,30 +12,29 @@ function _interopRequireDefault(obj) {
|
|
|
9
12
|
}
|
|
10
13
|
module.exports = function tailwindcss(configOrPath) {
|
|
11
14
|
return {
|
|
12
|
-
postcssPlugin:
|
|
15
|
+
postcssPlugin: "tailwindcss",
|
|
13
16
|
plugins: [
|
|
14
17
|
_sharedState.env.DEBUG && function(root) {
|
|
15
|
-
console.log(
|
|
16
|
-
console.time(
|
|
18
|
+
console.log("\n");
|
|
19
|
+
console.time("JIT TOTAL");
|
|
17
20
|
return root;
|
|
18
21
|
},
|
|
19
22
|
function(root, result) {
|
|
20
|
-
let context = (0, _setupTrackingContext
|
|
21
|
-
if (root.type ===
|
|
22
|
-
let roots = root.nodes.filter((node)=>node.type ===
|
|
23
|
-
);
|
|
23
|
+
let context = (0, _setupTrackingContext.default)(configOrPath);
|
|
24
|
+
if (root.type === "document") {
|
|
25
|
+
let roots = root.nodes.filter((node)=>node.type === "root");
|
|
24
26
|
for (const root1 of roots){
|
|
25
|
-
if (root1.type ===
|
|
26
|
-
(0, _processTailwindFeatures
|
|
27
|
+
if (root1.type === "root") {
|
|
28
|
+
(0, _processTailwindFeatures.default)(context)(root1, result);
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
return;
|
|
30
32
|
}
|
|
31
|
-
(0, _processTailwindFeatures
|
|
33
|
+
(0, _processTailwindFeatures.default)(context)(root, result);
|
|
32
34
|
},
|
|
33
35
|
_sharedState.env.DEBUG && function(root) {
|
|
34
|
-
console.timeEnd(
|
|
35
|
-
console.log(
|
|
36
|
+
console.timeEnd("JIT TOTAL");
|
|
37
|
+
console.log("\n");
|
|
36
38
|
return root;
|
|
37
39
|
},
|
|
38
40
|
].filter(Boolean)
|
|
@@ -2,34 +2,55 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
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"));
|
|
8
11
|
function _interopRequireDefault(obj) {
|
|
9
12
|
return obj && obj.__esModule ? obj : {
|
|
10
13
|
default: obj
|
|
11
14
|
};
|
|
12
15
|
}
|
|
13
|
-
function
|
|
14
|
-
if (
|
|
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) {
|
|
15
26
|
return obj;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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];
|
|
28
46
|
}
|
|
29
47
|
}
|
|
30
|
-
newObj.default = obj;
|
|
31
|
-
return newObj;
|
|
32
48
|
}
|
|
49
|
+
newObj.default = obj;
|
|
50
|
+
if (cache) {
|
|
51
|
+
cache.set(obj, newObj);
|
|
52
|
+
}
|
|
53
|
+
return newObj;
|
|
33
54
|
}
|
|
34
55
|
/**
|
|
35
56
|
* Calculate the hash of a string.
|
|
@@ -49,21 +70,21 @@ function _interopRequireWildcard(obj) {
|
|
|
49
70
|
* @param {string} str
|
|
50
71
|
*/ function getHash(str) {
|
|
51
72
|
try {
|
|
52
|
-
return _crypto.default.createHash(
|
|
73
|
+
return _crypto.default.createHash("md5").update(str, "utf-8").digest("binary");
|
|
53
74
|
} catch (err) {
|
|
54
|
-
return
|
|
75
|
+
return "";
|
|
55
76
|
}
|
|
56
77
|
}
|
|
57
78
|
function hasContentChanged(sourcePath, root) {
|
|
58
79
|
let css = root.toString();
|
|
59
80
|
// We only care about files with @tailwind directives
|
|
60
81
|
// Other files use an existing context
|
|
61
|
-
if (!css.includes(
|
|
82
|
+
if (!css.includes("@tailwind")) {
|
|
62
83
|
return false;
|
|
63
84
|
}
|
|
64
|
-
let existingHash =
|
|
85
|
+
let existingHash = _sharedState.sourceHashMap.get(sourcePath);
|
|
65
86
|
let rootHash = getHash(css);
|
|
66
87
|
let didChange = existingHash !== rootHash;
|
|
67
|
-
|
|
88
|
+
_sharedState.sourceHashMap.set(sourcePath, rootHash);
|
|
68
89
|
return didChange;
|
|
69
90
|
}
|
|
@@ -2,14 +2,17 @@
|
|
|
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));
|
|
@@ -27,11 +30,13 @@ 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;
|
|
@@ -43,7 +48,7 @@ function collapseAdjacentRules() {
|
|
|
43
48
|
// explicitly does not handle rule nesting on its own as
|
|
44
49
|
// the user is expected to use a nesting plugin
|
|
45
50
|
root.each((node)=>{
|
|
46
|
-
if (node.type ===
|
|
51
|
+
if (node.type === "atrule") {
|
|
47
52
|
collapseRulesIn(node);
|
|
48
53
|
}
|
|
49
54
|
});
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>collapseDuplicateDeclarations
|
|
8
|
+
});
|
|
6
9
|
function collapseDuplicateDeclarations() {
|
|
7
10
|
return (root)=>{
|
|
8
11
|
root.walkRules((node)=>{
|
|
@@ -41,35 +44,35 @@ function collapseDuplicateDeclarations() {
|
|
|
41
44
|
});
|
|
42
45
|
// Drop all the duplicate declarations with the exact same value we've
|
|
43
46
|
// already seen so far.
|
|
44
|
-
for (let
|
|
45
|
-
|
|
47
|
+
for (let decl of droppable){
|
|
48
|
+
decl.remove();
|
|
46
49
|
}
|
|
47
50
|
// Analyze the declarations based on its unit, drop all the declarations
|
|
48
51
|
// with the same unit but the last one in the list.
|
|
49
52
|
for (let declarations of byProperty.values()){
|
|
50
53
|
let byUnit = new Map();
|
|
51
|
-
for (let
|
|
52
|
-
let unit = resolveUnit(
|
|
54
|
+
for (let decl1 of declarations){
|
|
55
|
+
let unit = resolveUnit(decl1.value);
|
|
53
56
|
if (unit === null) {
|
|
54
57
|
continue;
|
|
55
58
|
}
|
|
56
59
|
if (!byUnit.has(unit)) {
|
|
57
60
|
byUnit.set(unit, new Set());
|
|
58
61
|
}
|
|
59
|
-
byUnit.get(unit).add(
|
|
62
|
+
byUnit.get(unit).add(decl1);
|
|
60
63
|
}
|
|
61
64
|
for (let declarations1 of byUnit.values()){
|
|
62
65
|
// Get all but the last one
|
|
63
66
|
let removableDeclarations = Array.from(declarations1).slice(0, -1);
|
|
64
|
-
for (let
|
|
65
|
-
|
|
67
|
+
for (let decl2 of removableDeclarations){
|
|
68
|
+
decl2.remove();
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
72
|
});
|
|
70
73
|
};
|
|
71
74
|
}
|
|
72
|
-
let UNITLESS_NUMBER = Symbol(
|
|
75
|
+
let UNITLESS_NUMBER = Symbol("unitless-number");
|
|
73
76
|
function resolveUnit(input) {
|
|
74
77
|
let result = /^-?\d*.?\d+([\w%]+)?$/g.exec(input);
|
|
75
78
|
if (result) {
|
|
@@ -2,39 +2,226 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
5
|
+
Object.defineProperty(exports, "defaultExtractor", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>defaultExtractor
|
|
8
|
+
});
|
|
9
|
+
const _featureFlags = require("../featureFlags");
|
|
10
|
+
const _regex = /*#__PURE__*/ _interopRequireWildcard(require("./regex"));
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
12
|
+
if (typeof WeakMap !== "function") return null;
|
|
13
|
+
var cacheBabelInterop = new WeakMap();
|
|
14
|
+
var cacheNodeInterop = new WeakMap();
|
|
15
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
16
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
17
|
+
})(nodeInterop);
|
|
18
|
+
}
|
|
19
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
20
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
21
|
+
return obj;
|
|
22
|
+
}
|
|
23
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
24
|
+
return {
|
|
25
|
+
default: obj
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
29
|
+
if (cache && cache.has(obj)) {
|
|
30
|
+
return cache.get(obj);
|
|
31
|
+
}
|
|
32
|
+
var newObj = {};
|
|
33
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
34
|
+
for(var key in obj){
|
|
35
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
36
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
37
|
+
if (desc && (desc.get || desc.set)) {
|
|
38
|
+
Object.defineProperty(newObj, key, desc);
|
|
39
|
+
} else {
|
|
40
|
+
newObj[key] = obj[key];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
newObj.default = obj;
|
|
45
|
+
if (cache) {
|
|
46
|
+
cache.set(obj, newObj);
|
|
47
|
+
}
|
|
48
|
+
return newObj;
|
|
49
|
+
}
|
|
50
|
+
function defaultExtractor(context) {
|
|
51
|
+
let patterns = Array.from(buildRegExps(context));
|
|
52
|
+
/**
|
|
53
|
+
* @param {string} content
|
|
54
|
+
*/ return (content)=>{
|
|
55
|
+
/** @type {(string|string)[]} */ let results = [];
|
|
56
|
+
for (let pattern of patterns){
|
|
57
|
+
var ref;
|
|
58
|
+
results = [
|
|
59
|
+
...results,
|
|
60
|
+
...(ref = content.match(pattern)) !== null && ref !== void 0 ? ref : []
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
return results.filter((v)=>v !== undefined).map(clipAtBalancedParens);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function* buildRegExps(context) {
|
|
67
|
+
let separator = context.tailwindConfig.separator;
|
|
68
|
+
let variantGroupingEnabled = (0, _featureFlags.flagEnabled)(context.tailwindConfig, "variantGrouping");
|
|
69
|
+
let prefix = context.tailwindConfig.prefix !== "" ? _regex.optional(_regex.pattern([
|
|
70
|
+
/-?/,
|
|
71
|
+
_regex.escape(context.tailwindConfig.prefix)
|
|
72
|
+
])) : "";
|
|
73
|
+
let utility = _regex.any([
|
|
74
|
+
// Arbitrary properties
|
|
75
|
+
/\[[^\s:'"`]+:[^\s\]]+\]/,
|
|
76
|
+
// Utilities
|
|
77
|
+
_regex.pattern([
|
|
78
|
+
// Utility Name / Group Name
|
|
79
|
+
/-?(?:\w+)/,
|
|
80
|
+
// Normal/Arbitrary values
|
|
81
|
+
_regex.optional(_regex.any([
|
|
82
|
+
_regex.pattern([
|
|
83
|
+
// Arbitrary values
|
|
84
|
+
/-(?:\w+-)*\[[^\s:]+\]/,
|
|
85
|
+
// Not immediately followed by an `{[(`
|
|
86
|
+
/(?![{([]])/,
|
|
87
|
+
// optionally followed by an opacity modifier
|
|
88
|
+
/(?:\/[^\s'"`\\><$]*)?/,
|
|
89
|
+
]),
|
|
90
|
+
_regex.pattern([
|
|
91
|
+
// Arbitrary values
|
|
92
|
+
/-(?:\w+-)*\[[^\s]+\]/,
|
|
93
|
+
// Not immediately followed by an `{[(`
|
|
94
|
+
/(?![{([]])/,
|
|
95
|
+
// optionally followed by an opacity modifier
|
|
96
|
+
/(?:\/[^\s'"`\\$]*)?/,
|
|
97
|
+
]),
|
|
98
|
+
// Normal values w/o quotes — may include an opacity modifier
|
|
99
|
+
/[-\/][^\s'"`\\$={><]*/,
|
|
100
|
+
])),
|
|
101
|
+
]),
|
|
102
|
+
]);
|
|
103
|
+
let variantPatterns = [
|
|
104
|
+
// Without quotes
|
|
105
|
+
_regex.any([
|
|
106
|
+
_regex.pattern([
|
|
107
|
+
/([^\s"'`\[\\]+-)?\[[^\s"'`]+\]/,
|
|
108
|
+
separator
|
|
109
|
+
]),
|
|
110
|
+
_regex.pattern([
|
|
111
|
+
/[^\s"'`\[\\]+/,
|
|
112
|
+
separator
|
|
113
|
+
]),
|
|
114
|
+
]),
|
|
115
|
+
// With quotes allowed
|
|
116
|
+
_regex.any([
|
|
117
|
+
_regex.pattern([
|
|
118
|
+
/([^\s"'`\[\\]+-)?\[[^\s`]+\]/,
|
|
119
|
+
separator
|
|
120
|
+
]),
|
|
121
|
+
_regex.pattern([
|
|
122
|
+
/[^\s`\[\\]+/,
|
|
123
|
+
separator
|
|
124
|
+
]),
|
|
125
|
+
]),
|
|
126
|
+
];
|
|
127
|
+
for (const variantPattern of variantPatterns){
|
|
128
|
+
yield _regex.pattern([
|
|
129
|
+
// Variants
|
|
130
|
+
"((?=((",
|
|
131
|
+
variantPattern,
|
|
132
|
+
")+))\\2)?",
|
|
133
|
+
// Important (optional)
|
|
134
|
+
/!?/,
|
|
135
|
+
prefix,
|
|
136
|
+
variantGroupingEnabled ? _regex.any([
|
|
137
|
+
// Or any of those things but grouped separated by commas
|
|
138
|
+
_regex.pattern([
|
|
139
|
+
/\(/,
|
|
140
|
+
utility,
|
|
141
|
+
_regex.zeroOrMore([
|
|
142
|
+
/,/,
|
|
143
|
+
utility
|
|
144
|
+
]),
|
|
145
|
+
/\)/
|
|
146
|
+
]),
|
|
147
|
+
// Arbitrary properties, constrained utilities, arbitrary values, etc…
|
|
148
|
+
utility,
|
|
149
|
+
]) : utility,
|
|
150
|
+
]);
|
|
151
|
+
}
|
|
152
|
+
// 5. Inner matches
|
|
153
|
+
yield /[^<>"'`\s.(){}[\]#=%$]*[^<>"'`\s.(){}[\]#=%:$]/g;
|
|
154
|
+
}
|
|
155
|
+
// We want to capture any "special" characters
|
|
156
|
+
// AND the characters immediately following them (if there is one)
|
|
157
|
+
let SPECIALS = /([\[\]'"`])([^\[\]'"`])?/g;
|
|
158
|
+
let ALLOWED_CLASS_CHARACTERS = /[^"'`\s<>\]]+/;
|
|
159
|
+
/**
|
|
160
|
+
* Clips a string ensuring that parentheses, quotes, etc… are balanced
|
|
161
|
+
* Used for arbitrary values only
|
|
162
|
+
*
|
|
163
|
+
* We will go past the end of the balanced parens until we find a non-class character
|
|
164
|
+
*
|
|
165
|
+
* Depth matching behavior:
|
|
166
|
+
* w-[calc(100%-theme('spacing[some_key][1.5]'))]']
|
|
167
|
+
* ┬ ┬ ┬┬ ┬ ┬┬ ┬┬┬┬┬┬┬
|
|
168
|
+
* 1 2 3 4 34 3 210 END
|
|
169
|
+
* ╰────┴──────────┴────────┴────────┴┴───┴─┴┴┴
|
|
170
|
+
*
|
|
171
|
+
* @param {string} input
|
|
172
|
+
*/ function clipAtBalancedParens(input) {
|
|
173
|
+
// We are care about this for arbitrary values
|
|
174
|
+
if (!input.includes("-[")) {
|
|
175
|
+
return input;
|
|
176
|
+
}
|
|
177
|
+
let depth = 0;
|
|
178
|
+
let openStringTypes = [];
|
|
179
|
+
// Find all parens, brackets, quotes, etc
|
|
180
|
+
// Stop when we end at a balanced pair
|
|
181
|
+
// This is naive and will treat mismatched parens as balanced
|
|
182
|
+
// This shouldn't be a problem in practice though
|
|
183
|
+
let matches = input.matchAll(SPECIALS);
|
|
184
|
+
// We can't use lookbehind assertions because we have to support Safari
|
|
185
|
+
// So, instead, we've emulated it using capture groups and we'll re-work the matches to accommodate
|
|
186
|
+
matches = Array.from(matches).flatMap((match)=>{
|
|
187
|
+
const [, ...groups] = match;
|
|
188
|
+
return groups.map((group, idx)=>Object.assign([], match, {
|
|
189
|
+
index: match.index + idx,
|
|
190
|
+
0: group
|
|
191
|
+
}));
|
|
192
|
+
});
|
|
193
|
+
for (let match of matches){
|
|
194
|
+
let char = match[0];
|
|
195
|
+
let inStringType = openStringTypes[openStringTypes.length - 1];
|
|
196
|
+
if (char === inStringType) {
|
|
197
|
+
openStringTypes.pop();
|
|
198
|
+
} else if (char === "'" || char === '"' || char === "`") {
|
|
199
|
+
openStringTypes.push(char);
|
|
200
|
+
}
|
|
201
|
+
if (inStringType) {
|
|
202
|
+
continue;
|
|
203
|
+
} else if (char === "[") {
|
|
204
|
+
depth++;
|
|
205
|
+
continue;
|
|
206
|
+
} else if (char === "]") {
|
|
207
|
+
depth--;
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
// We've gone one character past the point where we should stop
|
|
211
|
+
// This means that there was an extra closing `]`
|
|
212
|
+
// We'll clip to just before it
|
|
213
|
+
if (depth < 0) {
|
|
214
|
+
return input.substring(0, match.index);
|
|
215
|
+
}
|
|
216
|
+
// We've finished balancing the brackets but there still may be characters that can be included
|
|
217
|
+
// For example in the class `text-[#336699]/[.35]`
|
|
218
|
+
// The depth goes to `0` at the closing `]` but goes up again at the `[`
|
|
219
|
+
// If we're at zero and encounter a non-class character then we clip the class there
|
|
220
|
+
if (depth === 0 && !ALLOWED_CLASS_CHARACTERS.test(char)) {
|
|
221
|
+
return input.substring(0, match.index);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return input;
|
|
38
225
|
} // Regular utilities
|
|
39
226
|
// {{modifier}:}*{namespace}{-{suffix}}*{/{opacityModifier}}?
|
|
40
227
|
// Arbitrary values
|