tailwindcss 3.4.0 → 3.4.2

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 (69) hide show
  1. package/CHANGELOG.md +40 -1
  2. package/README.md +2 -3
  3. package/lib/cli/build/plugin.js +4 -11
  4. package/lib/cli.js +1 -5
  5. package/lib/corePluginList.js +1 -0
  6. package/lib/corePlugins.js +92 -25
  7. package/lib/css/preflight.css +4 -3
  8. package/lib/featureFlags.js +2 -6
  9. package/lib/lib/content.js +36 -3
  10. package/lib/lib/defaultExtractor.js +2 -2
  11. package/lib/lib/expandApplyAtRules.js +13 -0
  12. package/lib/lib/expandTailwindAtRules.js +20 -32
  13. package/lib/lib/generateRules.js +13 -2
  14. package/lib/lib/load-config.js +4 -0
  15. package/lib/lib/offsets.js +51 -2
  16. package/lib/lib/resolveDefaultsAtRules.js +3 -1
  17. package/lib/lib/setupContextUtils.js +23 -3
  18. package/lib/lib/sharedState.js +2 -10
  19. package/lib/plugin.js +0 -50
  20. package/lib/processTailwindFeatures.js +0 -2
  21. package/lib/util/dataTypes.js +12 -2
  22. package/lib/util/pseudoElements.js +3 -0
  23. package/package.json +5 -8
  24. package/peers/index.js +61 -61
  25. package/src/cli/build/plugin.js +4 -11
  26. package/src/cli.js +1 -5
  27. package/src/corePluginList.js +1 -1
  28. package/src/corePlugins.js +88 -27
  29. package/src/css/preflight.css +4 -3
  30. package/src/featureFlags.js +2 -6
  31. package/src/lib/content.js +42 -1
  32. package/src/lib/defaultExtractor.js +2 -2
  33. package/src/lib/expandApplyAtRules.js +17 -0
  34. package/src/lib/expandTailwindAtRules.js +23 -41
  35. package/src/lib/generateRules.js +12 -2
  36. package/src/lib/load-config.ts +5 -0
  37. package/src/lib/offsets.js +61 -2
  38. package/src/lib/resolveDefaultsAtRules.js +5 -1
  39. package/src/lib/setupContextUtils.js +28 -2
  40. package/src/lib/sharedState.js +0 -4
  41. package/src/plugin.js +0 -60
  42. package/src/processTailwindFeatures.js +0 -3
  43. package/src/util/dataTypes.js +13 -1
  44. package/src/util/pseudoElements.js +4 -0
  45. package/types/config.d.ts +7 -0
  46. package/types/generated/corePluginList.d.ts +1 -1
  47. package/lib/lib/detectNesting.js +0 -45
  48. package/lib/oxide/cli/build/deps.js +0 -89
  49. package/lib/oxide/cli/build/index.js +0 -53
  50. package/lib/oxide/cli/build/plugin.js +0 -375
  51. package/lib/oxide/cli/build/utils.js +0 -87
  52. package/lib/oxide/cli/build/watching.js +0 -179
  53. package/lib/oxide/cli/help/index.js +0 -72
  54. package/lib/oxide/cli/index.js +0 -214
  55. package/lib/oxide/cli/init/index.js +0 -52
  56. package/lib/oxide/cli.js +0 -5
  57. package/lib/oxide/postcss-plugin.js +0 -2
  58. package/scripts/swap-engines.js +0 -40
  59. package/src/lib/detectNesting.js +0 -47
  60. package/src/oxide/cli/build/deps.ts +0 -91
  61. package/src/oxide/cli/build/index.ts +0 -47
  62. package/src/oxide/cli/build/plugin.ts +0 -442
  63. package/src/oxide/cli/build/utils.ts +0 -74
  64. package/src/oxide/cli/build/watching.ts +0 -225
  65. package/src/oxide/cli/help/index.ts +0 -69
  66. package/src/oxide/cli/index.ts +0 -204
  67. package/src/oxide/cli/init/index.ts +0 -59
  68. package/src/oxide/cli.ts +0 -1
  69. package/src/oxide/postcss-plugin.ts +0 -1
@@ -762,13 +762,29 @@ function resolvePlugins(context, root) {
762
762
  _corePlugins.variantPlugins["supportsVariants"],
763
763
  _corePlugins.variantPlugins["reducedMotionVariants"],
764
764
  _corePlugins.variantPlugins["prefersContrastVariants"],
765
- _corePlugins.variantPlugins["printVariant"],
766
765
  _corePlugins.variantPlugins["screenVariants"],
767
766
  _corePlugins.variantPlugins["orientationVariants"],
768
767
  _corePlugins.variantPlugins["directionVariants"],
769
768
  _corePlugins.variantPlugins["darkVariants"],
770
- _corePlugins.variantPlugins["forcedColorsVariants"]
769
+ _corePlugins.variantPlugins["forcedColorsVariants"],
770
+ _corePlugins.variantPlugins["printVariant"]
771
771
  ];
772
+ // This is a compatibility fix for the pre 3.4 dark mode behavior
773
+ // `class` retains the old behavior, but `selector` keeps the new behavior
774
+ let isLegacyDarkMode = context.tailwindConfig.darkMode === "class" || Array.isArray(context.tailwindConfig.darkMode) && context.tailwindConfig.darkMode[0] === "class";
775
+ if (isLegacyDarkMode) {
776
+ afterVariants = [
777
+ _corePlugins.variantPlugins["supportsVariants"],
778
+ _corePlugins.variantPlugins["reducedMotionVariants"],
779
+ _corePlugins.variantPlugins["prefersContrastVariants"],
780
+ _corePlugins.variantPlugins["darkVariants"],
781
+ _corePlugins.variantPlugins["screenVariants"],
782
+ _corePlugins.variantPlugins["orientationVariants"],
783
+ _corePlugins.variantPlugins["directionVariants"],
784
+ _corePlugins.variantPlugins["forcedColorsVariants"],
785
+ _corePlugins.variantPlugins["printVariant"]
786
+ ];
787
+ }
772
788
  return [
773
789
  ...corePluginList,
774
790
  ...beforeVariants,
@@ -1005,6 +1021,10 @@ function registerPlugins(plugins, context) {
1005
1021
  };
1006
1022
  // Generate a list of available variants with meta information of the type of variant.
1007
1023
  context.getVariants = function getVariants() {
1024
+ // We use a unique, random ID for candidate names to avoid conflicts
1025
+ // We can't use characters like `_`, `:`, `@` or `.` because they might
1026
+ // be used as a separator
1027
+ let id = Math.random().toString(36).substring(7).toUpperCase();
1008
1028
  let result = [];
1009
1029
  for (let [name, options] of context.variantOptions.entries()){
1010
1030
  if (options.variantInfo === VARIANT_INFO.Base) continue;
@@ -1015,7 +1035,7 @@ function registerPlugins(plugins, context) {
1015
1035
  values: Object.keys((_options_values = options.values) !== null && _options_values !== void 0 ? _options_values : {}),
1016
1036
  hasDash: name !== "@",
1017
1037
  selectors ({ modifier , value } = {}) {
1018
- let candidate = "__TAILWIND_PLACEHOLDER__";
1038
+ let candidate = `TAILWINDPLACEHOLDER${id}`;
1019
1039
  let rule = _postcss.default.rule({
1020
1040
  selector: `.${candidate}`
1021
1041
  });
@@ -34,20 +34,12 @@ _export(exports, {
34
34
  return resolveDebug;
35
35
  }
36
36
  });
37
- const _packagejson = /*#__PURE__*/ _interop_require_default(require("../../package.json"));
38
- function _interop_require_default(obj) {
39
- return obj && obj.__esModule ? obj : {
40
- default: obj
41
- };
42
- }
43
37
  const env = typeof process !== "undefined" ? {
44
38
  NODE_ENV: process.env.NODE_ENV,
45
- DEBUG: resolveDebug(process.env.DEBUG),
46
- ENGINE: _packagejson.default.tailwindcss.engine
39
+ DEBUG: resolveDebug(process.env.DEBUG)
47
40
  } : {
48
41
  NODE_ENV: "production",
49
- DEBUG: false,
50
- ENGINE: _packagejson.default.tailwindcss.engine
42
+ DEBUG: false
51
43
  };
52
44
  const contextMap = new Map();
53
45
  const configContextMap = new Map();
package/lib/plugin.js CHANGED
@@ -37,56 +37,6 @@ module.exports = function tailwindcss(configOrPath) {
37
37
  }
38
38
  await (0, _processTailwindFeatures.default)(context)(root, result);
39
39
  },
40
- false && function lightningCssPlugin(_root, result) {
41
- let postcss = require("postcss");
42
- let lightningcss = require("lightningcss");
43
- let browserslist = require("browserslist");
44
- try {
45
- let transformed = lightningcss.transform({
46
- filename: result.opts.from,
47
- code: Buffer.from(result.root.toString()),
48
- minify: false,
49
- sourceMap: !!result.map,
50
- inputSourceMap: result.map ? result.map.toString() : undefined,
51
- targets: typeof process !== "undefined" && process.env.JEST_WORKER_ID ? {
52
- chrome: 106 << 16
53
- } : lightningcss.browserslistToTargets(browserslist(require("../package.json").browserslist)),
54
- drafts: {
55
- nesting: true,
56
- customMedia: true
57
- }
58
- });
59
- var _result_map;
60
- result.map = Object.assign((_result_map = result.map) !== null && _result_map !== void 0 ? _result_map : {}, {
61
- toJSON () {
62
- return transformed.map.toJSON();
63
- },
64
- toString () {
65
- return transformed.map.toString();
66
- }
67
- });
68
- result.root = postcss.parse(transformed.code.toString("utf8"));
69
- } catch (err) {
70
- if (typeof process !== "undefined" && process.env.JEST_WORKER_ID) {
71
- let lines = err.source.split("\n");
72
- err = new Error([
73
- "Error formatting using Lightning CSS:",
74
- "",
75
- ...[
76
- "```css",
77
- ...lines.slice(Math.max(err.loc.line - 3, 0), err.loc.line),
78
- " ".repeat(err.loc.column - 1) + "^-- " + err.toString(),
79
- ...lines.slice(err.loc.line, err.loc.line + 2),
80
- "```"
81
- ]
82
- ].join("\n"));
83
- }
84
- if (Error.captureStackTrace) {
85
- Error.captureStackTrace(err, lightningCssPlugin);
86
- }
87
- throw err;
88
- }
89
- },
90
40
  _sharedState.env.DEBUG && function(root) {
91
41
  console.timeEnd("JIT TOTAL");
92
42
  console.log("\n");
@@ -17,7 +17,6 @@ const _resolveDefaultsAtRules = /*#__PURE__*/ _interop_require_default(require("
17
17
  const _collapseAdjacentRules = /*#__PURE__*/ _interop_require_default(require("./lib/collapseAdjacentRules"));
18
18
  const _collapseDuplicateDeclarations = /*#__PURE__*/ _interop_require_default(require("./lib/collapseDuplicateDeclarations"));
19
19
  const _partitionApplyAtRules = /*#__PURE__*/ _interop_require_default(require("./lib/partitionApplyAtRules"));
20
- const _detectNesting = /*#__PURE__*/ _interop_require_default(require("./lib/detectNesting"));
21
20
  const _setupContextUtils = require("./lib/setupContextUtils");
22
21
  const _featureFlags = require("./featureFlags");
23
22
  function _interop_require_default(obj) {
@@ -28,7 +27,6 @@ function _interop_require_default(obj) {
28
27
  function processTailwindFeatures(setupContext) {
29
28
  return async function(root, result) {
30
29
  let { tailwindDirectives , applyDirectives } = (0, _normalizeTailwindDirectives.default)(root);
31
- (0, _detectNesting.default)()(root, result);
32
30
  // Partition apply rules that are found in the css
33
31
  // itself.
34
32
  (0, _partitionApplyAtRules.default)()(root, result);
@@ -140,7 +140,13 @@ function normalize(value, context = null, isRoot = true) {
140
140
  "keyboard-inset-bottom",
141
141
  "keyboard-inset-left",
142
142
  "keyboard-inset-width",
143
- "keyboard-inset-height"
143
+ "keyboard-inset-height",
144
+ "radial-gradient",
145
+ "linear-gradient",
146
+ "conic-gradient",
147
+ "repeating-radial-gradient",
148
+ "repeating-linear-gradient",
149
+ "repeating-conic-gradient"
144
150
  ];
145
151
  return value.replace(/(calc|min|max|clamp)\(.+\)/g, (match)=>{
146
152
  let result = "";
@@ -186,6 +192,10 @@ function normalize(value, context = null, isRoot = true) {
186
192
  result += consumeUntil([
187
193
  ")"
188
194
  ]);
195
+ } else if (peek("[")) {
196
+ result += consumeUntil([
197
+ "]"
198
+ ]);
189
199
  } else if ([
190
200
  "+",
191
201
  "-",
@@ -390,7 +400,7 @@ let absoluteSizes = new Set([
390
400
  "medium",
391
401
  "large",
392
402
  "x-large",
393
- "x-large",
403
+ "xx-large",
394
404
  "xxx-large"
395
405
  ]);
396
406
  function absoluteSize(value) {
@@ -114,6 +114,9 @@ let elementProperties = {
114
114
  "terminal",
115
115
  "jumpable"
116
116
  ],
117
+ ":where": [],
118
+ ":is": [],
119
+ ":has": [],
117
120
  // The default value is used when the pseudo-element is not recognized
118
121
  // Because it's not recognized, we don't know if it's terminal or not
119
122
  // So we assume it can be moved AND can have user-action pseudo classes attached to it
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwindcss",
3
- "version": "3.4.0",
3
+ "version": "3.4.2",
4
4
  "description": "A utility-first CSS framework for rapidly building custom user interfaces.",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -12,12 +12,9 @@
12
12
  "tailwind": "lib/cli.js",
13
13
  "tailwindcss": "lib/cli.js"
14
14
  },
15
- "tailwindcss": {
16
- "engine": "stable"
17
- },
18
15
  "scripts": {
19
16
  "prebuild": "npm run generate && rimraf lib",
20
- "build": "swc src --out-dir lib --copy-files --config jsc.transform.optimizer.globals.vars.__OXIDE__='\"false\"'",
17
+ "build": "swc src --out-dir lib --copy-files",
21
18
  "postbuild": "esbuild lib/cli-peer-dependencies.js --bundle --platform=node --outfile=peers/index.js --define:process.env.CSS_TRANSFORMER_WASM=false",
22
19
  "rebuild-fixtures": "npm run build && node -r @swc/register scripts/rebuildFixtures.js",
23
20
  "style": "eslint .",
@@ -54,13 +51,13 @@
54
51
  "browserslist": "^4.21.5",
55
52
  "concurrently": "^8.0.1",
56
53
  "cssnano": "^6.0.0",
57
- "esbuild": "^0.17.18",
54
+ "esbuild": "^0.20.2",
58
55
  "eslint": "^8.39.0",
59
56
  "eslint-config-prettier": "^8.8.0",
60
57
  "eslint-plugin-prettier": "^4.2.1",
61
58
  "jest": "^29.6.0",
62
59
  "jest-diff": "^29.6.0",
63
- "lightningcss": "1.18.0",
60
+ "lightningcss": "1.24.1",
64
61
  "prettier": "^2.8.8",
65
62
  "rimraf": "^5.0.0",
66
63
  "source-map-js": "^1.0.2",
@@ -75,7 +72,7 @@
75
72
  "fast-glob": "^3.3.0",
76
73
  "glob-parent": "^6.0.2",
77
74
  "is-glob": "^4.0.3",
78
- "jiti": "^1.19.1",
75
+ "jiti": "^1.21.0",
79
76
  "lilconfig": "^2.1.0",
80
77
  "micromatch": "^4.0.5",
81
78
  "normalize-path": "^3.0.0",