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,15 +1,12 @@
1
- // @ts-check
2
1
  "use strict";
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- function _export(target, all) {
3
+ value: !0
4
+ }), function(target, all) {
7
5
  for(var name in all)Object.defineProperty(target, name, {
8
- enumerable: true,
6
+ enumerable: !0,
9
7
  get: all[name]
10
8
  });
11
- }
12
- _export(exports, {
9
+ }(exports, {
13
10
  loadPostcss: ()=>loadPostcss,
14
11
  loadPostcssImport: ()=>loadPostcssImport,
15
12
  loadCssNano: ()=>loadCssNano,
@@ -17,36 +14,31 @@ _export(exports, {
17
14
  });
18
15
  const _indexJs = require("../../../peers/index.js");
19
16
  function loadPostcss() {
20
- // Try to load a local `postcss` version first
21
17
  try {
22
18
  return require("postcss");
23
19
  } catch {}
24
20
  return (0, _indexJs.lazyPostcss)();
25
21
  }
26
22
  function loadPostcssImport() {
27
- // Try to load a local `postcss-import` version first
28
23
  try {
29
24
  return require("postcss-import");
30
25
  } catch {}
31
26
  return (0, _indexJs.lazyPostcssImport)();
32
27
  }
33
28
  function loadCssNano() {
34
- let options = {
29
+ try {
30
+ return require("cssnano");
31
+ } catch {}
32
+ return (0, _indexJs.lazyCssnano)()({
35
33
  preset: [
36
34
  "default",
37
35
  {
38
- cssDeclarationSorter: false
36
+ cssDeclarationSorter: !1
39
37
  }
40
38
  ]
41
- };
42
- // Try to load a local `cssnano` version first
43
- try {
44
- return require("cssnano");
45
- } catch {}
46
- return (0, _indexJs.lazyCssnano)()(options);
39
+ });
47
40
  }
48
41
  function loadAutoprefixer() {
49
- // Try to load a local `autoprefixer` version first
50
42
  try {
51
43
  return require("autoprefixer");
52
44
  } catch {}
@@ -1,52 +1,21 @@
1
- // @ts-check
2
1
  "use strict";
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "build", {
7
- enumerable: true,
3
+ value: !0
4
+ }), Object.defineProperty(exports, "build", {
5
+ enumerable: !0,
8
6
  get: ()=>build
9
7
  });
10
- const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
11
- const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
12
- const _resolveConfigPathJs = require("../../util/resolveConfigPath.js");
13
- const _pluginJs = require("./plugin.js");
8
+ const _fs = _interopRequireDefault(require("fs")), _path = _interopRequireDefault(require("path")), _resolveConfigPathJs = require("../../util/resolveConfigPath.js"), _pluginJs = require("./plugin.js");
14
9
  function _interopRequireDefault(obj) {
15
10
  return obj && obj.__esModule ? obj : {
16
11
  default: obj
17
12
  };
18
13
  }
19
14
  async function build(args) {
20
- let input = args["--input"];
21
- let shouldWatch = args["--watch"];
22
- // TODO: Deprecate this in future versions
23
- if (!input && args["_"][1]) {
24
- console.error("[deprecation] Running tailwindcss without -i, please provide an input file.");
25
- input = args["--input"] = args["_"][1];
26
- }
27
- if (input && input !== "-" && !_fs.default.existsSync(input = _path.default.resolve(input))) {
28
- console.error(`Specified input file ${args["--input"]} does not exist.`);
29
- process.exit(9);
30
- }
31
- if (args["--config"] && !_fs.default.existsSync(args["--config"] = _path.default.resolve(args["--config"]))) {
32
- console.error(`Specified config file ${args["--config"]} does not exist.`);
33
- process.exit(9);
34
- }
35
- // TODO: Reference the @config path here if exists
36
- let configPath = args["--config"] ? args["--config"] : (0, _resolveConfigPathJs.resolveDefaultConfigPath)();
37
- let processor = await (0, _pluginJs.createProcessor)(args, configPath);
38
- if (shouldWatch) {
39
- // Abort the watcher if stdin is closed to avoid zombie processes
40
- // You can disable this behavior with --watch=always
41
- if (args["--watch"] !== "always") {
42
- process.stdin.on("end", ()=>process.exit(0));
43
- }
44
- process.stdin.resume();
45
- await processor.watch();
46
- } else {
47
- await processor.build().catch((e)=>{
48
- console.error(e);
49
- process.exit(1);
50
- });
51
- }
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 configPath = args["--config"] ? args["--config"] : (0, _resolveConfigPathJs.resolveDefaultConfigPath)(), processor = await (0, _pluginJs.createProcessor)(args, configPath);
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
+ });
52
21
  }
@@ -1,121 +1,41 @@
1
- // @ts-check
2
1
  "use strict";
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "createProcessor", {
7
- enumerable: true,
3
+ value: !0
4
+ }), Object.defineProperty(exports, "createProcessor", {
5
+ enumerable: !0,
8
6
  get: ()=>createProcessor
9
7
  });
10
- const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
11
- const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
12
- const _postcssLoadConfig = /*#__PURE__*/ _interopRequireDefault(require("postcss-load-config"));
13
- const _lilconfig = require("lilconfig");
14
- const _plugins = /*#__PURE__*/ _interopRequireDefault(require("postcss-load-config/src/plugins" // Little bit scary, looking at private/internal API
15
- ));
16
- const _options = /*#__PURE__*/ _interopRequireDefault(require("postcss-load-config/src/options" // Little bit scary, looking at private/internal API
17
- ));
18
- const _processTailwindFeatures = /*#__PURE__*/ _interopRequireDefault(require("../../processTailwindFeatures"));
19
- const _deps = require("./deps");
20
- const _utils = require("./utils");
21
- const _sharedState = require("../../lib/sharedState");
22
- const _resolveConfigJs = /*#__PURE__*/ _interopRequireDefault(require("../../../resolveConfig.js"));
23
- const _contentJs = require("../../lib/content.js");
24
- const _watchingJs = require("./watching.js");
25
- const _fastGlob = /*#__PURE__*/ _interopRequireDefault(require("fast-glob"));
26
- const _findAtConfigPathJs = require("../../lib/findAtConfigPath.js");
27
- const _log = /*#__PURE__*/ _interopRequireDefault(require("../../util/log"));
28
- const _loadConfig = require("../../lib/load-config");
29
- 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"), _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"));
30
9
  function _interopRequireDefault(obj) {
31
10
  return obj && obj.__esModule ? obj : {
32
11
  default: obj
33
12
  };
34
13
  }
35
- /**
36
- *
37
- * @param {string} [customPostCssPath ]
38
- * @returns
39
- */ async function loadPostCssPlugins(customPostCssPath) {
14
+ async function loadPostCssPlugins(customPostCssPath) {
40
15
  let config = customPostCssPath ? await (async ()=>{
41
- let file = _path.default.resolve(customPostCssPath);
42
- // Implementation, see: https://unpkg.com/browse/postcss-load-config@3.1.0/src/index.js
43
- // @ts-ignore
44
- let { config ={} } = await (0, _lilconfig.lilconfig)("postcss").load(file);
45
- if (typeof config === "function") {
46
- config = config();
47
- } else {
48
- config = Object.assign({}, config);
49
- }
50
- if (!config.plugins) {
51
- config.plugins = [];
52
- }
53
- 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 = []), {
54
18
  file,
55
19
  plugins: (0, _plugins.default)(config, file),
56
20
  options: (0, _options.default)(config, file)
57
21
  };
58
- })() : await (0, _postcssLoadConfig.default)();
59
- let configPlugins = config.plugins;
60
- let configPluginTailwindIdx = configPlugins.findIndex((plugin)=>{
61
- if (typeof plugin === "function" && plugin.name === "tailwindcss") {
62
- return true;
63
- }
64
- if (typeof plugin === "object" && plugin !== null && plugin.postcssPlugin === "tailwindcss") {
65
- return true;
66
- }
67
- return false;
68
- });
69
- let beforePlugins = configPluginTailwindIdx === -1 ? [] : configPlugins.slice(0, configPluginTailwindIdx);
70
- 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);
71
23
  return [
72
- beforePlugins,
73
- afterPlugins,
24
+ -1 === configPluginTailwindIdx ? [] : configPlugins.slice(0, configPluginTailwindIdx),
25
+ -1 === configPluginTailwindIdx ? configPlugins : configPlugins.slice(configPluginTailwindIdx + 1),
74
26
  config.options
75
27
  ];
76
28
  }
77
- function loadBuiltinPostcssPlugins() {
78
- let postcss = (0, _deps.loadPostcss)();
79
- let IMPORT_COMMENT = "__TAILWIND_RESTORE_IMPORT__: ";
80
- return [
81
- [
82
- (root)=>{
83
- root.walkAtRules("import", (rule)=>{
84
- if (rule.params.slice(1).startsWith("tailwindcss/")) {
85
- rule.after(postcss.comment({
86
- text: IMPORT_COMMENT + rule.params
87
- }));
88
- rule.remove();
89
- }
90
- });
91
- },
92
- (0, _deps.loadPostcssImport)(),
93
- (root)=>{
94
- root.walkComments((rule)=>{
95
- if (rule.text.startsWith(IMPORT_COMMENT)) {
96
- rule.after(postcss.atRule({
97
- name: "import",
98
- params: rule.text.replace(IMPORT_COMMENT, "")
99
- }));
100
- rule.remove();
101
- }
102
- });
103
- }
104
- ],
105
- [],
106
- {}
107
- ];
108
- }
109
29
  let state = {
110
- /** @type {any} */ context: null,
111
- /** @type {ReturnType<typeof createWatcher> | null} */ watcher: null,
112
- /** @type {{content: string, extension: string}[]} */ changedContent: [],
113
- /** @type {ReturnType<typeof load> | null} */ configBag: null,
30
+ context: null,
31
+ watcher: null,
32
+ changedContent: [],
33
+ configBag: null,
114
34
  contextDependencies: new Set(),
115
- /** @type {import('../../lib/content.js').ContentPath[]} */ contentPaths: [],
35
+ contentPaths: [],
116
36
  refreshContentPaths () {
117
37
  var _this_context;
118
- this.contentPaths = (0, _contentJs.parseCandidateFiles)(this.context, (_this_context = this.context) === null || _this_context === void 0 ? void 0 : _this_context.tailwindConfig);
38
+ this.contentPaths = (0, _contentJs.parseCandidateFiles)(this.context, null === (_this_context = this.context) || void 0 === _this_context ? void 0 : _this_context.tailwindConfig);
119
39
  },
120
40
  get config () {
121
41
  return this.context.tailwindConfig;
@@ -123,167 +43,105 @@ let state = {
123
43
  get contentPatterns () {
124
44
  return {
125
45
  all: this.contentPaths.map((contentPath)=>contentPath.pattern),
126
- 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)
127
47
  };
128
48
  },
129
49
  loadConfig (configPath, content) {
130
- if (this.watcher && configPath) {
131
- this.refreshConfigDependencies();
132
- }
133
- let config = (0, _loadConfig.loadConfig)(configPath);
134
- let dependencies = (0, _getModuleDependencies.default)(configPath);
135
- this.configBag = {
50
+ this.watcher && configPath && this.refreshConfigDependencies();
51
+ let config = (0, _loadConfig.loadConfig)(configPath), dependencies = (0, _getModuleDependencies.default)(configPath);
52
+ return this.configBag = {
136
53
  config,
137
54
  dependencies,
138
55
  dispose () {
139
- for (let file of dependencies){
140
- delete require.cache[require.resolve(file)];
141
- }
56
+ for (let file of dependencies)delete require.cache[require.resolve(file)];
142
57
  }
143
- };
144
- // @ts-ignore
145
- this.configBag.config = (0, _resolveConfigJs.default)(this.configBag.config, {
58
+ }, this.configBag.config = (0, _resolveConfigJs.default)(this.configBag.config, {
146
59
  content: {
147
60
  files: []
148
61
  }
149
- });
150
- // Override content files if `--content` has been passed explicitly
151
- if ((content === null || content === void 0 ? void 0 : content.length) > 0) {
152
- this.configBag.config.content.files = content;
153
- }
154
- return this.configBag.config;
62
+ }), (null == content ? void 0 : content.length) > 0 && (this.configBag.config.content.files = content), this.configBag.config;
155
63
  },
156
64
  refreshConfigDependencies () {
157
65
  var _this_configBag;
158
- _sharedState.env.DEBUG && console.time("Module dependencies");
159
- (_this_configBag = this.configBag) === null || _this_configBag === void 0 ? void 0 : _this_configBag.dispose();
160
- _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");
161
67
  },
162
68
  readContentPaths () {
163
69
  let content = [];
164
- // Resolve globs from the content config
165
- // TODO: When we make the postcss plugin async-capable this can become async
166
- let files = _fastGlob.default.sync(this.contentPatterns.all);
167
- for (let file of files){
168
- if (_sharedState.env.OXIDE) {
169
- content.push({
170
- file,
171
- extension: _path.default.extname(file).slice(1)
172
- });
173
- } else {
174
- content.push({
175
- content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
176
- extension: _path.default.extname(file).slice(1)
177
- });
178
- }
179
- }
180
- // Resolve raw content in the tailwind config
181
- let rawContent = this.config.content.files.filter((file)=>{
182
- 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
183
77
  });
184
- for (let { raw: htmlContent , extension ="html" } of rawContent){
185
- content.push({
186
- content: htmlContent,
187
- extension
188
- });
189
- }
190
78
  return content;
191
79
  },
192
80
  getContext ({ createContext , cliConfigPath , root , result , content }) {
193
- if (this.context) {
194
- this.context.changedContent = this.changedContent.splice(0);
195
- return this.context;
196
- }
197
- _sharedState.env.DEBUG && console.time("Searching for config");
198
81
  var _findAtConfigPath;
199
- let configPath = (_findAtConfigPath = (0, _findAtConfigPathJs.findAtConfigPath)(root, result)) !== null && _findAtConfigPath !== void 0 ? _findAtConfigPath : cliConfigPath;
200
- _sharedState.env.DEBUG && console.timeEnd("Searching for config");
201
- _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 !== (_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");
202
86
  let config = this.loadConfig(configPath, content);
203
- _sharedState.env.DEBUG && console.timeEnd("Loading config");
204
- _sharedState.env.DEBUG && console.time("Creating context");
205
- this.context = createContext(config, []);
206
- 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, {
207
88
  userConfigPath: configPath
208
- });
209
- _sharedState.env.DEBUG && console.timeEnd("Creating context");
210
- _sharedState.env.DEBUG && console.time("Resolving content paths");
211
- this.refreshContentPaths();
212
- _sharedState.env.DEBUG && console.timeEnd("Resolving content paths");
213
- if (this.watcher) {
214
- _sharedState.env.DEBUG && console.time("Watch new files");
215
- this.watcher.refreshWatchedFiles();
216
- _sharedState.env.DEBUG && console.timeEnd("Watch new files");
217
- }
218
- for (let file of this.readContentPaths()){
219
- this.context.changedContent.push(file);
220
- }
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);
221
90
  return this.context;
222
91
  }
223
92
  };
224
93
  async function createProcessor(args, cliConfigPath) {
225
- var _args_content;
226
- let postcss = (0, _deps.loadPostcss)();
227
- let input = args["--input"];
228
- let output = args["--output"];
229
- let includePostCss = args["--postcss"];
230
- let customPostCssPath = typeof args["--postcss"] === "string" ? args["--postcss"] : undefined;
231
- let [beforePlugins, afterPlugins, postcssOptions] = includePostCss ? await loadPostCssPlugins(customPostCssPath) : loadBuiltinPostcssPlugins();
232
- if (args["--purge"]) {
233
- _log.default.warn("purge-flag-deprecated", [
234
- "The `--purge` flag has been deprecated.",
235
- "Please use `--content` instead."
236
- ]);
237
- if (!args["--content"]) {
238
- args["--content"] = args["--purge"];
239
- }
240
- }
241
- var _args_content_split;
242
- 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 : [];
243
- let tailwindPlugin = ()=>{
244
- 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 = ()=>({
245
123
  postcssPlugin: "tailwindcss",
246
124
  Once (root, { result }) {
247
- _sharedState.env.DEBUG && console.time("Compiling CSS");
248
- (0, _processTailwindFeatures.default)(({ createContext })=>{
249
- console.error();
250
- console.error("Rebuilding...");
251
- return ()=>{
252
- return state.getContext({
125
+ _sharedState.env.DEBUG && console.time("Compiling CSS"), (0, _processTailwindFeatures.default)(({ createContext })=>(console.error(), console.error("Rebuilding..."), ()=>state.getContext({
253
126
  createContext,
254
127
  cliConfigPath,
255
128
  root,
256
129
  result,
257
130
  content
258
- });
259
- };
260
- })(root, result);
261
- _sharedState.env.DEBUG && console.timeEnd("Compiling CSS");
131
+ })))(root, result), _sharedState.env.DEBUG && console.timeEnd("Compiling CSS");
262
132
  }
263
- };
264
- };
265
- tailwindPlugin.postcss = true;
266
- let plugins = [
133
+ });
134
+ tailwindPlugin.postcss = !0;
135
+ let processor = postcss1([
267
136
  ...beforePlugins,
268
137
  tailwindPlugin,
269
138
  !args["--minify"] && _utils.formatNodes,
270
139
  ...afterPlugins,
271
140
  !args["--no-autoprefixer"] && (0, _deps.loadAutoprefixer)(),
272
141
  args["--minify"] && (0, _deps.loadCssNano)()
273
- ].filter(Boolean);
274
- /** @type {import('postcss').Processor} */ // @ts-ignore
275
- let processor = postcss(plugins);
142
+ ].filter(Boolean));
276
143
  async function readInput() {
277
- // Piping in data, let's drain the stdin
278
- if (input === "-") {
279
- return (0, _utils.drainStdin)();
280
- }
281
- // Input file has been provided
282
- if (input) {
283
- return _fs.default.promises.readFile(_path.default.resolve(input), "utf8");
284
- }
285
- // No input file provided, fallback to default atrules
286
- return "@tailwind base; @tailwind components; @tailwind utilities";
144
+ return "-" === input ? (0, _utils.drainStdin)() : input ? _fs.default.promises.readFile(_path.default.resolve(input), "utf8") : "@tailwind base; @tailwind components; @tailwind utilities";
287
145
  }
288
146
  async function build() {
289
147
  let start = process.hrtime.bigint();
@@ -292,21 +150,9 @@ async function createProcessor(args, cliConfigPath) {
292
150
  from: input,
293
151
  to: output
294
152
  })).then((result)=>{
295
- if (!state.watcher) {
296
- return result;
297
- }
298
- _sharedState.env.DEBUG && console.time("Recording PostCSS dependencies");
299
- for (let message of result.messages){
300
- if (message.type === "dependency") {
301
- state.contextDependencies.add(message.file);
302
- }
303
- }
304
- _sharedState.env.DEBUG && console.timeEnd("Recording PostCSS dependencies");
305
- // TODO: This needs to be in a different spot
306
- _sharedState.env.DEBUG && console.time("Watch new files");
307
- state.watcher.refreshWatchedFiles();
308
- _sharedState.env.DEBUG && console.timeEnd("Watch new files");
309
- return 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;
310
156
  }).then((result)=>{
311
157
  if (!output) {
312
158
  process.stdout.write(result.css);
@@ -318,59 +164,32 @@ async function createProcessor(args, cliConfigPath) {
318
164
  ]);
319
165
  }).then(()=>{
320
166
  let end = process.hrtime.bigint();
321
- console.error();
322
- console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
167
+ console.error(), console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
323
168
  }).then(()=>{}, (err)=>{
324
- // TODO: If an initial build fails we can't easily pick up any PostCSS dependencies
325
- // that were collected before the error occurred
326
- // The result is not stored on the error so we have to store it externally
327
- // and pull the messages off of it here somehow
328
- // This results in a less than ideal DX because the watcher will not pick up
329
- // changes to imported CSS if one of them caused an error during the initial build
330
- // If you fix it and then save the main CSS file so there's no error
331
- // The watcher will start watching the imported CSS files and will be
332
- // resilient to future errors.
333
- if (state.watcher) {
334
- console.error(err);
335
- } else {
336
- return Promise.reject(err);
337
- }
169
+ if (!state.watcher) return Promise.reject(err);
170
+ console.error(err);
338
171
  });
339
172
  }
340
- /**
341
- * @param {{file: string, content(): Promise<string>, extension: string}[]} changes
342
- */ async function parseChanges(changes) {
173
+ async function parseChanges(changes) {
343
174
  return Promise.all(changes.map(async (change)=>({
344
175
  content: await change.content(),
345
176
  extension: change.extension
346
177
  })));
347
178
  }
348
- if (input !== undefined && input !== "-") {
349
- state.contextDependencies.add(_path.default.resolve(input));
350
- }
351
- return {
179
+ return void 0 !== input && "-" !== input && state.contextDependencies.add(_path.default.resolve(input)), {
352
180
  build,
353
181
  watch: async ()=>{
354
182
  state.watcher = (0, _watchingJs.createWatcher)(args, {
355
183
  state,
356
- /**
357
- * @param {{file: string, content(): Promise<string>, extension: string}[]} changes
358
- */ async rebuild (changes) {
359
- let needsNewContext = changes.some((change)=>{
184
+ async rebuild (changes) {
185
+ if (changes.some((change)=>{
360
186
  var _state_configBag;
361
- return ((_state_configBag = state.configBag) === null || _state_configBag === void 0 ? void 0 : _state_configBag.dependencies.has(change.file)) || state.contextDependencies.has(change.file);
362
- });
363
- if (needsNewContext) {
364
- state.context = null;
365
- } else {
366
- for (let change of (await parseChanges(changes))){
367
- state.changedContent.push(change);
368
- }
369
- }
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);
370
190
  return build();
371
191
  }
372
- });
373
- await build();
192
+ }), await build();
374
193
  }
375
194
  };
376
195
  }