tailwindcss 0.0.0-insiders.b26ffa0 → 0.0.0-insiders.b2e3cf2

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 (219) hide show
  1. package/README.md +13 -9
  2. package/colors.d.ts +3 -0
  3. package/defaultConfig.d.ts +3 -0
  4. package/defaultTheme.d.ts +4 -0
  5. package/lib/cli/build/deps.js +46 -0
  6. package/lib/cli/build/index.js +21 -0
  7. package/lib/cli/build/plugin.js +195 -0
  8. package/lib/cli/build/utils.js +56 -0
  9. package/lib/cli/build/watching.js +65 -0
  10. package/lib/cli/help/index.js +28 -0
  11. package/lib/cli/index.js +171 -0
  12. package/lib/cli/init/index.js +39 -0
  13. package/lib/cli-peer-dependencies.js +21 -10
  14. package/lib/cli.js +1 -739
  15. package/lib/corePluginList.js +10 -4
  16. package/lib/corePlugins.js +2177 -2024
  17. package/lib/css/preflight.css +6 -4
  18. package/lib/featureFlags.js +37 -38
  19. package/lib/index.js +1 -29
  20. package/lib/lib/cacheInvalidation.js +44 -0
  21. package/lib/lib/collapseAdjacentRules.js +26 -29
  22. package/lib/lib/collapseDuplicateDeclarations.js +26 -67
  23. package/lib/lib/content.js +88 -0
  24. package/lib/lib/defaultExtractor.js +133 -39
  25. package/lib/lib/detectNesting.js +13 -28
  26. package/lib/lib/evaluateTailwindFunctions.js +115 -137
  27. package/lib/lib/expandApplyAtRules.js +184 -237
  28. package/lib/lib/expandTailwindAtRules.js +105 -223
  29. package/lib/lib/findAtConfigPath.js +27 -0
  30. package/lib/lib/generateRules.js +392 -531
  31. package/lib/lib/getModuleDependencies.js +51 -38
  32. package/lib/lib/load-config.js +32 -0
  33. package/lib/lib/normalizeTailwindDirectives.js +30 -71
  34. package/lib/lib/offsets.js +141 -0
  35. package/lib/lib/partitionApplyAtRules.js +29 -48
  36. package/lib/lib/regex.js +52 -0
  37. package/lib/lib/remap-bitfield.js +12 -0
  38. package/lib/lib/resolveDefaultsAtRules.js +66 -110
  39. package/lib/lib/setupContextUtils.js +654 -820
  40. package/lib/lib/setupTrackingContext.js +57 -154
  41. package/lib/lib/sharedState.js +33 -42
  42. package/lib/lib/substituteScreenAtRules.js +10 -16
  43. package/lib/oxide/cli/build/deps.js +66 -0
  44. package/lib/oxide/cli/build/index.js +21 -0
  45. package/lib/oxide/cli/build/plugin.js +193 -0
  46. package/lib/oxide/cli/build/utils.js +56 -0
  47. package/lib/oxide/cli/build/watching.js +63 -0
  48. package/lib/oxide/cli/help/index.js +28 -0
  49. package/lib/oxide/cli/index.js +153 -0
  50. package/lib/oxide/cli/init/index.js +31 -0
  51. package/lib/oxide/cli.js +4 -0
  52. package/lib/oxide/postcss-plugin.js +2 -0
  53. package/lib/plugin.js +34 -0
  54. package/lib/postcss-plugins/nesting/README.md +2 -2
  55. package/lib/postcss-plugins/nesting/index.js +8 -10
  56. package/lib/postcss-plugins/nesting/plugin.js +22 -31
  57. package/lib/processTailwindFeatures.js +11 -37
  58. package/lib/public/colors.js +280 -263
  59. package/lib/public/create-plugin.js +6 -7
  60. package/lib/public/default-config.js +6 -8
  61. package/lib/public/default-theme.js +6 -8
  62. package/lib/public/load-config.js +8 -0
  63. package/lib/public/resolve-config.js +7 -6
  64. package/lib/util/applyImportantSelector.js +25 -0
  65. package/lib/util/bigSign.js +6 -4
  66. package/lib/util/buildMediaQuery.js +13 -15
  67. package/lib/util/cloneDeep.js +9 -16
  68. package/lib/util/cloneNodes.js +15 -10
  69. package/lib/util/color.js +60 -83
  70. package/lib/util/configurePlugins.js +9 -13
  71. package/lib/util/createPlugin.js +9 -15
  72. package/lib/util/createUtilityPlugin.js +17 -27
  73. package/lib/util/dataTypes.js +92 -180
  74. package/lib/util/defaults.js +9 -16
  75. package/lib/util/escapeClassName.js +7 -8
  76. package/lib/util/escapeCommas.js +7 -5
  77. package/lib/util/flattenColorPalette.js +8 -11
  78. package/lib/util/formatVariantSelector.js +101 -173
  79. package/lib/util/getAllConfigs.js +35 -23
  80. package/lib/util/hashConfig.js +8 -7
  81. package/lib/util/isKeyframeRule.js +7 -5
  82. package/lib/util/isPlainObject.js +9 -9
  83. package/lib/util/isSyntacticallyValidPropertyValue.js +43 -0
  84. package/lib/util/log.js +18 -19
  85. package/lib/util/nameClass.js +13 -17
  86. package/lib/util/negateValue.js +15 -16
  87. package/lib/util/normalizeConfig.js +81 -218
  88. package/lib/util/normalizeScreens.js +86 -42
  89. package/lib/util/parseAnimationValue.js +34 -80
  90. package/lib/util/parseBoxShadowValue.js +23 -61
  91. package/lib/util/parseDependency.js +18 -60
  92. package/lib/util/parseGlob.js +19 -0
  93. package/lib/util/parseObjectStyles.js +17 -23
  94. package/lib/util/pluginUtils.js +105 -127
  95. package/lib/util/prefixSelector.js +13 -13
  96. package/lib/util/pseudoElements.js +147 -0
  97. package/lib/util/removeAlphaVariables.js +16 -0
  98. package/lib/util/resolveConfig.js +110 -206
  99. package/lib/util/resolveConfigPath.js +25 -36
  100. package/lib/util/responsive.js +7 -6
  101. package/lib/util/splitAtTopLevelOnly.js +15 -0
  102. package/lib/util/tap.js +7 -6
  103. package/lib/util/toColorValue.js +7 -5
  104. package/lib/util/toPath.js +7 -9
  105. package/lib/util/transformThemeValue.js +28 -49
  106. package/lib/util/validateConfig.js +27 -0
  107. package/lib/util/validateFormalSyntax.js +18 -0
  108. package/lib/util/withAlphaVariable.js +38 -50
  109. package/loadConfig.d.ts +4 -0
  110. package/loadConfig.js +2 -0
  111. package/package.json +59 -40
  112. package/peers/index.js +11196 -7650
  113. package/plugin.d.ts +11 -0
  114. package/resolveConfig.d.ts +12 -0
  115. package/scripts/generate-types.js +105 -0
  116. package/scripts/release-channel.js +18 -0
  117. package/scripts/release-notes.js +21 -0
  118. package/scripts/swap-engines.js +40 -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 +444 -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 +4 -812
  130. package/src/corePluginList.js +1 -1
  131. package/src/corePlugins.js +609 -86
  132. package/src/css/preflight.css +6 -4
  133. package/src/featureFlags.js +20 -4
  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 +208 -0
  138. package/src/lib/defaultExtractor.js +202 -33
  139. package/src/lib/detectNesting.js +9 -1
  140. package/src/lib/evaluateTailwindFunctions.js +78 -7
  141. package/src/lib/expandApplyAtRules.js +489 -183
  142. package/src/lib/expandTailwindAtRules.js +70 -59
  143. package/src/lib/findAtConfigPath.js +48 -0
  144. package/src/lib/generateRules.js +438 -126
  145. package/src/lib/getModuleDependencies.js +70 -30
  146. package/src/lib/load-config.ts +31 -0
  147. package/src/lib/offsets.js +373 -0
  148. package/src/lib/regex.js +74 -0
  149. package/src/lib/remap-bitfield.js +82 -0
  150. package/src/lib/resolveDefaultsAtRules.js +53 -32
  151. package/src/lib/setupContextUtils.js +615 -196
  152. package/src/lib/setupTrackingContext.js +45 -57
  153. package/src/lib/sharedState.js +19 -4
  154. package/src/oxide/cli/build/deps.ts +91 -0
  155. package/src/oxide/cli/build/index.ts +47 -0
  156. package/src/oxide/cli/build/plugin.ts +442 -0
  157. package/src/oxide/cli/build/utils.ts +74 -0
  158. package/src/oxide/cli/build/watching.ts +225 -0
  159. package/src/oxide/cli/help/index.ts +69 -0
  160. package/src/oxide/cli/index.ts +204 -0
  161. package/src/oxide/cli/init/index.ts +59 -0
  162. package/src/oxide/cli.ts +1 -0
  163. package/src/oxide/postcss-plugin.ts +1 -0
  164. package/src/plugin.js +107 -0
  165. package/src/postcss-plugins/nesting/README.md +2 -2
  166. package/src/postcss-plugins/nesting/plugin.js +36 -0
  167. package/src/public/colors.js +22 -0
  168. package/src/public/default-config.js +1 -1
  169. package/src/public/default-theme.js +2 -2
  170. package/src/public/load-config.js +2 -0
  171. package/src/util/applyImportantSelector.js +27 -0
  172. package/src/util/buildMediaQuery.js +5 -3
  173. package/src/util/cloneNodes.js +19 -2
  174. package/src/util/color.js +38 -19
  175. package/src/util/dataTypes.js +54 -21
  176. package/src/util/formatVariantSelector.js +264 -144
  177. package/src/util/getAllConfigs.js +21 -2
  178. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  179. package/src/util/log.js +8 -8
  180. package/src/util/nameClass.js +4 -0
  181. package/src/util/negateValue.js +11 -3
  182. package/src/util/normalizeConfig.js +41 -10
  183. package/src/util/normalizeScreens.js +99 -4
  184. package/src/util/parseBoxShadowValue.js +3 -2
  185. package/src/util/parseDependency.js +37 -42
  186. package/src/util/parseGlob.js +24 -0
  187. package/src/util/pluginUtils.js +127 -24
  188. package/src/util/prefixSelector.js +28 -10
  189. package/src/util/pseudoElements.js +170 -0
  190. package/src/util/removeAlphaVariables.js +24 -0
  191. package/src/util/resolveConfig.js +70 -32
  192. package/src/util/resolveConfigPath.js +12 -1
  193. package/src/util/splitAtTopLevelOnly.js +52 -0
  194. package/src/util/toPath.js +1 -1
  195. package/src/util/transformThemeValue.js +13 -3
  196. package/src/util/validateConfig.js +26 -0
  197. package/src/util/validateFormalSyntax.js +34 -0
  198. package/src/util/withAlphaVariable.js +1 -1
  199. package/stubs/.gitignore +1 -0
  200. package/stubs/.prettierrc.json +6 -0
  201. package/stubs/{defaultConfig.stub.js → config.full.js} +204 -164
  202. package/stubs/postcss.config.js +6 -0
  203. package/stubs/tailwind.config.cjs +2 -0
  204. package/stubs/tailwind.config.js +2 -0
  205. package/stubs/tailwind.config.ts +3 -0
  206. package/types/config.d.ts +368 -0
  207. package/types/generated/.gitkeep +0 -0
  208. package/types/generated/colors.d.ts +298 -0
  209. package/types/generated/corePluginList.d.ts +1 -0
  210. package/types/generated/default-theme.d.ts +371 -0
  211. package/types/index.d.ts +7 -0
  212. package/CHANGELOG.md +0 -2056
  213. package/lib/constants.js +0 -37
  214. package/lib/util/isValidArbitraryValue.js +0 -64
  215. package/scripts/install-integrations.js +0 -27
  216. package/scripts/rebuildFixtures.js +0 -68
  217. package/src/constants.js +0 -17
  218. /package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -0
  219. /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
package/README.md CHANGED
@@ -1,16 +1,20 @@
1
- <p>
2
- <a href="https://tailwindcss.com/#gh-light-mode-only" target="_blank">
3
- <img src="./.github/logo-light.svg" alt="Tailwind CSS" width="350" height="70">
4
- </a>
5
- <a href="https://tailwindcss.com/#gh-dark-mode-only" target="_blank">
6
- <img src="./.github/logo-dark.svg" alt="Tailwind CSS" width="350" height="70">
1
+ <p align="center">
2
+ <a href="https://tailwindcss.com" target="_blank">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-dark.svg">
5
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-light.svg">
6
+ <img alt="Tailwind CSS" src="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-light.svg" width="350" height="70" style="max-width: 100%;">
7
+ </picture>
7
8
  </a>
8
9
  </p>
9
10
 
10
- A utility-first CSS framework for rapidly building custom user interfaces.
11
+ <p align="center">
12
+ A utility-first CSS framework for rapidly building custom user interfaces.
13
+ </p>
14
+
11
15
 
12
- <p>
13
- <a href="https://github.com/tailwindlabs/tailwindcss/actions"><img src="https://img.shields.io/github/workflow/status/tailwindlabs/tailwindcss/Node.js%20CI" alt="Build Status"></a>
16
+ <p align="center">
17
+ <a href="https://github.com/tailwindlabs/tailwindcss/actions"><img src="https://img.shields.io/github/actions/workflow/status/tailwindlabs/tailwindcss/ci-stable.yml?branch=master" alt="Build Status"></a>
14
18
  <a href="https://www.npmjs.com/package/tailwindcss"><img src="https://img.shields.io/npm/dt/tailwindcss.svg" alt="Total Downloads"></a>
15
19
  <a href="https://github.com/tailwindcss/tailwindcss/releases"><img src="https://img.shields.io/npm/v/tailwindcss.svg" alt="Latest Release"></a>
16
20
  <a href="https://github.com/tailwindcss/tailwindcss/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/tailwindcss.svg" alt="License"></a>
package/colors.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { DefaultColors } from './types/generated/colors'
2
+ declare const colors: DefaultColors
3
+ export = colors
@@ -0,0 +1,3 @@
1
+ import type { Config } from './types/config'
2
+ declare const config: Config
3
+ export = config
@@ -0,0 +1,4 @@
1
+ import type { Config } from './types/config'
2
+ import { DefaultTheme } from './types/generated/default-theme'
3
+ declare const theme: Config['theme'] & DefaultTheme
4
+ export = theme
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: !0
4
+ }), function(target, all) {
5
+ for(var name in all)Object.defineProperty(target, name, {
6
+ enumerable: !0,
7
+ get: all[name]
8
+ });
9
+ }(exports, {
10
+ loadPostcss: ()=>loadPostcss,
11
+ loadPostcssImport: ()=>loadPostcssImport,
12
+ loadCssNano: ()=>loadCssNano,
13
+ loadAutoprefixer: ()=>loadAutoprefixer
14
+ });
15
+ const _indexJs = require("../../../peers/index.js");
16
+ function loadPostcss() {
17
+ try {
18
+ return require("postcss");
19
+ } catch {}
20
+ return (0, _indexJs.lazyPostcss)();
21
+ }
22
+ function loadPostcssImport() {
23
+ try {
24
+ return require("postcss-import");
25
+ } catch {}
26
+ return (0, _indexJs.lazyPostcssImport)();
27
+ }
28
+ function loadCssNano() {
29
+ try {
30
+ return require("cssnano");
31
+ } catch {}
32
+ return (0, _indexJs.lazyCssnano)()({
33
+ preset: [
34
+ "default",
35
+ {
36
+ cssDeclarationSorter: !1
37
+ }
38
+ ]
39
+ });
40
+ }
41
+ function loadAutoprefixer() {
42
+ try {
43
+ return require("autoprefixer");
44
+ } catch {}
45
+ return (0, _indexJs.lazyAutoprefixer)();
46
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: !0
4
+ }), Object.defineProperty(exports, "build", {
5
+ enumerable: !0,
6
+ get: ()=>build
7
+ });
8
+ const _fs = _interopRequireDefault(require("fs")), _path = _interopRequireDefault(require("path")), _resolveConfigPathJs = require("../../util/resolveConfigPath.js"), _pluginJs = require("./plugin.js");
9
+ function _interopRequireDefault(obj) {
10
+ return obj && obj.__esModule ? obj : {
11
+ default: obj
12
+ };
13
+ }
14
+ async function build(args) {
15
+ let input = args["--input"], shouldWatch = args["--watch"];
16
+ !input && args._[1] && (console.error("[deprecation] Running tailwindcss without -i, please provide an input file."), input = args["--input"] = args._[1]), input && "-" !== input && !_fs.default.existsSync(input = _path.default.resolve(input)) && (console.error(`Specified input file ${args["--input"]} does not exist.`), process.exit(9)), args["--config"] && !_fs.default.existsSync(args["--config"] = _path.default.resolve(args["--config"])) && (console.error(`Specified config file ${args["--config"]} does not exist.`), process.exit(9));
17
+ let processor = await (0, _pluginJs.createProcessor)(args, args["--config"] ? args["--config"] : (0, _resolveConfigPathJs.resolveDefaultConfigPath)());
18
+ shouldWatch ? ("always" !== args["--watch"] && process.stdin.on("end", ()=>process.exit(0)), process.stdin.resume(), await processor.watch()) : await processor.build().catch((e)=>{
19
+ console.error(e), process.exit(1);
20
+ });
21
+ }
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: !0
4
+ }), Object.defineProperty(exports, "createProcessor", {
5
+ enumerable: !0,
6
+ get: ()=>createProcessor
7
+ });
8
+ const _path = _interopRequireDefault(require("path")), _fs = _interopRequireDefault(require("fs")), _postcssLoadConfig = _interopRequireDefault(require("postcss-load-config")), _lilconfig = require("lilconfig"), _plugins = _interopRequireDefault(require("postcss-load-config/src/plugins")), _options = _interopRequireDefault(require("postcss-load-config/src/options")), _processTailwindFeatures = _interopRequireDefault(require("../../processTailwindFeatures")), _deps = require("./deps"), _utils = require("./utils"), _sharedState = require("../../lib/sharedState"), _resolveConfigJs = _interopRequireDefault(require("../../../resolveConfig.js")), _contentJs = require("../../lib/content.js"), _watchingJs = require("./watching.js"), _fastGlob = _interopRequireDefault(require("fast-glob")), _findAtConfigPathJs = require("../../lib/findAtConfigPath.js"), _log = _interopRequireDefault(require("../../util/log")), _loadConfig = require("../../lib/load-config"), _getModuleDependencies = _interopRequireDefault(require("../../lib/getModuleDependencies"));
9
+ function _interopRequireDefault(obj) {
10
+ return obj && obj.__esModule ? obj : {
11
+ default: obj
12
+ };
13
+ }
14
+ async function loadPostCssPlugins(customPostCssPath) {
15
+ let config = customPostCssPath ? await (async ()=>{
16
+ let file = _path.default.resolve(customPostCssPath), { config ={} } = await (0, _lilconfig.lilconfig)("postcss").load(file);
17
+ return (config = "function" == typeof config ? config() : Object.assign({}, config)).plugins || (config.plugins = []), {
18
+ file,
19
+ plugins: (0, _plugins.default)(config, file),
20
+ options: (0, _options.default)(config, file)
21
+ };
22
+ })() : await (0, _postcssLoadConfig.default)(), configPlugins = config.plugins, configPluginTailwindIdx = configPlugins.findIndex((plugin)=>"function" == typeof plugin && "tailwindcss" === plugin.name || "object" == typeof plugin && null !== plugin && "tailwindcss" === plugin.postcssPlugin);
23
+ return [
24
+ -1 === configPluginTailwindIdx ? [] : configPlugins.slice(0, configPluginTailwindIdx),
25
+ -1 === configPluginTailwindIdx ? configPlugins : configPlugins.slice(configPluginTailwindIdx + 1),
26
+ config.options
27
+ ];
28
+ }
29
+ let state = {
30
+ context: null,
31
+ watcher: null,
32
+ changedContent: [],
33
+ configBag: null,
34
+ contextDependencies: new Set(),
35
+ contentPaths: [],
36
+ refreshContentPaths () {
37
+ var _this_context;
38
+ this.contentPaths = (0, _contentJs.parseCandidateFiles)(this.context, null === (_this_context = this.context) || void 0 === _this_context ? void 0 : _this_context.tailwindConfig);
39
+ },
40
+ get config () {
41
+ return this.context.tailwindConfig;
42
+ },
43
+ get contentPatterns () {
44
+ return {
45
+ all: this.contentPaths.map((contentPath)=>contentPath.pattern),
46
+ dynamic: this.contentPaths.filter((contentPath)=>void 0 !== contentPath.glob).map((contentPath)=>contentPath.pattern)
47
+ };
48
+ },
49
+ loadConfig (configPath, content) {
50
+ this.watcher && configPath && this.refreshConfigDependencies();
51
+ let config = (0, _loadConfig.loadConfig)(configPath), dependencies = (0, _getModuleDependencies.default)(configPath);
52
+ return this.configBag = {
53
+ config,
54
+ dependencies,
55
+ dispose () {
56
+ for (let file of dependencies)delete require.cache[require.resolve(file)];
57
+ }
58
+ }, this.configBag.config = (0, _resolveConfigJs.default)(this.configBag.config, {
59
+ content: {
60
+ files: []
61
+ }
62
+ }), (null == content ? void 0 : content.length) > 0 && (this.configBag.config.content.files = content), this.configBag.config;
63
+ },
64
+ refreshConfigDependencies () {
65
+ var _this_configBag;
66
+ _sharedState.env.DEBUG && console.time("Module dependencies"), null === (_this_configBag = this.configBag) || void 0 === _this_configBag || _this_configBag.dispose(), _sharedState.env.DEBUG && console.timeEnd("Module dependencies");
67
+ },
68
+ readContentPaths () {
69
+ let content = [];
70
+ for (let file of _fastGlob.default.sync(this.contentPatterns.all))content.push({
71
+ content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
72
+ extension: _path.default.extname(file).slice(1)
73
+ });
74
+ for (let { raw: htmlContent , extension ="html" } of this.config.content.files.filter((file)=>null !== file && "object" == typeof file))content.push({
75
+ content: htmlContent,
76
+ extension
77
+ });
78
+ return content;
79
+ },
80
+ getContext ({ createContext , cliConfigPath , root , result , content }) {
81
+ var _findAtConfigPath;
82
+ if (this.context) return this.context.changedContent = this.changedContent.splice(0), this.context;
83
+ _sharedState.env.DEBUG && console.time("Searching for config");
84
+ let configPath = null !== (_findAtConfigPath = (0, _findAtConfigPathJs.findAtConfigPath)(root, result)) && void 0 !== _findAtConfigPath ? _findAtConfigPath : cliConfigPath;
85
+ _sharedState.env.DEBUG && console.timeEnd("Searching for config"), _sharedState.env.DEBUG && console.time("Loading config");
86
+ let config = this.loadConfig(configPath, content);
87
+ for (let file of (_sharedState.env.DEBUG && console.timeEnd("Loading config"), _sharedState.env.DEBUG && console.time("Creating context"), this.context = createContext(config, []), Object.assign(this.context, {
88
+ userConfigPath: configPath
89
+ }), _sharedState.env.DEBUG && console.timeEnd("Creating context"), _sharedState.env.DEBUG && console.time("Resolving content paths"), this.refreshContentPaths(), _sharedState.env.DEBUG && console.timeEnd("Resolving content paths"), this.watcher && (_sharedState.env.DEBUG && console.time("Watch new files"), this.watcher.refreshWatchedFiles(), _sharedState.env.DEBUG && console.timeEnd("Watch new files")), this.readContentPaths()))this.context.changedContent.push(file);
90
+ return this.context;
91
+ }
92
+ };
93
+ async function createProcessor(args, cliConfigPath) {
94
+ var _args_content, _args_content_split;
95
+ let postcss, IMPORT_COMMENT;
96
+ let postcss1 = (0, _deps.loadPostcss)(), input = args["--input"], output = args["--output"], includePostCss = args["--postcss"], customPostCssPath = "string" == typeof args["--postcss"] ? args["--postcss"] : void 0, [beforePlugins, afterPlugins, postcssOptions] = includePostCss ? await loadPostCssPlugins(customPostCssPath) : (postcss = (0, _deps.loadPostcss)(), IMPORT_COMMENT = "__TAILWIND_RESTORE_IMPORT__: ", [
97
+ [
98
+ (root)=>{
99
+ root.walkAtRules("import", (rule)=>{
100
+ rule.params.slice(1).startsWith("tailwindcss/") && (rule.after(postcss.comment({
101
+ text: IMPORT_COMMENT + rule.params
102
+ })), rule.remove());
103
+ });
104
+ },
105
+ (0, _deps.loadPostcssImport)(),
106
+ (root)=>{
107
+ root.walkComments((rule)=>{
108
+ rule.text.startsWith(IMPORT_COMMENT) && (rule.after(postcss.atRule({
109
+ name: "import",
110
+ params: rule.text.replace(IMPORT_COMMENT, "")
111
+ })), rule.remove());
112
+ });
113
+ }
114
+ ],
115
+ [],
116
+ {}
117
+ ]);
118
+ args["--purge"] && (_log.default.warn("purge-flag-deprecated", [
119
+ "The `--purge` flag has been deprecated.",
120
+ "Please use `--content` instead."
121
+ ]), args["--content"] || (args["--content"] = args["--purge"]));
122
+ let content = null !== (_args_content_split = null === (_args_content = args["--content"]) || void 0 === _args_content ? void 0 : _args_content.split(/(?<!{[^}]+),/)) && void 0 !== _args_content_split ? _args_content_split : [], tailwindPlugin = ()=>({
123
+ postcssPlugin: "tailwindcss",
124
+ Once (root, { result }) {
125
+ _sharedState.env.DEBUG && console.time("Compiling CSS"), (0, _processTailwindFeatures.default)(({ createContext })=>(console.error(), console.error("Rebuilding..."), ()=>state.getContext({
126
+ createContext,
127
+ cliConfigPath,
128
+ root,
129
+ result,
130
+ content
131
+ })))(root, result), _sharedState.env.DEBUG && console.timeEnd("Compiling CSS");
132
+ }
133
+ });
134
+ tailwindPlugin.postcss = !0;
135
+ let processor = postcss1([
136
+ ...beforePlugins,
137
+ tailwindPlugin,
138
+ !args["--minify"] && _utils.formatNodes,
139
+ ...afterPlugins,
140
+ !args["--no-autoprefixer"] && (0, _deps.loadAutoprefixer)(),
141
+ args["--minify"] && (0, _deps.loadCssNano)()
142
+ ].filter(Boolean));
143
+ async function readInput() {
144
+ return "-" === input ? (0, _utils.drainStdin)() : input ? _fs.default.promises.readFile(_path.default.resolve(input), "utf8") : "@tailwind base; @tailwind components; @tailwind utilities";
145
+ }
146
+ async function build() {
147
+ let start = process.hrtime.bigint();
148
+ return readInput().then((css)=>processor.process(css, {
149
+ ...postcssOptions,
150
+ from: input,
151
+ to: output
152
+ })).then((result)=>{
153
+ if (!state.watcher) return result;
154
+ for (let message of (_sharedState.env.DEBUG && console.time("Recording PostCSS dependencies"), result.messages))"dependency" === message.type && state.contextDependencies.add(message.file);
155
+ return _sharedState.env.DEBUG && console.timeEnd("Recording PostCSS dependencies"), _sharedState.env.DEBUG && console.time("Watch new files"), state.watcher.refreshWatchedFiles(), _sharedState.env.DEBUG && console.timeEnd("Watch new files"), result;
156
+ }).then((result)=>{
157
+ if (!output) {
158
+ process.stdout.write(result.css);
159
+ return;
160
+ }
161
+ return Promise.all([
162
+ (0, _utils.outputFile)(result.opts.to, result.css),
163
+ result.map && (0, _utils.outputFile)(result.opts.to + ".map", result.map.toString())
164
+ ]);
165
+ }).then(()=>{
166
+ let end = process.hrtime.bigint();
167
+ console.error(), console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
168
+ }).then(()=>{}, (err)=>{
169
+ if (!state.watcher) return Promise.reject(err);
170
+ console.error(err);
171
+ });
172
+ }
173
+ async function parseChanges(changes) {
174
+ return Promise.all(changes.map(async (change)=>({
175
+ content: await change.content(),
176
+ extension: change.extension
177
+ })));
178
+ }
179
+ return void 0 !== input && "-" !== input && state.contextDependencies.add(_path.default.resolve(input)), {
180
+ build,
181
+ watch: async ()=>{
182
+ state.watcher = (0, _watchingJs.createWatcher)(args, {
183
+ state,
184
+ async rebuild (changes) {
185
+ if (changes.some((change)=>{
186
+ var _state_configBag;
187
+ return (null === (_state_configBag = state.configBag) || void 0 === _state_configBag ? void 0 : _state_configBag.dependencies.has(change.file)) || state.contextDependencies.has(change.file);
188
+ })) state.context = null;
189
+ else for (let change of (await parseChanges(changes)))state.changedContent.push(change);
190
+ return build();
191
+ }
192
+ }), await build();
193
+ }
194
+ };
195
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: !0
4
+ }), function(target, all) {
5
+ for(var name in all)Object.defineProperty(target, name, {
6
+ enumerable: !0,
7
+ get: all[name]
8
+ });
9
+ }(exports, {
10
+ indentRecursive: ()=>indentRecursive,
11
+ formatNodes: ()=>formatNodes,
12
+ readFileWithRetries: ()=>readFileWithRetries,
13
+ drainStdin: ()=>drainStdin,
14
+ outputFile: ()=>outputFile
15
+ });
16
+ const _fs = _interopRequireDefault(require("fs")), _path = _interopRequireDefault(require("path"));
17
+ function _interopRequireDefault(obj) {
18
+ return obj && obj.__esModule ? obj : {
19
+ default: obj
20
+ };
21
+ }
22
+ function indentRecursive(node, indent = 0) {
23
+ node.each && node.each((child, i)=>{
24
+ (!child.raws.before || !child.raws.before.trim() || child.raws.before.includes("\n")) && (child.raws.before = `\n${"rule" !== node.type && i > 0 ? "\n" : ""}${" ".repeat(indent)}`), child.raws.after = `\n${" ".repeat(indent)}`, indentRecursive(child, indent + 1);
25
+ });
26
+ }
27
+ function formatNodes(root) {
28
+ indentRecursive(root), root.first && (root.first.raws.before = "");
29
+ }
30
+ async function readFileWithRetries(path, tries = 5) {
31
+ for(let n = 0; n <= tries; n++)try {
32
+ return await _fs.default.promises.readFile(path, "utf8");
33
+ } catch (err) {
34
+ if (n !== tries && ("ENOENT" === err.code || "EBUSY" === err.code)) {
35
+ await new Promise((resolve)=>setTimeout(resolve, 10));
36
+ continue;
37
+ }
38
+ throw err;
39
+ }
40
+ }
41
+ function drainStdin() {
42
+ return new Promise((resolve, reject)=>{
43
+ let result = "";
44
+ process.stdin.on("data", (chunk)=>{
45
+ result += chunk;
46
+ }), process.stdin.on("end", ()=>resolve(result)), process.stdin.on("error", (err)=>reject(err));
47
+ });
48
+ }
49
+ async function outputFile(file, newContents) {
50
+ try {
51
+ if (await _fs.default.promises.readFile(file, "utf8") === newContents) return;
52
+ } catch {}
53
+ await _fs.default.promises.mkdir(_path.default.dirname(file), {
54
+ recursive: !0
55
+ }), await _fs.default.promises.writeFile(file, newContents, "utf8");
56
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: !0
4
+ }), Object.defineProperty(exports, "createWatcher", {
5
+ enumerable: !0,
6
+ get: ()=>createWatcher
7
+ });
8
+ const _chokidar = _interopRequireDefault(require("chokidar")), _fs = _interopRequireDefault(require("fs")), _micromatch = _interopRequireDefault(require("micromatch")), _normalizePath = _interopRequireDefault(require("normalize-path")), _path = _interopRequireDefault(require("path")), _utilsJs = require("./utils.js");
9
+ function _interopRequireDefault(obj) {
10
+ return obj && obj.__esModule ? obj : {
11
+ default: obj
12
+ };
13
+ }
14
+ function createWatcher(args, { state , rebuild }) {
15
+ let _timer, _reject, shouldPoll = args["--poll"], shouldCoalesceWriteEvents = shouldPoll || "win32" === process.platform, watcher = _chokidar.default.watch([], {
16
+ atomic: !0,
17
+ usePolling: shouldPoll,
18
+ interval: shouldPoll ? 10 : void 0,
19
+ ignoreInitial: !0,
20
+ awaitWriteFinish: !!shouldCoalesceWriteEvents && {
21
+ stabilityThreshold: 50,
22
+ pollInterval: 10
23
+ }
24
+ }), chain = Promise.resolve(), changedContent = [], pendingRebuilds = new Set();
25
+ async function rebuildAndContinue() {
26
+ let changes = changedContent.splice(0);
27
+ return 0 === changes.length ? Promise.resolve() : (changes.forEach((change)=>pendingRebuilds.delete(change.file)), rebuild(changes).then(()=>{}, (e)=>{
28
+ console.error(e.toString());
29
+ }));
30
+ }
31
+ function recordChangedFile(file, content = null, skipPendingCheck = !1) {
32
+ return (file = _path.default.resolve(file), pendingRebuilds.has(file) && !skipPendingCheck) ? Promise.resolve() : (pendingRebuilds.add(file), changedContent.push({
33
+ file,
34
+ content: null != content ? content : ()=>_fs.default.promises.readFile(file, "utf8"),
35
+ extension: _path.default.extname(file).slice(1)
36
+ }), _timer && (clearTimeout(_timer), _reject()), chain = (chain = chain.then(()=>new Promise((resolve, reject)=>{
37
+ _timer = setTimeout(resolve, 10), _reject = reject;
38
+ }))).then(rebuildAndContinue, rebuildAndContinue));
39
+ }
40
+ return watcher.on("change", (file)=>recordChangedFile(file)), watcher.on("add", (file)=>recordChangedFile(file)), watcher.on("unlink", (file)=>{
41
+ file = (0, _normalizePath.default)(file), _micromatch.default.some([
42
+ file
43
+ ], state.contentPatterns.dynamic) || watcher.add(file);
44
+ }), watcher.on("raw", (evt, filePath, meta)=>{
45
+ if ("rename" !== evt) return;
46
+ let watchedPath = meta.watchedPath;
47
+ async function enqueue() {
48
+ try {
49
+ let content = await (0, _utilsJs.readFileWithRetries)(_path.default.resolve(filePath));
50
+ if (void 0 === content) return;
51
+ await recordChangedFile(filePath, ()=>content, !0);
52
+ } catch {}
53
+ }
54
+ filePath = watchedPath.endsWith(filePath) ? watchedPath : _path.default.join(watchedPath, filePath), _micromatch.default.some([
55
+ filePath
56
+ ], state.contentPatterns.all) && (pendingRebuilds.has(filePath) || (pendingRebuilds.add(filePath), enqueue().then(()=>{
57
+ pendingRebuilds.delete(filePath);
58
+ })));
59
+ }), {
60
+ fswatcher: watcher,
61
+ refreshWatchedFiles () {
62
+ watcher.add(Array.from(state.contextDependencies)), watcher.add(Array.from(state.configBag.dependencies)), watcher.add(state.contentPatterns.all);
63
+ }
64
+ };
65
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: !0
4
+ }), Object.defineProperty(exports, "help", {
5
+ enumerable: !0,
6
+ get: ()=>help
7
+ });
8
+ const _packageJson = function(obj) {
9
+ return obj && obj.__esModule ? obj : {
10
+ default: obj
11
+ };
12
+ }(require("../../../package.json"));
13
+ function help({ message , usage , commands , options }) {
14
+ if (console.log(), console.log(`${_packageJson.default.name} v${_packageJson.default.version}`), message) for (let msg of (console.log(), message.split("\n")))console.log(msg);
15
+ if (usage && usage.length > 0) for (let example of (console.log(), console.log("Usage:"), usage))console.log(" ".repeat(2), example);
16
+ if (commands && commands.length > 0) for (let command of (console.log(), console.log("Commands:"), commands))console.log(" ".repeat(2), command);
17
+ if (options) {
18
+ let groupedOptions = {};
19
+ for (let [key, value] of Object.entries(options))"object" == typeof value ? groupedOptions[key] = {
20
+ ...value,
21
+ flags: [
22
+ key
23
+ ]
24
+ } : groupedOptions[value].flags.push(key);
25
+ for (let { flags , description , deprecated } of (console.log(), console.log("Options:"), Object.values(groupedOptions)))deprecated || (1 === flags.length ? console.log(" ".repeat(6), flags.slice().reverse().join(", ").padEnd(20, " "), description) : console.log(" ".repeat(2), flags.slice().reverse().join(", ").padEnd(24, " "), description));
26
+ }
27
+ console.log();
28
+ }
@@ -0,0 +1,171 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ });
6
+ const _path = _interopRequireDefault(require("path")), _arg = _interopRequireDefault(require("arg")), _fs = _interopRequireDefault(require("fs")), _build = require("./build"), _help = require("./help"), _init = require("./init");
7
+ function _interopRequireDefault(obj) {
8
+ return obj && obj.__esModule ? obj : {
9
+ default: obj
10
+ };
11
+ }
12
+ function oneOf(...options) {
13
+ return Object.assign((value = !0)=>{
14
+ for (let option of options){
15
+ let parsed = option(value);
16
+ if (parsed === value) return parsed;
17
+ }
18
+ throw Error("...");
19
+ }, {
20
+ manualParsing: !0
21
+ });
22
+ }
23
+ let commands = {
24
+ init: {
25
+ run: _init.init,
26
+ args: {
27
+ "--esm": {
28
+ type: Boolean,
29
+ description: "Initialize configuration file as ESM"
30
+ },
31
+ "--ts": {
32
+ type: Boolean,
33
+ description: "Initialize configuration file as TypeScript"
34
+ },
35
+ "--postcss": {
36
+ type: Boolean,
37
+ description: "Initialize a `postcss.config.js` file"
38
+ },
39
+ "--full": {
40
+ type: Boolean,
41
+ description: "Include the default values for all options in the generated configuration file"
42
+ },
43
+ "-f": "--full",
44
+ "-p": "--postcss"
45
+ }
46
+ },
47
+ build: {
48
+ run: _build.build,
49
+ args: {
50
+ "--input": {
51
+ type: String,
52
+ description: "Input file"
53
+ },
54
+ "--output": {
55
+ type: String,
56
+ description: "Output file"
57
+ },
58
+ "--watch": {
59
+ type: oneOf(String, Boolean),
60
+ description: "Watch for changes and rebuild as needed"
61
+ },
62
+ "--poll": {
63
+ type: Boolean,
64
+ description: "Use polling instead of filesystem events when watching"
65
+ },
66
+ "--content": {
67
+ type: String,
68
+ description: "Content paths to use for removing unused classes"
69
+ },
70
+ "--purge": {
71
+ type: String,
72
+ deprecated: !0
73
+ },
74
+ "--postcss": {
75
+ type: oneOf(String, Boolean),
76
+ description: "Load custom PostCSS configuration"
77
+ },
78
+ "--minify": {
79
+ type: Boolean,
80
+ description: "Minify the output"
81
+ },
82
+ "--config": {
83
+ type: String,
84
+ description: "Path to a custom config file"
85
+ },
86
+ "--no-autoprefixer": {
87
+ type: Boolean,
88
+ description: "Disable autoprefixer"
89
+ },
90
+ "-c": "--config",
91
+ "-i": "--input",
92
+ "-o": "--output",
93
+ "-m": "--minify",
94
+ "-w": "--watch",
95
+ "-p": "--poll"
96
+ }
97
+ }
98
+ }, sharedFlags = {
99
+ "--help": {
100
+ type: Boolean,
101
+ description: "Display usage information"
102
+ },
103
+ "-h": "--help"
104
+ };
105
+ process.stdout.isTTY && (void 0 === process.argv[2] || process.argv.slice(2).every((flag)=>void 0 !== sharedFlags[flag])) && ((0, _help.help)({
106
+ usage: [
107
+ "tailwindcss [--input input.css] [--output output.css] [--watch] [options...]",
108
+ "tailwindcss init [--full] [--postcss] [options...]"
109
+ ],
110
+ commands: Object.keys(commands).filter((command)=>"build" !== command).map((command)=>`${command} [options]`),
111
+ options: {
112
+ ...commands.build.args,
113
+ ...sharedFlags
114
+ }
115
+ }), process.exit(0));
116
+ let command = ((arg = "")=>arg.startsWith("-") ? void 0 : arg)(process.argv[2]) || "build";
117
+ void 0 === commands[command] && (_fs.default.existsSync(_path.default.resolve(command)) ? command = "build" : ((0, _help.help)({
118
+ message: `Invalid command: ${command}`,
119
+ usage: [
120
+ "tailwindcss <command> [options]"
121
+ ],
122
+ commands: Object.keys(commands).filter((command)=>"build" !== command).map((command)=>`${command} [options]`),
123
+ options: sharedFlags
124
+ }), process.exit(1)));
125
+ let { args: flags , run } = commands[command], args = (()=>{
126
+ try {
127
+ let result = (0, _arg.default)(Object.fromEntries(Object.entries({
128
+ ...flags,
129
+ ...sharedFlags
130
+ }).filter(([_key, value])=>{
131
+ var _value_type;
132
+ return !(null == value ? void 0 : null === (_value_type = value.type) || void 0 === _value_type ? void 0 : _value_type.manualParsing);
133
+ }).map(([key, value])=>[
134
+ key,
135
+ "object" == typeof value ? value.type : value
136
+ ])), {
137
+ permissive: !0
138
+ });
139
+ for(let i = result._.length - 1; i >= 0; --i){
140
+ let flag = result._[i];
141
+ if (!flag.startsWith("-")) continue;
142
+ let [flagName, flagValue] = flag.split("="), handler = flags[flagName];
143
+ for(; "string" == typeof handler;)flagName = handler, handler = flags[handler];
144
+ if (!handler) continue;
145
+ let args = [], offset = i + 1;
146
+ if (void 0 === flagValue) {
147
+ for(; result._[offset] && !result._[offset].startsWith("-");)args.push(result._[offset++]);
148
+ result._.splice(i, 1 + args.length), flagValue = 0 === args.length ? void 0 : 1 === args.length ? args[0] : args;
149
+ } else result._.splice(i, 1);
150
+ result[flagName] = handler.type(flagValue, flagName);
151
+ }
152
+ return result._[0] !== command && result._.unshift(command), result;
153
+ } catch (err) {
154
+ throw "ARG_UNKNOWN_OPTION" === err.code && ((0, _help.help)({
155
+ message: err.message,
156
+ usage: [
157
+ "tailwindcss <command> [options]"
158
+ ],
159
+ options: sharedFlags
160
+ }), process.exit(1)), err;
161
+ }
162
+ })();
163
+ args["--help"] && ((0, _help.help)({
164
+ options: {
165
+ ...flags,
166
+ ...sharedFlags
167
+ },
168
+ usage: [
169
+ `tailwindcss ${command} [options]`
170
+ ]
171
+ }), process.exit(0)), run(args);