tailwindcss 3.1.8 → 3.2.1

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 (101) hide show
  1. package/CHANGELOG.md +64 -3
  2. package/README.md +6 -5
  3. package/lib/cli/build/deps.js +54 -0
  4. package/lib/cli/build/index.js +44 -0
  5. package/lib/cli/build/plugin.js +351 -0
  6. package/lib/cli/build/utils.js +78 -0
  7. package/lib/cli/build/watching.js +113 -0
  8. package/lib/cli/help/index.js +71 -0
  9. package/lib/cli/index.js +18 -0
  10. package/lib/cli/init/index.js +46 -0
  11. package/lib/cli/shared.js +12 -0
  12. package/lib/cli.js +11 -590
  13. package/lib/corePlugins.js +332 -108
  14. package/lib/css/preflight.css +5 -0
  15. package/lib/featureFlags.js +7 -4
  16. package/lib/index.js +6 -1
  17. package/lib/lib/content.js +167 -0
  18. package/lib/lib/defaultExtractor.js +15 -10
  19. package/lib/lib/detectNesting.js +2 -2
  20. package/lib/lib/evaluateTailwindFunctions.js +17 -1
  21. package/lib/lib/expandApplyAtRules.js +66 -37
  22. package/lib/lib/expandTailwindAtRules.js +10 -42
  23. package/lib/lib/findAtConfigPath.js +44 -0
  24. package/lib/lib/generateRules.js +180 -93
  25. package/lib/lib/normalizeTailwindDirectives.js +1 -1
  26. package/lib/lib/offsets.js +217 -0
  27. package/lib/lib/regex.js +1 -1
  28. package/lib/lib/setupContextUtils.js +339 -100
  29. package/lib/lib/setupTrackingContext.js +5 -39
  30. package/lib/lib/sharedState.js +2 -0
  31. package/lib/public/colors.js +1 -1
  32. package/lib/util/buildMediaQuery.js +6 -3
  33. package/lib/util/configurePlugins.js +1 -1
  34. package/lib/util/dataTypes.js +15 -19
  35. package/lib/util/formatVariantSelector.js +92 -8
  36. package/lib/util/getAllConfigs.js +14 -3
  37. package/lib/util/isValidArbitraryValue.js +1 -1
  38. package/lib/util/nameClass.js +3 -0
  39. package/lib/util/negateValue.js +15 -2
  40. package/lib/util/normalizeConfig.js +17 -3
  41. package/lib/util/normalizeScreens.js +100 -3
  42. package/lib/util/parseAnimationValue.js +1 -1
  43. package/lib/util/parseBoxShadowValue.js +1 -1
  44. package/lib/util/parseDependency.js +33 -54
  45. package/lib/util/parseGlob.js +34 -0
  46. package/lib/util/parseObjectStyles.js +1 -1
  47. package/lib/util/pluginUtils.js +87 -17
  48. package/lib/util/resolveConfig.js +2 -2
  49. package/lib/util/splitAtTopLevelOnly.js +31 -81
  50. package/lib/util/transformThemeValue.js +9 -2
  51. package/lib/util/validateConfig.js +1 -1
  52. package/lib/util/validateFormalSyntax.js +24 -0
  53. package/package.json +14 -13
  54. package/peers/index.js +3263 -1887
  55. package/plugin.d.ts +3 -3
  56. package/scripts/release-channel.js +18 -0
  57. package/scripts/release-notes.js +21 -0
  58. package/src/cli/build/deps.js +56 -0
  59. package/src/cli/build/index.js +45 -0
  60. package/src/cli/build/plugin.js +417 -0
  61. package/src/cli/build/utils.js +76 -0
  62. package/src/cli/build/watching.js +134 -0
  63. package/src/cli/help/index.js +70 -0
  64. package/src/cli/index.js +3 -0
  65. package/src/cli/init/index.js +50 -0
  66. package/src/cli/shared.js +5 -0
  67. package/src/cli.js +4 -696
  68. package/src/corePlugins.js +262 -39
  69. package/src/css/preflight.css +5 -0
  70. package/src/featureFlags.js +12 -2
  71. package/src/index.js +5 -0
  72. package/src/lib/content.js +205 -0
  73. package/src/lib/defaultExtractor.js +3 -0
  74. package/src/lib/evaluateTailwindFunctions.js +22 -1
  75. package/src/lib/expandApplyAtRules.js +70 -29
  76. package/src/lib/expandTailwindAtRules.js +8 -46
  77. package/src/lib/findAtConfigPath.js +48 -0
  78. package/src/lib/generateRules.js +223 -101
  79. package/src/lib/offsets.js +270 -0
  80. package/src/lib/setupContextUtils.js +376 -89
  81. package/src/lib/setupTrackingContext.js +4 -45
  82. package/src/lib/sharedState.js +2 -0
  83. package/src/util/buildMediaQuery.js +5 -3
  84. package/src/util/dataTypes.js +15 -17
  85. package/src/util/formatVariantSelector.js +113 -9
  86. package/src/util/getAllConfigs.js +14 -2
  87. package/src/util/nameClass.js +4 -0
  88. package/src/util/negateValue.js +10 -2
  89. package/src/util/normalizeConfig.js +22 -2
  90. package/src/util/normalizeScreens.js +99 -4
  91. package/src/util/parseBoxShadowValue.js +1 -1
  92. package/src/util/parseDependency.js +37 -42
  93. package/src/util/parseGlob.js +24 -0
  94. package/src/util/pluginUtils.js +96 -14
  95. package/src/util/resolveConfig.js +1 -1
  96. package/src/util/splitAtTopLevelOnly.js +23 -49
  97. package/src/util/transformThemeValue.js +9 -1
  98. package/src/util/validateFormalSyntax.js +34 -0
  99. package/stubs/defaultConfig.stub.js +20 -3
  100. package/types/config.d.ts +48 -13
  101. package/types/generated/default-theme.d.ts +11 -0
@@ -0,0 +1,113 @@
1
+ // @ts-check
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "createWatcher", {
7
+ enumerable: true,
8
+ get: ()=>createWatcher
9
+ });
10
+ const _chokidar = /*#__PURE__*/ _interopRequireDefault(require("chokidar"));
11
+ const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
12
+ const _micromatch = /*#__PURE__*/ _interopRequireDefault(require("micromatch"));
13
+ const _normalizePath = /*#__PURE__*/ _interopRequireDefault(require("normalize-path"));
14
+ const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
15
+ const _utilsJs = require("./utils.js");
16
+ function _interopRequireDefault(obj) {
17
+ return obj && obj.__esModule ? obj : {
18
+ default: obj
19
+ };
20
+ }
21
+ function createWatcher(args, { state , rebuild }) {
22
+ let shouldPoll = args["--poll"];
23
+ let shouldCoalesceWriteEvents = shouldPoll || process.platform === "win32";
24
+ // Polling interval in milliseconds
25
+ // Used only when polling or coalescing add/change events on Windows
26
+ let pollInterval = 10;
27
+ let watcher = _chokidar.default.watch([], {
28
+ // Force checking for atomic writes in all situations
29
+ // This causes chokidar to wait up to 100ms for a file to re-added after it's been unlinked
30
+ // This only works when watching directories though
31
+ atomic: true,
32
+ usePolling: shouldPoll,
33
+ interval: shouldPoll ? pollInterval : undefined,
34
+ ignoreInitial: true,
35
+ awaitWriteFinish: shouldCoalesceWriteEvents ? {
36
+ stabilityThreshold: 50,
37
+ pollInterval: pollInterval
38
+ } : false
39
+ });
40
+ let chain = Promise.resolve();
41
+ let pendingRebuilds = new Set();
42
+ let changedContent = [];
43
+ /**
44
+ *
45
+ * @param {*} file
46
+ * @param {(() => Promise<string>) | null} content
47
+ */ function recordChangedFile(file, content = null) {
48
+ file = _path.default.resolve(file);
49
+ content = content !== null && content !== void 0 ? content : async ()=>await _fs.default.promises.readFile(file, "utf8");
50
+ changedContent.push({
51
+ file,
52
+ content,
53
+ extension: _path.default.extname(file).slice(1)
54
+ });
55
+ chain = chain.then(()=>rebuild(changedContent.splice(0)));
56
+ return chain;
57
+ }
58
+ watcher.on("change", (file)=>recordChangedFile(file));
59
+ watcher.on("add", (file)=>recordChangedFile(file));
60
+ // Restore watching any files that are "removed"
61
+ // This can happen when a file is pseudo-atomically replaced (a copy is created, overwritten, the old one is unlinked, and the new one is renamed)
62
+ // TODO: An an optimization we should allow removal when the config changes
63
+ watcher.on("unlink", (file)=>{
64
+ file = (0, _normalizePath.default)(file);
65
+ // Only re-add the file if it's not covered by a dynamic pattern
66
+ if (!_micromatch.default.some([
67
+ file
68
+ ], state.contentPatterns.dynamic)) {
69
+ watcher.add(file);
70
+ }
71
+ });
72
+ // Some applications such as Visual Studio (but not VS Code)
73
+ // will only fire a rename event for atomic writes and not a change event
74
+ // This is very likely a chokidar bug but it's one we need to work around
75
+ // We treat this as a change event and rebuild the CSS
76
+ watcher.on("raw", (evt, filePath, meta)=>{
77
+ if (evt !== "rename") {
78
+ return;
79
+ }
80
+ let watchedPath = meta.watchedPath;
81
+ // Watched path might be the file itself
82
+ // Or the directory it is in
83
+ filePath = watchedPath.endsWith(filePath) ? watchedPath : _path.default.join(watchedPath, filePath);
84
+ // Skip this event since the files it is for does not match any of the registered content globs
85
+ if (!_micromatch.default.some([
86
+ filePath
87
+ ], state.contentPatterns.all)) {
88
+ return;
89
+ }
90
+ // Skip since we've already queued a rebuild for this file that hasn't happened yet
91
+ if (pendingRebuilds.has(filePath)) {
92
+ return;
93
+ }
94
+ pendingRebuilds.add(filePath);
95
+ chain = chain.then(async ()=>{
96
+ let content;
97
+ try {
98
+ content = await (0, _utilsJs.readFileWithRetries)(_path.default.resolve(filePath));
99
+ } finally{
100
+ pendingRebuilds.delete(filePath);
101
+ }
102
+ return recordChangedFile(filePath, ()=>content);
103
+ });
104
+ });
105
+ return {
106
+ fswatcher: watcher,
107
+ refreshWatchedFiles () {
108
+ watcher.add(Array.from(state.contextDependencies));
109
+ watcher.add(Array.from(state.configDependencies));
110
+ watcher.add(state.contentPatterns.all);
111
+ }
112
+ };
113
+ }
@@ -0,0 +1,71 @@
1
+ // @ts-check
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "help", {
7
+ enumerable: true,
8
+ get: ()=>help
9
+ });
10
+ const _packageJson = /*#__PURE__*/ _interopRequireDefault(require("../../../package.json"));
11
+ function _interopRequireDefault(obj) {
12
+ return obj && obj.__esModule ? obj : {
13
+ default: obj
14
+ };
15
+ }
16
+ function help({ message , usage , commands , options }) {
17
+ let indent = 2;
18
+ // Render header
19
+ console.log();
20
+ console.log(`${_packageJson.default.name} v${_packageJson.default.version}`);
21
+ // Render message
22
+ if (message) {
23
+ console.log();
24
+ for (let msg of message.split("\n")){
25
+ console.log(msg);
26
+ }
27
+ }
28
+ // Render usage
29
+ if (usage && usage.length > 0) {
30
+ console.log();
31
+ console.log("Usage:");
32
+ for (let example of usage){
33
+ console.log(" ".repeat(indent), example);
34
+ }
35
+ }
36
+ // Render commands
37
+ if (commands && commands.length > 0) {
38
+ console.log();
39
+ console.log("Commands:");
40
+ for (let command of commands){
41
+ console.log(" ".repeat(indent), command);
42
+ }
43
+ }
44
+ // Render options
45
+ if (options) {
46
+ let groupedOptions = {};
47
+ for (let [key, value] of Object.entries(options)){
48
+ if (typeof value === "object") {
49
+ groupedOptions[key] = {
50
+ ...value,
51
+ flags: [
52
+ key
53
+ ]
54
+ };
55
+ } else {
56
+ groupedOptions[value].flags.push(key);
57
+ }
58
+ }
59
+ console.log();
60
+ console.log("Options:");
61
+ for (let { flags , description , deprecated } of Object.values(groupedOptions)){
62
+ if (deprecated) continue;
63
+ if (flags.length === 1) {
64
+ console.log(" ".repeat(indent + 4 /* 4 = "-i, ".length */ ), flags.slice().reverse().join(", ").padEnd(20, " "), description);
65
+ } else {
66
+ console.log(" ".repeat(indent), flags.slice().reverse().join(", ").padEnd(24, " "), description);
67
+ }
68
+ }
69
+ }
70
+ console.log();
71
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ _exportStar(require("./build"), exports);
6
+ _exportStar(require("./config"), exports);
7
+ _exportStar(require("./content"), exports);
8
+ function _exportStar(from, to) {
9
+ Object.keys(from).forEach(function(k) {
10
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
11
+ enumerable: true,
12
+ get: function() {
13
+ return from[k];
14
+ }
15
+ });
16
+ });
17
+ return from;
18
+ }
@@ -0,0 +1,46 @@
1
+ // @ts-check
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "init", {
7
+ enumerable: true,
8
+ get: ()=>init
9
+ });
10
+ const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
11
+ const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
12
+ function _interopRequireDefault(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
17
+ function init(args, configs) {
18
+ let messages = [];
19
+ var ref;
20
+ let tailwindConfigLocation = _path.default.resolve((ref = args["_"][1]) !== null && ref !== void 0 ? ref : `./${configs.tailwind}`);
21
+ if (_fs.default.existsSync(tailwindConfigLocation)) {
22
+ messages.push(`${_path.default.basename(tailwindConfigLocation)} already exists.`);
23
+ } else {
24
+ let stubFile = _fs.default.readFileSync(args["--full"] ? _path.default.resolve(__dirname, "../../../stubs/defaultConfig.stub.js") : _path.default.resolve(__dirname, "../../../stubs/simpleConfig.stub.js"), "utf8");
25
+ // Change colors import
26
+ stubFile = stubFile.replace("../colors", "tailwindcss/colors");
27
+ _fs.default.writeFileSync(tailwindConfigLocation, stubFile, "utf8");
28
+ messages.push(`Created Tailwind CSS config file: ${_path.default.basename(tailwindConfigLocation)}`);
29
+ }
30
+ if (args["--postcss"]) {
31
+ let postcssConfigLocation = _path.default.resolve(`./${configs.postcss}`);
32
+ if (_fs.default.existsSync(postcssConfigLocation)) {
33
+ messages.push(`${_path.default.basename(postcssConfigLocation)} already exists.`);
34
+ } else {
35
+ let stubFile1 = _fs.default.readFileSync(_path.default.resolve(__dirname, "../../../stubs/defaultPostCssConfig.stub.js"), "utf8");
36
+ _fs.default.writeFileSync(postcssConfigLocation, stubFile1, "utf8");
37
+ messages.push(`Created PostCSS config file: ${_path.default.basename(postcssConfigLocation)}`);
38
+ }
39
+ }
40
+ if (messages.length > 0) {
41
+ console.log();
42
+ for (let message of messages){
43
+ console.log(message);
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "env", {
7
+ enumerable: true,
8
+ get: ()=>env
9
+ });
10
+ const env = {
11
+ DEBUG: process.env.DEBUG !== undefined && process.env.DEBUG !== "0"
12
+ };