tailwindcss 0.0.0-insiders.da85042 → 0.0.0-insiders.dae5fbc

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 (199) hide show
  1. package/README.md +7 -6
  2. package/lib/cli/build/deps.js +46 -0
  3. package/lib/cli/build/index.js +21 -0
  4. package/lib/cli/build/plugin.js +195 -0
  5. package/lib/cli/build/utils.js +56 -0
  6. package/lib/cli/build/watching.js +65 -0
  7. package/lib/cli/help/index.js +28 -0
  8. package/lib/cli/index.js +171 -0
  9. package/lib/cli/init/index.js +39 -0
  10. package/lib/cli-peer-dependencies.js +13 -15
  11. package/lib/cli.js +1 -872
  12. package/lib/corePluginList.js +7 -4
  13. package/lib/corePlugins.js +753 -725
  14. package/lib/css/preflight.css +4 -0
  15. package/lib/featureFlags.js +23 -34
  16. package/lib/index.js +1 -42
  17. package/lib/lib/cacheInvalidation.js +29 -75
  18. package/lib/lib/collapseAdjacentRules.js +22 -43
  19. package/lib/lib/collapseDuplicateDeclarations.js +24 -68
  20. package/lib/lib/content.js +88 -0
  21. package/lib/lib/defaultExtractor.js +97 -192
  22. package/lib/lib/detectNesting.js +12 -30
  23. package/lib/lib/evaluateTailwindFunctions.js +108 -177
  24. package/lib/lib/expandApplyAtRules.js +180 -465
  25. package/lib/lib/expandTailwindAtRules.js +95 -240
  26. package/lib/lib/findAtConfigPath.js +27 -0
  27. package/lib/lib/generateRules.js +373 -641
  28. package/lib/lib/getModuleDependencies.js +50 -40
  29. package/lib/lib/load-config.js +32 -0
  30. package/lib/lib/normalizeTailwindDirectives.js +26 -70
  31. package/lib/lib/offsets.js +141 -0
  32. package/lib/lib/partitionApplyAtRules.js +29 -51
  33. package/lib/lib/regex.js +22 -30
  34. package/lib/lib/remap-bitfield.js +12 -0
  35. package/lib/lib/resolveDefaultsAtRules.js +50 -116
  36. package/lib/lib/setupContextUtils.js +617 -839
  37. package/lib/lib/setupTrackingContext.js +55 -159
  38. package/lib/lib/sharedState.js +22 -41
  39. package/lib/lib/substituteScreenAtRules.js +8 -16
  40. package/lib/oxide/cli/build/deps.js +66 -0
  41. package/lib/oxide/cli/build/index.js +21 -0
  42. package/lib/oxide/cli/build/plugin.js +193 -0
  43. package/lib/oxide/cli/build/utils.js +56 -0
  44. package/lib/oxide/cli/build/watching.js +63 -0
  45. package/lib/oxide/cli/help/index.js +28 -0
  46. package/lib/oxide/cli/index.js +153 -0
  47. package/lib/oxide/cli/init/index.js +31 -0
  48. package/lib/oxide/cli.js +4 -0
  49. package/lib/oxide/postcss-plugin.js +2 -0
  50. package/lib/plugin.js +34 -0
  51. package/lib/postcss-plugins/nesting/index.js +6 -10
  52. package/lib/postcss-plugins/nesting/plugin.js +18 -61
  53. package/lib/processTailwindFeatures.js +8 -37
  54. package/lib/public/colors.js +60 -45
  55. package/lib/public/create-plugin.js +5 -8
  56. package/lib/public/default-config.js +5 -9
  57. package/lib/public/default-theme.js +5 -9
  58. package/lib/public/load-config.js +8 -0
  59. package/lib/public/resolve-config.js +4 -6
  60. package/lib/util/applyImportantSelector.js +25 -0
  61. package/lib/util/bigSign.js +6 -7
  62. package/lib/util/buildMediaQuery.js +13 -17
  63. package/lib/util/cloneDeep.js +9 -17
  64. package/lib/util/cloneNodes.js +15 -28
  65. package/lib/util/color.js +45 -67
  66. package/lib/util/configurePlugins.js +9 -16
  67. package/lib/util/createPlugin.js +8 -15
  68. package/lib/util/createUtilityPlugin.js +15 -27
  69. package/lib/util/dataTypes.js +31 -129
  70. package/lib/util/defaults.js +9 -19
  71. package/lib/util/escapeClassName.js +6 -10
  72. package/lib/util/escapeCommas.js +6 -7
  73. package/lib/util/flattenColorPalette.js +6 -8
  74. package/lib/util/formatVariantSelector.js +95 -182
  75. package/lib/util/getAllConfigs.js +35 -42
  76. package/lib/util/hashConfig.js +6 -8
  77. package/lib/util/isKeyframeRule.js +6 -7
  78. package/lib/util/isPlainObject.js +8 -11
  79. package/lib/util/isSyntacticallyValidPropertyValue.js +43 -0
  80. package/lib/util/log.js +7 -14
  81. package/lib/util/nameClass.js +6 -18
  82. package/lib/util/negateValue.js +15 -18
  83. package/lib/util/normalizeConfig.js +75 -225
  84. package/lib/util/normalizeScreens.js +86 -56
  85. package/lib/util/parseAnimationValue.js +14 -62
  86. package/lib/util/parseBoxShadowValue.js +12 -57
  87. package/lib/util/parseDependency.js +17 -62
  88. package/lib/util/parseGlob.js +19 -0
  89. package/lib/util/parseObjectStyles.js +17 -26
  90. package/lib/util/pluginUtils.js +86 -124
  91. package/lib/util/prefixSelector.js +12 -15
  92. package/lib/util/pseudoElements.js +147 -0
  93. package/lib/util/removeAlphaVariables.js +8 -21
  94. package/lib/util/resolveConfig.js +105 -227
  95. package/lib/util/resolveConfigPath.js +25 -39
  96. package/lib/util/responsive.js +4 -6
  97. package/lib/util/splitAtTopLevelOnly.js +11 -89
  98. package/lib/util/tap.js +6 -8
  99. package/lib/util/toColorValue.js +6 -7
  100. package/lib/util/toPath.js +8 -26
  101. package/lib/util/transformThemeValue.js +13 -39
  102. package/lib/util/validateConfig.js +17 -14
  103. package/lib/util/validateFormalSyntax.js +18 -0
  104. package/lib/util/withAlphaVariable.js +28 -48
  105. package/loadConfig.d.ts +4 -0
  106. package/loadConfig.js +2 -0
  107. package/package.json +41 -28
  108. package/peers/index.js +910 -895
  109. package/plugin.d.ts +3 -3
  110. package/resolveConfig.d.ts +11 -2
  111. package/scripts/release-channel.js +18 -0
  112. package/scripts/release-notes.js +21 -0
  113. package/scripts/swap-engines.js +40 -0
  114. package/src/cli/build/deps.js +56 -0
  115. package/src/cli/build/index.js +49 -0
  116. package/src/cli/build/plugin.js +444 -0
  117. package/src/cli/build/utils.js +76 -0
  118. package/src/cli/build/watching.js +229 -0
  119. package/src/cli/help/index.js +70 -0
  120. package/src/cli/index.js +216 -0
  121. package/src/cli/init/index.js +79 -0
  122. package/src/cli.js +4 -993
  123. package/src/corePluginList.js +1 -1
  124. package/src/corePlugins.js +453 -65
  125. package/src/css/preflight.css +4 -0
  126. package/src/featureFlags.js +13 -1
  127. package/src/index.js +1 -42
  128. package/src/lib/content.js +208 -0
  129. package/src/lib/defaultExtractor.js +12 -3
  130. package/src/lib/detectNesting.js +9 -1
  131. package/src/lib/evaluateTailwindFunctions.js +22 -1
  132. package/src/lib/expandApplyAtRules.js +48 -27
  133. package/src/lib/expandTailwindAtRules.js +42 -51
  134. package/src/lib/findAtConfigPath.js +48 -0
  135. package/src/lib/generateRules.js +343 -136
  136. package/src/lib/getModuleDependencies.js +70 -30
  137. package/src/lib/load-config.ts +31 -0
  138. package/src/lib/offsets.js +373 -0
  139. package/src/lib/remap-bitfield.js +82 -0
  140. package/src/lib/setupContextUtils.js +483 -135
  141. package/src/lib/setupTrackingContext.js +39 -55
  142. package/src/lib/sharedState.js +17 -4
  143. package/src/oxide/cli/build/deps.ts +91 -0
  144. package/src/oxide/cli/build/index.ts +47 -0
  145. package/src/oxide/cli/build/plugin.ts +442 -0
  146. package/src/oxide/cli/build/utils.ts +74 -0
  147. package/src/oxide/cli/build/watching.ts +225 -0
  148. package/src/oxide/cli/help/index.ts +69 -0
  149. package/src/oxide/cli/index.ts +204 -0
  150. package/src/oxide/cli/init/index.ts +59 -0
  151. package/src/oxide/cli.ts +1 -0
  152. package/src/oxide/postcss-plugin.ts +1 -0
  153. package/src/plugin.js +107 -0
  154. package/src/public/colors.js +22 -0
  155. package/src/public/default-config.js +1 -1
  156. package/src/public/default-theme.js +2 -2
  157. package/src/public/load-config.js +2 -0
  158. package/src/util/applyImportantSelector.js +27 -0
  159. package/src/util/buildMediaQuery.js +5 -3
  160. package/src/util/color.js +17 -2
  161. package/src/util/dataTypes.js +48 -21
  162. package/src/util/formatVariantSelector.js +256 -155
  163. package/src/util/getAllConfigs.js +2 -2
  164. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  165. package/src/util/nameClass.js +4 -0
  166. package/src/util/negateValue.js +11 -3
  167. package/src/util/normalizeConfig.js +41 -2
  168. package/src/util/normalizeScreens.js +99 -4
  169. package/src/util/parseBoxShadowValue.js +1 -1
  170. package/src/util/parseDependency.js +37 -42
  171. package/src/util/parseGlob.js +24 -0
  172. package/src/util/pluginUtils.js +114 -23
  173. package/src/util/prefixSelector.js +28 -10
  174. package/src/util/pseudoElements.js +170 -0
  175. package/src/util/resolveConfig.js +4 -10
  176. package/src/util/resolveConfigPath.js +12 -1
  177. package/src/util/splitAtTopLevelOnly.js +28 -47
  178. package/src/util/transformThemeValue.js +9 -1
  179. package/src/util/validateConfig.js +13 -0
  180. package/src/util/validateFormalSyntax.js +34 -0
  181. package/stubs/.gitignore +1 -0
  182. package/stubs/.prettierrc.json +6 -0
  183. package/stubs/{defaultConfig.stub.js → config.full.js} +202 -166
  184. package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -1
  185. package/stubs/postcss.config.js +6 -0
  186. package/stubs/tailwind.config.cjs +2 -0
  187. package/stubs/tailwind.config.js +2 -0
  188. package/stubs/tailwind.config.ts +3 -0
  189. package/types/config.d.ts +61 -20
  190. package/types/generated/colors.d.ts +22 -0
  191. package/types/generated/corePluginList.d.ts +1 -1
  192. package/types/generated/default-theme.d.ts +118 -78
  193. package/CHANGELOG.md +0 -2245
  194. package/lib/constants.js +0 -44
  195. package/lib/util/isValidArbitraryValue.js +0 -72
  196. package/scripts/install-integrations.js +0 -27
  197. package/scripts/rebuildFixtures.js +0 -68
  198. package/src/constants.js +0 -17
  199. /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
package/README.md CHANGED
@@ -1,9 +1,10 @@
1
1
  <p align="center">
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">
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
 
@@ -13,7 +14,7 @@
13
14
 
14
15
 
15
16
  <p align="center">
16
- <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>
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>
17
18
  <a href="https://www.npmjs.com/package/tailwindcss"><img src="https://img.shields.io/npm/dt/tailwindcss.svg" alt="Total Downloads"></a>
18
19
  <a href="https://github.com/tailwindcss/tailwindcss/releases"><img src="https://img.shields.io/npm/v/tailwindcss.svg" alt="Latest Release"></a>
19
20
  <a href="https://github.com/tailwindcss/tailwindcss/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/tailwindcss.svg" alt="License"></a>
@@ -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);
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: !0
4
+ }), Object.defineProperty(exports, "init", {
5
+ enumerable: !0,
6
+ get: ()=>init
7
+ });
8
+ const _fs = _interopRequireDefault(require("fs")), _path = _interopRequireDefault(require("path"));
9
+ function _interopRequireDefault(obj) {
10
+ return obj && obj.__esModule ? obj : {
11
+ default: obj
12
+ };
13
+ }
14
+ function init(args) {
15
+ var _args___;
16
+ let messages = [], isProjectESM = args["--ts"] || args["--esm"] || function() {
17
+ let pkgPath = _path.default.resolve("./package.json");
18
+ try {
19
+ let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, "utf8"));
20
+ return pkg.type && "module" === pkg.type;
21
+ } catch (err) {
22
+ return !1;
23
+ }
24
+ }(), syntax = args["--ts"] ? "ts" : isProjectESM ? "js" : "cjs", extension = args["--ts"] ? "ts" : "js", tailwindConfigLocation = _path.default.resolve(null !== (_args___ = args._[1]) && void 0 !== _args___ ? _args___ : `./tailwind.config.${extension}`);
25
+ if (_fs.default.existsSync(tailwindConfigLocation)) messages.push(`${_path.default.basename(tailwindConfigLocation)} already exists.`);
26
+ else {
27
+ let stubContentsFile = _fs.default.readFileSync(args["--full"] ? _path.default.resolve(__dirname, "../../../stubs/config.full.js") : _path.default.resolve(__dirname, "../../../stubs/config.simple.js"), "utf8"), stubFile = _fs.default.readFileSync(_path.default.resolve(__dirname, `../../../stubs/tailwind.config.${syntax}`), "utf8");
28
+ stubContentsFile = stubContentsFile.replace("../colors", "tailwindcss/colors"), stubFile = stubFile.replace("__CONFIG__", stubContentsFile.replace("module.exports =", "").trim()).trim() + "\n\n", _fs.default.writeFileSync(tailwindConfigLocation, stubFile, "utf8"), messages.push(`Created Tailwind CSS config file: ${_path.default.basename(tailwindConfigLocation)}`);
29
+ }
30
+ if (args["--postcss"]) {
31
+ let postcssConfigLocation = _path.default.resolve("./postcss.config.js");
32
+ if (_fs.default.existsSync(postcssConfigLocation)) messages.push(`${_path.default.basename(postcssConfigLocation)} already exists.`);
33
+ else {
34
+ let stubFile1 = _fs.default.readFileSync(isProjectESM ? _path.default.resolve(__dirname, "../../../stubs/postcss.config.js") : _path.default.resolve(__dirname, "../../../stubs/postcss.config.cjs"), "utf8");
35
+ _fs.default.writeFileSync(postcssConfigLocation, stubFile1, "utf8"), messages.push(`Created PostCSS config file: ${_path.default.basename(postcssConfigLocation)}`);
36
+ }
37
+ }
38
+ if (messages.length > 0) for (let message of (console.log(), messages))console.log(message);
39
+ }