tailwindcss 0.0.0-insiders.f4635e0 → 0.0.0-insiders.f4a2ccd

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 (238) 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 -304
  5. package/defaultConfig.d.ts +3 -0
  6. package/defaultConfig.js +2 -4
  7. package/defaultTheme.d.ts +4 -0
  8. package/defaultTheme.js +2 -4
  9. package/lib/cli/build/deps.js +54 -0
  10. package/lib/cli/build/index.js +52 -0
  11. package/lib/cli/build/plugin.js +376 -0
  12. package/lib/cli/build/utils.js +78 -0
  13. package/lib/cli/build/watching.js +180 -0
  14. package/lib/cli/help/index.js +71 -0
  15. package/lib/cli/index.js +230 -0
  16. package/lib/cli/init/index.js +61 -0
  17. package/lib/cli-peer-dependencies.js +22 -14
  18. package/lib/cli.js +4 -762
  19. package/lib/corePluginList.js +182 -5
  20. package/lib/corePlugins.js +4109 -2952
  21. package/lib/css/preflight.css +24 -9
  22. package/lib/featureFlags.js +68 -50
  23. package/lib/index.js +5 -30
  24. package/lib/lib/cacheInvalidation.js +90 -0
  25. package/lib/lib/collapseAdjacentRules.js +52 -36
  26. package/lib/lib/collapseDuplicateDeclarations.js +83 -0
  27. package/lib/lib/content.js +177 -0
  28. package/lib/lib/defaultExtractor.js +241 -0
  29. package/lib/lib/detectNesting.js +39 -17
  30. package/lib/lib/evaluateTailwindFunctions.js +203 -161
  31. package/lib/lib/expandApplyAtRules.js +503 -221
  32. package/lib/lib/expandTailwindAtRules.js +255 -243
  33. package/lib/lib/findAtConfigPath.js +44 -0
  34. package/lib/lib/generateRules.js +831 -317
  35. package/lib/lib/getModuleDependencies.js +93 -49
  36. package/lib/lib/load-config.js +36 -0
  37. package/lib/lib/normalizeTailwindDirectives.js +79 -60
  38. package/lib/lib/offsets.js +304 -0
  39. package/lib/lib/partitionApplyAtRules.js +56 -0
  40. package/lib/lib/regex.js +60 -0
  41. package/lib/lib/remap-bitfield.js +87 -0
  42. package/lib/lib/resolveDefaultsAtRules.js +150 -94
  43. package/lib/lib/setupContextUtils.js +1197 -685
  44. package/lib/lib/setupTrackingContext.js +150 -177
  45. package/lib/lib/sharedState.js +70 -21
  46. package/lib/lib/substituteScreenAtRules.js +26 -28
  47. package/lib/oxide/cli/build/deps.js +81 -0
  48. package/lib/oxide/cli/build/index.js +51 -0
  49. package/lib/oxide/cli/build/plugin.js +373 -0
  50. package/lib/oxide/cli/build/utils.js +77 -0
  51. package/lib/oxide/cli/build/watching.js +177 -0
  52. package/lib/oxide/cli/help/index.js +70 -0
  53. package/lib/oxide/cli/index.js +214 -0
  54. package/lib/oxide/cli/init/index.js +50 -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 +19 -0
  60. package/lib/postcss-plugins/nesting/plugin.js +87 -0
  61. package/lib/processTailwindFeatures.js +58 -56
  62. package/lib/public/colors.js +353 -0
  63. package/lib/public/create-plugin.js +15 -0
  64. package/lib/public/default-config.js +16 -0
  65. package/lib/public/default-theme.js +16 -0
  66. package/lib/public/load-config.js +10 -0
  67. package/lib/public/resolve-config.js +22 -0
  68. package/lib/util/applyImportantSelector.js +22 -0
  69. package/lib/util/bigSign.js +7 -6
  70. package/lib/util/buildMediaQuery.js +21 -32
  71. package/lib/util/cloneDeep.js +16 -14
  72. package/lib/util/cloneNodes.js +29 -15
  73. package/lib/util/color.js +104 -66
  74. package/lib/util/configurePlugins.js +17 -15
  75. package/lib/util/createPlugin.js +23 -26
  76. package/lib/util/createUtilityPlugin.js +46 -46
  77. package/lib/util/dataTypes.js +266 -0
  78. package/lib/util/defaults.js +20 -15
  79. package/lib/util/escapeClassName.js +18 -17
  80. package/lib/util/escapeCommas.js +7 -6
  81. package/lib/util/flattenColorPalette.js +13 -12
  82. package/lib/util/formatVariantSelector.js +341 -0
  83. package/lib/util/getAllConfigs.js +44 -18
  84. package/lib/util/hashConfig.js +15 -12
  85. package/lib/util/isKeyframeRule.js +7 -6
  86. package/lib/util/isPlainObject.js +11 -11
  87. package/lib/util/isSyntacticallyValidPropertyValue.js +72 -0
  88. package/lib/util/log.js +52 -33
  89. package/lib/util/nameClass.js +35 -29
  90. package/lib/util/negateValue.js +31 -17
  91. package/lib/util/normalizeConfig.js +294 -0
  92. package/lib/util/normalizeScreens.js +170 -0
  93. package/lib/util/parseAnimationValue.js +85 -54
  94. package/lib/util/parseBoxShadowValue.js +84 -0
  95. package/lib/util/parseDependency.js +41 -70
  96. package/lib/util/parseGlob.js +34 -0
  97. package/lib/util/parseObjectStyles.js +30 -24
  98. package/lib/util/pluginUtils.js +234 -288
  99. package/lib/util/prefixSelector.js +33 -19
  100. package/lib/util/removeAlphaVariables.js +29 -0
  101. package/lib/util/resolveConfig.js +221 -256
  102. package/lib/util/resolveConfigPath.js +55 -48
  103. package/lib/util/responsive.js +18 -14
  104. package/lib/util/splitAtTopLevelOnly.js +49 -0
  105. package/lib/util/tap.js +8 -7
  106. package/lib/util/toColorValue.js +7 -6
  107. package/lib/util/toPath.js +27 -8
  108. package/lib/util/transformThemeValue.js +67 -28
  109. package/lib/util/validateConfig.js +24 -0
  110. package/lib/util/validateFormalSyntax.js +24 -0
  111. package/lib/util/withAlphaVariable.js +67 -57
  112. package/loadConfig.d.ts +4 -0
  113. package/loadConfig.js +2 -0
  114. package/nesting/index.js +2 -12
  115. package/package.json +69 -66
  116. package/peers/index.js +76328 -84169
  117. package/plugin.d.ts +11 -0
  118. package/plugin.js +1 -2
  119. package/resolveConfig.d.ts +12 -0
  120. package/resolveConfig.js +2 -7
  121. package/scripts/create-plugin-list.js +2 -2
  122. package/scripts/generate-types.js +105 -0
  123. package/scripts/release-channel.js +18 -0
  124. package/scripts/release-notes.js +21 -0
  125. package/scripts/swap-engines.js +40 -0
  126. package/scripts/type-utils.js +27 -0
  127. package/src/cli/build/deps.js +56 -0
  128. package/src/cli/build/index.js +49 -0
  129. package/src/cli/build/plugin.js +444 -0
  130. package/src/cli/build/utils.js +76 -0
  131. package/src/cli/build/watching.js +229 -0
  132. package/src/cli/help/index.js +70 -0
  133. package/src/cli/index.js +216 -0
  134. package/src/cli/init/index.js +79 -0
  135. package/src/cli-peer-dependencies.js +7 -1
  136. package/src/cli.js +4 -756
  137. package/src/corePluginList.js +1 -1
  138. package/src/corePlugins.js +2526 -1956
  139. package/src/css/preflight.css +24 -9
  140. package/src/featureFlags.js +33 -10
  141. package/src/index.js +4 -33
  142. package/src/lib/cacheInvalidation.js +52 -0
  143. package/src/lib/collapseAdjacentRules.js +21 -2
  144. package/src/lib/collapseDuplicateDeclarations.js +93 -0
  145. package/src/lib/content.js +208 -0
  146. package/src/lib/defaultExtractor.js +217 -0
  147. package/src/lib/detectNesting.js +30 -3
  148. package/src/lib/evaluateTailwindFunctions.js +84 -10
  149. package/src/lib/expandApplyAtRules.js +509 -153
  150. package/src/lib/expandTailwindAtRules.js +125 -104
  151. package/src/lib/findAtConfigPath.js +48 -0
  152. package/src/lib/generateRules.js +678 -70
  153. package/src/lib/getModuleDependencies.js +70 -30
  154. package/src/lib/load-config.ts +27 -0
  155. package/src/lib/normalizeTailwindDirectives.js +10 -3
  156. package/src/lib/offsets.js +373 -0
  157. package/src/lib/partitionApplyAtRules.js +52 -0
  158. package/src/lib/regex.js +74 -0
  159. package/src/lib/remap-bitfield.js +82 -0
  160. package/src/lib/resolveDefaultsAtRules.js +105 -47
  161. package/src/lib/setupContextUtils.js +848 -247
  162. package/src/lib/setupTrackingContext.js +53 -64
  163. package/src/lib/sharedState.js +60 -6
  164. package/src/lib/substituteScreenAtRules.js +6 -3
  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 +18 -3
  180. package/src/public/colors.js +322 -0
  181. package/src/public/create-plugin.js +2 -0
  182. package/src/public/default-config.js +4 -0
  183. package/src/public/default-theme.js +4 -0
  184. package/src/public/load-config.js +2 -0
  185. package/src/public/resolve-config.js +7 -0
  186. package/src/util/applyImportantSelector.js +19 -0
  187. package/src/util/buildMediaQuery.js +14 -16
  188. package/src/util/cloneNodes.js +19 -2
  189. package/src/util/color.js +43 -11
  190. package/src/util/createUtilityPlugin.js +2 -11
  191. package/src/util/dataTypes.js +281 -0
  192. package/src/util/defaults.js +6 -0
  193. package/src/util/formatVariantSelector.js +412 -0
  194. package/src/util/getAllConfigs.js +21 -2
  195. package/src/util/isSyntacticallyValidPropertyValue.js +61 -0
  196. package/src/util/log.js +23 -22
  197. package/src/util/nameClass.js +6 -2
  198. package/src/util/negateValue.js +15 -5
  199. package/src/util/normalizeConfig.js +318 -0
  200. package/src/util/normalizeScreens.js +140 -0
  201. package/src/util/parseAnimationValue.js +7 -1
  202. package/src/util/parseBoxShadowValue.js +72 -0
  203. package/src/util/parseDependency.js +37 -38
  204. package/src/util/parseGlob.js +24 -0
  205. package/src/util/pluginUtils.js +219 -219
  206. package/src/util/prefixSelector.js +30 -13
  207. package/src/util/removeAlphaVariables.js +24 -0
  208. package/src/util/resolveConfig.js +86 -91
  209. package/src/util/resolveConfigPath.js +12 -1
  210. package/src/util/splitAtTopLevelOnly.js +52 -0
  211. package/src/util/toPath.js +23 -1
  212. package/src/util/transformThemeValue.js +33 -8
  213. package/src/util/validateConfig.js +13 -0
  214. package/src/util/validateFormalSyntax.js +34 -0
  215. package/src/util/withAlphaVariable.js +14 -9
  216. package/stubs/.gitignore +1 -0
  217. package/stubs/.prettierrc.json +6 -0
  218. package/stubs/{defaultConfig.stub.js → config.full.js} +332 -249
  219. package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -1
  220. package/stubs/postcss.config.js +6 -0
  221. package/stubs/tailwind.config.cjs +2 -0
  222. package/stubs/tailwind.config.js +2 -0
  223. package/stubs/tailwind.config.ts +3 -0
  224. package/types/config.d.ts +373 -0
  225. package/types/generated/.gitkeep +0 -0
  226. package/types/generated/colors.d.ts +298 -0
  227. package/types/generated/corePluginList.d.ts +1 -0
  228. package/types/generated/default-theme.d.ts +347 -0
  229. package/types/index.d.ts +7 -0
  230. package/CHANGELOG.md +0 -1742
  231. package/lib/constants.js +0 -37
  232. package/lib/lib/setupWatchingContext.js +0 -331
  233. package/nesting/plugin.js +0 -41
  234. package/scripts/install-integrations.js +0 -27
  235. package/scripts/rebuildFixtures.js +0 -68
  236. package/src/constants.js +0 -17
  237. package/src/lib/setupWatchingContext.js +0 -307
  238. /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
@@ -0,0 +1,341 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
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: ()=>formatVariantSelector,
13
+ eliminateIrrelevantSelectors: ()=>eliminateIrrelevantSelectors,
14
+ finalizeSelector: ()=>finalizeSelector,
15
+ handleMergePseudo: ()=>handleMergePseudo
16
+ });
17
+ const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
18
+ const _unesc = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser/dist/util/unesc"));
19
+ const _escapeClassName = /*#__PURE__*/ _interopRequireDefault(require("../util/escapeClassName"));
20
+ const _prefixSelector = /*#__PURE__*/ _interopRequireDefault(require("../util/prefixSelector"));
21
+ function _interopRequireDefault(obj) {
22
+ return obj && obj.__esModule ? obj : {
23
+ default: obj
24
+ };
25
+ }
26
+ /** @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";
27
+ function formatVariantSelector(formats, { context , candidate }) {
28
+ var _context_tailwindConfig_prefix;
29
+ let prefix = (_context_tailwindConfig_prefix = context === null || context === void 0 ? void 0 : context.tailwindConfig.prefix) !== null && _context_tailwindConfig_prefix !== void 0 ? _context_tailwindConfig_prefix : "";
30
+ // Parse the format selector into an AST
31
+ let parsedFormats = formats.map((format)=>{
32
+ let ast = (0, _postcssSelectorParser.default)().astSync(format.format);
33
+ return {
34
+ ...format,
35
+ ast: format.isArbitraryVariant ? ast : (0, _prefixSelector.default)(prefix, ast)
36
+ };
37
+ });
38
+ // We start with the candidate selector
39
+ let formatAst = _postcssSelectorParser.default.root({
40
+ nodes: [
41
+ _postcssSelectorParser.default.selector({
42
+ nodes: [
43
+ _postcssSelectorParser.default.className({
44
+ value: (0, _escapeClassName.default)(candidate)
45
+ })
46
+ ]
47
+ })
48
+ ]
49
+ });
50
+ // And iteratively merge each format selector into the candidate selector
51
+ for (let { ast } of parsedFormats){
52
+ [formatAst, ast] = handleMergePseudo(formatAst, ast);
53
+ // 2. Merge the format selector into the current selector AST
54
+ ast.walkNesting((nesting)=>nesting.replaceWith(...formatAst.nodes[0].nodes));
55
+ // 3. Keep going!
56
+ formatAst = ast;
57
+ }
58
+ return formatAst;
59
+ }
60
+ /**
61
+ * Given any node in a selector this gets the "simple" selector it's a part of
62
+ * A simple selector is just a list of nodes without any combinators
63
+ * Technically :is(), :not(), :has(), etc… can have combinators but those are nested
64
+ * inside the relevant node and won't be picked up so they're fine to ignore
65
+ *
66
+ * @param {Node} node
67
+ * @returns {Node[]}
68
+ **/ function simpleSelectorForNode(node) {
69
+ /** @type {Node[]} */ let nodes = [];
70
+ // Walk backwards until we hit a combinator node (or the start)
71
+ while(node.prev() && node.prev().type !== "combinator"){
72
+ node = node.prev();
73
+ }
74
+ // Now record all non-combinator nodes until we hit one (or the end)
75
+ while(node && node.type !== "combinator"){
76
+ nodes.push(node);
77
+ node = node.next();
78
+ }
79
+ return nodes;
80
+ }
81
+ /**
82
+ * Resorts the nodes in a selector to ensure they're in the correct order
83
+ * Tags go before classes, and pseudo classes go after classes
84
+ *
85
+ * @param {Selector} sel
86
+ * @returns {Selector}
87
+ **/ function resortSelector(sel) {
88
+ sel.sort((a, b)=>{
89
+ if (a.type === "tag" && b.type === "class") {
90
+ return -1;
91
+ } else if (a.type === "class" && b.type === "tag") {
92
+ return 1;
93
+ } else if (a.type === "class" && b.type === "pseudo" && b.value.startsWith("::")) {
94
+ return -1;
95
+ } else if (a.type === "pseudo" && a.value.startsWith("::") && b.type === "class") {
96
+ return 1;
97
+ }
98
+ return sel.index(a) - sel.index(b);
99
+ });
100
+ return sel;
101
+ }
102
+ function eliminateIrrelevantSelectors(sel, base) {
103
+ let hasClassesMatchingCandidate = false;
104
+ sel.walk((child)=>{
105
+ if (child.type === "class" && child.value === base) {
106
+ hasClassesMatchingCandidate = true;
107
+ return false // Stop walking
108
+ ;
109
+ }
110
+ });
111
+ if (!hasClassesMatchingCandidate) {
112
+ sel.remove();
113
+ }
114
+ // We do NOT recursively eliminate sub selectors that don't have the base class
115
+ // as this is NOT a safe operation. For example, if we have:
116
+ // `.space-x-2 > :not([hidden]) ~ :not([hidden])`
117
+ // We cannot remove the [hidden] from the :not() because it would change the
118
+ // meaning of the selector.
119
+ // TODO: Can we do this for :matches, :is, and :where?
120
+ }
121
+ function finalizeSelector(current, formats, { context , candidate , base }) {
122
+ var _context_tailwindConfig;
123
+ var _context_tailwindConfig_separator;
124
+ 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 : ":";
125
+ // Split by the separator, but ignore the separator inside square brackets:
126
+ //
127
+ // E.g.: dark:lg:hover:[paint-order:markers]
128
+ // ┬ ┬ ┬ ┬
129
+ // │ │ │ ╰── We will not split here
130
+ // ╰──┴─────┴─────────────── We will split here
131
+ //
132
+ base = base !== null && base !== void 0 ? base : candidate.split(new RegExp(`\\${separator}(?![^[]*\\])`)).pop();
133
+ // Parse the selector into an AST
134
+ let selector = (0, _postcssSelectorParser.default)().astSync(current);
135
+ // Normalize escaped classes, e.g.:
136
+ //
137
+ // The idea would be to replace the escaped `base` in the selector with the
138
+ // `format`. However, in css you can escape the same selector in a few
139
+ // different ways. This would result in different strings and therefore we
140
+ // can't replace it properly.
141
+ //
142
+ // base: bg-[rgb(255,0,0)]
143
+ // base in selector: bg-\\[rgb\\(255\\,0\\,0\\)\\]
144
+ // escaped base: bg-\\[rgb\\(255\\2c 0\\2c 0\\)\\]
145
+ //
146
+ selector.walkClasses((node)=>{
147
+ if (node.raws && node.value.includes(base)) {
148
+ node.raws.value = (0, _escapeClassName.default)((0, _unesc.default)(node.raws.value));
149
+ }
150
+ });
151
+ // Remove extraneous selectors that do not include the base candidate
152
+ selector.each((sel)=>eliminateIrrelevantSelectors(sel, base));
153
+ // If there are no formats that means there were no variants added to the candidate
154
+ // so we can just return the selector as-is
155
+ let formatAst = Array.isArray(formats) ? formatVariantSelector(formats, {
156
+ context,
157
+ candidate
158
+ }) : formats;
159
+ if (formatAst === null) {
160
+ return selector.toString();
161
+ }
162
+ let simpleStart = _postcssSelectorParser.default.comment({
163
+ value: "/*__simple__*/"
164
+ });
165
+ let simpleEnd = _postcssSelectorParser.default.comment({
166
+ value: "/*__simple__*/"
167
+ });
168
+ // We can safely replace the escaped base now, since the `base` section is
169
+ // now in a normalized escaped value.
170
+ selector.walkClasses((node)=>{
171
+ if (node.value !== base) {
172
+ return;
173
+ }
174
+ let parent = node.parent;
175
+ let formatNodes = formatAst.nodes[0].nodes;
176
+ // Perf optimization: if the parent is a single class we can just replace it and be done
177
+ if (parent.nodes.length === 1) {
178
+ node.replaceWith(...formatNodes);
179
+ return;
180
+ }
181
+ let simpleSelector = simpleSelectorForNode(node);
182
+ parent.insertBefore(simpleSelector[0], simpleStart);
183
+ parent.insertAfter(simpleSelector[simpleSelector.length - 1], simpleEnd);
184
+ for (let child of formatNodes){
185
+ parent.insertBefore(simpleSelector[0], child.clone());
186
+ }
187
+ node.remove();
188
+ // Re-sort the simple selector to ensure it's in the correct order
189
+ simpleSelector = simpleSelectorForNode(simpleStart);
190
+ let firstNode = parent.index(simpleStart);
191
+ parent.nodes.splice(firstNode, simpleSelector.length, ...resortSelector(_postcssSelectorParser.default.selector({
192
+ nodes: simpleSelector
193
+ })).nodes);
194
+ simpleStart.remove();
195
+ simpleEnd.remove();
196
+ });
197
+ // Remove unnecessary pseudo selectors that we used as placeholders
198
+ selector.walkPseudos((p)=>{
199
+ if (p.value === MERGE) {
200
+ p.replaceWith(p.nodes);
201
+ }
202
+ });
203
+ // Move pseudo elements to the end of the selector (if necessary)
204
+ selector.each((sel)=>{
205
+ let pseudoElements = collectPseudoElements(sel);
206
+ if (pseudoElements.length > 0) {
207
+ sel.nodes.push(pseudoElements.sort(sortSelector));
208
+ }
209
+ });
210
+ return selector.toString();
211
+ }
212
+ function handleMergePseudo(selector, format) {
213
+ /** @type {{pseudo: Pseudo, value: string}[]} */ let merges = [];
214
+ // Find all :merge() pseudo-classes in `selector`
215
+ selector.walkPseudos((pseudo)=>{
216
+ if (pseudo.value === MERGE) {
217
+ merges.push({
218
+ pseudo,
219
+ value: pseudo.nodes[0].toString()
220
+ });
221
+ }
222
+ });
223
+ // Find all :merge() "attachments" in `format` and attach them to the matching selector in `selector`
224
+ format.walkPseudos((pseudo)=>{
225
+ if (pseudo.value !== MERGE) {
226
+ return;
227
+ }
228
+ let value = pseudo.nodes[0].toString();
229
+ // Does `selector` contain a :merge() pseudo-class with the same value?
230
+ let existing = merges.find((merge)=>merge.value === value);
231
+ // Nope so there's nothing to do
232
+ if (!existing) {
233
+ return;
234
+ }
235
+ // Everything after `:merge()` up to the next combinator is what is attached to the merged selector
236
+ let attachments = [];
237
+ let next = pseudo.next();
238
+ while(next && next.type !== "combinator"){
239
+ attachments.push(next);
240
+ next = next.next();
241
+ }
242
+ let combinator = next;
243
+ existing.pseudo.parent.insertAfter(existing.pseudo, _postcssSelectorParser.default.selector({
244
+ nodes: attachments.map((node)=>node.clone())
245
+ }));
246
+ pseudo.remove();
247
+ attachments.forEach((node)=>node.remove());
248
+ // What about this case:
249
+ // :merge(.group):focus > &
250
+ // :merge(.group):hover &
251
+ if (combinator && combinator.type === "combinator") {
252
+ combinator.remove();
253
+ }
254
+ });
255
+ return [
256
+ selector,
257
+ format
258
+ ];
259
+ }
260
+ // Note: As a rule, double colons (::) should be used instead of a single colon
261
+ // (:). This distinguishes pseudo-classes from pseudo-elements. However, since
262
+ // this distinction was not present in older versions of the W3C spec, most
263
+ // browsers support both syntaxes for the original pseudo-elements.
264
+ let pseudoElementsBC = [
265
+ ":before",
266
+ ":after",
267
+ ":first-line",
268
+ ":first-letter"
269
+ ];
270
+ // These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
271
+ let pseudoElementExceptions = [
272
+ "::file-selector-button",
273
+ // Webkit scroll bar pseudo elements can be combined with user-action pseudo classes
274
+ "::-webkit-scrollbar",
275
+ "::-webkit-scrollbar-button",
276
+ "::-webkit-scrollbar-thumb",
277
+ "::-webkit-scrollbar-track",
278
+ "::-webkit-scrollbar-track-piece",
279
+ "::-webkit-scrollbar-corner",
280
+ "::-webkit-resizer"
281
+ ];
282
+ /**
283
+ * This will make sure to move pseudo's to the correct spot (the end for
284
+ * pseudo elements) because otherwise the selector will never work
285
+ * anyway.
286
+ *
287
+ * E.g.:
288
+ * - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
289
+ * - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
290
+ *
291
+ * `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
292
+ *
293
+ * @param {Selector} selector
294
+ **/ function collectPseudoElements(selector) {
295
+ /** @type {Node[]} */ let nodes = [];
296
+ for (let node of selector.nodes){
297
+ if (isPseudoElement(node)) {
298
+ nodes.push(node);
299
+ selector.removeChild(node);
300
+ }
301
+ if (node === null || node === void 0 ? void 0 : node.nodes) {
302
+ nodes.push(...collectPseudoElements(node));
303
+ }
304
+ }
305
+ return nodes;
306
+ }
307
+ // This will make sure to move pseudo's to the correct spot (the end for
308
+ // pseudo elements) because otherwise the selector will never work
309
+ // anyway.
310
+ //
311
+ // E.g.:
312
+ // - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
313
+ // - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
314
+ //
315
+ // `::before:hover` doesn't work, which means that we can make it work
316
+ // for you by flipping the order.
317
+ function sortSelector(a, z) {
318
+ // Both nodes are non-pseudo's so we can safely ignore them and keep
319
+ // them in the same order.
320
+ if (a.type !== "pseudo" && z.type !== "pseudo") {
321
+ return 0;
322
+ }
323
+ // If one of them is a combinator, we need to keep it in the same order
324
+ // because that means it will start a new "section" in the selector.
325
+ if (a.type === "combinator" ^ z.type === "combinator") {
326
+ return 0;
327
+ }
328
+ // One of the items is a pseudo and the other one isn't. Let's move
329
+ // the pseudo to the right.
330
+ if (a.type === "pseudo" ^ z.type === "pseudo") {
331
+ return (a.type === "pseudo") - (z.type === "pseudo");
332
+ }
333
+ // Both are pseudo's, move the pseudo elements (except for
334
+ // ::file-selector-button) to the right.
335
+ return isPseudoElement(a) - isPseudoElement(z);
336
+ }
337
+ function isPseudoElement(node) {
338
+ if (node.type !== "pseudo") return false;
339
+ if (pseudoElementExceptions.includes(node.value)) return false;
340
+ return node.value.startsWith("::") || pseudoElementsBC.includes(node.value);
341
+ }
@@ -1,22 +1,48 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.default = getAllConfigs;
7
-
8
- var _defaultConfigStub = _interopRequireDefault(require("../../stubs/defaultConfig.stub.js"));
9
-
10
- var _featureFlags = require("../featureFlags");
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>getAllConfigs
8
+ });
9
+ const _configFullJs = /*#__PURE__*/ _interopRequireDefault(require("../../stubs/config.full.js"));
10
+ const _featureFlags = require("../featureFlags");
11
+ function _interopRequireDefault(obj) {
12
+ return obj && obj.__esModule ? obj : {
13
+ default: obj
14
+ };
15
+ }
14
16
  function getAllConfigs(config) {
15
- var _config$presets;
16
-
17
- const configs = ((_config$presets = config === null || config === void 0 ? void 0 : config.presets) !== null && _config$presets !== void 0 ? _config$presets : [_defaultConfigStub.default]).slice().reverse().flatMap(preset => getAllConfigs(preset instanceof Function ? preset() : preset));
18
- const features = {// Add experimental configs here...
19
- };
20
- const experimentals = Object.keys(features).filter(feature => (0, _featureFlags.flagEnabled)(config, feature)).map(feature => features[feature]);
21
- return [config, ...experimentals, ...configs];
22
- }
17
+ var _config_presets;
18
+ const configs = ((_config_presets = config === null || config === void 0 ? void 0 : config.presets) !== null && _config_presets !== void 0 ? _config_presets : [
19
+ _configFullJs.default
20
+ ]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset));
21
+ const features = {
22
+ // Add experimental configs here...
23
+ respectDefaultRingColorOpacity: {
24
+ theme: {
25
+ ringColor: ({ theme })=>({
26
+ DEFAULT: "#3b82f67f",
27
+ ...theme("colors")
28
+ })
29
+ }
30
+ },
31
+ disableColorOpacityUtilitiesByDefault: {
32
+ corePlugins: {
33
+ backgroundOpacity: false,
34
+ borderOpacity: false,
35
+ divideOpacity: false,
36
+ placeholderOpacity: false,
37
+ ringOpacity: false,
38
+ textOpacity: false
39
+ }
40
+ }
41
+ };
42
+ const experimentals = Object.keys(features).filter((feature)=>(0, _featureFlags.flagEnabled)(config, feature)).map((feature)=>features[feature]);
43
+ return [
44
+ config,
45
+ ...experimentals,
46
+ ...configs
47
+ ];
48
+ }
@@ -1,16 +1,19 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.default = hashConfig;
7
-
8
- var _objectHash = _interopRequireDefault(require("object-hash"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>hashConfig
8
+ });
9
+ const _objectHash = /*#__PURE__*/ _interopRequireDefault(require("object-hash"));
10
+ function _interopRequireDefault(obj) {
11
+ return obj && obj.__esModule ? obj : {
12
+ default: obj
13
+ };
14
+ }
12
15
  function hashConfig(config) {
13
- return (0, _objectHash.default)(config, {
14
- ignoreUnknown: true
15
- });
16
- }
16
+ return (0, _objectHash.default)(config, {
17
+ ignoreUnknown: true
18
+ });
19
+ }
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>isKeyframeRule
5
8
  });
6
- exports.default = isKeyframeRule;
7
-
8
9
  function isKeyframeRule(rule) {
9
- return rule.parent && rule.parent.type === 'atrule' && /keyframes$/.test(rule.parent.name);
10
- }
10
+ return rule.parent && rule.parent.type === "atrule" && /keyframes$/.test(rule.parent.name);
11
+ }
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>isPlainObject
5
8
  });
6
- exports.default = isPlainObject;
7
-
8
9
  function isPlainObject(value) {
9
- if (Object.prototype.toString.call(value) !== '[object Object]') {
10
- return false;
11
- }
12
-
13
- const prototype = Object.getPrototypeOf(value);
14
- return prototype === null || prototype === Object.prototype;
15
- }
10
+ if (Object.prototype.toString.call(value) !== "[object Object]") {
11
+ return false;
12
+ }
13
+ const prototype = Object.getPrototypeOf(value);
14
+ return prototype === null || prototype === Object.prototype;
15
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
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: ()=>isSyntacticallyValidPropertyValue
14
+ });
15
+ let matchingBrackets = new Map([
16
+ [
17
+ "{",
18
+ "}"
19
+ ],
20
+ [
21
+ "[",
22
+ "]"
23
+ ],
24
+ [
25
+ "(",
26
+ ")"
27
+ ]
28
+ ]);
29
+ let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v])=>[
30
+ v,
31
+ k
32
+ ]));
33
+ let quotes = new Set([
34
+ '"',
35
+ "'",
36
+ "`"
37
+ ]);
38
+ function isSyntacticallyValidPropertyValue(value) {
39
+ let stack = [];
40
+ let inQuotes = false;
41
+ for(let i = 0; i < value.length; i++){
42
+ let char = value[i];
43
+ if (char === ":" && !inQuotes && stack.length === 0) {
44
+ return false;
45
+ }
46
+ // Non-escaped quotes allow us to "allow" anything in between
47
+ if (quotes.has(char) && value[i - 1] !== "\\") {
48
+ inQuotes = !inQuotes;
49
+ }
50
+ if (inQuotes) continue;
51
+ if (value[i - 1] === "\\") continue; // Escaped
52
+ if (matchingBrackets.has(char)) {
53
+ stack.push(char);
54
+ } else if (inverseMatchingBrackets.has(char)) {
55
+ let inverse = inverseMatchingBrackets.get(char);
56
+ // Nothing to pop from, therefore it is unbalanced
57
+ if (stack.length <= 0) {
58
+ return false;
59
+ }
60
+ // Popped value must match the inverse value, otherwise it is unbalanced
61
+ if (stack.pop() !== inverse) {
62
+ return false;
63
+ }
64
+ }
65
+ }
66
+ // If there is still something on the stack, it is also unbalanced
67
+ if (stack.length > 0) {
68
+ return false;
69
+ }
70
+ // All good, totally balanced!
71
+ return true;
72
+ }
package/lib/util/log.js CHANGED
@@ -1,38 +1,57 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.default = void 0;
7
-
8
- var _chalk = _interopRequireDefault(require("chalk"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- var _default = {
13
- info(messages) {
14
- if (process.env.JEST_WORKER_ID !== undefined) return;
15
- console.warn('');
16
- messages.forEach(message => {
17
- console.warn(_chalk.default.bold.cyan('info'), '-', message);
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
18
9
  });
19
- },
20
-
21
- warn(messages) {
22
- if (process.env.JEST_WORKER_ID !== undefined) return;
23
- console.warn('');
24
- messages.forEach(message => {
25
- console.warn(_chalk.default.bold.yellow('warn'), '-', message);
26
- });
27
- },
28
-
29
- risk(messages) {
30
- if (process.env.JEST_WORKER_ID !== undefined) return;
31
- console.warn('');
32
- messages.forEach(message => {
33
- console.warn(_chalk.default.bold.magenta('risk'), '-', message);
34
- });
35
- }
36
-
10
+ }
11
+ _export(exports, {
12
+ dim: ()=>dim,
13
+ default: ()=>_default
14
+ });
15
+ const _picocolors = /*#__PURE__*/ _interopRequireDefault(require("picocolors"));
16
+ function _interopRequireDefault(obj) {
17
+ return obj && obj.__esModule ? obj : {
18
+ default: obj
19
+ };
20
+ }
21
+ let alreadyShown = new Set();
22
+ function log(type, messages, key) {
23
+ if (typeof process !== "undefined" && process.env.JEST_WORKER_ID) return;
24
+ if (key && alreadyShown.has(key)) return;
25
+ if (key) alreadyShown.add(key);
26
+ console.warn("");
27
+ messages.forEach((message)=>console.warn(type, "-", message));
28
+ }
29
+ function dim(input) {
30
+ return _picocolors.default.dim(input);
31
+ }
32
+ const _default = {
33
+ info (key, messages) {
34
+ log(_picocolors.default.bold(_picocolors.default.cyan("info")), ...Array.isArray(key) ? [
35
+ key
36
+ ] : [
37
+ messages,
38
+ key
39
+ ]);
40
+ },
41
+ warn (key, messages) {
42
+ log(_picocolors.default.bold(_picocolors.default.yellow("warn")), ...Array.isArray(key) ? [
43
+ key
44
+ ] : [
45
+ messages,
46
+ key
47
+ ]);
48
+ },
49
+ risk (key, messages) {
50
+ log(_picocolors.default.bold(_picocolors.default.magenta("risk")), ...Array.isArray(key) ? [
51
+ key
52
+ ] : [
53
+ messages,
54
+ key
55
+ ]);
56
+ }
37
57
  };
38
- exports.default = _default;