tailwindcss 0.0.0-oxide-insiders.a7fe2fe → 0.0.0-oxide-insiders.7f555c4
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/lib/cli/build/deps.js +34 -18
- package/lib/cli/build/index.js +45 -12
- package/lib/cli/build/plugin.js +273 -90
- package/lib/cli/build/utils.js +56 -24
- package/lib/cli/build/watching.js +156 -38
- package/lib/cli/help/index.js +61 -16
- package/lib/cli/index.js +121 -62
- package/lib/cli/init/index.js +47 -23
- package/lib/cli-peer-dependencies.js +23 -13
- package/lib/cli.js +5 -1
- package/lib/corePluginList.js +7 -4
- package/lib/corePlugins.js +855 -386
- package/lib/featureFlags.js +43 -18
- package/lib/lib/cacheInvalidation.js +78 -30
- package/lib/lib/collapseAdjacentRules.js +46 -23
- package/lib/lib/collapseDuplicateDeclarations.js +70 -27
- package/lib/lib/content.js +134 -41
- package/lib/lib/defaultExtractor.js +201 -96
- package/lib/lib/detectNesting.js +38 -12
- package/lib/lib/evaluateTailwindFunctions.js +192 -103
- package/lib/lib/expandApplyAtRules.js +488 -181
- package/lib/lib/expandTailwindAtRules.js +240 -70
- package/lib/lib/findAtConfigPath.js +34 -15
- package/lib/lib/generateRules.js +775 -353
- package/lib/lib/getModuleDependencies.js +67 -29
- package/lib/lib/load-config.js +27 -17
- package/lib/lib/normalizeTailwindDirectives.js +73 -27
- package/lib/lib/offsets.js +227 -62
- package/lib/lib/partitionApplyAtRules.js +53 -29
- package/lib/lib/regex.js +50 -28
- package/lib/lib/remap-bitfield.js +86 -9
- package/lib/lib/resolveDefaultsAtRules.js +123 -53
- package/lib/lib/setupContextUtils.js +1117 -584
- package/lib/lib/setupTrackingContext.js +149 -58
- package/lib/lib/sharedState.js +71 -23
- package/lib/lib/substituteScreenAtRules.js +19 -9
- package/lib/oxide/cli/build/deps.js +46 -23
- package/lib/oxide/cli/build/index.js +44 -12
- package/lib/oxide/cli/build/plugin.js +271 -89
- package/lib/oxide/cli/build/utils.js +55 -24
- package/lib/oxide/cli/build/watching.js +153 -36
- package/lib/oxide/cli/help/index.js +60 -16
- package/lib/oxide/cli/index.js +128 -67
- package/lib/oxide/cli/init/index.js +40 -19
- package/lib/oxide/cli.js +3 -2
- package/lib/plugin.js +58 -31
- package/lib/postcss-plugins/nesting/index.js +13 -7
- package/lib/postcss-plugins/nesting/plugin.js +65 -20
- package/lib/processTailwindFeatures.js +41 -10
- package/lib/public/colors.js +25 -16
- package/lib/public/create-plugin.js +11 -6
- package/lib/public/default-config.js +12 -6
- package/lib/public/default-theme.js +12 -6
- package/lib/public/load-config.js +9 -5
- package/lib/public/resolve-config.js +10 -6
- package/lib/util/applyImportantSelector.js +28 -17
- package/lib/util/bigSign.js +9 -6
- package/lib/util/buildMediaQuery.js +19 -10
- package/lib/util/cloneDeep.js +19 -9
- package/lib/util/cloneNodes.js +29 -14
- package/lib/util/color.js +87 -47
- package/lib/util/colorNames.js +752 -0
- package/lib/util/configurePlugins.js +18 -9
- package/lib/util/createPlugin.js +17 -8
- package/lib/util/createUtilityPlugin.js +30 -16
- package/lib/util/dataTypes.js +189 -38
- package/lib/util/defaults.js +21 -9
- package/lib/util/escapeClassName.js +15 -9
- package/lib/util/escapeCommas.js +9 -6
- package/lib/util/flattenColorPalette.js +11 -7
- package/lib/util/formatVariantSelector.js +209 -60
- package/lib/util/getAllConfigs.js +44 -35
- package/lib/util/hashConfig.js +12 -8
- package/lib/util/isKeyframeRule.js +10 -7
- package/lib/util/isPlainObject.js +14 -9
- package/lib/util/isSyntacticallyValidPropertyValue.js +45 -14
- package/lib/util/log.js +20 -9
- package/lib/util/nameClass.js +31 -10
- package/lib/util/negateValue.js +28 -10
- package/lib/util/normalizeConfig.js +242 -63
- package/lib/util/normalizeScreens.js +145 -70
- package/lib/util/parseAnimationValue.js +64 -14
- package/lib/util/parseBoxShadowValue.js +63 -14
- package/lib/util/parseDependency.js +39 -13
- package/lib/util/parseGlob.js +25 -8
- package/lib/util/parseObjectStyles.js +29 -18
- package/lib/util/pluginUtils.js +196 -77
- package/lib/util/prefixSelector.js +31 -12
- package/lib/util/pseudoElements.js +116 -34
- package/lib/util/removeAlphaVariables.js +23 -8
- package/lib/util/resolveConfig.js +224 -105
- package/lib/util/resolveConfigPath.js +45 -15
- package/lib/util/responsive.js +10 -6
- package/lib/util/splitAtTopLevelOnly.js +46 -10
- package/lib/util/tap.js +11 -7
- package/lib/util/toColorValue.js +10 -7
- package/lib/util/toPath.js +28 -8
- package/lib/util/transformThemeValue.js +49 -14
- package/lib/util/validateConfig.js +25 -15
- package/lib/util/validateFormalSyntax.js +14 -6
- package/lib/util/withAlphaVariable.js +54 -30
- package/package.json +18 -22
- package/peers/index.js +57849 -43101
- package/src/lib/expandTailwindAtRules.js +1 -1
- package/src/lib/setupTrackingContext.js +1 -1
- package/src/util/color.js +1 -1
- package/src/util/colorNames.js +150 -0
- package/src/util/pseudoElements.js +4 -4
package/lib/featureFlags.js
CHANGED
|
@@ -1,32 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value:
|
|
4
|
-
})
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
5
6
|
for(var name in all)Object.defineProperty(target, name, {
|
|
6
|
-
enumerable:
|
|
7
|
+
enumerable: true,
|
|
7
8
|
get: all[name]
|
|
8
9
|
});
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
flagEnabled: function() {
|
|
13
|
+
return flagEnabled;
|
|
14
|
+
},
|
|
15
|
+
issueFlagNotices: function() {
|
|
16
|
+
return issueFlagNotices;
|
|
17
|
+
},
|
|
18
|
+
default: function() {
|
|
19
|
+
return _default;
|
|
20
|
+
}
|
|
13
21
|
});
|
|
14
|
-
const _picocolors =
|
|
15
|
-
|
|
22
|
+
const _picocolors = /*#__PURE__*/ _interop_require_default(require("picocolors"));
|
|
23
|
+
const _log = /*#__PURE__*/ _interop_require_default(require("./util/log"));
|
|
24
|
+
function _interop_require_default(obj) {
|
|
16
25
|
return obj && obj.__esModule ? obj : {
|
|
17
26
|
default: obj
|
|
18
27
|
};
|
|
19
28
|
}
|
|
20
29
|
let defaults = {
|
|
21
|
-
optimizeUniversalDefaults:
|
|
22
|
-
generalizedModifiers:
|
|
30
|
+
optimizeUniversalDefaults: false,
|
|
31
|
+
generalizedModifiers: true,
|
|
23
32
|
get disableColorOpacityUtilitiesByDefault () {
|
|
24
|
-
return
|
|
33
|
+
return true;
|
|
25
34
|
},
|
|
26
35
|
get relativeContentPathsByDefault () {
|
|
27
|
-
return
|
|
36
|
+
return true;
|
|
28
37
|
}
|
|
29
|
-
}
|
|
38
|
+
};
|
|
39
|
+
let featureFlags = {
|
|
30
40
|
future: [
|
|
31
41
|
"hoverOnlyWhenSupported",
|
|
32
42
|
"respectDefaultRingColorOpacity",
|
|
@@ -39,15 +49,30 @@ let defaults = {
|
|
|
39
49
|
]
|
|
40
50
|
};
|
|
41
51
|
function flagEnabled(config, flag) {
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
if (featureFlags.future.includes(flag)) {
|
|
53
|
+
var _config_future;
|
|
54
|
+
var _config_future_flag, _ref;
|
|
55
|
+
return config.future === "all" || ((_ref = (_config_future_flag = config === null || config === void 0 ? void 0 : (_config_future = config.future) === null || _config_future === void 0 ? void 0 : _config_future[flag]) !== null && _config_future_flag !== void 0 ? _config_future_flag : defaults[flag]) !== null && _ref !== void 0 ? _ref : false);
|
|
56
|
+
}
|
|
57
|
+
if (featureFlags.experimental.includes(flag)) {
|
|
58
|
+
var _config_experimental;
|
|
59
|
+
var _config_experimental_flag, _ref1;
|
|
60
|
+
return config.experimental === "all" || ((_ref1 = (_config_experimental_flag = config === null || config === void 0 ? void 0 : (_config_experimental = config.experimental) === null || _config_experimental === void 0 ? void 0 : _config_experimental[flag]) !== null && _config_experimental_flag !== void 0 ? _config_experimental_flag : defaults[flag]) !== null && _ref1 !== void 0 ? _ref1 : false);
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
44
63
|
}
|
|
45
64
|
function experimentalFlagsEnabled(config) {
|
|
65
|
+
if (config.experimental === "all") {
|
|
66
|
+
return featureFlags.experimental;
|
|
67
|
+
}
|
|
46
68
|
var _config_experimental;
|
|
47
|
-
return
|
|
69
|
+
return Object.keys((_config_experimental = config === null || config === void 0 ? void 0 : config.experimental) !== null && _config_experimental !== void 0 ? _config_experimental : {}).filter((flag)=>featureFlags.experimental.includes(flag) && config.experimental[flag]);
|
|
48
70
|
}
|
|
49
71
|
function issueFlagNotices(config) {
|
|
50
|
-
if (
|
|
72
|
+
if (process.env.JEST_WORKER_ID !== undefined) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (experimentalFlagsEnabled(config).length > 0) {
|
|
51
76
|
let changes = experimentalFlagsEnabled(config).map((s)=>_picocolors.default.yellow(s)).join(", ");
|
|
52
77
|
_log.default.warn("experimental-flags-enabled", [
|
|
53
78
|
`You have enabled experimental features: ${changes}`,
|
|
@@ -1,44 +1,92 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value:
|
|
4
|
-
}), Object.defineProperty(exports, "hasContentChanged", {
|
|
5
|
-
enumerable: !0,
|
|
6
|
-
get: ()=>hasContentChanged
|
|
3
|
+
value: true
|
|
7
4
|
});
|
|
8
|
-
|
|
5
|
+
Object.defineProperty(exports, "hasContentChanged", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return hasContentChanged;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _crypto = /*#__PURE__*/ _interop_require_default(require("crypto"));
|
|
12
|
+
const _sharedState = /*#__PURE__*/ _interop_require_wildcard(require("./sharedState"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
9
14
|
return obj && obj.__esModule ? obj : {
|
|
10
15
|
default: obj
|
|
11
16
|
};
|
|
12
|
-
}
|
|
13
|
-
if (!nodeInterop && obj && obj.__esModule) return obj;
|
|
14
|
-
if (null === obj || "object" != typeof obj && "function" != typeof obj) return {
|
|
15
|
-
default: obj
|
|
16
|
-
};
|
|
17
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
18
|
-
if (cache && cache.has(obj)) return cache.get(obj);
|
|
19
|
-
var newObj = {}, hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
20
|
-
for(var key in obj)if ("default" !== key && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
21
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
22
|
-
desc && (desc.get || desc.set) ? Object.defineProperty(newObj, key, desc) : newObj[key] = obj[key];
|
|
23
|
-
}
|
|
24
|
-
return newObj.default = obj, cache && cache.set(obj, newObj), newObj;
|
|
25
|
-
}(require("./sharedState"));
|
|
17
|
+
}
|
|
26
18
|
function _getRequireWildcardCache(nodeInterop) {
|
|
27
|
-
if ("function"
|
|
28
|
-
var cacheBabelInterop = new WeakMap()
|
|
19
|
+
if (typeof WeakMap !== "function") return null;
|
|
20
|
+
var cacheBabelInterop = new WeakMap();
|
|
21
|
+
var cacheNodeInterop = new WeakMap();
|
|
29
22
|
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
30
23
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
31
24
|
})(nodeInterop);
|
|
32
25
|
}
|
|
26
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
27
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
28
|
+
return obj;
|
|
29
|
+
}
|
|
30
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
31
|
+
return {
|
|
32
|
+
default: obj
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
36
|
+
if (cache && cache.has(obj)) {
|
|
37
|
+
return cache.get(obj);
|
|
38
|
+
}
|
|
39
|
+
var newObj = {};
|
|
40
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
41
|
+
for(var key in obj){
|
|
42
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
43
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
44
|
+
if (desc && (desc.get || desc.set)) {
|
|
45
|
+
Object.defineProperty(newObj, key, desc);
|
|
46
|
+
} else {
|
|
47
|
+
newObj[key] = obj[key];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
newObj.default = obj;
|
|
52
|
+
if (cache) {
|
|
53
|
+
cache.set(obj, newObj);
|
|
54
|
+
}
|
|
55
|
+
return newObj;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Calculate the hash of a string.
|
|
59
|
+
*
|
|
60
|
+
* This doesn't need to be cryptographically secure or
|
|
61
|
+
* anything like that since it's used only to detect
|
|
62
|
+
* when the CSS changes to invalidate the context.
|
|
63
|
+
*
|
|
64
|
+
* This is wrapped in a try/catch because it's really dependent
|
|
65
|
+
* on how Node itself is build and the environment and OpenSSL
|
|
66
|
+
* version / build that is installed on the user's machine.
|
|
67
|
+
*
|
|
68
|
+
* Based on the environment this can just outright fail.
|
|
69
|
+
*
|
|
70
|
+
* See https://github.com/nodejs/node/issues/40455
|
|
71
|
+
*
|
|
72
|
+
* @param {string} str
|
|
73
|
+
*/ function getHash(str) {
|
|
74
|
+
try {
|
|
75
|
+
return _crypto.default.createHash("md5").update(str, "utf-8").digest("binary");
|
|
76
|
+
} catch (err) {
|
|
77
|
+
return "";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
33
80
|
function hasContentChanged(sourcePath, root) {
|
|
34
81
|
let css = root.toString();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
82
|
+
// We only care about files with @tailwind directives
|
|
83
|
+
// Other files use an existing context
|
|
84
|
+
if (!css.includes("@tailwind")) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
let existingHash = _sharedState.sourceHashMap.get(sourcePath);
|
|
88
|
+
let rootHash = getHash(css);
|
|
89
|
+
let didChange = existingHash !== rootHash;
|
|
90
|
+
_sharedState.sourceHashMap.set(sourcePath, rootHash);
|
|
91
|
+
return didChange;
|
|
44
92
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value:
|
|
4
|
-
})
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return collapseAdjacentRules;
|
|
9
|
+
}
|
|
7
10
|
});
|
|
8
11
|
let comparisonMap = {
|
|
9
12
|
atrule: [
|
|
@@ -13,26 +16,46 @@ let comparisonMap = {
|
|
|
13
16
|
rule: [
|
|
14
17
|
"selector"
|
|
15
18
|
]
|
|
16
|
-
}
|
|
19
|
+
};
|
|
20
|
+
let types = new Set(Object.keys(comparisonMap));
|
|
17
21
|
function collapseAdjacentRules() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
function collapseRulesIn(root) {
|
|
23
|
+
let currentRule = null;
|
|
24
|
+
root.each((node)=>{
|
|
25
|
+
if (!types.has(node.type)) {
|
|
26
|
+
currentRule = null;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (currentRule === null) {
|
|
30
|
+
currentRule = node;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
let properties = comparisonMap[node.type];
|
|
34
|
+
var _node_property, _currentRule_property;
|
|
35
|
+
if (node.type === "atrule" && node.name === "font-face") {
|
|
36
|
+
currentRule = node;
|
|
37
|
+
} else if (properties.every((property)=>((_node_property = node[property]) !== null && _node_property !== void 0 ? _node_property : "").replace(/\s+/g, " ") === ((_currentRule_property = currentRule[property]) !== null && _currentRule_property !== void 0 ? _currentRule_property : "").replace(/\s+/g, " "))) {
|
|
38
|
+
// An AtRule may not have children (for example if we encounter duplicate @import url(…) rules)
|
|
39
|
+
if (node.nodes) {
|
|
40
|
+
currentRule.append(node.nodes);
|
|
26
41
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
node.remove();
|
|
43
|
+
} else {
|
|
44
|
+
currentRule = node;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
// After we've collapsed adjacent rules & at-rules, we need to collapse
|
|
48
|
+
// adjacent rules & at-rules that are children of at-rules.
|
|
49
|
+
// We do not care about nesting rules because Tailwind CSS
|
|
50
|
+
// explicitly does not handle rule nesting on its own as
|
|
51
|
+
// the user is expected to use a nesting plugin
|
|
52
|
+
root.each((node)=>{
|
|
53
|
+
if (node.type === "atrule") {
|
|
54
|
+
collapseRulesIn(node);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return (root)=>{
|
|
59
|
+
collapseRulesIn(root);
|
|
37
60
|
};
|
|
38
61
|
}
|
|
@@ -1,42 +1,85 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return collapseDuplicateDeclarations;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
2
11
|
function collapseDuplicateDeclarations() {
|
|
3
12
|
return (root)=>{
|
|
4
13
|
root.walkRules((node)=>{
|
|
5
|
-
let seen = new Map()
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
let seen = new Map();
|
|
15
|
+
let droppable = new Set([]);
|
|
16
|
+
let byProperty = new Map();
|
|
17
|
+
node.walkDecls((decl)=>{
|
|
18
|
+
// This could happen if we have nested selectors. In that case the
|
|
19
|
+
// parent will loop over all its declarations but also the declarations
|
|
20
|
+
// of nested rules. With this we ensure that we are shallowly checking
|
|
21
|
+
// declarations.
|
|
22
|
+
if (decl.parent !== node) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (seen.has(decl.prop)) {
|
|
26
|
+
// Exact same value as what we have seen so far
|
|
27
|
+
if (seen.get(decl.prop).value === decl.value) {
|
|
28
|
+
// Keep the last one, drop the one we've seen so far
|
|
29
|
+
droppable.add(seen.get(decl.prop));
|
|
30
|
+
// Override the existing one with the new value. This is necessary
|
|
31
|
+
// so that if we happen to have more than one declaration with the
|
|
32
|
+
// same value, that we keep removing the previous one. Otherwise we
|
|
33
|
+
// will only remove the *first* one.
|
|
34
|
+
seen.set(decl.prop, decl);
|
|
35
|
+
return;
|
|
14
36
|
}
|
|
15
|
-
|
|
37
|
+
// Not the same value, so we need to check if we can merge it so
|
|
38
|
+
// let's collect it first.
|
|
39
|
+
if (!byProperty.has(decl.prop)) {
|
|
40
|
+
byProperty.set(decl.prop, new Set());
|
|
41
|
+
}
|
|
42
|
+
byProperty.get(decl.prop).add(seen.get(decl.prop));
|
|
43
|
+
byProperty.get(decl.prop).add(decl);
|
|
16
44
|
}
|
|
17
|
-
|
|
45
|
+
seen.set(decl.prop, decl);
|
|
46
|
+
});
|
|
47
|
+
// Drop all the duplicate declarations with the exact same value we've
|
|
48
|
+
// already seen so far.
|
|
49
|
+
for (let decl of droppable){
|
|
50
|
+
decl.remove();
|
|
51
|
+
}
|
|
52
|
+
// Analyze the declarations based on its unit, drop all the declarations
|
|
53
|
+
// with the same unit but the last one in the list.
|
|
18
54
|
for (let declarations of byProperty.values()){
|
|
19
55
|
let byUnit = new Map();
|
|
20
56
|
for (let decl of declarations){
|
|
21
|
-
let unit =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
57
|
+
let unit = resolveUnit(decl.value);
|
|
58
|
+
if (unit === null) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (!byUnit.has(unit)) {
|
|
62
|
+
byUnit.set(unit, new Set());
|
|
63
|
+
}
|
|
64
|
+
byUnit.get(unit).add(decl);
|
|
65
|
+
}
|
|
66
|
+
for (let declarations of byUnit.values()){
|
|
67
|
+
// Get all but the last one
|
|
68
|
+
let removableDeclarations = Array.from(declarations).slice(0, -1);
|
|
69
|
+
for (let decl of removableDeclarations){
|
|
70
|
+
decl.remove();
|
|
71
|
+
}
|
|
30
72
|
}
|
|
31
|
-
for (let declarations of byUnit.values())for (let decl of Array.from(declarations).slice(0, -1))decl.remove();
|
|
32
73
|
}
|
|
33
74
|
});
|
|
34
75
|
};
|
|
35
76
|
}
|
|
36
|
-
Object.defineProperty(exports, "__esModule", {
|
|
37
|
-
value: !0
|
|
38
|
-
}), Object.defineProperty(exports, "default", {
|
|
39
|
-
enumerable: !0,
|
|
40
|
-
get: ()=>collapseDuplicateDeclarations
|
|
41
|
-
});
|
|
42
77
|
let UNITLESS_NUMBER = Symbol("unitless-number");
|
|
78
|
+
function resolveUnit(input) {
|
|
79
|
+
let result = /^-?\d*.?\d+([\w%]+)?$/g.exec(input);
|
|
80
|
+
if (result) {
|
|
81
|
+
var _result_;
|
|
82
|
+
return (_result_ = result[1]) !== null && _result_ !== void 0 ? _result_ : UNITLESS_NUMBER;
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
package/lib/lib/content.js
CHANGED
|
@@ -1,36 +1,65 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
"use strict";
|
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value:
|
|
4
|
-
})
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
function _export(target, all) {
|
|
5
7
|
for(var name in all)Object.defineProperty(target, name, {
|
|
6
|
-
enumerable:
|
|
8
|
+
enumerable: true,
|
|
7
9
|
get: all[name]
|
|
8
10
|
});
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
parseCandidateFiles: function() {
|
|
14
|
+
return parseCandidateFiles;
|
|
15
|
+
},
|
|
16
|
+
resolvedChangedContent: function() {
|
|
17
|
+
return resolvedChangedContent;
|
|
18
|
+
}
|
|
12
19
|
});
|
|
13
|
-
const _fs =
|
|
14
|
-
|
|
20
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
21
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
22
|
+
const _isglob = /*#__PURE__*/ _interop_require_default(require("is-glob"));
|
|
23
|
+
const _fastglob = /*#__PURE__*/ _interop_require_default(require("fast-glob"));
|
|
24
|
+
const _normalizepath = /*#__PURE__*/ _interop_require_default(require("normalize-path"));
|
|
25
|
+
const _parseGlob = require("../util/parseGlob");
|
|
26
|
+
const _sharedState = require("./sharedState");
|
|
27
|
+
function _interop_require_default(obj) {
|
|
15
28
|
return obj && obj.__esModule ? obj : {
|
|
16
29
|
default: obj
|
|
17
30
|
};
|
|
18
31
|
}
|
|
19
32
|
function parseCandidateFiles(context, tailwindConfig) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
files =
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
let files = tailwindConfig.content.files;
|
|
34
|
+
// Normalize the file globs
|
|
35
|
+
files = files.filter((filePath)=>typeof filePath === "string");
|
|
36
|
+
files = files.map(_normalizepath.default);
|
|
37
|
+
// Split into included and excluded globs
|
|
38
|
+
let tasks = _fastglob.default.generateTasks(files);
|
|
39
|
+
/** @type {ContentPath[]} */ let included = [];
|
|
40
|
+
/** @type {ContentPath[]} */ let excluded = [];
|
|
41
|
+
for (const task of tasks){
|
|
42
|
+
included.push(...task.positive.map((filePath)=>parseFilePath(filePath, false)));
|
|
43
|
+
excluded.push(...task.negative.map((filePath)=>parseFilePath(filePath, true)));
|
|
44
|
+
}
|
|
25
45
|
let paths = [
|
|
26
46
|
...included,
|
|
27
47
|
...excluded
|
|
28
48
|
];
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
49
|
+
// Resolve paths relative to the config file or cwd
|
|
50
|
+
paths = resolveRelativePaths(context, paths);
|
|
51
|
+
// Resolve symlinks if possible
|
|
52
|
+
paths = paths.flatMap(resolvePathSymlinks);
|
|
53
|
+
// Update cached patterns
|
|
54
|
+
paths = paths.map(resolveGlobPattern);
|
|
55
|
+
return paths;
|
|
32
56
|
}
|
|
33
|
-
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @param {string} filePath
|
|
60
|
+
* @param {boolean} ignore
|
|
61
|
+
* @returns {ContentPath}
|
|
62
|
+
*/ function parseFilePath(filePath, ignore) {
|
|
34
63
|
let contentPath = {
|
|
35
64
|
original: filePath,
|
|
36
65
|
base: filePath,
|
|
@@ -38,42 +67,79 @@ function parseFilePath(filePath, ignore) {
|
|
|
38
67
|
pattern: filePath,
|
|
39
68
|
glob: null
|
|
40
69
|
};
|
|
41
|
-
|
|
70
|
+
if ((0, _isglob.default)(filePath)) {
|
|
71
|
+
Object.assign(contentPath, (0, _parseGlob.parseGlob)(filePath));
|
|
72
|
+
}
|
|
73
|
+
return contentPath;
|
|
42
74
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* @param {ContentPath} contentPath
|
|
78
|
+
* @returns {ContentPath}
|
|
79
|
+
*/ function resolveGlobPattern(contentPath) {
|
|
80
|
+
// This is required for Windows support to properly pick up Glob paths.
|
|
81
|
+
// Afaik, this technically shouldn't be needed but there's probably
|
|
82
|
+
// some internal, direct path matching with a normalized path in
|
|
83
|
+
// a package which can't handle mixed directory separators
|
|
84
|
+
let base = (0, _normalizepath.default)(contentPath.base);
|
|
85
|
+
// If the user's file path contains any special characters (like parens) for instance fast-glob
|
|
86
|
+
// is like "OOOH SHINY" and treats them as such. So we have to escape the base path to fix this
|
|
87
|
+
base = _fastglob.default.escapePath(base);
|
|
88
|
+
contentPath.pattern = contentPath.glob ? `${base}/${contentPath.glob}` : base;
|
|
89
|
+
contentPath.pattern = contentPath.ignore ? `!${contentPath.pattern}` : contentPath.pattern;
|
|
90
|
+
return contentPath;
|
|
46
91
|
}
|
|
47
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Resolve each path relative to the config file (when possible) if the experimental flag is enabled
|
|
94
|
+
* Otherwise, resolve relative to the current working directory
|
|
95
|
+
*
|
|
96
|
+
* @param {any} context
|
|
97
|
+
* @param {ContentPath[]} contentPaths
|
|
98
|
+
* @returns {ContentPath[]}
|
|
99
|
+
*/ function resolveRelativePaths(context, contentPaths) {
|
|
100
|
+
let resolveFrom = [];
|
|
101
|
+
// Resolve base paths relative to the config file (when possible) if the experimental flag is enabled
|
|
102
|
+
if (context.userConfigPath && context.tailwindConfig.content.relative) {
|
|
103
|
+
resolveFrom = [
|
|
104
|
+
_path.default.dirname(context.userConfigPath)
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
return contentPaths.map((contentPath)=>{
|
|
108
|
+
contentPath.base = _path.default.resolve(...resolveFrom, contentPath.base);
|
|
109
|
+
return contentPath;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Resolve the symlink for the base directory / file in each path
|
|
114
|
+
* These are added as additional dependencies to watch for changes because
|
|
115
|
+
* some tools (like webpack) will only watch the actual file or directory
|
|
116
|
+
* but not the symlink itself even in projects that use monorepos.
|
|
117
|
+
*
|
|
118
|
+
* @param {ContentPath} contentPath
|
|
119
|
+
* @returns {ContentPath[]}
|
|
120
|
+
*/ function resolvePathSymlinks(contentPath) {
|
|
48
121
|
let paths = [
|
|
49
122
|
contentPath
|
|
50
123
|
];
|
|
51
124
|
try {
|
|
52
125
|
let resolvedPath = _fs.default.realpathSync(contentPath.base);
|
|
53
|
-
resolvedPath !== contentPath.base
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
126
|
+
if (resolvedPath !== contentPath.base) {
|
|
127
|
+
paths.push({
|
|
128
|
+
...contentPath,
|
|
129
|
+
base: resolvedPath
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
} catch {
|
|
133
|
+
// TODO: log this?
|
|
134
|
+
}
|
|
58
135
|
return paths;
|
|
59
136
|
}
|
|
60
137
|
function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
61
|
-
let changedContent = context.tailwindConfig.content.files.filter((item)=>
|
|
138
|
+
let changedContent = context.tailwindConfig.content.files.filter((item)=>typeof item.raw === "string").map(({ raw , extension ="html" })=>({
|
|
62
139
|
content: raw,
|
|
63
140
|
extension
|
|
64
|
-
}))
|
|
65
|
-
|
|
66
|
-
for (let file of (_sharedState.env.DEBUG && console.time("Finding changed files"), _fastGlob.default.sync(paths, {
|
|
67
|
-
absolute: !0
|
|
68
|
-
}))){
|
|
69
|
-
let prevModified = fileModifiedMap.get(file) || -1 / 0, modified = _fs.default.statSync(file).mtimeMs;
|
|
70
|
-
modified > prevModified && (changedFiles.add(file), mTimesToCommit.set(file, modified));
|
|
71
|
-
}
|
|
72
|
-
return _sharedState.env.DEBUG && console.timeEnd("Finding changed files"), [
|
|
73
|
-
changedFiles,
|
|
74
|
-
mTimesToCommit
|
|
75
|
-
];
|
|
76
|
-
}(candidateFiles, fileModifiedMap);
|
|
141
|
+
}));
|
|
142
|
+
let [changedFiles, mTimesToCommit] = resolveChangedFiles(candidateFiles, fileModifiedMap);
|
|
77
143
|
for (let changedFile of changedFiles){
|
|
78
144
|
let extension = _path.default.extname(changedFile).slice(1);
|
|
79
145
|
changedContent.push({
|
|
@@ -86,3 +152,30 @@ function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
|
86
152
|
mTimesToCommit
|
|
87
153
|
];
|
|
88
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
*
|
|
157
|
+
* @param {ContentPath[]} candidateFiles
|
|
158
|
+
* @param {Map<string, number>} fileModifiedMap
|
|
159
|
+
* @returns {[Set<string>, Map<string, number>]}
|
|
160
|
+
*/ function resolveChangedFiles(candidateFiles, fileModifiedMap) {
|
|
161
|
+
let paths = candidateFiles.map((contentPath)=>contentPath.pattern);
|
|
162
|
+
let mTimesToCommit = new Map();
|
|
163
|
+
let changedFiles = new Set();
|
|
164
|
+
_sharedState.env.DEBUG && console.time("Finding changed files");
|
|
165
|
+
let files = _fastglob.default.sync(paths, {
|
|
166
|
+
absolute: true
|
|
167
|
+
});
|
|
168
|
+
for (let file of files){
|
|
169
|
+
let prevModified = fileModifiedMap.get(file) || -Infinity;
|
|
170
|
+
let modified = _fs.default.statSync(file).mtimeMs;
|
|
171
|
+
if (modified > prevModified) {
|
|
172
|
+
changedFiles.add(file);
|
|
173
|
+
mTimesToCommit.set(file, modified);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
_sharedState.env.DEBUG && console.timeEnd("Finding changed files");
|
|
177
|
+
return [
|
|
178
|
+
changedFiles,
|
|
179
|
+
mTimesToCommit
|
|
180
|
+
];
|
|
181
|
+
}
|