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,190 +1,163 @@
1
+ // @ts-check
1
2
  "use strict";
2
-
3
3
  Object.defineProperty(exports, "__esModule", {
4
- value: true
4
+ value: true
5
5
  });
6
- exports.default = setupTrackingContext;
7
-
8
- var _fs = _interopRequireDefault(require("fs"));
9
-
10
- var _path = _interopRequireDefault(require("path"));
11
-
12
- var _fastGlob = _interopRequireDefault(require("fast-glob"));
13
-
14
- var _quickLru = _interopRequireDefault(require("quick-lru"));
15
-
16
- var _normalizePath = _interopRequireDefault(require("normalize-path"));
17
-
18
- var _hashConfig = _interopRequireDefault(require("../util/hashConfig"));
19
-
20
- var _getModuleDependencies = _interopRequireDefault(require("../lib/getModuleDependencies"));
21
-
22
- var _resolveConfig = _interopRequireDefault(require("../../resolveConfig"));
23
-
24
- var _resolveConfigPath = _interopRequireDefault(require("../util/resolveConfigPath"));
25
-
26
- var _sharedState = require("./sharedState");
27
-
28
- var _setupContextUtils = require("./setupContextUtils");
29
-
30
- var _parseDependency = _interopRequireDefault(require("../util/parseDependency"));
31
-
32
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
-
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: ()=>setupTrackingContext
13
+ });
14
+ const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
15
+ const _quickLru = /*#__PURE__*/ _interopRequireDefault(require("quick-lru"));
16
+ const _hashConfig = /*#__PURE__*/ _interopRequireDefault(require("../util/hashConfig"));
17
+ const _resolveConfig = /*#__PURE__*/ _interopRequireDefault(require("../public/resolve-config"));
18
+ const _resolveConfigPath = /*#__PURE__*/ _interopRequireDefault(require("../util/resolveConfigPath"));
19
+ const _setupContextUtils = require("./setupContextUtils");
20
+ const _parseDependency = /*#__PURE__*/ _interopRequireDefault(require("../util/parseDependency"));
21
+ const _validateConfigJs = require("../util/validateConfig.js");
22
+ const _contentJs = require("./content.js");
23
+ const _loadConfig = require("../lib/load-config");
24
+ const _getModuleDependencies = /*#__PURE__*/ _interopRequireDefault(require("./getModuleDependencies"));
25
+ function _interopRequireDefault(obj) {
26
+ return obj && obj.__esModule ? obj : {
27
+ default: obj
28
+ };
29
+ }
34
30
  let configPathCache = new _quickLru.default({
35
- maxSize: 100
31
+ maxSize: 100
36
32
  });
37
33
  let candidateFilesCache = new WeakMap();
38
-
39
34
  function getCandidateFiles(context, tailwindConfig) {
40
- if (candidateFilesCache.has(context)) {
41
- return candidateFilesCache.get(context);
42
- }
43
-
44
- let candidateFiles = tailwindConfig.content.content.filter(item => typeof item === 'string').map(contentPath => (0, _normalizePath.default)(_path.default.resolve(contentPath)));
45
- return candidateFilesCache.set(context, candidateFiles).get(context);
46
- } // Get the config object based on a path
47
-
48
-
49
- function getTailwindConfig(configOrPath) {
50
- let userConfigPath = (0, _resolveConfigPath.default)(configOrPath);
51
-
52
- if (userConfigPath !== null) {
53
- let [prevConfig, prevConfigHash, prevDeps, prevModified] = configPathCache.get(userConfigPath) || [];
54
- let newDeps = (0, _getModuleDependencies.default)(userConfigPath).map(dep => dep.file);
55
- let modified = false;
56
- let newModified = new Map();
57
-
58
- for (let file of newDeps) {
59
- let time = _fs.default.statSync(file).mtimeMs;
60
-
61
- newModified.set(file, time);
62
-
63
- if (!prevModified || !prevModified.has(file) || time > prevModified.get(file)) {
64
- modified = true;
65
- }
66
- } // It hasn't changed (based on timestamps)
67
-
68
-
69
- if (!modified) {
70
- return [prevConfig, userConfigPath, prevConfigHash, prevDeps];
71
- } // It has changed (based on timestamps), or first run
72
-
73
-
74
- for (let file of newDeps) {
75
- delete require.cache[file];
35
+ if (candidateFilesCache.has(context)) {
36
+ return candidateFilesCache.get(context);
76
37
  }
77
-
78
- let newConfig = (0, _resolveConfig.default)(require(userConfigPath));
79
- let newHash = (0, _hashConfig.default)(newConfig);
80
- configPathCache.set(userConfigPath, [newConfig, newHash, newDeps, newModified]);
81
- return [newConfig, userConfigPath, newHash, newDeps];
82
- } // It's a plain object, not a path
83
-
84
-
85
- let newConfig = (0, _resolveConfig.default)(configOrPath.config === undefined ? configOrPath : configOrPath.config);
86
- return [newConfig, null, (0, _hashConfig.default)(newConfig), []];
38
+ let candidateFiles = (0, _contentJs.parseCandidateFiles)(context, tailwindConfig);
39
+ return candidateFilesCache.set(context, candidateFiles).get(context);
87
40
  }
88
-
89
- function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
90
- let changedContent = context.tailwindConfig.content.content.filter(item => typeof item.raw === 'string').concat(context.tailwindConfig.content.safelist).concat(context.safelist()).map(({
91
- raw,
92
- extension
93
- }) => ({
94
- content: raw,
95
- extension
96
- }));
97
-
98
- for (let changedFile of resolveChangedFiles(candidateFiles, fileModifiedMap)) {
99
- let content = _fs.default.readFileSync(changedFile, 'utf8');
100
-
101
- let extension = _path.default.extname(changedFile).slice(1);
102
-
103
- changedContent.push({
104
- content,
105
- extension
106
- });
107
- }
108
-
109
- return changedContent;
110
- }
111
-
112
- function resolveChangedFiles(candidateFiles, fileModifiedMap) {
113
- let changedFiles = new Set();
114
- _sharedState.env.DEBUG && console.time('Finding changed files');
115
-
116
- let files = _fastGlob.default.sync(candidateFiles);
117
-
118
- for (let file of files) {
119
- let prevModified = fileModifiedMap.has(file) ? fileModifiedMap.get(file) : -Infinity;
120
-
121
- let modified = _fs.default.statSync(file).mtimeMs;
122
-
123
- if (modified > prevModified) {
124
- changedFiles.add(file);
125
- fileModifiedMap.set(file, modified);
126
- }
127
- }
128
-
129
- _sharedState.env.DEBUG && console.timeEnd('Finding changed files');
130
- return changedFiles;
131
- } // DISABLE_TOUCH = TRUE
132
- // Retrieve an existing context from cache if possible (since contexts are unique per
133
- // source path), or set up a new one (including setting up watchers and registering
134
- // plugins) then return it
135
-
136
-
137
- function setupTrackingContext(configOrPath) {
138
- return ({
139
- tailwindDirectives,
140
- registerDependency
141
- }) => {
142
- return (root, result) => {
143
- let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] = getTailwindConfig(configOrPath);
144
- let contextDependencies = new Set(configDependencies); // If there are no @tailwind rules, we don't consider this CSS file or it's dependencies
145
- // to be dependencies of the context. Can reuse the context even if they change.
146
- // We may want to think about `@layer` being part of this trigger too, but it's tough
147
- // because it's impossible for a layer in one file to end up in the actual @tailwind rule
148
- // in another file since independent sources are effectively isolated.
149
-
150
- if (tailwindDirectives.size > 0) {
151
- // Add current css file as a context dependencies.
152
- contextDependencies.add(result.opts.from); // Add all css @import dependencies as context dependencies.
153
-
154
- for (let message of result.messages) {
155
- if (message.type === 'dependency') {
156
- contextDependencies.add(message.file);
157
- }
41
+ // Get the config object based on a path
42
+ function getTailwindConfig(configOrPath) {
43
+ let userConfigPath = (0, _resolveConfigPath.default)(configOrPath);
44
+ if (userConfigPath !== null) {
45
+ let [prevConfig, prevConfigHash, prevDeps, prevModified] = configPathCache.get(userConfigPath) || [];
46
+ let newDeps = (0, _getModuleDependencies.default)(userConfigPath);
47
+ let modified = false;
48
+ let newModified = new Map();
49
+ for (let file of newDeps){
50
+ let time = _fs.default.statSync(file).mtimeMs;
51
+ newModified.set(file, time);
52
+ if (!prevModified || !prevModified.has(file) || time > prevModified.get(file)) {
53
+ modified = true;
54
+ }
158
55
  }
159
- }
160
-
161
- let [context] = (0, _setupContextUtils.getContext)(tailwindDirectives, root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
162
- let candidateFiles = getCandidateFiles(context, tailwindConfig); // If there are no @tailwind rules, we don't consider this CSS file or it's dependencies
163
- // to be dependencies of the context. Can reuse the context even if they change.
164
- // We may want to think about `@layer` being part of this trigger too, but it's tough
165
- // because it's impossible for a layer in one file to end up in the actual @tailwind rule
166
- // in another file since independent sources are effectively isolated.
167
-
168
- if (tailwindDirectives.size > 0) {
169
- let fileModifiedMap = (0, _setupContextUtils.getFileModifiedMap)(context); // Add template paths as postcss dependencies.
170
-
171
- for (let fileOrGlob of candidateFiles) {
172
- registerDependency((0, _parseDependency.default)(fileOrGlob));
56
+ // It hasn't changed (based on timestamps)
57
+ if (!modified) {
58
+ return [
59
+ prevConfig,
60
+ userConfigPath,
61
+ prevConfigHash,
62
+ prevDeps
63
+ ];
173
64
  }
174
-
175
- for (let changedContent of resolvedChangedContent(context, candidateFiles, fileModifiedMap)) {
176
- context.changedContent.push(changedContent);
65
+ // It has changed (based on timestamps), or first run
66
+ for (let file1 of newDeps){
67
+ delete require.cache[file1];
177
68
  }
178
- }
179
-
180
- for (let file of configDependencies) {
181
- registerDependency({
182
- type: 'dependency',
183
- file
184
- });
185
- }
186
-
187
- return context;
69
+ let newConfig = (0, _validateConfigJs.validateConfig)((0, _resolveConfig.default)((0, _loadConfig.loadConfig)(userConfigPath)));
70
+ let newHash = (0, _hashConfig.default)(newConfig);
71
+ configPathCache.set(userConfigPath, [
72
+ newConfig,
73
+ newHash,
74
+ newDeps,
75
+ newModified
76
+ ]);
77
+ return [
78
+ newConfig,
79
+ userConfigPath,
80
+ newHash,
81
+ newDeps
82
+ ];
83
+ }
84
+ // It's a plain object, not a path
85
+ let newConfig1 = (0, _resolveConfig.default)(configOrPath.config === undefined ? configOrPath : configOrPath.config);
86
+ newConfig1 = (0, _validateConfigJs.validateConfig)(newConfig1);
87
+ return [
88
+ newConfig1,
89
+ null,
90
+ (0, _hashConfig.default)(newConfig1),
91
+ []
92
+ ];
93
+ }
94
+ function setupTrackingContext(configOrPath) {
95
+ return ({ tailwindDirectives , registerDependency })=>{
96
+ return (root, result)=>{
97
+ let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] = getTailwindConfig(configOrPath);
98
+ let contextDependencies = new Set(configDependencies);
99
+ // If there are no @tailwind or @apply rules, we don't consider this CSS
100
+ // file or its dependencies to be dependencies of the context. Can reuse
101
+ // the context even if they change. We may want to think about `@layer`
102
+ // being part of this trigger too, but it's tough because it's impossible
103
+ // for a layer in one file to end up in the actual @tailwind rule in
104
+ // another file since independent sources are effectively isolated.
105
+ if (tailwindDirectives.size > 0) {
106
+ // Add current css file as a context dependencies.
107
+ contextDependencies.add(result.opts.from);
108
+ // Add all css @import dependencies as context dependencies.
109
+ for (let message of result.messages){
110
+ if (message.type === "dependency") {
111
+ contextDependencies.add(message.file);
112
+ }
113
+ }
114
+ }
115
+ let [context, , mTimesToCommit] = (0, _setupContextUtils.getContext)(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
116
+ let fileModifiedMap = (0, _setupContextUtils.getFileModifiedMap)(context);
117
+ let candidateFiles = getCandidateFiles(context, tailwindConfig);
118
+ // If there are no @tailwind or @apply rules, we don't consider this CSS file or it's
119
+ // dependencies to be dependencies of the context. Can reuse the context even if they change.
120
+ // We may want to think about `@layer` being part of this trigger too, but it's tough
121
+ // because it's impossible for a layer in one file to end up in the actual @tailwind rule
122
+ // in another file since independent sources are effectively isolated.
123
+ if (tailwindDirectives.size > 0) {
124
+ // Add template paths as postcss dependencies.
125
+ for (let contentPath of candidateFiles){
126
+ for (let dependency of (0, _parseDependency.default)(contentPath)){
127
+ registerDependency(dependency);
128
+ }
129
+ }
130
+ let [changedContent, contentMTimesToCommit] = (0, _contentJs.resolvedChangedContent)(context, candidateFiles, fileModifiedMap);
131
+ for (let content of changedContent){
132
+ context.changedContent.push(content);
133
+ }
134
+ // Add the mtimes of the content files to the commit list
135
+ // We can overwrite the existing values because unconditionally
136
+ // This is because:
137
+ // 1. Most of the files here won't be in the map yet
138
+ // 2. If they are that means it's a context dependency
139
+ // and we're reading this after the context. This means
140
+ // that the mtime we just read is strictly >= the context
141
+ // mtime. Unless the user / os is doing something weird
142
+ // in which the mtime would be going backwards. If that
143
+ // happens there's already going to be problems.
144
+ for (let [path, mtime] of contentMTimesToCommit.entries()){
145
+ mTimesToCommit.set(path, mtime);
146
+ }
147
+ }
148
+ for (let file of configDependencies){
149
+ registerDependency({
150
+ type: "dependency",
151
+ file
152
+ });
153
+ }
154
+ // "commit" the new modified time for all context deps
155
+ // We do this here because we want content tracking to
156
+ // read the "old" mtime even when it's a context dependency.
157
+ for (let [path1, mtime1] of mTimesToCommit.entries()){
158
+ fileModifiedMap.set(path1, mtime1);
159
+ }
160
+ return context;
161
+ };
188
162
  };
189
- };
190
- }
163
+ }
@@ -1,29 +1,78 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.contentMatchCache = exports.contextSourcesMap = exports.configContextMap = exports.contextMap = exports.env = void 0;
7
-
8
- var _quickLru = _interopRequireDefault(require("quick-lru"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
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: ()=>env,
13
+ contextMap: ()=>contextMap,
14
+ configContextMap: ()=>configContextMap,
15
+ contextSourcesMap: ()=>contextSourcesMap,
16
+ sourceHashMap: ()=>sourceHashMap,
17
+ NOT_ON_DEMAND: ()=>NOT_ON_DEMAND,
18
+ NONE: ()=>NONE,
19
+ resolveDebug: ()=>resolveDebug
20
+ });
21
+ const _packageJson = /*#__PURE__*/ _interopRequireDefault(require("../../package.json"));
22
+ function _interopRequireDefault(obj) {
23
+ return obj && obj.__esModule ? obj : {
24
+ default: obj
25
+ };
26
+ }
27
+ let OXIDE_DEFAULT_ENABLED = _packageJson.default.tailwindcss.engine === "oxide";
12
28
  const env = {
13
- TAILWIND_MODE: process.env.TAILWIND_MODE,
14
- NODE_ENV: process.env.NODE_ENV,
15
- DEBUG: process.env.DEBUG !== undefined,
16
- TAILWIND_DISABLE_TOUCH: process.env.TAILWIND_DISABLE_TOUCH !== undefined,
17
- TAILWIND_TOUCH_DIR: process.env.TAILWIND_TOUCH_DIR
29
+ NODE_ENV: process.env.NODE_ENV,
30
+ DEBUG: resolveDebug(process.env.DEBUG),
31
+ ENGINE: _packageJson.default.tailwindcss.engine,
32
+ OXIDE: resolveBoolean(process.env.OXIDE, OXIDE_DEFAULT_ENABLED)
18
33
  };
19
- exports.env = env;
20
34
  const contextMap = new Map();
21
- exports.contextMap = contextMap;
22
35
  const configContextMap = new Map();
23
- exports.configContextMap = configContextMap;
24
36
  const contextSourcesMap = new Map();
25
- exports.contextSourcesMap = contextSourcesMap;
26
- const contentMatchCache = new _quickLru.default({
27
- maxSize: 25000
28
- });
29
- exports.contentMatchCache = contentMatchCache;
37
+ const sourceHashMap = new Map();
38
+ const NOT_ON_DEMAND = new String("*");
39
+ const NONE = Symbol("__NONE__");
40
+ function resolveBoolean(value, defaultValue) {
41
+ if (value === undefined) {
42
+ return defaultValue;
43
+ }
44
+ if (value === "0" || value === "false") {
45
+ return false;
46
+ }
47
+ return true;
48
+ }
49
+ function resolveDebug(debug) {
50
+ if (debug === undefined) {
51
+ return false;
52
+ }
53
+ // Environment variables are strings, so convert to boolean
54
+ if (debug === "true" || debug === "1") {
55
+ return true;
56
+ }
57
+ if (debug === "false" || debug === "0") {
58
+ return false;
59
+ }
60
+ // Keep the debug convention into account:
61
+ // DEBUG=* -> This enables all debug modes
62
+ // DEBUG=projectA,projectB,projectC -> This enables debug for projectA, projectB and projectC
63
+ // DEBUG=projectA:* -> This enables all debug modes for projectA (if you have sub-types)
64
+ // DEBUG=projectA,-projectB -> This enables debug for projectA and explicitly disables it for projectB
65
+ if (debug === "*") {
66
+ return true;
67
+ }
68
+ let debuggers = debug.split(",").map((d)=>d.split(":")[0]);
69
+ // Ignoring tailwindcss
70
+ if (debuggers.includes("-tailwindcss")) {
71
+ return false;
72
+ }
73
+ // Including tailwindcss
74
+ if (debuggers.includes("tailwindcss")) {
75
+ return true;
76
+ }
77
+ return false;
78
+ }
@@ -1,31 +1,29 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.default = _default;
7
-
8
- var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- function _default({
13
- tailwindConfig: {
14
- theme
15
- }
16
- }) {
17
- return function (css) {
18
- css.walkAtRules('screen', atRule => {
19
- var _theme$screens, _theme$screens$hasOwn;
20
-
21
- const screen = atRule.params;
22
-
23
- if (!((_theme$screens = theme.screens) !== null && _theme$screens !== void 0 && (_theme$screens$hasOwn = _theme$screens.hasOwnProperty) !== null && _theme$screens$hasOwn !== void 0 && _theme$screens$hasOwn.call(_theme$screens, screen))) {
24
- throw atRule.error(`No \`${screen}\` screen found.`);
25
- }
26
-
27
- atRule.name = 'media';
28
- atRule.params = (0, _buildMediaQuery.default)(theme.screens[screen]);
29
- });
30
- };
31
- }
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>_default
8
+ });
9
+ const _normalizeScreens = require("../util/normalizeScreens");
10
+ const _buildMediaQuery = /*#__PURE__*/ _interopRequireDefault(require("../util/buildMediaQuery"));
11
+ function _interopRequireDefault(obj) {
12
+ return obj && obj.__esModule ? obj : {
13
+ default: obj
14
+ };
15
+ }
16
+ function _default({ tailwindConfig: { theme } }) {
17
+ return function(css) {
18
+ css.walkAtRules("screen", (atRule)=>{
19
+ let screen = atRule.params;
20
+ let screens = (0, _normalizeScreens.normalizeScreens)(theme.screens);
21
+ let screenDefinition = screens.find(({ name })=>name === screen);
22
+ if (!screenDefinition) {
23
+ throw atRule.error(`No \`${screen}\` screen found.`);
24
+ }
25
+ atRule.name = "media";
26
+ atRule.params = (0, _buildMediaQuery.default)(screenDefinition);
27
+ });
28
+ };
29
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
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
+ lazyLightningCss: ()=>lazyLightningCss,
13
+ lightningcss: ()=>lightningcss,
14
+ loadPostcss: ()=>loadPostcss,
15
+ loadPostcssImport: ()=>loadPostcssImport
16
+ });
17
+ const _packageJson = /*#__PURE__*/ _interopRequireDefault(require("../../../../package.json"));
18
+ const _browserslist = /*#__PURE__*/ _interopRequireDefault(require("browserslist"));
19
+ const _index = require("../../../../peers/index");
20
+ function _interopRequireDefault(obj) {
21
+ return obj && obj.__esModule ? obj : {
22
+ default: obj
23
+ };
24
+ }
25
+ function lazyLightningCss() {
26
+ // TODO: Make this lazy/bundled
27
+ return require("lightningcss");
28
+ }
29
+ let lightningCss;
30
+ function loadLightningCss() {
31
+ if (lightningCss) {
32
+ return lightningCss;
33
+ }
34
+ // Try to load a local version first
35
+ try {
36
+ return lightningCss = require("lightningcss");
37
+ } catch {}
38
+ return lightningCss = lazyLightningCss();
39
+ }
40
+ async function lightningcss(shouldMinify, result) {
41
+ let css = loadLightningCss();
42
+ try {
43
+ let transformed = css.transform({
44
+ filename: result.opts.from || "input.css",
45
+ code: Buffer.from(result.css, "utf-8"),
46
+ minify: shouldMinify,
47
+ sourceMap: !!result.map,
48
+ inputSourceMap: result.map ? result.map.toString() : undefined,
49
+ targets: css.browserslistToTargets((0, _browserslist.default)(_packageJson.default.browserslist)),
50
+ drafts: {
51
+ nesting: true
52
+ }
53
+ });
54
+ return Object.assign(result, {
55
+ css: transformed.code.toString("utf8"),
56
+ map: result.map ? Object.assign(result.map, {
57
+ toString () {
58
+ return transformed.map.toString();
59
+ }
60
+ }) : result.map
61
+ });
62
+ } catch (err) {
63
+ console.error("Unable to use Lightning CSS. Using raw version instead.");
64
+ console.error(err);
65
+ return result;
66
+ }
67
+ }
68
+ function loadPostcss() {
69
+ // Try to load a local `postcss` version first
70
+ try {
71
+ return require("postcss");
72
+ } catch {}
73
+ return (0, _index.lazyPostcss)();
74
+ }
75
+ function loadPostcssImport() {
76
+ // Try to load a local `postcss-import` version first
77
+ try {
78
+ return require("postcss-import");
79
+ } catch {}
80
+ return (0, _index.lazyPostcssImport)();
81
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "build", {
6
+ enumerable: true,
7
+ get: ()=>build
8
+ });
9
+ const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
10
+ const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
11
+ const _resolveConfigPath = require("../../../util/resolveConfigPath");
12
+ const _plugin = require("./plugin");
13
+ function _interopRequireDefault(obj) {
14
+ return obj && obj.__esModule ? obj : {
15
+ default: obj
16
+ };
17
+ }
18
+ async function build(args) {
19
+ let input = args["--input"];
20
+ let shouldWatch = args["--watch"];
21
+ // TODO: Deprecate this in future versions
22
+ if (!input && args["_"][1]) {
23
+ console.error("[deprecation] Running tailwindcss without -i, please provide an input file.");
24
+ input = args["--input"] = args["_"][1];
25
+ }
26
+ if (input && input !== "-" && !_fs.default.existsSync(input = _path.default.resolve(input))) {
27
+ console.error(`Specified input file ${args["--input"]} does not exist.`);
28
+ process.exit(9);
29
+ }
30
+ if (args["--config"] && !_fs.default.existsSync(args["--config"] = _path.default.resolve(args["--config"]))) {
31
+ console.error(`Specified config file ${args["--config"]} does not exist.`);
32
+ process.exit(9);
33
+ }
34
+ // TODO: Reference the @config path here if exists
35
+ let configPath = args["--config"] ? args["--config"] : (0, _resolveConfigPath.resolveDefaultConfigPath)();
36
+ let processor = await (0, _plugin.createProcessor)(args, configPath);
37
+ if (shouldWatch) {
38
+ // Abort the watcher if stdin is closed to avoid zombie processes
39
+ // You can disable this behavior with --watch=always
40
+ if (args["--watch"] !== "always") {
41
+ process.stdin.on("end", ()=>process.exit(0));
42
+ }
43
+ process.stdin.resume();
44
+ await processor.watch();
45
+ } else {
46
+ await processor.build().catch((e)=>{
47
+ console.error(e);
48
+ process.exit(1);
49
+ });
50
+ }
51
+ }