tailwindcss 0.0.0-oxide-insiders.dddaded → 0.0.0-oxide-insiders.b2e3cf2
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 +10 -18
- package/lib/cli/build/index.js +10 -41
- package/lib/cli/build/plugin.js +87 -268
- package/lib/cli/build/utils.js +18 -40
- package/lib/cli/build/watching.js +35 -151
- package/lib/cli/help/index.js +15 -58
- package/lib/cli/index.js +61 -120
- package/lib/cli/init/index.js +21 -43
- package/lib/cli-peer-dependencies.js +13 -15
- package/lib/cli.js +1 -5
- package/lib/corePluginList.js +3 -4
- package/lib/corePlugins.js +394 -857
- package/lib/featureFlags.js +14 -34
- package/lib/index.js +1 -5
- package/lib/lib/cacheInvalidation.js +29 -75
- package/lib/lib/collapseAdjacentRules.js +22 -43
- package/lib/lib/collapseDuplicateDeclarations.js +27 -68
- package/lib/lib/content.js +37 -126
- package/lib/lib/defaultExtractor.js +96 -199
- package/lib/lib/detectNesting.js +12 -36
- package/lib/lib/evaluateTailwindFunctions.js +101 -188
- package/lib/lib/expandApplyAtRules.js +177 -482
- package/lib/lib/expandTailwindAtRules.js +69 -237
- package/lib/lib/findAtConfigPath.js +13 -30
- package/lib/lib/generateRules.js +349 -765
- package/lib/lib/getModuleDependencies.js +27 -63
- package/lib/lib/load-config.js +16 -24
- package/lib/lib/normalizeTailwindDirectives.js +26 -70
- package/lib/lib/offsets.js +61 -224
- package/lib/lib/partitionApplyAtRules.js +29 -51
- package/lib/lib/regex.js +22 -30
- package/lib/lib/remap-bitfield.js +9 -84
- package/lib/lib/resolveDefaultsAtRules.js +50 -116
- package/lib/lib/setupContextUtils.js +576 -1099
- package/lib/lib/setupTrackingContext.js +54 -143
- package/lib/lib/sharedState.js +15 -59
- package/lib/lib/substituteScreenAtRules.js +8 -16
- package/lib/oxide/cli/build/deps.js +17 -32
- package/lib/oxide/cli/build/index.js +10 -40
- package/lib/oxide/cli/build/plugin.js +87 -267
- package/lib/oxide/cli/build/utils.js +18 -39
- package/lib/oxide/cli/build/watching.js +34 -149
- package/lib/oxide/cli/help/index.js +15 -57
- package/lib/oxide/cli/index.js +66 -127
- package/lib/oxide/cli/init/index.js +17 -36
- package/lib/oxide/cli.js +2 -3
- package/lib/plugin.js +30 -57
- package/lib/postcss-plugins/nesting/index.js +6 -10
- package/lib/postcss-plugins/nesting/plugin.js +17 -60
- package/lib/processTailwindFeatures.js +8 -37
- package/lib/public/colors.js +15 -22
- package/lib/public/create-plugin.js +5 -8
- package/lib/public/default-config.js +5 -9
- package/lib/public/default-theme.js +5 -9
- package/lib/public/load-config.js +4 -6
- package/lib/public/resolve-config.js +4 -6
- package/lib/util/applyImportantSelector.js +15 -24
- package/lib/util/bigSign.js +6 -7
- package/lib/util/buildMediaQuery.js +10 -17
- package/lib/util/cloneDeep.js +9 -17
- package/lib/util/cloneNodes.js +14 -27
- package/lib/util/color.js +45 -81
- package/lib/util/configurePlugins.js +9 -16
- package/lib/util/createPlugin.js +8 -15
- package/lib/util/createUtilityPlugin.js +15 -27
- package/lib/util/dataTypes.js +23 -144
- package/lib/util/defaults.js +9 -19
- package/lib/util/escapeClassName.js +6 -10
- package/lib/util/escapeCommas.js +6 -7
- package/lib/util/flattenColorPalette.js +6 -8
- package/lib/util/formatVariantSelector.js +49 -190
- package/lib/util/getAllConfigs.js +35 -42
- package/lib/util/hashConfig.js +6 -8
- package/lib/util/isKeyframeRule.js +6 -7
- package/lib/util/isPlainObject.js +8 -11
- package/lib/util/isSyntacticallyValidPropertyValue.js +13 -42
- package/lib/util/log.js +7 -14
- package/lib/util/nameClass.js +6 -21
- package/lib/util/negateValue.js +10 -26
- package/lib/util/normalizeConfig.js +63 -240
- package/lib/util/normalizeScreens.js +70 -137
- package/lib/util/parseAnimationValue.js +13 -61
- package/lib/util/parseBoxShadowValue.js +12 -57
- package/lib/util/parseDependency.js +13 -37
- package/lib/util/parseGlob.js +7 -22
- package/lib/util/parseObjectStyles.js +17 -26
- package/lib/util/pluginUtils.js +69 -176
- package/lib/util/prefixSelector.js +11 -28
- package/lib/util/pseudoElements.js +29 -105
- package/lib/util/removeAlphaVariables.js +8 -21
- package/lib/util/resolveConfig.js +103 -220
- package/lib/util/resolveConfigPath.js +12 -38
- package/lib/util/responsive.js +4 -6
- package/lib/util/splitAtTopLevelOnly.js +10 -44
- package/lib/util/tap.js +6 -8
- package/lib/util/toColorValue.js +6 -7
- package/lib/util/toPath.js +8 -26
- package/lib/util/transformThemeValue.js +12 -45
- package/lib/util/validateConfig.js +14 -22
- package/lib/util/validateFormalSyntax.js +5 -11
- package/lib/util/withAlphaVariable.js +28 -48
- package/package.json +3 -3
- package/peers/index.js +14 -16
- package/src/cli/build/plugin.js +1 -1
- package/src/cli.js +1 -1
- package/src/corePlugins.js +16 -17
- package/src/featureFlags.js +2 -3
- package/src/index.js +1 -5
- package/src/lib/expandTailwindAtRules.js +2 -2
- package/src/lib/sharedState.js +0 -15
- package/src/oxide/cli/build/plugin.ts +1 -1
- package/src/plugin.js +1 -1
package/lib/featureFlags.js
CHANGED
|
@@ -1,37 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value:
|
|
4
|
-
})
|
|
5
|
-
function _export(target, all) {
|
|
3
|
+
value: !0
|
|
4
|
+
}), function(target, all) {
|
|
6
5
|
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable:
|
|
6
|
+
enumerable: !0,
|
|
8
7
|
get: all[name]
|
|
9
8
|
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
9
|
+
}(exports, {
|
|
12
10
|
flagEnabled: ()=>flagEnabled,
|
|
13
11
|
issueFlagNotices: ()=>issueFlagNotices,
|
|
14
12
|
default: ()=>_default
|
|
15
13
|
});
|
|
16
|
-
const _picocolors =
|
|
17
|
-
const _log = /*#__PURE__*/ _interopRequireDefault(require("./util/log"));
|
|
18
|
-
const _sharedState = require("./lib/sharedState");
|
|
14
|
+
const _picocolors = _interopRequireDefault(require("picocolors")), _log = _interopRequireDefault(require("./util/log"));
|
|
19
15
|
function _interopRequireDefault(obj) {
|
|
20
16
|
return obj && obj.__esModule ? obj : {
|
|
21
17
|
default: obj
|
|
22
18
|
};
|
|
23
19
|
}
|
|
24
20
|
let defaults = {
|
|
25
|
-
optimizeUniversalDefaults:
|
|
26
|
-
generalizedModifiers:
|
|
21
|
+
optimizeUniversalDefaults: !1,
|
|
22
|
+
generalizedModifiers: !0,
|
|
27
23
|
get disableColorOpacityUtilitiesByDefault () {
|
|
28
|
-
return
|
|
24
|
+
return !0;
|
|
29
25
|
},
|
|
30
26
|
get relativeContentPathsByDefault () {
|
|
31
|
-
return
|
|
27
|
+
return !0;
|
|
32
28
|
}
|
|
33
|
-
}
|
|
34
|
-
let featureFlags = {
|
|
29
|
+
}, featureFlags = {
|
|
35
30
|
future: [
|
|
36
31
|
"hoverOnlyWhenSupported",
|
|
37
32
|
"respectDefaultRingColorOpacity",
|
|
@@ -44,30 +39,15 @@ let featureFlags = {
|
|
|
44
39
|
]
|
|
45
40
|
};
|
|
46
41
|
function flagEnabled(config, flag) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var _config_future_flag, _ref;
|
|
50
|
-
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);
|
|
51
|
-
}
|
|
52
|
-
if (featureFlags.experimental.includes(flag)) {
|
|
53
|
-
var _config_experimental;
|
|
54
|
-
var _config_experimental_flag, _ref1;
|
|
55
|
-
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);
|
|
56
|
-
}
|
|
57
|
-
return false;
|
|
42
|
+
var _config_future, _config_future_flag, _ref, _config_experimental, _config_experimental_flag, _ref1;
|
|
43
|
+
return featureFlags.future.includes(flag) ? "all" === config.future || null !== (_ref = null !== (_config_future_flag = null == config ? void 0 : null === (_config_future = config.future) || void 0 === _config_future ? void 0 : _config_future[flag]) && void 0 !== _config_future_flag ? _config_future_flag : defaults[flag]) && void 0 !== _ref && _ref : !!featureFlags.experimental.includes(flag) && ("all" === config.experimental || null !== (_ref1 = null !== (_config_experimental_flag = null == config ? void 0 : null === (_config_experimental = config.experimental) || void 0 === _config_experimental ? void 0 : _config_experimental[flag]) && void 0 !== _config_experimental_flag ? _config_experimental_flag : defaults[flag]) && void 0 !== _ref1 && _ref1);
|
|
58
44
|
}
|
|
59
45
|
function experimentalFlagsEnabled(config) {
|
|
60
|
-
if (config.experimental === "all") {
|
|
61
|
-
return featureFlags.experimental;
|
|
62
|
-
}
|
|
63
46
|
var _config_experimental;
|
|
64
|
-
return Object.keys((_config_experimental =
|
|
47
|
+
return "all" === config.experimental ? featureFlags.experimental : Object.keys(null !== (_config_experimental = null == config ? void 0 : config.experimental) && void 0 !== _config_experimental ? _config_experimental : {}).filter((flag)=>featureFlags.experimental.includes(flag) && config.experimental[flag]);
|
|
65
48
|
}
|
|
66
49
|
function issueFlagNotices(config) {
|
|
67
|
-
if (process.env.JEST_WORKER_ID
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (experimentalFlagsEnabled(config).length > 0) {
|
|
50
|
+
if (void 0 === process.env.JEST_WORKER_ID && experimentalFlagsEnabled(config).length > 0) {
|
|
71
51
|
let changes = experimentalFlagsEnabled(config).map((s)=>_picocolors.default.yellow(s)).join(", ");
|
|
72
52
|
_log.default.warn("experimental-flags-enabled", [
|
|
73
53
|
`You have enabled experimental features: ${changes}`,
|
package/lib/index.js
CHANGED
|
@@ -1,90 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value:
|
|
4
|
-
})
|
|
5
|
-
|
|
6
|
-
enumerable: true,
|
|
3
|
+
value: !0
|
|
4
|
+
}), Object.defineProperty(exports, "hasContentChanged", {
|
|
5
|
+
enumerable: !0,
|
|
7
6
|
get: ()=>hasContentChanged
|
|
8
7
|
});
|
|
9
|
-
const _crypto =
|
|
10
|
-
const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
|
|
11
|
-
function _interopRequireDefault(obj) {
|
|
8
|
+
const _crypto = function(obj) {
|
|
12
9
|
return obj && obj.__esModule ? obj : {
|
|
13
10
|
default: obj
|
|
14
11
|
};
|
|
15
|
-
}
|
|
12
|
+
}(require("crypto")), _sharedState = function(obj, nodeInterop) {
|
|
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"));
|
|
16
26
|
function _getRequireWildcardCache(nodeInterop) {
|
|
17
|
-
if (typeof WeakMap
|
|
18
|
-
var cacheBabelInterop = new WeakMap();
|
|
19
|
-
var cacheNodeInterop = new WeakMap();
|
|
27
|
+
if ("function" != typeof WeakMap) return null;
|
|
28
|
+
var cacheBabelInterop = new WeakMap(), cacheNodeInterop = new WeakMap();
|
|
20
29
|
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
21
30
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
22
31
|
})(nodeInterop);
|
|
23
32
|
}
|
|
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
33
|
function hasContentChanged(sourcePath, root) {
|
|
79
34
|
let css = root.toString();
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
_sharedState.sourceHashMap.set(sourcePath, rootHash);
|
|
89
|
-
return didChange;
|
|
35
|
+
if (!css.includes("@tailwind")) return !1;
|
|
36
|
+
let existingHash = _sharedState.sourceHashMap.get(sourcePath), rootHash = function(str) {
|
|
37
|
+
try {
|
|
38
|
+
return _crypto.default.createHash("md5").update(str, "utf-8").digest("binary");
|
|
39
|
+
} catch (err) {
|
|
40
|
+
return "";
|
|
41
|
+
}
|
|
42
|
+
}(css);
|
|
43
|
+
return _sharedState.sourceHashMap.set(sourcePath, rootHash), existingHash !== rootHash;
|
|
90
44
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value:
|
|
4
|
-
})
|
|
5
|
-
|
|
6
|
-
enumerable: true,
|
|
3
|
+
value: !0
|
|
4
|
+
}), Object.defineProperty(exports, "default", {
|
|
5
|
+
enumerable: !0,
|
|
7
6
|
get: ()=>collapseAdjacentRules
|
|
8
7
|
});
|
|
9
8
|
let comparisonMap = {
|
|
@@ -14,46 +13,26 @@ let comparisonMap = {
|
|
|
14
13
|
rule: [
|
|
15
14
|
"selector"
|
|
16
15
|
]
|
|
17
|
-
};
|
|
18
|
-
let types = new Set(Object.keys(comparisonMap));
|
|
16
|
+
}, types = new Set(Object.keys(comparisonMap));
|
|
19
17
|
function collapseAdjacentRules() {
|
|
20
|
-
function collapseRulesIn(root) {
|
|
21
|
-
let currentRule = null;
|
|
22
|
-
root.each((node)=>{
|
|
23
|
-
if (!types.has(node.type)) {
|
|
24
|
-
currentRule = null;
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (currentRule === null) {
|
|
28
|
-
currentRule = node;
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
let properties = comparisonMap[node.type];
|
|
32
|
-
var _node_property, _currentRule_property;
|
|
33
|
-
if (node.type === "atrule" && node.name === "font-face") {
|
|
34
|
-
currentRule = node;
|
|
35
|
-
} 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, " "))) {
|
|
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
|
-
}
|
|
40
|
-
node.remove();
|
|
41
|
-
} else {
|
|
42
|
-
currentRule = node;
|
|
43
|
-
}
|
|
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
18
|
return (root)=>{
|
|
57
|
-
collapseRulesIn(root)
|
|
19
|
+
!function collapseRulesIn(root) {
|
|
20
|
+
let currentRule = null;
|
|
21
|
+
root.each((node)=>{
|
|
22
|
+
var _node_property, _currentRule_property;
|
|
23
|
+
if (!types.has(node.type)) {
|
|
24
|
+
currentRule = null;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (null === currentRule) {
|
|
28
|
+
currentRule = node;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
let properties = comparisonMap[node.type];
|
|
32
|
+
"atrule" === node.type && "font-face" === node.name ? currentRule = node : properties.every((property)=>(null !== (_node_property = node[property]) && void 0 !== _node_property ? _node_property : "").replace(/\s+/g, " ") === (null !== (_currentRule_property = currentRule[property]) && void 0 !== _currentRule_property ? _currentRule_property : "").replace(/\s+/g, " ")) ? (node.nodes && currentRule.append(node.nodes), node.remove()) : currentRule = node;
|
|
33
|
+
}), root.each((node)=>{
|
|
34
|
+
"atrule" === node.type && collapseRulesIn(node);
|
|
35
|
+
});
|
|
36
|
+
}(root);
|
|
58
37
|
};
|
|
59
38
|
}
|
|
@@ -1,83 +1,42 @@
|
|
|
1
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
2
|
function collapseDuplicateDeclarations() {
|
|
10
3
|
return (root)=>{
|
|
11
4
|
root.walkRules((node)=>{
|
|
12
|
-
let seen = new Map();
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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());
|
|
5
|
+
let seen = new Map(), droppable = new Set([]), byProperty = new Map();
|
|
6
|
+
for (let decl of (node.walkDecls((decl)=>{
|
|
7
|
+
if (decl.parent === node) {
|
|
8
|
+
if (seen.has(decl.prop)) {
|
|
9
|
+
if (seen.get(decl.prop).value === decl.value) {
|
|
10
|
+
droppable.add(seen.get(decl.prop)), seen.set(decl.prop, decl);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
byProperty.has(decl.prop) || byProperty.set(decl.prop, new Set()), byProperty.get(decl.prop).add(seen.get(decl.prop)), byProperty.get(decl.prop).add(decl);
|
|
39
14
|
}
|
|
40
|
-
|
|
41
|
-
byProperty.get(decl.prop).add(decl);
|
|
15
|
+
seen.set(decl.prop, decl);
|
|
42
16
|
}
|
|
43
|
-
|
|
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.
|
|
17
|
+
}), droppable))decl.remove();
|
|
52
18
|
for (let declarations of byProperty.values()){
|
|
53
19
|
let byUnit = new Map();
|
|
54
20
|
for (let decl of declarations){
|
|
55
|
-
let unit =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
for (let declarations of byUnit.values()){
|
|
65
|
-
// Get all but the last one
|
|
66
|
-
let removableDeclarations = Array.from(declarations).slice(0, -1);
|
|
67
|
-
for (let decl of removableDeclarations){
|
|
68
|
-
decl.remove();
|
|
69
|
-
}
|
|
21
|
+
let unit = function(input) {
|
|
22
|
+
let result = /^-?\d*.?\d+([\w%]+)?$/g.exec(input);
|
|
23
|
+
if (result) {
|
|
24
|
+
var _result_;
|
|
25
|
+
return null !== (_result_ = result[1]) && void 0 !== _result_ ? _result_ : UNITLESS_NUMBER;
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}(decl.value);
|
|
29
|
+
null !== unit && (byUnit.has(unit) || byUnit.set(unit, new Set()), byUnit.get(unit).add(decl));
|
|
70
30
|
}
|
|
31
|
+
for (let declarations of byUnit.values())for (let decl of Array.from(declarations).slice(0, -1))decl.remove();
|
|
71
32
|
}
|
|
72
33
|
});
|
|
73
34
|
};
|
|
74
35
|
}
|
|
36
|
+
Object.defineProperty(exports, "__esModule", {
|
|
37
|
+
value: !0
|
|
38
|
+
}), Object.defineProperty(exports, "default", {
|
|
39
|
+
enumerable: !0,
|
|
40
|
+
get: ()=>collapseDuplicateDeclarations
|
|
41
|
+
});
|
|
75
42
|
let UNITLESS_NUMBER = Symbol("unitless-number");
|
|
76
|
-
function resolveUnit(input) {
|
|
77
|
-
let result = /^-?\d*.?\d+([\w%]+)?$/g.exec(input);
|
|
78
|
-
if (result) {
|
|
79
|
-
var _result_;
|
|
80
|
-
return (_result_ = result[1]) !== null && _result_ !== void 0 ? _result_ : UNITLESS_NUMBER;
|
|
81
|
-
}
|
|
82
|
-
return null;
|
|
83
|
-
}
|
package/lib/lib/content.js
CHANGED
|
@@ -1,61 +1,36 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
"use strict";
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value:
|
|
5
|
-
})
|
|
6
|
-
function _export(target, all) {
|
|
3
|
+
value: !0
|
|
4
|
+
}), function(target, all) {
|
|
7
5
|
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
-
enumerable:
|
|
6
|
+
enumerable: !0,
|
|
9
7
|
get: all[name]
|
|
10
8
|
});
|
|
11
|
-
}
|
|
12
|
-
_export(exports, {
|
|
9
|
+
}(exports, {
|
|
13
10
|
parseCandidateFiles: ()=>parseCandidateFiles,
|
|
14
11
|
resolvedChangedContent: ()=>resolvedChangedContent
|
|
15
12
|
});
|
|
16
|
-
const _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");
|
|
13
|
+
const _fs = _interopRequireDefault(require("fs")), _path = _interopRequireDefault(require("path")), _isGlob = _interopRequireDefault(require("is-glob")), _fastGlob = _interopRequireDefault(require("fast-glob")), _normalizePath = _interopRequireDefault(require("normalize-path")), _parseGlob = require("../util/parseGlob"), _sharedState = require("./sharedState");
|
|
23
14
|
function _interopRequireDefault(obj) {
|
|
24
15
|
return obj && obj.__esModule ? obj : {
|
|
25
16
|
default: obj
|
|
26
17
|
};
|
|
27
18
|
}
|
|
28
19
|
function parseCandidateFiles(context, tailwindConfig) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
files = files.filter((filePath)=>typeof filePath
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
}
|
|
20
|
+
var contentPaths;
|
|
21
|
+
let resolveFrom, files = tailwindConfig.content.files;
|
|
22
|
+
files = (files = files.filter((filePath)=>"string" == typeof filePath)).map(_normalizePath.default);
|
|
23
|
+
let tasks = _fastGlob.default.generateTasks(files), included = [], excluded = [];
|
|
24
|
+
for (let task of tasks)included.push(...task.positive.map((filePath)=>parseFilePath(filePath, !1))), excluded.push(...task.negative.map((filePath)=>parseFilePath(filePath, !0)));
|
|
41
25
|
let paths = [
|
|
42
26
|
...included,
|
|
43
27
|
...excluded
|
|
44
28
|
];
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
paths = paths.flatMap(resolvePathSymlinks);
|
|
49
|
-
// Update cached patterns
|
|
50
|
-
paths = paths.map(resolveGlobPattern);
|
|
51
|
-
return paths;
|
|
29
|
+
return (paths = (contentPaths = paths, resolveFrom = [], context.userConfigPath && context.tailwindConfig.content.relative && (resolveFrom = [
|
|
30
|
+
_path.default.dirname(context.userConfigPath)
|
|
31
|
+
]), paths = contentPaths.map((contentPath)=>(contentPath.base = _path.default.resolve(...resolveFrom, contentPath.base), contentPath))).flatMap(resolvePathSymlinks)).map(resolveGlobPattern);
|
|
52
32
|
}
|
|
53
|
-
|
|
54
|
-
*
|
|
55
|
-
* @param {string} filePath
|
|
56
|
-
* @param {boolean} ignore
|
|
57
|
-
* @returns {ContentPath}
|
|
58
|
-
*/ function parseFilePath(filePath, ignore) {
|
|
33
|
+
function parseFilePath(filePath, ignore) {
|
|
59
34
|
let contentPath = {
|
|
60
35
|
original: filePath,
|
|
61
36
|
base: filePath,
|
|
@@ -63,79 +38,42 @@ function parseCandidateFiles(context, tailwindConfig) {
|
|
|
63
38
|
pattern: filePath,
|
|
64
39
|
glob: null
|
|
65
40
|
};
|
|
66
|
-
|
|
67
|
-
Object.assign(contentPath, (0, _parseGlob.parseGlob)(filePath));
|
|
68
|
-
}
|
|
69
|
-
return contentPath;
|
|
41
|
+
return (0, _isGlob.default)(filePath) && Object.assign(contentPath, (0, _parseGlob.parseGlob)(filePath)), contentPath;
|
|
70
42
|
}
|
|
71
|
-
|
|
72
|
-
*
|
|
73
|
-
* @param {ContentPath} contentPath
|
|
74
|
-
* @returns {ContentPath}
|
|
75
|
-
*/ function resolveGlobPattern(contentPath) {
|
|
76
|
-
// This is required for Windows support to properly pick up Glob paths.
|
|
77
|
-
// Afaik, this technically shouldn't be needed but there's probably
|
|
78
|
-
// some internal, direct path matching with a normalized path in
|
|
79
|
-
// a package which can't handle mixed directory separators
|
|
43
|
+
function resolveGlobPattern(contentPath) {
|
|
80
44
|
let base = (0, _normalizePath.default)(contentPath.base);
|
|
81
|
-
|
|
82
|
-
// is like "OOOH SHINY" and treats them as such. So we have to escape the base path to fix this
|
|
83
|
-
base = _fastGlob.default.escapePath(base);
|
|
84
|
-
contentPath.pattern = contentPath.glob ? `${base}/${contentPath.glob}` : base;
|
|
85
|
-
contentPath.pattern = contentPath.ignore ? `!${contentPath.pattern}` : contentPath.pattern;
|
|
86
|
-
return contentPath;
|
|
45
|
+
return base = _fastGlob.default.escapePath(base), contentPath.pattern = contentPath.glob ? `${base}/${contentPath.glob}` : base, contentPath.pattern = contentPath.ignore ? `!${contentPath.pattern}` : contentPath.pattern, contentPath;
|
|
87
46
|
}
|
|
88
|
-
|
|
89
|
-
* Resolve each path relative to the config file (when possible) if the experimental flag is enabled
|
|
90
|
-
* Otherwise, resolve relative to the current working directory
|
|
91
|
-
*
|
|
92
|
-
* @param {any} context
|
|
93
|
-
* @param {ContentPath[]} contentPaths
|
|
94
|
-
* @returns {ContentPath[]}
|
|
95
|
-
*/ function resolveRelativePaths(context, contentPaths) {
|
|
96
|
-
let resolveFrom = [];
|
|
97
|
-
// Resolve base paths relative to the config file (when possible) if the experimental flag is enabled
|
|
98
|
-
if (context.userConfigPath && context.tailwindConfig.content.relative) {
|
|
99
|
-
resolveFrom = [
|
|
100
|
-
_path.default.dirname(context.userConfigPath)
|
|
101
|
-
];
|
|
102
|
-
}
|
|
103
|
-
return contentPaths.map((contentPath)=>{
|
|
104
|
-
contentPath.base = _path.default.resolve(...resolveFrom, contentPath.base);
|
|
105
|
-
return contentPath;
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Resolve the symlink for the base directory / file in each path
|
|
110
|
-
* These are added as additional dependencies to watch for changes because
|
|
111
|
-
* some tools (like webpack) will only watch the actual file or directory
|
|
112
|
-
* but not the symlink itself even in projects that use monorepos.
|
|
113
|
-
*
|
|
114
|
-
* @param {ContentPath} contentPath
|
|
115
|
-
* @returns {ContentPath[]}
|
|
116
|
-
*/ function resolvePathSymlinks(contentPath) {
|
|
47
|
+
function resolvePathSymlinks(contentPath) {
|
|
117
48
|
let paths = [
|
|
118
49
|
contentPath
|
|
119
50
|
];
|
|
120
51
|
try {
|
|
121
52
|
let resolvedPath = _fs.default.realpathSync(contentPath.base);
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
} catch {
|
|
129
|
-
// TODO: log this?
|
|
130
|
-
}
|
|
53
|
+
resolvedPath !== contentPath.base && paths.push({
|
|
54
|
+
...contentPath,
|
|
55
|
+
base: resolvedPath
|
|
56
|
+
});
|
|
57
|
+
} catch {}
|
|
131
58
|
return paths;
|
|
132
59
|
}
|
|
133
60
|
function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
134
|
-
let changedContent = context.tailwindConfig.content.files.filter((item)=>typeof item.raw
|
|
61
|
+
let changedContent = context.tailwindConfig.content.files.filter((item)=>"string" == typeof item.raw).map(({ raw , extension ="html" })=>({
|
|
135
62
|
content: raw,
|
|
136
63
|
extension
|
|
137
|
-
}))
|
|
138
|
-
|
|
64
|
+
})), [changedFiles, mTimesToCommit] = function(candidateFiles, fileModifiedMap) {
|
|
65
|
+
let paths = candidateFiles.map((contentPath)=>contentPath.pattern), mTimesToCommit = new Map(), changedFiles = new Set();
|
|
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);
|
|
139
77
|
for (let changedFile of changedFiles){
|
|
140
78
|
let extension = _path.default.extname(changedFile).slice(1);
|
|
141
79
|
changedContent.push({
|
|
@@ -148,30 +86,3 @@ function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
|
148
86
|
mTimesToCommit
|
|
149
87
|
];
|
|
150
88
|
}
|
|
151
|
-
/**
|
|
152
|
-
*
|
|
153
|
-
* @param {ContentPath[]} candidateFiles
|
|
154
|
-
* @param {Map<string, number>} fileModifiedMap
|
|
155
|
-
* @returns {[Set<string>, Map<string, number>]}
|
|
156
|
-
*/ function resolveChangedFiles(candidateFiles, fileModifiedMap) {
|
|
157
|
-
let paths = candidateFiles.map((contentPath)=>contentPath.pattern);
|
|
158
|
-
let mTimesToCommit = new Map();
|
|
159
|
-
let changedFiles = new Set();
|
|
160
|
-
_sharedState.env.DEBUG && console.time("Finding changed files");
|
|
161
|
-
let files = _fastGlob.default.sync(paths, {
|
|
162
|
-
absolute: true
|
|
163
|
-
});
|
|
164
|
-
for (let file of files){
|
|
165
|
-
let prevModified = fileModifiedMap.get(file) || -Infinity;
|
|
166
|
-
let modified = _fs.default.statSync(file).mtimeMs;
|
|
167
|
-
if (modified > prevModified) {
|
|
168
|
-
changedFiles.add(file);
|
|
169
|
-
mTimesToCommit.set(file, modified);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
_sharedState.env.DEBUG && console.timeEnd("Finding changed files");
|
|
173
|
-
return [
|
|
174
|
-
changedFiles,
|
|
175
|
-
mTimesToCommit
|
|
176
|
-
];
|
|
177
|
-
}
|