tailwindcss 0.0.0-oxide-insiders.a7fe2fe → 0.0.0-oxide-insiders.759a8c2

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.
Files changed (108) hide show
  1. package/lib/cli/build/deps.js +34 -18
  2. package/lib/cli/build/index.js +45 -12
  3. package/lib/cli/build/plugin.js +273 -90
  4. package/lib/cli/build/utils.js +56 -24
  5. package/lib/cli/build/watching.js +156 -38
  6. package/lib/cli/help/index.js +61 -16
  7. package/lib/cli/index.js +121 -62
  8. package/lib/cli/init/index.js +47 -23
  9. package/lib/cli-peer-dependencies.js +23 -13
  10. package/lib/cli.js +5 -1
  11. package/lib/corePluginList.js +7 -4
  12. package/lib/corePlugins.js +855 -386
  13. package/lib/featureFlags.js +43 -18
  14. package/lib/lib/cacheInvalidation.js +78 -30
  15. package/lib/lib/collapseAdjacentRules.js +46 -23
  16. package/lib/lib/collapseDuplicateDeclarations.js +70 -27
  17. package/lib/lib/content.js +134 -41
  18. package/lib/lib/defaultExtractor.js +201 -96
  19. package/lib/lib/detectNesting.js +38 -12
  20. package/lib/lib/evaluateTailwindFunctions.js +192 -103
  21. package/lib/lib/expandApplyAtRules.js +488 -181
  22. package/lib/lib/expandTailwindAtRules.js +240 -70
  23. package/lib/lib/findAtConfigPath.js +34 -15
  24. package/lib/lib/generateRules.js +775 -353
  25. package/lib/lib/getModuleDependencies.js +67 -29
  26. package/lib/lib/load-config.js +27 -17
  27. package/lib/lib/normalizeTailwindDirectives.js +73 -27
  28. package/lib/lib/offsets.js +227 -62
  29. package/lib/lib/partitionApplyAtRules.js +53 -29
  30. package/lib/lib/regex.js +50 -28
  31. package/lib/lib/remap-bitfield.js +86 -9
  32. package/lib/lib/resolveDefaultsAtRules.js +123 -53
  33. package/lib/lib/setupContextUtils.js +1117 -584
  34. package/lib/lib/setupTrackingContext.js +149 -58
  35. package/lib/lib/sharedState.js +71 -23
  36. package/lib/lib/substituteScreenAtRules.js +19 -9
  37. package/lib/oxide/cli/build/deps.js +46 -23
  38. package/lib/oxide/cli/build/index.js +44 -12
  39. package/lib/oxide/cli/build/plugin.js +271 -89
  40. package/lib/oxide/cli/build/utils.js +55 -24
  41. package/lib/oxide/cli/build/watching.js +153 -36
  42. package/lib/oxide/cli/help/index.js +60 -16
  43. package/lib/oxide/cli/index.js +128 -67
  44. package/lib/oxide/cli/init/index.js +40 -19
  45. package/lib/oxide/cli.js +3 -2
  46. package/lib/plugin.js +58 -31
  47. package/lib/postcss-plugins/nesting/index.js +13 -7
  48. package/lib/postcss-plugins/nesting/plugin.js +65 -20
  49. package/lib/processTailwindFeatures.js +41 -10
  50. package/lib/public/colors.js +25 -16
  51. package/lib/public/create-plugin.js +11 -6
  52. package/lib/public/default-config.js +12 -6
  53. package/lib/public/default-theme.js +12 -6
  54. package/lib/public/load-config.js +9 -5
  55. package/lib/public/resolve-config.js +10 -6
  56. package/lib/util/applyImportantSelector.js +28 -17
  57. package/lib/util/bigSign.js +9 -6
  58. package/lib/util/buildMediaQuery.js +19 -10
  59. package/lib/util/cloneDeep.js +19 -9
  60. package/lib/util/cloneNodes.js +29 -14
  61. package/lib/util/color.js +87 -47
  62. package/lib/util/colorNames.js +752 -0
  63. package/lib/util/configurePlugins.js +18 -9
  64. package/lib/util/createPlugin.js +17 -8
  65. package/lib/util/createUtilityPlugin.js +30 -16
  66. package/lib/util/dataTypes.js +189 -38
  67. package/lib/util/defaults.js +21 -9
  68. package/lib/util/escapeClassName.js +15 -9
  69. package/lib/util/escapeCommas.js +9 -6
  70. package/lib/util/flattenColorPalette.js +11 -7
  71. package/lib/util/formatVariantSelector.js +209 -60
  72. package/lib/util/getAllConfigs.js +44 -35
  73. package/lib/util/hashConfig.js +12 -8
  74. package/lib/util/isKeyframeRule.js +10 -7
  75. package/lib/util/isPlainObject.js +14 -9
  76. package/lib/util/isSyntacticallyValidPropertyValue.js +45 -14
  77. package/lib/util/log.js +20 -9
  78. package/lib/util/nameClass.js +31 -10
  79. package/lib/util/negateValue.js +28 -10
  80. package/lib/util/normalizeConfig.js +242 -63
  81. package/lib/util/normalizeScreens.js +145 -70
  82. package/lib/util/parseAnimationValue.js +64 -14
  83. package/lib/util/parseBoxShadowValue.js +63 -14
  84. package/lib/util/parseDependency.js +39 -13
  85. package/lib/util/parseGlob.js +25 -8
  86. package/lib/util/parseObjectStyles.js +29 -18
  87. package/lib/util/pluginUtils.js +196 -77
  88. package/lib/util/prefixSelector.js +31 -12
  89. package/lib/util/pseudoElements.js +116 -34
  90. package/lib/util/removeAlphaVariables.js +23 -8
  91. package/lib/util/resolveConfig.js +224 -105
  92. package/lib/util/resolveConfigPath.js +45 -15
  93. package/lib/util/responsive.js +10 -6
  94. package/lib/util/splitAtTopLevelOnly.js +46 -10
  95. package/lib/util/tap.js +11 -7
  96. package/lib/util/toColorValue.js +10 -7
  97. package/lib/util/toPath.js +28 -8
  98. package/lib/util/transformThemeValue.js +49 -14
  99. package/lib/util/validateConfig.js +25 -15
  100. package/lib/util/validateFormalSyntax.js +14 -6
  101. package/lib/util/withAlphaVariable.js +54 -30
  102. package/package.json +18 -22
  103. package/peers/index.js +57849 -43101
  104. package/src/lib/expandTailwindAtRules.js +1 -1
  105. package/src/lib/setupTrackingContext.js +1 -1
  106. package/src/util/color.js +1 -1
  107. package/src/util/colorNames.js +150 -0
  108. package/src/util/pseudoElements.js +4 -4
@@ -1,32 +1,42 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
- value: !0
4
- }), function(target, all) {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
5
6
  for(var name in all)Object.defineProperty(target, name, {
6
- enumerable: !0,
7
+ enumerable: true,
7
8
  get: all[name]
8
9
  });
9
- }(exports, {
10
- flagEnabled: ()=>flagEnabled,
11
- issueFlagNotices: ()=>issueFlagNotices,
12
- default: ()=>_default
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 = _interopRequireDefault(require("picocolors")), _log = _interopRequireDefault(require("./util/log"));
15
- function _interopRequireDefault(obj) {
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: !1,
22
- generalizedModifiers: !0,
30
+ optimizeUniversalDefaults: false,
31
+ generalizedModifiers: true,
23
32
  get disableColorOpacityUtilitiesByDefault () {
24
- return !0;
33
+ return true;
25
34
  },
26
35
  get relativeContentPathsByDefault () {
27
- return !0;
36
+ return true;
28
37
  }
29
- }, featureFlags = {
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
- 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);
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 "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]);
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 (void 0 === process.env.JEST_WORKER_ID && experimentalFlagsEnabled(config).length > 0) {
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: !0
4
- }), Object.defineProperty(exports, "hasContentChanged", {
5
- enumerable: !0,
6
- get: ()=>hasContentChanged
3
+ value: true
7
4
  });
8
- const _crypto = function(obj) {
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
- }(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"));
17
+ }
26
18
  function _getRequireWildcardCache(nodeInterop) {
27
- if ("function" != typeof WeakMap) return null;
28
- var cacheBabelInterop = new WeakMap(), cacheNodeInterop = 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
- 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;
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: !0
4
- }), Object.defineProperty(exports, "default", {
5
- enumerable: !0,
6
- get: ()=>collapseAdjacentRules
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
- }, types = new Set(Object.keys(comparisonMap));
19
+ };
20
+ let types = new Set(Object.keys(comparisonMap));
17
21
  function collapseAdjacentRules() {
18
- return (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;
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
- 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);
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(), 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);
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
- seen.set(decl.prop, decl);
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
- }), droppable))decl.remove();
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 = 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));
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
+ }
@@ -1,36 +1,65 @@
1
+ // @ts-check
1
2
  "use strict";
2
3
  Object.defineProperty(exports, "__esModule", {
3
- value: !0
4
- }), function(target, all) {
4
+ value: true
5
+ });
6
+ function _export(target, all) {
5
7
  for(var name in all)Object.defineProperty(target, name, {
6
- enumerable: !0,
8
+ enumerable: true,
7
9
  get: all[name]
8
10
  });
9
- }(exports, {
10
- parseCandidateFiles: ()=>parseCandidateFiles,
11
- resolvedChangedContent: ()=>resolvedChangedContent
11
+ }
12
+ _export(exports, {
13
+ parseCandidateFiles: function() {
14
+ return parseCandidateFiles;
15
+ },
16
+ resolvedChangedContent: function() {
17
+ return resolvedChangedContent;
18
+ }
12
19
  });
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");
14
- function _interopRequireDefault(obj) {
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
- 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)));
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
- 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);
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
- function parseFilePath(filePath, ignore) {
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
- return (0, _isGlob.default)(filePath) && Object.assign(contentPath, (0, _parseGlob.parseGlob)(filePath)), contentPath;
70
+ if ((0, _isglob.default)(filePath)) {
71
+ Object.assign(contentPath, (0, _parseGlob.parseGlob)(filePath));
72
+ }
73
+ return contentPath;
42
74
  }
43
- function resolveGlobPattern(contentPath) {
44
- let base = (0, _normalizePath.default)(contentPath.base);
45
- return base = _fastGlob.default.escapePath(base), contentPath.pattern = contentPath.glob ? `${base}/${contentPath.glob}` : base, contentPath.pattern = contentPath.ignore ? `!${contentPath.pattern}` : contentPath.pattern, contentPath;
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
- function resolvePathSymlinks(contentPath) {
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 && paths.push({
54
- ...contentPath,
55
- base: resolvedPath
56
- });
57
- } catch {}
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)=>"string" == typeof item.raw).map(({ raw , extension ="html" })=>({
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
- })), [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);
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
+ }