tailwindcss 0.0.0-insiders.ea139f2 → 0.0.0-insiders.ea4e1cd

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 (236) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +15 -7
  3. package/colors.d.ts +3 -0
  4. package/colors.js +2 -1
  5. package/defaultConfig.d.ts +3 -0
  6. package/defaultConfig.js +2 -1
  7. package/defaultTheme.d.ts +4 -0
  8. package/defaultTheme.js +2 -1
  9. package/lib/cli/build/deps.js +62 -0
  10. package/lib/cli/build/index.js +54 -0
  11. package/lib/cli/build/plugin.js +378 -0
  12. package/lib/cli/build/utils.js +88 -0
  13. package/lib/cli/build/watching.js +182 -0
  14. package/lib/cli/help/index.js +73 -0
  15. package/lib/cli/index.js +230 -0
  16. package/lib/cli/init/index.js +63 -0
  17. package/lib/cli-peer-dependencies.js +28 -7
  18. package/lib/cli.js +4 -703
  19. package/lib/corePluginList.js +12 -3
  20. package/lib/corePlugins.js +2373 -1863
  21. package/lib/css/preflight.css +10 -8
  22. package/lib/featureFlags.js +49 -26
  23. package/lib/index.js +1 -31
  24. package/lib/lib/cacheInvalidation.js +92 -0
  25. package/lib/lib/collapseAdjacentRules.js +30 -10
  26. package/lib/lib/collapseDuplicateDeclarations.js +60 -4
  27. package/lib/lib/content.js +181 -0
  28. package/lib/lib/defaultExtractor.js +243 -0
  29. package/lib/lib/detectNesting.js +21 -10
  30. package/lib/lib/evaluateTailwindFunctions.js +115 -50
  31. package/lib/lib/expandApplyAtRules.js +467 -161
  32. package/lib/lib/expandTailwindAtRules.js +160 -133
  33. package/lib/lib/findAtConfigPath.js +46 -0
  34. package/lib/lib/generateRules.js +553 -200
  35. package/lib/lib/getModuleDependencies.js +88 -37
  36. package/lib/lib/load-config.js +42 -0
  37. package/lib/lib/normalizeTailwindDirectives.js +46 -33
  38. package/lib/lib/offsets.js +306 -0
  39. package/lib/lib/partitionApplyAtRules.js +58 -0
  40. package/lib/lib/regex.js +74 -0
  41. package/lib/lib/remap-bitfield.js +89 -0
  42. package/lib/lib/resolveDefaultsAtRules.js +98 -58
  43. package/lib/lib/setupContextUtils.js +773 -321
  44. package/lib/lib/setupTrackingContext.js +70 -75
  45. package/lib/lib/sharedState.js +78 -10
  46. package/lib/lib/substituteScreenAtRules.js +14 -10
  47. package/lib/oxide/cli/build/deps.js +89 -0
  48. package/lib/oxide/cli/build/index.js +53 -0
  49. package/lib/oxide/cli/build/plugin.js +375 -0
  50. package/lib/oxide/cli/build/utils.js +87 -0
  51. package/lib/oxide/cli/build/watching.js +179 -0
  52. package/lib/oxide/cli/help/index.js +72 -0
  53. package/lib/oxide/cli/index.js +214 -0
  54. package/lib/oxide/cli/init/index.js +52 -0
  55. package/lib/oxide/cli.js +5 -0
  56. package/lib/oxide/postcss-plugin.js +2 -0
  57. package/lib/plugin.js +98 -0
  58. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  59. package/lib/postcss-plugins/nesting/index.js +21 -0
  60. package/lib/postcss-plugins/nesting/plugin.js +89 -0
  61. package/lib/processTailwindFeatures.js +39 -26
  62. package/lib/public/colors.js +272 -246
  63. package/lib/public/create-plugin.js +9 -5
  64. package/lib/public/default-config.js +10 -6
  65. package/lib/public/default-theme.js +10 -6
  66. package/lib/public/load-config.js +12 -0
  67. package/lib/public/resolve-config.js +11 -6
  68. package/lib/util/applyImportantSelector.js +36 -0
  69. package/lib/util/bigSign.js +6 -1
  70. package/lib/util/buildMediaQuery.js +13 -6
  71. package/lib/util/cloneDeep.js +9 -6
  72. package/lib/util/cloneNodes.js +23 -3
  73. package/lib/util/color.js +70 -38
  74. package/lib/util/colorNames.js +752 -0
  75. package/lib/util/configurePlugins.js +7 -2
  76. package/lib/util/createPlugin.js +8 -6
  77. package/lib/util/createUtilityPlugin.js +16 -16
  78. package/lib/util/dataTypes.js +173 -108
  79. package/lib/util/defaults.js +14 -3
  80. package/lib/util/escapeClassName.js +13 -8
  81. package/lib/util/escapeCommas.js +7 -2
  82. package/lib/util/flattenColorPalette.js +11 -12
  83. package/lib/util/formatVariantSelector.js +228 -151
  84. package/lib/util/getAllConfigs.js +33 -12
  85. package/lib/util/hashConfig.js +9 -4
  86. package/lib/util/isKeyframeRule.js +7 -2
  87. package/lib/util/isPlainObject.js +7 -2
  88. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +25 -15
  89. package/lib/util/log.js +27 -13
  90. package/lib/util/nameClass.js +27 -10
  91. package/lib/util/negateValue.js +25 -8
  92. package/lib/util/normalizeConfig.js +139 -65
  93. package/lib/util/normalizeScreens.js +131 -11
  94. package/lib/util/parseAnimationValue.js +44 -40
  95. package/lib/util/parseBoxShadowValue.js +34 -23
  96. package/lib/util/parseDependency.js +39 -55
  97. package/lib/util/parseGlob.js +36 -0
  98. package/lib/util/parseObjectStyles.js +15 -10
  99. package/lib/util/pluginUtils.js +159 -69
  100. package/lib/util/prefixSelector.js +30 -12
  101. package/lib/util/pseudoElements.js +229 -0
  102. package/lib/util/removeAlphaVariables.js +31 -0
  103. package/lib/util/resolveConfig.js +97 -75
  104. package/lib/util/resolveConfigPath.js +30 -12
  105. package/lib/util/responsive.js +11 -6
  106. package/lib/util/splitAtTopLevelOnly.js +51 -0
  107. package/lib/util/tap.js +6 -1
  108. package/lib/util/toColorValue.js +7 -3
  109. package/lib/util/toPath.js +26 -3
  110. package/lib/util/transformThemeValue.js +40 -30
  111. package/lib/util/validateConfig.js +37 -0
  112. package/lib/util/validateFormalSyntax.js +26 -0
  113. package/lib/util/withAlphaVariable.js +27 -15
  114. package/loadConfig.d.ts +4 -0
  115. package/loadConfig.js +2 -0
  116. package/nesting/index.js +2 -12
  117. package/package.json +66 -57
  118. package/peers/index.js +75964 -55560
  119. package/plugin.d.ts +11 -0
  120. package/plugin.js +2 -1
  121. package/resolveConfig.d.ts +12 -0
  122. package/resolveConfig.js +2 -1
  123. package/scripts/generate-types.js +105 -0
  124. package/scripts/release-channel.js +18 -0
  125. package/scripts/release-notes.js +21 -0
  126. package/scripts/swap-engines.js +40 -0
  127. package/scripts/type-utils.js +27 -0
  128. package/src/cli/build/deps.js +56 -0
  129. package/src/cli/build/index.js +49 -0
  130. package/src/cli/build/plugin.js +444 -0
  131. package/src/cli/build/utils.js +76 -0
  132. package/src/cli/build/watching.js +229 -0
  133. package/src/cli/help/index.js +70 -0
  134. package/src/cli/index.js +216 -0
  135. package/src/cli/init/index.js +79 -0
  136. package/src/cli-peer-dependencies.js +7 -1
  137. package/src/cli.js +4 -765
  138. package/src/corePluginList.js +1 -1
  139. package/src/corePlugins.js +786 -306
  140. package/src/css/preflight.css +10 -8
  141. package/src/featureFlags.js +21 -5
  142. package/src/index.js +1 -34
  143. package/src/lib/cacheInvalidation.js +52 -0
  144. package/src/lib/collapseAdjacentRules.js +21 -2
  145. package/src/lib/collapseDuplicateDeclarations.js +66 -1
  146. package/src/lib/content.js +208 -0
  147. package/src/lib/defaultExtractor.js +217 -0
  148. package/src/lib/detectNesting.js +9 -1
  149. package/src/lib/evaluateTailwindFunctions.js +79 -8
  150. package/src/lib/expandApplyAtRules.js +515 -153
  151. package/src/lib/expandTailwindAtRules.js +115 -86
  152. package/src/lib/findAtConfigPath.js +48 -0
  153. package/src/lib/generateRules.js +545 -147
  154. package/src/lib/getModuleDependencies.js +70 -30
  155. package/src/lib/load-config.ts +31 -0
  156. package/src/lib/normalizeTailwindDirectives.js +7 -1
  157. package/src/lib/offsets.js +373 -0
  158. package/src/lib/partitionApplyAtRules.js +52 -0
  159. package/src/lib/regex.js +74 -0
  160. package/src/lib/remap-bitfield.js +82 -0
  161. package/src/lib/resolveDefaultsAtRules.js +59 -17
  162. package/src/lib/setupContextUtils.js +701 -175
  163. package/src/lib/setupTrackingContext.js +51 -62
  164. package/src/lib/sharedState.js +58 -7
  165. package/src/oxide/cli/build/deps.ts +91 -0
  166. package/src/oxide/cli/build/index.ts +47 -0
  167. package/src/oxide/cli/build/plugin.ts +442 -0
  168. package/src/oxide/cli/build/utils.ts +74 -0
  169. package/src/oxide/cli/build/watching.ts +225 -0
  170. package/src/oxide/cli/help/index.ts +69 -0
  171. package/src/oxide/cli/index.ts +204 -0
  172. package/src/oxide/cli/init/index.ts +59 -0
  173. package/src/oxide/cli.ts +1 -0
  174. package/src/oxide/postcss-plugin.ts +1 -0
  175. package/src/plugin.js +107 -0
  176. package/src/postcss-plugins/nesting/README.md +42 -0
  177. package/src/postcss-plugins/nesting/index.js +13 -0
  178. package/src/postcss-plugins/nesting/plugin.js +80 -0
  179. package/src/processTailwindFeatures.js +12 -2
  180. package/src/public/colors.js +22 -0
  181. package/src/public/default-config.js +1 -1
  182. package/src/public/default-theme.js +2 -2
  183. package/src/public/load-config.js +2 -0
  184. package/src/util/applyImportantSelector.js +27 -0
  185. package/src/util/buildMediaQuery.js +5 -3
  186. package/src/util/cloneNodes.js +19 -2
  187. package/src/util/color.js +44 -12
  188. package/src/util/colorNames.js +150 -0
  189. package/src/util/dataTypes.js +51 -16
  190. package/src/util/defaults.js +6 -0
  191. package/src/util/formatVariantSelector.js +264 -144
  192. package/src/util/getAllConfigs.js +21 -2
  193. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  194. package/src/util/log.js +11 -7
  195. package/src/util/nameClass.js +4 -0
  196. package/src/util/negateValue.js +11 -3
  197. package/src/util/normalizeConfig.js +57 -5
  198. package/src/util/normalizeScreens.js +105 -7
  199. package/src/util/parseBoxShadowValue.js +4 -3
  200. package/src/util/parseDependency.js +37 -42
  201. package/src/util/parseGlob.js +24 -0
  202. package/src/util/pluginUtils.js +123 -24
  203. package/src/util/prefixSelector.js +30 -10
  204. package/src/util/pseudoElements.js +170 -0
  205. package/src/util/removeAlphaVariables.js +24 -0
  206. package/src/util/resolveConfig.js +74 -26
  207. package/src/util/resolveConfigPath.js +12 -1
  208. package/src/util/splitAtTopLevelOnly.js +52 -0
  209. package/src/util/toPath.js +23 -1
  210. package/src/util/transformThemeValue.js +13 -3
  211. package/src/util/validateConfig.js +26 -0
  212. package/src/util/validateFormalSyntax.js +34 -0
  213. package/src/util/withAlphaVariable.js +1 -1
  214. package/stubs/.gitignore +1 -0
  215. package/stubs/.prettierrc.json +6 -0
  216. package/stubs/{defaultConfig.stub.js → config.full.js} +206 -166
  217. package/stubs/postcss.config.js +6 -0
  218. package/stubs/tailwind.config.cjs +2 -0
  219. package/stubs/tailwind.config.js +2 -0
  220. package/stubs/tailwind.config.ts +3 -0
  221. package/types/config.d.ts +368 -0
  222. package/types/generated/.gitkeep +0 -0
  223. package/types/generated/colors.d.ts +298 -0
  224. package/types/generated/corePluginList.d.ts +1 -0
  225. package/types/generated/default-theme.d.ts +371 -0
  226. package/types/index.d.ts +7 -0
  227. package/CHANGELOG.md +0 -1843
  228. package/lib/constants.js +0 -37
  229. package/lib/lib/setupWatchingContext.js +0 -288
  230. package/nesting/plugin.js +0 -41
  231. package/scripts/install-integrations.js +0 -27
  232. package/scripts/rebuildFixtures.js +0 -68
  233. package/src/constants.js +0 -17
  234. package/src/lib/setupWatchingContext.js +0 -311
  235. /package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -0
  236. /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
@@ -2,45 +2,135 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.formatVariantSelector = formatVariantSelector;
6
- exports.finalizeSelector = finalizeSelector;
7
- exports.selectorFunctions = void 0;
8
- var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
9
- var _unesc = _interopRequireDefault(require("postcss-selector-parser/dist/util/unesc"));
10
- var _escapeClassName = _interopRequireDefault(require("../util/escapeClassName"));
11
- var _prefixSelector = _interopRequireDefault(require("../util/prefixSelector"));
12
- function _interopRequireDefault(obj) {
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ formatVariantSelector: function() {
13
+ return formatVariantSelector;
14
+ },
15
+ eliminateIrrelevantSelectors: function() {
16
+ return eliminateIrrelevantSelectors;
17
+ },
18
+ finalizeSelector: function() {
19
+ return finalizeSelector;
20
+ },
21
+ handleMergePseudo: function() {
22
+ return handleMergePseudo;
23
+ }
24
+ });
25
+ const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser"));
26
+ const _unesc = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser/dist/util/unesc"));
27
+ const _escapeClassName = /*#__PURE__*/ _interop_require_default(require("../util/escapeClassName"));
28
+ const _prefixSelector = /*#__PURE__*/ _interop_require_default(require("../util/prefixSelector"));
29
+ const _pseudoElements = require("./pseudoElements");
30
+ function _interop_require_default(obj) {
13
31
  return obj && obj.__esModule ? obj : {
14
32
  default: obj
15
33
  };
16
34
  }
17
- let MERGE = ':merge';
18
- let PARENT = '&';
19
- let selectorFunctions = new Set([
20
- MERGE
21
- ]);
22
- exports.selectorFunctions = selectorFunctions;
23
- function formatVariantSelector(current, ...others) {
24
- for (let other of others){
25
- let incomingValue = resolveFunctionArgument(other, MERGE);
26
- if (incomingValue !== null) {
27
- let existingValue = resolveFunctionArgument(current, MERGE, incomingValue);
28
- if (existingValue !== null) {
29
- let existingTarget = `${MERGE}(${incomingValue})`;
30
- let splitIdx = other.indexOf(existingTarget);
31
- let addition = other.slice(splitIdx + existingTarget.length).split(' ')[0];
32
- current = current.replace(existingTarget, existingTarget + addition);
33
- continue;
34
- }
35
+ /** @typedef {import('postcss-selector-parser').Root} Root */ /** @typedef {import('postcss-selector-parser').Selector} Selector */ /** @typedef {import('postcss-selector-parser').Pseudo} Pseudo */ /** @typedef {import('postcss-selector-parser').Node} Node */ /** @typedef {{format: string, isArbitraryVariant: boolean}[]} RawFormats */ /** @typedef {import('postcss-selector-parser').Root} ParsedFormats */ /** @typedef {RawFormats | ParsedFormats} AcceptedFormats */ let MERGE = ":merge";
36
+ function formatVariantSelector(formats, { context , candidate }) {
37
+ var _context_tailwindConfig_prefix;
38
+ let prefix = (_context_tailwindConfig_prefix = context === null || context === void 0 ? void 0 : context.tailwindConfig.prefix) !== null && _context_tailwindConfig_prefix !== void 0 ? _context_tailwindConfig_prefix : "";
39
+ // Parse the format selector into an AST
40
+ let parsedFormats = formats.map((format)=>{
41
+ let ast = (0, _postcssselectorparser.default)().astSync(format.format);
42
+ return {
43
+ ...format,
44
+ ast: format.isArbitraryVariant ? ast : (0, _prefixSelector.default)(prefix, ast)
45
+ };
46
+ });
47
+ // We start with the candidate selector
48
+ let formatAst = _postcssselectorparser.default.root({
49
+ nodes: [
50
+ _postcssselectorparser.default.selector({
51
+ nodes: [
52
+ _postcssselectorparser.default.className({
53
+ value: (0, _escapeClassName.default)(candidate)
54
+ })
55
+ ]
56
+ })
57
+ ]
58
+ });
59
+ // And iteratively merge each format selector into the candidate selector
60
+ for (let { ast } of parsedFormats){
61
+ [formatAst, ast] = handleMergePseudo(formatAst, ast);
62
+ // 2. Merge the format selector into the current selector AST
63
+ ast.walkNesting((nesting)=>nesting.replaceWith(...formatAst.nodes[0].nodes));
64
+ // 3. Keep going!
65
+ formatAst = ast;
66
+ }
67
+ return formatAst;
68
+ }
69
+ /**
70
+ * Given any node in a selector this gets the "simple" selector it's a part of
71
+ * A simple selector is just a list of nodes without any combinators
72
+ * Technically :is(), :not(), :has(), etc… can have combinators but those are nested
73
+ * inside the relevant node and won't be picked up so they're fine to ignore
74
+ *
75
+ * @param {Node} node
76
+ * @returns {Node[]}
77
+ **/ function simpleSelectorForNode(node) {
78
+ /** @type {Node[]} */ let nodes = [];
79
+ // Walk backwards until we hit a combinator node (or the start)
80
+ while(node.prev() && node.prev().type !== "combinator"){
81
+ node = node.prev();
82
+ }
83
+ // Now record all non-combinator nodes until we hit one (or the end)
84
+ while(node && node.type !== "combinator"){
85
+ nodes.push(node);
86
+ node = node.next();
87
+ }
88
+ return nodes;
89
+ }
90
+ /**
91
+ * Resorts the nodes in a selector to ensure they're in the correct order
92
+ * Tags go before classes, and pseudo classes go after classes
93
+ *
94
+ * @param {Selector} sel
95
+ * @returns {Selector}
96
+ **/ function resortSelector(sel) {
97
+ sel.sort((a, b)=>{
98
+ if (a.type === "tag" && b.type === "class") {
99
+ return -1;
100
+ } else if (a.type === "class" && b.type === "tag") {
101
+ return 1;
102
+ } else if (a.type === "class" && b.type === "pseudo" && b.value.startsWith("::")) {
103
+ return -1;
104
+ } else if (a.type === "pseudo" && a.value.startsWith("::") && b.type === "class") {
105
+ return 1;
35
106
  }
36
- current = other.replace(PARENT, current);
107
+ return sel.index(a) - sel.index(b);
108
+ });
109
+ return sel;
110
+ }
111
+ function eliminateIrrelevantSelectors(sel, base) {
112
+ let hasClassesMatchingCandidate = false;
113
+ sel.walk((child)=>{
114
+ if (child.type === "class" && child.value === base) {
115
+ hasClassesMatchingCandidate = true;
116
+ return false // Stop walking
117
+ ;
118
+ }
119
+ });
120
+ if (!hasClassesMatchingCandidate) {
121
+ sel.remove();
37
122
  }
38
- return current;
123
+ // We do NOT recursively eliminate sub selectors that don't have the base class
124
+ // as this is NOT a safe operation. For example, if we have:
125
+ // `.space-x-2 > :not([hidden]) ~ :not([hidden])`
126
+ // We cannot remove the [hidden] from the :not() because it would change the
127
+ // meaning of the selector.
128
+ // TODO: Can we do this for :matches, :is, and :where?
39
129
  }
40
- function finalizeSelector(format, { selector: selector1 , candidate , context }) {
41
- var ref, ref1;
42
- var ref2;
43
- let separator = (ref2 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref2 !== void 0 ? ref2 : ':';
130
+ function finalizeSelector(current, formats, { context , candidate , base }) {
131
+ var _context_tailwindConfig;
132
+ var _context_tailwindConfig_separator;
133
+ let separator = (_context_tailwindConfig_separator = context === null || context === void 0 ? void 0 : (_context_tailwindConfig = context.tailwindConfig) === null || _context_tailwindConfig === void 0 ? void 0 : _context_tailwindConfig.separator) !== null && _context_tailwindConfig_separator !== void 0 ? _context_tailwindConfig_separator : ":";
44
134
  // Split by the separator, but ignore the separator inside square brackets:
45
135
  //
46
136
  // E.g.: dark:lg:hover:[paint-order:markers]
@@ -48,12 +138,9 @@ function finalizeSelector(format, { selector: selector1 , candidate , context }
48
138
  // │ │ │ ╰── We will not split here
49
139
  // ╰──┴─────┴─────────────── We will split here
50
140
  //
51
- let splitter = new RegExp(`\\${separator}(?![^[]*\\])`);
52
- let base = candidate.split(splitter).pop();
53
- if (context === null || context === void 0 ? void 0 : (ref1 = context.tailwindConfig) === null || ref1 === void 0 ? void 0 : ref1.prefix) {
54
- format = (0, _prefixSelector).default(context.tailwindConfig.prefix, format);
55
- }
56
- format = format.replace(PARENT, `.${(0, _escapeClassName).default(candidate)}`);
141
+ base = base !== null && base !== void 0 ? base : candidate.split(new RegExp(`\\${separator}(?![^[]*\\])`)).pop();
142
+ // Parse the selector into an AST
143
+ let selector = (0, _postcssselectorparser.default)().astSync(current);
57
144
  // Normalize escaped classes, e.g.:
58
145
  //
59
146
  // The idea would be to replace the escaped `base` in the selector with the
@@ -65,122 +152,112 @@ function finalizeSelector(format, { selector: selector1 , candidate , context }
65
152
  // base in selector: bg-\\[rgb\\(255\\,0\\,0\\)\\]
66
153
  // escaped base: bg-\\[rgb\\(255\\2c 0\\2c 0\\)\\]
67
154
  //
68
- selector1 = (0, _postcssSelectorParser).default((selectors)=>{
69
- return selectors.walkClasses((node)=>{
70
- if (node.raws && node.value.includes(base)) {
71
- node.raws.value = (0, _escapeClassName).default((0, _unesc).default(node.raws.value));
72
- }
73
- return node;
74
- });
75
- }).processSync(selector1);
155
+ selector.walkClasses((node)=>{
156
+ if (node.raws && node.value.includes(base)) {
157
+ node.raws.value = (0, _escapeClassName.default)((0, _unesc.default)(node.raws.value));
158
+ }
159
+ });
160
+ // Remove extraneous selectors that do not include the base candidate
161
+ selector.each((sel)=>eliminateIrrelevantSelectors(sel, base));
162
+ // If there are no formats that means there were no variants added to the candidate
163
+ // so we can just return the selector as-is
164
+ let formatAst = Array.isArray(formats) ? formatVariantSelector(formats, {
165
+ context,
166
+ candidate
167
+ }) : formats;
168
+ if (formatAst === null) {
169
+ return selector.toString();
170
+ }
171
+ let simpleStart = _postcssselectorparser.default.comment({
172
+ value: "/*__simple__*/"
173
+ });
174
+ let simpleEnd = _postcssselectorparser.default.comment({
175
+ value: "/*__simple__*/"
176
+ });
76
177
  // We can safely replace the escaped base now, since the `base` section is
77
178
  // now in a normalized escaped value.
78
- selector1 = selector1.replace(`.${(0, _escapeClassName).default(base)}`, format);
179
+ selector.walkClasses((node)=>{
180
+ if (node.value !== base) {
181
+ return;
182
+ }
183
+ let parent = node.parent;
184
+ let formatNodes = formatAst.nodes[0].nodes;
185
+ // Perf optimization: if the parent is a single class we can just replace it and be done
186
+ if (parent.nodes.length === 1) {
187
+ node.replaceWith(...formatNodes);
188
+ return;
189
+ }
190
+ let simpleSelector = simpleSelectorForNode(node);
191
+ parent.insertBefore(simpleSelector[0], simpleStart);
192
+ parent.insertAfter(simpleSelector[simpleSelector.length - 1], simpleEnd);
193
+ for (let child of formatNodes){
194
+ parent.insertBefore(simpleSelector[0], child.clone());
195
+ }
196
+ node.remove();
197
+ // Re-sort the simple selector to ensure it's in the correct order
198
+ simpleSelector = simpleSelectorForNode(simpleStart);
199
+ let firstNode = parent.index(simpleStart);
200
+ parent.nodes.splice(firstNode, simpleSelector.length, ...resortSelector(_postcssselectorparser.default.selector({
201
+ nodes: simpleSelector
202
+ })).nodes);
203
+ simpleStart.remove();
204
+ simpleEnd.remove();
205
+ });
79
206
  // Remove unnecessary pseudo selectors that we used as placeholders
80
- return (0, _postcssSelectorParser).default((selectors)=>{
81
- return selectors.map((selector2)=>{
82
- selector2.walkPseudos((p)=>{
83
- if (selectorFunctions.has(p.value)) {
84
- p.replaceWith(p.nodes);
85
- }
86
- return p;
87
- });
88
- // This will make sure to move pseudo's to the correct spot (the end for
89
- // pseudo elements) because otherwise the selector will never work
90
- // anyway.
91
- //
92
- // E.g.:
93
- // - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
94
- // - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
95
- //
96
- // `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
97
- function collectPseudoElements(selector) {
98
- let nodes = [];
99
- for (let node of selector.nodes){
100
- if (isPseudoElement(node)) {
101
- nodes.push(node);
102
- selector.removeChild(node);
103
- }
104
- if (node === null || node === void 0 ? void 0 : node.nodes) {
105
- nodes.push(...collectPseudoElements(node));
106
- }
107
- }
108
- return nodes;
109
- }
110
- let pseudoElements = collectPseudoElements(selector2);
111
- if (pseudoElements.length > 0) {
112
- selector2.nodes.push(pseudoElements.sort(sortSelector));
113
- }
114
- return selector2;
115
- });
116
- }).processSync(selector1);
117
- }
118
- // Note: As a rule, double colons (::) should be used instead of a single colon
119
- // (:). This distinguishes pseudo-classes from pseudo-elements. However, since
120
- // this distinction was not present in older versions of the W3C spec, most
121
- // browsers support both syntaxes for the original pseudo-elements.
122
- let pseudoElementsBC = [
123
- ':before',
124
- ':after',
125
- ':first-line',
126
- ':first-letter'
127
- ];
128
- // These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
129
- let pseudoElementExceptions = [
130
- '::file-selector-button'
131
- ];
132
- // This will make sure to move pseudo's to the correct spot (the end for
133
- // pseudo elements) because otherwise the selector will never work
134
- // anyway.
135
- //
136
- // E.g.:
137
- // - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
138
- // - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
139
- //
140
- // `::before:hover` doesn't work, which means that we can make it work
141
- // for you by flipping the order.
142
- function sortSelector(a, z) {
143
- // Both nodes are non-pseudo's so we can safely ignore them and keep
144
- // them in the same order.
145
- if (a.type !== 'pseudo' && z.type !== 'pseudo') {
146
- return 0;
147
- }
148
- // If one of them is a combinator, we need to keep it in the same order
149
- // because that means it will start a new "section" in the selector.
150
- if (a.type === 'combinator' ^ z.type === 'combinator') {
151
- return 0;
152
- }
153
- // One of the items is a pseudo and the other one isn't. Let's move
154
- // the pseudo to the right.
155
- if (a.type === 'pseudo' ^ z.type === 'pseudo') {
156
- return (a.type === 'pseudo') - (z.type === 'pseudo');
157
- }
158
- // Both are pseudo's, move the pseudo elements (except for
159
- // ::file-selector-button) to the right.
160
- return isPseudoElement(a) - isPseudoElement(z);
161
- }
162
- function isPseudoElement(node) {
163
- if (node.type !== 'pseudo') return false;
164
- if (pseudoElementExceptions.includes(node.value)) return false;
165
- return node.value.startsWith('::') || pseudoElementsBC.includes(node.value);
207
+ selector.walkPseudos((p)=>{
208
+ if (p.value === MERGE) {
209
+ p.replaceWith(p.nodes);
210
+ }
211
+ });
212
+ // Move pseudo elements to the end of the selector (if necessary)
213
+ selector.each((sel)=>(0, _pseudoElements.movePseudos)(sel));
214
+ return selector.toString();
166
215
  }
167
- function resolveFunctionArgument(haystack, needle, arg) {
168
- let startIdx = haystack.indexOf(arg ? `${needle}(${arg})` : needle);
169
- if (startIdx === -1) return null;
170
- // Start inside the `(`
171
- startIdx += needle.length + 1;
172
- let target = '';
173
- let count = 0;
174
- for (let char of haystack.slice(startIdx)){
175
- if (char !== '(' && char !== ')') {
176
- target += char;
177
- } else if (char === '(') {
178
- target += char;
179
- count++;
180
- } else if (char === ')') {
181
- if (--count < 0) break; // unbalanced
182
- target += char;
216
+ function handleMergePseudo(selector, format) {
217
+ /** @type {{pseudo: Pseudo, value: string}[]} */ let merges = [];
218
+ // Find all :merge() pseudo-classes in `selector`
219
+ selector.walkPseudos((pseudo)=>{
220
+ if (pseudo.value === MERGE) {
221
+ merges.push({
222
+ pseudo,
223
+ value: pseudo.nodes[0].toString()
224
+ });
183
225
  }
184
- }
185
- return target;
226
+ });
227
+ // Find all :merge() "attachments" in `format` and attach them to the matching selector in `selector`
228
+ format.walkPseudos((pseudo)=>{
229
+ if (pseudo.value !== MERGE) {
230
+ return;
231
+ }
232
+ let value = pseudo.nodes[0].toString();
233
+ // Does `selector` contain a :merge() pseudo-class with the same value?
234
+ let existing = merges.find((merge)=>merge.value === value);
235
+ // Nope so there's nothing to do
236
+ if (!existing) {
237
+ return;
238
+ }
239
+ // Everything after `:merge()` up to the next combinator is what is attached to the merged selector
240
+ let attachments = [];
241
+ let next = pseudo.next();
242
+ while(next && next.type !== "combinator"){
243
+ attachments.push(next);
244
+ next = next.next();
245
+ }
246
+ let combinator = next;
247
+ existing.pseudo.parent.insertAfter(existing.pseudo, _postcssselectorparser.default.selector({
248
+ nodes: attachments.map((node)=>node.clone())
249
+ }));
250
+ pseudo.remove();
251
+ attachments.forEach((node)=>node.remove());
252
+ // What about this case:
253
+ // :merge(.group):focus > &
254
+ // :merge(.group):hover &
255
+ if (combinator && combinator.type === "combinator") {
256
+ combinator.remove();
257
+ }
258
+ });
259
+ return [
260
+ selector,
261
+ format
262
+ ];
186
263
  }
@@ -2,25 +2,46 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = getAllConfigs;
6
- var _defaultConfigStubJs = _interopRequireDefault(require("../../stubs/defaultConfig.stub.js"));
7
- var _featureFlags = require("../featureFlags");
8
- function _interopRequireDefault(obj) {
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getAllConfigs;
9
+ }
10
+ });
11
+ const _configfull = /*#__PURE__*/ _interop_require_default(require("../../stubs/config.full.js"));
12
+ const _featureFlags = require("../featureFlags");
13
+ function _interop_require_default(obj) {
9
14
  return obj && obj.__esModule ? obj : {
10
15
  default: obj
11
16
  };
12
17
  }
13
18
  function getAllConfigs(config) {
14
- var ref;
15
- const configs = ((ref = config === null || config === void 0 ? void 0 : config.presets) !== null && ref !== void 0 ? ref : [
16
- _defaultConfigStubJs.default
17
- ]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset)
18
- );
19
+ var _config_presets;
20
+ const configs = ((_config_presets = config === null || config === void 0 ? void 0 : config.presets) !== null && _config_presets !== void 0 ? _config_presets : [
21
+ _configfull.default
22
+ ]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset));
19
23
  const features = {
24
+ // Add experimental configs here...
25
+ respectDefaultRingColorOpacity: {
26
+ theme: {
27
+ ringColor: ({ theme })=>({
28
+ DEFAULT: "#3b82f67f",
29
+ ...theme("colors")
30
+ })
31
+ }
32
+ },
33
+ disableColorOpacityUtilitiesByDefault: {
34
+ corePlugins: {
35
+ backgroundOpacity: false,
36
+ borderOpacity: false,
37
+ divideOpacity: false,
38
+ placeholderOpacity: false,
39
+ ringOpacity: false,
40
+ textOpacity: false
41
+ }
42
+ }
20
43
  };
21
- const experimentals = Object.keys(features).filter((feature)=>(0, _featureFlags).flagEnabled(config, feature)
22
- ).map((feature)=>features[feature]
23
- );
44
+ const experimentals = Object.keys(features).filter((feature)=>(0, _featureFlags.flagEnabled)(config, feature)).map((feature)=>features[feature]);
24
45
  return [
25
46
  config,
26
47
  ...experimentals,
@@ -2,15 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = hashConfig;
6
- var _objectHash = _interopRequireDefault(require("object-hash"));
7
- function _interopRequireDefault(obj) {
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return hashConfig;
9
+ }
10
+ });
11
+ const _objecthash = /*#__PURE__*/ _interop_require_default(require("object-hash"));
12
+ function _interop_require_default(obj) {
8
13
  return obj && obj.__esModule ? obj : {
9
14
  default: obj
10
15
  };
11
16
  }
12
17
  function hashConfig(config) {
13
- return (0, _objectHash).default(config, {
18
+ return (0, _objecthash.default)(config, {
14
19
  ignoreUnknown: true
15
20
  });
16
21
  }
@@ -2,7 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = isKeyframeRule;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return isKeyframeRule;
9
+ }
10
+ });
6
11
  function isKeyframeRule(rule) {
7
- return rule.parent && rule.parent.type === 'atrule' && /keyframes$/.test(rule.parent.name);
12
+ return rule.parent && rule.parent.type === "atrule" && /keyframes$/.test(rule.parent.name);
8
13
  }
@@ -2,9 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = isPlainObject;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return isPlainObject;
9
+ }
10
+ });
6
11
  function isPlainObject(value) {
7
- if (Object.prototype.toString.call(value) !== '[object Object]') {
12
+ if (Object.prototype.toString.call(value) !== "[object Object]") {
8
13
  return false;
9
14
  }
10
15
  const prototype = Object.getPrototypeOf(value);
@@ -2,45 +2,55 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = isValidArbitraryValue;
5
+ Object.defineProperty(exports, // Arbitrary values must contain balanced brackets (), [] and {}. Escaped
6
+ // values don't count, and brackets inside quotes also don't count.
7
+ //
8
+ // E.g.: w-[this-is]w-[weird-and-invalid]
9
+ // E.g.: w-[this-is\\]w-\\[weird-but-valid]
10
+ // E.g.: content-['this-is-also-valid]-weirdly-enough']
11
+ "default", {
12
+ enumerable: true,
13
+ get: function() {
14
+ return isSyntacticallyValidPropertyValue;
15
+ }
16
+ });
6
17
  let matchingBrackets = new Map([
7
18
  [
8
- '{',
9
- '}'
19
+ "{",
20
+ "}"
10
21
  ],
11
22
  [
12
- '[',
13
- ']'
23
+ "[",
24
+ "]"
14
25
  ],
15
26
  [
16
- '(',
17
- ')'
18
- ],
27
+ "(",
28
+ ")"
29
+ ]
19
30
  ]);
20
31
  let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v])=>[
21
32
  v,
22
33
  k
23
- ]
24
- ));
34
+ ]));
25
35
  let quotes = new Set([
26
36
  '"',
27
37
  "'",
28
- '`'
38
+ "`"
29
39
  ]);
30
- function isValidArbitraryValue(value) {
40
+ function isSyntacticallyValidPropertyValue(value) {
31
41
  let stack = [];
32
42
  let inQuotes = false;
33
43
  for(let i = 0; i < value.length; i++){
34
44
  let char = value[i];
35
- if (char === ':' && !inQuotes && stack.length === 0) {
45
+ if (char === ":" && !inQuotes && stack.length === 0) {
36
46
  return false;
37
47
  }
38
48
  // Non-escaped quotes allow us to "allow" anything in between
39
- if (quotes.has(char) && value[i - 1] !== '\\') {
49
+ if (quotes.has(char) && value[i - 1] !== "\\") {
40
50
  inQuotes = !inQuotes;
41
51
  }
42
52
  if (inQuotes) continue;
43
- if (value[i - 1] === '\\') continue; // Escaped
53
+ if (value[i - 1] === "\\") continue; // Escaped
44
54
  if (matchingBrackets.has(char)) {
45
55
  stack.push(char);
46
56
  } else if (inverseMatchingBrackets.has(char)) {