tailwindcss 0.0.0-insiders.f4635e0 → 0.0.0-insiders.f4a2ccd

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 (238) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +15 -7
  3. package/colors.d.ts +3 -0
  4. package/colors.js +2 -304
  5. package/defaultConfig.d.ts +3 -0
  6. package/defaultConfig.js +2 -4
  7. package/defaultTheme.d.ts +4 -0
  8. package/defaultTheme.js +2 -4
  9. package/lib/cli/build/deps.js +54 -0
  10. package/lib/cli/build/index.js +52 -0
  11. package/lib/cli/build/plugin.js +376 -0
  12. package/lib/cli/build/utils.js +78 -0
  13. package/lib/cli/build/watching.js +180 -0
  14. package/lib/cli/help/index.js +71 -0
  15. package/lib/cli/index.js +230 -0
  16. package/lib/cli/init/index.js +61 -0
  17. package/lib/cli-peer-dependencies.js +22 -14
  18. package/lib/cli.js +4 -762
  19. package/lib/corePluginList.js +182 -5
  20. package/lib/corePlugins.js +4109 -2952
  21. package/lib/css/preflight.css +24 -9
  22. package/lib/featureFlags.js +68 -50
  23. package/lib/index.js +5 -30
  24. package/lib/lib/cacheInvalidation.js +90 -0
  25. package/lib/lib/collapseAdjacentRules.js +52 -36
  26. package/lib/lib/collapseDuplicateDeclarations.js +83 -0
  27. package/lib/lib/content.js +177 -0
  28. package/lib/lib/defaultExtractor.js +241 -0
  29. package/lib/lib/detectNesting.js +39 -17
  30. package/lib/lib/evaluateTailwindFunctions.js +203 -161
  31. package/lib/lib/expandApplyAtRules.js +503 -221
  32. package/lib/lib/expandTailwindAtRules.js +255 -243
  33. package/lib/lib/findAtConfigPath.js +44 -0
  34. package/lib/lib/generateRules.js +831 -317
  35. package/lib/lib/getModuleDependencies.js +93 -49
  36. package/lib/lib/load-config.js +36 -0
  37. package/lib/lib/normalizeTailwindDirectives.js +79 -60
  38. package/lib/lib/offsets.js +304 -0
  39. package/lib/lib/partitionApplyAtRules.js +56 -0
  40. package/lib/lib/regex.js +60 -0
  41. package/lib/lib/remap-bitfield.js +87 -0
  42. package/lib/lib/resolveDefaultsAtRules.js +150 -94
  43. package/lib/lib/setupContextUtils.js +1197 -685
  44. package/lib/lib/setupTrackingContext.js +150 -177
  45. package/lib/lib/sharedState.js +70 -21
  46. package/lib/lib/substituteScreenAtRules.js +26 -28
  47. package/lib/oxide/cli/build/deps.js +81 -0
  48. package/lib/oxide/cli/build/index.js +51 -0
  49. package/lib/oxide/cli/build/plugin.js +373 -0
  50. package/lib/oxide/cli/build/utils.js +77 -0
  51. package/lib/oxide/cli/build/watching.js +177 -0
  52. package/lib/oxide/cli/help/index.js +70 -0
  53. package/lib/oxide/cli/index.js +214 -0
  54. package/lib/oxide/cli/init/index.js +50 -0
  55. package/lib/oxide/cli.js +5 -0
  56. package/lib/oxide/postcss-plugin.js +2 -0
  57. package/lib/plugin.js +98 -0
  58. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  59. package/lib/postcss-plugins/nesting/index.js +19 -0
  60. package/lib/postcss-plugins/nesting/plugin.js +87 -0
  61. package/lib/processTailwindFeatures.js +58 -56
  62. package/lib/public/colors.js +353 -0
  63. package/lib/public/create-plugin.js +15 -0
  64. package/lib/public/default-config.js +16 -0
  65. package/lib/public/default-theme.js +16 -0
  66. package/lib/public/load-config.js +10 -0
  67. package/lib/public/resolve-config.js +22 -0
  68. package/lib/util/applyImportantSelector.js +22 -0
  69. package/lib/util/bigSign.js +7 -6
  70. package/lib/util/buildMediaQuery.js +21 -32
  71. package/lib/util/cloneDeep.js +16 -14
  72. package/lib/util/cloneNodes.js +29 -15
  73. package/lib/util/color.js +104 -66
  74. package/lib/util/configurePlugins.js +17 -15
  75. package/lib/util/createPlugin.js +23 -26
  76. package/lib/util/createUtilityPlugin.js +46 -46
  77. package/lib/util/dataTypes.js +266 -0
  78. package/lib/util/defaults.js +20 -15
  79. package/lib/util/escapeClassName.js +18 -17
  80. package/lib/util/escapeCommas.js +7 -6
  81. package/lib/util/flattenColorPalette.js +13 -12
  82. package/lib/util/formatVariantSelector.js +341 -0
  83. package/lib/util/getAllConfigs.js +44 -18
  84. package/lib/util/hashConfig.js +15 -12
  85. package/lib/util/isKeyframeRule.js +7 -6
  86. package/lib/util/isPlainObject.js +11 -11
  87. package/lib/util/isSyntacticallyValidPropertyValue.js +72 -0
  88. package/lib/util/log.js +52 -33
  89. package/lib/util/nameClass.js +35 -29
  90. package/lib/util/negateValue.js +31 -17
  91. package/lib/util/normalizeConfig.js +294 -0
  92. package/lib/util/normalizeScreens.js +170 -0
  93. package/lib/util/parseAnimationValue.js +85 -54
  94. package/lib/util/parseBoxShadowValue.js +84 -0
  95. package/lib/util/parseDependency.js +41 -70
  96. package/lib/util/parseGlob.js +34 -0
  97. package/lib/util/parseObjectStyles.js +30 -24
  98. package/lib/util/pluginUtils.js +234 -288
  99. package/lib/util/prefixSelector.js +33 -19
  100. package/lib/util/removeAlphaVariables.js +29 -0
  101. package/lib/util/resolveConfig.js +221 -256
  102. package/lib/util/resolveConfigPath.js +55 -48
  103. package/lib/util/responsive.js +18 -14
  104. package/lib/util/splitAtTopLevelOnly.js +49 -0
  105. package/lib/util/tap.js +8 -7
  106. package/lib/util/toColorValue.js +7 -6
  107. package/lib/util/toPath.js +27 -8
  108. package/lib/util/transformThemeValue.js +67 -28
  109. package/lib/util/validateConfig.js +24 -0
  110. package/lib/util/validateFormalSyntax.js +24 -0
  111. package/lib/util/withAlphaVariable.js +67 -57
  112. package/loadConfig.d.ts +4 -0
  113. package/loadConfig.js +2 -0
  114. package/nesting/index.js +2 -12
  115. package/package.json +69 -66
  116. package/peers/index.js +76328 -84169
  117. package/plugin.d.ts +11 -0
  118. package/plugin.js +1 -2
  119. package/resolveConfig.d.ts +12 -0
  120. package/resolveConfig.js +2 -7
  121. package/scripts/create-plugin-list.js +2 -2
  122. package/scripts/generate-types.js +105 -0
  123. package/scripts/release-channel.js +18 -0
  124. package/scripts/release-notes.js +21 -0
  125. package/scripts/swap-engines.js +40 -0
  126. package/scripts/type-utils.js +27 -0
  127. package/src/cli/build/deps.js +56 -0
  128. package/src/cli/build/index.js +49 -0
  129. package/src/cli/build/plugin.js +444 -0
  130. package/src/cli/build/utils.js +76 -0
  131. package/src/cli/build/watching.js +229 -0
  132. package/src/cli/help/index.js +70 -0
  133. package/src/cli/index.js +216 -0
  134. package/src/cli/init/index.js +79 -0
  135. package/src/cli-peer-dependencies.js +7 -1
  136. package/src/cli.js +4 -756
  137. package/src/corePluginList.js +1 -1
  138. package/src/corePlugins.js +2526 -1956
  139. package/src/css/preflight.css +24 -9
  140. package/src/featureFlags.js +33 -10
  141. package/src/index.js +4 -33
  142. package/src/lib/cacheInvalidation.js +52 -0
  143. package/src/lib/collapseAdjacentRules.js +21 -2
  144. package/src/lib/collapseDuplicateDeclarations.js +93 -0
  145. package/src/lib/content.js +208 -0
  146. package/src/lib/defaultExtractor.js +217 -0
  147. package/src/lib/detectNesting.js +30 -3
  148. package/src/lib/evaluateTailwindFunctions.js +84 -10
  149. package/src/lib/expandApplyAtRules.js +509 -153
  150. package/src/lib/expandTailwindAtRules.js +125 -104
  151. package/src/lib/findAtConfigPath.js +48 -0
  152. package/src/lib/generateRules.js +678 -70
  153. package/src/lib/getModuleDependencies.js +70 -30
  154. package/src/lib/load-config.ts +27 -0
  155. package/src/lib/normalizeTailwindDirectives.js +10 -3
  156. package/src/lib/offsets.js +373 -0
  157. package/src/lib/partitionApplyAtRules.js +52 -0
  158. package/src/lib/regex.js +74 -0
  159. package/src/lib/remap-bitfield.js +82 -0
  160. package/src/lib/resolveDefaultsAtRules.js +105 -47
  161. package/src/lib/setupContextUtils.js +848 -247
  162. package/src/lib/setupTrackingContext.js +53 -64
  163. package/src/lib/sharedState.js +60 -6
  164. package/src/lib/substituteScreenAtRules.js +6 -3
  165. package/src/oxide/cli/build/deps.ts +91 -0
  166. package/src/oxide/cli/build/index.ts +47 -0
  167. package/src/oxide/cli/build/plugin.ts +442 -0
  168. package/src/oxide/cli/build/utils.ts +74 -0
  169. package/src/oxide/cli/build/watching.ts +225 -0
  170. package/src/oxide/cli/help/index.ts +69 -0
  171. package/src/oxide/cli/index.ts +204 -0
  172. package/src/oxide/cli/init/index.ts +59 -0
  173. package/src/oxide/cli.ts +1 -0
  174. package/src/oxide/postcss-plugin.ts +1 -0
  175. package/src/plugin.js +107 -0
  176. package/src/postcss-plugins/nesting/README.md +42 -0
  177. package/src/postcss-plugins/nesting/index.js +13 -0
  178. package/src/postcss-plugins/nesting/plugin.js +80 -0
  179. package/src/processTailwindFeatures.js +18 -3
  180. package/src/public/colors.js +322 -0
  181. package/src/public/create-plugin.js +2 -0
  182. package/src/public/default-config.js +4 -0
  183. package/src/public/default-theme.js +4 -0
  184. package/src/public/load-config.js +2 -0
  185. package/src/public/resolve-config.js +7 -0
  186. package/src/util/applyImportantSelector.js +19 -0
  187. package/src/util/buildMediaQuery.js +14 -16
  188. package/src/util/cloneNodes.js +19 -2
  189. package/src/util/color.js +43 -11
  190. package/src/util/createUtilityPlugin.js +2 -11
  191. package/src/util/dataTypes.js +281 -0
  192. package/src/util/defaults.js +6 -0
  193. package/src/util/formatVariantSelector.js +412 -0
  194. package/src/util/getAllConfigs.js +21 -2
  195. package/src/util/isSyntacticallyValidPropertyValue.js +61 -0
  196. package/src/util/log.js +23 -22
  197. package/src/util/nameClass.js +6 -2
  198. package/src/util/negateValue.js +15 -5
  199. package/src/util/normalizeConfig.js +318 -0
  200. package/src/util/normalizeScreens.js +140 -0
  201. package/src/util/parseAnimationValue.js +7 -1
  202. package/src/util/parseBoxShadowValue.js +72 -0
  203. package/src/util/parseDependency.js +37 -38
  204. package/src/util/parseGlob.js +24 -0
  205. package/src/util/pluginUtils.js +219 -219
  206. package/src/util/prefixSelector.js +30 -13
  207. package/src/util/removeAlphaVariables.js +24 -0
  208. package/src/util/resolveConfig.js +86 -91
  209. package/src/util/resolveConfigPath.js +12 -1
  210. package/src/util/splitAtTopLevelOnly.js +52 -0
  211. package/src/util/toPath.js +23 -1
  212. package/src/util/transformThemeValue.js +33 -8
  213. package/src/util/validateConfig.js +13 -0
  214. package/src/util/validateFormalSyntax.js +34 -0
  215. package/src/util/withAlphaVariable.js +14 -9
  216. package/stubs/.gitignore +1 -0
  217. package/stubs/.prettierrc.json +6 -0
  218. package/stubs/{defaultConfig.stub.js → config.full.js} +332 -249
  219. package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -1
  220. package/stubs/postcss.config.js +6 -0
  221. package/stubs/tailwind.config.cjs +2 -0
  222. package/stubs/tailwind.config.js +2 -0
  223. package/stubs/tailwind.config.ts +3 -0
  224. package/types/config.d.ts +373 -0
  225. package/types/generated/.gitkeep +0 -0
  226. package/types/generated/colors.d.ts +298 -0
  227. package/types/generated/corePluginList.d.ts +1 -0
  228. package/types/generated/default-theme.d.ts +347 -0
  229. package/types/index.d.ts +7 -0
  230. package/CHANGELOG.md +0 -1742
  231. package/lib/constants.js +0 -37
  232. package/lib/lib/setupWatchingContext.js +0 -331
  233. package/nesting/plugin.js +0 -41
  234. package/scripts/install-integrations.js +0 -27
  235. package/scripts/rebuildFixtures.js +0 -68
  236. package/src/constants.js +0 -17
  237. package/src/lib/setupWatchingContext.js +0 -307
  238. /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
@@ -1,260 +1,272 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.default = expandTailwindAtRules;
7
-
8
- var sharedState = _interopRequireWildcard(require("./sharedState"));
9
-
10
- var _generateRules = require("./generateRules");
11
-
12
- var _bigSign = _interopRequireDefault(require("../util/bigSign"));
13
-
14
- var _cloneNodes = _interopRequireDefault(require("../util/cloneNodes"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
-
20
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
-
22
- let env = sharedState.env;
23
- let contentMatchCache = sharedState.contentMatchCache;
24
- const PATTERNS = ["([^<>\"'`\\s]*\\['[^<>\"'`\\s]*'\\])", // `content-['hello']` but not `content-['hello']']`
25
- '([^<>"\'`\\s]*\\["[^<>"\'`\\s]*"\\])', // `content-["hello"]` but not `content-["hello"]"]`
26
- '([^<>"\'`\\s]*\\[[^<>"\'`\\s]+\\])', // `fill-[#bada55]`
27
- '([^<>"\'`\\s]*[^<>"\'`\\s:])' // `px-1.5`, `uppercase` but not `uppercase:`
28
- ].join('|');
29
- const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
30
- const INNER_MATCH_GLOBAL_REGEXP = /[^<>"'`\s.(){}[\]#=%]*[^<>"'`\s.(){}[\]#=%:]/g;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>expandTailwindAtRules
8
+ });
9
+ const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
10
+ const _quickLru = /*#__PURE__*/ _interopRequireDefault(require("quick-lru"));
11
+ const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
12
+ const _generateRules = require("./generateRules");
13
+ const _log = /*#__PURE__*/ _interopRequireDefault(require("../util/log"));
14
+ const _cloneNodes = /*#__PURE__*/ _interopRequireDefault(require("../util/cloneNodes"));
15
+ const _defaultExtractor = require("./defaultExtractor");
16
+ function _interopRequireDefault(obj) {
17
+ return obj && obj.__esModule ? obj : {
18
+ default: obj
19
+ };
20
+ }
21
+ function _getRequireWildcardCache(nodeInterop) {
22
+ if (typeof WeakMap !== "function") return null;
23
+ var cacheBabelInterop = new WeakMap();
24
+ var cacheNodeInterop = new WeakMap();
25
+ return (_getRequireWildcardCache = function(nodeInterop) {
26
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
27
+ })(nodeInterop);
28
+ }
29
+ function _interopRequireWildcard(obj, nodeInterop) {
30
+ if (!nodeInterop && obj && obj.__esModule) {
31
+ return obj;
32
+ }
33
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
34
+ return {
35
+ default: obj
36
+ };
37
+ }
38
+ var cache = _getRequireWildcardCache(nodeInterop);
39
+ if (cache && cache.has(obj)) {
40
+ return cache.get(obj);
41
+ }
42
+ var newObj = {};
43
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
44
+ for(var key in obj){
45
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
46
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
47
+ if (desc && (desc.get || desc.set)) {
48
+ Object.defineProperty(newObj, key, desc);
49
+ } else {
50
+ newObj[key] = obj[key];
51
+ }
52
+ }
53
+ }
54
+ newObj.default = obj;
55
+ if (cache) {
56
+ cache.set(obj, newObj);
57
+ }
58
+ return newObj;
59
+ }
60
+ let env = _sharedState.env;
31
61
  const builtInExtractors = {
32
- DEFAULT: content => {
33
- let broadMatches = content.match(BROAD_MATCH_GLOBAL_REGEXP) || [];
34
- let innerMatches = content.match(INNER_MATCH_GLOBAL_REGEXP) || [];
35
- return [...broadMatches, ...innerMatches];
36
- }
62
+ DEFAULT: _defaultExtractor.defaultExtractor
37
63
  };
38
64
  const builtInTransformers = {
39
- DEFAULT: content => content,
40
- svelte: content => content.replace(/(?:^|\s)class:/g, ' ')
65
+ DEFAULT: (content)=>content,
66
+ svelte: (content)=>content.replace(/(?:^|\s)class:/g, " ")
41
67
  };
42
-
43
- function getExtractor(tailwindConfig, fileExtension) {
44
- let extractors = tailwindConfig.content.extract;
45
- let contentOptions = tailwindConfig.content.options;
46
-
47
- if (typeof extractors === 'function') {
48
- extractors = {
49
- DEFAULT: extractors
50
- };
51
- }
52
-
53
- if (contentOptions.defaultExtractor) {
54
- extractors.DEFAULT = contentOptions.defaultExtractor;
55
- }
56
-
57
- for (let {
58
- extensions,
59
- extractor
60
- } of contentOptions.extractors || []) {
61
- for (let extension of extensions) {
62
- extractors[extension] = extractor;
63
- }
64
- }
65
-
66
- return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT;
68
+ function getExtractor(context, fileExtension) {
69
+ let extractors = context.tailwindConfig.content.extract;
70
+ return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT(context);
67
71
  }
68
-
69
72
  function getTransformer(tailwindConfig, fileExtension) {
70
- let transformers = tailwindConfig.content.transform;
71
-
72
- if (typeof transformers === 'function') {
73
- transformers = {
74
- DEFAULT: transformers
75
- };
76
- }
77
-
78
- return transformers[fileExtension] || transformers.DEFAULT || builtInTransformers[fileExtension] || builtInTransformers.DEFAULT;
79
- } // Scans template contents for possible classes. This is a hot path on initial build but
73
+ let transformers = tailwindConfig.content.transform;
74
+ return transformers[fileExtension] || transformers.DEFAULT || builtInTransformers[fileExtension] || builtInTransformers.DEFAULT;
75
+ }
76
+ let extractorCache = new WeakMap();
77
+ // Scans template contents for possible classes. This is a hot path on initial build but
80
78
  // not too important for subsequent builds. The faster the better though — if we can speed
81
79
  // up these regexes by 50% that could cut initial build time by like 20%.
82
-
83
-
84
- function getClassCandidates(content, extractor, contentMatchCache, candidates, seen) {
85
- for (let line of content.split('\n')) {
86
- line = line.trim();
87
-
88
- if (seen.has(line)) {
89
- continue;
80
+ function getClassCandidates(content, extractor, candidates, seen) {
81
+ if (!extractorCache.has(extractor)) {
82
+ extractorCache.set(extractor, new _quickLru.default({
83
+ maxSize: 25000
84
+ }));
90
85
  }
91
-
92
- seen.add(line);
93
-
94
- if (contentMatchCache.has(line)) {
95
- for (let match of contentMatchCache.get(line)) {
96
- candidates.add(match);
97
- }
98
- } else {
99
- let extractorMatches = extractor(line).filter(s => s !== '!*');
100
- let lineMatchesSet = new Set(extractorMatches);
101
-
102
- for (let match of lineMatchesSet) {
103
- candidates.add(match);
104
- }
105
-
106
- contentMatchCache.set(line, lineMatchesSet);
86
+ for (let line of content.split("\n")){
87
+ line = line.trim();
88
+ if (seen.has(line)) {
89
+ continue;
90
+ }
91
+ seen.add(line);
92
+ if (extractorCache.get(extractor).has(line)) {
93
+ for (let match of extractorCache.get(extractor).get(line)){
94
+ candidates.add(match);
95
+ }
96
+ } else {
97
+ let extractorMatches = extractor(line).filter((s)=>s !== "!*");
98
+ let lineMatchesSet = new Set(extractorMatches);
99
+ for (let match1 of lineMatchesSet){
100
+ candidates.add(match1);
101
+ }
102
+ extractorCache.get(extractor).set(line, lineMatchesSet);
103
+ }
107
104
  }
108
- }
109
105
  }
110
-
111
- function buildStylesheet(rules, context) {
112
- let sortedRules = rules.sort(([a], [z]) => (0, _bigSign.default)(a - z));
113
- let returnValue = {
114
- base: new Set(),
115
- components: new Set(),
116
- utilities: new Set(),
117
- variants: new Set(),
118
- // All the CSS that is not Tailwind related can be put in this bucket. This
119
- // will make it easier to later use this information when we want to
120
- // `@apply` for example. The main reason we do this here is because we
121
- // still need to make sure the order is correct. Last but not least, we
122
- // will make sure to always re-inject this section into the css, even if
123
- // certain rules were not used. This means that it will look like a no-op
124
- // from the user's perspective, but we gathered all the useful information
125
- // we need.
126
- user: new Set()
127
- };
128
-
129
- for (let [sort, rule] of sortedRules) {
130
- if (sort >= context.minimumScreen) {
131
- returnValue.variants.add(rule);
132
- continue;
133
- }
134
-
135
- if (sort & context.layerOrder.base) {
136
- returnValue.base.add(rule);
137
- continue;
138
- }
139
-
140
- if (sort & context.layerOrder.components) {
141
- returnValue.components.add(rule);
142
- continue;
143
- }
144
-
145
- if (sort & context.layerOrder.utilities) {
146
- returnValue.utilities.add(rule);
147
- continue;
148
- }
149
-
150
- if (sort & context.layerOrder.user) {
151
- returnValue.user.add(rule);
152
- continue;
106
+ /**
107
+ *
108
+ * @param {[import('./offsets.js').RuleOffset, import('postcss').Node][]} rules
109
+ * @param {*} context
110
+ */ function buildStylesheet(rules, context) {
111
+ let sortedRules = context.offsets.sort(rules);
112
+ let returnValue = {
113
+ base: new Set(),
114
+ defaults: new Set(),
115
+ components: new Set(),
116
+ utilities: new Set(),
117
+ variants: new Set()
118
+ };
119
+ for (let [sort, rule] of sortedRules){
120
+ returnValue[sort.layer].add(rule);
153
121
  }
154
- }
155
-
156
- return returnValue;
122
+ return returnValue;
157
123
  }
158
-
159
124
  function expandTailwindAtRules(context) {
160
- return root => {
161
- let layerNodes = {
162
- base: null,
163
- components: null,
164
- utilities: null,
165
- variants: null
166
- }; // Make sure this file contains Tailwind directives. If not, we can save
167
- // a lot of work and bail early. Also we don't have to register our touch
168
- // file as a dependency since the output of this CSS does not depend on
169
- // the source of any templates. Think Vue <style> blocks for example.
170
-
171
- root.walkAtRules('tailwind', rule => {
172
- if (Object.keys(layerNodes).includes(rule.params)) {
173
- layerNodes[rule.params] = rule;
174
- }
175
- });
176
-
177
- if (Object.values(layerNodes).every(n => n === null)) {
178
- return root;
179
- } // ---
180
- // Find potential rules in changed files
181
-
182
-
183
- let candidates = new Set(['*']);
184
- let seen = new Set();
185
- env.DEBUG && console.time('Reading changed files');
186
-
187
- for (let {
188
- content,
189
- extension
190
- } of context.changedContent) {
191
- let transformer = getTransformer(context.tailwindConfig, extension);
192
- let extractor = getExtractor(context.tailwindConfig, extension);
193
- getClassCandidates(transformer(content), extractor, contentMatchCache, candidates, seen);
194
- } // ---
195
- // Generate the actual CSS
196
-
197
-
198
- let classCacheCount = context.classCache.size;
199
- env.DEBUG && console.time('Generate rules');
200
- let rules = (0, _generateRules.generateRules)(candidates, context);
201
- env.DEBUG && console.timeEnd('Generate rules'); // We only ever add to the classCache, so if it didn't grow, there is nothing new.
202
-
203
- env.DEBUG && console.time('Build stylesheet');
204
-
205
- if (context.stylesheetCache === null || context.classCache.size !== classCacheCount) {
206
- for (let rule of rules) {
207
- context.ruleCache.add(rule);
208
- }
209
-
210
- context.stylesheetCache = buildStylesheet([...context.ruleCache], context);
211
- }
212
-
213
- env.DEBUG && console.timeEnd('Build stylesheet');
214
- let {
215
- base: baseNodes,
216
- components: componentNodes,
217
- utilities: utilityNodes,
218
- variants: screenNodes
219
- } = context.stylesheetCache; // ---
220
- // Replace any Tailwind directives with generated CSS
221
-
222
- if (layerNodes.base) {
223
- layerNodes.base.before((0, _cloneNodes.default)([...baseNodes], layerNodes.base.source));
224
- layerNodes.base.remove();
225
- }
226
-
227
- if (layerNodes.components) {
228
- layerNodes.components.before((0, _cloneNodes.default)([...componentNodes], layerNodes.components.source));
229
- layerNodes.components.remove();
230
- }
231
-
232
- if (layerNodes.utilities) {
233
- layerNodes.utilities.before((0, _cloneNodes.default)([...utilityNodes], layerNodes.utilities.source));
234
- layerNodes.utilities.remove();
235
- }
236
-
237
- if (layerNodes.variants) {
238
- layerNodes.variants.before((0, _cloneNodes.default)([...screenNodes], layerNodes.variants.source));
239
- layerNodes.variants.remove();
240
- } else {
241
- root.append((0, _cloneNodes.default)([...screenNodes], root.source));
242
- } // ---
243
-
244
-
245
- if (env.DEBUG) {
246
- console.log('Potential classes: ', candidates.size);
247
- console.log('Active contexts: ', sharedState.contextSourcesMap.size);
248
- console.log('Content match entries', contentMatchCache.size);
249
- } // Clear the cache for the changed files
250
-
251
-
252
- context.changedContent = []; // Cleanup any leftover @layer atrules
253
-
254
- root.walkAtRules('layer', rule => {
255
- if (Object.keys(layerNodes).includes(rule.params)) {
256
- rule.remove();
257
- }
258
- });
259
- };
260
- }
125
+ return (root)=>{
126
+ let layerNodes = {
127
+ base: null,
128
+ components: null,
129
+ utilities: null,
130
+ variants: null
131
+ };
132
+ root.walkAtRules((rule)=>{
133
+ // Make sure this file contains Tailwind directives. If not, we can save
134
+ // a lot of work and bail early. Also we don't have to register our touch
135
+ // file as a dependency since the output of this CSS does not depend on
136
+ // the source of any templates. Think Vue <style> blocks for example.
137
+ if (rule.name === "tailwind") {
138
+ if (Object.keys(layerNodes).includes(rule.params)) {
139
+ layerNodes[rule.params] = rule;
140
+ }
141
+ }
142
+ });
143
+ if (Object.values(layerNodes).every((n)=>n === null)) {
144
+ return root;
145
+ }
146
+ var _context_candidates;
147
+ // ---
148
+ // Find potential rules in changed files
149
+ let candidates = new Set([
150
+ ...(_context_candidates = context.candidates) !== null && _context_candidates !== void 0 ? _context_candidates : [],
151
+ _sharedState.NOT_ON_DEMAND
152
+ ]);
153
+ let seen = new Set();
154
+ env.DEBUG && console.time("Reading changed files");
155
+ if (env.OXIDE) {
156
+ // TODO: Pass through or implement `extractor`
157
+ for (let candidate of require("@tailwindcss/oxide").parseCandidateStringsFromFiles(context.changedContent)){
158
+ candidates.add(candidate);
159
+ }
160
+ // for (let { file, content, extension } of context.changedContent) {
161
+ // let transformer = getTransformer(context.tailwindConfig, extension)
162
+ // let extractor = getExtractor(context, extension)
163
+ // getClassCandidatesOxide(file, transformer(content), extractor, candidates, seen)
164
+ // }
165
+ } else {
166
+ for (let { file , content , extension } of context.changedContent){
167
+ let transformer = getTransformer(context.tailwindConfig, extension);
168
+ let extractor = getExtractor(context, extension);
169
+ content = file ? _fs.default.readFileSync(file, "utf8") : content;
170
+ getClassCandidates(transformer(content), extractor, candidates, seen);
171
+ }
172
+ }
173
+ env.DEBUG && console.timeEnd("Reading changed files");
174
+ // ---
175
+ // Generate the actual CSS
176
+ let classCacheCount = context.classCache.size;
177
+ env.DEBUG && console.time("Generate rules");
178
+ env.DEBUG && console.time("Sorting candidates");
179
+ let sortedCandidates = env.OXIDE ? candidates : new Set([
180
+ ...candidates
181
+ ].sort((a, z)=>{
182
+ if (a === z) return 0;
183
+ if (a < z) return -1;
184
+ return 1;
185
+ }));
186
+ env.DEBUG && console.timeEnd("Sorting candidates");
187
+ (0, _generateRules.generateRules)(sortedCandidates, context);
188
+ env.DEBUG && console.timeEnd("Generate rules");
189
+ // We only ever add to the classCache, so if it didn't grow, there is nothing new.
190
+ env.DEBUG && console.time("Build stylesheet");
191
+ if (context.stylesheetCache === null || context.classCache.size !== classCacheCount) {
192
+ context.stylesheetCache = buildStylesheet([
193
+ ...context.ruleCache
194
+ ], context);
195
+ }
196
+ env.DEBUG && console.timeEnd("Build stylesheet");
197
+ let { defaults: defaultNodes , base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes } = context.stylesheetCache;
198
+ // ---
199
+ // Replace any Tailwind directives with generated CSS
200
+ if (layerNodes.base) {
201
+ layerNodes.base.before((0, _cloneNodes.default)([
202
+ ...baseNodes,
203
+ ...defaultNodes
204
+ ], layerNodes.base.source, {
205
+ layer: "base"
206
+ }));
207
+ layerNodes.base.remove();
208
+ }
209
+ if (layerNodes.components) {
210
+ layerNodes.components.before((0, _cloneNodes.default)([
211
+ ...componentNodes
212
+ ], layerNodes.components.source, {
213
+ layer: "components"
214
+ }));
215
+ layerNodes.components.remove();
216
+ }
217
+ if (layerNodes.utilities) {
218
+ layerNodes.utilities.before((0, _cloneNodes.default)([
219
+ ...utilityNodes
220
+ ], layerNodes.utilities.source, {
221
+ layer: "utilities"
222
+ }));
223
+ layerNodes.utilities.remove();
224
+ }
225
+ // We do post-filtering to not alter the emitted order of the variants
226
+ const variantNodes = Array.from(screenNodes).filter((node)=>{
227
+ var _node_raws_tailwind;
228
+ const parentLayer = (_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.parentLayer;
229
+ if (parentLayer === "components") {
230
+ return layerNodes.components !== null;
231
+ }
232
+ if (parentLayer === "utilities") {
233
+ return layerNodes.utilities !== null;
234
+ }
235
+ return true;
236
+ });
237
+ if (layerNodes.variants) {
238
+ layerNodes.variants.before((0, _cloneNodes.default)(variantNodes, layerNodes.variants.source, {
239
+ layer: "variants"
240
+ }));
241
+ layerNodes.variants.remove();
242
+ } else if (variantNodes.length > 0) {
243
+ root.append((0, _cloneNodes.default)(variantNodes, root.source, {
244
+ layer: "variants"
245
+ }));
246
+ }
247
+ // If we've got a utility layer and no utilities are generated there's likely something wrong
248
+ const hasUtilityVariants = variantNodes.some((node)=>{
249
+ var _node_raws_tailwind;
250
+ return ((_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.parentLayer) === "utilities";
251
+ });
252
+ if (layerNodes.utilities && utilityNodes.size === 0 && !hasUtilityVariants) {
253
+ _log.default.warn("content-problems", [
254
+ "No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.",
255
+ "https://tailwindcss.com/docs/content-configuration"
256
+ ]);
257
+ }
258
+ // ---
259
+ if (env.DEBUG) {
260
+ console.log("Potential classes: ", candidates.size);
261
+ console.log("Active contexts: ", _sharedState.contextSourcesMap.size);
262
+ }
263
+ // Clear the cache for the changed files
264
+ context.changedContent = [];
265
+ // Cleanup any leftover @layer atrules
266
+ root.walkAtRules("layer", (rule)=>{
267
+ if (Object.keys(layerNodes).includes(rule.params)) {
268
+ rule.remove();
269
+ }
270
+ });
271
+ };
272
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "findAtConfigPath", {
6
+ enumerable: true,
7
+ get: ()=>findAtConfigPath
8
+ });
9
+ const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
10
+ const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
11
+ function _interopRequireDefault(obj) {
12
+ return obj && obj.__esModule ? obj : {
13
+ default: obj
14
+ };
15
+ }
16
+ function findAtConfigPath(root, result) {
17
+ let configPath = null;
18
+ let relativeTo = null;
19
+ root.walkAtRules("config", (rule)=>{
20
+ var _rule_source;
21
+ var _rule_source_input_file, _ref;
22
+ relativeTo = (_ref = (_rule_source_input_file = (_rule_source = rule.source) === null || _rule_source === void 0 ? void 0 : _rule_source.input.file) !== null && _rule_source_input_file !== void 0 ? _rule_source_input_file : result.opts.from) !== null && _ref !== void 0 ? _ref : null;
23
+ if (relativeTo === null) {
24
+ throw rule.error("The `@config` directive cannot be used without setting `from` in your PostCSS config.");
25
+ }
26
+ if (configPath) {
27
+ throw rule.error("Only one `@config` directive is allowed per file.");
28
+ }
29
+ let matches = rule.params.match(/(['"])(.*?)\1/);
30
+ if (!matches) {
31
+ throw rule.error("A path is required when using the `@config` directive.");
32
+ }
33
+ let inputPath = matches[2];
34
+ if (_path.default.isAbsolute(inputPath)) {
35
+ throw rule.error("The `@config` directive cannot be used with an absolute path.");
36
+ }
37
+ configPath = _path.default.resolve(_path.default.dirname(relativeTo), inputPath);
38
+ if (!_fs.default.existsSync(configPath)) {
39
+ throw rule.error(`The config file at "${inputPath}" does not exist. Make sure the path is correct and the file exists.`);
40
+ }
41
+ rule.remove();
42
+ });
43
+ return configPath ? configPath : null;
44
+ }