tailwindcss 0.0.0-oxide-insiders.dddaded → 0.0.0-oxide-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 (112) hide show
  1. package/lib/cli/build/deps.js +10 -18
  2. package/lib/cli/build/index.js +10 -41
  3. package/lib/cli/build/plugin.js +87 -268
  4. package/lib/cli/build/utils.js +18 -40
  5. package/lib/cli/build/watching.js +35 -151
  6. package/lib/cli/help/index.js +15 -58
  7. package/lib/cli/index.js +61 -120
  8. package/lib/cli/init/index.js +21 -43
  9. package/lib/cli-peer-dependencies.js +13 -15
  10. package/lib/cli.js +1 -5
  11. package/lib/corePluginList.js +3 -4
  12. package/lib/corePlugins.js +394 -857
  13. package/lib/featureFlags.js +14 -34
  14. package/lib/index.js +1 -5
  15. package/lib/lib/cacheInvalidation.js +29 -75
  16. package/lib/lib/collapseAdjacentRules.js +22 -43
  17. package/lib/lib/collapseDuplicateDeclarations.js +27 -68
  18. package/lib/lib/content.js +37 -126
  19. package/lib/lib/defaultExtractor.js +96 -199
  20. package/lib/lib/detectNesting.js +12 -36
  21. package/lib/lib/evaluateTailwindFunctions.js +101 -188
  22. package/lib/lib/expandApplyAtRules.js +177 -482
  23. package/lib/lib/expandTailwindAtRules.js +69 -237
  24. package/lib/lib/findAtConfigPath.js +13 -30
  25. package/lib/lib/generateRules.js +349 -765
  26. package/lib/lib/getModuleDependencies.js +27 -63
  27. package/lib/lib/load-config.js +16 -24
  28. package/lib/lib/normalizeTailwindDirectives.js +26 -70
  29. package/lib/lib/offsets.js +61 -224
  30. package/lib/lib/partitionApplyAtRules.js +29 -51
  31. package/lib/lib/regex.js +22 -30
  32. package/lib/lib/remap-bitfield.js +9 -84
  33. package/lib/lib/resolveDefaultsAtRules.js +50 -116
  34. package/lib/lib/setupContextUtils.js +576 -1099
  35. package/lib/lib/setupTrackingContext.js +54 -143
  36. package/lib/lib/sharedState.js +15 -59
  37. package/lib/lib/substituteScreenAtRules.js +8 -16
  38. package/lib/oxide/cli/build/deps.js +17 -32
  39. package/lib/oxide/cli/build/index.js +10 -40
  40. package/lib/oxide/cli/build/plugin.js +87 -267
  41. package/lib/oxide/cli/build/utils.js +18 -39
  42. package/lib/oxide/cli/build/watching.js +34 -149
  43. package/lib/oxide/cli/help/index.js +15 -57
  44. package/lib/oxide/cli/index.js +66 -127
  45. package/lib/oxide/cli/init/index.js +17 -36
  46. package/lib/oxide/cli.js +2 -3
  47. package/lib/plugin.js +30 -57
  48. package/lib/postcss-plugins/nesting/index.js +6 -10
  49. package/lib/postcss-plugins/nesting/plugin.js +17 -60
  50. package/lib/processTailwindFeatures.js +8 -37
  51. package/lib/public/colors.js +15 -22
  52. package/lib/public/create-plugin.js +5 -8
  53. package/lib/public/default-config.js +5 -9
  54. package/lib/public/default-theme.js +5 -9
  55. package/lib/public/load-config.js +4 -6
  56. package/lib/public/resolve-config.js +4 -6
  57. package/lib/util/applyImportantSelector.js +15 -24
  58. package/lib/util/bigSign.js +6 -7
  59. package/lib/util/buildMediaQuery.js +10 -17
  60. package/lib/util/cloneDeep.js +9 -17
  61. package/lib/util/cloneNodes.js +14 -27
  62. package/lib/util/color.js +45 -81
  63. package/lib/util/configurePlugins.js +9 -16
  64. package/lib/util/createPlugin.js +8 -15
  65. package/lib/util/createUtilityPlugin.js +15 -27
  66. package/lib/util/dataTypes.js +23 -144
  67. package/lib/util/defaults.js +9 -19
  68. package/lib/util/escapeClassName.js +6 -10
  69. package/lib/util/escapeCommas.js +6 -7
  70. package/lib/util/flattenColorPalette.js +6 -8
  71. package/lib/util/formatVariantSelector.js +49 -190
  72. package/lib/util/getAllConfigs.js +35 -42
  73. package/lib/util/hashConfig.js +6 -8
  74. package/lib/util/isKeyframeRule.js +6 -7
  75. package/lib/util/isPlainObject.js +8 -11
  76. package/lib/util/isSyntacticallyValidPropertyValue.js +13 -42
  77. package/lib/util/log.js +7 -14
  78. package/lib/util/nameClass.js +6 -21
  79. package/lib/util/negateValue.js +10 -26
  80. package/lib/util/normalizeConfig.js +63 -240
  81. package/lib/util/normalizeScreens.js +70 -137
  82. package/lib/util/parseAnimationValue.js +13 -61
  83. package/lib/util/parseBoxShadowValue.js +12 -57
  84. package/lib/util/parseDependency.js +13 -37
  85. package/lib/util/parseGlob.js +7 -22
  86. package/lib/util/parseObjectStyles.js +17 -26
  87. package/lib/util/pluginUtils.js +69 -176
  88. package/lib/util/prefixSelector.js +11 -28
  89. package/lib/util/pseudoElements.js +29 -105
  90. package/lib/util/removeAlphaVariables.js +8 -21
  91. package/lib/util/resolveConfig.js +103 -220
  92. package/lib/util/resolveConfigPath.js +12 -38
  93. package/lib/util/responsive.js +4 -6
  94. package/lib/util/splitAtTopLevelOnly.js +10 -44
  95. package/lib/util/tap.js +6 -8
  96. package/lib/util/toColorValue.js +6 -7
  97. package/lib/util/toPath.js +8 -26
  98. package/lib/util/transformThemeValue.js +12 -45
  99. package/lib/util/validateConfig.js +14 -22
  100. package/lib/util/validateFormalSyntax.js +5 -11
  101. package/lib/util/withAlphaVariable.js +28 -48
  102. package/package.json +3 -3
  103. package/peers/index.js +14 -16
  104. package/src/cli/build/plugin.js +1 -1
  105. package/src/cli.js +1 -1
  106. package/src/corePlugins.js +16 -17
  107. package/src/featureFlags.js +2 -3
  108. package/src/index.js +1 -5
  109. package/src/lib/expandTailwindAtRules.js +2 -2
  110. package/src/lib/sharedState.js +0 -15
  111. package/src/oxide/cli/build/plugin.ts +1 -1
  112. package/src/plugin.js +1 -1
@@ -1,120 +1,41 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "createProcessor", {
6
- enumerable: true,
3
+ value: !0
4
+ }), Object.defineProperty(exports, "createProcessor", {
5
+ enumerable: !0,
7
6
  get: ()=>createProcessor
8
7
  });
9
- const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
10
- const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
11
- const _postcssLoadConfig = /*#__PURE__*/ _interopRequireDefault(require("postcss-load-config"));
12
- const _lilconfig = require("lilconfig");
13
- const _plugins = /*#__PURE__*/ _interopRequireDefault(require("postcss-load-config/src/plugins" // Little bit scary, looking at private/internal API
14
- ));
15
- const _options = /*#__PURE__*/ _interopRequireDefault(require("postcss-load-config/src/options" // Little bit scary, looking at private/internal API
16
- ));
17
- const _processTailwindFeatures = /*#__PURE__*/ _interopRequireDefault(require("../../../processTailwindFeatures"));
18
- const _deps = require("./deps");
19
- const _utils = require("./utils");
20
- const _sharedState = require("../../../lib/sharedState");
21
- const _resolveConfig = /*#__PURE__*/ _interopRequireDefault(require("../../../../resolveConfig"));
22
- const _content = require("../../../lib/content");
23
- const _watching = require("./watching");
24
- const _fastGlob = /*#__PURE__*/ _interopRequireDefault(require("fast-glob"));
25
- const _findAtConfigPath = require("../../../lib/findAtConfigPath");
26
- const _log = /*#__PURE__*/ _interopRequireDefault(require("../../../util/log"));
27
- const _loadConfig = require("../../../lib/load-config");
28
- const _getModuleDependencies = /*#__PURE__*/ _interopRequireDefault(require("../../../lib/getModuleDependencies"));
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"), _resolveConfig = _interopRequireDefault(require("../../../../resolveConfig")), _content = require("../../../lib/content"), _watching = require("./watching"), _fastGlob = _interopRequireDefault(require("fast-glob")), _findAtConfigPath = require("../../../lib/findAtConfigPath"), _log = _interopRequireDefault(require("../../../util/log")), _loadConfig = require("../../../lib/load-config"), _getModuleDependencies = _interopRequireDefault(require("../../../lib/getModuleDependencies"));
29
9
  function _interopRequireDefault(obj) {
30
10
  return obj && obj.__esModule ? obj : {
31
11
  default: obj
32
12
  };
33
13
  }
34
- /**
35
- *
36
- * @param {string} [customPostCssPath ]
37
- * @returns
38
- */ async function loadPostCssPlugins(customPostCssPath) {
14
+ async function loadPostCssPlugins(customPostCssPath) {
39
15
  let config = customPostCssPath ? await (async ()=>{
40
- let file = _path.default.resolve(customPostCssPath);
41
- // Implementation, see: https://unpkg.com/browse/postcss-load-config@3.1.0/src/index.js
42
- // @ts-ignore
43
- let { config ={} } = await (0, _lilconfig.lilconfig)("postcss").load(file);
44
- if (typeof config === "function") {
45
- config = config();
46
- } else {
47
- config = Object.assign({}, config);
48
- }
49
- if (!config.plugins) {
50
- config.plugins = [];
51
- }
52
- return {
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 = []), {
53
18
  file,
54
19
  plugins: (0, _plugins.default)(config, file),
55
20
  options: (0, _options.default)(config, file)
56
21
  };
57
- })() : await (0, _postcssLoadConfig.default)();
58
- let configPlugins = config.plugins;
59
- let configPluginTailwindIdx = configPlugins.findIndex((plugin)=>{
60
- if (typeof plugin === "function" && plugin.name === "tailwindcss") {
61
- return true;
62
- }
63
- if (typeof plugin === "object" && plugin !== null && plugin.postcssPlugin === "tailwindcss") {
64
- return true;
65
- }
66
- return false;
67
- });
68
- let beforePlugins = configPluginTailwindIdx === -1 ? [] : configPlugins.slice(0, configPluginTailwindIdx);
69
- let afterPlugins = configPluginTailwindIdx === -1 ? configPlugins : configPlugins.slice(configPluginTailwindIdx + 1);
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);
70
23
  return [
71
- beforePlugins,
72
- afterPlugins,
24
+ -1 === configPluginTailwindIdx ? [] : configPlugins.slice(0, configPluginTailwindIdx),
25
+ -1 === configPluginTailwindIdx ? configPlugins : configPlugins.slice(configPluginTailwindIdx + 1),
73
26
  config.options
74
27
  ];
75
28
  }
76
- function loadBuiltinPostcssPlugins() {
77
- let postcss = (0, _deps.loadPostcss)();
78
- let IMPORT_COMMENT = "__TAILWIND_RESTORE_IMPORT__: ";
79
- return [
80
- [
81
- (root)=>{
82
- root.walkAtRules("import", (rule)=>{
83
- if (rule.params.slice(1).startsWith("tailwindcss/")) {
84
- rule.after(postcss.comment({
85
- text: IMPORT_COMMENT + rule.params
86
- }));
87
- rule.remove();
88
- }
89
- });
90
- },
91
- (0, _deps.loadPostcssImport)(),
92
- (root)=>{
93
- root.walkComments((rule)=>{
94
- if (rule.text.startsWith(IMPORT_COMMENT)) {
95
- rule.after(postcss.atRule({
96
- name: "import",
97
- params: rule.text.replace(IMPORT_COMMENT, "")
98
- }));
99
- rule.remove();
100
- }
101
- });
102
- }
103
- ],
104
- [],
105
- {}
106
- ];
107
- }
108
29
  let state = {
109
- /** @type {any} */ context: null,
110
- /** @type {ReturnType<typeof createWatcher> | null} */ watcher: null,
111
- /** @type {{content: string, extension: string}[]} */ changedContent: [],
112
- /** @type {{config: Config, dependencies: Set<string>, dispose: Function } | null} */ configBag: null,
30
+ context: null,
31
+ watcher: null,
32
+ changedContent: [],
33
+ configBag: null,
113
34
  contextDependencies: new Set(),
114
- /** @type {import('../../lib/content.js').ContentPath[]} */ contentPaths: [],
35
+ contentPaths: [],
115
36
  refreshContentPaths () {
116
37
  var _this_context;
117
- this.contentPaths = (0, _content.parseCandidateFiles)(this.context, (_this_context = this.context) === null || _this_context === void 0 ? void 0 : _this_context.tailwindConfig);
38
+ this.contentPaths = (0, _content.parseCandidateFiles)(this.context, null === (_this_context = this.context) || void 0 === _this_context ? void 0 : _this_context.tailwindConfig);
118
39
  },
119
40
  get config () {
120
41
  return this.context.tailwindConfig;
@@ -122,165 +43,103 @@ let state = {
122
43
  get contentPatterns () {
123
44
  return {
124
45
  all: this.contentPaths.map((contentPath)=>contentPath.pattern),
125
- dynamic: this.contentPaths.filter((contentPath)=>contentPath.glob !== undefined).map((contentPath)=>contentPath.pattern)
46
+ dynamic: this.contentPaths.filter((contentPath)=>void 0 !== contentPath.glob).map((contentPath)=>contentPath.pattern)
126
47
  };
127
48
  },
128
49
  loadConfig (configPath, content) {
129
- if (this.watcher && configPath) {
130
- this.refreshConfigDependencies();
131
- }
132
- let config = (0, _loadConfig.loadConfig)(configPath);
133
- let dependencies = (0, _getModuleDependencies.default)(configPath);
134
- this.configBag = {
50
+ this.watcher && configPath && this.refreshConfigDependencies();
51
+ let config = (0, _loadConfig.loadConfig)(configPath), dependencies = (0, _getModuleDependencies.default)(configPath);
52
+ return this.configBag = {
135
53
  config,
136
54
  dependencies,
137
55
  dispose () {
138
- for (let file of dependencies){
139
- delete require.cache[require.resolve(file)];
140
- }
56
+ for (let file of dependencies)delete require.cache[require.resolve(file)];
141
57
  }
142
- };
143
- // @ts-ignore
144
- this.configBag.config = (0, _resolveConfig.default)(this.configBag.config, {
58
+ }, this.configBag.config = (0, _resolveConfig.default)(this.configBag.config, {
145
59
  content: {
146
60
  files: []
147
61
  }
148
- });
149
- // Override content files if `--content` has been passed explicitly
150
- if ((content === null || content === void 0 ? void 0 : content.length) > 0) {
151
- this.configBag.config.content.files = content;
152
- }
153
- return this.configBag.config;
62
+ }), (null == content ? void 0 : content.length) > 0 && (this.configBag.config.content.files = content), this.configBag.config;
154
63
  },
155
64
  refreshConfigDependencies (configPath) {
156
65
  var _this_configBag;
157
- _sharedState.env.DEBUG && console.time("Module dependencies");
158
- (_this_configBag = this.configBag) === null || _this_configBag === void 0 ? void 0 : _this_configBag.dispose();
159
- _sharedState.env.DEBUG && console.timeEnd("Module dependencies");
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");
160
67
  },
161
68
  readContentPaths () {
162
69
  let content = [];
163
- // Resolve globs from the content config
164
- // TODO: When we make the postcss plugin async-capable this can become async
165
- let files = _fastGlob.default.sync(this.contentPatterns.all);
166
- for (let file of files){
167
- if (_sharedState.env.OXIDE) {
168
- content.push({
169
- file,
170
- extension: _path.default.extname(file).slice(1)
171
- });
172
- } else {
173
- content.push({
174
- content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
175
- extension: _path.default.extname(file).slice(1)
176
- });
177
- }
178
- }
179
- // Resolve raw content in the tailwind config
180
- let rawContent = this.config.content.files.filter((file)=>{
181
- return file !== null && typeof file === "object";
70
+ for (let file of _fastGlob.default.sync(this.contentPatterns.all))content.push({
71
+ file,
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
182
77
  });
183
- for (let { raw: htmlContent , extension ="html" } of rawContent){
184
- content.push({
185
- content: htmlContent,
186
- extension
187
- });
188
- }
189
78
  return content;
190
79
  },
191
80
  getContext ({ createContext , cliConfigPath , root , result , content }) {
192
- if (this.context) {
193
- this.context.changedContent = this.changedContent.splice(0);
194
- return this.context;
195
- }
196
- _sharedState.env.DEBUG && console.time("Searching for config");
197
81
  var _findAtConfigPath1;
198
- let configPath = (_findAtConfigPath1 = (0, _findAtConfigPath.findAtConfigPath)(root, result)) !== null && _findAtConfigPath1 !== void 0 ? _findAtConfigPath1 : cliConfigPath;
199
- _sharedState.env.DEBUG && console.timeEnd("Searching for config");
200
- _sharedState.env.DEBUG && console.time("Loading config");
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 !== (_findAtConfigPath1 = (0, _findAtConfigPath.findAtConfigPath)(root, result)) && void 0 !== _findAtConfigPath1 ? _findAtConfigPath1 : cliConfigPath;
85
+ _sharedState.env.DEBUG && console.timeEnd("Searching for config"), _sharedState.env.DEBUG && console.time("Loading config");
201
86
  let config = this.loadConfig(configPath, content);
202
- _sharedState.env.DEBUG && console.timeEnd("Loading config");
203
- _sharedState.env.DEBUG && console.time("Creating context");
204
- this.context = createContext(config, []);
205
- Object.assign(this.context, {
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, {
206
88
  userConfigPath: configPath
207
- });
208
- _sharedState.env.DEBUG && console.timeEnd("Creating context");
209
- _sharedState.env.DEBUG && console.time("Resolving content paths");
210
- this.refreshContentPaths();
211
- _sharedState.env.DEBUG && console.timeEnd("Resolving content paths");
212
- if (this.watcher) {
213
- _sharedState.env.DEBUG && console.time("Watch new files");
214
- this.watcher.refreshWatchedFiles();
215
- _sharedState.env.DEBUG && console.timeEnd("Watch new files");
216
- }
217
- for (let file of this.readContentPaths()){
218
- this.context.changedContent.push(file);
219
- }
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);
220
90
  return this.context;
221
91
  }
222
92
  };
223
93
  async function createProcessor(args, cliConfigPath) {
224
- var _args_content;
225
- let postcss = (0, _deps.loadPostcss)();
226
- let input = args["--input"];
227
- let output = args["--output"];
228
- let includePostCss = args["--postcss"];
229
- let customPostCssPath = typeof args["--postcss"] === "string" ? args["--postcss"] : undefined;
230
- let [beforePlugins, afterPlugins, postcssOptions] = includePostCss ? await loadPostCssPlugins(customPostCssPath) : loadBuiltinPostcssPlugins();
231
- if (args["--purge"]) {
232
- _log.default.warn("purge-flag-deprecated", [
233
- "The `--purge` flag has been deprecated.",
234
- "Please use `--content` instead."
235
- ]);
236
- if (!args["--content"]) {
237
- args["--content"] = args["--purge"];
238
- }
239
- }
240
- var _args_content_split;
241
- let content = (_args_content_split = (_args_content = args["--content"]) === null || _args_content === void 0 ? void 0 : _args_content.split(/(?<!{[^}]+),/)) !== null && _args_content_split !== void 0 ? _args_content_split : [];
242
- let tailwindPlugin = ()=>{
243
- return {
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 = ()=>({
244
123
  postcssPlugin: "tailwindcss",
245
124
  Once (root, { result }) {
246
- _sharedState.env.DEBUG && console.time("Compiling CSS");
247
- (0, _processTailwindFeatures.default)(({ createContext })=>{
248
- console.error();
249
- console.error("Rebuilding...");
250
- return ()=>{
251
- return state.getContext({
125
+ _sharedState.env.DEBUG && console.time("Compiling CSS"), (0, _processTailwindFeatures.default)(({ createContext })=>(console.error(), console.error("Rebuilding..."), ()=>state.getContext({
252
126
  createContext,
253
127
  cliConfigPath,
254
128
  root,
255
129
  result,
256
130
  content
257
- });
258
- };
259
- })(root, result);
260
- _sharedState.env.DEBUG && console.timeEnd("Compiling CSS");
131
+ })))(root, result), _sharedState.env.DEBUG && console.timeEnd("Compiling CSS");
261
132
  }
262
- };
263
- };
264
- tailwindPlugin.postcss = true;
265
- let plugins = [
133
+ });
134
+ tailwindPlugin.postcss = !0;
135
+ let processor = postcss1([
266
136
  ...beforePlugins,
267
137
  tailwindPlugin,
268
138
  !args["--minify"] && _utils.formatNodes,
269
139
  ...afterPlugins
270
- ].filter(Boolean);
271
- /** @type {import('postcss').Processor} */ // @ts-ignore
272
- let processor = postcss(plugins);
140
+ ].filter(Boolean));
273
141
  async function readInput() {
274
- // Piping in data, let's drain the stdin
275
- if (input === "-") {
276
- return (0, _utils.drainStdin)();
277
- }
278
- // Input file has been provided
279
- if (input) {
280
- return _fs.default.promises.readFile(_path.default.resolve(input), "utf8");
281
- }
282
- // No input file provided, fallback to default atrules
283
- return "@tailwind base; @tailwind components; @tailwind utilities";
142
+ return "-" === input ? (0, _utils.drainStdin)() : input ? _fs.default.promises.readFile(_path.default.resolve(input), "utf8") : "@tailwind base; @tailwind components; @tailwind utilities";
284
143
  }
285
144
  async function build() {
286
145
  let start = process.hrtime.bigint();
@@ -289,21 +148,9 @@ async function createProcessor(args, cliConfigPath) {
289
148
  from: input,
290
149
  to: output
291
150
  })).then((result)=>(0, _deps.lightningcss)(!!args["--minify"], result)).then((result)=>{
292
- if (!state.watcher) {
293
- return result;
294
- }
295
- _sharedState.env.DEBUG && console.time("Recording PostCSS dependencies");
296
- for (let message of result.messages){
297
- if (message.type === "dependency") {
298
- state.contextDependencies.add(message.file);
299
- }
300
- }
301
- _sharedState.env.DEBUG && console.timeEnd("Recording PostCSS dependencies");
302
- // TODO: This needs to be in a different spot
303
- _sharedState.env.DEBUG && console.time("Watch new files");
304
- state.watcher.refreshWatchedFiles();
305
- _sharedState.env.DEBUG && console.timeEnd("Watch new files");
306
- return result;
151
+ if (!state.watcher) return result;
152
+ for (let message of (_sharedState.env.DEBUG && console.time("Recording PostCSS dependencies"), result.messages))"dependency" === message.type && state.contextDependencies.add(message.file);
153
+ 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;
307
154
  }).then((result)=>{
308
155
  if (!output) {
309
156
  process.stdout.write(result.css);
@@ -315,59 +162,32 @@ async function createProcessor(args, cliConfigPath) {
315
162
  ]);
316
163
  }).then(()=>{
317
164
  let end = process.hrtime.bigint();
318
- console.error();
319
- console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
165
+ console.error(), console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
320
166
  }).then(()=>{}, (err)=>{
321
- // TODO: If an initial build fails we can't easily pick up any PostCSS dependencies
322
- // that were collected before the error occurred
323
- // The result is not stored on the error so we have to store it externally
324
- // and pull the messages off of it here somehow
325
- // This results in a less than ideal DX because the watcher will not pick up
326
- // changes to imported CSS if one of them caused an error during the initial build
327
- // If you fix it and then save the main CSS file so there's no error
328
- // The watcher will start watching the imported CSS files and will be
329
- // resilient to future errors.
330
- if (state.watcher) {
331
- console.error(err);
332
- } else {
333
- return Promise.reject(err);
334
- }
167
+ if (!state.watcher) return Promise.reject(err);
168
+ console.error(err);
335
169
  });
336
170
  }
337
- /**
338
- * @param {{file: string, content(): Promise<string>, extension: string}[]} changes
339
- */ async function parseChanges(changes) {
171
+ async function parseChanges(changes) {
340
172
  return Promise.all(changes.map(async (change)=>({
341
173
  content: await change.content(),
342
174
  extension: change.extension
343
175
  })));
344
176
  }
345
- if (input !== undefined && input !== "-") {
346
- state.contextDependencies.add(_path.default.resolve(input));
347
- }
348
- return {
177
+ return void 0 !== input && "-" !== input && state.contextDependencies.add(_path.default.resolve(input)), {
349
178
  build,
350
179
  watch: async ()=>{
351
180
  state.watcher = (0, _watching.createWatcher)(args, {
352
181
  state,
353
- /**
354
- * @param {{file: string, content(): Promise<string>, extension: string}[]} changes
355
- */ async rebuild (changes) {
356
- let needsNewContext = changes.some((change)=>{
182
+ async rebuild (changes) {
183
+ if (changes.some((change)=>{
357
184
  var _state_configBag;
358
- return ((_state_configBag = state.configBag) === null || _state_configBag === void 0 ? void 0 : _state_configBag.dependencies.has(change.file)) || state.contextDependencies.has(change.file);
359
- });
360
- if (needsNewContext) {
361
- state.context = null;
362
- } else {
363
- for (let change of (await parseChanges(changes))){
364
- state.changedContent.push(change);
365
- }
366
- }
185
+ return (null === (_state_configBag = state.configBag) || void 0 === _state_configBag ? void 0 : _state_configBag.dependencies.has(change.file)) || state.contextDependencies.has(change.file);
186
+ })) state.context = null;
187
+ else for (let change of (await parseChanges(changes)))state.changedContent.push(change);
367
188
  return build();
368
189
  }
369
- });
370
- await build();
190
+ }), await build();
371
191
  }
372
192
  };
373
193
  }
@@ -1,22 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
3
+ value: !0
4
+ }), function(target, all) {
6
5
  for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
6
+ enumerable: !0,
8
7
  get: all[name]
9
8
  });
10
- }
11
- _export(exports, {
9
+ }(exports, {
12
10
  indentRecursive: ()=>indentRecursive,
13
11
  formatNodes: ()=>formatNodes,
14
12
  readFileWithRetries: ()=>readFileWithRetries,
15
13
  drainStdin: ()=>drainStdin,
16
14
  outputFile: ()=>outputFile
17
15
  });
18
- const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
19
- const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
16
+ const _fs = _interopRequireDefault(require("fs")), _path = _interopRequireDefault(require("path"));
20
17
  function _interopRequireDefault(obj) {
21
18
  return obj && obj.__esModule ? obj : {
22
19
  default: obj
@@ -24,32 +21,21 @@ function _interopRequireDefault(obj) {
24
21
  }
25
22
  function indentRecursive(node, indent = 0) {
26
23
  node.each && node.each((child, i)=>{
27
- if (!child.raws.before || !child.raws.before.trim() || child.raws.before.includes("\n")) {
28
- child.raws.before = `\n${node.type !== "rule" && i > 0 ? "\n" : ""}${" ".repeat(indent)}`;
29
- }
30
- child.raws.after = `\n${" ".repeat(indent)}`;
31
- indentRecursive(child, indent + 1);
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);
32
25
  });
33
26
  }
34
27
  function formatNodes(root) {
35
- indentRecursive(root);
36
- if (root.first) {
37
- root.first.raws.before = "";
38
- }
28
+ indentRecursive(root), root.first && (root.first.raws.before = "");
39
29
  }
40
30
  async function readFileWithRetries(path, tries = 5) {
41
- for(let n = 0; n <= tries; n++){
42
- try {
43
- return await _fs.default.promises.readFile(path, "utf8");
44
- } catch (err) {
45
- if (n !== tries) {
46
- if (err.code === "ENOENT" || err.code === "EBUSY") {
47
- await new Promise((resolve)=>setTimeout(resolve, 10));
48
- continue;
49
- }
50
- }
51
- throw err;
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;
52
37
  }
38
+ throw err;
53
39
  }
54
40
  }
55
41
  function drainStdin() {
@@ -57,21 +43,14 @@ function drainStdin() {
57
43
  let result = "";
58
44
  process.stdin.on("data", (chunk)=>{
59
45
  result += chunk;
60
- });
61
- process.stdin.on("end", ()=>resolve(result));
62
- process.stdin.on("error", (err)=>reject(err));
46
+ }), process.stdin.on("end", ()=>resolve(result)), process.stdin.on("error", (err)=>reject(err));
63
47
  });
64
48
  }
65
49
  async function outputFile(file, newContents) {
66
50
  try {
67
- let currentContents = await _fs.default.promises.readFile(file, "utf8");
68
- if (currentContents === newContents) {
69
- return; // Skip writing the file
70
- }
51
+ if (await _fs.default.promises.readFile(file, "utf8") === newContents) return;
71
52
  } catch {}
72
- // Write the file
73
53
  await _fs.default.promises.mkdir(_path.default.dirname(file), {
74
- recursive: true
75
- });
76
- await _fs.default.promises.writeFile(file, newContents, "utf8");
54
+ recursive: !0
55
+ }), await _fs.default.promises.writeFile(file, newContents, "utf8");
77
56
  }