tailwindcss 0.0.0-insiders.cb46ebd → 0.0.0-insiders.cb8af0c

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 (163) hide show
  1. package/lib/cli/build/deps.js +10 -18
  2. package/lib/cli/build/index.js +11 -38
  3. package/lib/cli/build/plugin.js +93 -265
  4. package/lib/cli/build/utils.js +18 -40
  5. package/lib/cli/build/watching.js +36 -149
  6. package/lib/cli/help/index.js +15 -58
  7. package/lib/cli/index.js +68 -136
  8. package/lib/cli/init/index.js +24 -31
  9. package/lib/cli-peer-dependencies.js +13 -15
  10. package/lib/cli.js +1 -5
  11. package/lib/corePluginList.js +7 -4
  12. package/lib/corePlugins.js +594 -801
  13. package/lib/css/preflight.css +2 -0
  14. package/lib/featureFlags.js +18 -31
  15. package/lib/index.js +1 -5
  16. package/lib/lib/cacheInvalidation.js +29 -75
  17. package/lib/lib/collapseAdjacentRules.js +22 -43
  18. package/lib/lib/collapseDuplicateDeclarations.js +24 -68
  19. package/lib/lib/content.js +37 -126
  20. package/lib/lib/defaultExtractor.js +94 -199
  21. package/lib/lib/detectNesting.js +12 -36
  22. package/lib/lib/evaluateTailwindFunctions.js +102 -187
  23. package/lib/lib/expandApplyAtRules.js +177 -476
  24. package/lib/lib/expandTailwindAtRules.js +91 -230
  25. package/lib/lib/findAtConfigPath.js +13 -30
  26. package/lib/lib/generateRules.js +351 -761
  27. package/lib/lib/getModuleDependencies.js +50 -40
  28. package/lib/lib/load-config.js +32 -0
  29. package/lib/lib/normalizeTailwindDirectives.js +26 -70
  30. package/lib/lib/offsets.js +61 -224
  31. package/lib/lib/partitionApplyAtRules.js +29 -51
  32. package/lib/lib/regex.js +22 -30
  33. package/lib/lib/remap-bitfield.js +9 -84
  34. package/lib/lib/resolveDefaultsAtRules.js +50 -116
  35. package/lib/lib/setupContextUtils.js +576 -1091
  36. package/lib/lib/setupTrackingContext.js +54 -143
  37. package/lib/lib/sharedState.js +17 -56
  38. package/lib/lib/substituteScreenAtRules.js +8 -16
  39. package/lib/oxide/cli/build/deps.js +17 -32
  40. package/lib/oxide/cli/build/index.js +11 -37
  41. package/lib/oxide/cli/build/plugin.js +92 -263
  42. package/lib/oxide/cli/build/utils.js +18 -39
  43. package/lib/oxide/cli/build/watching.js +34 -148
  44. package/lib/oxide/cli/help/index.js +15 -57
  45. package/lib/oxide/cli/index.js +72 -139
  46. package/lib/oxide/cli/init/index.js +18 -22
  47. package/lib/oxide/cli.js +2 -3
  48. package/lib/plugin.js +10 -74
  49. package/lib/postcss-plugins/nesting/index.js +6 -10
  50. package/lib/postcss-plugins/nesting/plugin.js +17 -60
  51. package/lib/processTailwindFeatures.js +8 -37
  52. package/lib/public/colors.js +59 -44
  53. package/lib/public/create-plugin.js +5 -8
  54. package/lib/public/default-config.js +5 -9
  55. package/lib/public/default-theme.js +5 -9
  56. package/lib/public/load-config.js +8 -0
  57. package/lib/public/resolve-config.js +4 -6
  58. package/lib/util/applyImportantSelector.js +25 -0
  59. package/lib/util/bigSign.js +6 -7
  60. package/lib/util/buildMediaQuery.js +10 -17
  61. package/lib/util/cloneDeep.js +9 -17
  62. package/lib/util/cloneNodes.js +14 -27
  63. package/lib/util/color.js +45 -81
  64. package/lib/util/configurePlugins.js +9 -16
  65. package/lib/util/createPlugin.js +8 -15
  66. package/lib/util/createUtilityPlugin.js +15 -27
  67. package/lib/util/dataTypes.js +23 -141
  68. package/lib/util/defaults.js +9 -19
  69. package/lib/util/escapeClassName.js +6 -10
  70. package/lib/util/escapeCommas.js +6 -7
  71. package/lib/util/flattenColorPalette.js +6 -8
  72. package/lib/util/formatVariantSelector.js +51 -288
  73. package/lib/util/getAllConfigs.js +35 -42
  74. package/lib/util/hashConfig.js +6 -8
  75. package/lib/util/isKeyframeRule.js +6 -7
  76. package/lib/util/isPlainObject.js +8 -11
  77. package/lib/util/isSyntacticallyValidPropertyValue.js +13 -42
  78. package/lib/util/log.js +7 -14
  79. package/lib/util/nameClass.js +6 -21
  80. package/lib/util/negateValue.js +10 -26
  81. package/lib/util/normalizeConfig.js +63 -241
  82. package/lib/util/normalizeScreens.js +70 -137
  83. package/lib/util/parseAnimationValue.js +13 -61
  84. package/lib/util/parseBoxShadowValue.js +12 -57
  85. package/lib/util/parseDependency.js +13 -37
  86. package/lib/util/parseGlob.js +7 -22
  87. package/lib/util/parseObjectStyles.js +17 -26
  88. package/lib/util/pluginUtils.js +72 -191
  89. package/lib/util/prefixSelector.js +11 -28
  90. package/lib/util/pseudoElements.js +147 -0
  91. package/lib/util/removeAlphaVariables.js +8 -21
  92. package/lib/util/resolveConfig.js +103 -220
  93. package/lib/util/resolveConfigPath.js +25 -39
  94. package/lib/util/responsive.js +4 -6
  95. package/lib/util/splitAtTopLevelOnly.js +10 -38
  96. package/lib/util/tap.js +6 -8
  97. package/lib/util/toColorValue.js +6 -7
  98. package/lib/util/toPath.js +8 -26
  99. package/lib/util/transformThemeValue.js +12 -45
  100. package/lib/util/validateConfig.js +17 -14
  101. package/lib/util/validateFormalSyntax.js +5 -11
  102. package/lib/util/withAlphaVariable.js +28 -48
  103. package/loadConfig.d.ts +4 -0
  104. package/loadConfig.js +2 -0
  105. package/package.json +6 -7
  106. package/peers/index.js +14 -16
  107. package/src/cli/build/index.js +7 -7
  108. package/src/cli/build/plugin.js +29 -24
  109. package/src/cli/build/watching.js +4 -2
  110. package/src/cli/index.js +8 -26
  111. package/src/cli/init/index.js +37 -8
  112. package/src/cli.js +1 -1
  113. package/src/corePluginList.js +1 -1
  114. package/src/corePlugins.js +186 -30
  115. package/src/css/preflight.css +2 -0
  116. package/src/featureFlags.js +6 -0
  117. package/src/index.js +1 -5
  118. package/src/lib/defaultExtractor.js +1 -1
  119. package/src/lib/expandApplyAtRules.js +8 -1
  120. package/src/lib/expandTailwindAtRules.js +3 -5
  121. package/src/lib/generateRules.js +35 -15
  122. package/src/lib/getModuleDependencies.js +70 -30
  123. package/src/lib/load-config.ts +31 -0
  124. package/src/lib/setupContextUtils.js +9 -2
  125. package/src/lib/setupTrackingContext.js +4 -4
  126. package/src/lib/sharedState.js +13 -19
  127. package/src/oxide/cli/build/index.ts +7 -7
  128. package/src/oxide/cli/build/plugin.ts +29 -23
  129. package/src/oxide/cli/build/watching.ts +1 -1
  130. package/src/oxide/cli/index.ts +7 -15
  131. package/src/oxide/cli/init/index.ts +34 -7
  132. package/src/plugin.js +1 -1
  133. package/src/public/colors.js +22 -0
  134. package/src/public/default-config.js +1 -1
  135. package/src/public/default-theme.js +2 -2
  136. package/src/public/load-config.js +2 -0
  137. package/src/util/applyImportantSelector.js +27 -0
  138. package/src/util/dataTypes.js +4 -0
  139. package/src/util/formatVariantSelector.js +3 -99
  140. package/src/util/getAllConfigs.js +2 -2
  141. package/src/util/normalizeConfig.js +2 -1
  142. package/src/util/pluginUtils.js +16 -31
  143. package/src/util/pseudoElements.js +170 -0
  144. package/src/util/resolveConfigPath.js +12 -1
  145. package/src/util/splitAtTopLevelOnly.js +8 -1
  146. package/src/util/validateConfig.js +13 -0
  147. package/stubs/.gitignore +1 -0
  148. package/stubs/.prettierrc.json +6 -0
  149. package/stubs/{defaultConfig.stub.js → config.full.js} +38 -3
  150. package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -1
  151. package/stubs/postcss.config.js +6 -0
  152. package/stubs/tailwind.config.cjs +2 -0
  153. package/stubs/tailwind.config.js +2 -0
  154. package/stubs/tailwind.config.ts +3 -0
  155. package/types/config.d.ts +8 -7
  156. package/types/generated/colors.d.ts +22 -0
  157. package/types/generated/corePluginList.d.ts +1 -1
  158. package/types/generated/default-theme.d.ts +31 -2
  159. package/lib/constants.js +0 -44
  160. package/oxide-node-api-shim/index.js +0 -21
  161. package/oxide-node-api-shim/package.json +0 -5
  162. package/src/constants.js +0 -17
  163. /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
@@ -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,48 +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 _pluginJs = require("./plugin.js");
8
+ const _fs = _interopRequireDefault(require("fs")), _path = _interopRequireDefault(require("path")), _resolveConfigPathJs = require("../../util/resolveConfigPath.js"), _pluginJs = require("./plugin.js");
13
9
  function _interopRequireDefault(obj) {
14
10
  return obj && obj.__esModule ? obj : {
15
11
  default: obj
16
12
  };
17
13
  }
18
- async function build(args, configs) {
19
- let input = args["--input"];
20
- let shouldWatch = args["--watch"];
21
- // TODO: Deprecate this in future versions
22
- if (!input && args["_"][1]) {
23
- console.error("[deprecation] Running tailwindcss without -i, please provide an input file.");
24
- input = args["--input"] = args["_"][1];
25
- }
26
- if (input && input !== "-" && !_fs.default.existsSync(input = _path.default.resolve(input))) {
27
- console.error(`Specified input file ${args["--input"]} does not exist.`);
28
- process.exit(9);
29
- }
30
- if (args["--config"] && !_fs.default.existsSync(args["--config"] = _path.default.resolve(args["--config"]))) {
31
- console.error(`Specified config file ${args["--config"]} does not exist.`);
32
- process.exit(9);
33
- }
34
- // TODO: Reference the @config path here if exists
35
- let configPath = args["--config"] ? args["--config"] : ((defaultPath)=>_fs.default.existsSync(defaultPath) ? defaultPath : null)(_path.default.resolve(`./${configs.tailwind}`));
36
- let processor = await (0, _pluginJs.createProcessor)(args, configPath);
37
- if (shouldWatch) {
38
- // Abort the watcher if stdin is closed to avoid zombie processes
39
- // You can disable this behavior with --watch=always
40
- if (args["--watch"] !== "always") {
41
- process.stdin.on("end", ()=>process.exit(0));
42
- }
43
- process.stdin.resume();
44
- await processor.watch();
45
- } else {
46
- await processor.build();
47
- }
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
+ });
48
21
  }
@@ -1,120 +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 _getModuleDependenciesJs = /*#__PURE__*/ _interopRequireDefault(require("../../lib/getModuleDependencies.js"));
24
- const _contentJs = require("../../lib/content.js");
25
- const _watchingJs = require("./watching.js");
26
- const _fastGlob = /*#__PURE__*/ _interopRequireDefault(require("fast-glob"));
27
- const _findAtConfigPathJs = require("../../lib/findAtConfigPath.js");
28
- const _log = /*#__PURE__*/ _interopRequireDefault(require("../../util/log"));
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"));
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
- configDependencies: new Set(),
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, _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);
118
39
  },
119
40
  get config () {
120
41
  return this.context.tailwindConfig;
@@ -122,164 +43,105 @@ 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(configPath);
131
- }
132
- let config = configPath ? require(configPath) : {};
133
- // @ts-ignore
134
- config = (0, _resolveConfigJs.default)(config, {
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, {
135
59
  content: {
136
60
  files: []
137
61
  }
138
- });
139
- // Override content files if `--content` has been passed explicitly
140
- if ((content === null || content === void 0 ? void 0 : content.length) > 0) {
141
- config.content.files = content;
142
- }
143
- return config;
62
+ }), (null == content ? void 0 : content.length) > 0 && (this.configBag.config.content.files = content), this.configBag.config;
144
63
  },
145
- refreshConfigDependencies (configPath) {
146
- _sharedState.env.DEBUG && console.time("Module dependencies");
147
- for (let file of this.configDependencies){
148
- delete require.cache[require.resolve(file)];
149
- }
150
- if (configPath) {
151
- let deps = (0, _getModuleDependenciesJs.default)(configPath).map(({ file })=>file);
152
- for (let dependency of deps){
153
- this.configDependencies.add(dependency);
154
- }
155
- }
156
- _sharedState.env.DEBUG && console.timeEnd("Module dependencies");
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");
157
67
  },
158
68
  readContentPaths () {
159
69
  let content = [];
160
- // Resolve globs from the content config
161
- // TODO: When we make the postcss plugin async-capable this can become async
162
- let files = _fastGlob.default.sync(this.contentPatterns.all);
163
- for (let file of files){
164
- if (_sharedState.env.OXIDE) {
165
- content.push({
166
- file,
167
- extension: _path.default.extname(file).slice(1)
168
- });
169
- } else {
170
- content.push({
171
- content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
172
- extension: _path.default.extname(file).slice(1)
173
- });
174
- }
175
- }
176
- // Resolve raw content in the tailwind config
177
- let rawContent = this.config.content.files.filter((file)=>{
178
- return file !== null && typeof file === "object";
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
179
77
  });
180
- for (let { raw: htmlContent , extension ="html" } of rawContent){
181
- content.push({
182
- content: htmlContent,
183
- extension
184
- });
185
- }
186
78
  return content;
187
79
  },
188
80
  getContext ({ createContext , cliConfigPath , root , result , content }) {
189
- if (this.context) {
190
- this.context.changedContent = this.changedContent.splice(0);
191
- return this.context;
192
- }
193
- _sharedState.env.DEBUG && console.time("Searching for config");
194
81
  var _findAtConfigPath;
195
- let configPath = (_findAtConfigPath = (0, _findAtConfigPathJs.findAtConfigPath)(root, result)) !== null && _findAtConfigPath !== void 0 ? _findAtConfigPath : cliConfigPath;
196
- _sharedState.env.DEBUG && console.timeEnd("Searching for config");
197
- _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");
198
86
  let config = this.loadConfig(configPath, content);
199
- _sharedState.env.DEBUG && console.timeEnd("Loading config");
200
- _sharedState.env.DEBUG && console.time("Creating context");
201
- this.context = createContext(config, []);
202
- 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, {
203
88
  userConfigPath: configPath
204
- });
205
- _sharedState.env.DEBUG && console.timeEnd("Creating context");
206
- _sharedState.env.DEBUG && console.time("Resolving content paths");
207
- this.refreshContentPaths();
208
- _sharedState.env.DEBUG && console.timeEnd("Resolving content paths");
209
- if (this.watcher) {
210
- _sharedState.env.DEBUG && console.time("Watch new files");
211
- this.watcher.refreshWatchedFiles();
212
- _sharedState.env.DEBUG && console.timeEnd("Watch new files");
213
- }
214
- for (let file of this.readContentPaths()){
215
- this.context.changedContent.push(file);
216
- }
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);
217
90
  return this.context;
218
91
  }
219
92
  };
220
93
  async function createProcessor(args, cliConfigPath) {
221
- var _args_content;
222
- let postcss = (0, _deps.loadPostcss)();
223
- let input = args["--input"];
224
- let output = args["--output"];
225
- let includePostCss = args["--postcss"];
226
- let customPostCssPath = typeof args["--postcss"] === "string" ? args["--postcss"] : undefined;
227
- let [beforePlugins, afterPlugins, postcssOptions] = includePostCss ? await loadPostCssPlugins(customPostCssPath) : loadBuiltinPostcssPlugins();
228
- if (args["--purge"]) {
229
- _log.default.warn("purge-flag-deprecated", [
230
- "The `--purge` flag has been deprecated.",
231
- "Please use `--content` instead."
232
- ]);
233
- if (!args["--content"]) {
234
- args["--content"] = args["--purge"];
235
- }
236
- }
237
- var _args_content_split;
238
- 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 : [];
239
- let tailwindPlugin = ()=>{
240
- 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 = ()=>({
241
123
  postcssPlugin: "tailwindcss",
242
124
  Once (root, { result }) {
243
- _sharedState.env.DEBUG && console.time("Compiling CSS");
244
- (0, _processTailwindFeatures.default)(({ createContext })=>{
245
- console.error();
246
- console.error("Rebuilding...");
247
- return ()=>{
248
- return state.getContext({
125
+ _sharedState.env.DEBUG && console.time("Compiling CSS"), (0, _processTailwindFeatures.default)(({ createContext })=>(console.error(), console.error("Rebuilding..."), ()=>state.getContext({
249
126
  createContext,
250
127
  cliConfigPath,
251
128
  root,
252
129
  result,
253
130
  content
254
- });
255
- };
256
- })(root, result);
257
- _sharedState.env.DEBUG && console.timeEnd("Compiling CSS");
131
+ })))(root, result), _sharedState.env.DEBUG && console.timeEnd("Compiling CSS");
258
132
  }
259
- };
260
- };
261
- tailwindPlugin.postcss = true;
262
- let plugins = [
133
+ });
134
+ tailwindPlugin.postcss = !0;
135
+ let processor = postcss1([
263
136
  ...beforePlugins,
264
137
  tailwindPlugin,
265
138
  !args["--minify"] && _utils.formatNodes,
266
139
  ...afterPlugins,
267
140
  !args["--no-autoprefixer"] && (0, _deps.loadAutoprefixer)(),
268
141
  args["--minify"] && (0, _deps.loadCssNano)()
269
- ].filter(Boolean);
270
- /** @type {import('postcss').Processor} */ // @ts-ignore
271
- let processor = postcss(plugins);
142
+ ].filter(Boolean));
272
143
  async function readInput() {
273
- // Piping in data, let's drain the stdin
274
- if (input === "-") {
275
- return (0, _utils.drainStdin)();
276
- }
277
- // Input file has been provided
278
- if (input) {
279
- return _fs.default.promises.readFile(_path.default.resolve(input), "utf8");
280
- }
281
- // No input file provided, fallback to default atrules
282
- 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";
283
145
  }
284
146
  async function build() {
285
147
  let start = process.hrtime.bigint();
@@ -288,21 +150,9 @@ async function createProcessor(args, cliConfigPath) {
288
150
  from: input,
289
151
  to: output
290
152
  })).then((result)=>{
291
- if (!state.watcher) {
292
- return result;
293
- }
294
- _sharedState.env.DEBUG && console.time("Recording PostCSS dependencies");
295
- for (let message of result.messages){
296
- if (message.type === "dependency") {
297
- state.contextDependencies.add(message.file);
298
- }
299
- }
300
- _sharedState.env.DEBUG && console.timeEnd("Recording PostCSS dependencies");
301
- // TODO: This needs to be in a different spot
302
- _sharedState.env.DEBUG && console.time("Watch new files");
303
- state.watcher.refreshWatchedFiles();
304
- _sharedState.env.DEBUG && console.timeEnd("Watch new files");
305
- 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;
306
156
  }).then((result)=>{
307
157
  if (!output) {
308
158
  process.stdout.write(result.css);
@@ -314,54 +164,32 @@ async function createProcessor(args, cliConfigPath) {
314
164
  ]);
315
165
  }).then(()=>{
316
166
  let end = process.hrtime.bigint();
317
- console.error();
318
- console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
167
+ console.error(), console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
319
168
  }).then(()=>{}, (err)=>{
320
- // TODO: If an initial build fails we can't easily pick up any PostCSS dependencies
321
- // that were collected before the error occurred
322
- // The result is not stored on the error so we have to store it externally
323
- // and pull the messages off of it here somehow
324
- // This results in a less than ideal DX because the watcher will not pick up
325
- // changes to imported CSS if one of them caused an error during the initial build
326
- // If you fix it and then save the main CSS file so there's no error
327
- // The watcher will start watching the imported CSS files and will be
328
- // resilient to future errors.
169
+ if (!state.watcher) return Promise.reject(err);
329
170
  console.error(err);
330
171
  });
331
172
  }
332
- /**
333
- * @param {{file: string, content(): Promise<string>, extension: string}[]} changes
334
- */ async function parseChanges(changes) {
173
+ async function parseChanges(changes) {
335
174
  return Promise.all(changes.map(async (change)=>({
336
175
  content: await change.content(),
337
176
  extension: change.extension
338
177
  })));
339
178
  }
340
- if (input !== undefined && input !== "-") {
341
- state.contextDependencies.add(_path.default.resolve(input));
342
- }
343
- return {
179
+ return void 0 !== input && "-" !== input && state.contextDependencies.add(_path.default.resolve(input)), {
344
180
  build,
345
181
  watch: async ()=>{
346
182
  state.watcher = (0, _watchingJs.createWatcher)(args, {
347
183
  state,
348
- /**
349
- * @param {{file: string, content(): Promise<string>, extension: string}[]} changes
350
- */ async rebuild (changes) {
351
- let needsNewContext = changes.some((change)=>{
352
- return state.configDependencies.has(change.file) || state.contextDependencies.has(change.file);
353
- });
354
- if (needsNewContext) {
355
- state.context = null;
356
- } else {
357
- for (let change of (await parseChanges(changes))){
358
- state.changedContent.push(change);
359
- }
360
- }
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);
361
190
  return build();
362
191
  }
363
- });
364
- await build();
192
+ }), await build();
365
193
  }
366
194
  };
367
195
  }