tailwindcss 0.0.0-insiders.bd4dddd → 0.0.0-insiders.bda8421

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 (224) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +13 -10
  3. package/colors.d.ts +3 -0
  4. package/defaultConfig.d.ts +3 -0
  5. package/defaultTheme.d.ts +4 -0
  6. package/lib/cli/build/deps.js +62 -0
  7. package/lib/cli/build/index.js +54 -0
  8. package/lib/cli/build/plugin.js +371 -0
  9. package/lib/cli/build/utils.js +88 -0
  10. package/lib/cli/build/watching.js +182 -0
  11. package/lib/cli/help/index.js +73 -0
  12. package/lib/cli/index.js +230 -0
  13. package/lib/cli/init/index.js +63 -0
  14. package/lib/cli-peer-dependencies.js +28 -7
  15. package/lib/cli.js +1 -741
  16. package/lib/corePluginList.js +17 -4
  17. package/lib/corePlugins.js +2503 -1839
  18. package/lib/css/preflight.css +32 -13
  19. package/lib/featureFlags.js +45 -28
  20. package/lib/index.js +1 -29
  21. package/lib/lib/cacheInvalidation.js +92 -0
  22. package/lib/lib/collapseAdjacentRules.js +30 -10
  23. package/lib/lib/collapseDuplicateDeclarations.js +13 -8
  24. package/lib/lib/content.js +214 -0
  25. package/lib/lib/defaultExtractor.js +240 -31
  26. package/lib/lib/evaluateTailwindFunctions.js +117 -50
  27. package/lib/lib/expandApplyAtRules.js +466 -230
  28. package/lib/lib/expandTailwindAtRules.js +156 -135
  29. package/lib/lib/findAtConfigPath.js +46 -0
  30. package/lib/lib/generateRules.js +554 -200
  31. package/lib/lib/getModuleDependencies.js +88 -37
  32. package/lib/lib/load-config.js +57 -0
  33. package/lib/lib/normalizeTailwindDirectives.js +39 -33
  34. package/lib/lib/offsets.js +355 -0
  35. package/lib/lib/partitionApplyAtRules.js +58 -0
  36. package/lib/lib/regex.js +74 -0
  37. package/lib/lib/remap-bitfield.js +89 -0
  38. package/lib/lib/resolveDefaultsAtRules.js +97 -69
  39. package/lib/lib/setupContextUtils.js +796 -341
  40. package/lib/lib/setupTrackingContext.js +66 -71
  41. package/lib/lib/sharedState.js +45 -14
  42. package/lib/lib/substituteScreenAtRules.js +14 -10
  43. package/lib/plugin.js +48 -0
  44. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  45. package/lib/postcss-plugins/nesting/index.js +21 -0
  46. package/lib/postcss-plugins/nesting/plugin.js +89 -0
  47. package/lib/processTailwindFeatures.js +37 -27
  48. package/lib/public/colors.js +272 -246
  49. package/lib/public/create-plugin.js +9 -5
  50. package/lib/public/default-config.js +10 -6
  51. package/lib/public/default-theme.js +10 -6
  52. package/lib/public/load-config.js +12 -0
  53. package/lib/public/resolve-config.js +11 -6
  54. package/lib/util/applyImportantSelector.js +36 -0
  55. package/lib/util/bigSign.js +6 -1
  56. package/lib/util/buildMediaQuery.js +13 -6
  57. package/lib/util/cloneDeep.js +9 -6
  58. package/lib/util/cloneNodes.js +44 -4
  59. package/lib/util/color.js +70 -53
  60. package/lib/util/colorNames.js +752 -0
  61. package/lib/util/configurePlugins.js +7 -2
  62. package/lib/util/createPlugin.js +8 -6
  63. package/lib/util/createUtilityPlugin.js +16 -16
  64. package/lib/util/dataTypes.js +295 -113
  65. package/lib/util/defaults.js +12 -7
  66. package/lib/util/escapeClassName.js +13 -8
  67. package/lib/util/escapeCommas.js +7 -2
  68. package/lib/util/flattenColorPalette.js +11 -12
  69. package/lib/util/formatVariantSelector.js +235 -151
  70. package/lib/util/getAllConfigs.js +33 -12
  71. package/lib/util/hashConfig.js +9 -4
  72. package/lib/util/isKeyframeRule.js +7 -2
  73. package/lib/util/isPlainObject.js +8 -3
  74. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +25 -15
  75. package/lib/util/log.js +25 -15
  76. package/lib/util/nameClass.js +27 -10
  77. package/lib/util/negateValue.js +25 -8
  78. package/lib/util/normalizeConfig.js +127 -82
  79. package/lib/util/normalizeScreens.js +128 -11
  80. package/lib/util/parseAnimationValue.js +44 -40
  81. package/lib/util/parseBoxShadowValue.js +34 -23
  82. package/lib/util/parseDependency.js +39 -55
  83. package/lib/util/parseGlob.js +36 -0
  84. package/lib/util/parseObjectStyles.js +15 -10
  85. package/lib/util/pluginUtils.js +172 -69
  86. package/lib/util/prefixSelector.js +30 -12
  87. package/lib/util/pseudoElements.js +212 -0
  88. package/lib/util/removeAlphaVariables.js +31 -0
  89. package/lib/util/resolveConfig.js +101 -87
  90. package/lib/util/resolveConfigPath.js +30 -12
  91. package/lib/util/responsive.js +11 -6
  92. package/lib/util/splitAtTopLevelOnly.js +51 -0
  93. package/lib/util/tap.js +6 -1
  94. package/lib/util/toColorValue.js +7 -3
  95. package/lib/util/toPath.js +22 -4
  96. package/lib/util/transformThemeValue.js +40 -30
  97. package/lib/util/validateConfig.js +37 -0
  98. package/lib/util/validateFormalSyntax.js +26 -0
  99. package/lib/util/withAlphaVariable.js +27 -15
  100. package/lib/value-parser/LICENSE +22 -0
  101. package/lib/value-parser/README.md +3 -0
  102. package/lib/value-parser/index.d.js +2 -0
  103. package/lib/value-parser/index.js +22 -0
  104. package/lib/value-parser/parse.js +259 -0
  105. package/lib/value-parser/stringify.js +38 -0
  106. package/lib/value-parser/unit.js +86 -0
  107. package/lib/value-parser/walk.js +16 -0
  108. package/loadConfig.d.ts +4 -0
  109. package/loadConfig.js +2 -0
  110. package/nesting/index.d.ts +4 -0
  111. package/nesting/index.js +2 -12
  112. package/package.json +60 -55
  113. package/peers/index.js +75503 -55095
  114. package/plugin.d.ts +11 -0
  115. package/resolveConfig.d.ts +31 -0
  116. package/scripts/generate-types.js +104 -0
  117. package/scripts/release-channel.js +18 -0
  118. package/scripts/release-notes.js +21 -0
  119. package/scripts/type-utils.js +27 -0
  120. package/src/cli/build/deps.js +56 -0
  121. package/src/cli/build/index.js +49 -0
  122. package/src/cli/build/plugin.js +437 -0
  123. package/src/cli/build/utils.js +76 -0
  124. package/src/cli/build/watching.js +229 -0
  125. package/src/cli/help/index.js +70 -0
  126. package/src/cli/index.js +216 -0
  127. package/src/cli/init/index.js +79 -0
  128. package/src/cli-peer-dependencies.js +7 -1
  129. package/src/cli.js +1 -811
  130. package/src/corePluginList.js +1 -1
  131. package/src/corePlugins.js +849 -243
  132. package/src/css/preflight.css +32 -13
  133. package/src/featureFlags.js +13 -9
  134. package/src/index.js +1 -28
  135. package/src/lib/cacheInvalidation.js +52 -0
  136. package/src/lib/collapseAdjacentRules.js +21 -2
  137. package/src/lib/content.js +249 -0
  138. package/src/lib/defaultExtractor.js +215 -33
  139. package/src/lib/evaluateTailwindFunctions.js +82 -8
  140. package/src/lib/expandApplyAtRules.js +512 -224
  141. package/src/lib/expandTailwindAtRules.js +102 -87
  142. package/src/lib/findAtConfigPath.js +48 -0
  143. package/src/lib/generateRules.js +541 -146
  144. package/src/lib/getModuleDependencies.js +70 -30
  145. package/src/lib/load-config.ts +44 -0
  146. package/src/lib/normalizeTailwindDirectives.js +1 -0
  147. package/src/lib/offsets.js +432 -0
  148. package/src/lib/partitionApplyAtRules.js +52 -0
  149. package/src/lib/regex.js +74 -0
  150. package/src/lib/remap-bitfield.js +82 -0
  151. package/src/lib/resolveDefaultsAtRules.js +55 -30
  152. package/src/lib/setupContextUtils.js +720 -190
  153. package/src/lib/setupTrackingContext.js +47 -61
  154. package/src/lib/sharedState.js +15 -4
  155. package/src/plugin.js +47 -0
  156. package/src/postcss-plugins/nesting/README.md +42 -0
  157. package/src/postcss-plugins/nesting/index.js +13 -0
  158. package/src/postcss-plugins/nesting/plugin.js +80 -0
  159. package/src/processTailwindFeatures.js +11 -4
  160. package/src/public/colors.js +22 -0
  161. package/src/public/default-config.js +1 -1
  162. package/src/public/default-theme.js +2 -2
  163. package/src/public/load-config.js +2 -0
  164. package/src/util/applyImportantSelector.js +27 -0
  165. package/src/util/buildMediaQuery.js +5 -3
  166. package/src/util/cloneNodes.js +40 -2
  167. package/src/util/color.js +39 -20
  168. package/src/util/colorNames.js +150 -0
  169. package/src/util/dataTypes.js +184 -26
  170. package/src/util/formatVariantSelector.js +272 -144
  171. package/src/util/getAllConfigs.js +21 -2
  172. package/src/util/isPlainObject.js +1 -1
  173. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  174. package/src/util/log.js +8 -8
  175. package/src/util/nameClass.js +4 -0
  176. package/src/util/negateValue.js +11 -3
  177. package/src/util/normalizeConfig.js +45 -6
  178. package/src/util/normalizeScreens.js +99 -4
  179. package/src/util/parseBoxShadowValue.js +4 -3
  180. package/src/util/parseDependency.js +37 -42
  181. package/src/util/parseGlob.js +24 -0
  182. package/src/util/pluginUtils.js +139 -24
  183. package/src/util/prefixSelector.js +31 -10
  184. package/src/util/pseudoElements.js +171 -0
  185. package/src/util/removeAlphaVariables.js +24 -0
  186. package/src/util/resolveConfig.js +70 -32
  187. package/src/util/resolveConfigPath.js +12 -1
  188. package/src/util/splitAtTopLevelOnly.js +52 -0
  189. package/src/util/toPath.js +1 -1
  190. package/src/util/transformThemeValue.js +13 -3
  191. package/src/util/validateConfig.js +26 -0
  192. package/src/util/validateFormalSyntax.js +34 -0
  193. package/src/util/withAlphaVariable.js +1 -1
  194. package/src/value-parser/LICENSE +22 -0
  195. package/src/value-parser/README.md +3 -0
  196. package/src/value-parser/index.d.ts +177 -0
  197. package/src/value-parser/index.js +28 -0
  198. package/src/value-parser/parse.js +303 -0
  199. package/src/value-parser/stringify.js +41 -0
  200. package/src/value-parser/unit.js +118 -0
  201. package/src/value-parser/walk.js +18 -0
  202. package/stubs/.gitignore +1 -0
  203. package/stubs/.prettierrc.json +6 -0
  204. package/stubs/{defaultConfig.stub.js → config.full.js} +290 -178
  205. package/stubs/postcss.config.js +6 -0
  206. package/stubs/tailwind.config.cjs +2 -0
  207. package/stubs/tailwind.config.js +2 -0
  208. package/stubs/tailwind.config.ts +3 -0
  209. package/types/config.d.ts +376 -0
  210. package/types/generated/.gitkeep +0 -0
  211. package/types/generated/colors.d.ts +298 -0
  212. package/types/generated/corePluginList.d.ts +1 -0
  213. package/types/generated/default-theme.d.ts +397 -0
  214. package/types/index.d.ts +11 -0
  215. package/CHANGELOG.md +0 -1959
  216. package/lib/constants.js +0 -37
  217. package/lib/lib/detectNesting.js +0 -34
  218. package/nesting/plugin.js +0 -41
  219. package/scripts/install-integrations.js +0 -27
  220. package/scripts/rebuildFixtures.js +0 -68
  221. package/src/constants.js +0 -17
  222. package/src/lib/detectNesting.js +0 -39
  223. /package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -0
  224. /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
@@ -9,7 +9,7 @@
9
9
  box-sizing: border-box; /* 1 */
10
10
  border-width: 0; /* 2 */
11
11
  border-style: solid; /* 2 */
12
- border-color: currentColor; /* 2 */
12
+ border-color: theme('borderColor.DEFAULT', currentColor); /* 2 */
13
13
  }
14
14
 
15
15
  ::before,
@@ -22,14 +22,21 @@
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.
26
+ 6. Use the user's configured `sans` font-variation-settings by default.
27
+ 7. Disable tap highlights on iOS
25
28
  */
26
29
 
27
- html {
30
+ html,
31
+ :host {
28
32
  line-height: 1.5; /* 1 */
29
33
  -webkit-text-size-adjust: 100%; /* 2 */
30
34
  -moz-tab-size: 4; /* 3 */
31
35
  tab-size: 4; /* 3 */
32
- 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 */
36
+ font-family: theme('fontFamily.sans', ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"); /* 4 */
37
+ font-feature-settings: theme('fontFamily.sans[1].fontFeatureSettings', normal); /* 5 */
38
+ font-variation-settings: theme('fontFamily.sans[1].fontVariationSettings', normal); /* 6 */
39
+ -webkit-tap-highlight-color: transparent; /* 7 */
33
40
  }
34
41
 
35
42
  /*
@@ -95,8 +102,10 @@ strong {
95
102
  }
96
103
 
97
104
  /*
98
- 1. Use the user's configured `mono` font family by default.
99
- 2. Correct the odd `em` font sizing in all browsers.
105
+ 1. Use the user's configured `mono` font-family by default.
106
+ 2. Use the user's configured `mono` font-feature-settings by default.
107
+ 3. Use the user's configured `mono` font-variation-settings by default.
108
+ 4. Correct the odd `em` font sizing in all browsers.
100
109
  */
101
110
 
102
111
  code,
@@ -104,7 +113,9 @@ kbd,
104
113
  samp,
105
114
  pre {
106
115
  font-family: theme('fontFamily.mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace); /* 1 */
107
- font-size: 1em; /* 2 */
116
+ font-feature-settings: theme('fontFamily.mono[1].fontFeatureSettings', normal); /* 2 */
117
+ font-variation-settings: theme('fontFamily.mono[1].fontVariationSettings', normal); /* 3 */
118
+ font-size: 1em; /* 4 */
108
119
  }
109
120
 
110
121
  /*
@@ -159,8 +170,12 @@ optgroup,
159
170
  select,
160
171
  textarea {
161
172
  font-family: inherit; /* 1 */
173
+ font-feature-settings: inherit; /* 1 */
174
+ font-variation-settings: inherit; /* 1 */
162
175
  font-size: 100%; /* 1 */
176
+ font-weight: inherit; /* 1 */
163
177
  line-height: inherit; /* 1 */
178
+ letter-spacing: inherit; /* 1 */
164
179
  color: inherit; /* 1 */
165
180
  margin: 0; /* 2 */
166
181
  padding: 0; /* 3 */
@@ -181,9 +196,9 @@ select {
181
196
  */
182
197
 
183
198
  button,
184
- [type='button'],
185
- [type='reset'],
186
- [type='submit'] {
199
+ input:where([type='button']),
200
+ input:where([type='reset']),
201
+ input:where([type='submit']) {
187
202
  -webkit-appearance: button; /* 1 */
188
203
  background-color: transparent; /* 2 */
189
204
  background-image: none; /* 2 */
@@ -295,6 +310,13 @@ menu {
295
310
  padding: 0;
296
311
  }
297
312
 
313
+ /*
314
+ Reset default styling for dialogs.
315
+ */
316
+ dialog {
317
+ padding: 0;
318
+ }
319
+
298
320
  /*
299
321
  Prevent resizing textareas horizontally by default.
300
322
  */
@@ -358,10 +380,7 @@ video {
358
380
  height: auto;
359
381
  }
360
382
 
361
- /*
362
- Ensure the default browser behavior of the `hidden` attribute.
363
- */
364
-
383
+ /* Make elements with the HTML hidden attribute stay hidden by default */
365
384
  [hidden] {
366
385
  display: none;
367
386
  }
@@ -2,61 +2,78 @@
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 _chalk = _interopRequireDefault(require("chalk"));
9
- var _log = _interopRequireDefault(require("./util/log"));
10
- function _interopRequireDefault(obj) {
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: function() {
13
+ return flagEnabled;
14
+ },
15
+ issueFlagNotices: function() {
16
+ return issueFlagNotices;
17
+ },
18
+ default: function() {
19
+ return _default;
20
+ }
21
+ });
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) {
11
25
  return obj && obj.__esModule ? obj : {
12
26
  default: obj
13
27
  };
14
28
  }
15
29
  let defaults = {
16
- // TODO: Drop this once we can safely rely on optimizeUniversalDefaults being
17
- // the default.
18
- optimizeUniversalDefaults: process.env.NODE_ENV === 'test' ? true : false
30
+ optimizeUniversalDefaults: false,
31
+ generalizedModifiers: true,
32
+ disableColorOpacityUtilitiesByDefault: false,
33
+ relativeContentPathsByDefault: false
19
34
  };
20
35
  let featureFlags = {
21
- future: [],
36
+ future: [
37
+ "hoverOnlyWhenSupported",
38
+ "respectDefaultRingColorOpacity",
39
+ "disableColorOpacityUtilitiesByDefault",
40
+ "relativeContentPathsByDefault"
41
+ ],
22
42
  experimental: [
23
- 'optimizeUniversalDefaults'
43
+ "optimizeUniversalDefaults",
44
+ "generalizedModifiers"
24
45
  ]
25
46
  };
26
47
  function flagEnabled(config, flag) {
27
48
  if (featureFlags.future.includes(flag)) {
28
- var ref;
29
- var ref1, ref2;
30
- 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);
49
+ var _config_future;
50
+ var _config_future_flag, _ref;
51
+ 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);
31
52
  }
32
53
  if (featureFlags.experimental.includes(flag)) {
33
- var ref3;
34
- var ref4, ref5;
35
- 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);
54
+ var _config_experimental;
55
+ var _config_experimental_flag, _ref1;
56
+ 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);
36
57
  }
37
58
  return false;
38
59
  }
39
60
  function experimentalFlagsEnabled(config) {
40
- if (config.experimental === 'all') {
61
+ if (config.experimental === "all") {
41
62
  return featureFlags.experimental;
42
63
  }
43
- var ref;
44
- return Object.keys((ref = config === null || config === void 0 ? void 0 : config.experimental) !== null && ref !== void 0 ? ref : {
45
- }).filter((flag)=>featureFlags.experimental.includes(flag) && config.experimental[flag]
46
- );
64
+ var _config_experimental;
65
+ 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]);
47
66
  }
48
67
  function issueFlagNotices(config) {
49
68
  if (process.env.JEST_WORKER_ID !== undefined) {
50
69
  return;
51
70
  }
52
71
  if (experimentalFlagsEnabled(config).length > 0) {
53
- let changes = experimentalFlagsEnabled(config).map((s)=>_chalk.default.yellow(s)
54
- ).join(', ');
55
- _log.default.warn('experimental-flags-enabled', [
72
+ let changes = experimentalFlagsEnabled(config).map((s)=>_picocolors.default.yellow(s)).join(", ");
73
+ _log.default.warn("experimental-flags-enabled", [
56
74
  `You have enabled experimental features: ${changes}`,
57
- 'Experimental features in Tailwind CSS are not covered by semver, may introduce breaking changes, and can change at any time.',
75
+ "Experimental features in Tailwind CSS are not covered by semver, may introduce breaking changes, and can change at any time."
58
76
  ]);
59
77
  }
60
78
  }
61
- var _default = featureFlags;
62
- exports.default = _default;
79
+ const _default = featureFlags;
package/lib/index.js CHANGED
@@ -1,30 +1,2 @@
1
1
  "use strict";
2
- var _setupTrackingContext = _interopRequireDefault(require("./lib/setupTrackingContext"));
3
- var _processTailwindFeatures = _interopRequireDefault(require("./processTailwindFeatures"));
4
- var _sharedState = require("./lib/sharedState");
5
- function _interopRequireDefault(obj) {
6
- return obj && obj.__esModule ? obj : {
7
- default: obj
8
- };
9
- }
10
- module.exports = function tailwindcss(configOrPath) {
11
- return {
12
- postcssPlugin: 'tailwindcss',
13
- plugins: [
14
- _sharedState.env.DEBUG && function(root) {
15
- console.log('\n');
16
- console.time('JIT TOTAL');
17
- return root;
18
- },
19
- function(root, result) {
20
- (0, _processTailwindFeatures).default((0, _setupTrackingContext).default(configOrPath))(root, result);
21
- },
22
- _sharedState.env.DEBUG && function(root) {
23
- console.timeEnd('JIT TOTAL');
24
- console.log('\n');
25
- return root;
26
- },
27
- ].filter(Boolean)
28
- };
29
- };
30
- module.exports.postcss = true;
2
+ module.exports = require("./plugin");
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
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) {
14
+ return obj && obj.__esModule ? obj : {
15
+ default: obj
16
+ };
17
+ }
18
+ function _getRequireWildcardCache(nodeInterop) {
19
+ if (typeof WeakMap !== "function") return null;
20
+ var cacheBabelInterop = new WeakMap();
21
+ var cacheNodeInterop = new WeakMap();
22
+ return (_getRequireWildcardCache = function(nodeInterop) {
23
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
24
+ })(nodeInterop);
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
+ }
80
+ function hasContentChanged(sourcePath, root) {
81
+ let css = root.toString();
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;
92
+ }
@@ -2,19 +2,24 @@
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: function() {
8
+ return collapseAdjacentRules;
9
+ }
10
+ });
6
11
  let comparisonMap = {
7
12
  atrule: [
8
- 'name',
9
- 'params'
13
+ "name",
14
+ "params"
10
15
  ],
11
16
  rule: [
12
- 'selector'
17
+ "selector"
13
18
  ]
14
19
  };
15
20
  let types = new Set(Object.keys(comparisonMap));
16
21
  function collapseAdjacentRules() {
17
- return (root)=>{
22
+ function collapseRulesIn(root) {
18
23
  let currentRule = null;
19
24
  root.each((node)=>{
20
25
  if (!types.has(node.type)) {
@@ -26,16 +31,31 @@ function collapseAdjacentRules() {
26
31
  return;
27
32
  }
28
33
  let properties = comparisonMap[node.type];
29
- var _property, _property1;
30
- if (node.type === 'atrule' && node.name === 'font-face') {
34
+ var _node_property, _currentRule_property;
35
+ if (node.type === "atrule" && node.name === "font-face") {
31
36
  currentRule = node;
32
- } 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, ' ')
33
- )) {
34
- currentRule.append(node.nodes);
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);
41
+ }
35
42
  node.remove();
36
43
  } else {
37
44
  currentRule = node;
38
45
  }
39
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);
40
60
  };
41
61
  }
@@ -2,7 +2,12 @@
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: function() {
8
+ return collapseDuplicateDeclarations;
9
+ }
10
+ });
6
11
  function collapseDuplicateDeclarations() {
7
12
  return (root)=>{
8
13
  root.walkRules((node)=>{
@@ -41,8 +46,8 @@ function collapseDuplicateDeclarations() {
41
46
  });
42
47
  // Drop all the duplicate declarations with the exact same value we've
43
48
  // already seen so far.
44
- for (let decl1 of droppable){
45
- decl1.remove();
49
+ for (let decl of droppable){
50
+ decl.remove();
46
51
  }
47
52
  // Analyze the declarations based on its unit, drop all the declarations
48
53
  // with the same unit but the last one in the list.
@@ -58,9 +63,9 @@ function collapseDuplicateDeclarations() {
58
63
  }
59
64
  byUnit.get(unit).add(decl);
60
65
  }
61
- for (let declarations1 of byUnit.values()){
66
+ for (let declarations of byUnit.values()){
62
67
  // Get all but the last one
63
- let removableDeclarations = Array.from(declarations1).slice(0, -1);
68
+ let removableDeclarations = Array.from(declarations).slice(0, -1);
64
69
  for (let decl of removableDeclarations){
65
70
  decl.remove();
66
71
  }
@@ -69,12 +74,12 @@ function collapseDuplicateDeclarations() {
69
74
  });
70
75
  };
71
76
  }
72
- let UNITLESS_NUMBER = Symbol('unitless-number');
77
+ let UNITLESS_NUMBER = Symbol("unitless-number");
73
78
  function resolveUnit(input) {
74
79
  let result = /^-?\d*.?\d+([\w%]+)?$/g.exec(input);
75
80
  if (result) {
76
- var ref;
77
- return (ref = result[1]) !== null && ref !== void 0 ? ref : UNITLESS_NUMBER;
81
+ var _result_;
82
+ return (_result_ = result[1]) !== null && _result_ !== void 0 ? _result_ : UNITLESS_NUMBER;
78
83
  }
79
84
  return null;
80
85
  }
@@ -0,0 +1,214 @@
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: function() {
14
+ return parseCandidateFiles;
15
+ },
16
+ resolvedChangedContent: function() {
17
+ return resolvedChangedContent;
18
+ }
19
+ });
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 _parseGlob = require("../util/parseGlob");
25
+ const _sharedState = require("./sharedState");
26
+ function _interop_require_default(obj) {
27
+ return obj && obj.__esModule ? obj : {
28
+ default: obj
29
+ };
30
+ }
31
+ /*!
32
+ * Modified version of normalize-path, original license below
33
+ *
34
+ * normalize-path <https://github.com/jonschlinkert/normalize-path>
35
+ *
36
+ * Copyright (c) 2014-2018, Jon Schlinkert.
37
+ * Released under the MIT License.
38
+ */ function normalizePath(path) {
39
+ if (typeof path !== "string") {
40
+ throw new TypeError("expected path to be a string");
41
+ }
42
+ if (path === "\\" || path === "/") return "/";
43
+ var len = path.length;
44
+ if (len <= 1) return path;
45
+ // ensure that win32 namespaces has two leading slashes, so that the path is
46
+ // handled properly by the win32 version of path.parse() after being normalized
47
+ // https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces
48
+ var prefix = "";
49
+ if (len > 4 && path[3] === "\\") {
50
+ var ch = path[2];
51
+ if ((ch === "?" || ch === ".") && path.slice(0, 2) === "\\\\") {
52
+ path = path.slice(2);
53
+ prefix = "//";
54
+ }
55
+ }
56
+ // Modified part: instead of purely splitting on `\\` and `/`, we split on
57
+ // `/` and `\\` that is _not_ followed by any of the following characters: ()[]
58
+ // This is to ensure that we keep the escaping of brackets and parentheses
59
+ let segs = path.split(/[/\\]+(?![\(\)\[\]])/);
60
+ return prefix + segs.join("/");
61
+ }
62
+ function parseCandidateFiles(context, tailwindConfig) {
63
+ let files = tailwindConfig.content.files;
64
+ // Normalize the file globs
65
+ files = files.filter((filePath)=>typeof filePath === "string");
66
+ files = files.map(normalizePath);
67
+ // Split into included and excluded globs
68
+ let tasks = _fastglob.default.generateTasks(files);
69
+ /** @type {ContentPath[]} */ let included = [];
70
+ /** @type {ContentPath[]} */ let excluded = [];
71
+ for (const task of tasks){
72
+ included.push(...task.positive.map((filePath)=>parseFilePath(filePath, false)));
73
+ excluded.push(...task.negative.map((filePath)=>parseFilePath(filePath, true)));
74
+ }
75
+ let paths = [
76
+ ...included,
77
+ ...excluded
78
+ ];
79
+ // Resolve paths relative to the config file or cwd
80
+ paths = resolveRelativePaths(context, paths);
81
+ // Resolve symlinks if possible
82
+ paths = paths.flatMap(resolvePathSymlinks);
83
+ // Update cached patterns
84
+ paths = paths.map(resolveGlobPattern);
85
+ return paths;
86
+ }
87
+ /**
88
+ *
89
+ * @param {string} filePath
90
+ * @param {boolean} ignore
91
+ * @returns {ContentPath}
92
+ */ function parseFilePath(filePath, ignore) {
93
+ // Escape special characters in the file path such as: ()[]
94
+ // But only if the special character isn't already escaped
95
+ filePath = filePath.replace(/(?<!\\)([\[\]\(\)])/g, "\\$1");
96
+ let contentPath = {
97
+ original: filePath,
98
+ base: filePath,
99
+ ignore,
100
+ pattern: filePath,
101
+ glob: null
102
+ };
103
+ if ((0, _isglob.default)(filePath)) {
104
+ Object.assign(contentPath, (0, _parseGlob.parseGlob)(filePath));
105
+ }
106
+ return contentPath;
107
+ }
108
+ /**
109
+ *
110
+ * @param {ContentPath} contentPath
111
+ * @returns {ContentPath}
112
+ */ function resolveGlobPattern(contentPath) {
113
+ // This is required for Windows support to properly pick up Glob paths.
114
+ // Afaik, this technically shouldn't be needed but there's probably
115
+ // some internal, direct path matching with a normalized path in
116
+ // a package which can't handle mixed directory separators
117
+ let base = normalizePath(contentPath.base);
118
+ // If the user's file path contains any special characters (like parens) for instance fast-glob
119
+ // is like "OOOH SHINY" and treats them as such. So we have to escape the base path to fix this
120
+ base = _fastglob.default.escapePath(base);
121
+ contentPath.pattern = contentPath.glob ? `${base}/${contentPath.glob}` : base;
122
+ contentPath.pattern = contentPath.ignore ? `!${contentPath.pattern}` : contentPath.pattern;
123
+ return contentPath;
124
+ }
125
+ /**
126
+ * Resolve each path relative to the config file (when possible) if the experimental flag is enabled
127
+ * Otherwise, resolve relative to the current working directory
128
+ *
129
+ * @param {any} context
130
+ * @param {ContentPath[]} contentPaths
131
+ * @returns {ContentPath[]}
132
+ */ function resolveRelativePaths(context, contentPaths) {
133
+ let resolveFrom = [];
134
+ // Resolve base paths relative to the config file (when possible) if the experimental flag is enabled
135
+ if (context.userConfigPath && context.tailwindConfig.content.relative) {
136
+ resolveFrom = [
137
+ _path.default.dirname(context.userConfigPath)
138
+ ];
139
+ }
140
+ return contentPaths.map((contentPath)=>{
141
+ contentPath.base = _path.default.resolve(...resolveFrom, contentPath.base);
142
+ return contentPath;
143
+ });
144
+ }
145
+ /**
146
+ * Resolve the symlink for the base directory / file in each path
147
+ * These are added as additional dependencies to watch for changes because
148
+ * some tools (like webpack) will only watch the actual file or directory
149
+ * but not the symlink itself even in projects that use monorepos.
150
+ *
151
+ * @param {ContentPath} contentPath
152
+ * @returns {ContentPath[]}
153
+ */ function resolvePathSymlinks(contentPath) {
154
+ let paths = [
155
+ contentPath
156
+ ];
157
+ try {
158
+ let resolvedPath = _fs.default.realpathSync(contentPath.base);
159
+ if (resolvedPath !== contentPath.base) {
160
+ paths.push({
161
+ ...contentPath,
162
+ base: resolvedPath
163
+ });
164
+ }
165
+ } catch {
166
+ // TODO: log this?
167
+ }
168
+ return paths;
169
+ }
170
+ function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
171
+ let changedContent = context.tailwindConfig.content.files.filter((item)=>typeof item.raw === "string").map(({ raw , extension ="html" })=>({
172
+ content: raw,
173
+ extension
174
+ }));
175
+ let [changedFiles, mTimesToCommit] = resolveChangedFiles(candidateFiles, fileModifiedMap);
176
+ for (let changedFile of changedFiles){
177
+ let extension = _path.default.extname(changedFile).slice(1);
178
+ changedContent.push({
179
+ file: changedFile,
180
+ extension
181
+ });
182
+ }
183
+ return [
184
+ changedContent,
185
+ mTimesToCommit
186
+ ];
187
+ }
188
+ /**
189
+ *
190
+ * @param {ContentPath[]} candidateFiles
191
+ * @param {Map<string, number>} fileModifiedMap
192
+ * @returns {[Set<string>, Map<string, number>]}
193
+ */ function resolveChangedFiles(candidateFiles, fileModifiedMap) {
194
+ let paths = candidateFiles.map((contentPath)=>contentPath.pattern);
195
+ let mTimesToCommit = new Map();
196
+ let changedFiles = new Set();
197
+ _sharedState.env.DEBUG && console.time("Finding changed files");
198
+ let files = _fastglob.default.sync(paths, {
199
+ absolute: true
200
+ });
201
+ for (let file of files){
202
+ let prevModified = fileModifiedMap.get(file) || -Infinity;
203
+ let modified = _fs.default.statSync(file).mtimeMs;
204
+ if (modified > prevModified) {
205
+ changedFiles.add(file);
206
+ mTimesToCommit.set(file, modified);
207
+ }
208
+ }
209
+ _sharedState.env.DEBUG && console.timeEnd("Finding changed files");
210
+ return [
211
+ changedFiles,
212
+ mTimesToCommit
213
+ ];
214
+ }