tailwindcss 0.0.0-insiders.7c337f2 → 0.0.0-insiders.7d8eb21

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 (161) hide show
  1. package/CHANGELOG.md +246 -6
  2. package/README.md +13 -9
  3. package/defaultTheme.d.ts +2 -1
  4. package/lib/cli/build/deps.js +54 -0
  5. package/lib/cli/build/index.js +48 -0
  6. package/lib/cli/build/plugin.js +362 -0
  7. package/lib/cli/build/utils.js +78 -0
  8. package/lib/cli/build/watching.js +178 -0
  9. package/lib/cli/help/index.js +71 -0
  10. package/lib/cli/index.js +18 -0
  11. package/lib/cli/init/index.js +46 -0
  12. package/lib/cli/shared.js +12 -0
  13. package/lib/cli-peer-dependencies.js +18 -5
  14. package/lib/cli.js +62 -592
  15. package/lib/constants.js +19 -12
  16. package/lib/corePluginList.js +5 -3
  17. package/lib/corePlugins.js +619 -347
  18. package/lib/css/preflight.css +7 -0
  19. package/lib/featureFlags.js +34 -22
  20. package/lib/index.js +16 -9
  21. package/lib/lib/cacheInvalidation.js +42 -21
  22. package/lib/lib/collapseAdjacentRules.js +16 -14
  23. package/lib/lib/collapseDuplicateDeclarations.js +13 -10
  24. package/lib/lib/content.js +177 -0
  25. package/lib/lib/defaultExtractor.js +230 -33
  26. package/lib/lib/detectNesting.js +13 -4
  27. package/lib/lib/evaluateTailwindFunctions.js +105 -42
  28. package/lib/lib/expandApplyAtRules.js +151 -92
  29. package/lib/lib/expandTailwindAtRules.js +134 -149
  30. package/lib/lib/findAtConfigPath.js +44 -0
  31. package/lib/lib/generateRules.js +404 -185
  32. package/lib/lib/getModuleDependencies.js +21 -18
  33. package/lib/lib/normalizeTailwindDirectives.js +11 -8
  34. package/lib/lib/offsets.js +285 -0
  35. package/lib/lib/partitionApplyAtRules.js +14 -11
  36. package/lib/lib/regex.js +60 -0
  37. package/lib/lib/remap-bitfield.js +87 -0
  38. package/lib/lib/resolveDefaultsAtRules.js +97 -79
  39. package/lib/lib/setupContextUtils.js +567 -242
  40. package/lib/lib/setupTrackingContext.js +77 -106
  41. package/lib/lib/sharedState.js +18 -10
  42. package/lib/lib/substituteScreenAtRules.js +9 -7
  43. package/lib/postcss-plugins/nesting/index.js +7 -5
  44. package/lib/postcss-plugins/nesting/plugin.js +10 -8
  45. package/lib/processTailwindFeatures.js +34 -31
  46. package/lib/public/colors.js +7 -5
  47. package/lib/public/create-plugin.js +6 -4
  48. package/lib/public/default-config.js +7 -5
  49. package/lib/public/default-theme.js +7 -5
  50. package/lib/public/resolve-config.js +13 -10
  51. package/lib/util/bigSign.js +4 -1
  52. package/lib/util/buildMediaQuery.js +10 -5
  53. package/lib/util/cloneDeep.js +6 -5
  54. package/lib/util/cloneNodes.js +9 -2
  55. package/lib/util/color.js +20 -17
  56. package/lib/util/configurePlugins.js +5 -2
  57. package/lib/util/createPlugin.js +6 -5
  58. package/lib/util/createUtilityPlugin.js +15 -13
  59. package/lib/util/dataTypes.js +75 -51
  60. package/lib/util/defaults.js +8 -5
  61. package/lib/util/escapeClassName.js +13 -10
  62. package/lib/util/escapeCommas.js +4 -1
  63. package/lib/util/flattenColorPalette.js +7 -8
  64. package/lib/util/formatVariantSelector.js +270 -103
  65. package/lib/util/getAllConfigs.js +34 -15
  66. package/lib/util/hashConfig.js +10 -7
  67. package/lib/util/isKeyframeRule.js +4 -1
  68. package/lib/util/isPlainObject.js +4 -1
  69. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +34 -26
  70. package/lib/util/log.js +14 -8
  71. package/lib/util/nameClass.js +19 -8
  72. package/lib/util/negateValue.js +20 -5
  73. package/lib/util/normalizeConfig.js +94 -53
  74. package/lib/util/normalizeScreens.js +115 -4
  75. package/lib/util/parseAnimationValue.js +43 -41
  76. package/lib/util/parseBoxShadowValue.js +12 -45
  77. package/lib/util/parseDependency.js +37 -55
  78. package/lib/util/parseGlob.js +34 -0
  79. package/lib/util/parseObjectStyles.js +15 -12
  80. package/lib/util/pluginUtils.js +146 -42
  81. package/lib/util/prefixSelector.js +26 -9
  82. package/lib/util/removeAlphaVariables.js +29 -0
  83. package/lib/util/resolveConfig.js +104 -105
  84. package/lib/util/resolveConfigPath.js +20 -17
  85. package/lib/util/responsive.js +12 -9
  86. package/lib/util/splitAtTopLevelOnly.js +43 -0
  87. package/lib/util/tap.js +4 -1
  88. package/lib/util/toColorValue.js +4 -1
  89. package/lib/util/toPath.js +18 -2
  90. package/lib/util/transformThemeValue.js +23 -11
  91. package/lib/util/validateConfig.js +24 -0
  92. package/lib/util/validateFormalSyntax.js +24 -0
  93. package/lib/util/withAlphaVariable.js +32 -24
  94. package/package.json +32 -29
  95. package/peers/index.js +6693 -3036
  96. package/plugin.d.ts +10 -5
  97. package/resolveConfig.d.ts +12 -0
  98. package/scripts/generate-types.js +53 -0
  99. package/scripts/release-channel.js +18 -0
  100. package/scripts/release-notes.js +21 -0
  101. package/scripts/type-utils.js +27 -0
  102. package/src/cli/build/deps.js +56 -0
  103. package/src/cli/build/index.js +49 -0
  104. package/src/cli/build/plugin.js +434 -0
  105. package/src/cli/build/utils.js +76 -0
  106. package/src/cli/build/watching.js +227 -0
  107. package/src/cli/help/index.js +70 -0
  108. package/src/cli/index.js +3 -0
  109. package/src/cli/init/index.js +50 -0
  110. package/src/cli/shared.js +5 -0
  111. package/src/cli-peer-dependencies.js +7 -1
  112. package/src/cli.js +46 -659
  113. package/src/corePlugins.js +346 -79
  114. package/src/css/preflight.css +7 -0
  115. package/src/featureFlags.js +12 -2
  116. package/src/index.js +5 -0
  117. package/src/lib/content.js +213 -0
  118. package/src/lib/defaultExtractor.js +202 -35
  119. package/src/lib/detectNesting.js +9 -1
  120. package/src/lib/evaluateTailwindFunctions.js +78 -7
  121. package/src/lib/expandApplyAtRules.js +129 -34
  122. package/src/lib/expandTailwindAtRules.js +12 -50
  123. package/src/lib/findAtConfigPath.js +48 -0
  124. package/src/lib/generateRules.js +379 -126
  125. package/src/lib/offsets.js +351 -0
  126. package/src/lib/regex.js +74 -0
  127. package/src/lib/remap-bitfield.js +82 -0
  128. package/src/lib/resolveDefaultsAtRules.js +53 -36
  129. package/src/lib/setupContextUtils.js +510 -120
  130. package/src/lib/setupTrackingContext.js +8 -45
  131. package/src/lib/sharedState.js +2 -0
  132. package/src/util/buildMediaQuery.js +5 -3
  133. package/src/util/cloneNodes.js +5 -1
  134. package/src/util/dataTypes.js +51 -26
  135. package/src/util/formatVariantSelector.js +317 -101
  136. package/src/util/getAllConfigs.js +19 -0
  137. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  138. package/src/util/log.js +1 -1
  139. package/src/util/nameClass.js +4 -0
  140. package/src/util/negateValue.js +10 -2
  141. package/src/util/normalizeConfig.js +40 -10
  142. package/src/util/normalizeScreens.js +99 -4
  143. package/src/util/parseBoxShadowValue.js +3 -50
  144. package/src/util/parseDependency.js +37 -42
  145. package/src/util/parseGlob.js +24 -0
  146. package/src/util/pluginUtils.js +132 -10
  147. package/src/util/prefixSelector.js +28 -10
  148. package/src/util/removeAlphaVariables.js +24 -0
  149. package/src/util/resolveConfig.js +70 -62
  150. package/src/util/splitAtTopLevelOnly.js +45 -0
  151. package/src/util/toPath.js +1 -1
  152. package/src/util/transformThemeValue.js +13 -3
  153. package/src/util/validateConfig.js +13 -0
  154. package/src/util/validateFormalSyntax.js +34 -0
  155. package/src/util/withAlphaVariable.js +1 -1
  156. package/stubs/defaultConfig.stub.js +165 -164
  157. package/stubs/simpleConfig.stub.js +1 -0
  158. package/types/config.d.ts +77 -37
  159. package/types/generated/default-theme.d.ts +342 -0
  160. package/types/index.d.ts +7 -1
  161. package/types.d.ts +0 -1
@@ -22,6 +22,7 @@
22
22
  2. Prevent adjustments of font size after orientation changes in iOS.
23
23
  3. Use a more readable tab size.
24
24
  4. Use the user's configured `sans` font-family by default.
25
+ 5. Use the user's configured `sans` font-feature-settings by default.
25
26
  */
26
27
 
27
28
  html {
@@ -30,6 +31,7 @@ html {
30
31
  -moz-tab-size: 4; /* 3 */
31
32
  tab-size: 4; /* 3 */
32
33
  font-family: theme('fontFamily.sans', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"); /* 4 */
34
+ font-feature-settings: theme('fontFamily.sans[1].fontFeatureSettings', normal); /* 5 */
33
35
  }
34
36
 
35
37
  /*
@@ -358,3 +360,8 @@ video {
358
360
  max-width: 100%;
359
361
  height: auto;
360
362
  }
363
+
364
+ /* Make elements with the HTML hidden attribute stay hidden by default */
365
+ [hidden] {
366
+ display: none;
367
+ }
@@ -2,35 +2,50 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.flagEnabled = flagEnabled;
6
- exports.issueFlagNotices = issueFlagNotices;
7
- exports.default = void 0;
8
- var _picocolors = _interopRequireDefault(require("picocolors"));
9
- var _log = _interopRequireDefault(require("./util/log"));
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ flagEnabled: ()=>flagEnabled,
13
+ issueFlagNotices: ()=>issueFlagNotices,
14
+ default: ()=>_default
15
+ });
16
+ const _picocolors = /*#__PURE__*/ _interopRequireDefault(require("picocolors"));
17
+ const _log = /*#__PURE__*/ _interopRequireDefault(require("./util/log"));
10
18
  function _interopRequireDefault(obj) {
11
19
  return obj && obj.__esModule ? obj : {
12
20
  default: obj
13
21
  };
14
22
  }
15
23
  let defaults = {
16
- optimizeUniversalDefaults: false
24
+ optimizeUniversalDefaults: false,
25
+ generalizedModifiers: true
17
26
  };
18
27
  let featureFlags = {
19
- future: [],
28
+ future: [
29
+ "hoverOnlyWhenSupported",
30
+ "respectDefaultRingColorOpacity",
31
+ "disableColorOpacityUtilitiesByDefault",
32
+ "relativeContentPathsByDefault"
33
+ ],
20
34
  experimental: [
21
- "optimizeUniversalDefaults"
35
+ "optimizeUniversalDefaults",
36
+ "generalizedModifiers"
22
37
  ]
23
38
  };
24
39
  function flagEnabled(config, flag) {
25
40
  if (featureFlags.future.includes(flag)) {
26
- var ref;
27
- var ref1, ref2;
28
- return config.future === "all" || ((ref2 = (ref1 = config === null || config === void 0 ? void 0 : (ref = config.future) === null || ref === void 0 ? void 0 : ref[flag]) !== null && ref1 !== void 0 ? ref1 : defaults[flag]) !== null && ref2 !== void 0 ? ref2 : false);
41
+ var _config_future;
42
+ var _config_future_flag, _ref;
43
+ 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);
29
44
  }
30
45
  if (featureFlags.experimental.includes(flag)) {
31
- var ref3;
32
- var ref4, ref5;
33
- return config.experimental === "all" || ((ref5 = (ref4 = config === null || config === void 0 ? void 0 : (ref3 = config.experimental) === null || ref3 === void 0 ? void 0 : ref3[flag]) !== null && ref4 !== void 0 ? ref4 : defaults[flag]) !== null && ref5 !== void 0 ? ref5 : false);
46
+ var _config_experimental;
47
+ var _config_experimental_flag, _ref1;
48
+ 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);
34
49
  }
35
50
  return false;
36
51
  }
@@ -38,22 +53,19 @@ function experimentalFlagsEnabled(config) {
38
53
  if (config.experimental === "all") {
39
54
  return featureFlags.experimental;
40
55
  }
41
- var ref;
42
- return Object.keys((ref = config === null || config === void 0 ? void 0 : config.experimental) !== null && ref !== void 0 ? ref : {}).filter((flag)=>featureFlags.experimental.includes(flag) && config.experimental[flag]
43
- );
56
+ var _config_experimental;
57
+ 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]);
44
58
  }
45
59
  function issueFlagNotices(config) {
46
60
  if (process.env.JEST_WORKER_ID !== undefined) {
47
61
  return;
48
62
  }
49
63
  if (experimentalFlagsEnabled(config).length > 0) {
50
- let changes = experimentalFlagsEnabled(config).map((s)=>_picocolors.default.yellow(s)
51
- ).join(", ");
64
+ let changes = experimentalFlagsEnabled(config).map((s)=>_picocolors.default.yellow(s)).join(", ");
52
65
  _log.default.warn("experimental-flags-enabled", [
53
66
  `You have enabled experimental features: ${changes}`,
54
- "Experimental features in Tailwind CSS are not covered by semver, may introduce breaking changes, and can change at any time.",
67
+ "Experimental features in Tailwind CSS are not covered by semver, may introduce breaking changes, and can change at any time."
55
68
  ]);
56
69
  }
57
70
  }
58
- var _default = featureFlags;
59
- exports.default = _default;
71
+ const _default = featureFlags;
package/lib/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
- var _setupTrackingContext = _interopRequireDefault(require("./lib/setupTrackingContext"));
3
- var _processTailwindFeatures = _interopRequireDefault(require("./processTailwindFeatures"));
4
- var _sharedState = require("./lib/sharedState");
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _setupTrackingContext = /*#__PURE__*/ _interopRequireDefault(require("./lib/setupTrackingContext"));
6
+ const _processTailwindFeatures = /*#__PURE__*/ _interopRequireDefault(require("./processTailwindFeatures"));
7
+ const _sharedState = require("./lib/sharedState");
8
+ const _findAtConfigPath = require("./lib/findAtConfigPath");
5
9
  function _interopRequireDefault(obj) {
6
10
  return obj && obj.__esModule ? obj : {
7
11
  default: obj
@@ -17,24 +21,27 @@ module.exports = function tailwindcss(configOrPath) {
17
21
  return root;
18
22
  },
19
23
  function(root, result) {
20
- let context = (0, _setupTrackingContext).default(configOrPath);
24
+ var _findAtConfigPath1;
25
+ // Use the path for the `@config` directive if it exists, otherwise use the
26
+ // path for the file being processed
27
+ configOrPath = (_findAtConfigPath1 = (0, _findAtConfigPath.findAtConfigPath)(root, result)) !== null && _findAtConfigPath1 !== void 0 ? _findAtConfigPath1 : configOrPath;
28
+ let context = (0, _setupTrackingContext.default)(configOrPath);
21
29
  if (root.type === "document") {
22
- let roots = root.nodes.filter((node)=>node.type === "root"
23
- );
30
+ let roots = root.nodes.filter((node)=>node.type === "root");
24
31
  for (const root1 of roots){
25
32
  if (root1.type === "root") {
26
- (0, _processTailwindFeatures).default(context)(root1, result);
33
+ (0, _processTailwindFeatures.default)(context)(root1, result);
27
34
  }
28
35
  }
29
36
  return;
30
37
  }
31
- (0, _processTailwindFeatures).default(context)(root, result);
38
+ (0, _processTailwindFeatures.default)(context)(root, result);
32
39
  },
33
40
  _sharedState.env.DEBUG && function(root) {
34
41
  console.timeEnd("JIT TOTAL");
35
42
  console.log("\n");
36
43
  return root;
37
- },
44
+ }
38
45
  ].filter(Boolean)
39
46
  };
40
47
  };
@@ -2,34 +2,55 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.hasContentChanged = hasContentChanged;
6
- var _crypto = _interopRequireDefault(require("crypto"));
7
- var sharedState = _interopRequireWildcard(require("./sharedState"));
5
+ Object.defineProperty(exports, "hasContentChanged", {
6
+ enumerable: true,
7
+ get: ()=>hasContentChanged
8
+ });
9
+ const _crypto = /*#__PURE__*/ _interopRequireDefault(require("crypto"));
10
+ const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
8
11
  function _interopRequireDefault(obj) {
9
12
  return obj && obj.__esModule ? obj : {
10
13
  default: obj
11
14
  };
12
15
  }
13
- function _interopRequireWildcard(obj) {
14
- if (obj && obj.__esModule) {
16
+ function _getRequireWildcardCache(nodeInterop) {
17
+ if (typeof WeakMap !== "function") return null;
18
+ var cacheBabelInterop = new WeakMap();
19
+ var cacheNodeInterop = new WeakMap();
20
+ return (_getRequireWildcardCache = function(nodeInterop) {
21
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
22
+ })(nodeInterop);
23
+ }
24
+ function _interopRequireWildcard(obj, nodeInterop) {
25
+ if (!nodeInterop && obj && obj.__esModule) {
15
26
  return obj;
16
- } else {
17
- var newObj = {};
18
- if (obj != null) {
19
- for(var key in obj){
20
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
21
- var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
22
- if (desc.get || desc.set) {
23
- Object.defineProperty(newObj, key, desc);
24
- } else {
25
- newObj[key] = obj[key];
26
- }
27
- }
27
+ }
28
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
29
+ return {
30
+ default: obj
31
+ };
32
+ }
33
+ var cache = _getRequireWildcardCache(nodeInterop);
34
+ if (cache && cache.has(obj)) {
35
+ return cache.get(obj);
36
+ }
37
+ var newObj = {};
38
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
39
+ for(var key in obj){
40
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
41
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
42
+ if (desc && (desc.get || desc.set)) {
43
+ Object.defineProperty(newObj, key, desc);
44
+ } else {
45
+ newObj[key] = obj[key];
28
46
  }
29
47
  }
30
- newObj.default = obj;
31
- return newObj;
32
48
  }
49
+ newObj.default = obj;
50
+ if (cache) {
51
+ cache.set(obj, newObj);
52
+ }
53
+ return newObj;
33
54
  }
34
55
  /**
35
56
  * Calculate the hash of a string.
@@ -61,9 +82,9 @@ function hasContentChanged(sourcePath, root) {
61
82
  if (!css.includes("@tailwind")) {
62
83
  return false;
63
84
  }
64
- let existingHash = sharedState.sourceHashMap.get(sourcePath);
85
+ let existingHash = _sharedState.sourceHashMap.get(sourcePath);
65
86
  let rootHash = getHash(css);
66
87
  let didChange = existingHash !== rootHash;
67
- sharedState.sourceHashMap.set(sourcePath, rootHash);
88
+ _sharedState.sourceHashMap.set(sourcePath, rootHash);
68
89
  return didChange;
69
90
  }
@@ -2,7 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = collapseAdjacentRules;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>collapseAdjacentRules
8
+ });
9
+ let comparisonMap = {
10
+ atrule: [
11
+ "name",
12
+ "params"
13
+ ],
14
+ rule: [
15
+ "selector"
16
+ ]
17
+ };
18
+ let types = new Set(Object.keys(comparisonMap));
6
19
  function collapseAdjacentRules() {
7
20
  function collapseRulesIn(root) {
8
21
  let currentRule = null;
@@ -16,11 +29,10 @@ function collapseAdjacentRules() {
16
29
  return;
17
30
  }
18
31
  let properties = comparisonMap[node.type];
19
- var _property, _property1;
32
+ var _node_property, _currentRule_property;
20
33
  if (node.type === "atrule" && node.name === "font-face") {
21
34
  currentRule = node;
22
- } else if (properties.every((property)=>((_property = node[property]) !== null && _property !== void 0 ? _property : "").replace(/\s+/g, " ") === ((_property1 = currentRule[property]) !== null && _property1 !== void 0 ? _property1 : "").replace(/\s+/g, " ")
23
- )) {
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, " "))) {
24
36
  // An AtRule may not have children (for example if we encounter duplicate @import url(…) rules)
25
37
  if (node.nodes) {
26
38
  currentRule.append(node.nodes);
@@ -45,13 +57,3 @@ function collapseAdjacentRules() {
45
57
  collapseRulesIn(root);
46
58
  };
47
59
  }
48
- let comparisonMap = {
49
- atrule: [
50
- "name",
51
- "params"
52
- ],
53
- rule: [
54
- "selector"
55
- ]
56
- };
57
- let types = new Set(Object.keys(comparisonMap));
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = collapseDuplicateDeclarations;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>collapseDuplicateDeclarations
8
+ });
6
9
  function collapseDuplicateDeclarations() {
7
10
  return (root)=>{
8
11
  root.walkRules((node)=>{
@@ -41,28 +44,28 @@ function collapseDuplicateDeclarations() {
41
44
  });
42
45
  // Drop all the duplicate declarations with the exact same value we've
43
46
  // already seen so far.
44
- for (let decl1 of droppable){
45
- decl1.remove();
47
+ for (let decl of droppable){
48
+ decl.remove();
46
49
  }
47
50
  // Analyze the declarations based on its unit, drop all the declarations
48
51
  // with the same unit but the last one in the list.
49
52
  for (let declarations of byProperty.values()){
50
53
  let byUnit = new Map();
51
- for (let decl of declarations){
52
- let unit = resolveUnit(decl.value);
54
+ for (let decl1 of declarations){
55
+ let unit = resolveUnit(decl1.value);
53
56
  if (unit === null) {
54
57
  continue;
55
58
  }
56
59
  if (!byUnit.has(unit)) {
57
60
  byUnit.set(unit, new Set());
58
61
  }
59
- byUnit.get(unit).add(decl);
62
+ byUnit.get(unit).add(decl1);
60
63
  }
61
64
  for (let declarations1 of byUnit.values()){
62
65
  // Get all but the last one
63
66
  let removableDeclarations = Array.from(declarations1).slice(0, -1);
64
- for (let decl of removableDeclarations){
65
- decl.remove();
67
+ for (let decl2 of removableDeclarations){
68
+ decl2.remove();
66
69
  }
67
70
  }
68
71
  }
@@ -73,8 +76,8 @@ let UNITLESS_NUMBER = Symbol("unitless-number");
73
76
  function resolveUnit(input) {
74
77
  let result = /^-?\d*.?\d+([\w%]+)?$/g.exec(input);
75
78
  if (result) {
76
- var ref;
77
- return (ref = result[1]) !== null && ref !== void 0 ? ref : UNITLESS_NUMBER;
79
+ var _result_;
80
+ return (_result_ = result[1]) !== null && _result_ !== void 0 ? _result_ : UNITLESS_NUMBER;
78
81
  }
79
82
  return null;
80
83
  }
@@ -0,0 +1,177 @@
1
+ // @ts-check
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ function _export(target, all) {
7
+ for(var name in all)Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ parseCandidateFiles: ()=>parseCandidateFiles,
14
+ resolvedChangedContent: ()=>resolvedChangedContent
15
+ });
16
+ const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
17
+ const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
18
+ const _isGlob = /*#__PURE__*/ _interopRequireDefault(require("is-glob"));
19
+ const _fastGlob = /*#__PURE__*/ _interopRequireDefault(require("fast-glob"));
20
+ const _normalizePath = /*#__PURE__*/ _interopRequireDefault(require("normalize-path"));
21
+ const _parseGlob = require("../util/parseGlob");
22
+ const _sharedState = require("./sharedState");
23
+ function _interopRequireDefault(obj) {
24
+ return obj && obj.__esModule ? obj : {
25
+ default: obj
26
+ };
27
+ }
28
+ function parseCandidateFiles(context, tailwindConfig) {
29
+ let files = tailwindConfig.content.files;
30
+ // Normalize the file globs
31
+ files = files.filter((filePath)=>typeof filePath === "string");
32
+ files = files.map(_normalizePath.default);
33
+ // Split into included and excluded globs
34
+ let tasks = _fastGlob.default.generateTasks(files);
35
+ /** @type {ContentPath[]} */ let included = [];
36
+ /** @type {ContentPath[]} */ let excluded = [];
37
+ for (const task of tasks){
38
+ included.push(...task.positive.map((filePath)=>parseFilePath(filePath, false)));
39
+ excluded.push(...task.negative.map((filePath)=>parseFilePath(filePath, true)));
40
+ }
41
+ let paths = [
42
+ ...included,
43
+ ...excluded
44
+ ];
45
+ // Resolve paths relative to the config file or cwd
46
+ paths = resolveRelativePaths(context, paths);
47
+ // Resolve symlinks if possible
48
+ paths = paths.flatMap(resolvePathSymlinks);
49
+ // Update cached patterns
50
+ paths = paths.map(resolveGlobPattern);
51
+ return paths;
52
+ }
53
+ /**
54
+ *
55
+ * @param {string} filePath
56
+ * @param {boolean} ignore
57
+ * @returns {ContentPath}
58
+ */ function parseFilePath(filePath, ignore) {
59
+ let contentPath = {
60
+ original: filePath,
61
+ base: filePath,
62
+ ignore,
63
+ pattern: filePath,
64
+ glob: null
65
+ };
66
+ if ((0, _isGlob.default)(filePath)) {
67
+ Object.assign(contentPath, (0, _parseGlob.parseGlob)(filePath));
68
+ }
69
+ return contentPath;
70
+ }
71
+ /**
72
+ *
73
+ * @param {ContentPath} contentPath
74
+ * @returns {ContentPath}
75
+ */ function resolveGlobPattern(contentPath) {
76
+ // 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
80
+ let base = (0, _normalizePath.default)(contentPath.base);
81
+ // If the user's file path contains any special characters (like parens) for instance fast-glob
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;
87
+ }
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) {
117
+ let paths = [
118
+ contentPath
119
+ ];
120
+ try {
121
+ let resolvedPath = _fs.default.realpathSync(contentPath.base);
122
+ if (resolvedPath !== contentPath.base) {
123
+ paths.push({
124
+ ...contentPath,
125
+ base: resolvedPath
126
+ });
127
+ }
128
+ } catch {
129
+ // TODO: log this?
130
+ }
131
+ return paths;
132
+ }
133
+ function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
134
+ let changedContent = context.tailwindConfig.content.files.filter((item)=>typeof item.raw === "string").map(({ raw , extension ="html" })=>({
135
+ content: raw,
136
+ extension
137
+ }));
138
+ for (let changedFile of resolveChangedFiles(candidateFiles, fileModifiedMap)){
139
+ let content = _fs.default.readFileSync(changedFile, "utf8");
140
+ let extension = _path.default.extname(changedFile).slice(1);
141
+ changedContent.push({
142
+ content,
143
+ extension
144
+ });
145
+ }
146
+ return changedContent;
147
+ }
148
+ /**
149
+ *
150
+ * @param {ContentPath[]} candidateFiles
151
+ * @param {Map<string, number>} fileModifiedMap
152
+ * @returns {Set<string>}
153
+ */ function resolveChangedFiles(candidateFiles, fileModifiedMap) {
154
+ let paths = candidateFiles.map((contentPath)=>contentPath.pattern);
155
+ let changedFiles = new Set();
156
+ _sharedState.env.DEBUG && console.time("Finding changed files");
157
+ let files = _fastGlob.default.sync(paths, {
158
+ absolute: true
159
+ });
160
+ for (let file of files){
161
+ let prevModified = fileModifiedMap.has(file) ? fileModifiedMap.get(file) : -Infinity;
162
+ let modified = _fs.default.statSync(file).mtimeMs;
163
+ // This check is intentionally >= because we track the last modified time of context dependencies
164
+ // earier in the process and we want to make sure we don't miss any changes that happen
165
+ // when a context dependency is also a content dependency
166
+ // Ideally, we'd do all this tracking at one time but that is a larger refactor
167
+ // than we want to commit to right now, so this is a decent compromise.
168
+ // This should be sufficient because file modification times will be off by at least
169
+ // 1ms (the precision of fstat in Node) in most cases if they exist and were changed.
170
+ if (modified >= prevModified) {
171
+ changedFiles.add(file);
172
+ fileModifiedMap.set(file, modified);
173
+ }
174
+ }
175
+ _sharedState.env.DEBUG && console.timeEnd("Finding changed files");
176
+ return changedFiles;
177
+ }