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
@@ -1,26 +1,35 @@
1
+ // @ts-check
1
2
  "use strict";
2
3
  Object.defineProperty(exports, "__esModule", {
3
4
  value: true
4
5
  });
5
- exports.default = setupTrackingContext;
6
- var _fs = _interopRequireDefault(require("fs"));
7
- var _path = _interopRequireDefault(require("path"));
8
- var _fastGlob = _interopRequireDefault(require("fast-glob"));
9
- var _quickLru = _interopRequireDefault(require("quick-lru"));
10
- var _normalizePath = _interopRequireDefault(require("normalize-path"));
11
- var _hashConfig = _interopRequireDefault(require("../util/hashConfig"));
12
- var _getModuleDependencies = _interopRequireDefault(require("../lib/getModuleDependencies"));
13
- var _resolveConfig = _interopRequireDefault(require("../public/resolve-config"));
14
- var _resolveConfigPath = _interopRequireDefault(require("../util/resolveConfigPath"));
15
- var _sharedState = require("./sharedState");
16
- var _setupContextUtils = require("./setupContextUtils");
17
- var _parseDependency = _interopRequireDefault(require("../util/parseDependency"));
18
- function _interopRequireDefault(obj) {
6
+ Object.defineProperty(exports, // DISABLE_TOUCH = TRUE
7
+ // Retrieve an existing context from cache if possible (since contexts are unique per
8
+ // source path), or set up a new one (including setting up watchers and registering
9
+ // plugins) then return it
10
+ "default", {
11
+ enumerable: true,
12
+ get: function() {
13
+ return setupTrackingContext;
14
+ }
15
+ });
16
+ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
17
+ const _quicklru = /*#__PURE__*/ _interop_require_default(require("@alloc/quick-lru"));
18
+ const _hashConfig = /*#__PURE__*/ _interop_require_default(require("../util/hashConfig"));
19
+ const _resolveconfig = /*#__PURE__*/ _interop_require_default(require("../public/resolve-config"));
20
+ const _resolveConfigPath = /*#__PURE__*/ _interop_require_default(require("../util/resolveConfigPath"));
21
+ const _setupContextUtils = require("./setupContextUtils");
22
+ const _parseDependency = /*#__PURE__*/ _interop_require_default(require("../util/parseDependency"));
23
+ const _validateConfig = require("../util/validateConfig.js");
24
+ const _content = require("./content.js");
25
+ const _loadconfig = require("../lib/load-config");
26
+ const _getModuleDependencies = /*#__PURE__*/ _interop_require_default(require("./getModuleDependencies"));
27
+ function _interop_require_default(obj) {
19
28
  return obj && obj.__esModule ? obj : {
20
29
  default: obj
21
30
  };
22
31
  }
23
- let configPathCache = new _quickLru.default({
32
+ let configPathCache = new _quicklru.default({
24
33
  maxSize: 100
25
34
  });
26
35
  let candidateFilesCache = new WeakMap();
@@ -28,18 +37,15 @@ function getCandidateFiles(context, tailwindConfig) {
28
37
  if (candidateFilesCache.has(context)) {
29
38
  return candidateFilesCache.get(context);
30
39
  }
31
- let candidateFiles = tailwindConfig.content.files.filter((item)=>typeof item === 'string'
32
- ).map((contentPath)=>(0, _normalizePath).default(contentPath)
33
- );
40
+ let candidateFiles = (0, _content.parseCandidateFiles)(context, tailwindConfig);
34
41
  return candidateFilesCache.set(context, candidateFiles).get(context);
35
42
  }
36
43
  // Get the config object based on a path
37
44
  function getTailwindConfig(configOrPath) {
38
- let userConfigPath = (0, _resolveConfigPath).default(configOrPath);
45
+ let userConfigPath = (0, _resolveConfigPath.default)(configOrPath);
39
46
  if (userConfigPath !== null) {
40
47
  let [prevConfig, prevConfigHash, prevDeps, prevModified] = configPathCache.get(userConfigPath) || [];
41
- let newDeps = (0, _getModuleDependencies).default(userConfigPath).map((dep)=>dep.file
42
- );
48
+ let newDeps = (0, _getModuleDependencies.default)(userConfigPath);
43
49
  let modified = false;
44
50
  let newModified = new Map();
45
51
  for (let file of newDeps){
@@ -59,11 +65,11 @@ function getTailwindConfig(configOrPath) {
59
65
  ];
60
66
  }
61
67
  // It has changed (based on timestamps), or first run
62
- for (let file1 of newDeps){
63
- delete require.cache[file1];
68
+ for (let file of newDeps){
69
+ delete require.cache[file];
64
70
  }
65
- let newConfig = (0, _resolveConfig).default(require(userConfigPath));
66
- let newHash = (0, _hashConfig).default(newConfig);
71
+ let newConfig = (0, _validateConfig.validateConfig)((0, _resolveconfig.default)((0, _loadconfig.loadConfig)(userConfigPath)));
72
+ let newHash = (0, _hashConfig.default)(newConfig);
67
73
  configPathCache.set(userConfigPath, [
68
74
  newConfig,
69
75
  newHash,
@@ -77,49 +83,19 @@ function getTailwindConfig(configOrPath) {
77
83
  newDeps
78
84
  ];
79
85
  }
86
+ var _configOrPath_config, _ref;
80
87
  // It's a plain object, not a path
81
- let newConfig = (0, _resolveConfig).default(configOrPath.config === undefined ? configOrPath : configOrPath.config);
88
+ let newConfig = (0, _resolveconfig.default)((_ref = (_configOrPath_config = configOrPath === null || configOrPath === void 0 ? void 0 : configOrPath.config) !== null && _configOrPath_config !== void 0 ? _configOrPath_config : configOrPath) !== null && _ref !== void 0 ? _ref : {});
89
+ newConfig = (0, _validateConfig.validateConfig)(newConfig);
82
90
  return [
83
91
  newConfig,
84
92
  null,
85
- (0, _hashConfig).default(newConfig),
93
+ (0, _hashConfig.default)(newConfig),
86
94
  []
87
95
  ];
88
96
  }
89
- function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
90
- let changedContent = context.tailwindConfig.content.files.filter((item)=>typeof item.raw === 'string'
91
- ).map(({ raw , extension ='html' })=>({
92
- content: raw,
93
- extension
94
- })
95
- );
96
- for (let changedFile of resolveChangedFiles(candidateFiles, fileModifiedMap)){
97
- let content = _fs.default.readFileSync(changedFile, 'utf8');
98
- let extension = _path.default.extname(changedFile).slice(1);
99
- changedContent.push({
100
- content,
101
- extension
102
- });
103
- }
104
- return changedContent;
105
- }
106
- function resolveChangedFiles(candidateFiles, fileModifiedMap) {
107
- let changedFiles = new Set();
108
- _sharedState.env.DEBUG && console.time('Finding changed files');
109
- let files = _fastGlob.default.sync(candidateFiles);
110
- for (let file of files){
111
- let prevModified = fileModifiedMap.has(file) ? fileModifiedMap.get(file) : -Infinity;
112
- let modified = _fs.default.statSync(file).mtimeMs;
113
- if (modified > prevModified) {
114
- changedFiles.add(file);
115
- fileModifiedMap.set(file, modified);
116
- }
117
- }
118
- _sharedState.env.DEBUG && console.timeEnd('Finding changed files');
119
- return changedFiles;
120
- }
121
97
  function setupTrackingContext(configOrPath) {
122
- return ({ tailwindDirectives , registerDependency , applyDirectives })=>{
98
+ return ({ tailwindDirectives , registerDependency })=>{
123
99
  return (root, result)=>{
124
100
  let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] = getTailwindConfig(configOrPath);
125
101
  let contextDependencies = new Set(configDependencies);
@@ -129,42 +105,61 @@ function setupTrackingContext(configOrPath) {
129
105
  // being part of this trigger too, but it's tough because it's impossible
130
106
  // for a layer in one file to end up in the actual @tailwind rule in
131
107
  // another file since independent sources are effectively isolated.
132
- if (tailwindDirectives.size > 0 || applyDirectives.size > 0) {
108
+ if (tailwindDirectives.size > 0) {
133
109
  // Add current css file as a context dependencies.
134
110
  contextDependencies.add(result.opts.from);
135
111
  // Add all css @import dependencies as context dependencies.
136
112
  for (let message of result.messages){
137
- if (message.type === 'dependency') {
113
+ if (message.type === "dependency") {
138
114
  contextDependencies.add(message.file);
139
115
  }
140
116
  }
141
117
  }
142
- let [context] = (0, _setupContextUtils).getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
118
+ let [context, , mTimesToCommit] = (0, _setupContextUtils.getContext)(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
119
+ let fileModifiedMap = (0, _setupContextUtils.getFileModifiedMap)(context);
143
120
  let candidateFiles = getCandidateFiles(context, tailwindConfig);
144
121
  // If there are no @tailwind or @apply rules, we don't consider this CSS file or it's
145
122
  // dependencies to be dependencies of the context. Can reuse the context even if they change.
146
123
  // We may want to think about `@layer` being part of this trigger too, but it's tough
147
124
  // because it's impossible for a layer in one file to end up in the actual @tailwind rule
148
125
  // in another file since independent sources are effectively isolated.
149
- if (tailwindDirectives.size > 0 || applyDirectives.size > 0) {
150
- let fileModifiedMap = (0, _setupContextUtils).getFileModifiedMap(context);
126
+ if (tailwindDirectives.size > 0) {
151
127
  // Add template paths as postcss dependencies.
152
- for (let fileOrGlob of candidateFiles){
153
- let dependency = (0, _parseDependency).default(fileOrGlob);
154
- if (dependency) {
128
+ for (let contentPath of candidateFiles){
129
+ for (let dependency of (0, _parseDependency.default)(contentPath)){
155
130
  registerDependency(dependency);
156
131
  }
157
132
  }
158
- for (let changedContent of resolvedChangedContent(context, candidateFiles, fileModifiedMap)){
159
- context.changedContent.push(changedContent);
133
+ let [changedContent, contentMTimesToCommit] = (0, _content.resolvedChangedContent)(context, candidateFiles, fileModifiedMap);
134
+ for (let content of changedContent){
135
+ context.changedContent.push(content);
136
+ }
137
+ // Add the mtimes of the content files to the commit list
138
+ // We can overwrite the existing values because unconditionally
139
+ // This is because:
140
+ // 1. Most of the files here won't be in the map yet
141
+ // 2. If they are that means it's a context dependency
142
+ // and we're reading this after the context. This means
143
+ // that the mtime we just read is strictly >= the context
144
+ // mtime. Unless the user / os is doing something weird
145
+ // in which the mtime would be going backwards. If that
146
+ // happens there's already going to be problems.
147
+ for (let [path, mtime] of contentMTimesToCommit.entries()){
148
+ mTimesToCommit.set(path, mtime);
160
149
  }
161
150
  }
162
151
  for (let file of configDependencies){
163
152
  registerDependency({
164
- type: 'dependency',
153
+ type: "dependency",
165
154
  file
166
155
  });
167
156
  }
157
+ // "commit" the new modified time for all context deps
158
+ // We do this here because we want content tracking to
159
+ // read the "old" mtime even when it's a context dependency.
160
+ for (let [path, mtime] of mTimesToCommit.entries()){
161
+ fileModifiedMap.set(path, mtime);
162
+ }
168
163
  return context;
169
164
  };
170
165
  };
@@ -2,28 +2,60 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.resolveDebug = resolveDebug;
6
- exports.contextSourcesMap = exports.configContextMap = exports.contextMap = exports.env = void 0;
7
- const env = {
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
+ env: function() {
13
+ return env;
14
+ },
15
+ contextMap: function() {
16
+ return contextMap;
17
+ },
18
+ configContextMap: function() {
19
+ return configContextMap;
20
+ },
21
+ contextSourcesMap: function() {
22
+ return contextSourcesMap;
23
+ },
24
+ sourceHashMap: function() {
25
+ return sourceHashMap;
26
+ },
27
+ NOT_ON_DEMAND: function() {
28
+ return NOT_ON_DEMAND;
29
+ },
30
+ NONE: function() {
31
+ return NONE;
32
+ },
33
+ resolveDebug: function() {
34
+ return resolveDebug;
35
+ }
36
+ });
37
+ const env = typeof process !== "undefined" ? {
8
38
  NODE_ENV: process.env.NODE_ENV,
9
39
  DEBUG: resolveDebug(process.env.DEBUG)
40
+ } : {
41
+ NODE_ENV: "production",
42
+ DEBUG: false
10
43
  };
11
- exports.env = env;
12
44
  const contextMap = new Map();
13
- exports.contextMap = contextMap;
14
45
  const configContextMap = new Map();
15
- exports.configContextMap = configContextMap;
16
46
  const contextSourcesMap = new Map();
17
- exports.contextSourcesMap = contextSourcesMap;
47
+ const sourceHashMap = new Map();
48
+ const NOT_ON_DEMAND = new String("*");
49
+ const NONE = Symbol("__NONE__");
18
50
  function resolveDebug(debug) {
19
51
  if (debug === undefined) {
20
52
  return false;
21
53
  }
22
54
  // Environment variables are strings, so convert to boolean
23
- if (debug === 'true' || debug === '1') {
55
+ if (debug === "true" || debug === "1") {
24
56
  return true;
25
57
  }
26
- if (debug === 'false' || debug === '0') {
58
+ if (debug === "false" || debug === "0") {
27
59
  return false;
28
60
  }
29
61
  // Keep the debug convention into account:
@@ -31,17 +63,16 @@ function resolveDebug(debug) {
31
63
  // DEBUG=projectA,projectB,projectC -> This enables debug for projectA, projectB and projectC
32
64
  // DEBUG=projectA:* -> This enables all debug modes for projectA (if you have sub-types)
33
65
  // DEBUG=projectA,-projectB -> This enables debug for projectA and explicitly disables it for projectB
34
- if (debug === '*') {
66
+ if (debug === "*") {
35
67
  return true;
36
68
  }
37
- let debuggers = debug.split(',').map((d)=>d.split(':')[0]
38
- );
69
+ let debuggers = debug.split(",").map((d)=>d.split(":")[0]);
39
70
  // Ignoring tailwindcss
40
- if (debuggers.includes('-tailwindcss')) {
71
+ if (debuggers.includes("-tailwindcss")) {
41
72
  return false;
42
73
  }
43
74
  // Including tailwindcss
44
- if (debuggers.includes('tailwindcss')) {
75
+ if (debuggers.includes("tailwindcss")) {
45
76
  return true;
46
77
  }
47
78
  return false;
@@ -2,26 +2,30 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = _default;
6
- var _normalizeScreens = require("../util/normalizeScreens");
7
- var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
8
- function _interopRequireDefault(obj) {
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ const _normalizeScreens = require("../util/normalizeScreens");
12
+ const _buildMediaQuery = /*#__PURE__*/ _interop_require_default(require("../util/buildMediaQuery"));
13
+ function _interop_require_default(obj) {
9
14
  return obj && obj.__esModule ? obj : {
10
15
  default: obj
11
16
  };
12
17
  }
13
18
  function _default({ tailwindConfig: { theme } }) {
14
19
  return function(css) {
15
- css.walkAtRules('screen', (atRule)=>{
20
+ css.walkAtRules("screen", (atRule)=>{
16
21
  let screen = atRule.params;
17
- let screens = (0, _normalizeScreens).normalizeScreens(theme.screens);
18
- let screenDefinition = screens.find(({ name })=>name === screen
19
- );
22
+ let screens = (0, _normalizeScreens.normalizeScreens)(theme.screens);
23
+ let screenDefinition = screens.find(({ name })=>name === screen);
20
24
  if (!screenDefinition) {
21
25
  throw atRule.error(`No \`${screen}\` screen found.`);
22
26
  }
23
- atRule.name = 'media';
24
- atRule.params = (0, _buildMediaQuery).default(screenDefinition);
27
+ atRule.name = "media";
28
+ atRule.params = (0, _buildMediaQuery.default)(screenDefinition);
25
29
  });
26
30
  };
27
31
  }
package/lib/plugin.js ADDED
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _setupTrackingContext = /*#__PURE__*/ _interop_require_default(require("./lib/setupTrackingContext"));
6
+ const _processTailwindFeatures = /*#__PURE__*/ _interop_require_default(require("./processTailwindFeatures"));
7
+ const _sharedState = require("./lib/sharedState");
8
+ const _findAtConfigPath = require("./lib/findAtConfigPath");
9
+ function _interop_require_default(obj) {
10
+ return obj && obj.__esModule ? obj : {
11
+ default: obj
12
+ };
13
+ }
14
+ module.exports = function tailwindcss(configOrPath) {
15
+ return {
16
+ postcssPlugin: "tailwindcss",
17
+ plugins: [
18
+ _sharedState.env.DEBUG && function(root) {
19
+ console.log("\n");
20
+ console.time("JIT TOTAL");
21
+ return root;
22
+ },
23
+ async function(root, result) {
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);
29
+ if (root.type === "document") {
30
+ let roots = root.nodes.filter((node)=>node.type === "root");
31
+ for (const root of roots){
32
+ if (root.type === "root") {
33
+ await (0, _processTailwindFeatures.default)(context)(root, result);
34
+ }
35
+ }
36
+ return;
37
+ }
38
+ await (0, _processTailwindFeatures.default)(context)(root, result);
39
+ },
40
+ _sharedState.env.DEBUG && function(root) {
41
+ console.timeEnd("JIT TOTAL");
42
+ console.log("\n");
43
+ return root;
44
+ }
45
+ ].filter(Boolean)
46
+ };
47
+ };
48
+ module.exports.postcss = true;
@@ -1,6 +1,6 @@
1
1
  # tailwindcss/nesting
2
2
 
3
- This is a PostCSS plugin that wraps [postcss-nested](https://github.com/postcss/postcss-nested) or [postcss-nesting](https://github.com/jonathantneal/postcss-nesting) and acts as a compatibility layer to make sure your nesting plugin of choice properly understands Tailwind's custom syntax like `@apply` and `@screen`.
3
+ This is a PostCSS plugin that wraps [postcss-nested](https://github.com/postcss/postcss-nested) or [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting) and acts as a compatibility layer to make sure your nesting plugin of choice properly understands Tailwind's custom syntax like `@apply` and `@screen`.
4
4
 
5
5
  Add it to your PostCSS configuration, somewhere before Tailwind itself:
6
6
 
@@ -18,7 +18,7 @@ module.exports = {
18
18
 
19
19
  By default, it uses the [postcss-nested](https://github.com/postcss/postcss-nested) plugin under the hood, which uses a Sass-like syntax and is the plugin that powers nesting support in the [Tailwind CSS plugin API](https://tailwindcss.com/docs/plugins#css-in-js-syntax).
20
20
 
21
- If you'd rather use [postcss-nesting](https://github.com/jonathantneal/postcss-nesting) (which is based on the work-in-progress [CSS Nesting](https://drafts.csswg.org/css-nesting-1/) specification), first install the plugin alongside:
21
+ If you'd rather use [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting) (which is based on the work-in-progress [CSS Nesting](https://drafts.csswg.org/css-nesting-1/) specification), first install the plugin alongside:
22
22
 
23
23
  ```shell
24
24
  npm install postcss-nesting
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ const _plugin = require("./plugin");
12
+ const _default = Object.assign(function(opts) {
13
+ return {
14
+ postcssPlugin: "tailwindcss/nesting",
15
+ Once (root, { result }) {
16
+ return (0, _plugin.nesting)(opts)(root, result);
17
+ }
18
+ };
19
+ }, {
20
+ postcss: true
21
+ });
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "nesting", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return nesting;
9
+ }
10
+ });
11
+ const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
12
+ const _postcssnested = /*#__PURE__*/ _interop_require_default(require("postcss-nested"));
13
+ function _interop_require_default(obj) {
14
+ return obj && obj.__esModule ? obj : {
15
+ default: obj
16
+ };
17
+ }
18
+ function nesting(opts = _postcssnested.default) {
19
+ return (root, result)=>{
20
+ root.walkAtRules("screen", (rule)=>{
21
+ rule.name = "media";
22
+ rule.params = `screen(${rule.params})`;
23
+ });
24
+ root.walkAtRules("apply", (rule)=>{
25
+ rule.before(_postcss.default.decl({
26
+ prop: "__apply",
27
+ value: rule.params,
28
+ source: rule.source
29
+ }));
30
+ rule.remove();
31
+ });
32
+ let plugin = (()=>{
33
+ var _opts_hasOwnProperty;
34
+ if (typeof opts === "function" || typeof opts === "object" && (opts === null || opts === void 0 ? void 0 : (_opts_hasOwnProperty = opts.hasOwnProperty) === null || _opts_hasOwnProperty === void 0 ? void 0 : _opts_hasOwnProperty.call(opts, "postcssPlugin"))) {
35
+ return opts;
36
+ }
37
+ if (typeof opts === "string") {
38
+ return require(opts);
39
+ }
40
+ if (Object.keys(opts).length <= 0) {
41
+ return _postcssnested.default;
42
+ }
43
+ throw new Error("tailwindcss/nesting should be loaded with a nesting plugin.");
44
+ })();
45
+ (0, _postcss.default)([
46
+ plugin
47
+ ]).process(root, result.opts).sync();
48
+ root.walkDecls("__apply", (decl)=>{
49
+ decl.before(_postcss.default.atRule({
50
+ name: "apply",
51
+ params: decl.value,
52
+ source: decl.source
53
+ }));
54
+ decl.remove();
55
+ });
56
+ /**
57
+ * Use a private PostCSS API to remove the "clean" flag from the entire AST.
58
+ * This is done because running process() on the AST will set the "clean"
59
+ * flag on all nodes, which we don't want.
60
+ *
61
+ * This causes downstream plugins using the visitor API to be skipped.
62
+ *
63
+ * This is guarded because the PostCSS API is not public
64
+ * and may change in future versions of PostCSS.
65
+ *
66
+ * See https://github.com/postcss/postcss/issues/1712 for more details
67
+ *
68
+ * @param {import('postcss').Node} node
69
+ */ function markDirty(node) {
70
+ if (!("markDirty" in node)) {
71
+ return;
72
+ }
73
+ // Traverse the tree down to the leaf nodes
74
+ if (node.nodes) {
75
+ node.nodes.forEach((n)=>markDirty(n));
76
+ }
77
+ // If it's a leaf node mark it as dirty
78
+ // We do this here because marking a node as dirty
79
+ // will walk up the tree and mark all parents as dirty
80
+ // resulting in a lot of unnecessary work if we did this
81
+ // for every single node
82
+ if (!node.nodes) {
83
+ node.markDirty();
84
+ }
85
+ }
86
+ markDirty(root);
87
+ return root;
88
+ };
89
+ }
@@ -2,51 +2,61 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = processTailwindFeatures;
6
- var _normalizeTailwindDirectives = _interopRequireDefault(require("./lib/normalizeTailwindDirectives"));
7
- var _expandTailwindAtRules = _interopRequireDefault(require("./lib/expandTailwindAtRules"));
8
- var _expandApplyAtRules = _interopRequireDefault(require("./lib/expandApplyAtRules"));
9
- var _evaluateTailwindFunctions = _interopRequireDefault(require("./lib/evaluateTailwindFunctions"));
10
- var _substituteScreenAtRules = _interopRequireDefault(require("./lib/substituteScreenAtRules"));
11
- var _resolveDefaultsAtRules = _interopRequireDefault(require("./lib/resolveDefaultsAtRules"));
12
- var _collapseAdjacentRules = _interopRequireDefault(require("./lib/collapseAdjacentRules"));
13
- var _collapseDuplicateDeclarations = _interopRequireDefault(require("./lib/collapseDuplicateDeclarations"));
14
- var _detectNesting = _interopRequireDefault(require("./lib/detectNesting"));
15
- var _setupContextUtils = require("./lib/setupContextUtils");
16
- var _featureFlags = require("./featureFlags");
17
- function _interopRequireDefault(obj) {
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return processTailwindFeatures;
9
+ }
10
+ });
11
+ const _normalizeTailwindDirectives = /*#__PURE__*/ _interop_require_default(require("./lib/normalizeTailwindDirectives"));
12
+ const _expandTailwindAtRules = /*#__PURE__*/ _interop_require_default(require("./lib/expandTailwindAtRules"));
13
+ const _expandApplyAtRules = /*#__PURE__*/ _interop_require_default(require("./lib/expandApplyAtRules"));
14
+ const _evaluateTailwindFunctions = /*#__PURE__*/ _interop_require_default(require("./lib/evaluateTailwindFunctions"));
15
+ const _substituteScreenAtRules = /*#__PURE__*/ _interop_require_default(require("./lib/substituteScreenAtRules"));
16
+ const _resolveDefaultsAtRules = /*#__PURE__*/ _interop_require_default(require("./lib/resolveDefaultsAtRules"));
17
+ const _collapseAdjacentRules = /*#__PURE__*/ _interop_require_default(require("./lib/collapseAdjacentRules"));
18
+ const _collapseDuplicateDeclarations = /*#__PURE__*/ _interop_require_default(require("./lib/collapseDuplicateDeclarations"));
19
+ const _partitionApplyAtRules = /*#__PURE__*/ _interop_require_default(require("./lib/partitionApplyAtRules"));
20
+ const _setupContextUtils = require("./lib/setupContextUtils");
21
+ const _featureFlags = require("./featureFlags");
22
+ function _interop_require_default(obj) {
18
23
  return obj && obj.__esModule ? obj : {
19
24
  default: obj
20
25
  };
21
26
  }
22
27
  function processTailwindFeatures(setupContext) {
23
- return function(root, result) {
24
- let { tailwindDirectives , applyDirectives } = (0, _normalizeTailwindDirectives).default(root);
28
+ return async function(root, result) {
29
+ let { tailwindDirectives , applyDirectives } = (0, _normalizeTailwindDirectives.default)(root);
30
+ // Partition apply rules that are found in the css
31
+ // itself.
32
+ (0, _partitionApplyAtRules.default)()(root, result);
25
33
  let context = setupContext({
26
34
  tailwindDirectives,
27
35
  applyDirectives,
28
36
  registerDependency (dependency) {
29
37
  result.messages.push({
30
- plugin: 'tailwindcss',
38
+ plugin: "tailwindcss",
31
39
  parent: result.opts.from,
32
40
  ...dependency
33
41
  });
34
42
  },
35
43
  createContext (tailwindConfig, changedContent) {
36
- return (0, _setupContextUtils).createContext(tailwindConfig, changedContent, root);
44
+ return (0, _setupContextUtils.createContext)(tailwindConfig, changedContent, root);
37
45
  }
38
46
  })(root, result);
39
- if (context.tailwindConfig.separator === '-') {
47
+ if (context.tailwindConfig.separator === "-") {
40
48
  throw new Error("The '-' character cannot be used as a custom separator in JIT mode due to parsing ambiguity. Please use another character like '_' instead.");
41
49
  }
42
- (0, _featureFlags).issueFlagNotices(context.tailwindConfig);
43
- (0, _detectNesting).default(context)(root, result);
44
- (0, _expandTailwindAtRules).default(context)(root, result);
45
- (0, _expandApplyAtRules).default(context)(root, result);
46
- (0, _evaluateTailwindFunctions).default(context)(root, result);
47
- (0, _substituteScreenAtRules).default(context)(root, result);
48
- (0, _resolveDefaultsAtRules).default(context)(root, result);
49
- (0, _collapseAdjacentRules).default(context)(root, result);
50
- (0, _collapseDuplicateDeclarations).default(context)(root, result);
50
+ (0, _featureFlags.issueFlagNotices)(context.tailwindConfig);
51
+ await (0, _expandTailwindAtRules.default)(context)(root, result);
52
+ // Partition apply rules that are generated by
53
+ // addComponents, addUtilities and so on.
54
+ (0, _partitionApplyAtRules.default)()(root, result);
55
+ (0, _expandApplyAtRules.default)(context)(root, result);
56
+ (0, _evaluateTailwindFunctions.default)(context)(root, result);
57
+ (0, _substituteScreenAtRules.default)(context)(root, result);
58
+ (0, _resolveDefaultsAtRules.default)(context)(root, result);
59
+ (0, _collapseAdjacentRules.default)(context)(root, result);
60
+ (0, _collapseDuplicateDeclarations.default)(context)(root, result);
51
61
  };
52
62
  }